From: Leif Åstrand Date: Wed, 11 Apr 2012 16:42:10 +0000 (+0300) Subject: Don't assume scrolling elements have no inline overflow style (#8615) X-Git-Tag: 7.0.0.alpha2~65^2~3 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=b210e23295d1a4bc71b7fa65cd7aa24997dea255;p=vaadin-framework.git Don't assume scrolling elements have no inline overflow style (#8615) --- diff --git a/src/com/vaadin/terminal/gwt/client/LayoutManager.java b/src/com/vaadin/terminal/gwt/client/LayoutManager.java index 40823f4bee..4ec5523156 100644 --- a/src/com/vaadin/terminal/gwt/client/LayoutManager.java +++ b/src/com/vaadin/terminal/gwt/client/LayoutManager.java @@ -349,20 +349,42 @@ public class LayoutManager { boolean measureAll) { if (!pendingOverflowFixes.isEmpty()) { Duration duration = new Duration(); + + HashMap originalOverflows = new HashMap(); + + // First set overflow to hidden (and save previous value so it can + // be restored later) for (ComponentConnector componentConnector : pendingOverflowFixes) { - Style style = componentConnector.getWidget().getElement() - .getParentElement().getStyle(); - assert (style.getOverflow() == null); + Element parentElement = componentConnector.getWidget() + .getElement().getParentElement(); + Style style = parentElement.getStyle(); + String originalOverflow = style.getOverflow(); + + if (originalOverflow != null + && !originalOverflows.containsKey(parentElement)) { + // Store original value for restore, but only the first time + // the value is changed + originalOverflows.put(parentElement, originalOverflow); + } + style.setOverflow(Overflow.HIDDEN); } + + // Then ensure all scrolling elements are reflowed by measuring for (ComponentConnector componentConnector : pendingOverflowFixes) { componentConnector.getWidget().getElement().getParentElement() .getOffsetHeight(); } + + // Finally restore old overflow value and update bookkeeping for (ComponentConnector componentConnector : pendingOverflowFixes) { - componentConnector.getWidget().getElement().getParentElement() - .getStyle().clearOverflow(); + Element parentElement = componentConnector.getWidget() + .getElement().getParentElement(); + parentElement.getStyle().setProperty("overflow", + originalOverflows.get(parentElement)); + layoutDependencyTree.setNeedsMeasure(componentConnector, true); + ComponentContainerConnector parent = componentConnector .getParent(); if (parent instanceof ManagedLayout) {