From a2b47fe091044ab4702362e27c66c8cf88f768cb Mon Sep 17 00:00:00 2001 From: =?utf8?q?Leif=20=C3=85strand?= Date: Tue, 13 Mar 2012 10:32:19 +0200 Subject: [PATCH] Run a new layout phase after VScrollTable.sizeInit (#8313) --- .../gwt/client/ApplicationConnection.java | 25 +++++++++++++------ .../terminal/gwt/client/LayoutManager.java | 11 ++++++++ .../terminal/gwt/client/ui/VScrollTable.java | 4 ++- 3 files changed, 32 insertions(+), 8 deletions(-) diff --git a/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java b/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java index 869c387a2f..7bd8199992 100644 --- a/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java +++ b/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java @@ -2071,21 +2071,32 @@ public class ApplicationConnection { eventIdentifier); } - private boolean layoutScheduled = false; + private boolean layoutPending = false; private ScheduledCommand layoutCommand = new ScheduledCommand() { public void execute() { - layoutScheduled = false; - - layoutManager.doLayout(); + /* + * Layout again if a new layout is requested while the current one + * is running. + */ + while (layoutPending) { + layoutPending = false; + layoutManager.doLayout(); + } } }; public void doLayout(boolean lazy) { + layoutPending = true; if (!lazy) { layoutCommand.execute(); - } else if (!layoutScheduled) { - layoutScheduled = true; - Scheduler.get().scheduleDeferred(layoutCommand); + } else if (!layoutPending) { + /* + * Current layoutCommand will do layouts again if layoutScheduled is + * set to true -> no need to schedule another command + */ + if (!layoutManager.isLayoutRunning()) { + Scheduler.get().scheduleDeferred(layoutCommand); + } } } diff --git a/src/com/vaadin/terminal/gwt/client/LayoutManager.java b/src/com/vaadin/terminal/gwt/client/LayoutManager.java index 3adfc017fd..44b652b530 100644 --- a/src/com/vaadin/terminal/gwt/client/LayoutManager.java +++ b/src/com/vaadin/terminal/gwt/client/LayoutManager.java @@ -17,6 +17,7 @@ public class LayoutManager { private final ApplicationConnection connection; private final Set nonPaintableElements = new HashSet(); private final MeasuredSize nullSize = new MeasuredSize(); + private boolean layoutRunning = false; public LayoutManager(ApplicationConnection connection) { this.connection = connection; @@ -101,8 +102,17 @@ public class LayoutManager { } } + public boolean isLayoutRunning() { + return layoutRunning; + } + public void doLayout() { + if (layoutRunning) { + throw new IllegalStateException( + "Can't start a new layout phase before the previous layout phase ends."); + } VConsole.log("Starting layout phase"); + layoutRunning = true; ConnectorMap paintableMap = connection.getConnectorMap(); ComponentConnector[] paintableWidgets = paintableMap @@ -225,6 +235,7 @@ public class LayoutManager { } } + layoutRunning = false; VConsole.log("Total layout phase time: " + totalDuration.elapsedMillis() + "ms"); } diff --git a/src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java b/src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java index 6a08ccb7df..809a4dcb72 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java @@ -1862,6 +1862,8 @@ public class VScrollTable extends FlowPanel implements HasWidgets, Util.runWebkitOverflowAutoFix(scrollBodyPanel.getElement()); } }); + + client.doLayout(true); } /** @@ -5511,7 +5513,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets, scrollBodyPanel.setScrollPosition(scrollTop - 1); } - sizeInit(); + sizeNeedsInit = true; } } -- 2.39.5