mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
style: Add an API to parse an absolute length without any other context
This should allow making these work on canvas. Differential Revision: https://phabricator.services.mozilla.com/D177074
This commit is contained in:
parent
a69578993a
commit
d9d865e8c9
1 changed files with 9 additions and 1 deletions
|
@ -1085,7 +1085,7 @@ impl NoCalcLength {
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn to_computed_pixel_length_without_context(&self) -> Result<CSSFloat, ()> {
|
pub fn to_computed_pixel_length_without_context(&self) -> Result<CSSFloat, ()> {
|
||||||
match *self {
|
match *self {
|
||||||
NoCalcLength::Absolute(len) => Ok(CSSPixelLength::new(len.to_px()).finite().px()),
|
Self::Absolute(len) => Ok(CSSPixelLength::new(len.to_px()).finite().px()),
|
||||||
_ => Err(()),
|
_ => Err(()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1344,6 +1344,14 @@ impl Length {
|
||||||
pub fn from_px(px_value: CSSFloat) -> Length {
|
pub fn from_px(px_value: CSSFloat) -> Length {
|
||||||
Length::NoCalc(NoCalcLength::from_px(px_value))
|
Length::NoCalc(NoCalcLength::from_px(px_value))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Get a px value without context.
|
||||||
|
pub fn to_computed_pixel_length_without_context(&self) -> Result<CSSFloat, ()> {
|
||||||
|
match *self {
|
||||||
|
Self::NoCalc(ref l) => l.to_computed_pixel_length_without_context(),
|
||||||
|
Self::Calc(ref l) => l.to_computed_pixel_length_without_context(),
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Parse for Length {
|
impl Parse for Length {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue