Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Thienel2016-07-17 04:26:58 -0400
committerFlorian Thienel2016-07-17 04:26:58 -0400
commit50f69718d8711018c275fbf26c475e75da97e520 (patch)
treeec7df071bfee426057e8fd3a861ce7624f60bc53
parentfd1a4d23c2bd41c061780df6ce2785d1562ab9b4 (diff)
downloadorg.eclipse.mylyn.docs.vex-50f69718d8711018c275fbf26c475e75da97e520.tar.gz
org.eclipse.mylyn.docs.vex-50f69718d8711018c275fbf26c475e75da97e520.tar.xz
org.eclipse.mylyn.docs.vex-50f69718d8711018c275fbf26c475e75da97e520.zip
fix layout reconciliation after content deletion
Signed-off-by: Florian Thienel <florian@thienel.org>
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/internal/widget/DOMVisualization.java47
1 files changed, 46 insertions, 1 deletions
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/widget/DOMVisualization.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/widget/DOMVisualization.java
index d231581c..12411ab1 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/widget/DOMVisualization.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/widget/DOMVisualization.java
@@ -27,6 +27,7 @@ import org.eclipse.vex.core.internal.boxes.List;
import org.eclipse.vex.core.internal.boxes.ListItem;
import org.eclipse.vex.core.internal.boxes.NodeEndOffsetPlaceholder;
import org.eclipse.vex.core.internal.boxes.Paragraph;
+import org.eclipse.vex.core.internal.boxes.ParentTraversal;
import org.eclipse.vex.core.internal.boxes.RootBox;
import org.eclipse.vex.core.internal.boxes.StructuralFrame;
import org.eclipse.vex.core.internal.boxes.StructuralNodeReference;
@@ -193,7 +194,7 @@ public class DOMVisualization {
}
public void rebuildContentRange(final INode node, final ContentRange modifiedRange) {
- final IContentBox modifiedBox = contentTopology.findBoxForRange(modifiedRange);
+ final IContentBox modifiedBox = findModifiedBox(modifiedRange);
Assert.isNotNull(modifiedBox, "No box found for range " + modifiedRange);
modifiedBox.accept(new BaseBoxVisitor() {
@@ -222,4 +223,48 @@ public class DOMVisualization {
}
});
}
+
+ private IContentBox findModifiedBox(final ContentRange modifiedRange) {
+ final IContentBox modifiedBox = contentTopology.findBoxForRange(new ContentRange(modifiedRange.getStartOffset(), modifiedRange.getStartOffset()));
+ if (modifiedBox.getEndOffset() >= modifiedRange.getEndOffset()) {
+ return modifiedBox;
+ }
+ return surroundingContentBox(modifiedBox);
+ }
+
+ private static IContentBox surroundingContentBox(final IContentBox contentBox) {
+ return contentBox.accept(new ParentTraversal<IContentBox>() {
+ @Override
+ public IContentBox visit(final StructuralNodeReference box) {
+ if (box == contentBox) {
+ return super.visit(box);
+ }
+ return box;
+ }
+
+ @Override
+ public IContentBox visit(final InlineNodeReference box) {
+ if (box == contentBox) {
+ return super.visit(box);
+ }
+ return box;
+ }
+
+ @Override
+ public IContentBox visit(final TextContent box) {
+ if (box == contentBox) {
+ return super.visit(box);
+ }
+ return box;
+ }
+
+ @Override
+ public IContentBox visit(final NodeEndOffsetPlaceholder box) {
+ if (box == contentBox) {
+ return super.visit(box);
+ }
+ return box;
+ }
+ });
+ }
}

Back to the top