Browse Source

Force more reflows in IE8 to detect icon style (#8313)

tags/7.0.0.alpha2
Leif Åstrand 12 years ago
parent
commit
688910a21d
1 changed files with 21 additions and 13 deletions
  1. 21
    13
      src/com/vaadin/terminal/gwt/client/ui/VFilterSelect.java

+ 21
- 13
src/com/vaadin/terminal/gwt/client/ui/VFilterSelect.java View File

if (iconUri == null || iconUri.length() == 0) { if (iconUri == null || iconUri.length() == 0) {
if (selectedItemIcon.isAttached()) { if (selectedItemIcon.isAttached()) {
panel.remove(selectedItemIcon); panel.remove(selectedItemIcon);
if (BrowserInfo.get().isIE8()) {
forceReflow();
}
updateRootWidth(); updateRootWidth();
} }
} else { } else {
panel.insert(selectedItemIcon, 0);
selectedItemIcon.setUrl(iconUri); selectedItemIcon.setUrl(iconUri);
panel.insert(selectedItemIcon, 0);
if (BrowserInfo.get().isIE8()) {
forceReflow();
}
updateRootWidth(); updateRootWidth();
updateSelectedIconPosition(); updateSelectedIconPosition();
} }
} }


private void forceReflow() {
Style style = tb.getElement().getStyle();

String oldZoom = style.getProperty("zoom");
style.setProperty("zoom", "1");

// Forces reflow because style has changed
tb.getOffsetWidth();

// Restore old style
style.setProperty("zoom", oldZoom);
}

/** /**
* Positions the icon vertically in the middle. Should be called after the * Positions the icon vertically in the middle. Should be called after the
* icon has loaded * icon has loaded
* Lock the textbox width to its current value if it's not already * Lock the textbox width to its current value if it's not already
* locked * locked
*/ */
Style style = tb.getElement().getStyle();
if (!style.getWidth().endsWith("px")) {
boolean isIE8 = BrowserInfo.get().isIE8();
if (isIE8) {
// Must do something to make IE8 realize that it should
// reflow the component when the offset width is read
style.setProperty("zoom", "1");
}
if (!tb.getElement().getStyle().getWidth().endsWith("px")) {
tb.setWidth((tb.getOffsetWidth() - selectedItemIcon tb.setWidth((tb.getOffsetWidth() - selectedItemIcon
.getOffsetWidth()) + "px"); .getOffsetWidth()) + "px");
if (isIE8) {
// Restore old style property value
style.clearProperty("zoom");
}
} }
} }
} }

Loading…
Cancel
Save