From b210e23295d1a4bc71b7fa65cd7aa24997dea255 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Leif=20=C3=85strand?= Date: Wed, 11 Apr 2012 19:42:10 +0300 Subject: [PATCH] Don't assume scrolling elements have no inline overflow style (#8615) --- .../terminal/gwt/client/LayoutManager.java | 32 ++++++++++++++++--- 1 file changed, 27 insertions(+), 5 deletions(-) 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) { -- 2.39.5