aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom
diff options
context:
space:
mode:
authorCorey Farwell <coreyf@rwell.org>2015-10-06 20:34:12 -0400
committerCorey Farwell <coreyf@rwell.org>2015-10-07 08:28:43 -0400
commiteabaf2c6a55f954c7a7e38ade2123f8f75dafe27 (patch)
treec803d595b639621328908240c2ad43c002b181fc /components/script/dom
parent5eb1c04e7854d932c0d63f9e5ed4d54ee43deb9b (diff)
downloadservo-eabaf2c6a55f954c7a7e38ade2123f8f75dafe27.tar.gz
servo-eabaf2c6a55f954c7a7e38ade2123f8f75dafe27.zip
Use the correct IDL setter for <font>.size
Previously, the IDL attribute would incorrectly set the `size` attribute for `<font>` elements as `AttrValue::String`. Now it correctly sets it as `AttrValue::Length`. Also included is a regression test.
Diffstat (limited to 'components/script/dom')
-rw-r--r--components/script/dom/htmlfontelement.rs12
1 files changed, 10 insertions, 2 deletions
diff --git a/components/script/dom/htmlfontelement.rs b/components/script/dom/htmlfontelement.rs
index 873079bee11..8b30375fbeb 100644
--- a/components/script/dom/htmlfontelement.rs
+++ b/components/script/dom/htmlfontelement.rs
@@ -70,7 +70,11 @@ impl HTMLFontElementMethods for HTMLFontElement {
make_getter!(Size);
// https://html.spec.whatwg.org/multipage/#dom-font-size
- make_setter!(SetSize, "size");
+ fn SetSize(&self, value: DOMString) {
+ let element = ElementCast::from_ref(self);
+ let length = parse_length(&value);
+ element.set_attribute(&Atom::from_slice("size"), AttrValue::Length(value, length));
+ }
}
impl VirtualMethods for HTMLFontElement {
@@ -100,7 +104,7 @@ impl VirtualMethods for HTMLFontElement {
match name {
&atom!("face") => AttrValue::from_atomic(value),
&atom!("size") => {
- let length = parse_legacy_font_size(&value).and_then(|parsed| specified::Length::from_str(&parsed));
+ let length = parse_length(&value);
AttrValue::Length(value, length)
},
_ => self.super_type().unwrap().parse_plain_attribute(name, value),
@@ -133,3 +137,7 @@ impl HTMLFontElement {
}
}
}
+
+fn parse_length(value: &str) -> Option<specified::Length> {
+ parse_legacy_font_size(&value).and_then(|parsed| specified::Length::from_str(&parsed))
+}