mirror of
https://github.com/servo/servo.git
synced 2025-08-07 06:25:32 +01:00
script: Map HTMLCanvasElement width and height attributes.
This commit is contained in:
parent
df29d02026
commit
53cad6227e
4 changed files with 63 additions and 3 deletions
|
@ -332,6 +332,23 @@ impl AttrValue {
|
|||
panic!("Uint not found");
|
||||
}
|
||||
}
|
||||
|
||||
/// Return the AttrValue as a dimension computed from its integer
|
||||
/// representation, assuming that integer representation specifies pixels.
|
||||
///
|
||||
/// This corresponds to attribute values returned as `AttrValue::UInt(_)`
|
||||
/// by `VirtualMethods::parse_plain_attribute()`.
|
||||
///
|
||||
/// ## Panics
|
||||
///
|
||||
/// Panics if the `AttrValue` is not a `UInt`
|
||||
pub fn as_uint_px_dimension(&self) -> LengthOrPercentageOrAuto {
|
||||
if let AttrValue::UInt(_, value) = *self {
|
||||
LengthOrPercentageOrAuto::Length(Au::from_px(value as i32))
|
||||
} else {
|
||||
panic!("Uint not found");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl ::std::ops::Deref for AttrValue {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue