Skip to content

Use viewport instead of initial viewport in screenshot algorithms#1951

Open
Sameem-baba wants to merge 1 commit intow3c:masterfrom
Sameem-baba:fix-element-screenshot-viewport
Open

Use viewport instead of initial viewport in screenshot algorithms#1951
Sameem-baba wants to merge 1 commit intow3c:masterfrom
Sameem-baba:fix-element-screenshot-viewport

Conversation

@Sameem-baba
Copy link

@Sameem-baba Sameem-baba commented Mar 4, 2026

The screenshot algorithms currently reference the initial viewport.

If the browser window is resized after the document loads,
this can lead to incorrect clipping calculations.

This change updates the algorithms to reference the viewport instead.

Fixes #1947


Preview | Diff

Copy link
Contributor

@whimboo whimboo left a comment

Choose a reason for hiding this comment

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

I think we can ignore the IPR for this PR so don't worry about it for now.

index.html Outdated
<p>Screenshots are a mechanism for providing
additional visual diagnostic information.
They work by dumping a snapshot of the <a>initial viewport</a>&apos;s
They work by dumping a snapshot of the <a>viewport</a>&apos;s
Copy link
Contributor

Choose a reason for hiding this comment

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

In WebDriver BiDi we explicitly use the visual viewport, see this line in the get the origin rectangle algorithm. We should do the same for classic including the addition of the reference to the cssom-view specification.

I think that should apply to all the entries in this file.

Copy link
Author

Choose a reason for hiding this comment

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

I have changed it to visual viewport

The screenshot algorithms reference the initial viewport when
computing framebuffer bounds. If the browser window is resized
after the document loads, this can lead to incorrect clipping.

Update the algorithms to reference the visual viewport instead.

Fixes w3c#1947
@Sameem-baba Sameem-baba force-pushed the fix-element-screenshot-viewport branch from 5f12ad9 to 0007dd5 Compare March 6, 2026 09:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Consider changing initial viewport to visual viewport for element screenshots

2 participants