diff --git a/index.bs b/index.bs index 7e1816b..50465ba 100644 --- a/index.bs +++ b/index.bs @@ -539,65 +539,65 @@ The requestPermission() method steps a
visible
", return.
- 1. For each policy of « "accelerometer
", "gyroscope
" »:
- 1. If document is not allowed to use the policy-controlled feature named policy, return.
- 1. Let topLevelTraversable be window's navigable's top-level traversable.
- 1. Let platformLinearAcceleration be null.
- 1. If topLevelTraversable's virtual sensor mapping contains "linear-acceleration
":
- 1. Let virtualSensor be topLevelTraversable's virtual sensor mapping["linear-acceleration
"].
- 1. If virtualSensor's can provide readings flag is true, then set platformLinearAcceleration to the latest readings provided to virtualSensor.
- 1. Otherwise, if the implementation is able to provide linear acceleration:
- 1. Set platformLinearAcceleration to the device's linear acceleration along the X, Y and Z axes.
- 1. Let acceleration be null.
- 1. If platformLinearAcceleration is not null:
- 1. Set acceleration to a new {{DeviceMotionEventAcceleration}} created in window's realm.
- 1. Set acceleration's x axis acceleration to platformLinearAcceleration's value along the X axis, or null if it cannot be provided.
- 1. If acceleration's x axis acceleration is not null, limit its precision to no more than 0.1 m/s2.
- 1. Set acceleration's y axis acceleration to platformLinearAcceleration's value along the Y axis, or null if it cannot be provided.
- 1. If acceleration's y axis acceleration is not null, limit its precision to no more than 0.1 m/s2.
- 1. Set acceleration's z axis acceleration to platformLinearAcceleration's value along the Z axis, or null if it cannot be provided.
- 1. If acceleration's z axis acceleration is not null, limit its precision to no more than 0.1 m/s2.
- 1. Let platformAccelerationIncludingGravity be null.
- 1. If topLevelTraversable's virtual sensor mapping contains "accelerometer
":
- 1. Let virtualSensor be topLevelTraversable's virtual sensor mapping["accelerometer
"].
- 1. If virtualSensor's can provide readings flag is true, then set platformAccelerationIncludingGravity to the latest readings provided to virtualSensor.
- 1. Otherwise, if the implementation is able to provide acceleration with gravity:
- 1. Set platformAccelerationIncludingGravity to the device's linear acceleration along the X, Y and Z axes.
- 1. Let accelerationIncludingGravity be null.
- 1. If platformAccelerationIncludingGravity is not null:
- 1. Set accelerationIncludingGravity to a new {{DeviceMotionEventAcceleration}} created in window's realm.
- 1. Set accelerationIncludingGravity's x axis acceleration to platformAccelerationIncludingGravity's value along the X axis, or null if it cannot be provided.
- 1. If accelerationIncludingGravity's x axis acceleration is not null, limit its precision to no more than 0.1 m/s2.
- 1. Set accelerationIncludingGravity's y axis acceleration to platformAccelerationIncludingGravity's value along the Y axis, or null if it cannot be provided.
- 1. If accelerationIncludingGravity's y axis acceleration is not null, limit its precision to no more than 0.1 m/s2.
- 1. Set accelerationIncludingGravity's z axis acceleration to platformAccelerationIncludingGravity's value along the Z axis, or null if it cannot be provided.
- 1. If accelerationIncludingGravity's z axis acceleration is not null, limit its precision to no more than 0.1 m/s2.
- 1. Let platformRotationRate be null.
- 1. If topLevelTraversable's virtual sensor mapping contains "gyroscope
":
- 1. Let virtualSensor be topLevelTraversable's virtual sensor mapping["gyroscope
"].
- 1. If virtualSensor's can provide readings flag is true, then set platformRotationRate to the latest readings provided to virtualSensor.
- 1. Otherwise, if the implementation is able to provide rotation rate:
- 1. Set platformRotationRate to the device's rotation rate about the X, Y and Z axes.
- 1. Let rotationRate be null.
- 1. If platformRotationRate is not null:
- 1. Set rotationRate to a new {{DeviceMotionEventRotationRate}} created in window's realm.
- 1. Set rotationRate's x axis rotation rate to platformRotationRate's value about the X axis, or null if it cannot be provided.
- 1. If rotationRate's x axis rotation rate is not null, limit its precision to no more than 0.1 deg/s.
- 1. Set rotationRate's y axis rotation rate to platformRotationRate's value about the Y axis, or null if it cannot be provided.
- 1. If rotationRate's y axis rotation rate is not null, limit its precision to no more than 0.1 deg/s.
- 1. Set rotationRate's z axis rotation rate to platformRotationRate's value about the Z axis, or null if it cannot be provided.
- 1. If rotationRate's z axis rotation rate is not null, limit its precision to no more than 0.1 deg/s.
- 1. Let environment be window's relevant settings object.
- 1. Run these steps in parallel:
- 1. For each permission name in « "accelerometer", "gyroscope" »:
- 1. Let state be the result of getting the current permission state with permission name and environment.
- 1. If state is not "{{PermissionState/granted}}", return.
- 1. Queue a global task on the device motion and orientation task source given window to run the following steps:
- 1. Fire an event named devicemotion
at window, using {{DeviceMotionEvent}}, with the {{DeviceMotionEvent/acceleration}} attribute initialized to acceleration, the {{DeviceMotionEvent/accelerationIncludingGravity}} attribute initialized to accelerationIncludingGravity, the {{DeviceMotionEvent/rotationRate}} attribute initialized to rotationRate, and the {{DeviceMotionEvent/interval}} attribute initialized to interval.
+At an [=implementation-defined=] interval |interval|, the user agent must execute the following steps on a [=/navigable=]'s [=navigable/active window=] |window|:
+
+ 1. Let |document| be |window|'s [=associated Document=].
+ 1. If |document|'s [=Document/visibility state=] is not "`visible`", return.
+ 1. [=list/For each=] |policy| of « "accelerometer", "gyroscope" »:
+ 1. If |document| is not [=allowed to use=] the [=policy-controlled feature=] named |policy|, return.
+ 1. Let |topLevelTraversable| be |window|'s [=Window/navigable=]'s [=navigable/top-level traversable=].
+ 1. Let |platformLinearAcceleration| be null.
+ 1. If |topLevelTraversable|'s [=virtual sensor mapping=] [=map/contains=] "`linear-acceleration`":
+ 1. Let |virtualSensor| be |topLevelTraversable|'s [=virtual sensor mapping=]["`linear-acceleration`"].
+ 1. If |virtualSensor|'s [=can provide readings flag=] is true, then set |platformLinearAcceleration| to the latest readings provided to |virtualSensor|.
+ 1. Otherwise, if the implementation is able to provide [=linear acceleration=]:
+ 1. Set |platformLinearAcceleration| to the device's [=linear acceleration=] along the X, Y and Z axes.
+ 1. Let |acceleration| be null.
+ 1. If |platformLinearAcceleration| is not null:
+ 1. Set |acceleration| to a [=new=] {{DeviceMotionEventAcceleration}} created in |window|'s [=global object/realm=].
+ 1. Set |acceleration|'s [=DeviceMotionEventAcceleration/x axis acceleration=] to |platformLinearAcceleration|'s value along the X axis, or null if it cannot be provided.
+ 1. If |acceleration|'s [=DeviceMotionEventAcceleration/x axis acceleration=] is not null, limit its precision to no more than 0.1 m/s2.
+ 1. Set |acceleration|'s [=DeviceMotionEventAcceleration/y axis acceleration=] to |platformLinearAcceleration|'s value along the Y axis, or null if it cannot be provided.
+ 1. If |acceleration|'s [=DeviceMotionEventAcceleration/y axis acceleration=] is not null, limit its precision to no more than 0.1 m/s2.
+ 1. Set |acceleration|'s [=DeviceMotionEventAcceleration/z axis acceleration=] to |platformLinearAcceleration|'s value along the Z axis, or null if it cannot be provided.
+ 1. If |acceleration|'s [=DeviceMotionEventAcceleration/z axis acceleration=] is not null, limit its precision to no more than 0.1 m/s2.
+ 1. Let |platformAccelerationIncludingGravity| be null.
+ 1. If |topLevelTraversable|'s [=virtual sensor mapping=] [=map/contains=] "`accelerometer`":
+ 1. Let |virtualSensor| be |topLevelTraversable|'s [=virtual sensor mapping=]["`accelerometer`"].
+ 1. If |virtualSensor|'s [=can provide readings flag=] is true, then set |platformAccelerationIncludingGravity| to the latest readings provided to |virtualSensor|.
+ 1. Otherwise, if the implementation is able to provide [=acceleration with gravity=]:
+ 1. Set |platformAccelerationIncludingGravity| to the device's [=linear acceleration=] along the X, Y and Z axes.
+ 1. Let |accelerationIncludingGravity| be null.
+ 1. If |platformAccelerationIncludingGravity| is not null:
+ 1. Set |accelerationIncludingGravity| to a [=new=] {{DeviceMotionEventAcceleration}} created in |window|'s [=global object/realm=].
+ 1. Set |accelerationIncludingGravity|'s [=DeviceMotionEventAcceleration/x axis acceleration=] to |platformAccelerationIncludingGravity|'s value along the X axis, or null if it cannot be provided.
+ 1. If |accelerationIncludingGravity|'s [=DeviceMotionEventAcceleration/x axis acceleration=] is not null, limit its precision to no more than 0.1 m/s2.
+ 1. Set |accelerationIncludingGravity|'s [=DeviceMotionEventAcceleration/y axis acceleration=] to |platformAccelerationIncludingGravity|'s value along the Y axis, or null if it cannot be provided.
+ 1. If |accelerationIncludingGravity|'s [=DeviceMotionEventAcceleration/y axis acceleration=] is not null, limit its precision to no more than 0.1 m/s2.
+ 1. Set |accelerationIncludingGravity|'s [=DeviceMotionEventAcceleration/z axis acceleration=] to |platformAccelerationIncludingGravity|'s value along the Z axis, or null if it cannot be provided.
+ 1. If |accelerationIncludingGravity|'s [=DeviceMotionEventAcceleration/z axis acceleration=] is not null, limit its precision to no more than 0.1 m/s2.
+ 1. Let |platformRotationRate| be null.
+ 1. If |topLevelTraversable|'s [=virtual sensor mapping=] [=map/contains=] "`gyroscope`":
+ 1. Let |virtualSensor| be |topLevelTraversable|'s [=virtual sensor mapping=]["`gyroscope`"].
+ 1. If |virtualSensor|'s [=can provide readings flag=] is true, then set |platformRotationRate| to the latest readings provided to |virtualSensor|.
+ 1. Otherwise, if the implementation is able to provide [=rotation rate=]:
+ 1. Set |platformRotationRate| to the device's [=rotation rate=] about the X, Y and Z axes.
+ 1. Let |rotationRate| be null.
+ 1. If |platformRotationRate| is not null:
+ 1. Set |rotationRate| to a [=new=] {{DeviceMotionEventRotationRate}} created in |window|'s [=global object/realm=].
+ 1. Set |rotationRate|'s [=DeviceMotionEventRotationRate/x axis rotation rate=] to |platformRotationRate|'s value about the X axis, or null if it cannot be provided.
+ 1. If |rotationRate|'s [=DeviceMotionEventRotationRate/x axis rotation rate=] is not null, limit its precision to no more than 0.1 deg/s.
+ 1. Set |rotationRate|'s [=DeviceMotionEventRotationRate/y axis rotation rate=] to |platformRotationRate|'s value about the Y axis, or null if it cannot be provided.
+ 1. If |rotationRate|'s [=DeviceMotionEventRotationRate/y axis rotation rate=] is not null, limit its precision to no more than 0.1 deg/s.
+ 1. Set |rotationRate|'s [=DeviceMotionEventRotationRate/z axis rotation rate=] to |platformRotationRate|'s value about the Z axis, or null if it cannot be provided.
+ 1. If |rotationRate|'s [=DeviceMotionEventRotationRate/z axis rotation rate=] is not null, limit its precision to no more than 0.1 deg/s.
+ 1. Let |environment| be |window|'s [=relevant settings object=].
+ 1. Run these steps [=in parallel=]:
+ 1. [=list/For each=] |permission| in « "accelerometer", "gyroscope" »:
+ 1. Let |state| be the result of [=getting the current permission state=] with |permission| and |environment|.
+ 1. If |state| is not "{{PermissionState/granted}}", return.
+ 1. [=Queue a global task=] on the [=device motion and orientation task source=] given |window| to run the following steps:
+ 1. [=Fire an event=] named "devicemotion" at |window|, using {{DeviceMotionEvent}}, with the {{DeviceMotionEvent/acceleration}} attribute initialized to |acceleration|, the {{DeviceMotionEvent/accelerationIncludingGravity}} attribute initialized to |accelerationIncludingGravity|, the {{DeviceMotionEvent/rotationRate}} attribute initialized to |rotationRate|, and the {{DeviceMotionEvent/interval}} attribute initialized to |interval|.