TreeSink impls do not explicitly rely on and methods anymore

This commit is contained in:
Nikhil Shagrithaya 2017-08-18 19:55:34 +05:30
parent 99235c9201
commit 2cc7199f42
2 changed files with 129 additions and 88 deletions

View file

@ -820,7 +820,15 @@ impl TreeSink for Sink {
node.GetParentNode().is_some()
}
fn associate_with_form(&mut self, target: &JS<Node>, form: &JS<Node>) {
fn associate_with_form(&mut self, target: &JS<Node>, form: &JS<Node>, nodes: (&JS<Node>, Option<&JS<Node>>)) {
let (element, prev_element) = nodes;
let tree_node = prev_element.map_or(element, |prev| {
if self.has_parent_node(element) { element } else { prev }
});
if !self.same_tree(tree_node, form) {
return;
}
let node = target;
let form = Root::downcast::<HTMLFormElement>(Root::from_ref(&**form))
.expect("Owner must be a form element");
@ -862,6 +870,19 @@ impl TreeSink for Sink {
insert(&parent, None, child);
}
fn append_based_on_parent_node(
&mut self,
elem: &JS<Node>,
prev_elem: &JS<Node>,
child: NodeOrText<JS<Node>>,
) {
if self.has_parent_node(elem) {
self.append_before_sibling(elem, child);
} else {
self.append(prev_elem, child);
}
}
fn append_doctype_to_document(&mut self, name: StrTendril, public_id: StrTendril,
system_id: StrTendril) {
let doc = &*self.document;