diff options
author | John Ahlroos <john@vaadin.com> | 2013-03-21 16:06:34 +0200 |
---|---|---|
committer | Vaadin Code Review <review@vaadin.com> | 2013-04-03 07:57:13 +0000 |
commit | 1d25d6d6427f94e93e3bf7417aa968aaa9673dab (patch) | |
tree | 38bd8723267333633de0e258c28a8797ffd65998 /client | |
parent | bde44c29bdec4647dbec94b1ed2482baaf00cddf (diff) | |
download | vaadin-framework-1d25d6d6427f94e93e3bf7417aa968aaa9673dab.tar.gz vaadin-framework-1d25d6d6427f94e93e3bf7417aa968aaa9673dab.zip |
Removed unnessesary pixel calculations from AbsoluteLayout #11177
Change-Id: Ib3f8b48e5712e895abab159616aa1b2a1ec589c8
Diffstat (limited to 'client')
-rw-r--r-- | client/src/com/vaadin/client/ui/VAbsoluteLayout.java | 112 | ||||
-rw-r--r-- | client/src/com/vaadin/client/ui/absolutelayout/AbsoluteLayoutConnector.java | 2 |
2 files changed, 25 insertions, 89 deletions
diff --git a/client/src/com/vaadin/client/ui/VAbsoluteLayout.java b/client/src/com/vaadin/client/ui/VAbsoluteLayout.java index 88fbae6e88..ee5d1f039a 100644 --- a/client/src/com/vaadin/client/ui/VAbsoluteLayout.java +++ b/client/src/com/vaadin/client/ui/VAbsoluteLayout.java @@ -18,7 +18,6 @@ package com.vaadin.client.ui; import com.google.gwt.dom.client.DivElement; import com.google.gwt.dom.client.Document; import com.google.gwt.dom.client.Style; -import com.google.gwt.dom.client.Style.Unit; import com.google.gwt.user.client.DOM; import com.google.gwt.user.client.Element; import com.google.gwt.user.client.ui.ComplexPanel; @@ -304,110 +303,45 @@ public class VAbsoluteLayout extends ComplexPanel { * is added or removed */ public void layoutVertically() { + layout(); + } + + /** + * Performs an horizontal layout. Should be called when a widget is add or + * removed + */ + public void layoutHorizontally() { + layout(); + } + + private void layout() { for (Widget widget : getChildren()) { if (widget instanceof AbsoluteWrapper) { AbsoluteWrapper wrapper = (AbsoluteWrapper) widget; - - /* - * Cleanup old wrappers which have been left empty by other - * inner layouts moving the widget from the wrapper into their - * own hierarchy. This usually happens when a call to - * setWidget(widget) is done in an inner layout which - * automatically detaches the widget from the parent, in this - * case the wrapper, and re-attaches it somewhere else. This has - * to be done in the layout phase since the order of the - * hierarchy events are not defined. - */ - if (wrapper.getWidget() == null) { - wrapper.destroy(); - super.remove(wrapper); - continue; - } - - Style wrapperStyle = wrapper.getElement().getStyle(); - Style widgetStyle = wrapper.getWidget().getElement().getStyle(); - - // Ensure previous heights do not affect the measures - wrapperStyle.clearHeight(); - - if (widgetStyle.getHeight() != null - && widgetStyle.getHeight().endsWith("%")) { - int h; - if (wrapper.top != null && wrapper.bottom != null) { - h = wrapper.getOffsetHeight(); - } else if (wrapper.bottom != null) { - // top not defined, available space 0... bottom of - // wrapper - h = wrapper.getElement().getOffsetTop() - + wrapper.getOffsetHeight(); - } else { - // top defined or both undefined, available space == - // canvas - top - h = canvas.getOffsetHeight() - - wrapper.getElement().getOffsetTop(); - } - wrapperStyle.setHeight(h, Unit.PX); - } - wrapper.updateCaptionPosition(); } } } - + /** - * Performs an horizontal layout. Should be called when a widget is add or - * removed - */ - public void layoutHorizontally() { + * Cleanup old wrappers which have been left empty by other inner layouts + * moving the widget from the wrapper into their own hierarchy. This usually + * happens when a call to setWidget(widget) is done in an inner layout which + * automatically detaches the widget from the parent, in this case the + * wrapper, and re-attaches it somewhere else. This has to be done in the + * layout phase since the order of the hierarchy events are not defined. + */ + public void cleanupWrappers() { for (Widget widget : getChildren()) { if (widget instanceof AbsoluteWrapper) { AbsoluteWrapper wrapper = (AbsoluteWrapper) widget; - - /* - * Cleanup old wrappers which have been left empty by other - * inner layouts moving the widget from the wrapper into their - * own hierarchy. This usually happens when a call to - * setWidget(widget) is done in an inner layout which - * automatically detaches the widget from the parent, in this - * case the wrapper, and re-attaches it somewhere else. This has - * to be done in the layout phase since the order of the - * hierarchy events are not defined. - */ if (wrapper.getWidget() == null) { wrapper.destroy(); super.remove(wrapper); continue; - } - - Style wrapperStyle = wrapper.getElement().getStyle(); - Style widgetStyle = wrapper.getWidget().getElement().getStyle(); - - // Ensure previous heights do not affect the measures - wrapperStyle.clearWidth(); - - if (widgetStyle.getWidth() != null - && widgetStyle.getWidth().endsWith("%")) { - int w; - if (wrapper.left != null && wrapper.right != null) { - w = wrapper.getOffsetWidth(); - } else if (wrapper.right != null) { - // left == null - // available width == right edge == offsetleft + width - w = wrapper.getOffsetWidth() - + wrapper.getElement().getOffsetLeft(); - } else { - // left != null && right == null || left == null && - // right == null - // available width == canvas width - offset left - w = canvas.getOffsetWidth() - - wrapper.getElement().getOffsetLeft(); - } - wrapperStyle.setWidth(w, Unit.PX); - } - - wrapper.updateCaptionPosition(); + } } - } + } } /** diff --git a/client/src/com/vaadin/client/ui/absolutelayout/AbsoluteLayoutConnector.java b/client/src/com/vaadin/client/ui/absolutelayout/AbsoluteLayoutConnector.java index 868c14f742..cba9cc2fa1 100644 --- a/client/src/com/vaadin/client/ui/absolutelayout/AbsoluteLayoutConnector.java +++ b/client/src/com/vaadin/client/ui/absolutelayout/AbsoluteLayoutConnector.java @@ -188,6 +188,8 @@ public class AbsoluteLayoutConnector extends oldChild.removeStateChangeHandler(childStateChangeHandler); } } + + getWidget().cleanupWrappers(); } /* |