github web-platform-tests/wpt merge_pr_47118

latest releases: merge_pr_49470, epochs/three_hourly/2024-12-03_06H, epochs/six_hourly/2024-12-03_06H...
8 months ago

[line-clamp] Make line-clamp: auto account for margins

In order for line-clamp: auto to properly clamp lines in nested
block elements, their bottom margin/padding/border must be accounted
for. Our previous patch, https://crrev.com/c/5547983, accounted for
paddings and borders, but margins are more complicated due to margin
collapsing.

Fortunately, some of the complications inherent in margin collapsing
don't apply to line-clamp. Since no boxes that start after the clamp
point should affect the layout, and it doesn't make sense to clamp
inside a self-collapsing box (although it does after one), we don't
need to handle self-collapse as part of line-clamp.

However, because a box's bottom margin can collapse with its
ancestors' bottom margins, the ancestor's bottom margin strut must be
propagated to its children. Rather than computing an end margin strut
inwards-out, as happens during normal layout, we need to have this
data before a box's layout start; so we pass the expected end margin
strut outwards-in, into a box's descendants, which we do by adding
LineClampEndMarginStrut to the constraint space.

Finally, when computing the clamp BFC offset for a box, we know the
ancestors' contribution to the bottom margin has already been
accounted for, so we only account for this box's margin contribution.
Similarly, when checking after layout whether a line or box is past
the clamp point, we compute its margin contribution. We do this by
computing the difference between the margin strut sum the parent
accounted for, and the one that we would get including the current
box's bottom margin.

Bug: 40336192
Change-Id: I1e634a3aeaa071c3355277bdf00c3a44e6eca4a4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5690174
Reviewed-by: Ian Kilpatrick ikilpatrick@chromium.org
Commit-Queue: Andreu Botella abotella@igalia.com
Cr-Commit-Position: refs/heads/main@{#1327044}

Don't miss a new wpt release

NewReleases is sending notifications on new releases.