aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorbors-servo <release+servo@mozilla.com>2013-09-12 11:43:00 -0700
committerbors-servo <release+servo@mozilla.com>2013-09-12 11:43:00 -0700
commit4cf80cd49c69a0da4b9d8c7df0ca5a9ece3b5a64 (patch)
tree7ce90d2d014839c1cd58dce5d27cc22ed366a58b /src
parentb4ffe3c3c240d5c98ad28175d8ff31350ad18087 (diff)
parent4ec428b9d6eb5d3c0e188b085bb7836cd36a12a9 (diff)
downloadservo-4cf80cd49c69a0da4b9d8c7df0ca5a9ece3b5a64.tar.gz
servo-4cf80cd49c69a0da4b9d8c7df0ca5a9ece3b5a64.zip
auto merge of #915 : jdm/servo/pinglayout, r=metajack
...Fixes #907.
Diffstat (limited to 'src')
-rw-r--r--src/components/script/dom/document.rs1
-rw-r--r--src/components/script/dom/node.rs44
-rw-r--r--src/components/script/script_task.rs10
3 files changed, 50 insertions, 5 deletions
diff --git a/src/components/script/dom/document.rs b/src/components/script/dom/document.rs
index 4333ea5b934..bc51ea7c149 100644
--- a/src/components/script/dom/document.rs
+++ b/src/components/script/dom/document.rs
@@ -33,6 +33,7 @@ pub trait WrappableDocument {
fn init_wrapper(@mut self, cx: *JSContext);
}
+#[deriving(Eq)]
pub struct AbstractDocument {
document: *Document
}
diff --git a/src/components/script/dom/node.rs b/src/components/script/dom/node.rs
index e137d4c31d0..bb3e0948f5f 100644
--- a/src/components/script/dom/node.rs
+++ b/src/components/script/dom/node.rs
@@ -414,6 +414,7 @@ impl Node<ScriptView> {
}
pub fn add_to_doc(&mut self, doc: AbstractDocument) {
+ let old_doc = self.owner_doc;
self.owner_doc = Some(doc);
let mut cur_node = self.first_child;
while cur_node.is_some() {
@@ -424,6 +425,42 @@ impl Node<ScriptView> {
};
cur_node = cur_node.unwrap().next_sibling();
}
+
+ // Signal the old document that it needs to update its display
+ match old_doc {
+ Some(old_doc) if old_doc != doc => do old_doc.with_base |old_doc| {
+ old_doc.content_changed();
+ },
+ _ => ()
+ }
+
+ // Signal the new document that it needs to update its display
+ do doc.with_base |doc| {
+ doc.content_changed();
+ }
+ }
+
+ pub fn remove_from_doc(&mut self) {
+ let old_doc = self.owner_doc;
+ self.owner_doc = None;
+
+ let mut cur_node = self.first_child;
+ while cur_node.is_some() {
+ for node in cur_node.unwrap().traverse_preorder() {
+ do node.with_mut_base |node_base| {
+ node_base.owner_doc = None;
+ }
+ };
+ cur_node = cur_node.unwrap().next_sibling();
+ }
+
+ // Signal the old document that it needs to update its display
+ match old_doc {
+ Some(doc) => do doc.with_base |doc| {
+ doc.content_changed();
+ },
+ None => ()
+ }
}
pub fn new(type_id: NodeTypeId) -> Node<ScriptView> {
@@ -592,6 +629,12 @@ impl Node<ScriptView> {
// If the node already exists it is removed from current parent node.
node.parent_node().map(|parent| parent.remove_child(node));
abstract_self.add_child(node);
+ match self.owner_doc {
+ Some(doc) => do node.with_mut_base |node| {
+ node.add_to_doc(doc);
+ },
+ None => ()
+ }
}
node
}
@@ -617,6 +660,7 @@ impl Node<ScriptView> {
}
if rv.is_ok() {
abstract_self.remove_child(node);
+ self.remove_from_doc();
}
node
}
diff --git a/src/components/script/script_task.rs b/src/components/script/script_task.rs
index 4025de24bb4..95c433c8569 100644
--- a/src/components/script/script_task.rs
+++ b/src/components/script/script_task.rs
@@ -611,11 +611,6 @@ impl ScriptTask {
let document = HTMLDocument::new(root, Some(window));
- // Tie the root into the document.
- do root.with_mut_base |base| {
- base.add_to_doc(document)
- }
-
// Create the root frame.
page.frame = Some(Frame {
document: document,
@@ -623,6 +618,11 @@ impl ScriptTask {
});
page.url = Some((url.clone(), true));
+ // Tie the root into the document.
+ do root.with_mut_base |base| {
+ base.add_to_doc(document)
+ }
+
// Send style sheets over to layout.
//
// FIXME: These should be streamed to layout as they're parsed. We don't need to stop here