mirror of
https://github.com/servo/servo.git
synced 2025-07-29 10:10:34 +01:00
Auto merge of #7898 - frewsxcv:htmlfontelement-size-attribute-setter, r=nox
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. <!-- Reviewable:start --> [<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/7898) <!-- Reviewable:end -->
This commit is contained in:
commit
60a77defe5
2 changed files with 15 additions and 2 deletions
|
@ -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))
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue