diff options
author | John Ahlroos <john@vaadin.com> | 2012-09-13 11:02:13 +0300 |
---|---|---|
committer | John Ahlroos <john@vaadin.com> | 2012-09-13 11:02:13 +0300 |
commit | eef6af3029923b6ad9076e264394bfa8b9b4b789 (patch) | |
tree | a622577e9f2360faa8254d7874b5ee355a9f8fef /client | |
parent | 0bd47dcbb4813d08ecba6941ac63465f21cfde0b (diff) | |
download | vaadin-framework-eef6af3029923b6ad9076e264394bfa8b9b4b789.tar.gz vaadin-framework-eef6af3029923b6ad9076e264394bfa8b9b4b789.zip |
Ensures negative height is not returned in HorizontalLayout height calculations #9596
Diffstat (limited to 'client')
-rw-r--r-- | client/src/com/vaadin/client/ui/AbstractComponentConnector.java | 4 | ||||
-rw-r--r-- | client/src/com/vaadin/client/ui/orderedlayout/AbstractOrderedLayoutConnector.java | 42 |
2 files changed, 37 insertions, 9 deletions
diff --git a/client/src/com/vaadin/client/ui/AbstractComponentConnector.java b/client/src/com/vaadin/client/ui/AbstractComponentConnector.java index c40dc27581..b1d31370b3 100644 --- a/client/src/com/vaadin/client/ui/AbstractComponentConnector.java +++ b/client/src/com/vaadin/client/ui/AbstractComponentConnector.java @@ -230,12 +230,12 @@ public abstract class AbstractComponentConnector extends AbstractConnector @Override public boolean isRelativeHeight() { - return getState().height != null && getState().height.endsWith("%"); + return ComponentStateUtil.isRelativeHeight(getState()); } @Override public boolean isRelativeWidth() { - return getState().width != null && getState().width.endsWith("%"); + return ComponentStateUtil.isRelativeWidth(getState()); } @Override diff --git a/client/src/com/vaadin/client/ui/orderedlayout/AbstractOrderedLayoutConnector.java b/client/src/com/vaadin/client/ui/orderedlayout/AbstractOrderedLayoutConnector.java index 7092109d11..8fb7b6d936 100644 --- a/client/src/com/vaadin/client/ui/orderedlayout/AbstractOrderedLayoutConnector.java +++ b/client/src/com/vaadin/client/ui/orderedlayout/AbstractOrderedLayoutConnector.java @@ -404,14 +404,29 @@ public abstract class AbstractOrderedLayoutConnector extends * Does the layout need a fixed height? */ private boolean needsFixedHeight() { - if (!getWidget().vertical - && isUndefinedHeight() - && (hasRelativeHeight.size() > 0 || (hasVerticalAlignment - .size() > 0 && hasVerticalAlignment.size() < getChildren() - .size()))) { - return true; + boolean isVertical = getWidget().vertical; + boolean hasChildrenWithVerticalAlignmentCenterOrBottom = !hasVerticalAlignment + .isEmpty(); + boolean allChildrenHasVerticalAlignmentCenterOrBottom = hasVerticalAlignment + .size() == getChildren().size(); + + if(isVertical){ + return false; } - return false; + + else if(!isUndefinedHeight()){ + return false; + } + + else if (!hasChildrenWithVerticalAlignmentCenterOrBottom) { + return false; + } + + else if (allChildrenHasVerticalAlignmentCenterOrBottom) { + return false; + } + + return true; } /** @@ -493,6 +508,7 @@ public abstract class AbstractOrderedLayoutConnector extends private void updateLayoutHeight() { if (needsFixedHeight()) { int h = getMaxHeight(); + assert(h >= 0); h += getLayoutManager().getBorderHeight(getWidget().getElement()) + getLayoutManager().getPaddingHeight( getWidget().getElement()); @@ -518,6 +534,12 @@ public abstract class AbstractOrderedLayoutConnector extends (Element) el.getParentElement().cast()); if (needsMeasure.contains(el)) { int h = getLayoutManager().getOuterHeight(el); + if (h == -1) { + // Height has not yet been measured so using a more + // conventional method instead. + h = Util.getRequiredHeight(el); + } + String sHeight = el.getStyle().getHeight(); // Only add the caption size to the height of the slot if // coption position is top or bottom @@ -531,6 +553,12 @@ public abstract class AbstractOrderedLayoutConnector extends } } else { int h = getLayoutManager().getOuterHeight(el); + if (h == -1) { + // Height has not yet been measured so using a more + // conventional method instead. + h = Util.getRequiredHeight(el); + } + if (childCaptionElementHeight.containsKey(el) && (pos == CaptionPosition.TOP || pos == CaptionPosition.BOTTOM)) { h += childCaptionElementHeight.get(el); |