Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Thienel2016-07-13 15:32:51 -0400
committerFlorian Thienel2016-07-13 15:32:51 -0400
commita9d8e35399ce44e844fac17fde487a55a44c93f0 (patch)
tree1a84cc13f85a2e8ef96fd2552dd922d061ab3ba6
parent7df9874847214b8e4fbe18ed636454afe23702f2 (diff)
downloadorg.eclipse.mylyn.docs.vex-a9d8e35399ce44e844fac17fde487a55a44c93f0.tar.gz
org.eclipse.mylyn.docs.vex-a9d8e35399ce44e844fac17fde487a55a44c93f0.tar.xz
org.eclipse.mylyn.docs.vex-a9d8e35399ce44e844fac17fde487a55a44c93f0.zip
return a list of other invalidated boxes when reconciling layout
Instead of indicated that something has changed and outer boxes have to adapt, we return a list of the boxes that need to adapt. This can e.g. be used by table cells that span over several rows, to indicate which rows need to be reconciled. Signed-off-by: Florian Thienel <florian@thienel.org>
-rw-r--r--org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/boxes/FakeContentBox.java6
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/GraphicalBullet.java11
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/HorizontalBar.java6
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/IBox.java7
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/Image.java10
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/InlineContainer.java10
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/InlineFrame.java11
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/InlineNodeReference.java10
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/List.java8
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/ListItem.java10
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/NodeEndOffsetPlaceholder.java9
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/NodeTag.java12
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/Paragraph.java10
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/RootBox.java5
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/Square.java6
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/StaticText.java11
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/StructuralFrame.java11
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/StructuralNodeReference.java12
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/Table.java5
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/TableCell.java9
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/TableColumnSpec.java12
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/TableRow.java10
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/TableRowGroup.java10
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/TextContent.java11
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/VerticalBlock.java10
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/internal/widget/BoxView.java31
26 files changed, 193 insertions, 70 deletions
diff --git a/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/boxes/FakeContentBox.java b/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/boxes/FakeContentBox.java
index 013c7258..1e690ebb 100644
--- a/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/boxes/FakeContentBox.java
+++ b/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/boxes/FakeContentBox.java
@@ -10,6 +10,8 @@
*******************************************************************************/
package org.eclipse.vex.core.internal.boxes;
+import java.util.Collection;
+
import org.eclipse.vex.core.internal.core.Color;
import org.eclipse.vex.core.internal.core.Graphics;
import org.eclipse.vex.core.internal.core.Rectangle;
@@ -82,8 +84,8 @@ public class FakeContentBox extends BaseBox implements IContentBox {
}
@Override
- public boolean reconcileLayout(final Graphics graphics) {
- return false;
+ public Collection<IBox> reconcileLayout(final Graphics graphics) {
+ return NOTHING_INVALIDATED;
}
@Override
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/GraphicalBullet.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/GraphicalBullet.java
index 416d3ecf..e168d180 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/GraphicalBullet.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/GraphicalBullet.java
@@ -10,6 +10,9 @@
*******************************************************************************/
package org.eclipse.vex.core.internal.boxes;
+import java.util.Collection;
+import java.util.Collections;
+
import org.eclipse.vex.core.internal.core.Color;
import org.eclipse.vex.core.internal.core.FontResource;
import org.eclipse.vex.core.internal.core.FontSpec;
@@ -86,12 +89,16 @@ public class GraphicalBullet extends SimpleInlineBox {
}
@Override
- public boolean reconcileLayout(final Graphics graphics) {
+ public Collection<IBox> reconcileLayout(final Graphics graphics) {
final int oldHeight = height;
layout(graphics);
- return height != oldHeight;
+ if (height != oldHeight) {
+ return Collections.singleton(getParent());
+ } else {
+ return NOTHING_INVALIDATED;
+ }
}
@Override
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/HorizontalBar.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/HorizontalBar.java
index 7c891885..1310a979 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/HorizontalBar.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/HorizontalBar.java
@@ -10,6 +10,8 @@
*******************************************************************************/
package org.eclipse.vex.core.internal.boxes;
+import java.util.Collection;
+
import org.eclipse.vex.core.internal.core.Color;
import org.eclipse.vex.core.internal.core.ColorResource;
import org.eclipse.vex.core.internal.core.Graphics;
@@ -116,9 +118,9 @@ public class HorizontalBar extends BaseBox implements IStructuralBox {
}
@Override
- public boolean reconcileLayout(final Graphics graphics) {
+ public Collection<IBox> reconcileLayout(final Graphics graphics) {
// ignore, everything is static
- return false;
+ return NOTHING_INVALIDATED;
}
@Override
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/IBox.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/IBox.java
index 15926772..9cd82dd5 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/IBox.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/IBox.java
@@ -10,6 +10,9 @@
*******************************************************************************/
package org.eclipse.vex.core.internal.boxes;
+import java.util.Collection;
+import java.util.Collections;
+
import org.eclipse.vex.core.internal.core.Graphics;
import org.eclipse.vex.core.internal.core.Rectangle;
@@ -18,6 +21,8 @@ import org.eclipse.vex.core.internal.core.Rectangle;
*/
public interface IBox {
+ Collection<IBox> NOTHING_INVALIDATED = Collections.emptyList();
+
int getAbsoluteTop();
int getAbsoluteLeft();
@@ -38,7 +43,7 @@ public interface IBox {
void layout(Graphics graphics);
- boolean reconcileLayout(Graphics graphics);
+ Collection<IBox> reconcileLayout(Graphics graphics);
void paint(Graphics graphics);
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/Image.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/Image.java
index 9a0623e8..473fed7a 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/Image.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/Image.java
@@ -11,6 +11,8 @@
package org.eclipse.vex.core.internal.boxes;
import java.net.URL;
+import java.util.Collection;
+import java.util.Collections;
import org.eclipse.vex.core.internal.core.Graphics;
import org.eclipse.vex.core.internal.core.Length;
@@ -221,13 +223,17 @@ public class Image extends BaseBox implements IInlineBox {
}
@Override
- public boolean reconcileLayout(final Graphics graphics) {
+ public Collection<IBox> reconcileLayout(final Graphics graphics) {
final int oldHeight = height;
final int oldWidth = width;
layout(graphics);
- return oldHeight != height || oldWidth != width;
+ if (oldHeight != height || oldWidth != width) {
+ return Collections.singleton(getParent());
+ } else {
+ return NOTHING_INVALIDATED;
+ }
}
@Override
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/InlineContainer.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/InlineContainer.java
index ffcee5df..459a0afb 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/InlineContainer.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/InlineContainer.java
@@ -11,6 +11,7 @@
package org.eclipse.vex.core.internal.boxes;
import java.util.Collection;
+import java.util.Collections;
import java.util.LinkedList;
import java.util.ListIterator;
@@ -263,12 +264,17 @@ public class InlineContainer extends BaseBox implements IInlineBox, IParentBox<I
}
@Override
- public boolean reconcileLayout(final Graphics graphics) {
+ public Collection<IBox> reconcileLayout(final Graphics graphics) {
final int oldWidth = width;
final int oldHeight = height;
final int oldBaseline = baseline;
calculateBoundsAndBaseline();
- return oldWidth != width || oldHeight != height || oldBaseline != baseline;
+
+ if (oldWidth != width || oldHeight != height || oldBaseline != baseline) {
+ return Collections.singleton(getParent());
+ } else {
+ return NOTHING_INVALIDATED;
+ }
}
@Override
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/InlineFrame.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/InlineFrame.java
index 2cad78ad..1aa11e2b 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/InlineFrame.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/InlineFrame.java
@@ -10,6 +10,9 @@
*******************************************************************************/
package org.eclipse.vex.core.internal.boxes;
+import java.util.Collection;
+import java.util.Collections;
+
import org.eclipse.vex.core.internal.core.Color;
import org.eclipse.vex.core.internal.core.Graphics;
import org.eclipse.vex.core.internal.core.Rectangle;
@@ -227,13 +230,17 @@ public class InlineFrame extends BaseBox implements IInlineBox, IDecoratorBox<II
}
@Override
- public boolean reconcileLayout(final Graphics graphics) {
+ public Collection<IBox> reconcileLayout(final Graphics graphics) {
final int oldHeight = height;
final int oldWidth = width;
calculateBounds();
- return oldHeight != height || oldWidth != width;
+ if (oldHeight != height || oldWidth != width) {
+ return Collections.singleton(getParent());
+ } else {
+ return NOTHING_INVALIDATED;
+ }
}
private int topFrame(final int componentHeight) {
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/InlineNodeReference.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/InlineNodeReference.java
index 5fae4e3d..bf4b9e28 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/InlineNodeReference.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/InlineNodeReference.java
@@ -11,6 +11,8 @@
package org.eclipse.vex.core.internal.boxes;
import java.text.MessageFormat;
+import java.util.Collection;
+import java.util.Collections;
import org.eclipse.core.runtime.Assert;
import org.eclipse.vex.core.internal.core.Color;
@@ -210,7 +212,7 @@ public class InlineNodeReference extends BaseBox implements IInlineBox, IDecorat
}
@Override
- public boolean reconcileLayout(final Graphics graphics) {
+ public Collection<IBox> reconcileLayout(final Graphics graphics) {
final int oldWidth = width;
final int oldHeight = height;
final int oldBaseline = baseline;
@@ -220,7 +222,11 @@ public class InlineNodeReference extends BaseBox implements IInlineBox, IDecorat
layout(graphics);
- return oldWidth != width || oldHeight != height || oldBaseline != baseline;
+ if (oldWidth != width || oldHeight != height || oldBaseline != baseline) {
+ return Collections.singleton(getParent());
+ } else {
+ return NOTHING_INVALIDATED;
+ }
}
@Override
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/List.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/List.java
index b09a4fe1..ebef04fd 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/List.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/List.java
@@ -1,6 +1,8 @@
package org.eclipse.vex.core.internal.boxes;
import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
import org.eclipse.vex.core.internal.core.Graphics;
import org.eclipse.vex.core.internal.core.Rectangle;
@@ -174,14 +176,14 @@ public class List extends BaseBox implements IStructuralBox, IDecoratorBox<IStru
}
@Override
- public boolean reconcileLayout(final Graphics graphics) {
+ public Collection<IBox> reconcileLayout(final Graphics graphics) {
final int oldHeight = height;
height = component.getHeight();
if (oldHeight != height) {
layout(graphics);
- return true;
+ return Collections.singleton(getParent());
}
- return false;
+ return NOTHING_INVALIDATED;
}
@Override
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/ListItem.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/ListItem.java
index 6717e4f5..fda1389a 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/ListItem.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/ListItem.java
@@ -12,6 +12,8 @@ package org.eclipse.vex.core.internal.boxes;
import static org.eclipse.vex.core.internal.boxes.BoxFactory.frame;
+import java.util.Collection;
+import java.util.Collections;
import java.util.Iterator;
import org.eclipse.vex.core.internal.core.Graphics;
@@ -324,7 +326,7 @@ public class ListItem extends BaseBox implements IStructuralBox, IDecoratorBox<I
}
@Override
- public boolean reconcileLayout(final Graphics graphics) {
+ public Collection<IBox> reconcileLayout(final Graphics graphics) {
final int oldHeight = height;
if (bulletPosition == BulletStyle.Position.INSIDE && component != null) {
@@ -334,7 +336,11 @@ public class ListItem extends BaseBox implements IStructuralBox, IDecoratorBox<I
height = Math.max(getBulletHeight(), getComponentHeight());
- return oldHeight != height;
+ if (oldHeight != height) {
+ return Collections.singleton(getParent());
+ } else {
+ return NOTHING_INVALIDATED;
+ }
}
private int getBulletHeight() {
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/NodeEndOffsetPlaceholder.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/NodeEndOffsetPlaceholder.java
index eba40663..b76ddff8 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/NodeEndOffsetPlaceholder.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/NodeEndOffsetPlaceholder.java
@@ -10,6 +10,9 @@
*******************************************************************************/
package org.eclipse.vex.core.internal.boxes;
+import java.util.Collection;
+import java.util.Collections;
+
import org.eclipse.vex.core.internal.core.Color;
import org.eclipse.vex.core.internal.core.FontMetrics;
import org.eclipse.vex.core.internal.core.FontSpec;
@@ -187,12 +190,12 @@ public class NodeEndOffsetPlaceholder extends BaseBox implements IInlineBox, ICo
}
@Override
- public boolean reconcileLayout(final Graphics graphics) {
+ public Collection<IBox> reconcileLayout(final Graphics graphics) {
if (layoutValid) {
- return false;
+ return NOTHING_INVALIDATED;
}
layout(graphics);
- return true;
+ return Collections.singleton(getParent());
}
@Override
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/NodeTag.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/NodeTag.java
index 773115d5..2b9a9392 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/NodeTag.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/NodeTag.java
@@ -10,6 +10,9 @@
*******************************************************************************/
package org.eclipse.vex.core.internal.boxes;
+import java.util.Collection;
+import java.util.Collections;
+
import org.eclipse.vex.core.internal.core.Color;
import org.eclipse.vex.core.internal.core.Graphics;
import org.eclipse.vex.core.internal.core.NodeGraphics;
@@ -135,11 +138,16 @@ public class NodeTag extends SimpleInlineBox {
}
@Override
- public boolean reconcileLayout(final Graphics graphics) {
+ public Collection<IBox> reconcileLayout(final Graphics graphics) {
final int oldWidth = width;
final int oldHeight = height;
layout(graphics);
- return oldWidth != width || oldHeight != height;
+
+ if (oldWidth != width || oldHeight != height) {
+ return Collections.singleton(getParent());
+ } else {
+ return NOTHING_INVALIDATED;
+ }
}
@Override
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/Paragraph.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/Paragraph.java
index 95dd6475..213b7e5e 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/Paragraph.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/Paragraph.java
@@ -11,6 +11,7 @@
package org.eclipse.vex.core.internal.boxes;
import java.util.Collection;
+import java.util.Collections;
import java.util.LinkedList;
import java.util.ListIterator;
@@ -190,10 +191,15 @@ public class Paragraph extends BaseBox implements IStructuralBox, IParentBox<IIn
}
@Override
- public boolean reconcileLayout(final Graphics graphics) {
+ public Collection<IBox> reconcileLayout(final Graphics graphics) {
final int oldHeight = lines.getHeight();
arrangeChildrenOnLines(graphics);
- return oldHeight != lines.getHeight();
+
+ if (oldHeight != lines.getHeight()) {
+ return Collections.singleton(getParent());
+ } else {
+ return NOTHING_INVALIDATED;
+ }
}
@Override
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/RootBox.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/RootBox.java
index d8fb9fd0..592c6945 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/RootBox.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/RootBox.java
@@ -128,15 +128,14 @@ public class RootBox extends BaseBox implements IParentBox<IStructuralBox> {
}
@Override
- public boolean reconcileLayout(final Graphics graphics) {
- final int oldHeight = height;
+ public Collection<IBox> reconcileLayout(final Graphics graphics) {
height = 0;
for (int i = 0; i < children.size(); i += 1) {
final IStructuralBox child = children.get(i);
child.setPosition(height, 0);
height += child.getHeight();
}
- return oldHeight != height;
+ return NOTHING_INVALIDATED;
}
@Override
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/Square.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/Square.java
index 55526b45..d5f3ada2 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/Square.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/Square.java
@@ -10,6 +10,8 @@
*******************************************************************************/
package org.eclipse.vex.core.internal.boxes;
+import java.util.Collection;
+
import org.eclipse.vex.core.internal.core.Color;
import org.eclipse.vex.core.internal.core.Graphics;
@@ -59,8 +61,8 @@ public class Square extends SimpleInlineBox {
}
@Override
- public boolean reconcileLayout(final Graphics graphics) {
- return false; // static size
+ public Collection<IBox> reconcileLayout(final Graphics graphics) {
+ return NOTHING_INVALIDATED; // static size
}
@Override
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/StaticText.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/StaticText.java
index da7c9b40..77e56886 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/StaticText.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/StaticText.java
@@ -13,6 +13,9 @@ package org.eclipse.vex.core.internal.boxes;
import static org.eclipse.vex.core.internal.core.TextUtils.countWhitespaceAtEnd;
import static org.eclipse.vex.core.internal.core.TextUtils.countWhitespaceAtStart;
+import java.util.Collection;
+import java.util.Collections;
+
import org.eclipse.vex.core.internal.core.Color;
import org.eclipse.vex.core.internal.core.FontMetrics;
import org.eclipse.vex.core.internal.core.FontResource;
@@ -208,14 +211,18 @@ public class StaticText extends BaseBox implements IInlineBox {
}
@Override
- public boolean reconcileLayout(final Graphics graphics) {
+ public Collection<IBox> reconcileLayout(final Graphics graphics) {
final int oldHeight = height;
final int oldWidth = width;
final int oldBaseline = baseline;
layout(graphics);
- return oldHeight != height || oldWidth != width || oldBaseline != baseline;
+ if (oldHeight != height || oldWidth != width || oldBaseline != baseline) {
+ return Collections.singleton(getParent());
+ } else {
+ return NOTHING_INVALIDATED;
+ }
}
@Override
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/StructuralFrame.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/StructuralFrame.java
index ee3c244d..ede03345 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/StructuralFrame.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/StructuralFrame.java
@@ -10,6 +10,9 @@
*******************************************************************************/
package org.eclipse.vex.core.internal.boxes;
+import java.util.Collection;
+import java.util.Collections;
+
import org.eclipse.vex.core.internal.core.Color;
import org.eclipse.vex.core.internal.core.Graphics;
import org.eclipse.vex.core.internal.core.Rectangle;
@@ -184,14 +187,18 @@ public class StructuralFrame extends BaseBox implements IHeightAdjustableBox, ID
}
@Override
- public boolean reconcileLayout(final Graphics graphics) {
+ public Collection<IBox> reconcileLayout(final Graphics graphics) {
final int oldHeight = height;
height = component.getHeight();
height += topFrame(component.getHeight());
height += bottomFrame(component.getHeight());
- return oldHeight != height;
+ if (oldHeight != height) {
+ return Collections.singleton(getParent());
+ } else {
+ return NOTHING_INVALIDATED;
+ }
}
@Override
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/StructuralNodeReference.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/StructuralNodeReference.java
index 161c3156..7969851f 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/StructuralNodeReference.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/StructuralNodeReference.java
@@ -10,6 +10,9 @@
*******************************************************************************/
package org.eclipse.vex.core.internal.boxes;
+import java.util.Collection;
+import java.util.Collections;
+
import org.eclipse.vex.core.internal.core.Color;
import org.eclipse.vex.core.internal.core.Graphics;
import org.eclipse.vex.core.internal.core.LineStyle;
@@ -158,10 +161,15 @@ public class StructuralNodeReference extends BaseBox implements IStructuralBox,
}
@Override
- public boolean reconcileLayout(final Graphics graphics) {
+ public Collection<IBox> reconcileLayout(final Graphics graphics) {
final int oldHeight = height;
height = component.getHeight();
- return oldHeight != height;
+
+ if (oldHeight != height) {
+ return Collections.singleton(getParent());
+ } else {
+ return NOTHING_INVALIDATED;
+ }
}
@Override
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/Table.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/Table.java
index 11ed90d7..e9a3c37f 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/Table.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/Table.java
@@ -12,6 +12,7 @@ package org.eclipse.vex.core.internal.boxes;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.Collections;
import java.util.ListIterator;
import org.eclipse.vex.core.internal.core.Graphics;
@@ -173,9 +174,9 @@ public class Table extends BaseBox implements IStructuralBox, IParentBox<IStruct
}
@Override
- public boolean reconcileLayout(final Graphics graphics) {
+ public Collection<IBox> reconcileLayout(final Graphics graphics) {
layout(graphics);
- return true;
+ return Collections.singleton(getParent());
}
@Override
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/TableCell.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/TableCell.java
index e8ab3e88..f7393ffd 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/TableCell.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/TableCell.java
@@ -10,6 +10,9 @@
*******************************************************************************/
package org.eclipse.vex.core.internal.boxes;
+import java.util.Collection;
+import java.util.Collections;
+
import org.eclipse.vex.core.internal.core.Graphics;
import org.eclipse.vex.core.internal.core.Rectangle;
@@ -189,17 +192,17 @@ public class TableCell extends BaseBox implements IStructuralBox, IDecoratorBox<
}
@Override
- public boolean reconcileLayout(final Graphics graphics) {
+ public Collection<IBox> reconcileLayout(final Graphics graphics) {
final int oldHeight = naturalHeight;
naturalHeight = calculateNaturalHeight(graphics, width);
if (oldHeight == naturalHeight) {
- return false;
+ return NOTHING_INVALIDATED;
}
component.setPosition(0, 0);
adjustComponentHeight();
- return true;
+ return Collections.singleton(getParent());
}
@Override
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/TableColumnSpec.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/TableColumnSpec.java
index 0a6e008b..78a1210e 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/TableColumnSpec.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/TableColumnSpec.java
@@ -10,6 +10,9 @@
*******************************************************************************/
package org.eclipse.vex.core.internal.boxes;
+import java.util.Collection;
+import java.util.Collections;
+
import org.eclipse.vex.core.internal.core.Graphics;
import org.eclipse.vex.core.internal.core.Rectangle;
@@ -176,10 +179,15 @@ public class TableColumnSpec extends BaseBox implements IStructuralBox, IDecorat
}
@Override
- public boolean reconcileLayout(final Graphics graphics) {
+ public Collection<IBox> reconcileLayout(final Graphics graphics) {
final int oldHeight = height;
height = component.getHeight();
- return oldHeight != height;
+
+ if (oldHeight != height) {
+ return Collections.singleton(getParent());
+ } else {
+ return NOTHING_INVALIDATED;
+ }
}
@Override
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/TableRow.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/TableRow.java
index 1bf81af6..d4eb2733 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/TableRow.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/TableRow.java
@@ -12,6 +12,7 @@ package org.eclipse.vex.core.internal.boxes;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.Collections;
import java.util.ListIterator;
import org.eclipse.vex.core.internal.core.Graphics;
@@ -229,10 +230,15 @@ public class TableRow extends BaseBox implements IStructuralBox, IParentBox<IStr
}
@Override
- public boolean reconcileLayout(final Graphics graphics) {
+ public Collection<IBox> reconcileLayout(final Graphics graphics) {
final int oldHeight = height;
layout(graphics);
- return oldHeight != height;
+
+ if (oldHeight != height) {
+ return Collections.singleton(getParent());
+ } else {
+ return NOTHING_INVALIDATED;
+ }
}
@Override
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/TableRowGroup.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/TableRowGroup.java
index a562ab81..0cdd41c4 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/TableRowGroup.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/TableRowGroup.java
@@ -12,6 +12,7 @@ package org.eclipse.vex.core.internal.boxes;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.Collections;
import java.util.ListIterator;
import org.eclipse.vex.core.internal.core.Graphics;
@@ -173,7 +174,7 @@ public class TableRowGroup extends BaseBox implements IStructuralBox, IParentBox
}
@Override
- public boolean reconcileLayout(final Graphics graphics) {
+ public Collection<IBox> reconcileLayout(final Graphics graphics) {
final int oldHeight = height;
height = 0;
for (int i = 0; i < children.size(); i += 1) {
@@ -181,7 +182,12 @@ public class TableRowGroup extends BaseBox implements IStructuralBox, IParentBox
child.setPosition(height, 0);
height += child.getHeight();
}
- return oldHeight != height;
+
+ if (oldHeight != height) {
+ return Collections.singleton(getParent());
+ } else {
+ return NOTHING_INVALIDATED;
+ }
}
@Override
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/TextContent.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/TextContent.java
index 22f2bdce..017b5333 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/TextContent.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/TextContent.java
@@ -13,6 +13,9 @@ package org.eclipse.vex.core.internal.boxes;
import static org.eclipse.vex.core.internal.core.TextUtils.countWhitespaceAtEnd;
import static org.eclipse.vex.core.internal.core.TextUtils.countWhitespaceAtStart;
+import java.util.Collection;
+import java.util.Collections;
+
import org.eclipse.core.runtime.Assert;
import org.eclipse.vex.core.internal.core.Color;
import org.eclipse.vex.core.internal.core.FontMetrics;
@@ -236,14 +239,18 @@ public class TextContent extends BaseBox implements IInlineBox, IContentBox {
}
@Override
- public boolean reconcileLayout(final Graphics graphics) {
+ public Collection<IBox> reconcileLayout(final Graphics graphics) {
final int oldHeight = height;
final int oldWidth = width;
final int oldBaseline = baseline;
layout(graphics);
- return oldHeight != height || oldWidth != width || oldBaseline != baseline;
+ if (oldHeight != height || oldWidth != width || oldBaseline != baseline) {
+ return Collections.singleton(getParent());
+ } else {
+ return NOTHING_INVALIDATED;
+ }
}
@Override
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/VerticalBlock.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/VerticalBlock.java
index 43c63240..f78d7743 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/VerticalBlock.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/VerticalBlock.java
@@ -12,6 +12,7 @@ package org.eclipse.vex.core.internal.boxes;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.Collections;
import java.util.ListIterator;
import org.eclipse.vex.core.internal.core.Graphics;
@@ -153,7 +154,7 @@ public class VerticalBlock extends BaseBox implements IStructuralBox, IParentBox
}
@Override
- public boolean reconcileLayout(final Graphics graphics) {
+ public Collection<IBox> reconcileLayout(final Graphics graphics) {
final int oldHeight = height;
height = 0;
for (int i = 0; i < children.size(); i += 1) {
@@ -161,7 +162,12 @@ public class VerticalBlock extends BaseBox implements IStructuralBox, IParentBox
child.setPosition(height, 0);
height += child.getHeight();
}
- return oldHeight != height;
+
+ if (oldHeight != height) {
+ return Collections.singleton(getParent());
+ } else {
+ return NOTHING_INVALIDATED;
+ }
}
@Override
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/widget/BoxView.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/widget/BoxView.java
index a19616e7..fc0d8106 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/widget/BoxView.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/widget/BoxView.java
@@ -10,8 +10,10 @@
*******************************************************************************/
package org.eclipse.vex.core.internal.widget;
+import java.util.Collection;
+import java.util.LinkedList;
+
import org.eclipse.vex.core.internal.boxes.IBox;
-import org.eclipse.vex.core.internal.boxes.IChildBox;
import org.eclipse.vex.core.internal.boxes.RootBox;
import org.eclipse.vex.core.internal.core.Graphics;
import org.eclipse.vex.core.internal.core.Rectangle;
@@ -109,8 +111,17 @@ public class BoxView {
return new IRenderStep() {
@Override
public void render(final Graphics graphics) {
- box.layout(graphics);
- reconcileParentsLayout(box, graphics);
+ final LinkedList<IBox> invalidatedBoxes = new LinkedList<IBox>();
+ invalidatedBoxes.add(box);
+
+ while (!invalidatedBoxes.isEmpty()) {
+ final IBox invalidatedBox = invalidatedBoxes.pollFirst();
+ final Collection<IBox> nextBoxes = invalidatedBox.reconcileLayout(graphics);
+
+ invalidatedBoxes.addAll(nextBoxes); // TODO add only required boxes
+ // TODO remove unneccessary boxes
+ }
+
reconcileViewPort();
}
};
@@ -120,20 +131,6 @@ public class BoxView {
viewPort.reconcile(rootBox.getHeight() + Cursor.CARET_BUFFER);
}
- private void reconcileParentsLayout(final IBox box, final Graphics graphics) {
- IBox parentBox = getParentBox(box);
- while (parentBox != null && parentBox.reconcileLayout(graphics)) {
- parentBox = getParentBox(parentBox);
- }
- }
-
- private IBox getParentBox(final IBox box) {
- if (box instanceof IChildBox) {
- return ((IChildBox) box).getParent();
- }
- return null;
- }
-
private IRenderStep renderCursorMovement() {
return new IRenderStep() {
@Override

Back to the top