From 9f41984a9b36ab49303fa02d9cb756b4377d85b9 Mon Sep 17 00:00:00 2001 From: Jouni Koivuviita Date: Sun, 20 May 2012 22:30:36 +0300 Subject: [PATCH] Small optimization to BoxLayout By setting vertical alignment to all components in a horizontal layout with undefined height the layout will skip lots of measurements. --- .../gwt/client/ui/AbstractBoxLayoutConnector.java | 11 +++++------ .../components/orderedlayout/BoxLayoutTest.java | 12 ++++++------ 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/com/vaadin/terminal/gwt/client/ui/AbstractBoxLayoutConnector.java b/src/com/vaadin/terminal/gwt/client/ui/AbstractBoxLayoutConnector.java index 752e567f4c..25d917b7e8 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/AbstractBoxLayoutConnector.java +++ b/src/com/vaadin/terminal/gwt/client/ui/AbstractBoxLayoutConnector.java @@ -283,12 +283,11 @@ public abstract class AbstractBoxLayoutConnector extends }; private boolean needsFixedHeight() { - if (!getWidget().vertical && isUndefinedHeight() - && (hasRelativeHeight.size() > 0 /* - * || - * hasVerticalAlignment.size() - * > 0 - */)) { + if (!getWidget().vertical + && isUndefinedHeight() + && (hasRelativeHeight.size() > 0 || (hasVerticalAlignment + .size() > 0 && hasVerticalAlignment.size() < getChildren() + .size()))) { return true; } return false; diff --git a/tests/testbench/com/vaadin/tests/components/orderedlayout/BoxLayoutTest.java b/tests/testbench/com/vaadin/tests/components/orderedlayout/BoxLayoutTest.java index 5e2de2f262..f41bc35d0e 100644 --- a/tests/testbench/com/vaadin/tests/components/orderedlayout/BoxLayoutTest.java +++ b/tests/testbench/com/vaadin/tests/components/orderedlayout/BoxLayoutTest.java @@ -57,13 +57,13 @@ public class BoxLayoutTest extends AbstractTestRoot { view.setMargin(true); view.setSpacing(true); - view.addComponent(createControls(false)); - view.addComponent(createTestLayout(false)); - view.setExpandRatio(view.getComponent(1), 1); + // view.addComponent(createControls(false)); + // view.addComponent(createTestLayout(false)); + // view.setExpandRatio(view.getComponent(1), 1); - // for (int i = 0; i < 20; i++) { - // view.addComponent(createHorizontalTest()); - // } + for (int i = 0; i < 200; i++) { + view.addComponent(createHorizontalTest()); + } setContent(view); getApplication().setRootPreserved(true); -- 2.39.5