Skip to content

Commit

Permalink
Merge pull request #425 from rakuco/algorithm-proof-reading
Browse files Browse the repository at this point in the history
Do some editorial adjustments to the Sensor algorithms.
  • Loading branch information
anssiko authored Dec 14, 2021
2 parents ef6a1e3 + 90cee3f commit f9caadf
Showing 1 changed file with 27 additions and 25 deletions.
52 changes: 27 additions & 25 deletions index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -1102,9 +1102,9 @@ with the internal slots described in the following table:

<div algorithm="is sensor activated">

The getter of the {{Sensor/activated!!attribute}} attribute must run these steps:
The {{Sensor/activated!!attribute}} getter steps are:

1. If <strong>this</strong>.{{[[state]]}} is "activated",
1. If [=this=].{{[[state]]}} is "activated",
return true.
1. Otherwise, return false.
</div>
Expand All @@ -1113,32 +1113,32 @@ with the internal slots described in the following table:

<div algorithm="sensor has reading">

The getter of the {{Sensor/hasReading!!attribute}} attribute must run these steps:
The {{Sensor/hasReading!!attribute}} getter steps are:

1. Let |timestamp| be the result of invoking [=get value from latest reading=] with <strong>this</strong> and "timestamp" as arguments.
1. Let |timestamp| be the result of invoking [=get value from latest reading=] with [=this=] and "timestamp" as arguments.
1. If |timestamp| is not null, return true.
1. Otherwise, return false.
</div>

### Sensor.timestamp ### {#sensor-timestamp}

The getter of the {{Sensor/timestamp!!attribute}} attribute returns
the result of invoking [=get value from latest reading=] with <strong>this</strong>
and "timestamp" as arguments. It represents a [=reading timestamp=].
The {{Sensor/timestamp!!attribute}} getter steps are to return
the result of invoking [=get value from latest reading=] with [=this=]
and "timestamp" as arguments.

It represents a [=reading timestamp=].

### Sensor.start() ### {#sensor-start}

<div algorithm="to start a sensor">

The {{Sensor/start()}} method must run these steps:
The {{Sensor/start()}} method steps are:

1. Let |sensor_state| be the value of |sensor_instance|.{{[[state]]}}.
1. If |sensor_state| is either "activating"
or "activated", then return.
1. Set |sensor_instance|.{{[[state]]}} to "activating".
1. If [=this=].{{[[state]]}} is either "activating" or "activated", then
return.
1. Set [=this=].{{[[state]]}} to "activating".
1. Run these sub-steps [=in parallel=]:
1. let |connected| be the result of invoking [=connect to sensor=] with |sensor_instance|
1. Let |connected| be the result of invoking [=connect to sensor=] with [=this=]
as argument.
1. If |connected| is false, then
1. Let |e| be the result of [=created|creating=] a
Expand All @@ -1153,29 +1153,29 @@ and "timestamp" as arguments. It represents a [=reading timestamp=].
correctly diagnosing the reason for the rejection
and might lead to confusing instructions to the user,
but it is a tradeoff some User Agent might choose to make. -->
1. Queue a task to run [=notify error=] with |e| and |sensor_instance| as arguments.
1. Queue a task to run [=notify error=] with [=this=] and |e| as arguments.
1. Return.
1. Let |permission_state| be the result of invoking
[=request sensor access=] with |sensor_instance| as argument.
[=request sensor access=] with [=this=] as argument.
1. If |permission_state| is "granted",
1. Invoke [=activate a sensor object=] with |sensor_instance| as argument.
1. Invoke [=activate a sensor object=] with [=this=] as argument.
1. Otherwise, if |permission_state| is "denied",
1. let |e| be the result of [=created|creating=]
1. Let |e| be the result of [=created|creating=]
a "{{NotAllowedError!!exception}}" {{DOMException}}.
1. Queue a task to run [=notify error=] with |e| and |sensor_instance| as arguments.
1. Queue a task to run [=notify error=] with [=this=] and |e| as arguments.
</div>


### Sensor.stop() ### {#sensor-stop}

<div algorithm="to stop a sensor">

The {{Sensor/stop()}} method must run these steps:
The {{Sensor/stop()}} method steps are:

1. If |sensor_instance|.{{[[state]]}} is "idle", then return.
1. Set |sensor_instance|.{{[[state]]}} to "idle".
1. If [=this=].{{[[state]]}} is "idle", then return.
1. Set [=this=].{{[[state]]}} to "idle".
1. Run these sub-steps [=in parallel=]:
1. Invoke [=deactivate a sensor object=] with |sensor_instance| as argument.
1. Invoke [=deactivate a sensor object=] with [=this=] as argument.
</div>


Expand All @@ -1188,7 +1188,7 @@ to notify that new [=sensor reading|reading=] is available.
### Sensor.onactivate ### {#sensor-onactivate}

{{Sensor/onactivate}} is an {{EventHandler}} which is called when
<strong>this</strong>.{{[[state]]}} transitions from "activating" to "activated".
[=this=].{{[[state]]}} transitions from "activating" to "activated".


### Sensor.onerror ### {#sensor-onerror}
Expand Down Expand Up @@ -1242,7 +1242,9 @@ dictionary SensorErrorEventInit : EventInit {

### SensorErrorEvent.error ### {#sensor-error-event-error}

Gets the {{DOMException}} object passed to {{SensorErrorEventInit}}.
The {{SensorErrorEvent/error!!attribute}} getter steps are to return the value it was initialized to.

It represents the {{DOMException}} object passed to {{SensorErrorEventInit}}.

<h2 id="abstract-operations">Abstract Operations</h2>

Expand Down Expand Up @@ -1361,7 +1363,7 @@ Gets the {{DOMException}} object passed to {{SensorErrorEventInit}}.
1. Invoke [=deactivate a sensor object=] with |s| as argument.
1. Let |e| be the result of [=created|creating=]
a "{{NotAllowedError!!exception}}" {{DOMException}}.
1. Queue a task to run [=notify error=] with |e| and |s| as arguments.
1. Queue a task to run [=notify error=] with |s| and |e| as arguments.
</div>


Expand Down

0 comments on commit f9caadf

Please sign in to comment.