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

@@ -1150,16 +1150,35 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler,
if (iconUri == null || iconUri.length() == 0) {
if (selectedItemIcon.isAttached()) {
panel.remove(selectedItemIcon);
if (BrowserInfo.get().isIE8()) {
forceReflow();
}
updateRootWidth();
}
} else {
panel.insert(selectedItemIcon, 0);
selectedItemIcon.setUrl(iconUri);
panel.insert(selectedItemIcon, 0);
if (BrowserInfo.get().isIE8()) {
forceReflow();
}
updateRootWidth();
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
* icon has loaded
@@ -1605,20 +1624,9 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler,
* Lock the textbox width to its current value if it's not already
* 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
.getOffsetWidth()) + "px");
if (isIE8) {
// Restore old style property value
style.clearProperty("zoom");
}
}
}
}

Loading…
Cancel
Save