insert an own box for the document
https://bugs.eclipse.org/bugs/show_bug.cgi?id=257806

Signed-off-by: Florian Thienel <florian@thienel.org>
diff --git a/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/dom/BlockElementBoxTest.java b/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/dom/BlockElementBoxTest.java
index a7e9ceb..10c2d3a 100644
--- a/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/dom/BlockElementBoxTest.java
+++ b/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/dom/BlockElementBoxTest.java
@@ -54,7 +54,7 @@
 		final Document doc = docReader.read(docString);
 		context.setDocument(doc);
 
-		final RootBox parentBox = new RootBox(context, doc.getRootElement(), 500);
+		final RootBox parentBox = new RootBox(context, doc, 500);
 
 		final BlockElementBox box = new BlockElementBox(context, parentBox, doc.getRootElement());
 
diff --git a/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/layout/LayoutTestSuite.java b/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/layout/LayoutTestSuite.java
index 59cf6f5..1875eb9 100644
--- a/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/layout/LayoutTestSuite.java
+++ b/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/layout/LayoutTestSuite.java
@@ -110,7 +110,7 @@
 		final Document doc = docReader.read(this.doc);
 		context.setDocument(doc);
 
-		final RootBox rootBox = new RootBox(context, doc.getRootElement(), layoutWidth);
+		final RootBox rootBox = new RootBox(context, doc, layoutWidth);
 		rootBox.layout(context, 0, Integer.MAX_VALUE);
 
 		assertBox(result, rootBox, "");
diff --git a/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/layout/TableLayoutTest.java b/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/layout/TableLayoutTest.java
index feed82c..ca119bc 100644
--- a/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/layout/TableLayoutTest.java
+++ b/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/layout/TableLayoutTest.java
@@ -77,7 +77,7 @@
 		document = new Document(new Element("root"));
 		context.setDocument(document);
 		caretPosition = 2;
-		rootBox = new RootBox(context, document.getRootElement(), 500);
+		rootBox = new RootBox(context, document, 500);
 	}
 
 	private void insertElement(final String elementName) {
diff --git a/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/layout/TestBlockElementBox.java b/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/layout/TestBlockElementBox.java
index 6ac82f8..b18ffff 100644
--- a/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/layout/TestBlockElementBox.java
+++ b/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/layout/TestBlockElementBox.java
@@ -44,7 +44,7 @@
 		doc.insertElement(2, new QualifiedName(null, "beforeBlock"));
 		context.setDocument(doc);
 
-		final RootBox rootBox = new RootBox(context, root, 500);
+		final RootBox rootBox = new RootBox(context, doc, 500);
 		rootBox.layout(context, 0, Integer.MAX_VALUE);
 
 		Box[] children;
@@ -54,6 +54,12 @@
 		assertEquals(1, children.length);
 		assertEquals(BlockElementBox.class, children[0].getClass());
 		beb = (BlockElementBox) children[0];
+		assertEquals(doc, beb.getNode());
+
+		children = beb.getChildren();
+		assertEquals(1, children.length);
+		assertEquals(BlockElementBox.class, children[0].getClass());
+		beb = (BlockElementBox) children[0];
 		assertEquals(root, beb.getNode());
 
 		children = beb.getChildren();
diff --git a/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/layout/TestBlocksInInlines.java b/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/layout/TestBlocksInInlines.java
index 5cf3629..08eb78d 100644
--- a/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/layout/TestBlocksInInlines.java
+++ b/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/layout/TestBlocksInInlines.java
@@ -61,7 +61,7 @@
 		doc.insertElement(11, new QualifiedName(null, "p"));
 		doc.insertText(12, "three");
 
-		final RootBox rootBox = new RootBox(context, root, 500);
+		final RootBox rootBox = new RootBox(context, doc, 500);
 		rootBox.layout(context, 0, Integer.MAX_VALUE);
 
 	}
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/layout/RootBox.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/layout/RootBox.java
index 7a58528..ae6fd76 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/layout/RootBox.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/layout/RootBox.java
@@ -14,14 +14,15 @@
 import org.eclipse.vex.core.internal.core.Caret;
 import org.eclipse.vex.core.internal.core.Insets;
 import org.eclipse.vex.core.internal.core.Rectangle;
-import org.eclipse.vex.core.internal.dom.Element;
+import org.eclipse.vex.core.internal.dom.Document;
+import org.eclipse.vex.core.internal.dom.Node;
 
 /**
  * A wrapper for the top level <code>BlockElementBox</code> that applies its margins.
  */
 public class RootBox extends AbstractBox implements BlockBox {
 
-	private final Element element;
+	private final Document document;
 	private final BlockElementBox childBox;
 	private final Box[] children = new Box[1];
 
@@ -30,16 +31,16 @@
 	 * 
 	 * @param context
 	 *            LayoutContext used to create children.
-	 * @param element
+	 * @param document
 	 *            Element associated with this box.
 	 * @param width
 	 *            width of this box
 	 */
-	public RootBox(final LayoutContext context, final Element element, final int width) {
-		this.element = element;
+	public RootBox(final LayoutContext context, final Document document, final int width) {
+		this.document = document;
 		setWidth(width);
 
-		childBox = new BlockElementBox(context, this, this.element);
+		childBox = new BlockElementBox(context, this, this.document);
 
 		final Insets insets = this.getInsets(context, getWidth());
 		childBox.setX(insets.getLeft());
@@ -67,8 +68,8 @@
 	 * @see org.eclipse.vex.core.internal.layout.Box#getNode()
 	 */
 	@Override
-	public Element getNode() {
-		return element;
+	public Node getNode() {
+		return document;
 	}
 
 	/**
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/widget/VexWidgetImpl.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/widget/VexWidgetImpl.java
index fec2339..04b5f222 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/widget/VexWidgetImpl.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/widget/VexWidgetImpl.java
@@ -1436,7 +1436,7 @@
 	private void createRootBox() {
 		final Graphics g = hostComponent.createDefaultGraphics();
 		final LayoutContext context = createLayoutContext(g);
-		rootBox = new RootBox(context, document.getRootElement(), getLayoutWidth());
+		rootBox = new RootBox(context, document, getLayoutWidth());
 		g.dispose();
 	}