Closed Bug 1714045 Opened 5 years ago Closed 3 years ago

[wpt-sync] Sync PR 29184 - Add LayoutObject::CSSBoxParent().

Categories

(Core :: DOM: Core & HTML, task, P4)

task

Tracking

()

RESOLVED INVALID

People

(Reporter: wpt-sync, Unassigned)

References

()

Details

(Whiteboard: [wptsync downstream])

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

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

b'Morten Stenshorne <mstensho@chromium.org>' wrote:

Add LayoutObject::CSSBoxParent().

For now it only behaves differently from Parent() if we're a rendered
legend. This allows for some light simplification in assorted ancestry
walking code, as we had a quite a few instances of special code for
this.

In LayoutNG, all children of a fieldset are placed inside an anonymous
fieldset contents wrapper. This also includes the rendered legend (since
it's hard to keep track of which child legend is the rendered legend at
any given time), even if the HTML standard says that it should be a
direct child of the fieldset. For the purpose of finding the containing
block or CSS box parent (as defined in the standard), we'll need to
ignore the anonymous fieldset contents wrapper when walking upwards from
a rendered legend.

If a fieldset is a grid, flex, math or custom layout, the anonymous
fieldset contents wrapper will take care of that part, e.g. it's the
wrapper that becomes a grid here:

\<fieldset style="display:grid;">
\<legend>\</legend>
\<div>\</div>
\</fieldset>

We'll get this LayoutObject tree:

LayoutNGFieldset FIELDSET
Layout(NG)Grid (anonymous)
LayoutNGBlockFlow LEGEND
LayoutNGBlockFlow DIV

Only the DIV should be treated as a grid item. The LEGEND shouldn't, and
this is what this CL fixes.

Note that on the NG side, we were already behaving correctly. We make
sure the the layout input node tree structure is corrected (so that the
algorithms behave correctly), and the fragment output also isn't so
weird:

NGPhysicalBoxFragment FIELDSET
NGPhysicalBoxFragment LEGEND
NGPhysicalBoxFragment (anonymous grid container)
NGPhysicalBoxFragment DIV

Have the various IsFooItem() use CSSBoxParent() instead of Parent().
Also make sure to use CSSBoxParent() at locations that first call
IsFooItem() and then do To\<LayoutFoo>(parent). That shouldn't be
strictly necessary, since the bug was that we'd get false positives, but
it just seemed too scary to leave alone.

Bug: 1214561
Change-Id: Ib4870943f27e7d685890ef96df8bae465cb04194

Reviewed-on: https://chromium-review.googlesource.com/2928718
WPT-Export-Revision: e0a1df8eda66c0a63a51b2097523e5595d187374

Component: web-platform-tests → DOM: Core & HTML
Product: Testing → Core
Status: NEW → RESOLVED
Closed: 3 years ago
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.