mirror of
https://github.com/servo/servo.git
synced 2025-08-04 13:10:20 +01:00
Makes int_getter macro, and uses -1 as default maxlength instead of maxint
This commit is contained in:
parent
d26c555e2a
commit
eecdfdf6c1
4 changed files with 51 additions and 11 deletions
|
@ -1090,6 +1090,27 @@ impl Element {
|
|||
self.set_attribute(local_name, AttrValue::from_atomic_tokens(tokens));
|
||||
}
|
||||
|
||||
pub fn get_int_attribute(&self, local_name: &Atom, default: i32) -> i32 {
|
||||
// TODO: Is this assert necessary?
|
||||
assert!(local_name.chars().all(|ch| {
|
||||
!ch.is_ascii() || ch.to_ascii_lowercase() == ch
|
||||
}));
|
||||
let attribute = self.get_attribute(&ns!(""), local_name);
|
||||
|
||||
match attribute {
|
||||
Some(ref attribute) => {
|
||||
match *attribute.r().value() {
|
||||
AttrValue::Int(_, value) => value,
|
||||
_ => panic!("Expected an AttrValue::Int: \
|
||||
implement parse_plain_attribute"),
|
||||
}
|
||||
}
|
||||
None => default,
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: set_int_attribute(...)
|
||||
|
||||
pub fn get_uint_attribute(&self, local_name: &Atom, default: u32) -> u32 {
|
||||
assert!(local_name.chars().all(|ch| !ch.is_ascii() || ch.to_ascii_lowercase() == ch));
|
||||
let attribute = self.get_attribute(&ns!(), local_name);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue