From 6bdcd72a78d640e2ffdd819c4da123516a578370 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20C=C3=A1ceres?= Date: Wed, 9 Jun 2021 16:05:42 +1000 Subject: [PATCH 1/9] Always invoke in a microtask step --- index.html | 253 +++++++++++++++++++++++++++-------------------------- 1 file changed, 128 insertions(+), 125 deletions(-) diff --git a/index.html b/index.html index 5a70bfc..027c722 100644 --- a/index.html +++ b/index.html @@ -596,165 +596,167 @@

  • Let |watchTasks:Set| be [=this=]'s {{Geolocation/[[watchTasks]]}}.
  • -
  • Acquire a watch id. -
      -
    1. If |previous id| was provided, let |watchId:long| be - |previous id|; Otherwise, let |watchId:long| be an - [=implementation-defined=] {{long}} that is greater than or equal - to zero. -
    2. -
    3. [=Set/Append=] |watchId| to |watchTasks|. -
    4. -
    5. Return |watchId| and continue [=in parallel=]. -
    6. -
    +
  • If |previous id| was provided, let |watchId:long| be |previous + id|; Otherwise, let |watchId:long| be an [=implementation-defined=] + {{long}} that is greater than or equal to zero.
  • -
  • Do security check. -
      -
    1. If the environment settings object is a - non-secure context, then: -
        -
      1. [=Call back with error=] |errorCallback| and - {{GeolocationPositionError/PERMISSION_DENIED}}. -
      2. -
      3. [=List/Remove=] |watchId| from |watchTasks|. -
      4. -
      5. Terminate this algorithm. -
      6. -
      -
    2. -
    +
  • [=Set/Append=] |watchId| to |watchTasks|.
  • -
  • Wait for document to become - visible. -
      -
    1. Let |document:Document| be the [=current settings object=]'s - [=associated Document=]. -
    2. -
    3. If |document:Document| is [=Document/hidden=], wait for the - |document| to become [=Document/visible=]. -
    4. -
    -
  • -
  • - [=Check permission=] passing |errorCallback|. If the check return - failure: -
      -
    1. [=List/Remove=] |watchId| from |watchTasks|. -
    2. -
    3. Terminate this algorithm. -
    4. -
    +
  • Return |watchId|.
  • -
  • - Acquire position. +
  • Run these steps [=in parallel=]:
      -
    1. Let |acquisitionTime:DOMTimeStamp| be a new {{DOMTimeStamp}} - that represents now in milliseconds, using 01 January, 1970 UTC - as the epoch. -
    2. -
    3. If |options|.{{PositionOptions/maximumAge}} is greater than - 0, and |cachedPosition| is not null: +
    4. Do security check.
        -
      1. Let |cachedPosition:GeolocationPosition| be [=this=]'s - {{Geolocation/[[cachedPosition]]}}. -
      2. -
      3. Let |cacheTime:long| be |acquisitionTime| minus the value - of |options|.{{PositionOptions/maximumAge}} member. -
      4. -
      5. If |cachedPosition|'s {{GeolocationPosition/timestamp}}'s - value is greater than |cacheTime|, and - |cachedPosition|.{{GeolocationPosition/[[isHighAccuracy]]}} - equals |options|.{{PositionOptions/enableHighAccuracy}}: +
      6. If the environment settings object is a + non-secure context, then:
          -
        1. [=Queue a microtask=] to invoke |successCallback| - with |cachedPosition|. +
        2. [=Call back with error=] |errorCallback| and + {{GeolocationPositionError/PERMISSION_DENIED}}. +
        3. +
        4. [=List/Remove=] |watchId| from |watchTasks|.
        5. -
        6. Go to determine - repetition steps below. +
        7. Terminate this algorithm.
    5. -
    6. Let |timeout:Task| be a new timed [=task=] that runs in - |options|.{{PositionOptions/timeout}} milliseconds after - |acquisitionTime|, which performs the following sub-steps: - +
    7. Wait for document to become + visible.
        -
      1. If the entry for |timerId| in the [=list of active - timers=] has been cleared, then abort these steps. +
      2. Let |document:Document| be the [=current settings + object=]'s [=associated Document=].
      3. -
      4. [=Call back with error=] with |errorCallback| and - {{GeolocationPositionError/TIMEOUT}}. +
      5. If |document:Document| is [=Document/hidden=], wait for + the |document| to become [=Document/visible=].
    8. -
    9. Let |timerId:long| be an [=implementation-defined=] - identifier that represents |timeout|. -
    10. -
    11. Add |timerId| to the [=list of active timers=]. +
    12. + [=Check permission=] passing |errorCallback|. If the check + returns failure: +
        +
      1. [=List/Remove=] |watchId| from |watchTasks|. +
      2. +
      3. Terminate this algorithm. +
      4. +
    13. -
    14. Try to acquire the device's position, optionally taking into - consideration the value of - |options|.{{PositionOptions/enableHighAccuracy}}: +
    15. + Acquire + position.
        -
      1. If acquiring a position succeeds: +
      2. Let |acquisitionTime:DOMTimeStamp| be a new + {{DOMTimeStamp}} that represents now in milliseconds, using + 01 January, 1970 UTC as the epoch. +
      3. +
      4. If |options|.{{PositionOptions/maximumAge}} is greater + than 0, and |cachedPosition| is not null:
          -
        1. Let |position:GeolocationPosition| be [=a new - `GeolocationPosition`=] passing |acquisitionTime| and - |options|.{{PositionOptions/enableHighAccuracy}}. +
        2. Let |cachedPosition:GeolocationPosition| be + [=this=]'s {{Geolocation/[[cachedPosition]]}}.
        3. -
        4. Set [=this=]'s {{Geolocation/[[cachedPosition]]}} to - |position|. +
        5. Let |cacheTime:long| be |acquisitionTime| minus the + value of |options|.{{PositionOptions/maximumAge}} member. +
        6. +
        7. If |cachedPosition|'s + {{GeolocationPosition/timestamp}}'s value is greater than + |cacheTime|, and + |cachedPosition|.{{GeolocationPosition/[[isHighAccuracy]]}} + equals |options|.{{PositionOptions/enableHighAccuracy}}: +
            +
          1. [=Queue a microtask=] with a step that + [=invokes=] |successCallback| with |cachedPosition|. +
          2. +
          3. Go to determine + repetition steps below. +
          4. +
          +
        8. +
        +
      5. +
      6. Let |timeout:Task| be a new timed [=task=] that runs in + |options|.{{PositionOptions/timeout}} milliseconds after + |acquisitionTime|, which performs the following sub-steps: + +
          +
        1. If the entry for |timerId| in the [=list of active + timers=] has been cleared, then abort these steps.
        2. -
        3. [=Queue a microtask=] to [=invoke=] |successCallback| - with |position|. +
        4. [=Call back with error=] with |errorCallback| and + {{GeolocationPositionError/TIMEOUT}}.
      7. -
      8. If acquiring a position fails: +
      9. Let |timerId:long| be an [=implementation-defined=] + identifier that represents |timeout|. +
      10. +
      11. Add |timerId| to the [=list of active timers=]. +
      12. +
      13. Try to acquire the device's position, optionally taking + into consideration the value of + |options|.{{PositionOptions/enableHighAccuracy}}:
          -
        1. [=Call back with error=] passing |errorCallback| and - {{GeolocationPositionError/POSITION_UNAVAILABLE}}. +
        2. If acquiring a position succeeds: +
            +
          1. Let |position:GeolocationPosition| be [=a new + `GeolocationPosition`=] passing |acquisitionTime| and + |options|.{{PositionOptions/enableHighAccuracy}}. +
          2. +
          3. Set [=this=]'s {{Geolocation/[[cachedPosition]]}} + to |position|. +
          4. +
          5. [=Queue a microtask=] with a step that + [=invokes=] |successCallback| with |position|. +
          6. +
          +
        3. +
        4. If acquiring a position fails: +
            +
          1. [=Call back with error=] passing |errorCallback| + and + {{GeolocationPositionError/POSITION_UNAVAILABLE}}. +
          2. +
      14. +
      15. Clear |timerId| from the [=list of active timers=]. +
    16. -
    17. Clear |timerId| from the [=list of active timers=]. -
    18. -
    -
  • -
  • - Determine repetition. -
      -
    1. If |repeats| is false: +
    2. + Determine repetition.
        -
      1. [=List/Remove=] |watchId| from |watchTasks|. -
      2. -
      3. Terminate this algorithm. +
      4. If |repeats| is false: +
          +
        1. [=List/Remove=] |watchId| from |watchTasks|. +
        2. +
        3. Terminate this algorithm. +
        4. +
    3. -
    -
  • -
  • Wait for a significant change of geographic position. What - constitutes a significant change of geographic position is left to - the implementation. A user agents MAY impose a rate limit on the - frequency position changes. -
  • -
  • If |watchTasks| [=list/contain|contains=] |watchId|, then: -
      -
    1. [=Request position=] passing |successCallback|, - |errorCallback|, |options|, |repeats|, and |watchId|. +
    2. Wait for a significant change of geographic position. What + constitutes a significant change of geographic position is left + to the implementation. A user agents MAY impose a rate limit on + the frequency position changes. +
    3. +
    4. If |watchTasks| [=list/contain|contains=] |watchId|, then: +
        +
      1. [=Request position=] passing |successCallback|, + |errorCallback|, |options|, |repeats|, and |watchId|. +
      2. +
  • @@ -800,7 +802,8 @@

    {{GeolocationPositionError}} instance whose {{GeolocationPositionError/code}} attribute is initialized to |code|. -
  • [=Invoke=] |callback| with |error|. +
  • [=Queue a microtask=] with step that [=invokes=] |callback| with + |error|.
  • From bc89d4e7fc9777fbdfd55369b98cc9034e77f63b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20C=C3=A1ceres?= Date: Wed, 9 Jun 2021 16:13:24 +1000 Subject: [PATCH 2/9] return watchID at end of algo --- index.html | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/index.html b/index.html index 027c722..c6eee0e 100644 --- a/index.html +++ b/index.html @@ -35,14 +35,6 @@ caniuse: "geolocation", testSuiteURI: "https://wpt.live/geolocation-API/", // implementationReportURI: "https://wpt.fyi/geolocation-API", - localBiblio: { - WGS84: { - title: - "National Imagery and Mapping Agency Technical Report 8350.2, Third Edition", - publisher: "National Imagery and Mapping Agency", - date: "3 January 2000", - }, - }, xref: "web-platform", }; @@ -602,8 +594,6 @@

  • [=Set/Append=] |watchId| to |watchTasks|.
  • -
  • Return |watchId|. -
  • Run these steps [=in parallel=]:
    1. Do security check. @@ -760,6 +750,8 @@

  • +
  • Return |watchId|. +
  • From 0c15f00cff2a4871cdbdfe8d3279ec98382da3b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20C=C3=A1ceres?= Date: Wed, 9 Jun 2021 16:17:35 +1000 Subject: [PATCH 3/9] add WGS84 back in --- index.html | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/index.html b/index.html index c6eee0e..4f57bb4 100644 --- a/index.html +++ b/index.html @@ -35,6 +35,14 @@ caniuse: "geolocation", testSuiteURI: "https://wpt.live/geolocation-API/", // implementationReportURI: "https://wpt.fyi/geolocation-API", + localBiblio: { + WGS84: { + title: + "National Imagery and Mapping Agency Technical Report 8350.2, Third Edition", + publisher: "National Imagery and Mapping Agency", + date: "3 January 2000", + }, + }, xref: "web-platform", }; From 4c5a57f37d44c1a9f49999f03b6bfc5f89281d79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20C=C3=A1ceres?= Date: Thu, 10 Jun 2021 14:49:28 +1000 Subject: [PATCH 4/9] Update index.html Co-authored-by: Reilly Grant --- index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.html b/index.html index 4f57bb4..85b88e8 100644 --- a/index.html +++ b/index.html @@ -802,7 +802,7 @@

    {{GeolocationPositionError}} instance whose {{GeolocationPositionError/code}} attribute is initialized to |code|. -
  • [=Queue a microtask=] with step that [=invokes=] |callback| with +
  • [=Queue a microtask=] with a step that [=invokes=] |callback| with |error|.
  • From 6de25d717fcc1527f142f98538211fbdaf0bf87f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20C=C3=A1ceres?= Date: Thu, 10 Jun 2021 14:52:57 +1000 Subject: [PATCH 5/9] Review feedback --- index.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/index.html b/index.html index 85b88e8..b466773 100644 --- a/index.html +++ b/index.html @@ -590,14 +590,14 @@

    |successCallback:PositionCallback|, a {{PositionErrorCallback}}`?` |errorCallback:PositionErrorCallback|, {{PositionOptions}} |options:PositionOptions|, a {{boolean}} |repeats:boolean|, and - optionally (and only if |repeats| is true) a |previous id:long|. + optionally (and only if |repeats| is true) a |previousId:long|.

    1. Let |watchTasks:Set| be [=this=]'s {{Geolocation/[[watchTasks]]}}.
    2. -
    3. If |previous id| was provided, let |watchId:long| be |previous - id|; Otherwise, let |watchId:long| be an [=implementation-defined=] +
    4. If |previousId| was provided, let |watchId:long| be |previousId|; + Otherwise, let |watchId:long| be an [=implementation-defined=] {{long}} that is greater than or equal to zero.
    5. [=Set/Append=] |watchId| to |watchTasks|. From a434443b251f6d95dc2b9079134e1334db4f0e60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20C=C3=A1ceres?= Date: Thu, 10 Jun 2021 22:40:52 +1000 Subject: [PATCH 6/9] Add the 'geolocation task source' --- index.html | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/index.html b/index.html index 23ddf9b..10e910a 100644 --- a/index.html +++ b/index.html @@ -670,8 +670,9 @@

      |cachedPosition|.{{GeolocationPosition/[[isHighAccuracy]]}} equals |options|.{{PositionOptions/enableHighAccuracy}}:
        -
      1. [=Queue a microtask=] with a step that - [=invokes=] |successCallback| with |cachedPosition|. +
      2. [=Queue a task=] on the [=geolocation task + source=] with a step that [=invokes=] + |successCallback| with |cachedPosition|.
      3. Go to determine repetition steps below. @@ -716,8 +717,9 @@

      4. Set [=this=]'s {{Geolocation/[[cachedPosition]]}} to |position|.
      5. -
      6. [=Queue a microtask=] with a step that - [=invokes=] |successCallback| with |position|. +
      7. [=Queue a task=] on the [=geolocation task + source=] with a step that [=invokes=] + |successCallback| with |position|.

    6. @@ -806,8 +808,8 @@

      {{GeolocationPositionError}} instance whose {{GeolocationPositionError/code}} attribute is initialized to |code|. -
    7. [=Queue a microtask=] with a step that [=invokes=] |callback| with - |error|. +
    8. [=Queue a task=] on the [=geolocation task source=] with a step + that [=invokes=] |callback| with |error|.

    @@ -929,6 +931,24 @@

    +
    +

    + Task sources +

    +

    + The following [=task source=] is defined by this specifications. +

    +
    +
    + The geolocation task source +
    +
    + Used by this specification to queue up non-blocking + {{PositionCallback}} and {{PositionErrorCallback}} when performing + [=position requests=]. +
    +
    +

    From 950603c41be7b49aff7450740470f94099765fa6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20C=C3=A1ceres?= Date: Thu, 10 Jun 2021 22:42:51 +1000 Subject: [PATCH 7/9] Fixup alias request position --- index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.html b/index.html index 10e910a..4d819c5 100644 --- a/index.html +++ b/index.html @@ -945,7 +945,7 @@

    Used by this specification to queue up non-blocking {{PositionCallback}} and {{PositionErrorCallback}} when performing - [=position requests=]. + [=request position|position requests=].

    From f9e52d33579c06e4464d9ea62c99a8fefc805cf3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20C=C3=A1ceres?= Date: Tue, 15 Jun 2021 11:39:38 +1000 Subject: [PATCH 8/9] Apply suggestions from code review --- index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.html b/index.html index 4d819c5..3934076 100644 --- a/index.html +++ b/index.html @@ -752,7 +752,7 @@

  • Wait for a significant change of geographic position. What constitutes a significant change of geographic position is left - to the implementation. A user agents MAY impose a rate limit on + to the implementation. User agents MAY impose a rate limit on the frequency position changes.
  • If |watchTasks| [=list/contain|contains=] |watchId|, then: From c65844e327f8a762b8e61dedeecb4ebb97012c25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20C=C3=A1ceres?= Date: Thu, 8 Jul 2021 14:17:37 +1000 Subject: [PATCH 9/9] Use 'queue global task' --- index.html | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/index.html b/index.html index 3934076..0efc4d4 100644 --- a/index.html +++ b/index.html @@ -127,6 +127,9 @@

    has received the following changes:

      +
    • Added the [=geolocation task source=], which handles dispatching + position updates and errors. +
    • [=Request position=] only proceeds when a document is visible, or the document becomes visible.
    • @@ -606,7 +609,10 @@

    • [=Set/Append=] |watchId| to |watchTasks|.
    • -
    • Run these steps [=in parallel=]: +
    • Let |global| be [=this=]'s [=relevant global object=]. +
    • +
    • [=Queue a global task=] using the [=geolocation task source=] + with |global| to run the following steps [=in parallel=]:
      1. Do security check.