Skip to content

Implement "adoption agency algorithm" and "reconstruct the active formatting elements" #77

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Feb 2, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 0 additions & 87 deletions data/test/ignore
Original file line number Diff line number Diff line change
@@ -1,20 +1,3 @@
tb: adoption01.dat-0
tb: adoption01.dat-1
tb: adoption01.dat-10
tb: adoption01.dat-13
tb: adoption01.dat-14
tb: adoption01.dat-16
tb: adoption01.dat-2
tb: adoption01.dat-3
tb: adoption01.dat-4
tb: adoption01.dat-5
tb: adoption01.dat-6
tb: adoption01.dat-7
tb: adoption01.dat-8
tb: adoption01.dat-9
tb: adoption02.dat-0
tb: adoption02.dat-1
tb: html5test-com.dat-20
tb: isindex.dat-0
tb: isindex.dat-1
tb: isindex.dat-2
Expand All @@ -30,93 +13,23 @@ tb: ruby.dat-20
tb: ruby.dat-3
tb: ruby.dat-5
tb: ruby.dat-7
tb: tests1.dat-22
tb: tests1.dat-23
tb: tests1.dat-25
tb: tests1.dat-30
tb: tests1.dat-31
tb: tests1.dat-51
tb: tests1.dat-53
tb: tests1.dat-56
tb: tests1.dat-60
tb: tests1.dat-70
tb: tests1.dat-71
tb: tests1.dat-72
tb: tests1.dat-73
tb: tests1.dat-74
tb: tests1.dat-75
tb: tests1.dat-77
tb: tests1.dat-79
tb: tests1.dat-81
tb: tests1.dat-96
tb: tests1.dat-97
tb: tests1.dat-98
tb: tests11.dat-1
tb: tests11.dat-6
tb: tests15.dat-0
tb: tests15.dat-1
tb: tests16.dat-181
tb: tests16.dat-183
tb: tests16.dat-185
tb: tests16.dat-194
tb: tests16.dat-195
tb: tests16.dat-84
tb: tests16.dat-86
tb: tests16.dat-88
tb: tests19.dat-10
tb: tests19.dat-100
tb: tests19.dat-103
tb: tests19.dat-104
tb: tests19.dat-107
tb: tests19.dat-108
tb: tests19.dat-11
tb: tests19.dat-18
tb: tests19.dat-21
tb: tests19.dat-7
tb: tests19.dat-8
tb: tests19.dat-9
tb: tests19.dat-95
tb: tests19.dat-96
tb: tests19.dat-97
tb: tests19.dat-98
tb: tests19.dat-99
tb: tests2.dat-44
tb: tests2.dat-9
tb: tests22.dat-0
tb: tests22.dat-1
tb: tests22.dat-2
tb: tests22.dat-3
tb: tests22.dat-4
tb: tests23.dat-0
tb: tests23.dat-1
tb: tests23.dat-2
tb: tests23.dat-3
tb: tests23.dat-4
tb: tests26.dat-0
tb: tests26.dat-1
tb: tests26.dat-2
tb: tests26.dat-3
tb: tests26.dat-4
tb: tests26.dat-5
tb: tests26.dat-6
tb: tests26.dat-7
tb: tests26.dat-8
tb: tests26.dat-9
tb: tests5.dat-16
tb: tests7.dat-26
tb: tests8.dat-7
tb: tests8.dat-8
tb: tricky01.dat-0
tb: tricky01.dat-1
tb: tricky01.dat-2
tb: tricky01.dat-3
tb: tricky01.dat-4
tb: tricky01.dat-5
tb: tricky01.dat-6
tb: tricky01.dat-7
tb: tricky01.dat-8
tb: webkit01.dat-30
tb: webkit01.dat-35
tb: webkit01.dat-36
tb: webkit01.dat-37
tb: webkit02.dat-2
1 change: 1 addition & 0 deletions examples/noop-tree-builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ impl TreeSink for Sink {
fn append_doctype_to_document(&mut self, _name: String, _public_id: String, _system_id: String) { }
fn add_attrs_if_missing(&mut self, _target: usize, _attrs: Vec<Attribute>) { }
fn remove_from_parent(&mut self, _target: usize) { }
fn reparent_children(&mut self, _node: usize, _new_parent: usize) { }
fn mark_script_already_started(&mut self, _node: usize) { }
}

Expand Down
4 changes: 4 additions & 0 deletions examples/print-tree-actions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,10 @@ impl TreeSink for Sink {
println!("Remove {} from parent", target);
}

fn reparent_children(&mut self, node: usize, new_parent: usize) {
println!("Move children from {} to {}", node, new_parent);
}

fn mark_script_already_started(&mut self, node: usize) {
println!("Mark script {} as already started", node);
}
Expand Down
8 changes: 6 additions & 2 deletions src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,17 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

macro_rules! unwrap_or_return ( ($opt:expr, $retval:expr) => (
macro_rules! unwrap_or_else ( ($opt:expr, $else_block:block) => (
match $opt {
None => return $retval,
None => $else_block,
Some(x) => x,
}
));

macro_rules! unwrap_or_return ( ($opt:expr, $retval:expr) => (
unwrap_or_else!($opt, { return $retval })
));

macro_rules! test_eq ( ($name:ident, $left:expr, $right:expr) => (
#[test]
fn $name() {
Expand Down
4 changes: 4 additions & 0 deletions src/sink/owned_dom.rs
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,10 @@ impl TreeSink for Sink {
self.unparent(target);
}

fn reparent_children(&mut self, mut node: Handle, mut new_parent: Handle) {
new_parent.children.append(&mut node.children);
}

fn mark_script_already_started(&mut self, _node: Handle) { }
}

Expand Down
12 changes: 12 additions & 0 deletions src/sink/rcdom.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,18 @@ impl TreeSink for RcDom {
remove_from_parent(&target);
}

fn reparent_children(&mut self, node: Handle, new_parent: Handle) {
let children = &mut node.borrow_mut().children;
let new_children = &mut new_parent.borrow_mut().children;
for child in children.iter() {
// FIXME: It would be nice to assert that the child's parent is node, but I haven't
// found a way to do that that doesn't create overlapping borrows of RefCells.
let parent = &mut child.borrow_mut().parent;
*parent = Some(new_parent.downgrade());
}
new_children.append(children);
}

fn mark_script_already_started(&mut self, node: Handle) {
node.borrow_mut().script_already_started = true;
}
Expand Down
Loading