From 36a0b5375c70d732684b191372e92bf55aed3a02 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Leif=20=C3=85strand?= Date: Thu, 9 Feb 2012 16:36:53 +0200 Subject: [PATCH] Update CssLayout to work with CalculatingLayotus (#8313) --- .../themes/base/csslayout/csslayout.css | 6 + .../terminal/gwt/client/ui/VCssLayout.java | 107 +----------------- .../gwt/client/ui/VCssLayoutPaintable.java | 3 - 3 files changed, 7 insertions(+), 109 deletions(-) diff --git a/WebContent/VAADIN/themes/base/csslayout/csslayout.css b/WebContent/VAADIN/themes/base/csslayout/csslayout.css index 1f85d6f460..108be7accd 100644 --- a/WebContent/VAADIN/themes/base/csslayout/csslayout.css +++ b/WebContent/VAADIN/themes/base/csslayout/csslayout.css @@ -1,6 +1,12 @@ .v-csslayout { overflow: hidden; } +.v-csslayout-margin, .v-csslayout-container { + height: 100%; + width: 100%; + box-sizing: border-box; + -moz-box-sizing: border-box; +} .v-csslayout-margin-top { padding-top: 12px; } diff --git a/src/com/vaadin/terminal/gwt/client/ui/VCssLayout.java b/src/com/vaadin/terminal/gwt/client/ui/VCssLayout.java index 839b84061c..bdf9718573 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VCssLayout.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VCssLayout.java @@ -8,7 +8,6 @@ import java.util.Collection; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; -import java.util.Set; import com.google.gwt.dom.client.Style; import com.google.gwt.user.client.DOM; @@ -18,8 +17,6 @@ import com.google.gwt.user.client.ui.SimplePanel; import com.google.gwt.user.client.ui.Widget; import com.vaadin.terminal.gwt.client.ApplicationConnection; import com.vaadin.terminal.gwt.client.BrowserInfo; -import com.vaadin.terminal.gwt.client.Container; -import com.vaadin.terminal.gwt.client.RenderSpace; import com.vaadin.terminal.gwt.client.StyleConstants; import com.vaadin.terminal.gwt.client.UIDL; import com.vaadin.terminal.gwt.client.Util; @@ -29,7 +26,7 @@ import com.vaadin.terminal.gwt.client.VPaintableMap; import com.vaadin.terminal.gwt.client.VPaintableWidget; import com.vaadin.terminal.gwt.client.ValueMap; -public class VCssLayout extends SimplePanel implements Container { +public class VCssLayout extends SimplePanel { public static final String TAGNAME = "csslayout"; public static final String CLASSNAME = "v-" + TAGNAME; @@ -37,10 +34,6 @@ public class VCssLayout extends SimplePanel implements Container { Element margin = DOM.createDiv(); - private boolean hasHeight; - private boolean hasWidth; - boolean rendering; - public VCssLayout() { super(); getElement().appendChild(margin); @@ -54,34 +47,6 @@ public class VCssLayout extends SimplePanel implements Container { return margin; } - @Override - public void setWidth(String width) { - super.setWidth(width); - // panel.setWidth(width); - hasWidth = width != null && !width.equals(""); - if (!rendering) { - panel.updateRelativeSizes(); - } - } - - @Override - public void setHeight(String height) { - super.setHeight(height); - // panel.setHeight(height); - hasHeight = height != null && !height.equals(""); - if (!rendering) { - panel.updateRelativeSizes(); - } - } - - public boolean hasChildComponent(Widget component) { - return panel.hasChildComponent(component); - } - - public void replaceChildComponent(Widget oldComponent, Widget newComponent) { - panel.replaceChildComponent(oldComponent, newComponent); - } - public class FlowPane extends FlowPanel { private final HashMap widgetToCaption = new HashMap(); @@ -93,14 +58,6 @@ public class VCssLayout extends SimplePanel implements Container { setStyleName(CLASSNAME + "-container"); } - public void updateRelativeSizes() { - for (Widget w : getChildren()) { - if (w instanceof VPaintableWidget) { - client.handleComponentRelativeSize(w); - } - } - } - public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { // for later requests @@ -187,24 +144,6 @@ public class VCssLayout extends SimplePanel implements Container { insert(child, index); } - public boolean hasChildComponent(Widget component) { - return component.getParent() == this; - } - - public void replaceChildComponent(Widget oldComponent, - Widget newComponent) { - VCaption caption = widgetToCaption.get(oldComponent); - if (caption != null) { - remove(caption); - widgetToCaption.remove(oldComponent); - } - int index = getWidgetIndex(oldComponent); - if (index >= 0) { - remove(oldComponent); - insert(newComponent, index); - } - } - public void updateCaption(VPaintableWidget paintable, UIDL uidl) { Widget widget = paintable.getWidgetForPaintable(); VCaption caption = widgetToCaption.get(widget); @@ -232,50 +171,6 @@ public class VCssLayout extends SimplePanel implements Container { } - private RenderSpace space; - - public RenderSpace getAllocatedSpace(Widget child) { - if (space == null) { - space = new RenderSpace(-1, -1) { - @Override - public int getWidth() { - if (BrowserInfo.get().isIE()) { - int width = getOffsetWidth(); - int margins = margin.getOffsetWidth() - - panel.getOffsetWidth(); - return width - margins; - } else { - return panel.getOffsetWidth(); - } - } - - @Override - public int getHeight() { - int height = getOffsetHeight(); - int margins = margin.getOffsetHeight() - - panel.getOffsetHeight(); - return height - margins; - } - }; - } - return space; - } - - public boolean requestLayout(Set children) { - if (hasSize()) { - return true; - } else { - // Size may have changed - // TODO optimize this: cache size if not fixed, handle both width - // and height separately - return false; - } - } - - private boolean hasSize() { - return hasWidth && hasHeight; - } - private static final String makeCamelCase(String cssProperty) { // TODO this might be cleaner to implement with regexp while (cssProperty.contains("-")) { diff --git a/src/com/vaadin/terminal/gwt/client/ui/VCssLayoutPaintable.java b/src/com/vaadin/terminal/gwt/client/ui/VCssLayoutPaintable.java index 016474973f..a3795600bc 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VCssLayoutPaintable.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VCssLayoutPaintable.java @@ -33,11 +33,9 @@ public class VCssLayoutPaintable extends VAbstractPaintableWidgetContainer { @Override public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { - getWidgetForPaintable().rendering = true; super.updateFromUIDL(uidl, client); if (!isRealUpdate(uidl)) { - getWidgetForPaintable().rendering = false; return; } clickEventHandler.handleEventHandlerRegistration(client); @@ -46,7 +44,6 @@ public class VCssLayoutPaintable extends VAbstractPaintableWidgetContainer { new VMarginInfo(uidl.getIntAttribute("margins")), uidl.hasAttribute("spacing")); getWidgetForPaintable().panel.updateFromUIDL(uidl, client); - getWidgetForPaintable().rendering = false; } @Override -- 2.39.5