diff options
author | nithin murali <imnmfotmal@gmail.com> | 2015-04-21 14:34:40 -0400 |
---|---|---|
committer | Josh Matthews <josh@joshmatthews.net> | 2015-04-22 13:47:28 -0400 |
commit | c5e101b6e53e17824a227742213ac4fd1a7dbf37 (patch) | |
tree | 6fe7a8b56dfaa24042963d627f0fd5f8f487b5bc /components/script/parse/html.rs | |
parent | 69a2c45b34124dc8b4b53806550b783abe041bc3 (diff) | |
download | servo-c5e101b6e53e17824a227742213ac4fd1a7dbf37.tar.gz servo-c5e101b6e53e17824a227742213ac4fd1a7dbf37.zip |
Implement child reparenting and node removal during parsing.
Diffstat (limited to 'components/script/parse/html.rs')
-rw-r--r-- | components/script/parse/html.rs | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/components/script/parse/html.rs b/components/script/parse/html.rs index 1424c72181c..73501809300 100644 --- a/components/script/parse/html.rs +++ b/components/script/parse/html.rs @@ -166,8 +166,11 @@ impl<'a> TreeSink for servohtmlparser::Sink { } } - fn remove_from_parent(&mut self, _target: JS<Node>) { - error!("remove_from_parent not implemented!"); + fn remove_from_parent(&mut self, target: JS<Node>) { + let node = target.root(); + if let Some(ref parent) = node.r().GetParentNode().root() { + parent.r().RemoveChild(node.r()).unwrap(); + } } fn mark_script_already_started(&mut self, node: JS<Node>) { @@ -182,8 +185,15 @@ impl<'a> TreeSink for servohtmlparser::Sink { script.map(|script| script.prepare()); } - fn reparent_children(&mut self, _node: JS<Node>, _new_parent: JS<Node>) { - panic!("unimplemented") + fn reparent_children(&mut self, node: JS<Node>, new_parent: JS<Node>) { + let new_parent = new_parent.root(); + let new_parent = new_parent.r(); + let old_parent = node.root(); + let old_parent = old_parent.r(); + while let Some(ref child) = old_parent.GetFirstChild().root() { + new_parent.AppendChild(child.r()).unwrap(); + } + } } |