Introduce a set_uint_attribute method.

This commit is contained in:
Ms2ger 2014-04-06 14:19:30 +02:00
parent 4386bae576
commit bb732ef4e6
3 changed files with 10 additions and 6 deletions

View file

@ -198,6 +198,7 @@ pub trait AttributeHandlers {
fn set_url_attribute(&mut self, name: &str, value: DOMString); fn set_url_attribute(&mut self, name: &str, value: DOMString);
fn get_string_attribute(&self, name: &str) -> DOMString; fn get_string_attribute(&self, name: &str) -> DOMString;
fn set_string_attribute(&mut self, name: &str, value: DOMString); fn set_string_attribute(&mut self, name: &str, value: DOMString);
fn set_uint_attribute(&mut self, name: &str, value: u32);
} }
pub trait AfterSetAttrListener { pub trait AfterSetAttrListener {
@ -410,6 +411,11 @@ impl AttributeHandlers for JS<Element> {
assert!(name == name.to_ascii_lower()); assert!(name == name.to_ascii_lower());
assert!(self.set_attribute(Null, name.to_owned(), value).is_ok()); assert!(self.set_attribute(Null, name.to_owned(), value).is_ok());
} }
fn set_uint_attribute(&mut self, name: &str, value: u32) {
assert!(name == name.to_ascii_lower());
assert!(self.set_attribute(Null, name.to_owned(), value.to_str()).is_ok());
}
} }
impl Element { impl Element {

View file

@ -144,9 +144,9 @@ impl HTMLImageElement {
to_px(rect.size.width) as u32 to_px(rect.size.width) as u32
} }
pub fn SetWidth(&mut self, abstract_self: &JS<HTMLImageElement>, width: u32) -> ErrorResult { pub fn SetWidth(&mut self, abstract_self: &JS<HTMLImageElement>, width: u32) {
let mut elem: JS<Element> = ElementCast::from(abstract_self); let mut elem: JS<Element> = ElementCast::from(abstract_self);
elem.set_attr(~"width", width.to_str()) elem.set_uint_attribute("width", width)
} }
pub fn Height(&self, abstract_self: &JS<HTMLImageElement>) -> u32 { pub fn Height(&self, abstract_self: &JS<HTMLImageElement>) -> u32 {
@ -160,9 +160,9 @@ impl HTMLImageElement {
to_px(rect.size.height) as u32 to_px(rect.size.height) as u32
} }
pub fn SetHeight(&mut self, abstract_self: &JS<HTMLImageElement>, height: u32) -> ErrorResult { pub fn SetHeight(&mut self, abstract_self: &JS<HTMLImageElement>, height: u32) {
let mut elem: JS<Element> = ElementCast::from(abstract_self); let mut elem: JS<Element> = ElementCast::from(abstract_self);
elem.set_attr(~"height", height.to_str()) elem.set_uint_attribute("height", height)
} }
pub fn NaturalWidth(&self) -> u32 { pub fn NaturalWidth(&self) -> u32 {

View file

@ -23,9 +23,7 @@ interface HTMLImageElement : HTMLElement {
attribute DOMString useMap; attribute DOMString useMap;
[SetterThrows] [SetterThrows]
attribute boolean isMap; attribute boolean isMap;
[SetterThrows]
attribute unsigned long width; attribute unsigned long width;
[SetterThrows]
attribute unsigned long height; attribute unsigned long height;
readonly attribute unsigned long naturalWidth; readonly attribute unsigned long naturalWidth;
readonly attribute unsigned long naturalHeight; readonly attribute unsigned long naturalHeight;