diff options
author | Patrick Walton <pcwalton@mimiga.net> | 2012-11-18 22:54:28 -0800 |
---|---|---|
committer | Patrick Walton <pcwalton@mimiga.net> | 2012-11-18 22:54:28 -0800 |
commit | 0537e3723f5ee9ee40a8f371446c9e18e15c3406 (patch) | |
tree | d78cb5b9d84d1cc8982406ec9352c04229586271 | |
parent | 2120a651c59918c9f641fe6880778f051fdbe71b (diff) | |
download | servo-0537e3723f5ee9ee40a8f371446c9e18e15c3406.tar.gz servo-0537e3723f5ee9ee40a8f371446c9e18e15c3406.zip |
html: Implement shallow node cloning. http://yellow5.com/pokey/ doesn't crash now.
-rw-r--r-- | src/servo/html/hubbub_html_parser.rs | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/servo/html/hubbub_html_parser.rs b/src/servo/html/hubbub_html_parser.rs index a1656f5efb2..d9f0084f3ca 100644 --- a/src/servo/html/hubbub_html_parser.rs +++ b/src/servo/html/hubbub_html_parser.rs @@ -239,7 +239,7 @@ pub fn parse_html(scope: NodeScope, let elem_kind = build_element_kind(tag.name); let elem = ElementData(copy tag.name, move elem_kind); - debug!("attach attrs"); + debug!("-- attach attrs"); for tag.attributes.each |attr| { elem.attrs.push(~Attr(copy attr.name, copy attr.value)); } @@ -282,7 +282,7 @@ pub fn parse_html(scope: NodeScope, ref_node: |_node| {}, unref_node: |_node| {}, append_child: |parent: hubbub::NodeDataPtr, child: hubbub::NodeDataPtr| unsafe { - debug!("append child"); + debug!("append child %x %x", cast::transmute(parent), cast::transmute(child)); unsafe { let p: Node = cow::wrap(cast::transmute(parent)); let c: Node = cow::wrap(cast::transmute(child)); @@ -299,9 +299,15 @@ pub fn parse_html(scope: NodeScope, debug!("remove child"); 0u }, - clone_node: |_node, _deep| { + clone_node: |node, deep| { debug!("clone node"); - 0u + unsafe { + if deep { error!("-- deep clone unimplemented"); } + let n: Node = cow::wrap(cast::transmute(node)); + let data = n.read(|read_data| copy *read_data.kind); + let new_node = scope.new_node(move data); + unsafe { cast::transmute(cow::unwrap(new_node)) } + } }, reparent_children: |_node, _new_parent| { debug!("reparent children"); |