Skip to content

Conversation

chromium-wpt-export-bot
Copy link
Collaborator

@chromium-wpt-export-bot chromium-wpt-export-bot commented Oct 9, 2025

The LayoutShift API was returning attribution data (currentRect and
prevRect) in physical pixels instead of CSS pixels. This makes the Layout
Instability API inconsistent with other layout-related APIs, which all use
CSS pixels.

With the current behavior, consumers of this API are required to manually
convert the attribution data using devicePixelRatio to make the coordinates
relative to the viewport.

Previously, on a display with device pixel ratio 2.0, a 100x100 CSS pixel
element positioned at (50, 50) would be reported as 200x200 at (100, 100)
in the attribution data. After this fix, it correctly reports as 100x100
at (50, 50) CSS pixels, matching the actual element position and size as
seen by web developers.

The layout shift scores themselves remain unaffected as they are calculated
using the impact fraction (shifted area relative to viewport) multiplied
by the distance fraction (movement distance relative to viewport dimensions).
Only the attribution data reporting to the Performance API is corrected.

Bug: 399058544
Change-Id: Ib8109c12eaf1c1a2e5648edbc39ef97111431494
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6624567
Reviewed-by: Manuel Rego <[email protected]>
Reviewed-by: Michal Mocny <[email protected]>
Commit-Queue: Manuel Rego <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1527545}

The LayoutShift API was returning attribution data (currentRect and
prevRect) in physical pixels instead of CSS pixels. This makes the Layout
Instability API inconsistent with other layout-related APIs, which all use
CSS pixels.

With the current behavior, consumers of this API are required to manually
convert the attribution data using devicePixelRatio to make the coordinates
relative to the viewport.

Previously, on a display with device pixel ratio 2.0, a 100x100 CSS pixel
element positioned at (50, 50) would be reported as 200x200 at (100, 100)
in the attribution data. After this fix, it correctly reports as 100x100
at (50, 50) CSS pixels, matching the actual element position and size as
seen by web developers.

The layout shift scores themselves remain unaffected as they are calculated
using the impact fraction (shifted area relative to viewport) multiplied
by the distance fraction (movement distance relative to viewport dimensions).
Only the attribution data reporting to the Performance API is corrected.

Bug: 399058544
Change-Id: Ib8109c12eaf1c1a2e5648edbc39ef97111431494
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6624567
Reviewed-by: Manuel Rego <[email protected]>
Reviewed-by: Michal Mocny <[email protected]>
Commit-Queue: Manuel Rego <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1527545}
Copy link
Collaborator

@wpt-pr-bot wpt-pr-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The review process for this patch is being conducted in the Chromium project.

@chromium-wpt-export-bot chromium-wpt-export-bot merged commit 30a480f into master Oct 9, 2025
15 checks passed
@chromium-wpt-export-bot chromium-wpt-export-bot deleted the chromium-export-cl-6624567 branch October 9, 2025 16:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants