Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Editorial: formalize screenshot waiting algorithm #538

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
54 changes: 43 additions & 11 deletions index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ spec: HTML; urlPrefix: https://html.spec.whatwg.org/multipage/
text: default classic script fetch options; url: webappapis.html#default-classic-script-fetch-options
text: default view; url: nav-history-apis.html#dom-document-defaultview
text: environment settings object's Realm; url: webappapis.html#environment-settings-object's-realm
text: event loop processing model; url: event-loop-processing-model
text: focused area of the document; url: document-sequences.html#focused-area-of-the-document
text: getting all used history steps; url:browsing-the-web.html#getting-all-used-history-steps
text: handled; url: webappapis.html#concept-error-handled
Expand All @@ -189,7 +190,6 @@ spec: HTML; urlPrefix: https://html.spec.whatwg.org/multipage/
text: prompt; url: timers-and-user-prompts.html#dom-prompt
text: remove a browsing context; url: browsers.html#bcg-remove
text: report an error; url: webappapis.html#report-the-error
text: run the animation frame callbacks; url: imagebitmap-and-animations.html#run-the-animation-frame-callbacks
text: same origin domain; url: browsers.html#same-origin-domain
text: session history; url: history.html#session-history
text: session history entry; url: browsing-the-web.html#session-history-entry
Expand Down Expand Up @@ -1971,6 +1971,11 @@ implicitly set when the context is created. For browsing contexts with an
associated WebDriver [=window handle=] the [=/browsing context id=] must be the
same as the [=window handle=].

Each [=/browsing context=] has an associated <dfn>list of suspended rendering
Copy link
Member

Choose a reason for hiding this comment

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

Let's add properties directly on the remote end (or session) rather than on the browsing context. In this case a map between browsing context id and animation frame callback ids would work.

ids</dfn>, which is initially an empty list. It is used to track pending
invocations of [=browsingContext.captureScreenshot=] and
[=browsingContext.print=].

<div algorithm>
To <dfn export>get a browsing context</dfn> given |context id|:

Expand All @@ -1985,6 +1990,19 @@ To <dfn export>get a browsing context</dfn> given |context id|:

</div>

<div algorithm>
To <dfn export>resume suspended renderings</dfn> for a given |browsing context|.

1. Let |rendering ids| be |browsing context|'s [=list of suspended rendering ids=].

1. For each |rendering id| in |rendering ids|:

1. [=Resume=] with "<code>animation frame</code>", |rendering id|, and ().

1. [=list/Empty=] |rendering ids|.

</div>

#### The browsingContext.Info Type #### {#type-browsingContext-Info}

[=local end definition=]
Expand Down Expand Up @@ -2479,6 +2497,17 @@ To <dfn>render document to a canvas</dfn> given |document| and |rect|:

</div>

<div algorithm>
To <dfn>await the next animation frame</dfn> given |browsing context|:

1. Let |rendering id| be a new unique opaque string.

1. [=list/Append=] |rendering id| to |browsing context|'s [=list of suspended rendering ids=].

1. [=Await=] with «"<code>animation frame</code>"», and |rendering id|.

</div>

<div algorithm>
To <dfn>encode a canvas as Base64</dfn> given |canvas| and |format|:

Expand Down Expand Up @@ -2532,11 +2561,7 @@ The [=remote end steps=] with <var ignore>session</var> and |command parameters|

1. Let |document| be |context|'s [=active document=].

1. Immediately after the next invocation of the [=run the animation frame
callbacks=] algorithm for |document|:

Issue: This ought to be integrated into the update rendering algorithm in
some more explicit way.
1. [=Await the next animation frame=] with |context|.

1. Let |origin| be the value of the <code>context</code> field of |command
parameters| if present, or "viewport" otherwise.
Expand Down Expand Up @@ -3323,11 +3348,7 @@ Note: The minimum page size is 1 point, which is (2.54 / 72) cm as per

1. Let |document| be |context|'s [=active document=].

1. Immediately after the next invocation of the [=run the animation frame
callbacks=] algorithm for |document|:

Issue: This ought to be integrated into the update rendering algorithm
in some more explicit way.
1. [=Await the next animation frame=] with |context|.

1. Let |pdf data| be the result taking UA-specific steps to generate a
paginated representation of |document|, with the CSS [=media type=] set to
Expand Down Expand Up @@ -9627,6 +9648,17 @@ end:
ignore>col</var>, <var ignore>message</var>, and true if the error is
[=handled=], or false otherwise.

</div>

The [=event loop processing model=] is modified to insert a step at the end of
the sub-steps labeled [=update the rendering=]:

<div algorithm="extension to update the rendering in HTML">

1. For each [=fully active=] <code>Document</code> |doc| in <var
Copy link
Member

Choose a reason for hiding this comment

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

I don't like the term "suspended renderings"; it sounds too much like we're preventing paints from happening, which isn't true, we're just awaiting an animation frame.

Also, on the HTML side pass in the document, not the browsing context. We want to move away from the use of browsing context, so it's easier to do the book keeping entirely on the WebDriver side.

ignore>docs</var> run [=resume suspended renderings=] given |doc|'s
[=/browsing context=]. WEBDRIVERBIDI

</div>
## Console ## {#patches-console}

Expand Down