mirror of
https://github.com/servo/servo.git
synced 2025-06-24 09:04:33 +01:00
Introduce a set_uint_attribute method.
This commit is contained in:
parent
4386bae576
commit
bb732ef4e6
3 changed files with 10 additions and 6 deletions
|
@ -198,6 +198,7 @@ pub trait AttributeHandlers {
|
|||
fn set_url_attribute(&mut self, name: &str, value: DOMString);
|
||||
fn get_string_attribute(&self, name: &str) -> DOMString;
|
||||
fn set_string_attribute(&mut self, name: &str, value: DOMString);
|
||||
fn set_uint_attribute(&mut self, name: &str, value: u32);
|
||||
}
|
||||
|
||||
pub trait AfterSetAttrListener {
|
||||
|
@ -410,6 +411,11 @@ impl AttributeHandlers for JS<Element> {
|
|||
assert!(name == name.to_ascii_lower());
|
||||
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 {
|
||||
|
|
|
@ -144,9 +144,9 @@ impl HTMLImageElement {
|
|||
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);
|
||||
elem.set_attr(~"width", width.to_str())
|
||||
elem.set_uint_attribute("width", width)
|
||||
}
|
||||
|
||||
pub fn Height(&self, abstract_self: &JS<HTMLImageElement>) -> u32 {
|
||||
|
@ -160,9 +160,9 @@ impl HTMLImageElement {
|
|||
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);
|
||||
elem.set_attr(~"height", height.to_str())
|
||||
elem.set_uint_attribute("height", height)
|
||||
}
|
||||
|
||||
pub fn NaturalWidth(&self) -> u32 {
|
||||
|
|
|
@ -23,9 +23,7 @@ interface HTMLImageElement : HTMLElement {
|
|||
attribute DOMString useMap;
|
||||
[SetterThrows]
|
||||
attribute boolean isMap;
|
||||
[SetterThrows]
|
||||
attribute unsigned long width;
|
||||
[SetterThrows]
|
||||
attribute unsigned long height;
|
||||
readonly attribute unsigned long naturalWidth;
|
||||
readonly attribute unsigned long naturalHeight;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue