Closed Bug 2086959 Opened 1 month ago Closed 18 days ago

[wpt-sync] Sync PR 64185 - WebKit export of https://bugs.webkit.org/show_bug.cgi?id=321236

Categories

(Core :: CSS Parsing and Computation, task, P4)

task

Tracking

()

RESOLVED FIXED
162 Branch
Tracking Status
firefox162 --- fixed

People

(Reporter: wpt-sync, Unassigned)

References

()

Details

(Whiteboard: [wptsync downstream])

Sync web-platform-tests PR 64185 into mozilla-central (this bug is closed when the sync is complete).

PR: https://github.com/web-platform-tests/wpt/pull/64185
Details from upstream follow.

Alan Baradlay <zalan@apple.com> wrote:

WebKit export of https://bugs.webkit.org/show_bug.cgi?id=321236

WebKit export from bug: [<!---->block-<!---->in-<!---->inline]<!----> A block level box'<!---->s margin after is counted twice when only that box needs layout

<pre>
[block-in-inline] A block level box's margin after is counted twice when only that box needs layout

layoutSimpleBlockContentInInline() is the fast-path taken when a container with inline children needs
layout only because one of its block level boxes does. It walks the block level boxes, lays each one out,
and takes the MarginInfo the last one leaves behind. The lines are not laid out at all.

That is fine while the block level box is the only in-flow content, since its margins are then the
container's own. A line next to the box changes that: the line consumes the adjacent margin as its own
spacing, so nothing is left to collapse with the container. Normal line layout accounts for this in
LineBuilder::layoutInlineContent (see updateMarginStateIfNeeded), which does two things once a line places
contentful inline content - it resets the margin values, and it leaves the before side of the block. The
shortcut lays out no lines, so it has to do both itself as the walk passes contentful inline content.

 &lt;div&gt;&lt;span&gt;&lt;div style=&quot;margin-bottom: 16px&quot;&gt;block&lt;/div&gt;&lt;/span&gt;line after&lt;/div&gt;

reports a 16px margin after on the container once something inside the block changes and this path runs:
the margin is still in MarginInfo when the caller hands it to handleAfterSideOfBlock(), so it is counted a
second time.

 &lt;div&gt;line before&lt;span&gt;&lt;div style=&quot;margin-top: 16px&quot;&gt;block&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;

reports a 16px margin before for the same reason. Resetting the margin values is not enough here, because
canCollapseWithMarginBefore() reads m_atBeforeSideOfBlock rather than the values, so collapseMargins()
still promotes the block's own margin before into the container's collapsed margin before and the container
is then repositioned by its parent.

WebKit-Bug: <a href="https://bugs.webkit.org/show_bug.cgi?id=321236">https://bugs.webkit.org/show_bug.cgi?id=321236</a>
WebKit-Canonical-Link: <a href="https://commits.webkit.org/318792@main">https://commits.webkit.org/318792@main</a>
</pre>

Component: web-platform-tests → CSS Parsing and Computation
Product: Testing → Core

CI Results

Ran 11 Firefox configurations based on mozilla-central, and Firefox, Chrome, and Safari on GitHub CI

Total 817 tests and 2 subtests

Status Summary

Firefox

OK : 2[GitHub] 26[Gecko-android-em-14-x86_64-debug-geckoview, Gecko-android-em-14-x86_64-lite-opt-geckoview, Gecko-android-em-14-x86_64-opt-geckoview, Gecko-linux2404-64-debug, Gecko-linux2404-64-opt, Gecko-windows11-32-25h2-debug, Gecko-windows11-32-25h2-opt, Gecko-windows11-64-25h2-debug, Gecko-windows11-64-25h2-opt]
PASS: 2[Gecko-linux2204-64-wayland-debug, Gecko-linux2204-64-wayland-opt] 4[GitHub] 98[Gecko-windows11-32-25h2-debug, Gecko-windows11-32-25h2-opt] 877[Gecko-windows11-64-25h2-debug, Gecko-windows11-64-25h2-opt] 879[Gecko-android-em-14-x86_64-debug-geckoview, Gecko-android-em-14-x86_64-lite-opt-geckoview, Gecko-android-em-14-x86_64-opt-geckoview] 882[Gecko-linux2404-64-debug, Gecko-linux2404-64-opt]
FAIL: 26[Gecko-windows11-32-25h2-debug, Gecko-windows11-32-25h2-opt] 31[Gecko-linux2404-64-debug, Gecko-linux2404-64-opt] 34[Gecko-android-em-14-x86_64-debug-geckoview, Gecko-android-em-14-x86_64-lite-opt-geckoview, Gecko-android-em-14-x86_64-opt-geckoview] 36[Gecko-windows11-64-25h2-debug, Gecko-windows11-64-25h2-opt]

Chrome

OK : 2
PASS: 4

Safari

OK : 2
PASS: 4

Links

Gecko CI (Treeherder)
GitHub PR Head
GitHub PR Base

Details

New Tests That Don't Pass

Status: NEW → RESOLVED
Closed: 18 days ago
Resolution: --- → FIXED
Target Milestone: --- → 162 Branch
You need to log in before you can comment on or make changes to this bug.