aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArtur Signell <artur@vaadin.com>2012-11-16 17:38:59 +0200
committerVaadin Code Review <review@vaadin.com>2012-11-20 09:36:53 +0000
commitbe552340eec864492a021f2d0b3e5cfb07e08471 (patch)
treec61a17c748eb23aaa2bc4b61eed8a1b30eef3697
parent09d532f34b713d0c470656a575ce53014eb12557 (diff)
downloadvaadin-framework-be552340eec864492a021f2d0b3e5cfb07e08471.tar.gz
vaadin-framework-be552340eec864492a021f2d0b3e5cfb07e08471.zip
Added possibility to more easily debug layout loops (#10222)
Change-Id: Id7a1e7590d0a35a8e9051acab043d7a26293637a
-rw-r--r--client/src/com/vaadin/client/MeasuredSize.java35
1 files changed, 35 insertions, 0 deletions
diff --git a/client/src/com/vaadin/client/MeasuredSize.java b/client/src/com/vaadin/client/MeasuredSize.java
index 48585ae7c5..ccc8a5058c 100644
--- a/client/src/com/vaadin/client/MeasuredSize.java
+++ b/client/src/com/vaadin/client/MeasuredSize.java
@@ -19,6 +19,8 @@ import com.google.gwt.core.client.JsArrayString;
import com.google.gwt.dom.client.Element;
public class MeasuredSize {
+ private final static boolean debugSizeChanges = false;
+
public static class MeasureResult {
private final boolean widthChanged;
private final boolean heightChanged;
@@ -189,46 +191,79 @@ public class MeasuredSize {
ComputedStyle computedStyle = new ComputedStyle(element);
int[] paddings = computedStyle.getPadding();
if (!heightChanged && hasHeightChanged(this.paddings, paddings)) {
+ debugSizeChange(element, "Height (padding)", this.paddings,
+ paddings);
heightChanged = true;
}
if (!widthChanged && hasWidthChanged(this.paddings, paddings)) {
+ debugSizeChange(element, "Width (padding)", this.paddings, paddings);
widthChanged = true;
}
this.paddings = paddings;
int[] margins = computedStyle.getMargin();
if (!heightChanged && hasHeightChanged(this.margins, margins)) {
+ debugSizeChange(element, "Height (margins)", this.margins, margins);
heightChanged = true;
}
if (!widthChanged && hasWidthChanged(this.margins, margins)) {
+ debugSizeChange(element, "Width (margins)", this.margins, margins);
widthChanged = true;
}
this.margins = margins;
int[] borders = computedStyle.getBorder();
if (!heightChanged && hasHeightChanged(this.borders, borders)) {
+ debugSizeChange(element, "Height (borders)", this.borders, borders);
heightChanged = true;
}
if (!widthChanged && hasWidthChanged(this.borders, borders)) {
+ debugSizeChange(element, "Width (borders)", this.borders, borders);
widthChanged = true;
}
this.borders = borders;
int requiredHeight = Util.getRequiredHeight(element);
int marginHeight = sumHeights(margins);
+ int oldHeight = height;
+ int oldWidth = width;
if (setOuterHeight(requiredHeight + marginHeight)) {
+ debugSizeChange(element, "Height (outer)", oldHeight, height);
heightChanged = true;
}
int requiredWidth = Util.getRequiredWidth(element);
int marginWidth = sumWidths(margins);
if (setOuterWidth(requiredWidth + marginWidth)) {
+ debugSizeChange(element, "Width (outer)", oldWidth, width);
widthChanged = true;
}
return new MeasureResult(widthChanged, heightChanged);
}
+ private void debugSizeChange(Element element, String sizeChangeType,
+ int[] changedFrom, int[] changedTo) {
+ debugSizeChange(element, sizeChangeType,
+ java.util.Arrays.asList(changedFrom).toString(),
+ java.util.Arrays.asList(changedTo).toString());
+ }
+
+ private void debugSizeChange(Element element, String sizeChangeType,
+ int changedFrom, int changedTo) {
+ debugSizeChange(element, sizeChangeType, String.valueOf(changedFrom),
+ String.valueOf(changedTo));
+ }
+
+ private void debugSizeChange(Element element, String sizeChangeType,
+ String changedFrom, String changedTo) {
+ if (debugSizeChanges) {
+ VConsole.log(sizeChangeType + " has changed for "
+ + element.toString() + " from " + changedFrom + " to "
+ + changedTo);
+ }
+ }
+
private static boolean hasWidthChanged(int[] sizes1, int[] sizes2) {
return sizes1[1] != sizes2[1] || sizes1[3] != sizes2[3];
}