aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom
diff options
context:
space:
mode:
authorAlan Jeffrey <ajeffrey@mozilla.com>2015-11-24 13:44:59 -0600
committerAlan Jeffrey <ajeffrey@mozilla.com>2015-11-25 10:13:21 -0600
commit3dec6edd10ec800de50a04c105a75fb98e0411ca (patch)
tree9ef42584eb3b543904524248ad11c1dff84082a5 /components/script/dom
parente7b19249489eff7a7fd49bf458ee7bd681f8ad13 (diff)
downloadservo-3dec6edd10ec800de50a04c105a75fb98e0411ca.tar.gz
servo-3dec6edd10ec800de50a04c105a75fb98e0411ca.zip
Update string_cache to 0.2.
Updated string_cache, html5ever, xml5ever and selectors in Cargo.toml files and Cargo.lock. Removed references to string_cache_plugin. Import atom! and ns! from string_cache. Replaced ns!("") by ns!(). Replaced ns!(XML) and co by ns!(xml) and co. Replaced atom!(foo) by atom!("foo"). Replaced Atom::from_slice by Atom::from. Replaced atom.as_slice() by &*atom.
Diffstat (limited to 'components/script/dom')
-rw-r--r--components/script/dom/attr.rs2
-rw-r--r--components/script/dom/bindings/xmlname.rs14
-rw-r--r--components/script/dom/create.rs2
-rw-r--r--components/script/dom/cssstyledeclaration.rs6
-rw-r--r--components/script/dom/document.rs56
-rw-r--r--components/script/dom/documentfragment.rs4
-rw-r--r--components/script/dom/domtokenlist.rs4
-rw-r--r--components/script/dom/element.rs74
-rw-r--r--components/script/dom/event.rs2
-rw-r--r--components/script/dom/eventtarget.rs10
-rw-r--r--components/script/dom/htmlanchorelement.rs2
-rw-r--r--components/script/dom/htmlbaseelement.rs4
-rw-r--r--components/script/dom/htmlbodyelement.rs16
-rw-r--r--components/script/dom/htmlbuttonelement.rs2
-rw-r--r--components/script/dom/htmlcanvaselement.rs6
-rw-r--r--components/script/dom/htmlcollection.rs10
-rw-r--r--components/script/dom/htmlelement.rs14
-rw-r--r--components/script/dom/htmlfieldsetelement.rs2
-rw-r--r--components/script/dom/htmlfontelement.rs6
-rw-r--r--components/script/dom/htmlhrelement.rs4
-rw-r--r--components/script/dom/htmliframeelement.rs10
-rw-r--r--components/script/dom/htmlimageelement.rs2
-rw-r--r--components/script/dom/htmlinputelement.rs24
-rw-r--r--components/script/dom/htmllabelelement.rs2
-rw-r--r--components/script/dom/htmllinkelement.rs10
-rw-r--r--components/script/dom/htmlmetaelement.rs4
-rw-r--r--components/script/dom/htmlobjectelement.rs6
-rw-r--r--components/script/dom/htmloptgroupelement.rs2
-rw-r--r--components/script/dom/htmloptionelement.rs6
-rw-r--r--components/script/dom/htmlscriptelement.rs12
-rw-r--r--components/script/dom/htmlselectelement.rs2
-rw-r--r--components/script/dom/htmlstyleelement.rs2
-rw-r--r--components/script/dom/htmltablecellelement.rs6
-rw-r--r--components/script/dom/htmltableelement.rs8
-rw-r--r--components/script/dom/htmltablerowelement.rs2
-rw-r--r--components/script/dom/htmltablesectionelement.rs2
-rw-r--r--components/script/dom/htmltextareaelement.rs6
-rw-r--r--components/script/dom/macros.rs26
-rw-r--r--components/script/dom/namednodemap.rs4
-rw-r--r--components/script/dom/node.rs24
40 files changed, 202 insertions, 198 deletions
diff --git a/components/script/dom/attr.rs b/components/script/dom/attr.rs
index 1e2692f064b..9a3593f20d8 100644
--- a/components/script/dom/attr.rs
+++ b/components/script/dom/attr.rs
@@ -170,7 +170,7 @@ impl Attr {
assert!(Some(owner) == self.owner().r());
owner.will_mutate_attr();
mem::swap(&mut *self.value.borrow_mut(), &mut value);
- if self.identifier.namespace == ns!("") {
+ if self.identifier.namespace == ns!() {
vtable_for(owner.upcast())
.attribute_mutated(self, AttributeMutation::Set(Some(&value)));
}
diff --git a/components/script/dom/bindings/xmlname.rs b/components/script/dom/bindings/xmlname.rs
index 63a71b266b7..957de10c9eb 100644
--- a/components/script/dom/bindings/xmlname.rs
+++ b/components/script/dom/bindings/xmlname.rs
@@ -57,25 +57,25 @@ pub fn validate_and_extract(namespace: Option<DOMString>,
debug_assert!(!local_name.contains(colon));
match (namespace, maybe_prefix) {
- (ns!(""), Some(_)) => {
+ (ns!(), Some(_)) => {
// Step 6.
Err(Error::Namespace)
},
- (ref ns, Some("xml")) if ns != &ns!(XML) => {
+ (ref ns, Some("xml")) if ns != &ns!(xml) => {
// Step 7.
Err(Error::Namespace)
},
- (ref ns, p) if ns != &ns!(XMLNS) && (qualified_name == "xmlns" || p == Some("xmlns")) => {
+ (ref ns, p) if ns != &ns!(xmlns) && (qualified_name == "xmlns" || p == Some("xmlns")) => {
// Step 8.
Err(Error::Namespace)
},
- (ns!(XMLNS), p) if qualified_name != "xmlns" && p != Some("xmlns") => {
+ (ns!(xmlns), p) if qualified_name != "xmlns" && p != Some("xmlns") => {
// Step 9.
Err(Error::Namespace)
},
(ns, p) => {
// Step 10.
- Ok((ns, p.map(Atom::from_slice), Atom::from_slice(local_name)))
+ Ok((ns, p.map(Atom::from), Atom::from(local_name)))
}
}
}
@@ -171,7 +171,7 @@ pub fn xml_name_type(name: &str) -> XMLName {
/// If the URL is None, returns the empty namespace.
pub fn namespace_from_domstring(url: Option<DOMString>) -> Namespace {
match url {
- None => ns!(""),
- Some(ref s) => Namespace(Atom::from_slice(s)),
+ None => ns!(),
+ Some(s) => Namespace(Atom::from(&*s)),
}
}
diff --git a/components/script/dom/create.rs b/components/script/dom/create.rs
index 266a810ff6c..655c6a8d786 100644
--- a/components/script/dom/create.rs
+++ b/components/script/dom/create.rs
@@ -86,7 +86,7 @@ pub fn create_element(name: QualName,
let prefix = prefix.map(|p| DOMString::from(&*p));
- if name.ns != ns!(HTML) {
+ if name.ns != ns!(html) {
return Element::new(DOMString::from(&*name.local), name.ns, prefix, document);
}
diff --git a/components/script/dom/cssstyledeclaration.rs b/components/script/dom/cssstyledeclaration.rs
index 05caa20f642..14285dc4c2e 100644
--- a/components/script/dom/cssstyledeclaration.rs
+++ b/components/script/dom/cssstyledeclaration.rs
@@ -145,7 +145,7 @@ impl CSSStyleDeclarationMethods for CSSStyleDeclaration {
// Step 1
property.make_ascii_lowercase();
- let property = Atom::from_slice(&property);
+ let property = Atom::from(&*property);
if self.readonly {
// Readonly style declarations are used for getComputedStyle.
@@ -160,7 +160,7 @@ impl CSSStyleDeclarationMethods for CSSStyleDeclaration {
// Step 2.2
for longhand in shorthand.longhands() {
// Step 2.2.1
- let declaration = owner.get_inline_style_declaration(&Atom::from_slice(&longhand));
+ let declaration = owner.get_inline_style_declaration(&Atom::from(*longhand));
// Step 2.2.2 & 2.2.3
match declaration {
@@ -185,7 +185,7 @@ impl CSSStyleDeclarationMethods for CSSStyleDeclaration {
fn GetPropertyPriority(&self, mut property: DOMString) -> DOMString {
// Step 1
property.make_ascii_lowercase();
- let property = Atom::from_slice(&property);
+ let property = Atom::from(&*property);
// Step 2
if let Some(shorthand) = Shorthand::from_name(&property) {
diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs
index be57cf45ae4..b8ca6723e2c 100644
--- a/components/script/dom/document.rs
+++ b/components/script/dom/document.rs
@@ -478,10 +478,10 @@ impl Document {
/// Attempt to find a named element in this page's document.
/// https://html.spec.whatwg.org/multipage/#the-indicated-part-of-the-document
pub fn find_fragment_node(&self, fragid: &str) -> Option<Root<Element>> {
- self.get_element_by_id(&Atom::from_slice(fragid)).or_else(|| {
+ self.get_element_by_id(&Atom::from(fragid)).or_else(|| {
let check_anchor = |node: &HTMLAnchorElement| {
let elem = node.upcast::<Element>();
- elem.get_attribute(&ns!(""), &atom!("name"))
+ elem.get_attribute(&ns!(), &atom!("name"))
.map_or(false, |attr| &**attr.value() == fragid)
};
let doc_node = self.upcast::<Node>();
@@ -1037,7 +1037,7 @@ impl Document {
pub fn set_body_attribute(&self, local_name: &Atom, value: DOMString) {
if let Some(ref body) = self.GetBody().and_then(Root::downcast::<HTMLBodyElement>) {
let body = body.upcast::<Element>();
- let value = body.parse_attribute(&ns!(""), &local_name, value);
+ let value = body.parse_attribute(&ns!(), &local_name, value);
body.set_attribute(local_name, value);
}
}
@@ -1700,13 +1700,13 @@ impl DocumentMethods for Document {
// https://dom.spec.whatwg.org/#dom-document-getelementsbytagname
fn GetElementsByTagName(&self, tag_name: DOMString) -> Root<HTMLCollection> {
- let tag_atom = Atom::from_slice(&tag_name);
+ let tag_atom = Atom::from(&*tag_name);
match self.tag_map.borrow_mut().entry(tag_atom.clone()) {
Occupied(entry) => Root::from_ref(entry.get()),
Vacant(entry) => {
let mut tag_copy = tag_name;
tag_copy.make_ascii_lowercase();
- let ascii_lower_tag = Atom::from_slice(&tag_copy);
+ let ascii_lower_tag = Atom::from(&*tag_copy);
let result = HTMLCollection::by_atomic_tag_name(&self.window,
self.upcast(),
tag_atom,
@@ -1723,7 +1723,7 @@ impl DocumentMethods for Document {
tag_name: DOMString)
-> Root<HTMLCollection> {
let ns = namespace_from_domstring(maybe_ns);
- let local = Atom::from_slice(&tag_name);
+ let local = Atom::from(&*tag_name);
let qname = QualName::new(ns, local);
match self.tagns_map.borrow_mut().entry(qname.clone()) {
Occupied(entry) => Root::from_ref(entry.get()),
@@ -1738,7 +1738,7 @@ impl DocumentMethods for Document {
// https://dom.spec.whatwg.org/#dom-document-getelementsbyclassname
fn GetElementsByClassName(&self, classes: DOMString) -> Root<HTMLCollection> {
let class_atoms: Vec<Atom> = split_html_space_chars(&classes)
- .map(Atom::from_slice)
+ .map(Atom::from)
.collect();
match self.classes_map.borrow_mut().entry(class_atoms.clone()) {
Occupied(entry) => Root::from_ref(entry.get()),
@@ -1754,7 +1754,7 @@ impl DocumentMethods for Document {
// https://dom.spec.whatwg.org/#dom-nonelementparentnode-getelementbyid
fn GetElementById(&self, id: DOMString) -> Option<Root<Element>> {
- self.get_element_by_id(&Atom::from_slice(&id))
+ self.get_element_by_id(&Atom::from(&*id))
}
// https://dom.spec.whatwg.org/#dom-document-createelement
@@ -1766,7 +1766,7 @@ impl DocumentMethods for Document {
if self.is_html_document {
local_name.make_ascii_lowercase();
}
- let name = QualName::new(ns!(HTML), Atom::from_slice(&local_name));
+ let name = QualName::new(ns!(html), Atom::from(&*local_name));
Ok(Element::create(name, None, self, ElementCreator::ScriptCreated))
}
@@ -1788,12 +1788,12 @@ impl DocumentMethods for Document {
return Err(Error::InvalidCharacter);
}
- let name = Atom::from_slice(&local_name);
+ let name = Atom::from(&*local_name);
// repetition used because string_cache::atom::Atom is non-copyable
- let l_name = Atom::from_slice(&local_name);
+ let l_name = Atom::from(&*local_name);
let value = AttrValue::String(DOMString::new());
- Ok(Attr::new(&self.window, name, value, l_name, ns!(""), None, None))
+ Ok(Attr::new(&self.window, name, value, l_name, ns!(), None, None))
}
// https://dom.spec.whatwg.org/#dom-document-createattributens
@@ -1804,7 +1804,7 @@ impl DocumentMethods for Document {
let (namespace, prefix, local_name) = try!(validate_and_extract(namespace,
&qualified_name));
let value = AttrValue::String(DOMString::new());
- let qualified_name = Atom::from_slice(&qualified_name);
+ let qualified_name = Atom::from(&*qualified_name);
Ok(Attr::new(&self.window,
local_name,
value,
@@ -1964,12 +1964,12 @@ impl DocumentMethods for Document {
// https://html.spec.whatwg.org/multipage/#document.title
fn Title(&self) -> DOMString {
let title = self.GetDocumentElement().and_then(|root| {
- if root.namespace() == &ns!(SVG) && root.local_name() == &atom!("svg") {
+ if root.namespace() == &ns!(svg) && root.local_name() == &atom!("svg") {
// Step 1.
root.upcast::<Node>()
.child_elements()
.find(|node| {
- node.namespace() == &ns!(SVG) && node.local_name() == &atom!("title")
+ node.namespace() == &ns!(svg) && node.local_name() == &atom!("title")
})
.map(Root::upcast::<Node>)
} else {
@@ -1997,14 +1997,14 @@ impl DocumentMethods for Document {
None => return,
};
- let elem = if root.namespace() == &ns!(SVG) && root.local_name() == &atom!("svg") {
+ let elem = if root.namespace() == &ns!(svg) && root.local_name() == &atom!("svg") {
let elem = root.upcast::<Node>().child_elements().find(|node| {
- node.namespace() == &ns!(SVG) && node.local_name() == &atom!("title")
+ node.namespace() == &ns!(svg) && node.local_name() == &atom!("title")
});
match elem {
Some(elem) => Root::upcast::<Node>(elem),
None => {
- let name = QualName::new(ns!(SVG), atom!("title"));
+ let name = QualName::new(ns!(svg), atom!("title"));
let elem = Element::create(name, None, self, ElementCreator::ScriptCreated);
let parent = root.upcast::<Node>();
let child = elem.upcast::<Node>();
@@ -2012,7 +2012,7 @@ impl DocumentMethods for Document {
.unwrap()
}
}
- } else if root.namespace() == &ns!(HTML) {
+ } else if root.namespace() == &ns!(html) {
let elem = root.upcast::<Node>()
.traverse_preorder()
.find(|node| node.is::<HTMLTitleElement>());
@@ -2021,7 +2021,7 @@ impl DocumentMethods for Document {
None => {
match self.GetHead() {
Some(head) => {
- let name = QualName::new(ns!(HTML), atom!("title"));
+ let name = QualName::new(ns!(html), atom!("title"));
let elem = Element::create(name,
None,
self,
@@ -2113,10 +2113,10 @@ impl DocumentMethods for Document {
Some(element) => element,
None => return false,
};
- if element.namespace() != &ns!(HTML) {
+ if element.namespace() != &ns!(html) {
return false;
}
- element.get_attribute(&ns!(""), &atom!("name"))
+ element.get_attribute(&ns!(), &atom!("name"))
.map_or(false, |attr| &**attr.value() == &*name)
})
}
@@ -2299,10 +2299,10 @@ impl DocumentMethods for Document {
};
match html_elem_type {
HTMLElementTypeId::HTMLAppletElement => {
- match elem.get_attribute(&ns!(""), &atom!("name")) {
+ match elem.get_attribute(&ns!(), &atom!("name")) {
Some(ref attr) if attr.value().as_atom() == name => true,
_ => {
- match elem.get_attribute(&ns!(""), &atom!("id")) {
+ match elem.get_attribute(&ns!(), &atom!("id")) {
Some(ref attr) => attr.value().as_atom() == name,
None => false,
}
@@ -2310,18 +2310,18 @@ impl DocumentMethods for Document {
}
},
HTMLElementTypeId::HTMLFormElement => {
- match elem.get_attribute(&ns!(""), &atom!("name")) {
+ match elem.get_attribute(&ns!(), &atom!("name")) {
Some(ref attr) => attr.value().as_atom() == name,
None => false,
}
},
HTMLElementTypeId::HTMLImageElement => {
- match elem.get_attribute(&ns!(""), &atom!("name")) {
+ match elem.get_attribute(&ns!(), &atom!("name")) {
Some(ref attr) => {
if attr.value().as_atom() == name {
true
} else {
- match elem.get_attribute(&ns!(""), &atom!("id")) {
+ match elem.get_attribute(&ns!(), &atom!("id")) {
Some(ref attr) => attr.value().as_atom() == name,
None => false,
}
@@ -2334,7 +2334,7 @@ impl DocumentMethods for Document {
_ => false,
}
}
- let name = Atom::from_slice(&name);
+ let name = Atom::from(&*name);
let root = self.upcast::<Node>();
{
// Step 1.
diff --git a/components/script/dom/documentfragment.rs b/components/script/dom/documentfragment.rs
index 1334bff1da0..471da29be51 100644
--- a/components/script/dom/documentfragment.rs
+++ b/components/script/dom/documentfragment.rs
@@ -55,9 +55,9 @@ impl DocumentFragmentMethods for DocumentFragment {
// https://dom.spec.whatwg.org/#dom-nonelementparentnode-getelementbyid
fn GetElementById(&self, id: DOMString) -> Option<Root<Element>> {
let node = self.upcast::<Node>();
- let id = Atom::from_slice(&id);
+ let id = Atom::from(&*id);
node.traverse_preorder().filter_map(Root::downcast::<Element>).find(|descendant| {
- match descendant.get_attribute(&ns!(""), &atom!(id)) {
+ match descendant.get_attribute(&ns!(), &atom!("id")) {
None => false,
Some(attr) => *attr.value().as_atom() == id,
}
diff --git a/components/script/dom/domtokenlist.rs b/components/script/dom/domtokenlist.rs
index 23bfb7ed300..6c1c931c407 100644
--- a/components/script/dom/domtokenlist.rs
+++ b/components/script/dom/domtokenlist.rs
@@ -38,14 +38,14 @@ impl DOMTokenList {
}
fn attribute(&self) -> Option<Root<Attr>> {
- self.element.get_attribute(&ns!(""), &self.local_name)
+ self.element.get_attribute(&ns!(), &self.local_name)
}
fn check_token_exceptions(&self, token: &str) -> Fallible<Atom> {
match token {
"" => Err(Error::Syntax),
slice if slice.find(HTML_SPACE_CHARACTERS).is_some() => Err(Error::InvalidCharacter),
- slice => Ok(Atom::from_slice(slice)),
+ slice => Ok(Atom::from(slice)),
}
}
}
diff --git a/components/script/dom/element.rs b/components/script/dom/element.rs
index b62f8768da2..92ac3c8e1b2 100644
--- a/components/script/dom/element.rs
+++ b/components/script/dom/element.rs
@@ -138,7 +138,7 @@ impl Element {
-> Element {
Element {
node: Node::new_inherited(document),
- local_name: Atom::from_slice(&local_name),
+ local_name: Atom::from(&*local_name),
namespace: namespace,
prefix: prefix,
attrs: DOMRefCell::new(vec![]),
@@ -241,7 +241,7 @@ impl LayoutElementHelpers for LayoutJS<Element> {
#[allow(unsafe_code)]
#[inline]
unsafe fn has_class_for_layout(&self, name: &Atom) -> bool {
- get_attr_for_layout(&*self.unsafe_get(), &ns!(""), &atom!("class")).map_or(false, |attr| {
+ get_attr_for_layout(&*self.unsafe_get(), &ns!(), &atom!("class")).map_or(false, |attr| {
attr.value_tokens_forever().unwrap().iter().any(|atom| atom == name)
})
}
@@ -249,7 +249,7 @@ impl LayoutElementHelpers for LayoutJS<Element> {
#[allow(unsafe_code)]
#[inline]
unsafe fn get_classes_for_layout(&self) -> Option<&'static [Atom]> {
- get_attr_for_layout(&*self.unsafe_get(), &ns!(""), &atom!("class"))
+ get_attr_for_layout(&*self.unsafe_get(), &ns!(), &atom!("class"))
.map(|attr| attr.value_tokens_forever().unwrap())
}
@@ -364,7 +364,7 @@ impl LayoutElementHelpers for LayoutJS<Element> {
// FIXME(pcwalton): More use of atoms, please!
// FIXME(Ms2ger): this is nonsense! Invalid values also end up as
// a text field
- match (*self.unsafe_get()).get_attr_val_for_layout(&ns!(""), &atom!("type")) {
+ match (*self.unsafe_get()).get_attr_val_for_layout(&ns!(), &atom!("type")) {
Some("text") | Some("password") => {
match this.get_size_for_layout() {
0 => None,
@@ -517,7 +517,7 @@ impl LayoutElementHelpers for LayoutJS<Element> {
#[inline]
#[allow(unsafe_code)]
unsafe fn html_element_in_html_document_for_layout(&self) -> bool {
- if (*self.unsafe_get()).namespace != ns!(HTML) {
+ if (*self.unsafe_get()).namespace != ns!(html) {
return false;
}
self.upcast::<Node>().owner_doc_for_layout().is_html_document_for_layout()
@@ -593,7 +593,7 @@ pub enum StylePriority {
impl Element {
pub fn html_element_in_html_document(&self) -> bool {
- self.namespace == ns!(HTML) && self.upcast::<Node>().is_in_html_doc()
+ self.namespace == ns!(html) && self.upcast::<Node>().is_in_html_doc()
}
pub fn local_name(&self) -> &Atom {
@@ -604,7 +604,7 @@ impl Element {
if self.html_element_in_html_document() {
name.make_ascii_lowercase();
}
- Atom::from_slice(&name)
+ Atom::from(&*name)
}
pub fn namespace(&self) -> &Namespace {
@@ -630,15 +630,17 @@ impl Element {
}
pub fn is_void(&self) -> bool {
- if self.namespace != ns!(HTML) {
+ if self.namespace != ns!(html) {
return false
}
match self.local_name {
/* List of void elements from
https://html.spec.whatwg.org/multipage/#html-fragment-serialisation-algorithm */
- atom!(area) | atom!(base) | atom!(basefont) | atom!(bgsound) | atom!(br) | atom!(col) | atom!(embed) |
- atom!(frame) | atom!(hr) | atom!(img) | atom!(input) | atom!(keygen) | atom!(link) | atom!(menuitem) |
- atom!(meta) | atom!(param) | atom!(source) | atom!(track) | atom!(wbr) => true,
+
+ atom!("area") | atom!("base") | atom!("basefont") | atom!("bgsound") | atom!("br") |
+ atom!("col") | atom!("embed") | atom!("frame") | atom!("hr") | atom!("img") |
+ atom!("input") | atom!("keygen") | atom!("link") | atom!("menuitem") | atom!("meta") |
+ atom!("param") | atom!("source") | atom!("track") | atom!("wbr") => true,
_ => false
}
}
@@ -855,7 +857,7 @@ impl Element {
prefix: Option<Atom>) {
self.will_mutate_attr();
let window = window_from_node(self);
- let in_empty_ns = namespace == ns!("");
+ let in_empty_ns = namespace == ns!();
let attr = Attr::new(&window,
local_name,
value,
@@ -899,7 +901,7 @@ impl Element {
None => qname.local.clone(),
Some(ref prefix) => {
let name = format!("{}:{}", &**prefix, &*qname.local);
- Atom::from_slice(&name)
+ Atom::from(&*name)
},
};
let value = self.parse_attribute(&qname.ns, &qname.local, value);
@@ -913,7 +915,7 @@ impl Element {
self.set_first_matching_attribute(name.clone(),
value,
name.clone(),
- ns!(""),
+ ns!(),
None,
|attr| attr.local_name() == name);
}
@@ -927,15 +929,15 @@ impl Element {
}
// Steps 2-5.
- let name = Atom::from_slice(&name);
- let value = self.parse_attribute(&ns!(""), &name, value);
+ let name = Atom::from(&*name);
+ let value = self.parse_attribute(&ns!(), &name, value);
self.set_first_matching_attribute(name.clone(),
value,
name.clone(),
- ns!(""),
+ ns!(),
None,
|attr| {
- *attr.name() == name && *attr.namespace() == ns!("")
+ *attr.name() == name && *attr.namespace() == ns!()
});
Ok(())
}
@@ -966,7 +968,7 @@ impl Element {
local_name: &Atom,
value: DOMString)
-> AttrValue {
- if *namespace == ns!("") {
+ if *namespace == ns!() {
vtable_for(self.upcast()).parse_plain_attribute(local_name, value)
} else {
AttrValue::String(value)
@@ -993,7 +995,7 @@ impl Element {
let attr = Root::from_ref(&*(*self.attrs.borrow())[idx]);
self.attrs.borrow_mut().remove(idx);
attr.set_owner(None);
- if attr.namespace() == &ns!("") {
+ if attr.namespace() == &ns!() {
vtable_for(self.upcast()).attribute_mutated(&attr, AttributeMutation::Removed);
}
attr
@@ -1008,7 +1010,7 @@ impl Element {
Quirks => lhs.eq_ignore_ascii_case(&rhs),
}
};
- self.get_attribute(&ns!(""), &atom!("class"))
+ self.get_attribute(&ns!(), &atom!("class"))
.map(|attr| attr.value().as_tokens().iter().any(|atom| is_equal(name, atom)))
.unwrap_or(false)
}
@@ -1024,7 +1026,7 @@ impl Element {
self.attrs
.borrow()
.iter()
- .any(|attr| attr.local_name() == local_name && attr.namespace() == &ns!(""))
+ .any(|attr| attr.local_name() == local_name && attr.namespace() == &ns!())
}
pub fn set_bool_attribute(&self, local_name: &Atom, value: bool) {
@@ -1034,7 +1036,7 @@ impl Element {
if value {
self.set_string_attribute(local_name, DOMString::new());
} else {
- self.remove_attribute(&ns!(""), local_name);
+ self.remove_attribute(&ns!(), local_name);
}
}
@@ -1058,7 +1060,7 @@ impl Element {
}
pub fn get_string_attribute(&self, local_name: &Atom) -> DOMString {
- match self.get_attribute(&ns!(""), local_name) {
+ match self.get_attribute(&ns!(), local_name) {
Some(x) => x.Value(),
None => DOMString::new(),
}
@@ -1069,7 +1071,7 @@ impl Element {
}
pub fn get_tokenlist_attribute(&self, local_name: &Atom) -> Vec<Atom> {
- self.get_attribute(&ns!(""), local_name).map(|attr| {
+ self.get_attribute(&ns!(), local_name).map(|attr| {
attr.r()
.value()
.as_tokens()
@@ -1089,7 +1091,7 @@ impl Element {
pub fn get_uint_attribute(&self, local_name: &Atom, default: u32) -> u32 {
assert!(local_name.chars().all(|ch| !ch.is_ascii() || ch.to_ascii_lowercase() == ch));
- let attribute = self.get_attribute(&ns!(""), local_name);
+ let attribute = self.get_attribute(&ns!(), local_name);
match attribute {
Some(ref attribute) => {
match *attribute.value() {
@@ -1201,7 +1203,7 @@ impl ElementMethods for Element {
local_name: DOMString)
-> Option<Root<Attr>> {
let namespace = &namespace_from_domstring(namespace);
- self.get_attribute(namespace, &Atom::from_slice(&local_name))
+ self.get_attribute(namespace, &Atom::from(&*local_name))
}
// https://dom.spec.whatwg.org/#dom-element-setattribute
@@ -1215,9 +1217,9 @@ impl ElementMethods for Element {
let name = self.parsed_name(name);
// Step 3-5.
- let value = self.parse_attribute(&ns!(""), &name, value);
+ let value = self.parse_attribute(&ns!(), &name, value);
self.set_first_matching_attribute(
- name.clone(), value, name.clone(), ns!(""), None,
+ name.clone(), value, name.clone(), ns!(), None,
|attr| *attr.name() == name);
Ok(())
}
@@ -1229,7 +1231,7 @@ impl ElementMethods for Element {
value: DOMString) -> ErrorResult {
let (namespace, prefix, local_name) =
try!(validate_and_extract(namespace, &qualified_name));
- let qualified_name = Atom::from_slice(&qualified_name);
+ let qualified_name = Atom::from(&*qualified_name);
let value = self.parse_attribute(&namespace, &local_name, value);
self.set_first_matching_attribute(
local_name.clone(), value, qualified_name, namespace.clone(), prefix,
@@ -1246,7 +1248,7 @@ impl ElementMethods for Element {
// https://dom.spec.whatwg.org/#dom-element-removeattributens
fn RemoveAttributeNS(&self, namespace: Option<DOMString>, local_name: DOMString) {
let namespace = namespace_from_domstring(namespace);
- let local_name = Atom::from_slice(&local_name);
+ let local_name = Atom::from(&*local_name);
self.remove_attribute(&namespace, &local_name);
}
@@ -1372,7 +1374,7 @@ impl ElementMethods for Element {
// Step 4.
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(),
ElementCreator::ScriptCreated);
Root::upcast(body_elem)
@@ -1508,7 +1510,7 @@ impl VirtualMethods for Element {
let node = self.upcast::<Node>();
let doc = node.owner_doc();
match attr.local_name() {
- &atom!(style) => {
+ &atom!("style") => {
// Modifying the `style` attribute might change style.
*self.style_attribute.borrow_mut() =
mutation.new_value(attr).map(|value| {
@@ -1518,7 +1520,7 @@ impl VirtualMethods for Element {
doc.content_changed(node, NodeDamage::NodeStyleDamaged);
}
},
- &atom!(id) => {
+ &atom!("id") => {
*self.id_attribute.borrow_mut() =
mutation.new_value(attr).and_then(|value| {
let value = value.as_atom();
@@ -1548,7 +1550,7 @@ impl VirtualMethods for Element {
}
}
},
- _ if attr.namespace() == &ns!("") => {
+ _ if attr.namespace() == &ns!() => {
if fragment_affecting_attributes().iter().any(|a| a == attr.local_name()) ||
common_style_affecting_attributes().iter().any(|a| &a.atom == attr.local_name()) ||
rare_style_affecting_attributes().iter().any(|a| a == attr.local_name())
@@ -1691,7 +1693,7 @@ impl<'a> ::selectors::Element for Root<Element> {
fn each_class<F>(&self, mut callback: F)
where F: FnMut(&Atom)
{
- if let Some(ref attr) = self.get_attribute(&ns!(""), &atom!("class")) {
+ if let Some(ref attr) = self.get_attribute(&ns!(), &atom!("class")) {
let tokens = attr.value();
let tokens = tokens.as_tokens();
for token in tokens {
diff --git a/components/script/dom/event.rs b/components/script/dom/event.rs
index 2ba9fe152b9..6f6284703c5 100644
--- a/components/script/dom/event.rs
+++ b/components/script/dom/event.rs
@@ -234,7 +234,7 @@ impl EventMethods for Event {
self.canceled.set(false);
self.trusted.set(false);
self.target.set(None);
- *self.type_.borrow_mut() = Atom::from_slice(&type_);
+ *self.type_.borrow_mut() = Atom::from(&*type_);
self.bubbles.set(bubbles);
self.cancelable.set(cancelable);
}
diff --git a/components/script/dom/eventtarget.rs b/components/script/dom/eventtarget.rs
index 0b53d3c43b2..612c3d78b11 100644
--- a/components/script/dom/eventtarget.rs
+++ b/components/script/dom/eventtarget.rs
@@ -309,7 +309,7 @@ impl EventTarget {
let event_listener = listener.map(|listener|
CommonEventHandler::EventHandler(
EventHandlerNonNull::new(listener.callback())));
- self.set_inline_event_listener(Atom::from_slice(ty), event_listener);
+ self.set_inline_event_listener(Atom::from(ty), event_listener);
}
pub fn set_error_event_handler<T: CallbackContainer>(
@@ -318,11 +318,11 @@ impl EventTarget {
let event_listener = listener.map(|listener|
CommonEventHandler::ErrorEventHandler(
OnErrorEventHandlerNonNull::new(listener.callback())));
- self.set_inline_event_listener(Atom::from_slice(ty), event_listener);
+ self.set_inline_event_listener(Atom::from(ty), event_listener);
}
pub fn get_event_handler_common<T: CallbackContainer>(&self, ty: &str) -> Option<Rc<T>> {
- let listener = self.get_inline_event_listener(&Atom::from_slice(ty));
+ let listener = self.get_inline_event_listener(&Atom::from(ty));
listener.map(|listener| CallbackContainer::new(listener.parent().callback()))
}
@@ -340,7 +340,7 @@ impl EventTargetMethods for EventTarget {
match listener {
Some(listener) => {
let mut handlers = self.handlers.borrow_mut();
- let entry = match handlers.entry(Atom::from_slice(&ty)) {
+ let entry = match handlers.entry(Atom::from(&*ty)) {
Occupied(entry) => entry.into_mut(),
Vacant(entry) => entry.insert(vec!()),
};
@@ -366,7 +366,7 @@ impl EventTargetMethods for EventTarget {
match listener {
Some(ref listener) => {
let mut handlers = self.handlers.borrow_mut();
- let entry = handlers.get_mut(&Atom::from_slice(&ty));
+ let entry = handlers.get_mut(&Atom::from(&*ty));
for entry in entry {
let phase = if capture { ListenerPhase::Capturing } else { ListenerPhase::Bubbling };
let old_entry = EventListenerEntry {
diff --git a/components/script/dom/htmlanchorelement.rs b/components/script/dom/htmlanchorelement.rs
index 5839de3f4f4..0498b7a6388 100644
--- a/components/script/dom/htmlanchorelement.rs
+++ b/components/script/dom/htmlanchorelement.rs
@@ -176,7 +176,7 @@ fn follow_hyperlink(subject: &Element, hyperlink_suffix: Option<String>) {
// Step 3: target browsing context.
// Step 4.
- let attribute = subject.get_attribute(&ns!(""), &atom!("href")).unwrap();
+ let attribute = subject.get_attribute(&ns!(), &atom!("href")).unwrap();
let mut href = attribute.Value();
// Step 6.
diff --git a/components/script/dom/htmlbaseelement.rs b/components/script/dom/htmlbaseelement.rs
index d31fb1f8dec..a537b06b27a 100644
--- a/components/script/dom/htmlbaseelement.rs
+++ b/components/script/dom/htmlbaseelement.rs
@@ -36,7 +36,7 @@ impl HTMLBaseElement {
/// https://html.spec.whatwg.org/multipage/#frozen-base-url
pub fn frozen_base_url(&self) -> Url {
- let href = self.upcast::<Element>().get_attribute(&ns!(""), &atom!("href"))
+ let href = self.upcast::<Element>().get_attribute(&ns!(), &atom!("href"))
.expect("The frozen base url is only defined for base elements \
that have a base url.");
let document = document_from_node(self);
@@ -66,7 +66,7 @@ impl VirtualMethods for HTMLBaseElement {
fn attribute_mutated(&self, attr: &Attr, mutation: AttributeMutation) {
self.super_type().unwrap().attribute_mutated(attr, mutation);
- if *attr.local_name() == atom!(href) {
+ if *attr.local_name() == atom!("href") {
document_from_node(self).refresh_base_element();
}
}
diff --git a/components/script/dom/htmlbodyelement.rs b/components/script/dom/htmlbodyelement.rs
index 32efe1bd53b..ffc4d0985d6 100644
--- a/components/script/dom/htmlbodyelement.rs
+++ b/components/script/dom/htmlbodyelement.rs
@@ -97,7 +97,7 @@ impl HTMLBodyElementLayoutHelpers for LayoutJS<HTMLBodyElement> {
fn get_background_color(&self) -> Option<RGBA> {
unsafe {
(*self.upcast::<Element>().unsafe_get())
- .get_attr_for_layout(&ns!(""), &atom!("bgcolor"))
+ .get_attr_for_layout(&ns!(), &atom!("bgcolor"))
.and_then(AttrValue::as_color)
.cloned()
}
@@ -107,7 +107,7 @@ impl HTMLBodyElementLayoutHelpers for LayoutJS<HTMLBodyElement> {
fn get_color(&self) -> Option<RGBA> {
unsafe {
(*self.upcast::<Element>().unsafe_get())
- .get_attr_for_layout(&ns!(""), &atom!("text"))
+ .get_attr_for_layout(&ns!(), &atom!("text"))
.and_then(AttrValue::as_color)
.cloned()
}
@@ -153,7 +153,7 @@ impl VirtualMethods for HTMLBodyElement {
fn attribute_mutated(&self, attr: &Attr, mutation: AttributeMutation) {
let do_super_mutate = match (attr.local_name(), mutation) {
- (&atom!(background), _) => {
+ (&atom!("background"), _) => {
*self.background.borrow_mut() = mutation.new_value(attr).and_then(|value| {
let document = document_from_node(self);
let base = document.url();
@@ -169,11 +169,11 @@ impl VirtualMethods for HTMLBodyElement {
// https://html.spec.whatwg.org/multipage/
// #event-handlers-on-elements,-document-objects,-and-window-objects:event-handlers-3
match name {
- &atom!(onfocus) | &atom!(onload) | &atom!(onscroll) | &atom!(onafterprint) |
- &atom!(onbeforeprint) | &atom!(onbeforeunload) | &atom!(onhashchange) |
- &atom!(onlanguagechange) | &atom!(onmessage) | &atom!(onoffline) | &atom!(ononline) |
- &atom!(onpagehide) | &atom!(onpageshow) | &atom!(onpopstate) | &atom!(onstorage) |
- &atom!(onresize) | &atom!(onunload) | &atom!(onerror)
+ &atom!("onfocus") | &atom!("onload") | &atom!("onscroll") | &atom!("onafterprint") |
+ &atom!("onbeforeprint") | &atom!("onbeforeunload") | &atom!("onhashchange") |
+ &atom!("onlanguagechange") | &atom!("onmessage") | &atom!("onoffline") | &atom!("ononline") |
+ &atom!("onpagehide") | &atom!("onpageshow") | &atom!("onpopstate") | &atom!("onstorage") |
+ &atom!("onresize") | &atom!("onunload") | &atom!("onerror")
=> {
let evtarget = window.upcast::<EventTarget>(); // forwarded event
evtarget.set_event_handler_uncompiled(cx, url, reflector,
diff --git a/components/script/dom/htmlbuttonelement.rs b/components/script/dom/htmlbuttonelement.rs
index 4d32648541c..bd6d990c54c 100644
--- a/components/script/dom/htmlbuttonelement.rs
+++ b/components/script/dom/htmlbuttonelement.rs
@@ -138,7 +138,7 @@ impl VirtualMethods for HTMLButtonElement {
fn attribute_mutated(&self, attr: &Attr, mutation: AttributeMutation) {
self.super_type().unwrap().attribute_mutated(attr, mutation);
match attr.local_name() {
- &atom!(disabled) => {
+ &atom!("disabled") => {
let el = self.upcast::<Element>();
match mutation {
AttributeMutation::Set(Some(_)) => {}
diff --git a/components/script/dom/htmlcanvaselement.rs b/components/script/dom/htmlcanvaselement.rs
index af3ffce3987..325a324b3c7 100644
--- a/components/script/dom/htmlcanvaselement.rs
+++ b/components/script/dom/htmlcanvaselement.rs
@@ -120,8 +120,8 @@ impl LayoutHTMLCanvasElementHelpers for LayoutJS<HTMLCanvasElement> {
None => (None, None),
};
- let width_attr = canvas.upcast::<Element>().get_attr_for_layout(&ns!(""), &atom!(width));
- let height_attr = canvas.upcast::<Element>().get_attr_for_layout(&ns!(""), &atom!(height));
+ let width_attr = canvas.upcast::<Element>().get_attr_for_layout(&ns!(), &atom!("width"));
+ let height_attr = canvas.upcast::<Element>().get_attr_for_layout(&ns!(), &atom!("height"));
HTMLCanvasData {
renderer_id: renderer_id,
ipc_renderer: ipc_renderer,
@@ -292,7 +292,7 @@ impl VirtualMethods for HTMLCanvasElement {
fn attribute_mutated(&self, attr: &Attr, mutation: AttributeMutation) {
self.super_type().unwrap().attribute_mutated(attr, mutation);
match attr.local_name() {
- &atom!(width) | &atom!(height) => self.recreate_contexts(),
+ &atom!("width") | &atom!("height") => self.recreate_contexts(),
_ => (),
};
}
diff --git a/components/script/dom/htmlcollection.rs b/components/script/dom/htmlcollection.rs
index b645449dcc1..9eb375dc89b 100644
--- a/components/script/dom/htmlcollection.rs
+++ b/components/script/dom/htmlcollection.rs
@@ -161,9 +161,9 @@ impl HTMLCollection {
pub fn by_tag_name(window: &Window, root: &Node, mut tag: DOMString)
-> Root<HTMLCollection> {
- let tag_atom = Atom::from_slice(&tag);
+ let tag_atom = Atom::from(&*tag); // FIXME(ajeffrey): Convert directly from DOMString to Atom
tag.make_ascii_lowercase();
- let ascii_lower_tag = Atom::from_slice(&tag);
+ let ascii_lower_tag = Atom::from(&*tag); // FIXME(ajeffrey): Convert directly from DOMString to Atom
HTMLCollection::by_atomic_tag_name(window, root, tag_atom, ascii_lower_tag)
}
@@ -194,7 +194,7 @@ impl HTMLCollection {
pub fn by_tag_name_ns(window: &Window, root: &Node, tag: DOMString,
maybe_ns: Option<DOMString>) -> Root<HTMLCollection> {
- let local = Atom::from_slice(&tag);
+ let local = Atom::from(&*tag); // FIXME(ajeffrey): Convert directly from DOMString to Atom
let ns = namespace_from_domstring(maybe_ns);
let qname = QualName::new(ns, local);
HTMLCollection::by_qual_tag_name(window, root, qname)
@@ -219,7 +219,7 @@ impl HTMLCollection {
pub fn by_class_name(window: &Window, root: &Node, classes: DOMString)
-> Root<HTMLCollection> {
- let class_atoms = split_html_space_chars(&classes).map(Atom::from_slice).collect();
+ let class_atoms = split_html_space_chars(&classes).map(Atom::from).collect();
HTMLCollection::by_atomic_class_name(window, root, class_atoms)
}
@@ -370,7 +370,7 @@ impl HTMLCollectionMethods for HTMLCollection {
}
// Step 2.2
let name_attr = elem.get_string_attribute(&atom!("name"));
- if !name_attr.is_empty() && !result.contains(&name_attr) && *elem.namespace() == ns!(HTML) {
+ if !name_attr.is_empty() && !result.contains(&name_attr) && *elem.namespace() == ns!(html) {
result.push(name_attr)
}
}
diff --git a/components/script/dom/htmlelement.rs b/components/script/dom/htmlelement.rs
index 85c64b669f8..8fcd4fe7905 100644
--- a/components/script/dom/htmlelement.rs
+++ b/components/script/dom/htmlelement.rs
@@ -64,7 +64,7 @@ impl HTMLElement {
-> HTMLElement {
HTMLElement {
element:
- Element::new_inherited_with_state(state, tag_name, ns!(HTML), prefix, document),
+ Element::new_inherited_with_state(state, tag_name, ns!(html), prefix, document),
style_decl: Default::default(),
dataset: Default::default(),
}
@@ -100,7 +100,7 @@ impl HTMLElement {
}
},
_ => {
- if let Some(attr) = element.get_attribute(&ns!(""), &atom!("draggable")) {
+ if let Some(attr) = element.get_attribute(&ns!(), &atom!("draggable")) {
let attr = attr.r();
let value = attr.value();
let is_true = match *value {
@@ -328,15 +328,17 @@ impl HTMLElement {
}
pub fn get_custom_attr(&self, local_name: DOMString) -> Option<DOMString> {
- let local_name = Atom::from_slice(&to_snake_case(local_name));
- self.upcast::<Element>().get_attribute(&ns!(""), &local_name).map(|attr| {
+ // FIXME(ajeffrey): Convert directly from DOMString to Atom
+ let local_name = Atom::from(&*to_snake_case(local_name));
+ self.upcast::<Element>().get_attribute(&ns!(), &local_name).map(|attr| {
DOMString::from(&**attr.value()) // FIXME(ajeffrey): Convert directly from AttrValue to DOMString
})
}
pub fn delete_custom_attr(&self, local_name: DOMString) {
- let local_name = Atom::from_slice(&to_snake_case(local_name));
- self.upcast::<Element>().remove_attribute(&ns!(""), &local_name);
+ // FIXME(ajeffrey): Convert directly from DOMString to Atom
+ let local_name = Atom::from(&*to_snake_case(local_name));
+ self.upcast::<Element>().remove_attribute(&ns!(), &local_name);
}
// https://html.spec.whatwg.org/multipage/#category-label
diff --git a/components/script/dom/htmlfieldsetelement.rs b/components/script/dom/htmlfieldsetelement.rs
index 71b19bc85eb..9a2c3a611d7 100644
--- a/components/script/dom/htmlfieldsetelement.rs
+++ b/components/script/dom/htmlfieldsetelement.rs
@@ -87,7 +87,7 @@ impl VirtualMethods for HTMLFieldSetElement {
fn attribute_mutated(&self, attr: &Attr, mutation: AttributeMutation) {
self.super_type().unwrap().attribute_mutated(attr, mutation);
match attr.local_name() {
- &atom!(disabled) => {
+ &atom!("disabled") => {
let disabled_state = match mutation {
AttributeMutation::Set(None) => true,
AttributeMutation::Set(Some(_)) => {
diff --git a/components/script/dom/htmlfontelement.rs b/components/script/dom/htmlfontelement.rs
index 6bc093c9e05..e5e6755d48e 100644
--- a/components/script/dom/htmlfontelement.rs
+++ b/components/script/dom/htmlfontelement.rs
@@ -92,7 +92,7 @@ impl HTMLFontElementLayoutHelpers for LayoutJS<HTMLFontElement> {
fn get_color(&self) -> Option<RGBA> {
unsafe {
(*self.upcast::<Element>().unsafe_get())
- .get_attr_for_layout(&ns!(""), &atom!("color"))
+ .get_attr_for_layout(&ns!(), &atom!("color"))
.and_then(AttrValue::as_color)
.cloned()
}
@@ -102,7 +102,7 @@ impl HTMLFontElementLayoutHelpers for LayoutJS<HTMLFontElement> {
fn get_face(&self) -> Option<Atom> {
unsafe {
(*self.upcast::<Element>().unsafe_get())
- .get_attr_for_layout(&ns!(""), &atom!("face"))
+ .get_attr_for_layout(&ns!(), &atom!("face"))
.map(AttrValue::as_atom)
.cloned()
}
@@ -112,7 +112,7 @@ impl HTMLFontElementLayoutHelpers for LayoutJS<HTMLFontElement> {
fn get_size(&self) -> Option<specified::Length> {
unsafe {
(*self.upcast::<Element>().unsafe_get())
- .get_attr_for_layout(&ns!(""), &atom!("size"))
+ .get_attr_for_layout(&ns!(), &atom!("size"))
.and_then(AttrValue::as_length)
.cloned()
}
diff --git a/components/script/dom/htmlhrelement.rs b/components/script/dom/htmlhrelement.rs
index 8b6cf338786..20e852ca021 100644
--- a/components/script/dom/htmlhrelement.rs
+++ b/components/script/dom/htmlhrelement.rs
@@ -60,7 +60,7 @@ impl HTMLHRLayoutHelpers for LayoutJS<HTMLHRElement> {
fn get_color(&self) -> Option<RGBA> {
unsafe {
(&*self.upcast::<Element>().unsafe_get())
- .get_attr_for_layout(&ns!(""), &atom!("color"))
+ .get_attr_for_layout(&ns!(), &atom!("color"))
.and_then(AttrValue::as_color)
.cloned()
}
@@ -70,7 +70,7 @@ impl HTMLHRLayoutHelpers for LayoutJS<HTMLHRElement> {
fn get_width(&self) -> LengthOrPercentageOrAuto {
unsafe {
(&*self.upcast::<Element>().unsafe_get())
- .get_attr_for_layout(&ns!(""), &atom!("width"))
+ .get_attr_for_layout(&ns!(), &atom!("width"))
.map(AttrValue::as_dimension)
.cloned()
.unwrap_or(LengthOrPercentageOrAuto::Auto)
diff --git a/components/script/dom/htmliframeelement.rs b/components/script/dom/htmliframeelement.rs
index 7d14dfe916d..16d263fd08c 100644
--- a/components/script/dom/htmliframeelement.rs
+++ b/components/script/dom/htmliframeelement.rs
@@ -68,7 +68,7 @@ impl HTMLIFrameElement {
pub fn get_url(&self) -> Option<Url> {
let element = self.upcast::<Element>();
- element.get_attribute(&ns!(""), &atom!("src")).and_then(|src| {
+ element.get_attribute(&ns!(), &atom!("src")).and_then(|src| {
let url = src.value();
if url.is_empty() {
None
@@ -210,7 +210,7 @@ impl HTMLIFrameElementLayoutMethods for LayoutJS<HTMLIFrameElement> {
fn get_width(&self) -> LengthOrPercentageOrAuto {
unsafe {
(*self.upcast::<Element>().unsafe_get())
- .get_attr_for_layout(&ns!(""), &atom!("width"))
+ .get_attr_for_layout(&ns!(), &atom!("width"))
.map(|attribute| str::parse_length(&attribute))
.unwrap_or(LengthOrPercentageOrAuto::Auto)
}
@@ -220,7 +220,7 @@ impl HTMLIFrameElementLayoutMethods for LayoutJS<HTMLIFrameElement> {
fn get_height(&self) -> LengthOrPercentageOrAuto {
unsafe {
(*self.upcast::<Element>().unsafe_get())
- .get_attr_for_layout(&ns!(""), &atom!("height"))
+ .get_attr_for_layout(&ns!(), &atom!("height"))
.map(|attribute| str::parse_length(&attribute))
.unwrap_or(LengthOrPercentageOrAuto::Auto)
}
@@ -398,7 +398,7 @@ impl VirtualMethods for HTMLIFrameElement {
fn attribute_mutated(&self, attr: &Attr, mutation: AttributeMutation) {
self.super_type().unwrap().attribute_mutated(attr, mutation);
match attr.local_name() {
- &atom!(sandbox) => {
+ &atom!("sandbox") => {
self.sandbox.set(mutation.new_value(attr).map(|value| {
let mut modes = SandboxAllowance::AllowNothing as u8;
for token in value.as_tokens() {
@@ -415,7 +415,7 @@ impl VirtualMethods for HTMLIFrameElement {
modes
}));
},
- &atom!(src) => {
+ &atom!("src") => {
if let AttributeMutation::Set(_) = mutation {
if self.upcast::<Node>().is_in_doc() {
self.process_the_iframe_attributes();
diff --git a/components/script/dom/htmlimageelement.rs b/components/script/dom/htmlimageelement.rs
index c31d792a887..cf35d045353 100644
--- a/components/script/dom/htmlimageelement.rs
+++ b/components/script/dom/htmlimageelement.rs
@@ -292,7 +292,7 @@ impl VirtualMethods for HTMLImageElement {
fn attribute_mutated(&self, attr: &Attr, mutation: AttributeMutation) {
self.super_type().unwrap().attribute_mutated(attr, mutation);
match attr.local_name() {
- &atom!(src) => {
+ &atom!("src") => {
self.update_image(mutation.new_value(attr).map(|value| {
// FIXME(ajeffrey): convert directly from AttrValue to DOMString
(DOMString::from(&**value), window_from_node(self).get_url())
diff --git a/components/script/dom/htmlinputelement.rs b/components/script/dom/htmlinputelement.rs
index 35b9d3cd4e7..14391ae3170 100644
--- a/components/script/dom/htmlinputelement.rs
+++ b/components/script/dom/htmlinputelement.rs
@@ -131,7 +131,7 @@ impl HTMLInputElement {
pub fn type_(&self) -> Atom {
self.upcast::<Element>()
- .get_attribute(&ns!(""), &atom!("type"))
+ .get_attribute(&ns!(), &atom!("type"))
.map_or_else(|| atom!(""), |a| a.value().as_atom().to_owned())
}
}
@@ -166,7 +166,7 @@ impl LayoutHTMLInputElementHelpers for LayoutJS<HTMLInputElement> {
unsafe fn get_raw_attr_value(input: LayoutJS<HTMLInputElement>, default: &str) -> String {
let elem = input.upcast::<Element>();
let value = (*elem.unsafe_get())
- .get_attr_val_for_layout(&ns!(""), &atom!("value"))
+ .get_attr_val_for_layout(&ns!(), &atom!("value"))
.unwrap_or(default);
String::from(value)
}
@@ -451,7 +451,7 @@ impl HTMLInputElement {
fn get_radio_group_name(&self) -> Option<Atom> {
//TODO: determine form owner
self.upcast::<Element>()
- .get_attribute(&ns!(""), &atom!("name"))
+ .get_attribute(&ns!(), &atom!("name"))
.map(|name| name.value().as_atom().clone())
}
@@ -507,7 +507,7 @@ impl VirtualMethods for HTMLInputElement {
fn attribute_mutated(&self, attr: &Attr, mutation: AttributeMutation) {
self.super_type().unwrap().attribute_mutated(attr, mutation);
match attr.local_name() {
- &atom!(disabled) => {
+ &atom!("disabled") => {
let disabled_state = match mutation {
AttributeMutation::Set(None) => true,
AttributeMutation::Set(Some(_)) => {
@@ -521,7 +521,7 @@ impl VirtualMethods for HTMLInputElement {
el.set_enabled_state(!disabled_state);
el.check_ancestors_disabled_state_for_form_control();
},
- &atom!(checked) if !self.checked_changed.get() => {
+ &atom!("checked") if !self.checked_changed.get() => {
let checked_state = match mutation {
AttributeMutation::Set(None) => true,
AttributeMutation::Set(Some(_)) => {
@@ -532,13 +532,13 @@ impl VirtualMethods for HTMLInputElement {
};
self.update_checked_state(checked_state, false);
},
- &atom!(size) => {
+ &atom!("size") => {
let size = mutation.new_value(attr).map(|value| {
value.as_uint()
});
self.size.set(size.unwrap_or(DEFAULT_INPUT_SIZE));
}
- &atom!(type) => {
+ &atom!("type") => {
match mutation {
AttributeMutation::Set(_) => {
let value = match &**attr.value() {
@@ -567,16 +567,16 @@ impl VirtualMethods for HTMLInputElement {
}
}
},
- &atom!(value) if !self.value_changed.get() => {
+ &atom!("value") if !self.value_changed.get() => {
let value = mutation.new_value(attr).map(|value| (**value).to_owned());
self.textinput.borrow_mut().set_content(
value.map(DOMString::from).unwrap_or(DOMString::from("")));
},
- &atom!(name) if self.input_type.get() == InputType::InputRadio => {
+ &atom!("name") if self.input_type.get() == InputType::InputRadio => {
self.radio_group_updated(
mutation.new_value(attr).as_ref().map(|name| name.as_atom()));
},
- &atom!(placeholder) => {
+ &atom!("placeholder") => {
// FIXME(ajeffrey): Should we do in-place mutation of the placeholder?
let mut placeholder = self.placeholder.borrow_mut();
placeholder.clear();
@@ -591,9 +591,9 @@ impl VirtualMethods for HTMLInputElement {
fn parse_plain_attribute(&self, name: &Atom, value: DOMString) -> AttrValue {
match name {
- &atom!(name) => AttrValue::from_atomic(value),
+ &atom!("name") => AttrValue::from_atomic(value),
&atom!("size") => AttrValue::from_limited_u32(value, DEFAULT_INPUT_SIZE),
- &atom!(type) => AttrValue::from_atomic(value),
+ &atom!("type") => AttrValue::from_atomic(value),
_ => self.super_type().unwrap().parse_plain_attribute(name, value),
}
}
diff --git a/components/script/dom/htmllabelelement.rs b/components/script/dom/htmllabelelement.rs
index f64633082b4..69fac1871b1 100644
--- a/components/script/dom/htmllabelelement.rs
+++ b/components/script/dom/htmllabelelement.rs
@@ -95,7 +95,7 @@ impl HTMLLabelElementMethods for HTMLLabelElement {
return None;
}
- let for_attr = match self.upcast::<Element>().get_attribute(&ns!(""), &atom!("for")) {
+ let for_attr = match self.upcast::<Element>().get_attribute(&ns!(), &atom!("for")) {
Some(for_attr) => for_attr,
None => return self.first_labelable_descendant(),
};
diff --git a/components/script/dom/htmllinkelement.rs b/components/script/dom/htmllinkelement.rs
index bb470bf8d45..b0954796b8d 100644
--- a/components/script/dom/htmllinkelement.rs
+++ b/components/script/dom/htmllinkelement.rs
@@ -78,7 +78,7 @@ impl HTMLLinkElement {
}
fn get_attr(element: &Element, local_name: &Atom) -> Option<String> {
- let elem = element.get_attribute(&ns!(""), local_name);
+ let elem = element.get_attribute(&ns!(), local_name);
elem.map(|e| {
let value = e.value();
(**value).to_owned()
@@ -119,9 +119,9 @@ impl VirtualMethods for HTMLLinkElement {
return;
}
- let rel = get_attr(self.upcast(), &atom!(rel));
+ let rel = get_attr(self.upcast(), &atom!("rel"));
match attr.local_name() {
- &atom!(href) => {
+ &atom!("href") => {
if string_is_stylesheet(&rel) {
self.handle_stylesheet_url(&attr.value());
} else if is_favicon(&rel) {
@@ -136,7 +136,7 @@ impl VirtualMethods for HTMLLinkElement {
}
}
},
- &atom!(media) => {
+ &atom!("media") => {
if string_is_stylesheet(&rel) {
self.handle_stylesheet_url(&attr.value());
}
@@ -186,7 +186,7 @@ impl HTMLLinkElement {
Ok(url) => {
let element = self.upcast::<Element>();
- let mq_attribute = element.get_attribute(&ns!(""), &atom!("media"));
+ let mq_attribute = element.get_attribute(&ns!(), &atom!("media"));
let value = mq_attribute.r().map(|a| a.value());
let mq_str = match value {
Some(ref value) => &***value,
diff --git a/components/script/dom/htmlmetaelement.rs b/components/script/dom/htmlmetaelement.rs
index 5f581e2a433..0d2730c5f42 100644
--- a/components/script/dom/htmlmetaelement.rs
+++ b/components/script/dom/htmlmetaelement.rs
@@ -48,7 +48,7 @@ impl HTMLMetaElement {
fn process_attributes(&self) {
let element = self.upcast::<Element>();
- if let Some(name) = element.get_attribute(&ns!(""), &atom!("name")).r() {
+ if let Some(name) = element.get_attribute(&ns!(), &atom!("name")).r() {
let name = name.value().to_ascii_lowercase();
let name = name.trim_matches(HTML_SPACE_CHARACTERS);
@@ -64,7 +64,7 @@ impl HTMLMetaElement {
return;
}
let element = self.upcast::<Element>();
- if let Some(content) = element.get_attribute(&ns!(""), &atom!("content")).r() {
+ if let Some(content) = element.get_attribute(&ns!(), &atom!("content")).r() {
let content = content.value();
if !content.is_empty() {
if let Some(translated_rule) = ViewportRule::from_meta(&**content) {
diff --git a/components/script/dom/htmlobjectelement.rs b/components/script/dom/htmlobjectelement.rs
index c69329c2148..d1fc1c2367b 100644
--- a/components/script/dom/htmlobjectelement.rs
+++ b/components/script/dom/htmlobjectelement.rs
@@ -56,8 +56,8 @@ impl<'a> ProcessDataURL for &'a HTMLObjectElement {
let elem = self.upcast::<Element>();
// TODO: support other values
- match (elem.get_attribute(&ns!(""), &atom!("type")),
- elem.get_attribute(&ns!(""), &atom!("data"))) {
+ match (elem.get_attribute(&ns!(), &atom!("type")),
+ elem.get_attribute(&ns!(), &atom!("data"))) {
(None, Some(_uri)) => {
// TODO(gw): Prefetch the image here.
}
@@ -98,7 +98,7 @@ impl VirtualMethods for HTMLObjectElement {
fn attribute_mutated(&self, attr: &Attr, mutation: AttributeMutation) {
self.super_type().unwrap().attribute_mutated(attr, mutation);
match attr.local_name() {
- &atom!(data) => {
+ &atom!("data") => {
if let AttributeMutation::Set(_) = mutation {
self.process_data_url();
}
diff --git a/components/script/dom/htmloptgroupelement.rs b/components/script/dom/htmloptgroupelement.rs
index b44bad67b91..80bbab1f36a 100644
--- a/components/script/dom/htmloptgroupelement.rs
+++ b/components/script/dom/htmloptgroupelement.rs
@@ -57,7 +57,7 @@ impl VirtualMethods for HTMLOptGroupElement {
fn attribute_mutated(&self, attr: &Attr, mutation: AttributeMutation) {
self.super_type().unwrap().attribute_mutated(attr, mutation);
match attr.local_name() {
- &atom!(disabled) => {
+ &atom!("disabled") => {
let disabled_state = match mutation {
AttributeMutation::Set(None) => true,
AttributeMutation::Set(Some(_)) => {
diff --git a/components/script/dom/htmloptionelement.rs b/components/script/dom/htmloptionelement.rs
index b29d0bc2332..22fe44c0d2f 100644
--- a/components/script/dom/htmloptionelement.rs
+++ b/components/script/dom/htmloptionelement.rs
@@ -72,7 +72,7 @@ impl HTMLOptionElement {
// FIXME(ajeffrey): Provide a way of buffering DOMStrings other than using Strings
fn collect_text(element: &Element, value: &mut String) {
- let svg_script = *element.namespace() == ns!(SVG) && element.local_name() == &atom!("script");
+ let svg_script = *element.namespace() == ns!(svg) && element.local_name() == &atom!("script");
let html_script = element.is::<HTMLScriptElement>();
if svg_script || html_script {
return;
@@ -162,7 +162,7 @@ impl VirtualMethods for HTMLOptionElement {
fn attribute_mutated(&self, attr: &Attr, mutation: AttributeMutation) {
self.super_type().unwrap().attribute_mutated(attr, mutation);
match attr.local_name() {
- &atom!(disabled) => {
+ &atom!("disabled") => {
let el = self.upcast::<Element>();
match mutation {
AttributeMutation::Set(_) => {
@@ -176,7 +176,7 @@ impl VirtualMethods for HTMLOptionElement {
}
}
},
- &atom!(selected) => {
+ &atom!("selected") => {
match mutation {
AttributeMutation::Set(_) => {
// https://html.spec.whatwg.org/multipage/#concept-option-selectedness
diff --git a/components/script/dom/htmlscriptelement.rs b/components/script/dom/htmlscriptelement.rs
index 1a37926772e..62c850c9942 100644
--- a/components/script/dom/htmlscriptelement.rs
+++ b/components/script/dom/htmlscriptelement.rs
@@ -216,8 +216,8 @@ impl HTMLScriptElement {
}
// Step 12.
- let for_attribute = element.get_attribute(&ns!(""), &atom!("for"));
- let event_attribute = element.get_attribute(&ns!(""), &atom!("event"));
+ let for_attribute = element.get_attribute(&ns!(), &atom!("for"));
+ let event_attribute = element.get_attribute(&ns!(), &atom!("event"));
match (for_attribute.r(), event_attribute.r()) {
(Some(for_attribute), Some(event_attribute)) => {
let for_value = for_attribute.value().to_ascii_lowercase();
@@ -236,7 +236,7 @@ impl HTMLScriptElement {
}
// Step 13.
- if let Some(ref charset) = element.get_attribute(&ns!(""), &atom!("charset")) {
+ if let Some(ref charset) = element.get_attribute(&ns!(), &atom!("charset")) {
if let Some(encodingRef) = encoding_from_whatwg_label(&charset.Value()) {
*self.block_character_encoding.borrow_mut() = encodingRef;
}
@@ -248,7 +248,7 @@ impl HTMLScriptElement {
let base_url = window.get_url();
let deferred = element.has_attribute(&atom!("defer"));
- let is_external = match element.get_attribute(&ns!(""), &atom!("src")) {
+ let is_external = match element.get_attribute(&ns!(), &atom!("src")) {
// Step 14.
Some(ref src) => {
// Step 14.1
@@ -500,7 +500,7 @@ impl HTMLScriptElement {
pub fn is_javascript(&self) -> bool {
let element = self.upcast::<Element>();
- let type_attr = element.get_attribute(&ns!(""), &atom!("type"));
+ let type_attr = element.get_attribute(&ns!(), &atom!("type"));
let is_js = match type_attr.as_ref().map(|s| s.value()) {
Some(ref s) if s.is_empty() => {
// type attr exists, but empty means js
@@ -513,7 +513,7 @@ impl HTMLScriptElement {
},
None => {
debug!("no script type");
- let language_attr = element.get_attribute(&ns!(""), &atom!("language"));
+ let language_attr = element.get_attribute(&ns!(), &atom!("language"));
let is_js = match language_attr.as_ref().map(|s| s.value()) {
Some(ref s) if s.is_empty() => {
debug!("script language empty, inferring js");
diff --git a/components/script/dom/htmlselectelement.rs b/components/script/dom/htmlselectelement.rs
index 3531e2587da..73365e427a6 100644
--- a/components/script/dom/htmlselectelement.rs
+++ b/components/script/dom/htmlselectelement.rs
@@ -172,7 +172,7 @@ impl VirtualMethods for HTMLSelectElement {
fn attribute_mutated(&self, attr: &Attr, mutation: AttributeMutation) {
self.super_type().unwrap().attribute_mutated(attr, mutation);
- if attr.local_name() == &atom!(disabled) {
+ if attr.local_name() == &atom!("disabled") {
let el = self.upcast::<Element>();
match mutation {
AttributeMutation::Set(_) => {
diff --git a/components/script/dom/htmlstyleelement.rs b/components/script/dom/htmlstyleelement.rs
index e225ec33981..42c4d0315ac 100644
--- a/components/script/dom/htmlstyleelement.rs
+++ b/components/script/dom/htmlstyleelement.rs
@@ -51,7 +51,7 @@ impl HTMLStyleElement {
let win = window_from_node(node);
let url = win.get_url();
- let mq_attribute = element.get_attribute(&ns!(""), &atom!("media"));
+ let mq_attribute = element.get_attribute(&ns!(), &atom!("media"));
let mq_str = match mq_attribute {
Some(a) => String::from(&**a.value()),
None => String::new(),
diff --git a/components/script/dom/htmltablecellelement.rs b/components/script/dom/htmltablecellelement.rs
index 88730779ce2..86621953da3 100644
--- a/components/script/dom/htmltablecellelement.rs
+++ b/components/script/dom/htmltablecellelement.rs
@@ -85,7 +85,7 @@ impl HTMLTableCellElementLayoutHelpers for LayoutJS<HTMLTableCellElement> {
fn get_background_color(&self) -> Option<RGBA> {
unsafe {
(&*self.upcast::<Element>().unsafe_get())
- .get_attr_for_layout(&ns!(""), &atom!("bgcolor"))
+ .get_attr_for_layout(&ns!(), &atom!("bgcolor"))
.and_then(AttrValue::as_color)
.cloned()
}
@@ -94,7 +94,7 @@ impl HTMLTableCellElementLayoutHelpers for LayoutJS<HTMLTableCellElement> {
fn get_colspan(&self) -> Option<u32> {
unsafe {
(&*self.upcast::<Element>().unsafe_get())
- .get_attr_for_layout(&ns!(""), &atom!("colspan"))
+ .get_attr_for_layout(&ns!(), &atom!("colspan"))
.map(AttrValue::as_uint)
}
}
@@ -114,7 +114,7 @@ impl VirtualMethods for HTMLTableCellElement {
fn attribute_mutated(&self, attr: &Attr, mutation: AttributeMutation) {
self.super_type().unwrap().attribute_mutated(attr, mutation);
match *attr.local_name() {
- atom!(width) => {
+ atom!("width") => {
let width = mutation.new_value(attr).map(|value| {
str::parse_length(&value)
});
diff --git a/components/script/dom/htmltableelement.rs b/components/script/dom/htmltableelement.rs
index 3279b59bc53..f2053d8aff4 100644
--- a/components/script/dom/htmltableelement.rs
+++ b/components/script/dom/htmltableelement.rs
@@ -156,7 +156,7 @@ impl HTMLTableElementLayoutHelpers for LayoutJS<HTMLTableElement> {
fn get_width(&self) -> LengthOrPercentageOrAuto {
unsafe {
(*self.upcast::<Element>().unsafe_get())
- .get_attr_for_layout(&ns!(""), &atom!("width"))
+ .get_attr_for_layout(&ns!(), &atom!("width"))
.map(AttrValue::as_dimension)
.cloned()
.unwrap_or(LengthOrPercentageOrAuto::Auto)
@@ -172,18 +172,18 @@ impl VirtualMethods for HTMLTableElement {
fn attribute_mutated(&self, attr: &Attr, mutation: AttributeMutation) {
self.super_type().unwrap().attribute_mutated(attr, mutation);
match *attr.local_name() {
- atom!(bgcolor) => {
+ atom!("bgcolor") => {
self.background_color.set(mutation.new_value(attr).and_then(|value| {
str::parse_legacy_color(&value).ok()
}));
},
- atom!(border) => {
+ atom!("border") => {
// According to HTML5 § 14.3.9, invalid values map to 1px.
self.border.set(mutation.new_value(attr).map(|value| {
str::parse_unsigned_integer(value.chars()).unwrap_or(1)
}));
}
- atom!(cellspacing) => {
+ atom!("cellspacing") => {
self.cellspacing.set(mutation.new_value(attr).and_then(|value| {
str::parse_unsigned_integer(value.chars())
}));
diff --git a/components/script/dom/htmltablerowelement.rs b/components/script/dom/htmltablerowelement.rs
index b37fb125e0c..78804f39bbb 100644
--- a/components/script/dom/htmltablerowelement.rs
+++ b/components/script/dom/htmltablerowelement.rs
@@ -98,7 +98,7 @@ impl HTMLTableRowElementLayoutHelpers for LayoutJS<HTMLTableRowElement> {
fn get_background_color(&self) -> Option<RGBA> {
unsafe {
(&*self.upcast::<Element>().unsafe_get())
- .get_attr_for_layout(&ns!(""), &atom!("bgcolor"))
+ .get_attr_for_layout(&ns!(), &atom!("bgcolor"))
.and_then(AttrValue::as_color)
.cloned()
}
diff --git a/components/script/dom/htmltablesectionelement.rs b/components/script/dom/htmltablesectionelement.rs
index 63954707758..78d21d7ec86 100644
--- a/components/script/dom/htmltablesectionelement.rs
+++ b/components/script/dom/htmltablesectionelement.rs
@@ -83,7 +83,7 @@ impl HTMLTableSectionElementLayoutHelpers for LayoutJS<HTMLTableSectionElement>
fn get_background_color(&self) -> Option<RGBA> {
unsafe {
(&*self.upcast::<Element>().unsafe_get())
- .get_attr_for_layout(&ns!(""), &atom!("bgcolor"))
+ .get_attr_for_layout(&ns!(), &atom!("bgcolor"))
.and_then(AttrValue::as_color)
.cloned()
}
diff --git a/components/script/dom/htmltextareaelement.rs b/components/script/dom/htmltextareaelement.rs
index f84b38ca55c..5ce5cf7e98e 100644
--- a/components/script/dom/htmltextareaelement.rs
+++ b/components/script/dom/htmltextareaelement.rs
@@ -254,7 +254,7 @@ impl VirtualMethods for HTMLTextAreaElement {
fn attribute_mutated(&self, attr: &Attr, mutation: AttributeMutation) {
self.super_type().unwrap().attribute_mutated(attr, mutation);
match *attr.local_name() {
- atom!(disabled) => {
+ atom!("disabled") => {
let el = self.upcast::<Element>();
match mutation {
AttributeMutation::Set(_) => {
@@ -268,13 +268,13 @@ impl VirtualMethods for HTMLTextAreaElement {
}
}
},
- atom!(cols) => {
+ atom!("cols") => {
let cols = mutation.new_value(attr).map(|value| {
value.as_uint()
});
self.cols.set(cols.unwrap_or(DEFAULT_COLS));
},
- atom!(rows) => {
+ atom!("rows") => {
let rows = mutation.new_value(attr).map(|value| {
value.as_uint()
});
diff --git a/components/script/dom/macros.rs b/components/script/dom/macros.rs
index 4cdd6eb277e..cdfeebc01cb 100644
--- a/components/script/dom/macros.rs
+++ b/components/script/dom/macros.rs
@@ -10,7 +10,7 @@ macro_rules! make_getter(
use dom::element::Element;
use string_cache::Atom;
let element = self.upcast::<Element>();
- element.get_string_attribute(&Atom::from_slice($htmlname))
+ element.get_string_attribute(&Atom::from($htmlname))
}
);
($attr:ident) => {
@@ -27,7 +27,7 @@ macro_rules! make_bool_getter(
use string_cache::Atom;
let element = self.upcast::<Element>();
// FIXME(pcwalton): Do this at compile time, not runtime.
- element.has_attribute(&Atom::from_slice($htmlname))
+ element.has_attribute(&Atom::from($htmlname))
}
);
($attr:ident) => {
@@ -44,7 +44,7 @@ macro_rules! make_uint_getter(
use string_cache::Atom;
let element = self.upcast::<Element>();
// FIXME(pcwalton): Do this at compile time, not runtime.
- element.get_uint_attribute(&Atom::from_slice($htmlname), $default)
+ element.get_uint_attribute(&Atom::from($htmlname), $default)
}
);
($attr:ident, $htmlname:expr) => {
@@ -64,7 +64,7 @@ macro_rules! make_url_getter(
use string_cache::Atom;
let element = self.upcast::<Element>();
// FIXME(pcwalton): Do this at compile time, not runtime.
- element.get_url_attribute(&Atom::from_slice($htmlname))
+ element.get_url_attribute(&Atom::from($htmlname))
}
);
($attr:ident) => {
@@ -81,7 +81,7 @@ macro_rules! make_url_or_base_getter(
use dom::element::Element;
use string_cache::Atom;
let element = self.upcast::<Element>();
- let url = element.get_url_attribute(&Atom::from_slice($htmlname));
+ let url = element.get_url_attribute(&Atom::from($htmlname));
if url.is_empty() {
let window = window_from_node(self);
DOMString::from(window.get_url().serialize())
@@ -104,7 +104,7 @@ macro_rules! make_enumerated_getter(
use std::ascii::AsciiExt;
use string_cache::Atom;
let element = self.upcast::<Element>();
- let mut val = element.get_string_attribute(&Atom::from_slice($htmlname));
+ let mut val = element.get_string_attribute(&Atom::from(*$htmlname));
val.make_ascii_lowercase();
// https://html.spec.whatwg.org/multipage/#attr-fs-method
match &*val {
@@ -129,7 +129,7 @@ macro_rules! make_setter(
use string_cache::Atom;
let element = self.upcast::<Element>();
// FIXME(pcwalton): Do this at compile time, not at runtime.
- element.set_string_attribute(&Atom::from_slice($htmlname), value)
+ element.set_string_attribute(&Atom::from($htmlname), value)
}
);
);
@@ -143,7 +143,7 @@ macro_rules! make_bool_setter(
use string_cache::Atom;
let element = self.upcast::<Element>();
// FIXME(pcwalton): Do this at compile time, not at runtime.
- element.set_bool_attribute(&Atom::from_slice($htmlname), value)
+ element.set_bool_attribute(&Atom::from($htmlname), value)
}
);
);
@@ -163,7 +163,7 @@ macro_rules! make_uint_setter(
};
let element = self.upcast::<Element>();
// FIXME(pcwalton): Do this at compile time, not at runtime.
- element.set_uint_attribute(&Atom::from_slice($htmlname), value)
+ element.set_uint_attribute(&Atom::from($htmlname), value)
}
);
($attr:ident, $htmlname:expr) => {
@@ -188,7 +188,7 @@ macro_rules! make_limited_uint_setter(
};
let element = self.upcast::<Element>();
// FIXME(pcwalton): Do this at compile time, not runtime.
- element.set_uint_attribute(&Atom::from_slice($htmlname), value);
+ element.set_uint_attribute(&Atom::from($htmlname), value);
Ok(())
}
);
@@ -209,7 +209,7 @@ macro_rules! make_atomic_setter(
use string_cache::Atom;
let element = self.upcast::<Element>();
// FIXME(pcwalton): Do this at compile time, not at runtime.
- element.set_atomic_attribute(&Atom::from_slice($htmlname), value)
+ element.set_atomic_attribute(&Atom::from($htmlname), value)
}
);
);
@@ -225,7 +225,7 @@ macro_rules! make_legacy_color_setter(
let element = self.upcast::<Element>();
let value = AttrValue::from_legacy_color(value);
// FIXME(pcwalton): Do this at compile time, not at runtime.
- element.set_attribute(&Atom::from_slice($htmlname), value)
+ element.set_attribute(&Atom::from($htmlname), value)
}
);
);
@@ -240,7 +240,7 @@ macro_rules! make_dimension_setter(
let element = self.upcast::<Element>();
let value = AttrValue::from_dimension(value);
// FIXME(pcwalton): Do this at compile time, not at runtime.
- element.set_attribute(&Atom::from_slice($htmlname), value)
+ element.set_attribute(&Atom::from($htmlname), value)
}
);
);
diff --git a/components/script/dom/namednodemap.rs b/components/script/dom/namednodemap.rs
index 437cc59c890..0bb7f438c8e 100644
--- a/components/script/dom/namednodemap.rs
+++ b/components/script/dom/namednodemap.rs
@@ -55,7 +55,7 @@ impl NamedNodeMapMethods for NamedNodeMap {
fn GetNamedItemNS(&self, namespace: Option<DOMString>, local_name: DOMString)
-> Option<Root<Attr>> {
let ns = namespace_from_domstring(namespace);
- self.owner.get_attribute(&ns, &Atom::from_slice(&local_name))
+ self.owner.get_attribute(&ns, &Atom::from(&*local_name))
}
// https://dom.spec.whatwg.org/#dom-namednodemap-removenameditem
@@ -68,7 +68,7 @@ impl NamedNodeMapMethods for NamedNodeMap {
fn RemoveNamedItemNS(&self, namespace: Option<DOMString>, local_name: DOMString)
-> Fallible<Root<Attr>> {
let ns = namespace_from_domstring(namespace);
- self.owner.remove_attribute(&ns, &Atom::from_slice(&local_name))
+ self.owner.remove_attribute(&ns, &Atom::from(&*local_name))
.ok_or(Error::NotFound)
}
diff --git a/components/script/dom/node.rs b/components/script/dom/node.rs
index 57e1abd61b1..768a2accb1d 100644
--- a/components/script/dom/node.rs
+++ b/components/script/dom/node.rs
@@ -1631,7 +1631,7 @@ impl Node {
local: element.local_name().clone()
};
let element = Element::create(name,
- element.prefix().as_ref().map(|p| Atom::from_slice(&p)),
+ element.prefix().as_ref().map(|p| Atom::from(&**p)),
document.r(), ElementCreator::ScriptCreated);
Root::upcast::<Node>(element)
},
@@ -1707,7 +1707,7 @@ impl Node {
pub fn namespace_to_string(namespace: Namespace) -> Option<DOMString> {
match namespace {
- ns!("") => None,
+ ns!() => None,
// FIXME(ajeffrey): convert directly from &Atom to DOMString
Namespace(ref ns) => Some(DOMString::from(&**ns))
}
@@ -1717,7 +1717,7 @@ impl Node {
pub fn locate_namespace(node: &Node, prefix: Option<DOMString>) -> Namespace {
fn attr_defines_namespace(attr: &Attr,
prefix: &Option<Atom>) -> bool {
- *attr.namespace() == ns!(XMLNS) &&
+ *attr.namespace() == ns!(xmlns) &&
match (attr.prefix(), prefix) {
(&Some(ref attr_prefix), &Some(ref prefix)) =>
attr_prefix == &atom!("xmlns") &&
@@ -1731,12 +1731,12 @@ impl Node {
NodeTypeId::Element(_) => {
let element = node.downcast::<Element>().unwrap();
// Step 1.
- if *element.namespace() != ns!("") && *element.prefix() == prefix {
+ if *element.namespace() != ns!() && *element.prefix() == prefix {
return element.namespace().clone()
}
-
- let prefix_atom = prefix.as_ref().map(|s| Atom::from_slice(s));
+ // FIXME(ajeffrey): directly convert DOMString to Atom
+ let prefix_atom = prefix.as_ref().map(|s| Atom::from(&**s));
// Step 2.
let attrs = element.attrs();
@@ -1751,7 +1751,7 @@ impl Node {
match node.GetParentElement() {
// Step 3.
- None => ns!(""),
+ None => ns!(),
// Step 4.
Some(parent) => Node::locate_namespace(parent.upcast(), prefix)
}
@@ -1759,18 +1759,18 @@ impl Node {
NodeTypeId::Document => {
match node.downcast::<Document>().unwrap().GetDocumentElement().r() {
// Step 1.
- None => ns!(""),
+ None => ns!(),
// Step 2.
Some(document_element) => {
Node::locate_namespace(document_element.upcast(), prefix)
}
}
},
- NodeTypeId::DocumentType => ns!(""),
- NodeTypeId::DocumentFragment => ns!(""),
+ NodeTypeId::DocumentType => ns!(),
+ NodeTypeId::DocumentFragment => ns!(),
_ => match node.GetParentElement() {
// Step 1.
- None => ns!(""),
+ None => ns!(),
// Step 2.
Some(parent) => Node::locate_namespace(parent.upcast(), prefix)
}
@@ -2270,7 +2270,7 @@ impl NodeMethods for Node {
let namespace = namespace_from_domstring(namespace);
// Step 1.
- if namespace == ns!("") {
+ if namespace == ns!() {
return None;
}