mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
Improve how intrinsic sizes work for videos (#31746)
* feat: patch for video layout sizes added rebase from main 2024/10/05 Co-authored-by: Josh Matthews <josh@joshmatthews.net> Signed-off-by: eri <epazos@igalia.com> * feat: take width and height parameters if provided Signed-off-by: eri <epazos@igalia.com> * chore: tidy the code and update test expectations Signed-off-by: eri <epazos@igalia.com> * feat: handle removing poster Signed-off-by: eri <epazos@igalia.com> * chore: update test expectations and remove debug code Signed-off-by: eri <epazos@igalia.com> * fix: issues after rebasing to main Signed-off-by: eri <epazos@igalia.com> * feat: pass src remove test and tidy Signed-off-by: eri <epazos@igalia.com> * chore: clippy fixes Signed-off-by: eri <epazos@igalia.com> * chore: update passing test expectations Signed-off-by: eri <epazos@igalia.com> * fix object-position-svg test Signed-off-by: eri <epazos@igalia.com> * fix unintentional override of video size and resize events Signed-off-by: eri <epazos@igalia.com> * change how resize events are sent to better match the spec Signed-off-by: eri <epazos@igalia.com> * simplify poster mutation handling Co-authored-by: Oriol Brufau <obrufau@igalia.com> Signed-off-by: eri <eri@inventati.org> * improved handling of intrinsic sizes - differentiate between natural size and css size - presentational attributes - fallback ratio for video element - handle more cases where the src/poster are added/removed - aspect ratio hints Signed-off-by: eri <epazos@igalia.com> * update test expectations Signed-off-by: eri <epazos@igalia.com> * fix cleaning current frame Signed-off-by: eri <epazos@igalia.com> * update test expectations Signed-off-by: eri <epazos@igalia.com> * Apply suggestions from code review Co-authored-by: Oriol Brufau <obrufau@igalia.com> Signed-off-by: eri <eri@inventati.org> * More code review suggestions Signed-off-by: eri <epazos@igalia.com> * Prevent aspect-ratio:auto from pulling the ratio from the default object size As resolved in https://github.com/w3c/csswg-drafts/issues/7524#issuecomment-1204462924 Signed-off-by: Oriol Brufau <obrufau@igalia.com> --------- Signed-off-by: eri <epazos@igalia.com> Signed-off-by: eri <eri@inventati.org> Signed-off-by: Oriol Brufau <obrufau@igalia.com> Co-authored-by: Josh Matthews <josh@joshmatthews.net> Co-authored-by: Oriol Brufau <obrufau@igalia.com>
This commit is contained in:
parent
43d1601016
commit
01820e2a8a
25 changed files with 290 additions and 360 deletions
|
@ -177,6 +177,13 @@ impl AspectRatio {
|
|||
},
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn from_content_ratio(i_over_b: CSSFloat) -> Self {
|
||||
Self {
|
||||
box_sizing_adjustment: LogicalVec2::zero(),
|
||||
i_over_b,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
|
@ -905,25 +912,18 @@ impl ComputedValuesExt for ComputedValues {
|
|||
// ratio; otherwise the box has no preferred aspect ratio. Size
|
||||
// calculations involving the aspect ratio work with the content box
|
||||
// dimensions always."
|
||||
(_, PreferredRatio::None) => natural_aspect_ratio.map(|natural_ratio| AspectRatio {
|
||||
i_over_b: natural_ratio,
|
||||
box_sizing_adjustment: LogicalVec2::zero(),
|
||||
}),
|
||||
(_, PreferredRatio::None) => natural_aspect_ratio.map(AspectRatio::from_content_ratio),
|
||||
// "If both auto and a <ratio> are specified together, the preferred
|
||||
// aspect ratio is the specified ratio of width / height unless it
|
||||
// is a replaced element with a natural aspect ratio, in which case
|
||||
// that aspect ratio is used instead. In all cases, size
|
||||
// calculations involving the aspect ratio work with the content box
|
||||
// dimensions always."
|
||||
(true, PreferredRatio::Ratio(preferred_ratio)) => match natural_aspect_ratio {
|
||||
Some(natural_ratio) => Some(AspectRatio {
|
||||
i_over_b: natural_ratio,
|
||||
box_sizing_adjustment: LogicalVec2::zero(),
|
||||
}),
|
||||
None => Some(AspectRatio {
|
||||
i_over_b: (preferred_ratio.0).0 / (preferred_ratio.1).0,
|
||||
box_sizing_adjustment: LogicalVec2::zero(),
|
||||
}),
|
||||
(true, PreferredRatio::Ratio(preferred_ratio)) => {
|
||||
Some(AspectRatio::from_content_ratio(
|
||||
natural_aspect_ratio
|
||||
.unwrap_or_else(|| (preferred_ratio.0).0 / (preferred_ratio.1).0),
|
||||
))
|
||||
},
|
||||
|
||||
// "The box’s preferred aspect ratio is the specified ratio of width
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue