*/
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.
processedResponseId = lastResponseId;
hasChildrenWithRelativeHeight = false;
+ hasChildrenWithRelativeWidth = false;
+
hasChildrenWithMiddleAlignment = false;
needsExpand = getWidget().vertical ? !isUndefinedHeight()
if (child.isRelativeHeight()) {
hasChildrenWithRelativeHeight = true;
}
+ if (child.isRelativeWidth()) {
+ hasChildrenWithRelativeWidth = true;
+ }
}
if (needsFixedHeight()) {
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
}
};
- /*
- * 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;
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");
getElement().appendChild(widget.getElement());
adopt(widget);
captionWrap.removeFromParent();
- layout.getLayoutManager().removeElementResizeListener(caption,
- CAPTION_DUMMY_LISTENER);
caption = null;
captionWrap = null;