mirror of
https://github.com/servo/servo.git
synced 2025-08-02 04:00:32 +01:00
fragment parsing functions take DOMString instead of HTMLInput
This commit is contained in:
parent
2cc5bad21e
commit
cc771fdd68
3 changed files with 8 additions and 8 deletions
|
@ -55,7 +55,6 @@ use dom::node::{window_from_node};
|
||||||
use dom::nodelist::NodeList;
|
use dom::nodelist::NodeList;
|
||||||
use dom::virtualmethods::{VirtualMethods, vtable_for};
|
use dom::virtualmethods::{VirtualMethods, vtable_for};
|
||||||
use devtools_traits::AttrInfo;
|
use devtools_traits::AttrInfo;
|
||||||
use parse::html::HTMLInput;
|
|
||||||
use style::legacy::{SimpleColorAttribute, UnsignedIntegerAttribute, IntegerAttribute, LengthAttribute};
|
use style::legacy::{SimpleColorAttribute, UnsignedIntegerAttribute, IntegerAttribute, LengthAttribute};
|
||||||
use selectors::matching::matches;
|
use selectors::matching::matches;
|
||||||
use style::properties::{PropertyDeclarationBlock, PropertyDeclaration, parse_style_attribute};
|
use style::properties::{PropertyDeclarationBlock, PropertyDeclaration, parse_style_attribute};
|
||||||
|
@ -1177,7 +1176,7 @@ impl<'a> ElementMethods for JSRef<'a, Element> {
|
||||||
// with the new value as markup, and the context object as the context element.
|
// with the new value as markup, and the context object as the context element.
|
||||||
// 2. Replace all with fragment within the context object.
|
// 2. Replace all with fragment within the context object.
|
||||||
let context_node: JSRef<Node> = NodeCast::from_ref(self);
|
let context_node: JSRef<Node> = NodeCast::from_ref(self);
|
||||||
context_node.parse_fragment(HTMLInput::InputString(value))
|
context_node.parse_fragment(value)
|
||||||
.and_then(|frag| Ok(Node::replace_all(Some(NodeCast::from_ref(frag.root().r())),
|
.and_then(|frag| Ok(Node::replace_all(Some(NodeCast::from_ref(frag.root().r())),
|
||||||
context_node)))
|
context_node)))
|
||||||
}
|
}
|
||||||
|
@ -1218,7 +1217,7 @@ impl<'a> ElementMethods for JSRef<'a, Element> {
|
||||||
// 5. Let fragment be the result of invoking the fragment parsing algorithm with
|
// 5. Let fragment be the result of invoking the fragment parsing algorithm with
|
||||||
// the new value as markup, and parent as the context element.
|
// the new value as markup, and parent as the context element.
|
||||||
// 6. Replace the context object with fragment within the context object's parent.
|
// 6. Replace the context object with fragment within the context object's parent.
|
||||||
parent.r().parse_fragment(HTMLInput::InputString(value))
|
parent.r().parse_fragment(value)
|
||||||
.and_then(|frag| {
|
.and_then(|frag| {
|
||||||
let frag = frag.root();
|
let frag = frag.root();
|
||||||
let frag_node: JSRef<Node> = NodeCast::from_ref(frag.r());
|
let frag_node: JSRef<Node> = NodeCast::from_ref(frag.r());
|
||||||
|
|
|
@ -46,7 +46,7 @@ use dom::window::{Window, WindowHelpers};
|
||||||
use geom::rect::Rect;
|
use geom::rect::Rect;
|
||||||
use layout_interface::{LayoutChan, Msg};
|
use layout_interface::{LayoutChan, Msg};
|
||||||
use devtools_traits::NodeInfo;
|
use devtools_traits::NodeInfo;
|
||||||
use parse::html::{HTMLInput, parse_html_fragment};
|
use parse::html::parse_html_fragment;
|
||||||
use script_traits::UntrustedNodeAddress;
|
use script_traits::UntrustedNodeAddress;
|
||||||
use util::geometry::Au;
|
use util::geometry::Au;
|
||||||
use util::str::{DOMString, null_str_as_empty};
|
use util::str::{DOMString, null_str_as_empty};
|
||||||
|
@ -504,7 +504,7 @@ pub trait NodeHelpers<'a> {
|
||||||
|
|
||||||
fn teardown(self);
|
fn teardown(self);
|
||||||
|
|
||||||
fn parse_fragment(self, markup: HTMLInput) -> Fallible<Temporary<DocumentFragment>>;
|
fn parse_fragment(self, markup: DOMString) -> Fallible<Temporary<DocumentFragment>>;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> NodeHelpers<'a> for JSRef<'a, Node> {
|
impl<'a> NodeHelpers<'a> for JSRef<'a, Node> {
|
||||||
|
@ -933,7 +933,7 @@ impl<'a> NodeHelpers<'a> for JSRef<'a, Node> {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dvcs.w3.org/hg/innerhtml/raw-file/tip/index.html#dfn-concept-parse-fragment
|
// https://dvcs.w3.org/hg/innerhtml/raw-file/tip/index.html#dfn-concept-parse-fragment
|
||||||
fn parse_fragment(self, markup: HTMLInput) -> Fallible<Temporary<DocumentFragment>> {
|
fn parse_fragment(self, markup: DOMString) -> Fallible<Temporary<DocumentFragment>> {
|
||||||
let context_node: JSRef<Node> = NodeCast::from_ref(self);
|
let context_node: JSRef<Node> = NodeCast::from_ref(self);
|
||||||
let context_document = document_from_node(self).root();
|
let context_document = document_from_node(self).root();
|
||||||
let new_children =
|
let new_children =
|
||||||
|
|
|
@ -31,6 +31,7 @@ use encoding::all::UTF_8;
|
||||||
use encoding::types::{Encoding, DecoderTrap};
|
use encoding::types::{Encoding, DecoderTrap};
|
||||||
|
|
||||||
use net_traits::{ProgressMsg, LoadResponse};
|
use net_traits::{ProgressMsg, LoadResponse};
|
||||||
|
use util::str::DOMString;
|
||||||
use util::task_state;
|
use util::task_state;
|
||||||
use util::task_state::IN_HTML_PARSER;
|
use util::task_state::IN_HTML_PARSER;
|
||||||
use std::ascii::AsciiExt;
|
use std::ascii::AsciiExt;
|
||||||
|
@ -330,7 +331,7 @@ pub fn parse_html(document: JSRef<Document>,
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/syntax.html#parsing-html-fragments
|
// https://html.spec.whatwg.org/multipage/syntax.html#parsing-html-fragments
|
||||||
pub fn parse_html_fragment(context_node: JSRef<Node>, input: HTMLInput) -> Vec<Temporary<Node>> {
|
pub fn parse_html_fragment(context_node: JSRef<Node>, input: DOMString) -> Vec<Temporary<Node>> {
|
||||||
let window = window_from_node(context_node).root();
|
let window = window_from_node(context_node).root();
|
||||||
let context_document = document_from_node(context_node).root();
|
let context_document = document_from_node(context_node).root();
|
||||||
let url = context_document.r().url();
|
let url = context_document.r().url();
|
||||||
|
@ -359,7 +360,7 @@ pub fn parse_html_fragment(context_node: JSRef<Node>, input: HTMLInput) -> Vec<T
|
||||||
context_elem: context_node,
|
context_elem: context_node,
|
||||||
form_elem: form,
|
form_elem: form,
|
||||||
};
|
};
|
||||||
parse_html(document.r(), input, &url, Some(fragment_context));
|
parse_html(document.r(), HTMLInput::InputString(input), &url, Some(fragment_context));
|
||||||
|
|
||||||
// "14. Return the child nodes of root, in tree order."
|
// "14. Return the child nodes of root, in tree order."
|
||||||
let root_element = document.r().GetDocumentElement().expect("no document element").root();
|
let root_element = document.r().GetDocumentElement().expect("no document element").root();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue