From 7182665fde6fdedb721ef72efd5412432b4d13a9 Mon Sep 17 00:00:00 2001 From: Patrik Lindström Date: Thu, 15 Aug 2013 15:36:36 +0300 Subject: Fix scrollbar for Window under WebKit browsers (#11994) Change-Id: Ie39d521c2f299bca0e2175fd8bb59beaa4f66241 --- client/src/com/vaadin/client/ui/VWindow.java | 31 ++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'client') diff --git a/client/src/com/vaadin/client/ui/VWindow.java b/client/src/com/vaadin/client/ui/VWindow.java index 1331eb106a..ff6a15e597 100644 --- a/client/src/com/vaadin/client/ui/VWindow.java +++ b/client/src/com/vaadin/client/ui/VWindow.java @@ -342,6 +342,37 @@ public class VWindow extends VOverlay implements ShortcutActionHandlerOwner, if (!visibilityChangesDisabled) { super.setVisible(visible); } + + if (visible && BrowserInfo.get().isWebkit()) { + + /* + * Shake up the DOM a bit to make the window shed unnecessary + * scrollbars and resize correctly afterwards. This resulting code + * took over a week to summon forth, and involved some pretty hairy + * black magic. Don't touch it unless you know what you're doing! + * Fixes ticket #11994 + */ + Scheduler.get().scheduleFinally(new ScheduledCommand() { + @Override + public void execute() { + final com.google.gwt.dom.client.Element scrollable = contents + .getFirstChildElement(); + final String oldWidth = scrollable.getStyle().getWidth(); + final String oldHeight = scrollable.getStyle().getHeight(); + + scrollable.getStyle().setWidth(110, Unit.PCT); + scrollable.getOffsetWidth(); + scrollable.getStyle().setProperty("width", oldWidth); + + scrollable.getStyle().setHeight(110, Unit.PCT); + scrollable.getOffsetHeight(); + scrollable.getStyle().setProperty("height", oldHeight); + + updateContentsSize(); + positionOrSizeUpdated(); + } + }); + } } /** For internal use only. May be removed or replaced in the future. */ -- cgit v1.2.3