Auto merge of #8245 - eefriedman:misc-attribute-fixes, r=nox

Use attribute getter/setter macros for misc DOM attributes.

This fixes a few minor bugs.

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/8245)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2015-11-02 15:14:32 +05:30
commit 50d51bab7f
8 changed files with 213 additions and 67 deletions

View file

@ -83,15 +83,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");

View file

@ -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 {

View file

@ -92,9 +92,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 {

View file

@ -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 {