Skip to content

Commit 1d4b691

Browse files
authored
Use visual viewport instead of initial viewport in screenshot algorithm (#1951)
Updates the screenshot algorithm to stay aligned with WebDriver BiDi. Fixes #1947
1 parent cc4c0d2 commit 1d4b691

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

index.html

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10926,12 +10926,12 @@ <h2>Screen capture</h2>
1092610926

1092710927
<p>Screenshots are a mechanism for providing
1092810928
additional visual diagnostic information.
10929-
They work by dumping a snapshot of the <a>initial viewport</a>&apos;s
10929+
They work by dumping a snapshot of the <a>visual viewport</a>&apos;s
1093010930
framebuffer as a lossless PNG image.
1093110931
It is returned to the <a>local end</a> as a Base64 encoded string.
1093210932

1093310933
<p>WebDriver provides the <a>Take Screenshot</a> <a>command</a>
10934-
to capture the <a>top-level browsing context</a>&apos;s <a>initial viewport</a>,
10934+
to capture the <a>top-level browsing context</a>&apos;s <a>visual viewport</a>,
1093510935
and a <a>command</a> <a>Take Element Screenshot</a>
1093610936
for doing the same with the visible region of an <a>element</a>&apos;s
1093710937
<a>bounding rectangle</a> after it has been <a>scrolled into view</a>.
@@ -10940,15 +10940,15 @@ <h2>Screen capture</h2>
1094010940
given a <a>rectangle</a>:
1094110941

1094210942
<ol>
10943-
<li><p>If either the <a>initial viewport</a>&apos;s width or height
10943+
<li><p>If either the <a>visual viewport</a>&apos;s width or height
1094410944
is 0 <a>CSS pixels</a>,
1094510945
return <a>error</a> with <a>error code</a> <a>unable to capture screen</a>.
1094610946

10947-
<li><p>Let <var>paint width</var> be the <a>initial viewport</a>&apos;s width –
10947+
<li><p>Let <var>paint width</var> be the <a>visual viewport</a>&apos;s width –
1094810948
<a>min</a>(<a>rectangle x coordinate</a>,
1094910949
<a>rectangle x coordinate</a> + <a>rectangle width dimension</a>).
1095010950

10951-
<li><p>Let <var>paint height</var> be the <a>initial viewport</a>&apos;s height –
10951+
<li><p>Let <var>paint height</var> be the <a>visual viewport</a>&apos;s height –
1095210952
<a>min</a>(<a>rectangle y coordinate</a>,
1095310953
<a>rectangle y coordinate</a> + <a>rectangle height dimension</a>).
1095410954

@@ -11973,6 +11973,7 @@ <h2>Index</h2>
1197311973
<!-- ScrollIntoViewOptions --> <li><dfn><a href=https://drafts.csswg.org/cssom-view/#dictdef-scrollintoviewoptions><code>ScrollIntoViewOptions</code></a></dfn>
1197411974
<!-- ScrollIntoViewOptions block --> <li><dfn><a href=https://drafts.csswg.org/cssom-view/#dom-scrollintoviewoptions-block>Logical scroll position "<code>block</code>"</a></dfn>
1197511975
<!-- ScrollIntoViewOptions inline --> <li><dfn><a href=https://drafts.csswg.org/cssom-view/#dom-scrollintoviewoptions-inline>Logical scroll position "<code>inline</code>"</a></dfn>
11976+
<!-- visual viewport --> <li><dfn><a href="https://drafts.csswg.org/cssom-view/#visual-viewport">visual viewport</a></dfn>
1197611977
</ul>
1197711978

1197811979
<dd>The following terms are defined in [[mediaqueries-4]]:

0 commit comments

Comments
 (0)