aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/components/script/dom/document.rs15
-rw-r--r--src/components/script/dom/node.rs10
-rw-r--r--src/components/script/html/hubbub_html_parser.rs14
-rw-r--r--src/components/script/script_task.rs9
-rw-r--r--src/test/html/content/test_documentElement.html2
5 files changed, 18 insertions, 32 deletions
diff --git a/src/components/script/dom/document.rs b/src/components/script/dom/document.rs
index a8c91558e7d..eb30f110533 100644
--- a/src/components/script/dom/document.rs
+++ b/src/components/script/dom/document.rs
@@ -77,17 +77,6 @@ impl AbstractDocument {
document: ptr as *mut Box<Document>
}
}
-
- pub fn set_root(&self, root: AbstractNode<ScriptView>) {
- assert!(do root.traverse_preorder().all |node| {
- node.node().owner_doc() == *self
- });
-
- let document = self.mut_document();
- document.node.AppendChild(AbstractNode::from_document(*self), root);
- // Register elements having "id" attribute to the owner doc.
- document.register_nodes_with_id(&root);
- }
}
#[deriving(Eq)]
@@ -173,7 +162,9 @@ impl Reflectable for Document {
impl Document {
pub fn GetDocumentElement(&self) -> Option<AbstractNode<ScriptView>> {
- self.node.first_child
+ do self.node.children().find |c| {
+ c.is_element()
+ }
}
fn get_cx(&self) -> *JSContext {
diff --git a/src/components/script/dom/node.rs b/src/components/script/dom/node.rs
index 83deddcaf50..78533b2b48c 100644
--- a/src/components/script/dom/node.rs
+++ b/src/components/script/dom/node.rs
@@ -441,9 +441,7 @@ impl<'self, View> AbstractNode<View> {
}
pub fn children(&self) -> AbstractNodeChildrenIterator<View> {
- AbstractNodeChildrenIterator {
- current_node: self.first_child(),
- }
+ self.node().children()
}
// Issue #1030: should not walk the tree
@@ -498,6 +496,12 @@ impl<View> Node<View> {
pub fn set_owner_doc(&mut self, document: AbstractDocument) {
self.owner_doc = Some(document);
}
+
+ pub fn children(&self) -> AbstractNodeChildrenIterator<View> {
+ AbstractNodeChildrenIterator {
+ current_node: self.first_child,
+ }
+ }
}
impl Node<ScriptView> {
diff --git a/src/components/script/html/hubbub_html_parser.rs b/src/components/script/html/hubbub_html_parser.rs
index ffde4eeba26..4a12a397ab0 100644
--- a/src/components/script/html/hubbub_html_parser.rs
+++ b/src/components/script/html/hubbub_html_parser.rs
@@ -72,7 +72,6 @@ pub enum HtmlDiscoveryMessage {
}
pub struct HtmlParserResult {
- root: AbstractNode<ScriptView>,
discovery_port: Port<HtmlDiscoveryMessage>,
}
@@ -300,12 +299,11 @@ pub fn parse_html(cx: *JSContext,
(*page).url = Some((url2.clone(), true));
}
- // Build the root node.
- let root = HTMLHtmlElement::new(~"html", document);
- debug!("created new node");
let mut parser = hubbub::Parser("UTF-8", false);
debug!("created parser");
- parser.set_document_node(unsafe { root.to_hubbub_node() });
+
+ let document_node = AbstractNode::<ScriptView>::from_document(document);
+ parser.set_document_node(unsafe { document_node.to_hubbub_node() });
parser.enable_scripting(true);
parser.enable_styling(true);
@@ -427,10 +425,7 @@ pub fn parse_html(cx: *JSContext,
debug!("append child {:x} {:x}", parent, child);
let parent: AbstractNode<ScriptView> = NodeWrapping::from_hubbub_node(parent);
let child: AbstractNode<ScriptView> = NodeWrapping::from_hubbub_node(child);
- // FIXME this needs to be AppendChild.
- // Probably blocked on #838, so that we can remove the
- // double root element.
- parent.add_child(child, None);
+ parent.AppendChild(child);
}
child
},
@@ -543,7 +538,6 @@ pub fn parse_html(cx: *JSContext,
js_chan.send(JSTaskExit);
HtmlParserResult {
- root: root,
discovery_port: discovery_port,
}
}
diff --git a/src/components/script/script_task.rs b/src/components/script/script_task.rs
index 7ad26a18eff..515dd1b0338 100644
--- a/src/components/script/script_task.rs
+++ b/src/components/script/script_task.rs
@@ -701,7 +701,7 @@ impl ScriptTask {
self.constellation_chan.clone());
- let HtmlParserResult {root, discovery_port} = html_parsing_result;
+ let HtmlParserResult {discovery_port} = html_parsing_result;
// Create the root frame.
page.frame = Some(Frame {
@@ -741,11 +741,8 @@ impl ScriptTask {
}
}
- // Tie the root into the document. This will kick off the initial reflow
- // of the page.
- // FIXME: We have no way to ensure that the first reflow performed is a
- // ReflowForDisplay operation.
- document.set_root(root);
+ // Kick off the initial reflow of the page.
+ document.document().content_changed();
// No more reflow required
page.url = Some((url, false));
diff --git a/src/test/html/content/test_documentElement.html b/src/test/html/content/test_documentElement.html
index 0c38828084e..eea379456b1 100644
--- a/src/test/html/content/test_documentElement.html
+++ b/src/test/html/content/test_documentElement.html
@@ -4,7 +4,7 @@
<script>
is_a(window, Window);
is_a(document.documentElement, HTMLHtmlElement);
-is_a(document.documentElement.firstChild, HTMLHtmlElement);
+is_a(document.documentElement.firstChild, HTMLHeadElement);
is(document.documentElement.nextSibling, null);
is_a(document, HTMLDocument);
is_a(document, Document);