aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorArtur Signell <artur@vaadin.com>2012-06-21 15:21:56 +0300
committerArtur Signell <artur@vaadin.com>2012-06-21 17:11:35 +0300
commitbdb89b555123312c1b0f954f8ba05723b7c7a93d (patch)
tree2243b70ee35e686fe406941765a7afc15892e965 /src
parentd0eeb5bf53d02b57a58222ad40c07028d0643c96 (diff)
downloadvaadin-framework-bdb89b555123312c1b0f954f8ba05723b7c7a93d.tar.gz
vaadin-framework-bdb89b555123312c1b0f954f8ba05723b7c7a93d.zip
Store measuredSize in map instead of in DOM in IE8 (#8717)
Diffstat (limited to 'src')
-rw-r--r--src/com/vaadin/terminal/gwt/client/LayoutManager.java30
-rw-r--r--src/com/vaadin/terminal/gwt/client/LayoutManagerIE8.java43
2 files changed, 60 insertions, 13 deletions
diff --git a/src/com/vaadin/terminal/gwt/client/LayoutManager.java b/src/com/vaadin/terminal/gwt/client/LayoutManager.java
index 2281b4ab9c..1b9c184b62 100644
--- a/src/com/vaadin/terminal/gwt/client/LayoutManager.java
+++ b/src/com/vaadin/terminal/gwt/client/LayoutManager.java
@@ -120,7 +120,7 @@ public class LayoutManager {
/**
* Assigns a measured size to an element. Method defined as protected to
- * allow separate implementation for IE8 in which delete not always works.
+ * allow separate implementation for IE8.
*
* @param element
* the dom element to attach the measured size to
@@ -138,7 +138,17 @@ public class LayoutManager {
}
}-*/;
- private static native final MeasuredSize getMeasuredSize(Element element,
+ /**
+ * Gets the measured size for an element. Method defined as protected to
+ * allow separate implementation for IE8.
+ *
+ * @param element
+ * The element to get measured size for
+ * @param defaultSize
+ * The size to return if no measured size could be found
+ * @return The measured size for the element or {@literal defaultSize}
+ */
+ protected native MeasuredSize getMeasuredSize(Element element,
MeasuredSize defaultSize)
/*-{
return element.vMeasuredSize || defaultSize;
@@ -389,8 +399,13 @@ public class LayoutManager {
((PostLayoutListener) connector).postLayout();
}
}
- VConsole.log("Invoke post layout listeners in "
- + (totalDuration.elapsedMillis() - postLayoutStart) + " ms");
+ int postLayoutDone = (totalDuration.elapsedMillis() - postLayoutStart);
+ VConsole.log("Invoke post layout listeners in " + postLayoutDone
+ + " ms");
+
+ cleanMeasuredSizes();
+ int cleaningDone = (totalDuration.elapsedMillis() - postLayoutDone);
+ VConsole.log("Cleaned old measured sizes in " + cleaningDone + "ms");
VConsole.log("Total layout phase time: "
+ totalDuration.elapsedMillis() + "ms");
@@ -1190,4 +1205,11 @@ public class LayoutManager {
public void setEverythingNeedsMeasure() {
everythingNeedsMeasure = true;
}
+
+ /**
+ * Clean measured sizes which are no longer needed. Only for IE8.
+ */
+ protected void cleanMeasuredSizes() {
+ }
+
}
diff --git a/src/com/vaadin/terminal/gwt/client/LayoutManagerIE8.java b/src/com/vaadin/terminal/gwt/client/LayoutManagerIE8.java
index 2b677985b5..742594671f 100644
--- a/src/com/vaadin/terminal/gwt/client/LayoutManagerIE8.java
+++ b/src/com/vaadin/terminal/gwt/client/LayoutManagerIE8.java
@@ -3,21 +3,46 @@
*/
package com.vaadin.terminal.gwt.client;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
import com.google.gwt.dom.client.Element;
+import com.google.gwt.user.client.ui.RootPanel;
public class LayoutManagerIE8 extends LayoutManager {
+ private Map<Element, MeasuredSize> measuredSizes = new HashMap<Element, MeasuredSize>();
+
+ @Override
+ protected void setMeasuredSize(Element element, MeasuredSize measuredSize) {
+ if (measuredSize != null) {
+ measuredSizes.put(element, measuredSize);
+ } else {
+ measuredSizes.remove(element);
+ }
+ }
+
@Override
- protected native void setMeasuredSize(Element element,
- MeasuredSize measuredSize)
- // IE8 cannot do delete element.vMeasuredSize, at least in the case when
- // element is not attached to the document (e.g. when a caption is removed)
- /*-{
- if (measuredSize) {
- element.vMeasuredSize = measuredSize;
+ protected MeasuredSize getMeasuredSize(Element element,
+ MeasuredSize defaultSize) {
+ MeasuredSize measured = measuredSizes.get(element);
+ if (measured != null) {
+ return measured;
} else {
- element.vMeasuredSize = undefined;
+ return defaultSize;
}
- }-*/;
+ }
+ @Override
+ protected void cleanMeasuredSizes() {
+ Iterator<Element> i = measuredSizes.keySet().iterator();
+ while (i.hasNext()) {
+ Element e = i.next();
+ if (e.getOwnerDocument() != RootPanel.get().getElement()
+ .getOwnerDocument()) {
+ i.remove();
+ }
+ }
+ }
}