Skip to content

Commit d0bd15d

Browse files
author
Raphael Kubo da Costa
committed
Reword the "Sensor Type" section, move permission revocation algorithm
Instead of having several paragraphs mixing what a sensor type must or may and algorithms, the "Sensor Type" section now only has two paragraphs and two groups containing what must be defined and what may be defined to make it easier to follow. This also has consequences for the "Extensibility" section, as its "Definition Requirements" subsection used to duplicate some of the contents in "Sensor Type". It now just refers to the latter and provides more details about how some of a sensor type's associated data must be defined in extension specifications. Some data that used to be associated with a sensor type has been removed: - "Associated sensors" were never properly defined and it was not clear that they meant "associated _platform_ sensors". They were only used in the generic sensor permission revocation algorithm, which has been rewritten. - "Permission request algorithm" is a term that has been moved from the Permissions spec to the Requesting Permissions permission in WICG. None of the extension specifications ever defined it. The generic sensor permission revocation algorithm was moved to the "Abstract Operations" section. It has also been merged with the revoke sensor permission algorithm since it was its only caller. There should not be any user-visible effects though: the language was just made more formal by iterating over all Sensor instances belonging to the current realm (like the Web Bluetooth spec does) instead of hand-wavingly gathering all platform sensors (which technically are per-navigable) with the same sensor type. Related to w3c#463.
1 parent d3431b7 commit d0bd15d

File tree

1 file changed

+40
-57
lines changed

1 file changed

+40
-57
lines changed

index.bs

Lines changed: 40 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,9 @@ urlPrefix: https://w3c.github.io/geolocation-sensor/; spec: GEOLOCATION-SENSOR
8080
urlPrefix: https://w3c.github.io/proximity; spec: PROXIMITY
8181
type: dfn
8282
text: ProximitySensor; url: proximity-sensor-interface
83+
urlPrefix: https://tc39.github.io/ecma262/; spec: ECMAScript
84+
type: dfn
85+
text: current realm; url: current-realm
8386
</pre>
8487
<pre class=link-defaults>
8588
spec: dom; type:dfn; text:event
@@ -769,44 +772,23 @@ Note: In order to release hardware resources, the user agent can request underly
769772

770773
<h3 id="model-sensor-type">Sensor Type</h3>
771774

772-
A <dfn>sensor type</dfn> has one or more associated
773-
[=extension sensor interface|extension sensor interfaces=].
774-
775-
A [=sensor type=] has a [=ordered set|set=] of <dfn export>associated sensors</dfn>.
776-
777-
A [=sensor type=] may have a [=default sensor=].
778-
779-
A [=sensor type=] has a [=set/is empty|nonempty=] [=ordered set|set=] of associated
780-
[=powerful feature/names=] referred to as <dfn export>sensor permission names</dfn>.
781-
782-
Note: Multiple [=sensor types=] may share the same [=powerful feature/name=].
783-
784-
A [=sensor type=] has a [=permission revocation algorithm=].
785-
786-
<div algorithm>
787-
788-
To invoke the <dfn local-lt="permission revocation algorithm" export>
789-
generic sensor permission revocation algorithm</dfn>
790-
with [=powerful feature/name=] |permission_name|, run the following steps:
791-
792-
1. For each |sensor_type| whose [=sensor permission names|permission names=] [=set/contains=] |permission_name|:
793-
1. [=set/For each=] |sensor| in |sensor_type|'s [=ordered set|set=] of [=associated sensors=],
794-
1. Invoke [=revoke sensor permission=] with |sensor| as argument.
795-
</div>
796-
797-
A [=sensor type=] has a [=permission request algorithm=].
775+
A <dfn>sensor type</dfn> must have the following associated data:
776+
- One or more [=extension sensor interfaces=].
777+
- An [=set/is empty|nonempty=] [=ordered set=] of associated [=powerful feature/name|powerful
778+
feature names=] referred to as <dfn export>sensor permission names</dfn>.
798779

799-
A [=sensor type=] has a [=set/is empty|nonempty=] [=ordered set|set=] of associated
800-
[=policy-controlled feature=] tokens referred to as <dfn export>sensor feature names</dfn>.
780+
Note: Multiple [=sensor types=] may share the same [=powerful feature/name=].
781+
- An [=set/is empty|nonempty=] [=ordered set=] of associated [=policy-controlled feature=] tokens
782+
referred to as <dfn export>sensor feature names</dfn>.
783+
- A [=permission revocation algorithm=].
801784

802-
A [=sensor type=] may have an associated <dfn export>threshold check
803-
algorithm</dfn>, which takes as arguments two separate [=sensor readings=] and
804-
determines if they differ enough to cause a [=platform sensor=]'s [=latest
805-
reading=] map to be updated.
806-
807-
A [=sensor type=] may have an associated <dfn export>reading quantization
808-
algorithm</dfn>, which takes a [=sensor reading=] and returns a less accurate
809-
[=sensor reading=].
785+
A [=sensor type=] may have the following associated data:
786+
- A [=default sensor=].
787+
- A <dfn export>threshold check algorithm</dfn>, which takes as arguments two separate [=sensor
788+
readings=] and determines if they differ enough to cause a [=platform sensor=]'s [=latest
789+
reading=] map to be updated.
790+
- A <dfn export>reading quantization algorithm</dfn>, which takes a [=sensor reading=] and returns a
791+
less accurate [=sensor reading=].
810792

811793
<h3 id="model-sensor">Sensor</h3>
812794

@@ -1353,21 +1335,22 @@ to {{SensorErrorEventInit}}.
13531335
1. Set |sensor_instance|.{{[[lastEventFiredAt]]}} to null.
13541336
</div>
13551337

1356-
<h3 dfn export>Revoke sensor permission</h3>
1338+
<h3 dfn export>Generic Sensor permission revocation algorithm</h3>
13571339

1358-
<div algorithm="revoke sensor permission">
1340+
<div algorithm="generic sensor permission revocation algorithm">
13591341

13601342
: input
1361-
:: |sensor|, a [=platform sensor=].
1343+
:: |permissionName|, a [=powerful feature/name|powerful feature name=]
13621344
: output
13631345
:: None
13641346

1365-
1. Let |activated_sensors| be |sensor|'s associated [=ordered set|set=] of [=activated sensor objects=].
1366-
1. [=set/For each=] |s| of |activated_sensors|,
1367-
1. Invoke [=deactivate a sensor object=] with |s| as argument.
1368-
1. Let |e| be the result of [=exception/create|creating=]
1369-
a "{{NotAllowedError!!exception}}" {{DOMException}}.
1370-
1. Queue a task to run [=notify error=] with |s| and |e| as arguments.
1347+
1. For each {{Sensor}} instance |sensor| in the [=current realm=]:
1348+
1. If |sensor|'s associated [=platform sensor=]'s [=sensor type=]'s [=sensor permission
1349+
names=] [=set/contains=] |permissionName|:
1350+
1. Invoke [=deactivate a sensor object=] with |sensor|.
1351+
1. Let |exception| be the result of [=exception/create|creating=]
1352+
a "{{NotAllowedError}}" {{DOMException}}.
1353+
1. Queue a task to run [=notify error=] with |sensor| and |exception|.
13711354
</div>
13721355

13731356
<h3 dfn export>Set sensor settings</h3>
@@ -2021,8 +2004,10 @@ accuracy or other settings defined in [=extension specifications=].
20212004

20222005
<h3 id="definition-reqs">Definition Requirements</h3>
20232006

2024-
The following definitions must be specified for
2025-
each [=sensor type=] in [=extension specifications=]:
2007+
[=Extension specifications=] must define all the associated data listed in [[#model-sensor-type]].
2008+
2009+
This section provides more information about some of the associated data that [=extension
2010+
specifications=] must specify.
20262011

20272012
- An <dfn export>extension sensor interface</dfn>, which is an [=interface=]
20282013
whose [=inherited interfaces=] contains {{Sensor}}.
@@ -2044,20 +2029,18 @@ each [=sensor type=] in [=extension specifications=]:
20442029
[=get value from latest reading=] with <strong>this</strong> and
20452030
[=attribute=] [=identifier=] as arguments.
20462031

2047-
- A [=powerful feature/name=], if the [=sensor type=] is not representing
2048-
[=sensor fusion=] (otherwise, [=powerful feature/names=]
2049-
associated with the fusion source [=sensor types=] must be used).
2032+
- If the [=sensor type=] is representing [=sensor fusion=], its [=sensor permission names=] must
2033+
be those associated with the fusion source [=sensor types=].
20502034

20512035
An [=extension specification=] may specify the following definitions
2052-
for each [=sensor types=]:
2036+
for each [=sensor type=]:
20532037

20542038
- A [=dictionary=] whose [=inherited dictionaries=] contains {{SensorOptions}}.
2055-
- A [=default sensor=]. Generally, devices are equipped with a single [=platform sensor=]
2056-
of each [=sensor types|type=],
2057-
so defining a [=default sensor=] should be straightforward.
2058-
For [=sensor types=] where multiple [=device sensor|sensors=] are common,
2059-
[=extension specifications=] may choose not to define a [=default sensor=],
2060-
especially when doing so would not make sense.
2039+
- A [=default sensor=]. Generally, devices are equipped with a single [=platform sensor=] of each
2040+
[=sensor types|type=], in which case defining a [=default sensor=] is straightforward. For
2041+
[=sensor types=] where multiple [=device sensor|sensors=] are common, [=extension
2042+
specifications=] may choose not to define a [=default sensor=], especially when doing so would
2043+
not make sense.
20612044

20622045
<h3 id="extend-automation">Automation</h3>
20632046

0 commit comments

Comments
 (0)