Implement size attribute for <font> element

This commit is contained in:
Corey Farwell 2015-09-19 15:04:11 -04:00
parent 520c907742
commit 74e4c4fdc7
12 changed files with 201 additions and 181 deletions

View file

@ -18,6 +18,7 @@ use std::cell::Ref;
use std::mem;
use std::ops::Deref;
use string_cache::{Atom, Namespace};
use style::values::specified::Length;
use util::str::{DOMString, parse_unsigned_integer, split_html_space_chars, str_join};
#[derive(JSTraceable, PartialEq, Clone, HeapSizeOf)]
@ -26,6 +27,7 @@ pub enum AttrValue {
TokenList(DOMString, Vec<Atom>),
UInt(DOMString, u32),
Atom(Atom),
Length(DOMString, Option<Length>),
}
impl AttrValue {
@ -86,6 +88,13 @@ impl AttrValue {
}
}
pub fn as_length(&self) -> Option<&Length> {
match *self {
AttrValue::Length(_, ref length) => length.as_ref(),
_ => panic!("Length not found"),
}
}
/// Return the AttrValue as its integer representation, if any.
/// This corresponds to attribute values returned as `AttrValue::UInt(_)`
/// by `VirtualMethods::parse_plain_attribute()`.
@ -105,7 +114,8 @@ impl Deref for AttrValue {
match *self {
AttrValue::String(ref value) |
AttrValue::TokenList(ref value, _) |
AttrValue::UInt(ref value, _) => &value,
AttrValue::UInt(ref value, _) |
AttrValue::Length(ref value, _) => &value,
AttrValue::Atom(ref value) => &value,
}
}