mirror of
https://github.com/servo/servo.git
synced 2025-08-02 20:20:14 +01:00
Add new methods to Fragment for size calculation of replaced element
These new methods calculate both the used width and height of an replaced element and the same time. The `has_intrinsic_ratio()` method also exposes information about whether a fragment has intrinsic aspect ratio.
This commit is contained in:
parent
39780e894b
commit
d3ab919745
2 changed files with 193 additions and 2 deletions
|
@ -436,6 +436,21 @@ impl MaybeAuto {
|
|||
}
|
||||
}
|
||||
|
||||
/// Receive an optional container size and return used value for width or height.
|
||||
///
|
||||
/// `style_length`: content size as given in the CSS.
|
||||
pub fn style_length(style_length: LengthOrPercentageOrAuto,
|
||||
container_size: Option<Au>) -> MaybeAuto {
|
||||
match container_size {
|
||||
Some(length) => MaybeAuto::from_style(style_length, length),
|
||||
None => if let LengthOrPercentageOrAuto::Length(length) = style_length {
|
||||
MaybeAuto::Specified(length)
|
||||
} else {
|
||||
MaybeAuto::Auto
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn specified_or_none(length: LengthOrPercentageOrNone, containing_length: Au) -> Option<Au> {
|
||||
match length {
|
||||
LengthOrPercentageOrNone::None => None,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue