Add "geolocation task queue" (#87) · w3c/geolocation@41d7945 (original) (raw)
`@@ -118,6 +118,9 @@
`
118
118
` has received the following changes:
`
119
119
`
`
120
120
`
- Added the [=geolocation task source=], which handles dispatching
`
``
122
`+
position updates and errors.
`
``
123
`+
- [=Request position=] only proceeds when a document is visible, or
- Let |watchTasks:Set| be [=this=]'s
- Acquire a watch id.
`
595
``
`-
- If |previous id| was provided, let |watchId:long| be
`
597
``
`-
|previous id|; Otherwise, let |watchId:long| be an
`
598
``
`-
[=implementation-defined=] {{long}} that is greater than or equal
`
599
``
`-
to zero.
`
600
``
`-
- [=Set/Append=] |watchId| to |watchTasks|.
`
602
``
`-
- Return |watchId| and continue [=in parallel=].
`
604
``
`-
`
596
``
`-
`
601
``
`-
`
603
``
`-
`
605
``
`-
`
``
597
`+
- If |previous id| was provided, let |watchId:long| be
- If |previousId| was provided, let |watchId:long| be |previousId|;
`
``
598
`+
Otherwise, let |watchId:long| be an [=implementation-defined=]
`
``
599
`+
{{long}} that is greater than or equal to zero.
`
606
600
`
- Do security check.
`
608
``
`-
- If the environment settings object is a
`
610
``
`-
non-secure context, then:
`
611
``
`-
- [=Call back with error=] |errorCallback| and
`
613
``
`-
{{GeolocationPositionError/PERMISSION_DENIED}}.
`
614
``
`-
- [=List/Remove=] |watchId| from |watchTasks|.
`
616
``
`-
- Terminate this algorithm.
`
618
``
`-
`
612
``
`-
`
615
``
`-
`
617
``
`-
`
619
``
`-
`
620
``
`-
- [=Call back with error=] |errorCallback| and
`
609
``
`-
`
621
``
`-
`
``
601
`+
- If the environment settings object is a
- [=Set/Append=] |watchId| to |watchTasks|.
`
622
602
`
- Wait for document to become
`
624
``
`-
visible.
`
625
``
`-
- Let |document:Document| be the [=current settings object=]'s
`
627
``
`-
[=associated Document=].
`
628
``
`-
- If |document:Document| is [=Document/hidden=], wait for the
`
630
``
`-
|document| to become [=Document/visible=].
`
631
``
`-
`
626
``
`-
`
629
``
`-
`
632
``
`-
`
``
603
`+
- Let |document:Document| be the [=current settings object=]'s
- Let |global| be [=this=]'s [=relevant global object=].
`
633
604
`
- `
635
``
`-
"getCurrentPosition_permission_allow.https.html, getCurrentPosition_permission_deny.https.html">
`
636
``
`-
[=Check permission=] passing |errorCallback|. If the check return
`
637
``
`-
failure:
`
``
605
`+
- [=Queue a global task=] using the [=geolocation task source=]
`
``
606
`+
with |global| to run the following steps [=in parallel=]:
`
638
607
`
- [=List/Remove=] |watchId| from |watchTasks|.
`
640
``
`-
- Terminate this algorithm.
`
642
``
`-
`
639
``
`-
`
641
``
`-
`
643
``
`-
`
644
``
`-
- [=List/Remove=] |watchId| from |watchTasks|.
-
`
646
``
`-
<dfn data-local-lt=
`
647
``
`-
"acquiring a position|acquire a position">Acquire position.
`
648
``
`-
- Let |acquisitionTime:DOMTimeStamp| be a new {{DOMTimeStamp}}
`
650
``
`-
that represents now in milliseconds, using 01 January, 1970 UTC
`
651
``
`-
as the epoch.
`
652
``
`-
- If |options|.{{PositionOptions/maximumAge}} is greater than
`
654
``
`-
0, and |cachedPosition| is not null:
`
``
608
`+
- Do security check.
`
655
609
`
- Let |cachedPosition:GeolocationPosition| be [=this=]'s
`
657
``
`-
{{Geolocation/[[cachedPosition]]}}.
`
658
``
`-
- Let |cacheTime:long| be |acquisitionTime| minus the value
`
660
``
`-
of |options|.{{PositionOptions/maximumAge}} member.
`
661
``
`-
- If |cachedPosition|'s {{GeolocationPosition/timestamp}}'s
`
663
``
`-
value is greater than |cacheTime|, and
`
664
``
`-
|cachedPosition|.{{GeolocationPosition/[[isHighAccuracy]]}}
`
665
``
`-
equals |options|.{{PositionOptions/enableHighAccuracy}}:
`
``
610
`+
- If the environment settings object is a
`
``
611
`+
non-secure context, then:
`
666
612
`
- [=Queue a microtask=] to invoke |successCallback|
`
668
``
`-
with |cachedPosition|.
`
``
613
`+
- [=Call back with error=] |errorCallback| and
`
``
614
`+
{{GeolocationPositionError/PERMISSION_DENIED}}.
`
669
615
`
- Go to determine
`
671
``
`-
repetition
steps below.`
``
616
`+
- [=List/Remove=] |watchId| from |watchTasks|.
`
``
617
`+
- Terminate this algorithm.
`
672
619
`
`
667
``
`-
`
670
``
`-
`
``
618
`+
`
673
620
`
`
674
621
`
- [=Queue a microtask=] to invoke |successCallback|
`
656
``
`-
`
659
``
`-
`
662
``
`-
`
675
622
`
`
676
623
`
- Let |cachedPosition:GeolocationPosition| be [=this=]'s
- Let |timeout:Task| be a new timed [=task=] that runs in
`
678
``
`-
|options|.{{PositionOptions/timeout}} milliseconds after
`
679
``
`-
|acquisitionTime|, which performs the following sub-steps:
`
680
``
`-
`
``
624
`+
- Wait for document to become
`
``
625
`+
visible.
`
686
626
`
- If the entry for |timerId| in the [=list of active
`
688
``
`-
timers=] has been cleared, then abort these steps.
`
``
627
`+
- Let |document:Document| be the [=current settings
`
``
628
`+
object=]'s [=associated Document=].
`
689
629
`
- [=Call back with error=] with |errorCallback| and
`
691
``
`-
{{GeolocationPositionError/TIMEOUT}}.
`
``
630
`+
- If |document:Document| is [=Document/hidden=], wait for
`
``
631
`+
the |document| to become [=Document/visible=].
`
692
632
`
`
687
``
`-
`
690
``
`-
`
693
633
`
`
694
634
`
- If the entry for |timerId| in the [=list of active
- Let |timerId:long| be an [=implementation-defined=]
`
696
``
`-
identifier that represents |timeout|.
`
697
``
`-
- Add |timerId| to the [=list of active timers=].
`
``
635
`+
- `
``
636
`+
"getCurrentPosition_permission_allow.https.html, getCurrentPosition_permission_deny.https.html">
`
``
637
`+
[=Check permission=] passing |errorCallback|. If the check
`
``
638
`+
returns failure:
`
``
639
`+
- [=List/Remove=] |watchId| from |watchTasks|.
`
``
641
`+
- Terminate this algorithm.
`
``
643
`+
`
``
640
`+
`
``
642
`+
`
``
644
`+
`
699
645
`
- [=List/Remove=] |watchId| from |watchTasks|.
- Try to acquire the device's position, optionally taking into
`
701
``
`-
consideration the value of
`
702
``
`-
|options|.{{PositionOptions/enableHighAccuracy}}:
`
``
646
`+
-
`
``
647
`+
<dfn data-local-lt=
`
``
648
`+
"acquiring a position|acquire a position">Acquire
`
``
649
`+
position.
`
703
650
`
- If acquiring a position succeeds:
`
``
651
`+
- Let |acquisitionTime:DOMTimeStamp| be a new
`
``
652
`+
{{DOMTimeStamp}} that represents now in milliseconds, using
`
``
653
`+
01 January, 1970 UTC as the epoch.
`
``
654
`+
- If |options|.{{PositionOptions/maximumAge}} is greater
`
``
656
`+
than 0, and |cachedPosition| is not null:
`
705
657
`
- Let |position:GeolocationPosition| be [=a new
`
707
``
`` -
GeolocationPosition
=] passing |acquisitionTime| and``
708
``
`-
|options|.{{PositionOptions/enableHighAccuracy}}.
`
``
658
`+
- Let |cachedPosition:GeolocationPosition| be
`
``
659
`+
[=this=]'s {{Geolocation/[[cachedPosition]]}}.
`
709
660
`
- Set [=this=]'s {{Geolocation/[[cachedPosition]]}} to
`
711
``
`-
|position|.
`
``
661
`+
- Let |cacheTime:long| be |acquisitionTime| minus the
`
``
662
`+
value of |options|.{{PositionOptions/maximumAge}} member.
`
712
663
`
- [=Queue a microtask=] to [=invoke=] |successCallback|
`
714
``
`-
with |position|.
`
``
664
`+
- If |cachedPosition|'s
`
``
665
`+
{{GeolocationPosition/timestamp}}'s value is greater than
`
``
666
`+
|cacheTime|, and
`
``
667
`+
|cachedPosition|.{{GeolocationPosition/[[isHighAccuracy]]}}
`
``
668
`+
equals |options|.{{PositionOptions/enableHighAccuracy}}:
`
``
669
`+
- [=Queue a task=] on the [=geolocation task
`
``
671
`+
source=] with a step that [=invokes=]
`
``
672
`+
|successCallback| with |cachedPosition|.
`
``
673
`+
- Go to determine
`
``
675
`+
repetition
steps below.`
``
676
`+
`
``
670
`+
`
``
674
`+
`
``
677
`+
`
715
678
`
- [=Queue a task=] on the [=geolocation task
`
706
``
`-
`
710
``
`-
`
713
``
`-
`
716
679
`
`
717
680
`
- Let |position:GeolocationPosition| be [=a new
- If acquiring a position fails:
`
``
681
`+
- Let |timeout:Task| be a new timed [=task=] that runs in
`
``
682
`+
|options|.{{PositionOptions/timeout}} milliseconds after
`
``
683
`+
|acquisitionTime|, which performs the following sub-steps:
`
``
684
`+
`
719
690
`
- [=Call back with error=] passing |errorCallback| and
`
721
``
`-
{{GeolocationPositionError/POSITION_UNAVAILABLE}}.
`
``
691
`+
- If the entry for |timerId| in the [=list of active
`
``
692
`+
timers=] has been cleared, then abort these steps.
`
``
693
`+
- [=Call back with error=] with |errorCallback| and
`
``
695
`+
{{GeolocationPositionError/TIMEOUT}}.
`
722
696
`
`
720
``
`-
`
``
694
`+
`
723
697
`
`
724
698
`
- [=Call back with error=] passing |errorCallback| and
- Let |timerId:long| be an [=implementation-defined=]
`
``
700
`+
identifier that represents |timeout|.
`
``
701
`+
- Add |timerId| to the [=list of active timers=].
`
``
703
`+
- Try to acquire the device's position, optionally taking
`
``
705
`+
into consideration the value of
`
``
706
`+
|options|.{{PositionOptions/enableHighAccuracy}}:
`
``
707
`+
- If acquiring a position succeeds:
`
``
709
`+
- Let |position:GeolocationPosition| be [=a new
`
``
711
`` +
GeolocationPosition
=] passing |acquisitionTime| and``
``
712
`+
|options|.{{PositionOptions/enableHighAccuracy}}.
`
``
713
`+
- Set [=this=]'s {{Geolocation/[[cachedPosition]]}}
`
``
715
`+
to |position|.
`
``
716
`+
- [=Queue a task=] on the [=geolocation task
`
``
718
`+
source=] with a step that [=invokes=]
`
``
719
`+
|successCallback| with |position|.
`
``
720
`+
`
``
710
`+
`
``
714
`+
`
``
717
`+
`
``
721
`+
`
``
722
`+
- Let |position:GeolocationPosition| be [=a new
- If acquiring a position fails:
`
``
724
`+
- [=Call back with error=] passing |errorCallback|
`
``
726
`+
and
`
``
727
`+
{{GeolocationPositionError/POSITION_UNAVAILABLE}}.
`
``
728
`+
`
``
725
`+
`
``
729
`+
`
``
730
`+
- [=Call back with error=] passing |errorCallback|
`
``
708
`+
`
``
723
`+
`
``
731
`+
`
``
732
`+
- If acquiring a position succeeds:
- Clear |timerId| from the [=list of active timers=].
`
``
734
`+
`
704
``
`-
`
``
655
`+
`
718
``
`-
`
``
699
`+
`
``
702
`+
`
``
704
`+
`
``
733
`+
`
725
735
`
`
726
736
`
- If acquiring a position succeeds:
- Clear |timerId| from the [=list of active timers=].
`
728
``
`-
`
649
``
`-
`
653
``
`-
`
677
``
`-
`
695
``
`-
`
698
``
`-
`
700
``
`-
`
727
``
`-
`
729
``
`-
`
730
``
`-
- Let |acquisitionTime:DOMTimeStamp| be a new {{DOMTimeStamp}}
-
`
732
``
`-
Determine repetition.
`
733
``
`-
- If |repeats| is false:
`
``
737
`+
-
`
``
738
`+
Determine repetition.
`
735
739
`
- [=List/Remove=] |watchId| from |watchTasks|.
`
``
740
`+
- If |repeats| is false:
`
``
741
`+
- [=List/Remove=] |watchId| from |watchTasks|.
`
``
743
`+
- Terminate this algorithm.
`
``
745
`+
`
``
742
`+
`
``
744
`+
`
``
746
`+
`
737
747
`
- [=List/Remove=] |watchId| from |watchTasks|.
- Terminate this algorithm.
`
``
748
`+
`
736
``
`-
`
738
``
`-
`
``
749
`+
- [=List/Remove=] |watchId| from |watchTasks|.
- Wait for a significant change of geographic position. What
`
``
751
`+
constitutes a significant change of geographic position is left
`
``
752
`+
to the implementation. User agents MAY impose a rate limit on
`
``
753
`+
the frequency position changes.
`
``
754
`+
- If |watchTasks| [=list/contain|contains=] |watchId|, then:
`
``
756
`+
- [=Request position=] passing |successCallback|,
`
``
758
`+
|errorCallback|, |options|, |repeats|, and |watchId|.
`
739
759
`
`
``
757
`+
`
740
760
`
`
741
761
`
- [=Request position=] passing |successCallback|,
`
734
``
`-
`
``
750
`+
`
``
755
`+
`
742
762
`
`
743
763
`
- If |repeats| is false:
- Wait for a significant change of geographic position. What
`
745
``
`-
constitutes a significant change of geographic position is
`
746
``
`-
[=implementation-defined|left to the implementation=]. A user agent
`
747
``
`-
MAY impose a rate limit on the frequency of position changes.
`
748
``
`-
- If |watchTasks| [=list/contain|contains=] |watchId|, then:
`
750
``
`-
- [=Request position=] passing |successCallback|,
`
752
``
`-
|errorCallback|, |options|, |repeats|, and |watchId|.
`
753
``
`-
`
751
``
`-
`
754
``
`-
`
``
764
`+
- [=Request position=] passing |successCallback|,
- Return |watchId|.
`
755
765
`
- [=Invoke=] |callback| with |error|.
`
``
808
`+
- [=Queue a task=] on the [=geolocation task source=] with a step
`
``
809
`+
that [=invokes=] |callback| with |error|.
`
799
810
`
-
`
``
940
`+
The geolocation task source
`
``
941
`+
-
`
``
943
`+
Used by this specification to queue up non-blocking
`
``
944
`+
{{PositionCallback}} and {{PositionErrorCallback}} when performing
`
``
945
`+
[=request position|position requests=].
`
``
946
`+
`
``
121
`+
`
121
124
`
`
122
125
` the document becomes visible.
`
123
126
`
`
`@@ -585,173 +588,180 @@
`
585
588
`` |successCallback:PositionCallback|, a {{PositionErrorCallback}}?
``
586
589
` |errorCallback:PositionErrorCallback|, {{PositionOptions}}
`
587
590
` |options:PositionOptions|, a {{boolean}} |repeats:boolean|, and
`
588
``
`-
optionally (and only if |repeats| is true) a |previous id:long|.
`
``
591
`+
optionally (and only if |repeats| is true) a |previousId:long|.
`
589
592
`
`
590
593
`
`
591
594
`
`
592
595
` {{Geolocation/[[watchTasks]]}}.
`
593
596
`
`
594
``
`-
`
607
``
`-
`
623
``
`-
`
634
``
`-
`
645
``
`-
`
731
``
`-
`
744
``
`-
`
749
``
`-
`
756
766
`
`
757
767
`
`
795
805
` {{GeolocationPositionError}} instance whose
`
796
806
` {{GeolocationPositionError/code}} attribute is initialized to |code|.
`
797
807
`
`
798
``
`-
`
800
811
`
`
801
812
`
`
`@@ -917,6 +928,24 @@
`
917
928
`
`
918
929
`
`
919
930
`
`
``
931
`+
`
``
932
`+
`
``
933
`+
Task sources
`
``
934
`+
`
``
935
`+
`
``
936
`+
The following [=task source=] is defined by this specifications.
`
``
937
`+
`
``
938
`+
`
``
939
`+
`
``
942
`+
`
``
947
`+
`
``
948
`+
`
920
949
`
`
921
950
`
`
922
951
`
`