From b396e4779bb8e423af065e7a25640fa404142f2f Mon Sep 17 00:00:00 2001 From: =?utf8?q?Leif=20=C3=85strand?= Date: Fri, 18 Jan 2013 15:22:34 +0200 Subject: [PATCH] Reimplement zero size component checking for analyze layouts (#10792) Change-Id: Idcc3571fea86cc1114d7124117be738cb8a82934 --- .../vaadin/client/ApplicationConnection.java | 34 ++++++++++++++----- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/client/src/com/vaadin/client/ApplicationConnection.java b/client/src/com/vaadin/client/ApplicationConnection.java index 4a3215bb21..bc260a2bbc 100644 --- a/client/src/com/vaadin/client/ApplicationConnection.java +++ b/client/src/com/vaadin/client/ApplicationConnection.java @@ -220,10 +220,6 @@ public class ApplicationConnection { private boolean validatingLayouts = false; - private Set zeroWidthComponents = null; - - private Set zeroHeightComponents = null; - private final LayoutManager layoutManager; private final RpcManager rpcManager; @@ -1408,8 +1404,6 @@ public class ApplicationConnection { getConnectorMap().clear(); if (meta.containsKey("invalidLayouts")) { validatingLayouts = true; - zeroWidthComponents = new HashSet(); - zeroHeightComponents = new HashSet(); } } if (meta.containsKey("timedRedirect")) { @@ -1540,11 +1534,13 @@ public class ApplicationConnection { applicationRunning = false; } if (validatingLayouts) { + Set zeroHeightComponents = new HashSet(); + Set zeroWidthComponents = new HashSet(); + findZeroSizeComponents(zeroHeightComponents, + zeroWidthComponents, getUIConnector()); VConsole.printLayoutProblems(meta, ApplicationConnection.this, zeroHeightComponents, zeroWidthComponents); - zeroHeightComponents = null; - zeroWidthComponents = null; validatingLayouts = false; } @@ -2201,6 +2197,28 @@ public class ApplicationConnection { ApplicationConfiguration.runWhenDependenciesLoaded(c); } + private void findZeroSizeComponents( + Set zeroHeightComponents, + Set zeroWidthComponents, + ComponentConnector connector) { + Widget widget = connector.getWidget(); + ComputedStyle computedStyle = new ComputedStyle(widget.getElement()); + if (computedStyle.getIntProperty("height") == 0) { + zeroHeightComponents.add(connector); + } + if (computedStyle.getIntProperty("width") == 0) { + zeroWidthComponents.add(connector); + } + List children = connector.getChildren(); + for (ServerConnector serverConnector : children) { + if (serverConnector instanceof ComponentConnector) { + findZeroSizeComponents(zeroHeightComponents, + zeroWidthComponents, + (ComponentConnector) serverConnector); + } + } + } + private void loadStyleDependencies(JsArrayString dependencies) { // Assuming no reason to interpret in a defined order ResourceLoadListener resourceLoadListener = new ResourceLoadListener() { -- 2.39.5