remove use of ContentMap in MoveRight

Signed-off-by: Florian Thienel <florian@thienel.org>

diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/cursor/MoveRight.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/cursor/MoveRight.java
index d90af06..b0f8d9c 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/cursor/MoveRight.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/cursor/MoveRight.java
@@ -11,6 +11,8 @@
 package org.eclipse.vex.core.internal.cursor;
 
 import org.eclipse.vex.core.internal.boxes.IContentBox;
+import org.eclipse.vex.core.internal.boxes.ParentTraversal;
+import org.eclipse.vex.core.internal.boxes.StructuralNodeReference;
 import org.eclipse.vex.core.internal.core.Graphics;
 import org.eclipse.vex.core.internal.core.Rectangle;
 
@@ -20,11 +22,6 @@
 public class MoveRight implements ICursorMove {
 
 	@Override
-	public int calculateNewOffset(final Graphics graphics, final ContentMap contentMap, final int currentOffset, final IContentBox currentBox, final Rectangle hotArea, final int preferredX) {
-		return Math.min(currentOffset + 1, contentMap.getLastOffset());
-	}
-
-	@Override
 	public boolean preferX() {
 		return true;
 	}
@@ -33,4 +30,28 @@
 	public boolean isAbsolute() {
 		return false;
 	}
+
+	@Override
+	public int calculateNewOffset(final Graphics graphics, final ContentMap contentMap, final int currentOffset, final IContentBox currentBox, final Rectangle hotArea, final int preferredX) {
+		final int nextOffset = currentOffset + 1;
+		if (nextOffset > currentBox.getEndOffset()) {
+			final IContentBox parent = getParentContentBox(currentBox);
+			if (parent == null) {
+				return currentOffset;
+			}
+		}
+		return nextOffset;
+	}
+
+	private static IContentBox getParentContentBox(final IContentBox childBox) {
+		return childBox.accept(new ParentTraversal<IContentBox>() {
+			@Override
+			public IContentBox visit(final StructuralNodeReference box) {
+				if (box == childBox) {
+					return super.visit(box);
+				}
+				return box;
+			}
+		});
+	}
 }