aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLeif Åstrand <leif@vaadin.com>2012-02-27 15:47:30 +0200
committerLeif Åstrand <leif@vaadin.com>2012-02-27 15:47:30 +0200
commit827dd25319110a3aef00bef936243bc3fe6a9051 (patch)
treed8d8d971e72bbe3695bee0d9a9b013ba953cacec /src
parentd57efca78be178a5aba4e1fe3c67d6e4b2c7b9e8 (diff)
downloadvaadin-framework-827dd25319110a3aef00bef936243bc3fe6a9051.tar.gz
vaadin-framework-827dd25319110a3aef00bef936243bc3fe6a9051.zip
Drop size calculations from Embeddable (#8312)
Diffstat (limited to 'src')
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/VEmbedded.java66
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/VEmbeddedPaintable.java4
2 files changed, 11 insertions, 59 deletions
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VEmbedded.java b/src/com/vaadin/terminal/gwt/client/ui/VEmbedded.java
index e2247b627d..95ffb8076b 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/VEmbedded.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/VEmbedded.java
@@ -8,7 +8,6 @@ import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
-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.Event;
@@ -17,12 +16,13 @@ import com.vaadin.terminal.gwt.client.ApplicationConnection;
import com.vaadin.terminal.gwt.client.BrowserInfo;
import com.vaadin.terminal.gwt.client.UIDL;
import com.vaadin.terminal.gwt.client.Util;
+import com.vaadin.terminal.gwt.client.VConsole;
+import com.vaadin.terminal.gwt.client.VPaintableMap;
+import com.vaadin.terminal.gwt.client.VPaintableWidget;
public class VEmbedded extends HTML {
public static String CLASSNAME = "v-embedded";
- protected String height;
- protected String width;
protected Element browserElement;
protected String type;
@@ -84,6 +84,11 @@ public class VEmbedded extends HTML {
html.append("codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0\" ");
}
+ VPaintableWidget paintable = VPaintableMap.get(client).getPaintable(
+ this);
+ String height = paintable.getDeclaredHeight();
+ String width = paintable.getDeclaredWidth();
+
// Add width and height
html.append("width=\"" + Util.escapeAttribute(width) + "\" ");
html.append("height=\"" + Util.escapeAttribute(height) + "\" ");
@@ -197,40 +202,6 @@ public class VEmbedded extends HTML {
}
@Override
- public void setWidth(String width) {
- this.width = width;
- if (isDynamicHeight()) {
- int oldHeight = getOffsetHeight();
- super.setWidth(width);
- int newHeight = getOffsetHeight();
- /*
- * Must notify parent if the height changes as a result of a width
- * change
- */
- if (oldHeight != newHeight) {
- Util.notifyParentOfSizeChange(this, false);
- }
- } else {
- super.setWidth(width);
- }
-
- }
-
- private boolean isDynamicWidth() {
- return width == null || width.equals("");
- }
-
- private boolean isDynamicHeight() {
- return height == null || height.equals("");
- }
-
- @Override
- public void setHeight(String height) {
- this.height = height;
- super.setHeight(height);
- }
-
- @Override
protected void onDetach() {
if (BrowserInfo.get().isIE()) {
// Force browser to fire unload event when component is detached
@@ -247,30 +218,11 @@ public class VEmbedded extends HTML {
public void onBrowserEvent(Event event) {
super.onBrowserEvent(event);
if (DOM.eventGetType(event) == Event.ONLOAD) {
- if ("image".equals(type)) {
- updateElementDynamicSizeFromImage();
- }
+ VConsole.log("Embeddable onload");
Util.notifyParentOfSizeChange(this, true);
}
client.handleTooltipEvent(event, this);
}
- /**
- * Updates the size of the embedded component's element if size is
- * undefined. Without this embeddeds containing images will remain the wrong
- * size in certain cases (e.g. #6304).
- */
- private void updateElementDynamicSizeFromImage() {
- if (isDynamicWidth()) {
- getElement().getStyle().setWidth(
- getElement().getFirstChildElement().getOffsetWidth(),
- Unit.PX);
- }
- if (isDynamicHeight()) {
- getElement().getStyle().setHeight(
- getElement().getFirstChildElement().getOffsetHeight(),
- Unit.PX);
- }
- }
}
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VEmbeddedPaintable.java b/src/com/vaadin/terminal/gwt/client/ui/VEmbeddedPaintable.java
index 585241ef21..6a538319a2 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/VEmbeddedPaintable.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/VEmbeddedPaintable.java
@@ -128,10 +128,10 @@ public class VEmbeddedPaintable extends VAbstractPaintableWidget {
ObjectElement obj = Document.get().createObjectElement();
obj.setType(mime);
obj.setData(data);
- if (getWidgetForPaintable().width != null) {
+ if (!isUndefinedWidth()) {
obj.getStyle().setProperty("width", "100%");
}
- if (getWidgetForPaintable().height != null) {
+ if (!isUndefinedHeight()) {
obj.getStyle().setProperty("height", "100%");
}
if (uidl.hasAttribute("classid")) {