diff options
author | Eli Friedman <eli.friedman@gmail.com> | 2015-11-01 12:47:28 -0800 |
---|---|---|
committer | Eli Friedman <eli.friedman@gmail.com> | 2015-11-01 12:47:28 -0800 |
commit | cf8f2b1874a83df30f785e063139e808de690c78 (patch) | |
tree | 6c1fb45af86f94555e4451fcbd6b24c1a809b861 /components | |
parent | 285e29c06637f31a8b8a27c2e454468717924ebd (diff) | |
download | servo-cf8f2b1874a83df30f785e063139e808de690c78.tar.gz servo-cf8f2b1874a83df30f785e063139e808de690c78.zip |
Use attribute getter/setter macros for misc DOM attributes.
This fixes a few minor bugs.
Also adds some better testing for "unsigned long" attributes.
Diffstat (limited to 'components')
-rw-r--r-- | components/script/dom/htmlbuttonelement.rs | 10 | ||||
-rw-r--r-- | components/script/dom/htmlimageelement.rs | 15 | ||||
-rw-r--r-- | components/script/dom/htmloptionelement.rs | 4 | ||||
-rw-r--r-- | components/script/dom/htmltablecellelement.rs | 2 |
4 files changed, 7 insertions, 24 deletions
diff --git a/components/script/dom/htmlbuttonelement.rs b/components/script/dom/htmlbuttonelement.rs index 5146c7e4888..7d73a2ad64f 100644 --- a/components/script/dom/htmlbuttonelement.rs +++ b/components/script/dom/htmlbuttonelement.rs @@ -81,15 +81,7 @@ impl HTMLButtonElementMethods for HTMLButtonElement { } // https://html.spec.whatwg.org/multipage/#dom-button-type - fn Type(&self) -> DOMString { - let mut ty = self.upcast::<Element>().get_string_attribute(&atom!("type")); - ty.make_ascii_lowercase(); - // https://html.spec.whatwg.org/multipage/#attr-button-type - match &*ty { - "reset" | "button" | "menu" => ty, - _ => "submit".to_owned() - } - } + make_enumerated_getter!(Type, "submit", ("reset") | ("button") | ("menu")); // https://html.spec.whatwg.org/multipage/#dom-button-type make_setter!(SetType, "type"); diff --git a/components/script/dom/htmlimageelement.rs b/components/script/dom/htmlimageelement.rs index 25b93621c02..e3b2fd85111 100644 --- a/components/script/dom/htmlimageelement.rs +++ b/components/script/dom/htmlimageelement.rs @@ -14,7 +14,7 @@ use dom::bindings::global::GlobalRef; use dom::bindings::js::{LayoutJS, Root}; use dom::bindings::refcounted::Trusted; use dom::document::Document; -use dom::element::{AttributeMutation, Element}; +use dom::element::AttributeMutation; use dom::event::{Event, EventBubbles, EventCancelable}; use dom::htmlelement::HTMLElement; use dom::node::{Node, NodeDamage, document_from_node, window_from_node}; @@ -196,11 +196,8 @@ impl HTMLImageElementMethods for HTMLImageElement { // https://html.spec.whatwg.org/multipage/#dom-img-ismap make_bool_getter!(IsMap); - // https://html.spec.whatwg.org/multipage/#dom-img-ismap - fn SetIsMap(&self, is_map: bool) { - self.upcast::<Element>().set_string_attribute(&atom!("ismap"), is_map.to_string()) - } + make_bool_setter!(SetIsMap, "ismap"); // https://html.spec.whatwg.org/multipage/#dom-img-width fn Width(&self) -> u32 { @@ -210,9 +207,7 @@ impl HTMLImageElementMethods for HTMLImageElement { } // https://html.spec.whatwg.org/multipage/#dom-img-width - fn SetWidth(&self, width: u32) { - self.upcast::<Element>().set_uint_attribute(&atom!("width"), width) - } + make_uint_setter!(SetWidth, "width"); // https://html.spec.whatwg.org/multipage/#dom-img-height fn Height(&self) -> u32 { @@ -222,9 +217,7 @@ impl HTMLImageElementMethods for HTMLImageElement { } // https://html.spec.whatwg.org/multipage/#dom-img-height - fn SetHeight(&self, height: u32) { - self.upcast::<Element>().set_uint_attribute(&atom!("height"), height) - } + make_uint_setter!(SetHeight, "height"); // https://html.spec.whatwg.org/multipage/#dom-img-naturalwidth fn NaturalWidth(&self) -> u32 { diff --git a/components/script/dom/htmloptionelement.rs b/components/script/dom/htmloptionelement.rs index 8c7dea8ac1e..03ea7aabf84 100644 --- a/components/script/dom/htmloptionelement.rs +++ b/components/script/dom/htmloptionelement.rs @@ -91,9 +91,7 @@ impl HTMLOptionElementMethods for HTMLOptionElement { make_bool_getter!(Disabled); // https://html.spec.whatwg.org/multipage/#dom-option-disabled - fn SetDisabled(&self, disabled: bool) { - self.upcast::<Element>().set_bool_attribute(&atom!("disabled"), disabled) - } + make_bool_setter!(SetDisabled, "disabled"); // https://html.spec.whatwg.org/multipage/#dom-option-text fn Text(&self) -> DOMString { diff --git a/components/script/dom/htmltablecellelement.rs b/components/script/dom/htmltablecellelement.rs index 3f1b13633f2..afb1cebdb3d 100644 --- a/components/script/dom/htmltablecellelement.rs +++ b/components/script/dom/htmltablecellelement.rs @@ -53,7 +53,7 @@ impl HTMLTableCellElementMethods for HTMLTableCellElement { make_uint_getter!(ColSpan, "colspan", DEFAULT_COLSPAN); // https://html.spec.whatwg.org/multipage/#dom-tdth-colspan - make_uint_setter!(SetColSpan, "colspan"); + make_uint_setter!(SetColSpan, "colspan", DEFAULT_COLSPAN); // https://html.spec.whatwg.org/multipage/#dom-tdth-cellindex fn CellIndex(&self) -> i32 { |