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