Skip to content

Use viewport instead of initial viewport in screenshot algorithms#1951

Merged
whimboo merged 1 commit into
w3c:masterfrom
Sameem-baba:fix-element-screenshot-viewport
Mar 19, 2026
Merged

Use viewport instead of initial viewport in screenshot algorithms#1951
whimboo merged 1 commit into
w3c:masterfrom
Sameem-baba:fix-element-screenshot-viewport

Conversation

@Sameem-baba
Copy link
Copy Markdown
Contributor

@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
Copy Markdown
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.

Comment thread 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
Copy Markdown
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
Copy Markdown
Contributor 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
Copy link
Copy Markdown
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.

The change looks fine. Thank you!

@whimboo whimboo merged commit 1d4b691 into w3c:master Mar 19, 2026
1 check passed
github-actions Bot added a commit that referenced this pull request Mar 19, 2026
…hm (#1951)

SHA: 1d4b691
Reason: push, by whimboo

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
github-actions Bot added a commit to soloinovator/webdriver that referenced this pull request Mar 19, 2026
…hm (w3c#1951)

SHA: 1d4b691
Reason: push, by pull[bot]

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
github-actions Bot added a commit to xjc90s/webdriver that referenced this pull request Mar 20, 2026
…hm (w3c#1951)

SHA: 1d4b691
Reason: push, by pull[bot]

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
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