mirror of
https://github.com/servo/servo.git
synced 2025-10-08 20:49:24 +01:00
Implement parsed 'unsigned long' attributes.
This commit is partially based on earlier work by Bruno Abinader in #2073.
This commit is contained in:
parent
972c69883e
commit
b012c99e05
3 changed files with 34 additions and 5 deletions
|
@ -24,6 +24,7 @@ pub enum AttrSettingType {
|
|||
pub enum AttrValue {
|
||||
StringAttrValue(DOMString),
|
||||
TokenListAttrValue(DOMString, Vec<(uint, uint)>),
|
||||
UIntAttrValue(DOMString, u32),
|
||||
}
|
||||
|
||||
impl AttrValue {
|
||||
|
@ -39,10 +40,16 @@ impl AttrValue {
|
|||
return TokenListAttrValue(list, indexes);
|
||||
}
|
||||
|
||||
pub fn from_u32(string: DOMString, default: u32) -> AttrValue {
|
||||
let result: u32 = from_str(string.as_slice()).unwrap_or(default);
|
||||
UIntAttrValue(string, result)
|
||||
}
|
||||
|
||||
pub fn as_slice<'a>(&'a self) -> &'a str {
|
||||
match *self {
|
||||
StringAttrValue(ref value) |
|
||||
TokenListAttrValue(ref value, _) => value.as_slice(),
|
||||
TokenListAttrValue(ref value, _) |
|
||||
UIntAttrValue(ref value, _) => value.as_slice(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue