mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-22 17:55:50 +00:00
servo: Merge #6641 - Directly append children to output node in parse_html_fragment (from michaelwu:direct-output); r=Ms2ger
Source-Repo: https://github.com/servo/servo Source-Revision: 9534e8143f52ef091595c18caeb82cfc46cc20a4
This commit is contained in:
parent
3232fd8dfe
commit
12233307ae
@ -1023,20 +1023,14 @@ impl<'a> NodeHelpers for &'a Node {
|
||||
fn parse_fragment(self, markup: DOMString) -> Fallible<Root<DocumentFragment>> {
|
||||
let context_node: &Node = NodeCast::from_ref(self);
|
||||
let context_document = document_from_node(self);
|
||||
let mut new_children: RootedVec<JS<Node>> = RootedVec::new();
|
||||
let fragment = DocumentFragment::new(context_document.r());
|
||||
if context_document.r().is_html_document() {
|
||||
parse_html_fragment(context_node, markup, &mut new_children);
|
||||
let fragment_node = NodeCast::from_ref(fragment.r());
|
||||
parse_html_fragment(context_node, markup, fragment_node);
|
||||
} else {
|
||||
// FIXME: XML case
|
||||
unimplemented!();
|
||||
}
|
||||
let fragment = DocumentFragment::new(context_document.r());
|
||||
{
|
||||
let fragment_node = NodeCast::from_ref(fragment.r());
|
||||
for node in new_children.iter() {
|
||||
fragment_node.AppendChild(node.root().r()).unwrap();
|
||||
}
|
||||
}
|
||||
Ok(fragment)
|
||||
}
|
||||
}
|
||||
|
@ -14,7 +14,6 @@ use dom::bindings::codegen::InheritTypes::{HTMLFormElementDerived, NodeCast};
|
||||
use dom::bindings::codegen::InheritTypes::ProcessingInstructionCast;
|
||||
use dom::bindings::js::{JS, Root};
|
||||
use dom::bindings::js::{RootedReference};
|
||||
use dom::bindings::trace::RootedVec;
|
||||
use dom::characterdata::{CharacterDataHelpers, CharacterDataTypeId};
|
||||
use dom::comment::Comment;
|
||||
use dom::document::{Document, DocumentHelpers};
|
||||
@ -284,7 +283,7 @@ pub fn parse_html(document: &Document,
|
||||
// https://html.spec.whatwg.org/multipage/#parsing-html-fragments
|
||||
pub fn parse_html_fragment(context_node: &Node,
|
||||
input: DOMString,
|
||||
output: &mut RootedVec<JS<Node>>) {
|
||||
output: &Node) {
|
||||
let window = window_from_node(context_node);
|
||||
let context_document = document_from_node(context_node);
|
||||
let context_document = context_document.r();
|
||||
@ -314,6 +313,6 @@ pub fn parse_html_fragment(context_node: &Node,
|
||||
let root_element = document.r().GetDocumentElement().expect("no document element");
|
||||
let root_node = NodeCast::from_ref(root_element.r());
|
||||
for child in root_node.children() {
|
||||
output.push(JS::from_rooted(&child));
|
||||
output.AppendChild(child.r()).unwrap();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user