mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +01:00
layout: Remove special height logic of replaced element with auto width (#35275)
When computing the intrinsic block size of a replaced element with a computed preferred inline size of `auto`, instead of transferring the final inline size through the aspect ratio, we were only transferring the min and max constraints. We did this to match other browsers, but Ian Kilpatrick agreed that this is a bug and plans to change Blink. CSSWG issue: https://github.com/w3c/csswg-drafts/issues/11236 Signed-off-by: Oriol Brufau <obrufau@igalia.com>
This commit is contained in:
parent
e2daeeaceb
commit
98816b753c
9 changed files with 80 additions and 114 deletions
|
@ -979,28 +979,6 @@ impl Sizes {
|
|||
get_content_size: impl FnOnce() -> ContentSizes,
|
||||
is_table: bool,
|
||||
) -> Au {
|
||||
let (preferred, min, max) = self.resolve_each(
|
||||
axis,
|
||||
automatic_size,
|
||||
automatic_minimum_size,
|
||||
stretch_size,
|
||||
get_content_size,
|
||||
is_table,
|
||||
);
|
||||
preferred.clamp_between_extremums(min, max)
|
||||
}
|
||||
|
||||
/// Resolves each of the three sizes into a numerical value, separately.
|
||||
#[inline]
|
||||
pub(crate) fn resolve_each(
|
||||
&self,
|
||||
axis: Direction,
|
||||
automatic_size: Size<Au>,
|
||||
automatic_minimum_size: Au,
|
||||
stretch_size: Option<Au>,
|
||||
get_content_size: impl FnOnce() -> ContentSizes,
|
||||
is_table: bool,
|
||||
) -> (Au, Au, Option<Au>) {
|
||||
// The provided `get_content_size` is a FnOnce but we may need its result multiple times.
|
||||
// A LazyCell will only invoke it once if needed, and then reuse the result.
|
||||
let content_size = LazyCell::new(get_content_size);
|
||||
|
@ -1010,7 +988,7 @@ impl Sizes {
|
|||
// but it can be a smaller amount if there are collapsed rows.
|
||||
// Therefore, disregard sizing properties and just defer to the intrinsic size.
|
||||
// This is being discussed in https://github.com/w3c/csswg-drafts/issues/11408
|
||||
return (content_size.max_content, content_size.min_content, None);
|
||||
return content_size.max_content;
|
||||
}
|
||||
|
||||
let preferred =
|
||||
|
@ -1028,7 +1006,7 @@ impl Sizes {
|
|||
min.max_assign(content_size.min_content);
|
||||
}
|
||||
let max = self.max.resolve_for_max(stretch_size, &content_size);
|
||||
(preferred, min, max)
|
||||
preferred.clamp_between_extremums(min, max)
|
||||
}
|
||||
|
||||
/// Tries to extrinsically resolve the three sizes into a single [`SizeConstraint`].
|
||||
|
|
|
@ -535,7 +535,7 @@ impl ReplacedContents {
|
|||
)
|
||||
.into()
|
||||
};
|
||||
let (preferred_inline, min_inline, max_inline) = sizes.inline.resolve_each(
|
||||
let inline_size = sizes.inline.resolve(
|
||||
Direction::Inline,
|
||||
automatic_size.inline,
|
||||
Au::zero(),
|
||||
|
@ -543,19 +543,10 @@ impl ReplacedContents {
|
|||
get_inline_content_size,
|
||||
false, /* is_table */
|
||||
);
|
||||
let inline_size = preferred_inline.clamp_between_extremums(min_inline, max_inline);
|
||||
|
||||
// Now we can compute the block size, using the inline size from above.
|
||||
let block_content_size = LazyCell::new(|| -> ContentSizes {
|
||||
let get_inline_size = || {
|
||||
if sizes.inline.preferred.is_initial() {
|
||||
// TODO: do we really need to special-case `auto`?
|
||||
// https://github.com/w3c/csswg-drafts/issues/11236
|
||||
SizeConstraint::MinMax(min_inline, max_inline)
|
||||
} else {
|
||||
SizeConstraint::Definite(inline_size)
|
||||
}
|
||||
};
|
||||
let get_inline_size = || SizeConstraint::Definite(inline_size);
|
||||
self.content_size(
|
||||
Direction::Block,
|
||||
preferred_aspect_ratio,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue