diff options
author | Patrick Walton <pcwalton@mimiga.net> | 2014-09-12 13:28:37 -0700 |
---|---|---|
committer | Patrick Walton <pcwalton@mimiga.net> | 2014-10-14 10:32:40 -0700 |
commit | ee2ccc4f872ba33a86057d87a99d1015b3c41cf1 (patch) | |
tree | 3a7ef263aa401fb3a36e9d48ff5bc8a384ab1f65 /components/script/dom/htmlformelement.rs | |
parent | d1685015559562a42cc440f4e3b7a97d38cc642c (diff) | |
download | servo-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/htmlformelement.rs')
-rw-r--r-- | components/script/dom/htmlformelement.rs | 32 |
1 files changed, 27 insertions, 5 deletions
diff --git a/components/script/dom/htmlformelement.rs b/components/script/dom/htmlformelement.rs index 363e90fa596..ed18eb109f2 100644 --- a/components/script/dom/htmlformelement.rs +++ b/components/script/dom/htmlformelement.rs @@ -28,6 +28,7 @@ use std::ascii::OwnedStrAsciiExt; use std::str::StrSlice; use url::UrlParser; use url::form_urlencoded::serialize; +use string_cache::Atom; #[jstraceable] #[must_root] @@ -349,14 +350,24 @@ impl<'a> FormSubmitter<'a> { fn action(&self) -> DOMString { match *self { FormElement(form) => form.Action(), - InputElement(input_element) => input_element.get_form_attribute("formaction", |i| i.FormAction(), |f| f.Action()) + InputElement(input_element) => { + // FIXME(pcwalton): Make this a static atom. + input_element.get_form_attribute(&Atom::from_slice("formaction"), + |i| i.FormAction(), + |f| f.Action()) + } } } fn enctype(&self) -> FormEncType { let attr = match *self { FormElement(form) => form.Enctype(), - InputElement(input_element) => input_element.get_form_attribute("formenctype", |i| i.FormEnctype(), |f| f.Enctype()) + InputElement(input_element) => { + // FIXME(pcwalton): Make this a static atom. + input_element.get_form_attribute(&Atom::from_slice("formenctype"), + |i| i.FormEnctype(), + |f| f.Enctype()) + } }; match attr.as_slice() { "multipart/form-data" => FormDataEncoded, @@ -370,7 +381,12 @@ impl<'a> FormSubmitter<'a> { fn method(&self) -> FormMethod { let attr = match *self { FormElement(form) => form.Method(), - InputElement(input_element) => input_element.get_form_attribute("formmethod", |i| i.FormMethod(), |f| f.Method()) + InputElement(input_element) => { + // FIXME(pcwalton): Make this a static atom. + input_element.get_form_attribute(&Atom::from_slice("formmethod"), + |i| i.FormMethod(), + |f| f.Method()) + } }; match attr.as_slice() { "dialog" => FormDialog, @@ -382,14 +398,20 @@ impl<'a> FormSubmitter<'a> { fn target(&self) -> DOMString { match *self { FormElement(form) => form.Target(), - InputElement(input_element) => input_element.get_form_attribute("formtarget", |i| i.FormTarget(), |f| f.Target()) + InputElement(input_element) => { + // FIXME(pcwalton): Make this a static atom. + input_element.get_form_attribute(&Atom::from_slice("formtarget"), + |i| i.FormTarget(), + |f| f.Target()) + } } } } pub trait FormOwner<'a> : Copy { fn form_owner(self) -> Option<Temporary<HTMLFormElement>>; - fn get_form_attribute(self, attr: &str, + fn get_form_attribute(self, + attr: &Atom, input: |Self| -> DOMString, owner: |JSRef<HTMLFormElement>| -> DOMString) -> DOMString { if self.to_element().has_attribute(attr) { |