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: Tidy up uses of "in parallel". #299

Merged
merged 1 commit into from
Mar 22, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
139 changes: 69 additions & 70 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ <h2>
</ol>
<p>
To <dfn>obtain permission</dfn> for <a>wake lock type</a> |name|, run
these steps <a>in parallel</a>. This async algorithm returns either
the following steps. This algorithm returns either
{{PermissionState/"granted"}} or {{PermissionState/"denied"}}.
</p>
<aside class="note">
Expand Down Expand Up @@ -338,7 +338,8 @@ <h3>
</p>
<ol class="algorithm">
<li>Let |document:Document| be the [=environment settings object /
responsible document=] of the <a>current settings object</a>.
responsible document=] of <a>this</a>'s <a>relevant settings
object</a>.
Copy link
Contributor

Choose a reason for hiding this comment

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

Domenic just used "

  • Let |document:Document| be the [=current settings object=]'s [=associated Document=]."

  • Copy link
    Member Author

    Choose a reason for hiding this comment

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

    I think it makes sense to clean this up in #307 rather than here, as it's part of the effort to stop mentioning "responsible document" altogether.

    </li>
    <li data-tests="wakelock-disabled-by-feature-policy.https.sub.html">
    If |document| is not [=allowed to use=] the [=policy-controlled
    Expand All @@ -363,48 +364,73 @@ <h3>
    return [=a promise rejected with=] {{"NotAllowedError"}}
    {{DOMException}}.
    </li>
    rakuco marked this conversation as resolved.
    Show resolved Hide resolved
    <li>Let |record| be the <a>platform wake lock</a>'s <a>state
    record</a> associated with |document| and |type|.
    </li>
    <li>Let |promise:Promise| be [=a new promise=].
    </li>
    <li>Return |promise| and run the following steps <a>in parallel</a>:
    <li>Run the following steps <a>in parallel</a>:
    <ol>
    <li>
    <a>Abort when</a> the steps to <a>determine the visibility
    state</a> return `hidden`.
    </li>
    <li>Let |state:PermissionState| be the result of awaiting
    <a>obtain permission</a> steps with "`screen-wake-lock`".
    <li>Let |state:PermissionState| be the result of invoking
    <a>obtain permission</a> with "`screen-wake-lock`".
    </li>
    <li data-tests="wakelock-request-denied.https.html">If |state| is
    {{PermissionState/"denied"}}, then:
    <ol>
    <li>Reject |promise| with a {{"NotAllowedError"}}
    {{DOMException}}.
    <li>
    <a>Queue a global task</a> on the <a>screen wake lock task
    source</a> given |document|'s <a>relevant global object</a>
    to reject |promise| with a {{"NotAllowedError"}}
    {{DOMException}}.
    </li>
    <li>Abort these steps.
    rakuco marked this conversation as resolved.
    Show resolved Hide resolved
    </li>
    </ol>
    </li>
    <li>Let |lock:WakeLockSentinel| be a new {{WakeLockSentinel}}
    object with its {{WakeLockSentinel/type}} attribute set to
    |type|.
    </li>
    <li>Invoke <a>acquire a wake lock</a> with |lock| and
    {{WakeLockType/"screen"}}.
    <aside class="note">
    The <a>acquire a wake lock</a> algorithm may ultimately be
    unable to acquire a lock from the operating system, but this
    is indistinguishable from a successful lock acquisition to
    avoid user fingerprinting (failure to acquire a lock can
    indicate low battery levels, for example).
    </aside>
    </li>
    <li>Resolve |promise| with |lock|.
    <li>
    <a>Queue a global task</a> on the <a>screen wake lock task
    source</a> given |document|'s <a>relevant global object</a> to
    run these steps:
    <ol>
    <li>If the steps to <a>determine the visibility state</a>
    return `hidden`, then:
    <ol>
    <li>Reject |promise| with a {{"NotAllowedError"}}
    {{DOMException}}.
    </li>
    <li>Abort these steps.
    </li>
    </ol>
    </li>
    <li>If |record|.{{[[ActiveLocks]]}} [=list/is empty=], then
    invoke the following steps <a>in parallel</a>:
    <ol>
    <li>Invoke <a>acquire a wake lock</a> with
    {{WakeLockType/"screen"}}.
    <aside class="note">
    The <a>acquire a wake lock</a> algorithm may
    ultimately be unable to acquire a lock from the
    operating system, but this is indistinguishable from
    a successful lock acquisition to avoid user
    fingerprinting (failure to acquire a lock can
    indicate low battery levels, for example).
    </aside>
    </li>
    </ol>
    </li>
    <li>Let |lock:WakeLockSentinel| be a new {{WakeLockSentinel}}
    object with its {{WakeLockSentinel/type}} attribute set to
    |type|.
    </li>
    <li>Add |lock| to |record|.{{[[ActiveLocks]]}}.
    </li>
    <li>Resolve |promise| with |lock|.
    </li>
    </ol>
    </li>
    </ol>
    </li>
    <li>
    <a>If aborted</a>, reject |promise| with a {{"NotAllowedError"}}
    {{DOMException}}.
    <li>Return |promise|.
    </li>
    </ol>
    </section>
    Expand Down Expand Up @@ -508,22 +534,12 @@ <h3>
    following steps:
    </p>
    <ol class="algorithm">
    <li>If <a>this</a>'s {{[[Released]]}} internal slot is `true`, return
    <a>a promise resolved with</a> `undefined`.
    <li>If <a>this</a>'s {{[[Released]]}} is `false`, then run <a>release
    a wake lock</a> with |lock:WakeLockSentinel| set to <a>this</a> and
    |type:WakeLockType| set to the value of <a>this</a>'s
    {{WakeLockSentinel/type}} attribute.
    </li>
    <li>Otherwise, let |promise:Promise| be <a>a new promise</a>.
    </li>
    <li>Run the following steps <a>in parallel</a>:
    <ol>
    <li>Run <a>release a wake lock</a> with |lock:WakeLockSentinel|
    set to <a>this</a> and |type:WakeLockType| set to the value of
    <a>this</a>'s {{WakeLockSentinel/type}} attribute.
    </li>
    <li>Resolve |promise|.
    </li>
    </ol>
    </li>
    <li>Return |promise|.
    <li>Return <a>a promise resolved with</a> `undefined`.
    </li>
    </ol>
    </section>
    Expand Down Expand Up @@ -705,27 +721,16 @@ <h3>
    Acquire wake lock algorithm
    </h3>
    <p>
    To <dfn>acquire a wake lock</dfn> for a given |lock:WakeLockSentinel|
    and |type:WakeLockType|, run these steps <a>in parallel</a>:
    To <dfn>acquire a wake lock</dfn> for a given |type:WakeLockType|,
    run these steps:
    </p>
    <ol class="algorithm">
    <li>If the wake lock for type |type| is not <a>applicable</a>, abort
    these steps.
    </li>
    <li>If the <a>platform wake lock</a> has an active lock for |type|,
    abort these steps.
    </li>
    <li>Ask the underlying operating system to <a>acquire the wake
    lock</a> of type |type|.
    </li>
    <li>Let |document:Document| be the [=environment settings object /
    responsible document=] of the <a>current settings object</a>.
    </li>
    <li>Let |record| be the <a>platform wake lock</a>'s <a>state
    record</a> associated with |document| and |type|.
    </li>
    <li>Add |lock| to |record|.{{[[ActiveLocks]]}}.
    </li>
    </ol>
    </section>
    <section>
    Expand All @@ -734,7 +739,7 @@ <h3>
    </h3>
    <p>
    To <dfn>release a wake lock</dfn> for a given |lock:WakeLockSentinel|
    and |type:WakeLockType|, run these steps <a>in parallel</a>:
    and |type:WakeLockType|, run these steps:
    </p>
    <ol class="algorithm">
    <li>Let |document:Document| be the [=environment settings object /
    Expand All @@ -748,8 +753,7 @@ <h3>
    </li>
    <li>Remove |lock| from |record|.{{[[ActiveLocks]]}}.
    </li>
    <li>If the internal slot {{[[ActiveLocks]]}} of all the <a>platform
    wake lock</a>'s <a>state record</a>s are all empty, then run the
    <li>If |record|.{{[[ActiveLocks]]}} [=list/is empty=], then run the
    following steps <a>in parallel</a>:
    <ol>
    <li>Ask the underlying operating system to release the wake lock
    Expand All @@ -770,15 +774,10 @@ <h3>
    </li>
    </ol>
    </li>
    <li>Set |lock|'s {{[[Released]]}} to `true`.
    </li>
    <li>
    <a>Queue a task</a> to run the following steps:
    <ol>
    <li>Set |lock|'s {{[[Released]]}} internal slot to `true`.
    </li>
    <li>
    <a>Fire an event</a> named "`release`" at |lock|.
    </li>
    </ol>
    <a>Fire an event</a> named "`release`" at |lock|.
    rakuco marked this conversation as resolved.
    Show resolved Hide resolved
    </li>
    </ol>
    </section>
    Expand Down Expand Up @@ -866,8 +865,8 @@ <h2>
    <p>
    We would like to offer our sincere thanks to Mounir Lamouri, Sergey
    Konstantinov, Matvey Larionov, Dominique Hazael-Massieux, Domenic
    Denicola, Thomas Steiner, Raphael Kubo da Costa for their contributions
    to this work.
    Denicola, Thomas Steiner, Anne van Kesteren for their contributions to
    this work.
    </p>
    </section>
    <section class="appendix informative" id="changes">
    Expand Down