-
Notifications
You must be signed in to change notification settings - Fork 31
Update docs to mention layout shift sources being sorted by impact area #126
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
mmocny
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for also updating MDN, and the examples here.
|
I've approved this but I'm not a maintainer of this wicg repo-- I'll talk to @yoavweiss |
|
@anediaz -- the build is failing with some errors I think the main one is: Could you try to fix that first? |
Sort the LayoutShift.sources array by per-source impact area in descending order (largest first). LayoutShift.sources currently returns up to five sources in an undefined order. This makes it difficult for diagnostics and tooling to reliably identify the most impactful contributor to a layout shift. Sorting ensures that sources[0] always corresponds to the largest impact area. Impact area is computed as the union of previousRect and currentRect for each source, matching the semantics used by Cumulative Layout Shift (CLS) calculation. This provides a deterministic ordering and makes the API more meaningful for users. The WICG spec PR: WICG/layout-instability#126 Bug: 450950606 Change-Id: Iec3530250a8c29f44203f0e17b7789806323dd48 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7196706 Commit-Queue: Ane Diaz De Tuesta <[email protected]> Reviewed-by: Michal Mocny <[email protected]> Reviewed-by: Scott Haseley <[email protected]> Cr-Commit-Position: refs/heads/main@{#1554088}
Sort the LayoutShift.sources array by per-source impact area in descending order (largest first). LayoutShift.sources currently returns up to five sources in an undefined order. This makes it difficult for diagnostics and tooling to reliably identify the most impactful contributor to a layout shift. Sorting ensures that sources[0] always corresponds to the largest impact area. Impact area is computed as the union of previousRect and currentRect for each source, matching the semantics used by Cumulative Layout Shift (CLS) calculation. This provides a deterministic ordering and makes the API more meaningful for users. The WICG spec PR: WICG/layout-instability#126 Bug: 450950606 Change-Id: Iec3530250a8c29f44203f0e17b7789806323dd48 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7196706 Commit-Queue: Ane Diaz De Tuesta <[email protected]> Reviewed-by: Michal Mocny <[email protected]> Reviewed-by: Scott Haseley <[email protected]> Cr-Commit-Position: refs/heads/main@{#1554088}
Sort the LayoutShift.sources array by per-source impact area in descending order (largest first). LayoutShift.sources currently returns up to five sources in an undefined order. This makes it difficult for diagnostics and tooling to reliably identify the most impactful contributor to a layout shift. Sorting ensures that sources[0] always corresponds to the largest impact area. Impact area is computed as the union of previousRect and currentRect for each source, matching the semantics used by Cumulative Layout Shift (CLS) calculation. This provides a deterministic ordering and makes the API more meaningful for users. The WICG spec PR: WICG/layout-instability#126 Bug: 450950606 Change-Id: Iec3530250a8c29f44203f0e17b7789806323dd48 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7196706 Commit-Queue: Ane Diaz De Tuesta <[email protected]> Reviewed-by: Michal Mocny <[email protected]> Reviewed-by: Scott Haseley <[email protected]> Cr-Commit-Position: refs/heads/main@{#1554088}
0252b44 to
ed6a3d4
Compare
Thanks for the help! It seems to be passing now :-) |
Summary
Define the ordering of
LayoutShift.sourcesto be sorted by impact area in descending order.This ensures that the element which contributed most to the layout shift appears first in the array.
Motivation
This change aligns the specification with:
Without this clarification, developers cannot rely on any consistent ordering of the
sourcesarray, making it harder to programmatically identify the most impactful elements causing layout shifts.Changes
This PR adds explicit documentation and normative algorithm steps to specify that layout shift sources are sorted by impact area:
sourcesare sorted by impact area in descending orderPreview | Diff