aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/node.rs
diff options
context:
space:
mode:
authorMs2ger <ms2ger@gmail.com>2014-12-17 10:42:52 +0100
committerJosh Matthews <josh@joshmatthews.net>2014-12-17 15:19:45 -0500
commit466faac2a507c833b282e274a28f6ae533c628f9 (patch)
tree0022a66d52deec0081b8b721b56e2f15d7225f8e /components/script/dom/node.rs
parentb8900782b0fcb409f37189bdc08eb7f8b3564a5f (diff)
downloadservo-466faac2a507c833b282e274a28f6ae533c628f9.tar.gz
servo-466faac2a507c833b282e274a28f6ae533c628f9.zip
Update rustc to revision 3dcd2157403163789aaf21a9ab3c4d30a7c6494d.
Diffstat (limited to 'components/script/dom/node.rs')
-rw-r--r--components/script/dom/node.rs314
1 files changed, 159 insertions, 155 deletions
diff --git a/components/script/dom/node.rs b/components/script/dom/node.rs
index 0871a266df3..50647862007 100644
--- a/components/script/dom/node.rs
+++ b/components/script/dom/node.rs
@@ -19,7 +19,8 @@ use dom::bindings::codegen::InheritTypes::{CharacterDataCast, NodeBase, NodeDeri
use dom::bindings::codegen::InheritTypes::{ProcessingInstructionCast, EventTargetCast};
use dom::bindings::codegen::InheritTypes::{HTMLLegendElementDerived, HTMLFieldSetElementDerived};
use dom::bindings::codegen::InheritTypes::HTMLOptGroupElementDerived;
-use dom::bindings::error::{Fallible, NotFound, HierarchyRequest, Syntax};
+use dom::bindings::error::Fallible;
+use dom::bindings::error::Error::{NotFound, HierarchyRequest, Syntax};
use dom::bindings::global::GlobalRef;
use dom::bindings::global;
use dom::bindings::js::{JS, JSRef, RootedReference, Temporary, Root};
@@ -30,15 +31,12 @@ use dom::bindings::utils;
use dom::bindings::utils::{Reflectable, Reflector, reflect_dom_object};
use dom::characterdata::CharacterData;
use dom::comment::Comment;
-use dom::document::{Document, DocumentHelpers, HTMLDocument, NonHTMLDocument, NotFromParser};
+use dom::document::{Document, DocumentHelpers, IsHTMLDocument, DocumentSource};
use dom::documentfragment::DocumentFragment;
use dom::documenttype::DocumentType;
-use dom::element::{AttributeHandlers, Element, ScriptCreated, ElementTypeId};
-use dom::element::{HTMLAnchorElementTypeId, HTMLButtonElementTypeId, ElementHelpers};
-use dom::element::{HTMLInputElementTypeId, HTMLSelectElementTypeId};
-use dom::element::{HTMLTextAreaElementTypeId, HTMLOptGroupElementTypeId};
-use dom::element::{HTMLOptionElementTypeId, HTMLFieldSetElementTypeId};
-use dom::eventtarget::{EventTarget, NodeTargetTypeId};
+use dom::element::{AttributeHandlers, Element, ElementCreator, ElementTypeId};
+use dom::element::ElementHelpers;
+use dom::eventtarget::{EventTarget, EventTargetTypeId};
use dom::nodelist::NodeList;
use dom::processinginstruction::ProcessingInstruction;
use dom::text::Text;
@@ -50,7 +48,7 @@ use devtools_traits::NodeInfo;
use script_traits::UntrustedNodeAddress;
use servo_util::geometry::Au;
use servo_util::str::{DOMString, null_str_as_empty};
-use style::{matches, AuthorOrigin, ParserContext, SelectorList};
+use style::{matches, StylesheetOrigin, ParserContext, SelectorList};
use js::jsapi::{JSContext, JSObject, JSTracer, JSRuntime};
use js::jsfriendapi;
@@ -114,7 +112,7 @@ pub struct Node {
impl NodeDerived for EventTarget {
fn is_node(&self) -> bool {
match *self.type_id() {
- NodeTargetTypeId(_) => true,
+ EventTargetTypeId::Node(_) => true,
_ => false
}
}
@@ -155,16 +153,16 @@ impl NodeFlags {
pub fn new(type_id: NodeTypeId) -> NodeFlags {
let dirty = HAS_CHANGED | IS_DIRTY | HAS_DIRTY_SIBLINGS | HAS_DIRTY_DESCENDANTS;
match type_id {
- DocumentNodeTypeId => IS_IN_DOC | dirty,
+ NodeTypeId::Document => IS_IN_DOC | dirty,
// The following elements are enabled by default.
- ElementNodeTypeId(HTMLButtonElementTypeId) |
- ElementNodeTypeId(HTMLInputElementTypeId) |
- ElementNodeTypeId(HTMLSelectElementTypeId) |
- ElementNodeTypeId(HTMLTextAreaElementTypeId) |
- ElementNodeTypeId(HTMLOptGroupElementTypeId) |
- ElementNodeTypeId(HTMLOptionElementTypeId) |
- //ElementNodeTypeId(HTMLMenuItemElementTypeId) |
- ElementNodeTypeId(HTMLFieldSetElementTypeId) => IN_ENABLED_STATE | dirty,
+ NodeTypeId::Element(ElementTypeId::HTMLButtonElement) |
+ NodeTypeId::Element(ElementTypeId::HTMLInputElement) |
+ NodeTypeId::Element(ElementTypeId::HTMLSelectElement) |
+ NodeTypeId::Element(ElementTypeId::HTMLTextAreaElement) |
+ NodeTypeId::Element(ElementTypeId::HTMLOptGroupElement) |
+ NodeTypeId::Element(ElementTypeId::HTMLOptionElement) |
+ //NodeTypeId::Element(ElementTypeId::HTMLMenuItemElement) |
+ NodeTypeId::Element(ElementTypeId::HTMLFieldSetElement) => IN_ENABLED_STATE | dirty,
_ => dirty,
}
}
@@ -257,13 +255,13 @@ impl LayoutDataRef {
#[deriving(PartialEq, Show)]
#[jstraceable]
pub enum NodeTypeId {
- DoctypeNodeTypeId,
- DocumentFragmentNodeTypeId,
- CommentNodeTypeId,
- DocumentNodeTypeId,
- ElementNodeTypeId(ElementTypeId),
- TextNodeTypeId,
- ProcessingInstructionNodeTypeId,
+ DocumentType,
+ DocumentFragment,
+ Comment,
+ Document,
+ Element(ElementTypeId),
+ Text,
+ ProcessingInstruction,
}
trait PrivateNodeHelpers {
@@ -286,7 +284,7 @@ impl<'a> PrivateNodeHelpers for JSRef<'a, Node> {
let parent = self.parent_node().root();
parent.map(|parent| vtable_for(&*parent).child_inserted(self));
- document.content_and_heritage_changed(self, OtherNodeDamage);
+ document.content_and_heritage_changed(self, NodeDamage::OtherNodeDamage);
}
// http://dom.spec.whatwg.org/#node-is-removed
@@ -546,29 +544,29 @@ impl<'a> NodeHelpers<'a> for JSRef<'a, Node> {
#[inline]
fn is_element(self) -> bool {
match self.type_id {
- ElementNodeTypeId(..) => true,
+ NodeTypeId::Element(..) => true,
_ => false
}
}
#[inline]
fn is_document(self) -> bool {
- self.type_id == DocumentNodeTypeId
+ self.type_id == NodeTypeId::Document
}
#[inline]
fn is_anchor_element(self) -> bool {
- self.type_id == ElementNodeTypeId(HTMLAnchorElementTypeId)
+ self.type_id == NodeTypeId::Element(ElementTypeId::HTMLAnchorElement)
}
#[inline]
fn is_doctype(self) -> bool {
- self.type_id == DoctypeNodeTypeId
+ self.type_id == NodeTypeId::DocumentType
}
#[inline]
fn is_text(self) -> bool {
- self.type_id == TextNodeTypeId
+ self.type_id == NodeTypeId::Text
}
fn get_flag(self, flag: NodeFlags) -> bool {
@@ -654,8 +652,8 @@ impl<'a> NodeHelpers<'a> for JSRef<'a, Node> {
fn dirty_impl(self, damage: NodeDamage, force_ancestors: bool) {
// 1. Dirty self.
match damage {
- NodeStyleDamaged => {}
- OtherNodeDamage => self.set_has_changed(true),
+ NodeDamage::NodeStyleDamaged => {}
+ NodeDamage::OtherNodeDamage => self.set_has_changed(true),
}
if self.get_is_dirty() && !force_ancestors {
@@ -741,7 +739,7 @@ impl<'a> NodeHelpers<'a> for JSRef<'a, Node> {
fn query_selector(self, selectors: DOMString) -> Fallible<Option<Temporary<Element>>> {
// Step 1.
let parser_context = ParserContext {
- origin: AuthorOrigin,
+ origin: StylesheetOrigin::Author,
};
match style::parse_selector_list_from_str(&parser_context, selectors.as_slice()) {
// Step 2.
@@ -766,7 +764,7 @@ impl<'a> NodeHelpers<'a> for JSRef<'a, Node> {
let nodes;
let root = self.ancestors().last().unwrap_or(self.clone());
let parser_context = ParserContext {
- origin: AuthorOrigin,
+ origin: StylesheetOrigin::Author,
};
match style::parse_selector_list_from_str(&parser_context, selectors.as_slice()) {
// Step 2.
@@ -1176,7 +1174,7 @@ impl Node {
fn new_(type_id: NodeTypeId, doc: Option<JSRef<Document>>) -> Node {
Node {
- eventtarget: EventTarget::new_inherited(NodeTargetTypeId(type_id)),
+ eventtarget: EventTarget::new_inherited(EventTargetTypeId::Node(type_id)),
type_id: type_id,
parent_node: Default::default(),
@@ -1214,7 +1212,7 @@ impl Node {
// Step 1.
match node.parent_node().root() {
Some(parent) => {
- Node::remove(node, *parent, Unsuppressed);
+ Node::remove(node, *parent, SuppressObserver::Unsuppressed);
}
None => (),
}
@@ -1236,9 +1234,9 @@ impl Node {
-> Fallible<Temporary<Node>> {
// Step 1.
match parent.type_id() {
- DocumentNodeTypeId |
- DocumentFragmentNodeTypeId |
- ElementNodeTypeId(..) => (),
+ NodeTypeId::Document |
+ NodeTypeId::DocumentFragment |
+ NodeTypeId::Element(..) => (),
_ => return Err(HierarchyRequest)
}
@@ -1255,29 +1253,29 @@ impl Node {
// Step 4-5.
match node.type_id() {
- TextNodeTypeId => {
+ NodeTypeId::Text => {
if parent.is_document() {
return Err(HierarchyRequest);
}
},
- DoctypeNodeTypeId => {
+ NodeTypeId::DocumentType => {
if !parent.is_document() {
return Err(HierarchyRequest);
}
},
- DocumentFragmentNodeTypeId |
- ElementNodeTypeId(_) |
- ProcessingInstructionNodeTypeId |
- CommentNodeTypeId => (),
- DocumentNodeTypeId => return Err(HierarchyRequest)
+ NodeTypeId::DocumentFragment |
+ NodeTypeId::Element(_) |
+ NodeTypeId::ProcessingInstruction |
+ NodeTypeId::Comment => (),
+ NodeTypeId::Document => return Err(HierarchyRequest)
}
// Step 6.
match parent.type_id() {
- DocumentNodeTypeId => {
+ NodeTypeId::Document => {
match node.type_id() {
// Step 6.1
- DocumentFragmentNodeTypeId => {
+ NodeTypeId::DocumentFragment => {
// Step 6.1.1(b)
if node.children().any(|c| c.is_text()) {
return Err(HierarchyRequest);
@@ -1304,7 +1302,7 @@ impl Node {
}
},
// Step 6.2
- ElementNodeTypeId(_) => {
+ NodeTypeId::Element(_) => {
if !parent.child_elements().is_empty() {
return Err(HierarchyRequest);
}
@@ -1319,7 +1317,7 @@ impl Node {
}
},
// Step 6.3
- DoctypeNodeTypeId => {
+ NodeTypeId::DocumentType => {
if parent.children().any(|c| c.is_doctype()) {
return Err(HierarchyRequest);
}
@@ -1338,10 +1336,10 @@ impl Node {
},
}
},
- TextNodeTypeId |
- ProcessingInstructionNodeTypeId |
- CommentNodeTypeId => (),
- DocumentNodeTypeId => unreachable!(),
+ NodeTypeId::Text |
+ NodeTypeId::ProcessingInstruction |
+ NodeTypeId::Comment => (),
+ NodeTypeId::Document => unreachable!(),
}
},
_ => (),
@@ -1358,7 +1356,7 @@ impl Node {
Node::adopt(node, *document);
// Step 10.
- Node::insert(node, parent, referenceChild, Unsuppressed);
+ Node::insert(node, parent, referenceChild, SuppressObserver::Unsuppressed);
// Step 11.
return Ok(Temporary::from_rooted(node))
@@ -1385,8 +1383,8 @@ impl Node {
fn fire_observer_if_necessary(node: JSRef<Node>, suppress_observers: SuppressObserver) {
match suppress_observers {
- Unsuppressed => node.node_inserted(),
- Suppressed => ()
+ SuppressObserver::Unsuppressed => node.node_inserted(),
+ SuppressObserver::Suppressed => ()
}
}
@@ -1394,14 +1392,14 @@ impl Node {
// Step 1-3: ranges.
match node.type_id() {
- DocumentFragmentNodeTypeId => {
+ NodeTypeId::DocumentFragment => {
// Step 4.
// Step 5: DocumentFragment, mutation records.
// Step 6: DocumentFragment.
let mut kids = Vec::new();
for kid in node.children() {
kids.push(kid.clone());
- Node::remove(kid, node, Suppressed);
+ Node::remove(kid, node, SuppressObserver::Suppressed);
}
// Step 7: mutation records.
@@ -1445,19 +1443,19 @@ impl Node {
let addedNodes = match node {
None => vec!(),
Some(node) => match node.type_id() {
- DocumentFragmentNodeTypeId => node.children().collect(),
+ NodeTypeId::DocumentFragment => node.children().collect(),
_ => vec!(node.clone()),
},
};
// Step 4.
for child in parent.children() {
- Node::remove(child, parent, Suppressed);
+ Node::remove(child, parent, SuppressObserver::Suppressed);
}
// Step 5.
match node {
- Some(node) => Node::insert(node, parent, None, Suppressed),
+ Some(node) => Node::insert(node, parent, None, SuppressObserver::Suppressed),
None => (),
}
@@ -1482,7 +1480,7 @@ impl Node {
}
// Step 2.
- Node::remove(child, parent, Unsuppressed);
+ Node::remove(child, parent, SuppressObserver::Unsuppressed);
// Step 3.
Ok(Temporary::from_rooted(child))
@@ -1501,8 +1499,8 @@ impl Node {
// Step 9.
match suppress_observers {
- Suppressed => (),
- Unsuppressed => node.node_removed(parent.is_in_doc()),
+ SuppressObserver::Suppressed => (),
+ SuppressObserver::Unsuppressed => node.node_removed(parent.is_in_doc()),
}
}
@@ -1519,49 +1517,51 @@ impl Node {
// Step 2.
// XXXabinader: clone() for each node as trait?
let copy: Root<Node> = match node.type_id() {
- DoctypeNodeTypeId => {
+ NodeTypeId::DocumentType => {
let doctype: JSRef<DocumentType> = DocumentTypeCast::to_ref(node).unwrap();
let doctype = DocumentType::new(doctype.name().clone(),
Some(doctype.public_id().clone()),
Some(doctype.system_id().clone()), *document);
NodeCast::from_temporary(doctype)
},
- DocumentFragmentNodeTypeId => {
+ NodeTypeId::DocumentFragment => {
let doc_fragment = DocumentFragment::new(*document);
NodeCast::from_temporary(doc_fragment)
},
- CommentNodeTypeId => {
+ NodeTypeId::Comment => {
let comment: JSRef<Comment> = CommentCast::to_ref(node).unwrap();
let comment = Comment::new(comment.characterdata().data().clone(), *document);
NodeCast::from_temporary(comment)
},
- DocumentNodeTypeId => {
+ NodeTypeId::Document => {
let document: JSRef<Document> = DocumentCast::to_ref(node).unwrap();
let is_html_doc = match document.is_html_document() {
- true => HTMLDocument,
- false => NonHTMLDocument
+ true => IsHTMLDocument::HTMLDocument,
+ false => IsHTMLDocument::NonHTMLDocument,
};
let window = document.window().root();
let document = Document::new(*window, Some(document.url().clone()),
- is_html_doc, None, NotFromParser);
+ is_html_doc, None,
+ DocumentSource::NotFromParser);
NodeCast::from_temporary(document)
},
- ElementNodeTypeId(..) => {
+ NodeTypeId::Element(..) => {
let element: JSRef<Element> = ElementCast::to_ref(node).unwrap();
let name = QualName {
ns: element.namespace().clone(),
local: element.local_name().clone()
};
let element = Element::create(name,
- element.prefix().as_ref().map(|p| p.as_slice().to_string()), *document, ScriptCreated);
+ element.prefix().as_ref().map(|p| p.as_slice().to_string()),
+ *document, ElementCreator::ScriptCreated);
NodeCast::from_temporary(element)
},
- TextNodeTypeId => {
+ NodeTypeId::Text => {
let text: JSRef<Text> = TextCast::to_ref(node).unwrap();
let text = Text::new(text.characterdata().data().clone(), *document);
NodeCast::from_temporary(text)
},
- ProcessingInstructionNodeTypeId => {
+ NodeTypeId::ProcessingInstruction => {
let pi: JSRef<ProcessingInstruction> = ProcessingInstructionCast::to_ref(node).unwrap();
let pi = ProcessingInstruction::new(pi.target().clone(),
pi.characterdata().data().clone(), *document);
@@ -1578,13 +1578,13 @@ impl Node {
// Step 4 (some data already copied in step 2).
match node.type_id() {
- DocumentNodeTypeId => {
+ NodeTypeId::Document => {
let node_doc: JSRef<Document> = DocumentCast::to_ref(node).unwrap();
let copy_doc: JSRef<Document> = DocumentCast::to_ref(*copy).unwrap();
copy_doc.set_encoding_name(node_doc.encoding_name().clone());
copy_doc.set_quirks_mode(node_doc.quirks_mode());
},
- ElementNodeTypeId(..) => {
+ NodeTypeId::Element(..) => {
let node_elem: JSRef<Element> = ElementCast::to_ref(node).unwrap();
let copy_elem: JSRef<Element> = ElementCast::to_ref(*copy).unwrap();
@@ -1605,7 +1605,7 @@ impl Node {
vtable_for(&node).cloning_steps(*copy, maybe_doc, clone_children);
// Step 6.
- if clone_children == CloneChildren {
+ if clone_children == CloneChildrenFlag::CloneChildren {
for child in node.children() {
let child_copy = Node::clone(child, Some(document), clone_children).root();
let _inserted_node = Node::pre_insert(*child_copy, *copy, None);
@@ -1648,36 +1648,36 @@ impl<'a> NodeMethods for JSRef<'a, Node> {
// http://dom.spec.whatwg.org/#dom-node-nodetype
fn NodeType(self) -> u16 {
match self.type_id {
- ElementNodeTypeId(_) => NodeConstants::ELEMENT_NODE,
- TextNodeTypeId => NodeConstants::TEXT_NODE,
- ProcessingInstructionNodeTypeId => NodeConstants::PROCESSING_INSTRUCTION_NODE,
- CommentNodeTypeId => NodeConstants::COMMENT_NODE,
- DocumentNodeTypeId => NodeConstants::DOCUMENT_NODE,
- DoctypeNodeTypeId => NodeConstants::DOCUMENT_TYPE_NODE,
- DocumentFragmentNodeTypeId => NodeConstants::DOCUMENT_FRAGMENT_NODE,
+ NodeTypeId::Element(_) => NodeConstants::ELEMENT_NODE,
+ NodeTypeId::Text => NodeConstants::TEXT_NODE,
+ NodeTypeId::ProcessingInstruction => NodeConstants::PROCESSING_INSTRUCTION_NODE,
+ NodeTypeId::Comment => NodeConstants::COMMENT_NODE,
+ NodeTypeId::Document => NodeConstants::DOCUMENT_NODE,
+ NodeTypeId::DocumentType => NodeConstants::DOCUMENT_TYPE_NODE,
+ NodeTypeId::DocumentFragment => NodeConstants::DOCUMENT_FRAGMENT_NODE,
}
}
// http://dom.spec.whatwg.org/#dom-node-nodename
fn NodeName(self) -> DOMString {
match self.type_id {
- ElementNodeTypeId(..) => {
+ NodeTypeId::Element(..) => {
let elem: JSRef<Element> = ElementCast::to_ref(self).unwrap();
elem.TagName()
}
- TextNodeTypeId => "#text".to_string(),
- ProcessingInstructionNodeTypeId => {
+ NodeTypeId::Text => "#text".to_string(),
+ NodeTypeId::ProcessingInstruction => {
let processing_instruction: JSRef<ProcessingInstruction> =
ProcessingInstructionCast::to_ref(self).unwrap();
processing_instruction.Target()
}
- CommentNodeTypeId => "#comment".to_string(),
- DoctypeNodeTypeId => {
+ NodeTypeId::Comment => "#comment".to_string(),
+ NodeTypeId::DocumentType => {
let doctype: JSRef<DocumentType> = DocumentTypeCast::to_ref(self).unwrap();
doctype.name().clone()
},
- DocumentFragmentNodeTypeId => "#document-fragment".to_string(),
- DocumentNodeTypeId => "#document".to_string()
+ NodeTypeId::DocumentFragment => "#document-fragment".to_string(),
+ NodeTypeId::Document => "#document".to_string()
}
}
@@ -1690,13 +1690,13 @@ impl<'a> NodeMethods for JSRef<'a, Node> {
// http://dom.spec.whatwg.org/#dom-node-ownerdocument
fn GetOwnerDocument(self) -> Option<Temporary<Document>> {
match self.type_id {
- ElementNodeTypeId(..) |
- CommentNodeTypeId |
- TextNodeTypeId |
- ProcessingInstructionNodeTypeId |
- DoctypeNodeTypeId |
- DocumentFragmentNodeTypeId => Some(self.owner_doc()),
- DocumentNodeTypeId => None
+ NodeTypeId::Element(..) |
+ NodeTypeId::Comment |
+ NodeTypeId::Text |
+ NodeTypeId::ProcessingInstruction |
+ NodeTypeId::DocumentType |
+ NodeTypeId::DocumentFragment => Some(self.owner_doc()),
+ NodeTypeId::Document => None
}
}
@@ -1753,9 +1753,9 @@ impl<'a> NodeMethods for JSRef<'a, Node> {
// http://dom.spec.whatwg.org/#dom-node-nodevalue
fn GetNodeValue(self) -> Option<DOMString> {
match self.type_id {
- CommentNodeTypeId |
- TextNodeTypeId |
- ProcessingInstructionNodeTypeId => {
+ NodeTypeId::Comment |
+ NodeTypeId::Text |
+ NodeTypeId::ProcessingInstruction => {
let chardata: JSRef<CharacterData> = CharacterDataCast::to_ref(self).unwrap();
Some(chardata.Data())
}
@@ -1768,9 +1768,9 @@ impl<'a> NodeMethods for JSRef<'a, Node> {
// http://dom.spec.whatwg.org/#dom-node-nodevalue
fn SetNodeValue(self, val: Option<DOMString>) {
match self.type_id {
- CommentNodeTypeId |
- TextNodeTypeId |
- ProcessingInstructionNodeTypeId => {
+ NodeTypeId::Comment |
+ NodeTypeId::Text |
+ NodeTypeId::ProcessingInstruction => {
self.SetTextContent(val)
}
_ => {}
@@ -1780,19 +1780,19 @@ impl<'a> NodeMethods for JSRef<'a, Node> {
// http://dom.spec.whatwg.org/#dom-node-textcontent
fn GetTextContent(self) -> Option<DOMString> {
match self.type_id {
- DocumentFragmentNodeTypeId |
- ElementNodeTypeId(..) => {
+ NodeTypeId::DocumentFragment |
+ NodeTypeId::Element(..) => {
let content = Node::collect_text_contents(self.traverse_preorder());
Some(content)
}
- CommentNodeTypeId |
- TextNodeTypeId |
- ProcessingInstructionNodeTypeId => {
+ NodeTypeId::Comment |
+ NodeTypeId::Text |
+ NodeTypeId::ProcessingInstruction => {
let characterdata: JSRef<CharacterData> = CharacterDataCast::to_ref(self).unwrap();
Some(characterdata.Data())
}
- DoctypeNodeTypeId |
- DocumentNodeTypeId => {
+ NodeTypeId::DocumentType |
+ NodeTypeId::Document => {
None
}
}
@@ -1802,8 +1802,8 @@ impl<'a> NodeMethods for JSRef<'a, Node> {
fn SetTextContent(self, value: Option<DOMString>) {
let value = null_str_as_empty(&value);
match self.type_id {
- DocumentFragmentNodeTypeId |
- ElementNodeTypeId(..) => {
+ NodeTypeId::DocumentFragment |
+ NodeTypeId::Element(..) => {
// Step 1-2.
let node = if value.len() == 0 {
None
@@ -1815,18 +1815,18 @@ impl<'a> NodeMethods for JSRef<'a, Node> {
// Step 3.
Node::replace_all(node.root_ref(), self);
}
- CommentNodeTypeId |
- TextNodeTypeId |
- ProcessingInstructionNodeTypeId => {
+ NodeTypeId::Comment |
+ NodeTypeId::Text |
+ NodeTypeId::ProcessingInstruction => {
let characterdata: JSRef<CharacterData> = CharacterDataCast::to_ref(self).unwrap();
characterdata.set_data(value);
// Notify the document that the content of this node is different
let document = self.owner_doc().root();
- document.content_changed(self, OtherNodeDamage);
+ document.content_changed(self, NodeDamage::OtherNodeDamage);
}
- DoctypeNodeTypeId |
- DocumentNodeTypeId => {}
+ NodeTypeId::DocumentType |
+ NodeTypeId::Document => {}
}
}
@@ -1845,9 +1845,9 @@ impl<'a> NodeMethods for JSRef<'a, Node> {
// Step 1.
match self.type_id {
- DocumentNodeTypeId |
- DocumentFragmentNodeTypeId |
- ElementNodeTypeId(..) => (),
+ NodeTypeId::Document |
+ NodeTypeId::DocumentFragment |
+ NodeTypeId::Element(..) => (),
_ => return Err(HierarchyRequest)
}
@@ -1863,23 +1863,23 @@ impl<'a> NodeMethods for JSRef<'a, Node> {
// Step 4-5.
match node.type_id() {
- TextNodeTypeId if self.is_document() => return Err(HierarchyRequest),
- DoctypeNodeTypeId if !self.is_document() => return Err(HierarchyRequest),
- DocumentFragmentNodeTypeId |
- DoctypeNodeTypeId |
- ElementNodeTypeId(..) |
- TextNodeTypeId |
- ProcessingInstructionNodeTypeId |
- CommentNodeTypeId => (),
- DocumentNodeTypeId => return Err(HierarchyRequest)
+ NodeTypeId::Text if self.is_document() => return Err(HierarchyRequest),
+ NodeTypeId::DocumentType if !self.is_document() => return Err(HierarchyRequest),
+ NodeTypeId::DocumentFragment |
+ NodeTypeId::DocumentType |
+ NodeTypeId::Element(..) |
+ NodeTypeId::Text |
+ NodeTypeId::ProcessingInstruction |
+ NodeTypeId::Comment => (),
+ NodeTypeId::Document => return Err(HierarchyRequest)
}
// Step 6.
match self.type_id {
- DocumentNodeTypeId => {
+ NodeTypeId::Document => {
match node.type_id() {
// Step 6.1
- DocumentFragmentNodeTypeId => {
+ NodeTypeId::DocumentFragment => {
// Step 6.1.1(b)
if node.children().any(|c| c.is_text()) {
return Err(HierarchyRequest);
@@ -1901,7 +1901,7 @@ impl<'a> NodeMethods for JSRef<'a, Node> {
}
},
// Step 6.2
- ElementNodeTypeId(..) => {
+ NodeTypeId::Element(..) => {
if self.child_elements().any(|c| NodeCast::from_ref(c) != child) {
return Err(HierarchyRequest);
}
@@ -1911,7 +1911,7 @@ impl<'a> NodeMethods for JSRef<'a, Node> {
}
},
// Step 6.3
- DoctypeNodeTypeId => {
+ NodeTypeId::DocumentType => {
if self.children().any(|c| c.is_doctype() && c != child) {
return Err(HierarchyRequest);
}
@@ -1921,10 +1921,10 @@ impl<'a> NodeMethods for JSRef<'a, Node> {
return Err(HierarchyRequest);
}
},
- TextNodeTypeId |
- ProcessingInstructionNodeTypeId |
- CommentNodeTypeId => (),
- DocumentNodeTypeId => unreachable!()
+ NodeTypeId::Text |
+ NodeTypeId::ProcessingInstruction |
+ NodeTypeId::Comment => (),
+ NodeTypeId::Document => unreachable!()
}
},
_ => ()
@@ -1948,16 +1948,16 @@ impl<'a> NodeMethods for JSRef<'a, Node> {
{
// Step 10.
- Node::remove(child, self, Suppressed);
+ Node::remove(child, self, SuppressObserver::Suppressed);
// Step 11.
- Node::insert(node, self, reference_child, Suppressed);
+ Node::insert(node, self, reference_child, SuppressObserver::Suppressed);
}
// Step 12-14.
// Step 13: mutation records.
child.node_removed(self.is_in_doc());
- if node.type_id() == DocumentFragmentNodeTypeId {
+ if node.type_id() == NodeTypeId::DocumentFragment {
for child_node in node.children() {
child_node.node_inserted();
}
@@ -2005,7 +2005,11 @@ impl<'a> NodeMethods for JSRef<'a, Node> {
// http://dom.spec.whatwg.org/#dom-node-clonenode
fn CloneNode(self, deep: bool) -> Temporary<Node> {
- Node::clone(self, None, if deep { CloneChildren } else { DoNotCloneChildren })
+ Node::clone(self, None, if deep {
+ CloneChildrenFlag::CloneChildren
+ } else {
+ CloneChildrenFlag::DoNotCloneChildren
+ })
}
// http://dom.spec.whatwg.org/#dom-node-isequalnode
@@ -2056,13 +2060,13 @@ impl<'a> NodeMethods for JSRef<'a, Node> {
match node.type_id() {
// Step 3.
- DoctypeNodeTypeId if !is_equal_doctype(this, node) => return false,
- ElementNodeTypeId(..) if !is_equal_element(this, node) => return false,
- ProcessingInstructionNodeTypeId if !is_equal_processinginstruction(this, node) => return false,
- TextNodeTypeId |
- CommentNodeTypeId if !is_equal_characterdata(this, node) => return false,
+ NodeTypeId::DocumentType if !is_equal_doctype(this, node) => return false,
+ NodeTypeId::Element(..) if !is_equal_element(this, node) => return false,
+ NodeTypeId::ProcessingInstruction if !is_equal_processinginstruction(this, node) => return false,
+ NodeTypeId::Text |
+ NodeTypeId::Comment if !is_equal_characterdata(this, node) => return false,
// Step 4.
- ElementNodeTypeId(..) if !is_equal_element_attrs(this, node) => return false,
+ NodeTypeId::Element(..) if !is_equal_element_attrs(this, node) => return false,
_ => ()
}
@@ -2280,11 +2284,11 @@ impl<'a> style::TNode<'a, JSRef<'a, Element>> for JSRef<'a, Node> {
}
};
match attr.namespace {
- style::SpecificNamespace(ref ns) => {
+ style::NamespaceConstraint::Specific(ref ns) => {
self.as_element().get_attribute(ns.clone(), name).root()
.map_or(false, |attr| test(attr.value().as_slice()))
},
- style::AnyNamespace => {
+ style::NamespaceConstraint::Any => {
self.as_element().get_attributes(name).iter()
.map(|attr| attr.root())
.any(|attr| test(attr.value().as_slice()))