diff options
author | Juuso Valli <juuso@vaadin.com> | 2014-05-23 11:00:48 +0300 |
---|---|---|
committer | Juuso Valli <juuso@vaadin.com> | 2014-05-23 11:00:48 +0300 |
commit | af9dadbf3517b76e86e0e60452661dc07b178e57 (patch) | |
tree | 719bfe5fab3625cb9c994b1bac5499a5975fb9eb | |
parent | dda3797ee1c89aa2d62a2b99e2fde8967aa95b81 (diff) | |
download | vaadin-framework-af9dadbf3517b76e86e0e60452661dc07b178e57.tar.gz vaadin-framework-af9dadbf3517b76e86e0e60452661dc07b178e57.zip |
Fix caption listener leak and caption measurement (#13741)
Reverting the previous fix to caption measurement, it caused a leak with
the listeners.
Change-Id: If1c06db692c0e829d91528eceb49a9a07f58ed4a
-rw-r--r-- | client/src/com/vaadin/client/ui/orderedlayout/AbstractOrderedLayoutConnector.java | 14 | ||||
-rw-r--r-- | client/src/com/vaadin/client/ui/orderedlayout/Slot.java | 23 |
2 files changed, 13 insertions, 24 deletions
diff --git a/client/src/com/vaadin/client/ui/orderedlayout/AbstractOrderedLayoutConnector.java b/client/src/com/vaadin/client/ui/orderedlayout/AbstractOrderedLayoutConnector.java index 918b7fbdaa..0c09ae49c6 100644 --- a/client/src/com/vaadin/client/ui/orderedlayout/AbstractOrderedLayoutConnector.java +++ b/client/src/com/vaadin/client/ui/orderedlayout/AbstractOrderedLayoutConnector.java @@ -205,6 +205,13 @@ public abstract class AbstractOrderedLayoutConnector extends private boolean hasChildrenWithRelativeHeight = false; /** + * Keep track of whether any child has relative width. Used to determine + * whether measurements are needed to make relative child widths work + * together with undefined container width. + */ + private boolean hasChildrenWithRelativeWidth = false; + + /** * Keep track of whether any child is middle aligned. Used to determine if * measurements are needed to make middle aligned children work. */ @@ -423,6 +430,8 @@ public abstract class AbstractOrderedLayoutConnector extends processedResponseId = lastResponseId; hasChildrenWithRelativeHeight = false; + hasChildrenWithRelativeWidth = false; + hasChildrenWithMiddleAlignment = false; needsExpand = getWidget().vertical ? !isUndefinedHeight() @@ -476,6 +485,9 @@ public abstract class AbstractOrderedLayoutConnector extends if (child.isRelativeHeight()) { hasChildrenWithRelativeHeight = true; } + if (child.isRelativeWidth()) { + hasChildrenWithRelativeWidth = true; + } } if (needsFixedHeight()) { @@ -575,7 +587,7 @@ public abstract class AbstractOrderedLayoutConnector extends if (slot.hasCaption()) { slot.setCaptionResizeListener(slotCaptionResizeListener); } - } else if ((child.isRelativeHeight() || child.isRelativeWidth()) + } else if ((hasChildrenWithRelativeHeight || hasChildrenWithRelativeWidth) && slot.hasCaption()) { /* * If the slot has caption, we need to listen for its size changes diff --git a/client/src/com/vaadin/client/ui/orderedlayout/Slot.java b/client/src/com/vaadin/client/ui/orderedlayout/Slot.java index f16351ab54..b1d7dd2804 100644 --- a/client/src/com/vaadin/client/ui/orderedlayout/Slot.java +++ b/client/src/com/vaadin/client/ui/orderedlayout/Slot.java @@ -79,25 +79,6 @@ public final class Slot extends SimplePanel { } }; - /* - * This listener is only used to force the LayoutManager to measure the - * caption size. #13741 - */ - private static final ElementResizeListener CAPTION_DUMMY_LISTENER = new ElementResizeListener() { - @Override - public void onElementResize(ElementResizeEvent e) { - // Do nothing - // We must include a listener for the element so - // that it gets measured during layout. - - // TODO Alter the way in which LayoutManager - // determines which elements should be measured. - // There should be an easier way to do add items - // to LayoutManager.measuredNonConnectorElements - // (#13792) - } - }; - // Caption is placed after component unless there is some part which // moves it above. private CaptionPosition captionPosition = CaptionPosition.RIGHT; @@ -490,8 +471,6 @@ public final class Slot extends SimplePanel { if (captionText != null || icon != null || error != null || required) { if (caption == null) { caption = DOM.createDiv(); - layout.getLayoutManager().addElementResizeListener(caption, - CAPTION_DUMMY_LISTENER); captionWrap = DOM.createDiv(); captionWrap.addClassName(StyleConstants.UI_WIDGET); captionWrap.addClassName("v-has-caption"); @@ -510,8 +489,6 @@ public final class Slot extends SimplePanel { getElement().appendChild(widget.getElement()); adopt(widget); captionWrap.removeFromParent(); - layout.getLayoutManager().removeElementResizeListener(caption, - CAPTION_DUMMY_LISTENER); caption = null; captionWrap = null; |