aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/macros.rs
diff options
context:
space:
mode:
authorPatrick Walton <pcwalton@mimiga.net>2014-09-12 13:28:37 -0700
committerPatrick Walton <pcwalton@mimiga.net>2014-10-14 10:32:40 -0700
commitee2ccc4f872ba33a86057d87a99d1015b3c41cf1 (patch)
tree3a7ef263aa401fb3a36e9d48ff5bc8a384ab1f65 /components/script/dom/macros.rs
parentd1685015559562a42cc440f4e3b7a97d38cc642c (diff)
downloadservo-ee2ccc4f872ba33a86057d87a99d1015b3c41cf1.tar.gz
servo-ee2ccc4f872ba33a86057d87a99d1015b3c41cf1.zip
script: Use atom comparison in more places, especially for attributes.
75% improvement in style recalc for Guardians of the Galaxy.
Diffstat (limited to 'components/script/dom/macros.rs')
-rw-r--r--components/script/dom/macros.rs26
1 files changed, 17 insertions, 9 deletions
diff --git a/components/script/dom/macros.rs b/components/script/dom/macros.rs
index b4b0d4d2ef7..b0aba98c7d6 100644
--- a/components/script/dom/macros.rs
+++ b/components/script/dom/macros.rs
@@ -11,7 +11,7 @@ macro_rules! make_getter(
#[allow(unused_imports)]
use std::ascii::StrAsciiExt;
let element: JSRef<Element> = ElementCast::from_ref(self);
- element.get_string_attribute($htmlname)
+ element.get_string_attribute(&Atom::from_slice($htmlname.to_ascii_lower().as_slice()))
}
);
($attr:ident) => {
@@ -28,7 +28,8 @@ macro_rules! make_bool_getter(
#[allow(unused_imports)]
use std::ascii::StrAsciiExt;
let element: JSRef<Element> = ElementCast::from_ref(self);
- element.has_attribute($htmlname)
+ // FIXME(pcwalton): Do this at compile time, not runtime.
+ element.has_attribute(&Atom::from_slice($htmlname))
}
);
($attr:ident) => {
@@ -45,7 +46,8 @@ macro_rules! make_uint_getter(
#[allow(unused_imports)]
use std::ascii::StrAsciiExt;
let element: JSRef<Element> = ElementCast::from_ref(self);
- element.get_uint_attribute($htmlname)
+ // FIXME(pcwalton): Do this at compile time, not runtime.
+ element.get_uint_attribute(&Atom::from_slice($htmlname))
}
);
($attr:ident) => {
@@ -62,10 +64,12 @@ macro_rules! make_url_getter(
#[allow(unused_imports)]
use std::ascii::StrAsciiExt;
let element: JSRef<Element> = ElementCast::from_ref(self);
- element.get_url_attribute($htmlname)
+ // FIXME(pcwalton): Do this at compile time, not runtime.
+ element.get_url_attribute(&Atom::from_slice($htmlname))
}
);
($attr:ident) => {
+ // FIXME(pcwalton): Do this at compile time, not runtime.
make_url_getter!($attr, stringify!($attr).to_ascii_lower().as_slice())
}
)
@@ -79,7 +83,7 @@ macro_rules! make_url_or_base_getter(
#[allow(unused_imports)]
use std::ascii::StrAsciiExt;
let element: JSRef<Element> = ElementCast::from_ref(self);
- let url = element.get_url_attribute($htmlname);
+ let url = element.get_url_attribute(&Atom::from_slice($htmlname));
match url.as_slice() {
"" => {
let window = window_from_node(self).root();
@@ -103,7 +107,8 @@ macro_rules! make_enumerated_getter(
#[allow(unused_imports)]
use std::ascii::StrAsciiExt;
let element: JSRef<Element> = ElementCast::from_ref(self);
- let val = element.get_string_attribute($htmlname).into_ascii_lower();
+ let val = element.get_string_attribute(&Atom::from_slice($htmlname))
+ .into_ascii_lower();
// https://html.spec.whatwg.org/multipage/forms.html#attr-fs-method
match val.as_slice() {
$($choices)|+ => val,
@@ -125,7 +130,8 @@ macro_rules! make_setter(
use dom::element::{Element, AttributeHandlers};
use dom::bindings::codegen::InheritTypes::ElementCast;
let element: JSRef<Element> = ElementCast::from_ref(self);
- element.set_string_attribute($htmlname, value)
+ // FIXME(pcwalton): Do this at compile time, not at runtime.
+ element.set_string_attribute(&Atom::from_slice($htmlname), value)
}
);
)
@@ -137,7 +143,8 @@ macro_rules! make_bool_setter(
use dom::element::{Element, AttributeHandlers};
use dom::bindings::codegen::InheritTypes::ElementCast;
let element: JSRef<Element> = ElementCast::from_ref(self);
- element.set_bool_attribute($htmlname, value)
+ // FIXME(pcwalton): Do this at compile time, not at runtime.
+ element.set_bool_attribute(&Atom::from_slice($htmlname), value)
}
);
)
@@ -149,7 +156,8 @@ macro_rules! make_uint_setter(
use dom::element::{Element, AttributeHandlers};
use dom::bindings::codegen::InheritTypes::ElementCast;
let element: JSRef<Element> = ElementCast::from_ref(self);
- element.set_uint_attribute($htmlname, value)
+ // FIXME(pcwalton): Do this at compile time, not at runtime.
+ element.set_uint_attribute(&Atom::from_slice($htmlname), value)
}
);
)