layout: Allow collapsing bottom margins with any indefinite block size (#36278)

According to CSS2, the bottom margin of a block container can collapse
with the bottom margin of its last in-flow child if `height` computes to
`auto`.

However, according to CSS Sizing, that was "legacy spec prose" and
should be interpreted as "behaves as `auto`".

Therefore, cyclic percentages and intrinsic keywords like `min-content`
shouldn't prevent margin collapse, because they behave as `auto`.

This change aligns Servo with Gecko and Blink, but diverges from WebKit.

https://www.w3.org/TR/CSS22/box.html#collapsing-margins
https://www.w3.org/TR/css-sizing/#behave-auto

Testing:
-
`tests/wpt/tests/css/css-sizing/margin-collapse-with-indefinite-block-size-001.html`
-
`tests/wpt/tests/css/css-sizing/margin-collapse-with-indefinite-block-size-002.html`
-
`tests/wpt/tests/css/css-sizing/margin-collapse-with-indefinite-block-size-003.html`
-
`tests/wpt/tests/css/css-sizing/margin-collapse-with-indefinite-block-size-004.html`
-
`tests/wpt/tests/css/css-sizing/margin-collapse-with-indefinite-block-size-005.html`

Signed-off-by: Oriol Brufau <obrufau@igalia.com>
This commit is contained in:
Oriol Brufau 2025-04-02 05:10:04 -07:00 committed by GitHub
parent 3bc0eeab8f
commit 1f13e8b596
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 181 additions and 1 deletions

View file

@ -248765,6 +248765,71 @@
{}
]
],
"margin-collapse-with-indefinite-block-size-001.html": [
"47d2a0a043d32ba6220c1dd6a26859908a19bf6e",
[
null,
[
[
"/css/reference/ref-filled-green-100px-square.xht",
"=="
]
],
{}
]
],
"margin-collapse-with-indefinite-block-size-002.html": [
"eb401c92b5e9475129f39be9980f47f42cb2bfa0",
[
null,
[
[
"/css/reference/ref-filled-green-100px-square.xht",
"=="
]
],
{}
]
],
"margin-collapse-with-indefinite-block-size-003.html": [
"51f16f68e6998de4956a5f0615b49406fcacb02e",
[
null,
[
[
"/css/reference/ref-filled-green-100px-square.xht",
"=="
]
],
{}
]
],
"margin-collapse-with-indefinite-block-size-004.html": [
"c393560d6c6ce799943db09468ba8e5cb0e90a5c",
[
null,
[
[
"/css/reference/ref-filled-green-100px-square.xht",
"=="
]
],
{}
]
],
"margin-collapse-with-indefinite-block-size-005.html": [
"27814994aaac7ead76f67d051e8744323e8f4247",
[
null,
[
[
"/css/reference/ref-filled-green-100px-square.xht",
"=="
]
],
{}
]
],
"max-content-input-001.html": [
"aabbea015748f9276718e2ba9728efc375c8910b",
[