Open Bug 1651528 Opened 6 years ago Updated 7 hours ago

Implement Layout Instability API ("layout shift")

Categories

(Core :: Layout, enhancement, P3)

enhancement

Tracking

()

ASSIGNED
Size Estimate L

People

(Reporter: dholbert, Assigned: bas.schouten)

References

(Depends on 1 open bug, Blocks 1 open bug, )

Details

(Keywords: dev-doc-needed, parity-chrome, web-feature, Whiteboard: [platform-feature])

User Story

web-feature:layout-instability
webcompat-risk:low

Attachments

(8 external files)

This bug tracks the implementation of the Layout Instability API (for computing "layout shift" / "cumulative layout shift").
Spec: https://wicg.github.io/layout-instability/

(Not sure about timeline/priority at this point; just filing this as a placeholder bug for now.)

Depends on: 1651531
User Story: (updated)
Whiteboard: [platform-feature][webcompat:risk-low]
User Story: (updated)
Whiteboard: [platform-feature][webcompat:risk-low] → [platform-feature]

The position written there is tentative and overwritten by block-direction
alignment, so every inline frame of a reflowed line moved twice, which marks it
modified for retained display lists even when it ends up where it was. The ruby
base container's inline position is read before alignment, so it keeps the full
write, and the frames that SetSpanForEmptyLine skips get their position there.

Behind layout.layout_shift.enabled, which is off by default. Nothing creates
entries yet.

Frames store their rect from before their first change since the last rendering
update in a table on the PresShell, which costs one bit test when the rect
changes and nothing otherwise. A new rendering phase after intersection
observations scores the recorded moves, ignoring those explained by scrolling
or scroll anchoring, and queues an entry.

Key and mouse button presses count as recent input right away. Shifts while a
pointer is down are held back until it is released, which makes them excluded,
or canceled because it became a scroll, which doesn't.

When content is inserted into a long block, nsBlockFrame slides every following
line, and adding each of their frames to the hash table dominated the cost of
tracking. Keep them in one list per block instead, which reporting can cull
cheaply.

User Story: (updated)
Attachment #9671310 - Attachment description: WIP: Bug 1651528 - Only size frames in nsLineLayout::ReflowFrame. r?#layout-reviewers → WIP: Bug 1651528 - Part 1: Only size frames in nsLineLayout::ReflowFrame. r?#layout-reviewers
Attachment #9671311 - Attachment description: WIP: Bug 1651528 - Add the LayoutShift performance entry type. r?#dom-reviewers,#webidl! → WIP: Bug 1651528 - Part 2: Add the LayoutShift performance entry type. r?#dom-reviewers,#webidl!
Attachment #9671312 - Attachment description: WIP: Bug 1651528 - Track layout shifts and report LayoutShift entries. r?#layout-reviewers → WIP: Bug 1651528 - Part 3: Track layout shifts and report LayoutShift entries. r?#layout-reviewers
Attachment #9671313 - Attachment description: WIP: Bug 1651528 - Exclude layout shifts caused by user input. r?#dom-core-reviewers,#layout-reviewers → WIP: Bug 1651528 - Part 4: Exclude layout shifts caused by user input. r?#dom-core-reviewers,#layout-reviewers
Attachment #9671314 - Attachment description: WIP: Bug 1651528 - Track frames moved by line slides per block. r?#layout-reviewers → WIP: Bug 1651528 - Part 5: Track frames moved by line slides per block. r?#layout-reviewers

The spec defines the visual representation of a node as the bounds of its own
boxes, and the impact region as the union of the visual representations of the
unstable nodes. These tests expected the bounding box of the parent and its
overflowing child instead (300x500), which is what Chrome computes from the
parent's visual overflow. Per node, the impact region is the parent's 300x400
plus the 100x100 where the child overflows below it.

child-shift-with-parent.html also gets a background on the child, so that the
expected score doesn't depend on whether boxes that don't paint anything count,
which the spec and implementations disagree on.

Previous clip geometry, transient visibility changes, source pruning across
both rectangles, new descendants of a moving parent, resizes that move or keep
the starting corner, scroll containers that move while resizing, detached
attribution nodes, input timestamps of held-back shifts, and the entry type not
being supported in workers.

Still failing:

  • body-display-change.html: reconstructing a frame loses its old position.
  • transform-counter-layout-shift.html, translate-counter-layout-shift.html,
    shift-with-counter-scroll-and-transform.html,
    shift-with-counter-scroll-and-translate.html: transform changes in the same
    rendering update aren't accounted for.
  • pointerdown-becomes-scroll.html: no pointercancel reaches content when the
    touch becomes a scroll.
  • inline-flow-shift.html: text boxes are shorter than the test assumes.
Assignee: nobody → bas
Attachment #9671310 - Attachment description: WIP: Bug 1651528 - Part 1: Only size frames in nsLineLayout::ReflowFrame. r?#layout-reviewers → Bug 1651528 - Part 1: Only size frames in nsLineLayout::ReflowFrame. r?#layout-reviewers
Status: NEW → ASSIGNED
Attachment #9671311 - Attachment description: WIP: Bug 1651528 - Part 2: Add the LayoutShift performance entry type. r?#dom-reviewers,#webidl! → Bug 1651528 - Part 2: Add the LayoutShift performance entry type. r?#dom-reviewers,#webidl!
Attachment #9671312 - Attachment description: WIP: Bug 1651528 - Part 3: Track layout shifts and report LayoutShift entries. r?#layout-reviewers → Bug 1651528 - Part 3: Track layout shifts and report LayoutShift entries. r?#layout-reviewers
Attachment #9671313 - Attachment description: WIP: Bug 1651528 - Part 4: Exclude layout shifts caused by user input. r?#dom-core-reviewers,#layout-reviewers → Bug 1651528 - Part 4: Exclude layout shifts caused by user input. r?#dom-core-reviewers,#layout-reviewers
Attachment #9671314 - Attachment description: WIP: Bug 1651528 - Part 5: Track frames moved by line slides per block. r?#layout-reviewers → Bug 1651528 - Part 5: Track frames moved by line slides per block. r?#layout-reviewers
Attachment #9677692 - Attachment description: WIP: Bug 1651528 - Part 6: Count parent and child separately in the child-shift-with-parent layout-instability tests. r?#layout-reviewers → Bug 1651528 - Part 6: Count parent and child separately in the child-shift-with-parent layout-instability tests. r?#layout-reviewers
Attachment #9677693 - Attachment description: WIP: Bug 1651528 - Part 7: Add layout-instability web-platform-tests for cases the existing tests leave uncovered. r?#layout-reviewers → Bug 1651528 - Part 7: Add layout-instability web-platform-tests for cases the existing tests leave uncovered. r?#layout-reviewers
Attachment #9677694 - Attachment description: WIP: Bug 1651528 - Part 8: Enable the layout-instability web-platform-tests. r?#layout-reviewers → Bug 1651528 - Part 8: Enable the layout-instability web-platform-tests. r?#layout-reviewers
Size Estimate: --- → L
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: