mirror of
https://github.com/servo/servo.git
synced 2025-08-02 04:00:32 +01:00
Replace spec quotes with spec step numbers
This commit is contained in:
parent
d1c5ac31ab
commit
ce16075588
2 changed files with 12 additions and 26 deletions
|
@ -1172,11 +1172,10 @@ impl<'a> ElementMethods for JSRef<'a, Element> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn SetInnerHTML(self, value: DOMString) -> Fallible<()> {
|
fn SetInnerHTML(self, value: DOMString) -> Fallible<()> {
|
||||||
// 1. Let fragment be the result of invoking the fragment parsing algorithm
|
|
||||||
// with the new value as markup, and the context object as the context element.
|
|
||||||
// 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);
|
||||||
|
// Step 1.
|
||||||
let frag = try!(context_node.parse_fragment(value));
|
let frag = try!(context_node.parse_fragment(value));
|
||||||
|
// Step 2.
|
||||||
Node::replace_all(Some(NodeCast::from_ref(frag.root().r())), context_node);
|
Node::replace_all(Some(NodeCast::from_ref(frag.root().r())), context_node);
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -1188,22 +1187,18 @@ impl<'a> ElementMethods for JSRef<'a, Element> {
|
||||||
fn SetOuterHTML(self, value: DOMString) -> Fallible<()> {
|
fn SetOuterHTML(self, value: DOMString) -> Fallible<()> {
|
||||||
let context_document = document_from_node(self).root();
|
let context_document = document_from_node(self).root();
|
||||||
let context_node: JSRef<Node> = NodeCast::from_ref(self);
|
let context_node: JSRef<Node> = NodeCast::from_ref(self);
|
||||||
// 1. Let parent be the context object's parent.
|
// Step 1.
|
||||||
let context_parent = match context_node.parent_node() {
|
let context_parent = match context_node.parent_node() {
|
||||||
// 2. If parent is null, terminate these steps.
|
// Step 2.
|
||||||
None => return Ok(()),
|
None => return Ok(()),
|
||||||
Some(parent) => parent.root()
|
Some(parent) => parent.root()
|
||||||
};
|
};
|
||||||
|
|
||||||
let parent: Root<Node> = match context_parent.r().type_id() {
|
let parent: Root<Node> = match context_parent.r().type_id() {
|
||||||
// 3. If parent is a Document, throw a DOMException
|
// Step 3.
|
||||||
// with name "NoModificationAllowedError" exception.
|
|
||||||
NodeTypeId::Document => return Err(NoModificationAllowed),
|
NodeTypeId::Document => return Err(NoModificationAllowed),
|
||||||
|
|
||||||
// 4. If parent is a DocumentFragment, let parent be a new Element with
|
// Step 4.
|
||||||
// body as its local name,
|
|
||||||
// The HTML namespace as its namespace, and
|
|
||||||
// The context object's node document as its node document.
|
|
||||||
NodeTypeId::DocumentFragment => {
|
NodeTypeId::DocumentFragment => {
|
||||||
let body_elem = Element::create(QualName::new(ns!(HTML), atom!(body)),
|
let body_elem = Element::create(QualName::new(ns!(HTML), atom!(body)),
|
||||||
None, context_document.r(),
|
None, context_document.r(),
|
||||||
|
@ -1214,10 +1209,9 @@ impl<'a> ElementMethods for JSRef<'a, Element> {
|
||||||
_ => context_node.parent_node().unwrap().root()
|
_ => context_node.parent_node().unwrap().root()
|
||||||
};
|
};
|
||||||
|
|
||||||
// 5. Let fragment be the result of invoking the fragment parsing algorithm with
|
// Step 5.
|
||||||
// the new value as markup, and parent as the context element.
|
|
||||||
// 6. Replace the context object with fragment within the context object's parent.
|
|
||||||
let frag = try!(parent.r().parse_fragment(value));
|
let frag = try!(parent.r().parse_fragment(value));
|
||||||
|
// Step 6.
|
||||||
try!(context_parent.r().ReplaceChild(NodeCast::from_ref(frag.root().r()),
|
try!(context_parent.r().ReplaceChild(NodeCast::from_ref(frag.root().r()),
|
||||||
context_node));
|
context_node));
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
|
@ -336,24 +336,16 @@ pub fn parse_html_fragment(context_node: JSRef<Node>, input: DOMString) -> Vec<T
|
||||||
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();
|
||||||
|
|
||||||
// 1. Create a new Document node, and mark it as being an HTML document.
|
// Step 1.
|
||||||
let document = Document::new(window.r(), Some(url.clone()),
|
let document = Document::new(window.r(), Some(url.clone()),
|
||||||
IsHTMLDocument::HTMLDocument,
|
IsHTMLDocument::HTMLDocument,
|
||||||
None, None,
|
None, None,
|
||||||
DocumentSource::FromParser).root();
|
DocumentSource::FromParser).root();
|
||||||
|
|
||||||
// 2. If the node document of the context element is in quirks mode,
|
// Step 2.
|
||||||
// then let the Document be in quirks mode. Otherwise,
|
|
||||||
// the node document of the context element is in limited-quirks mode,
|
|
||||||
// then let the Document be in limited-quirks mode. Otherwise,
|
|
||||||
// leave the Document in no-quirks mode.
|
|
||||||
document.r().set_quirks_mode(context_document.r().quirks_mode());
|
document.r().set_quirks_mode(context_document.r().quirks_mode());
|
||||||
|
|
||||||
// 11. Set the parser's form element pointer to the nearest node to
|
// Step 11.
|
||||||
// the context element that is a form element (going straight up
|
|
||||||
// the ancestor chain, and including the element itself, if it
|
|
||||||
// is a form element), if any. (If there is no such form element,
|
|
||||||
// the form element pointer keeps its initial value, null.)
|
|
||||||
let form = context_node.inclusive_ancestors()
|
let form = context_node.inclusive_ancestors()
|
||||||
.find(|element| element.is_htmlformelement());
|
.find(|element| element.is_htmlformelement());
|
||||||
let fragment_context = FragmentContext {
|
let fragment_context = FragmentContext {
|
||||||
|
@ -362,7 +354,7 @@ pub fn parse_html_fragment(context_node: JSRef<Node>, input: DOMString) -> Vec<T
|
||||||
};
|
};
|
||||||
parse_html(document.r(), HTMLInput::InputString(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."
|
// Step 14.
|
||||||
let root_element = document.r().GetDocumentElement().expect("no document element").root();
|
let root_element = document.r().GetDocumentElement().expect("no document element").root();
|
||||||
let root_node: JSRef<Node> = NodeCast::from_ref(root_element.r());
|
let root_node: JSRef<Node> = NodeCast::from_ref(root_element.r());
|
||||||
root_node.children()
|
root_node.children()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue