Skip to content

Commit a1f7dae

Browse files
committed
fixup! Implement support for form owner
1 parent 4ea225e commit a1f7dae

File tree

3 files changed

+30
-11
lines changed

3 files changed

+30
-11
lines changed

examples/noop-tree-builder.rs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ impl TreeSink for Sink {
4646
x == y
4747
}
4848

49+
fn same_home_subtree(&self, _x: usize, _y: usize) -> bool {
50+
true
51+
}
52+
4953
fn elem_name(&self, target: usize) -> QualName {
5054
self.names.get(&target).expect("not an element").clone()
5155
}
@@ -60,20 +64,23 @@ impl TreeSink for Sink {
6064
self.get_id()
6165
}
6266

67+
fn has_parent_node(&self, _node: usize) -> bool {
68+
// `node` will have a parent unless a script moved it, and we're
69+
// not running scripts. Therefore we can aways return true.
70+
true
71+
}
72+
6373
fn append_before_sibling(&mut self,
6474
_sibling: usize,
65-
_new_node: NodeOrText<usize>) -> Result<(), NodeOrText<usize>> {
66-
// `sibling` will have a parent unless a script moved it, and we're
67-
// not running scripts. Therefore we can aways return `Ok(())`.
68-
Ok(())
69-
}
75+
_new_node: NodeOrText<usize>) { }
7076

7177
fn parse_error(&mut self, _msg: Cow<'static, str>) { }
7278
fn set_quirks_mode(&mut self, _mode: QuirksMode) { }
7379
fn append(&mut self, _parent: usize, _child: NodeOrText<usize>) { }
7480

7581
fn append_doctype_to_document(&mut self, _name: String, _public_id: String, _system_id: String) { }
7682
fn add_attrs_if_missing(&mut self, _target: usize, _attrs: Vec<Attribute>) { }
83+
fn associate_with_form(&mut self, _target: usize, _form: usize) { }
7784
fn remove_from_parent(&mut self, _target: usize) { }
7885
fn reparent_children(&mut self, _node: usize, _new_parent: usize) { }
7986
fn mark_script_already_started(&mut self, _node: usize) { }

examples/print-tree-actions.rs

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ impl TreeSink for Sink {
5656
x == y
5757
}
5858

59+
fn same_home_subtree(&self, _x: usize, _y: usize) -> bool {
60+
true
61+
}
62+
5963
fn elem_name(&self, target: usize) -> QualName {
6064
self.names.get(&target).expect("not an element").clone()
6165
}
@@ -73,6 +77,12 @@ impl TreeSink for Sink {
7377
id
7478
}
7579

80+
fn has_parent_node(&self, _node: usize) -> bool {
81+
// `node` will have a parent unless a script moved it, and we're
82+
// not running scripts. Therefore we can aways return true
83+
true
84+
}
85+
7686
fn append(&mut self, parent: usize, child: NodeOrText<usize>) {
7787
match child {
7888
AppendNode(n)
@@ -84,17 +94,13 @@ impl TreeSink for Sink {
8494

8595
fn append_before_sibling(&mut self,
8696
sibling: usize,
87-
new_node: NodeOrText<usize>) -> Result<(), NodeOrText<usize>> {
97+
new_node: NodeOrText<usize>) {
8898
match new_node {
8999
AppendNode(n)
90100
=> println!("Append node {} before {}", n, sibling),
91101
AppendText(t)
92102
=> println!("Append text before {}: \"{}\"", sibling, t.escape_default()),
93103
}
94-
95-
// `sibling` will have a parent unless a script moved it, and we're
96-
// not running scripts. Therefore we can aways return `Ok(())`.
97-
Ok(())
98104
}
99105

100106
fn append_doctype_to_document(&mut self, name: String, public_id: String, system_id: String) {
@@ -108,6 +114,12 @@ impl TreeSink for Sink {
108114
}
109115
}
110116

117+
fn associate_with_form(&mut self, _target: usize, _form: usize) {
118+
// No form owner support. Since same_home_subtree always returns
119+
// true we cannot be sure that this associate_with_form call is
120+
// valid
121+
}
122+
111123
fn remove_from_parent(&mut self, target: usize) {
112124
println!("Remove {} from parent", target);
113125
}

src/tree_builder/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ impl<Handle, Sink> TreeBuilder<Handle, Sink>
404404
fn insert_at(&mut self, insertion_point: InsertionPoint<Handle>, child: NodeOrText<Handle>) {
405405
match insertion_point {
406406
LastChild(parent) => self.sink.append(parent, child),
407-
BeforeSibling(sibling) => { let _ = self.sink.append_before_sibling(sibling, child); }
407+
BeforeSibling(sibling) => self.sink.append_before_sibling(sibling, child)
408408
}
409409
}
410410
}

0 commit comments

Comments
 (0)