commit 663da710ae13f547614eee339aa565111a2bb7ed
parent 3872cd9d21ea2c0618c8f93f6ed769e273cf9891
Author: Ane Diaz de Tuesta <anediaz@gmail.com>
Date: Mon, 8 Dec 2025 12:27:08 +0000
Bug 2004108 [wpt PR 56496] - layout_shift: Sort LayoutShift.sources by impact area, a=testonly
Automatic update from web-platform-tests
layout_shift: Sort LayoutShift.sources by impact area
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: https://github.com/WICG/layout-instability/pull/126
Bug: 450950606
Change-Id: Iec3530250a8c29f44203f0e17b7789806323dd48
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7196706
Commit-Queue: Ane Diaz De Tuesta <anediaz@gmail.com>
Reviewed-by: Michal Mocny <mmocny@chromium.org>
Reviewed-by: Scott Haseley <shaseley@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1554088}
--
wpt-commits: a9cc67ed3c97410ad427eeb0cdfb2baea7bb644c
wpt-pr: 56496
Diffstat:
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/testing/web-platform/tests/layout-instability/sources-maximpact.html b/testing/web-platform/tests/layout-instability/sources-maximpact.html
@@ -43,9 +43,9 @@ promise_test(async () => {
cls_expect(watcher, {sources: [
{
- node: $("#a"),
- previousRect: [0, 0, 30, 30],
- currentRect: [0, 50, 30, 30]
+ node: $("#e"),
+ previousRect: [110, 0, 40, 30],
+ currentRect: [110, 50, 40, 30]
},
{
node: $("#f"),
@@ -53,6 +53,11 @@ promise_test(async () => {
currentRect: [150, 50, 30, 40]
},
{
+ node: $("#a"),
+ previousRect: [0, 0, 30, 30],
+ currentRect: [0, 50, 30, 30]
+ },
+ {
node: $("#c"),
previousRect: [50, 0, 10, 50],
currentRect: [50, 50, 10, 50]
@@ -61,11 +66,6 @@ promise_test(async () => {
node: $("#d"),
previousRect: [60, 0, 50, 10],
currentRect: [60, 50, 50, 10]
- },
- {
- node: $("#e"),
- previousRect: [110, 0, 40, 30],
- currentRect: [110, 50, 40, 30]
}
]});
}, "Source attribution prioritizes by impact.");