mirror of
https://github.com/dart-lang/sdk
synced 2024-11-02 06:20:13 +00:00
[dart:html] Fix Geoposition bindings and callbacks
Closes https://github.com/dart-lang/sdk/issues/45562 Closes https://github.com/dart-lang/sdk/issues/44324 Geoposition should be bound to GeolocationPosition as well since Position is deprecated since Chrome 79. Similarly, success callbacks used in the Geolocation API can accept a Firefox-specific implementation, so the callback should accept a dynamic instead. Doing this requires adding annotations to the APIs so liveness of Geolocation types is maintained. Change-Id: Id38f68d10c9cdcb7d711ef83a70df87b30be405d Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/194325 Reviewed-by: Mayank Patke <fishythefish@google.com> Reviewed-by: Stephen Adams <sra@google.com> Commit-Queue: Srujan Gaddam <srujzs@google.com>
This commit is contained in:
parent
68d133d949
commit
7abaa95492
5 changed files with 50 additions and 5 deletions
|
@ -16953,6 +16953,8 @@ class Geolocation extends Interceptor {
|
|||
@JSName('clearWatch')
|
||||
void _clearWatch(int watchID) native;
|
||||
|
||||
@Creates('Geoposition')
|
||||
@Creates('PositionError')
|
||||
void _getCurrentPosition(_PositionCallback successCallback,
|
||||
[_PositionErrorCallback? errorCallback, Map? options]) {
|
||||
if (options != null) {
|
||||
|
@ -16972,14 +16974,22 @@ class Geolocation extends Interceptor {
|
|||
}
|
||||
|
||||
@JSName('getCurrentPosition')
|
||||
@Creates('Geoposition')
|
||||
@Creates('PositionError')
|
||||
void _getCurrentPosition_1(
|
||||
successCallback, _PositionErrorCallback? errorCallback, options) native;
|
||||
@JSName('getCurrentPosition')
|
||||
@Creates('Geoposition')
|
||||
@Creates('PositionError')
|
||||
void _getCurrentPosition_2(
|
||||
successCallback, _PositionErrorCallback? errorCallback) native;
|
||||
@JSName('getCurrentPosition')
|
||||
@Creates('Geoposition')
|
||||
@Creates('PositionError')
|
||||
void _getCurrentPosition_3(successCallback) native;
|
||||
|
||||
@Creates('Geoposition')
|
||||
@Creates('PositionError')
|
||||
int _watchPosition(_PositionCallback successCallback,
|
||||
[_PositionErrorCallback? errorCallback, Map? options]) {
|
||||
if (options != null) {
|
||||
|
@ -16996,12 +17006,18 @@ class Geolocation extends Interceptor {
|
|||
}
|
||||
|
||||
@JSName('watchPosition')
|
||||
@Creates('Geoposition')
|
||||
@Creates('PositionError')
|
||||
int _watchPosition_1(
|
||||
successCallback, _PositionErrorCallback? errorCallback, options) native;
|
||||
@JSName('watchPosition')
|
||||
@Creates('Geoposition')
|
||||
@Creates('PositionError')
|
||||
int _watchPosition_2(successCallback, _PositionErrorCallback? errorCallback)
|
||||
native;
|
||||
@JSName('watchPosition')
|
||||
@Creates('Geoposition')
|
||||
@Creates('PositionError')
|
||||
int _watchPosition_3(successCallback) native;
|
||||
}
|
||||
|
||||
|
@ -17021,7 +17037,7 @@ class _GeopositionWrapper implements Geoposition {
|
|||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
@Native("Position")
|
||||
@Native("Position,GeolocationPosition")
|
||||
class Geoposition extends Interceptor {
|
||||
// To suppress missing implicit constructor warnings.
|
||||
factory Geoposition._() {
|
||||
|
@ -25723,13 +25739,13 @@ class PopStateEvent extends Event {
|
|||
// WARNING: Do not edit - generated code.
|
||||
|
||||
@Unstable()
|
||||
typedef void _PositionCallback(Geoposition position);
|
||||
typedef void _PositionCallback(position);
|
||||
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
@Unstable()
|
||||
@Native("PositionError")
|
||||
@Native("PositionError,GeolocationPositionError")
|
||||
class PositionError extends Interceptor {
|
||||
// To suppress missing implicit constructor warnings.
|
||||
factory PositionError._() {
|
||||
|
|
|
@ -8567,6 +8567,17 @@
|
|||
},
|
||||
"support_level": "stable"
|
||||
},
|
||||
"GeolocationPosition": {
|
||||
"members": {
|
||||
"coords": {
|
||||
"support_level": "untriaged"
|
||||
},
|
||||
"timestamp": {
|
||||
"support_level": "untriaged"
|
||||
}
|
||||
},
|
||||
"support_level": "untriaged"
|
||||
},
|
||||
"Geoposition": {
|
||||
"comment": "http://dev.w3.org/geo/api/spec-source.html#position",
|
||||
"dart_action": "unstable",
|
||||
|
|
|
@ -386,7 +386,7 @@ interface ImageBitmapFactories {};
|
|||
interface ImageData {
|
||||
[DartSuppress] ImageDataColorSettings getColorSettings();
|
||||
// Below needs 'any' because ImageDataArray is union of (Uint8ClampedArray
|
||||
// or Uint16Array or Float32Array)
|
||||
// or Uint16Array or Float32Array)
|
||||
[DartSuppress] readonly attribute any dataUnion;
|
||||
};
|
||||
|
||||
|
@ -648,3 +648,7 @@ interface NoncedElement {
|
|||
[DartSuppress, CEReactions] attribute DOMString nonce;
|
||||
[CEReactions] attribute DOMString? nonce;
|
||||
};
|
||||
|
||||
// PositionCallback can be used on a deprecated Position object,
|
||||
// a GeolocationPosition object, or a Firefox-specific object.
|
||||
callback PositionCallback = void(object position);
|
||||
|
|
|
@ -171,6 +171,16 @@ _dart2js_annotations = monitored.Dict(
|
|||
"@Creates('JSExtendableArray|GamepadButton')",
|
||||
"@Returns('JSExtendableArray')",
|
||||
],
|
||||
# Creates a GeolocationPosition or a GeolocationPositionError for a
|
||||
# callback. See issue #45562.
|
||||
'Geolocation.getCurrentPosition': [
|
||||
"@Creates('Geoposition')",
|
||||
"@Creates('PositionError')",
|
||||
],
|
||||
'Geolocation.watchPosition': [
|
||||
"@Creates('Geoposition')",
|
||||
"@Creates('PositionError')",
|
||||
],
|
||||
'HTMLCanvasElement.getContext': [
|
||||
"@Creates('CanvasRenderingContext2D|RenderingContext|RenderingContext2')",
|
||||
"@Returns('CanvasRenderingContext2D|RenderingContext|RenderingContext2|Null')",
|
||||
|
|
|
@ -292,7 +292,7 @@ _dart2js_dom_custom_native_specs = monitored.Dict(
|
|||
'ApplicationCache':
|
||||
'ApplicationCache,DOMApplicationCache,OfflineResourceList',
|
||||
'Event':
|
||||
'Event,InputEvent,SubmitEvent', # Workaround for issue 40901.
|
||||
'Event,InputEvent,SubmitEvent', # Workaround for issue 40901.
|
||||
'HTMLTableCellElement':
|
||||
'HTMLTableCellElement,HTMLTableDataCellElement,HTMLTableHeaderCellElement',
|
||||
'GainNode':
|
||||
|
@ -311,6 +311,10 @@ _dart2js_dom_custom_native_specs = monitored.Dict(
|
|||
'OscillatorNode,Oscillator',
|
||||
'PannerNode':
|
||||
'PannerNode,AudioPannerNode,webkitAudioPannerNode',
|
||||
'Position':
|
||||
'Position,GeolocationPosition',
|
||||
'PositionError':
|
||||
'PositionError,GeolocationPositionError',
|
||||
'RTCPeerConnection':
|
||||
'RTCPeerConnection,webkitRTCPeerConnection,mozRTCPeerConnection',
|
||||
'RTCIceCandidate':
|
||||
|
|
Loading…
Reference in a new issue