diff options
author | Simon Sapin <simon.sapin@exyr.org> | 2016-10-30 19:27:43 +0100 |
---|---|---|
committer | Simon Sapin <simon.sapin@exyr.org> | 2016-11-03 16:23:05 +0100 |
commit | 53b638c0e29ba78448d07695343b7ddfa36c5141 (patch) | |
tree | 52647391f6184df815a1d9ce85ad4a84e51f0ffe /components/script/dom/node.rs | |
parent | 9fcc9d9d3f59428bf19f950bd79ab257d59e3d16 (diff) | |
download | servo-53b638c0e29ba78448d07695343b7ddfa36c5141.tar.gz servo-53b638c0e29ba78448d07695343b7ddfa36c5141.zip |
Update to string-cache 0.3
Diffstat (limited to 'components/script/dom/node.rs')
-rw-r--r-- | components/script/dom/node.rs | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/components/script/dom/node.rs b/components/script/dom/node.rs index 767a3132eb3..4ec6c878ad5 100644 --- a/components/script/dom/node.rs +++ b/components/script/dom/node.rs @@ -57,6 +57,7 @@ use euclid::rect::Rect; use euclid::size::Size2D; use heapsize::{HeapSizeOf, heap_size_of}; use html5ever::tree_builder::QuirksMode; +use html5ever_atoms::{Prefix, LocalName, Namespace, QualName}; use js::jsapi::{JSContext, JSObject, JSRuntime}; use libc::{self, c_void, uintptr_t}; use msg::constellation_msg::PipelineId; @@ -75,7 +76,6 @@ use std::default::Default; use std::iter; use std::mem; use std::ops::Range; -use string_cache::{Atom, Namespace, QualName}; use style::dom::OpaqueNode; use style::selector_impl::ServoSelectorImpl; use style::thread_state; @@ -1752,7 +1752,7 @@ impl Node { local: element.local_name().clone() }; let element = Element::create(name, - element.prefix().as_ref().map(|p| Atom::from(&**p)), + element.prefix().as_ref().map(|p| Prefix::from(&**p)), &document, ElementCreator::ScriptCreated); Root::upcast::<Node>(element) }, @@ -1818,21 +1818,21 @@ impl Node { pub fn namespace_to_string(namespace: Namespace) -> Option<DOMString> { match namespace { ns!() => None, - // FIXME(ajeffrey): convert directly from &Atom to DOMString - Namespace(ref ns) => Some(DOMString::from(&**ns)) + // FIXME(ajeffrey): convert directly from Namespace to DOMString + _ => Some(DOMString::from(&*namespace)) } } // https://dom.spec.whatwg.org/#locate-a-namespace pub fn locate_namespace(node: &Node, prefix: Option<DOMString>) -> Namespace { fn attr_defines_namespace(attr: &Attr, - prefix: &Option<Atom>) -> bool { + defined_prefix: &Option<LocalName>) -> bool { *attr.namespace() == ns!(xmlns) && - match (attr.prefix(), prefix) { - (&Some(ref attr_prefix), &Some(ref prefix)) => - attr_prefix == &atom!("xmlns") && - attr.local_name() == prefix, - (&None, &None) => *attr.local_name() == atom!("xmlns"), + match (attr.prefix(), defined_prefix) { + (&Some(ref attr_prefix), &Some(ref defined_prefix)) => + attr_prefix == &namespace_prefix!("xmlns") && + attr.local_name() == defined_prefix, + (&None, &None) => *attr.local_name() == local_name!("xmlns"), _ => false } } @@ -1845,8 +1845,11 @@ impl Node { return element.namespace().clone() } - // FIXME(ajeffrey): directly convert DOMString to Atom - let prefix_atom = prefix.as_ref().map(|s| Atom::from(&**s)); + // Even though this is conceptually a namespace prefix, + // in the `xmlns:foo="https://example.net/namespace" declaration + // it is a local name. + // FIXME(ajeffrey): directly convert DOMString to LocalName + let prefix_atom = prefix.as_ref().map(|s| LocalName::from(&**s)); // Step 2. let attrs = element.attrs(); |