| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 part of $LIBRARYNAME; | 5 part of $LIBRARYNAME; |
| 6 | 6 |
| 7 @DocsEditable() | 7 @DocsEditable() |
| 8 $(ANNOTATIONS)$(NATIVESPEC)$(CLASS_MODIFIERS)class $CLASSNAME$EXTENDS$IMPLEMENTS
{ | 8 $(ANNOTATIONS)$(NATIVESPEC)$(CLASS_MODIFIERS)class $CLASSNAME$EXTENDS$IMPLEMENTS
{ |
| 9 | 9 |
| 10 @DomName('Geolocation.getCurrentPosition') | 10 @DomName('Geolocation.getCurrentPosition') |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 }, | 70 }, |
| 71 onCancel: () { | 71 onCancel: () { |
| 72 assert(watchId != null); | 72 assert(watchId != null); |
| 73 _clearWatch(watchId); | 73 _clearWatch(watchId); |
| 74 }); | 74 }); |
| 75 | 75 |
| 76 return controller.stream; | 76 return controller.stream; |
| 77 } | 77 } |
| 78 | 78 |
| 79 Geoposition _ensurePosition(domPosition) { | 79 Geoposition _ensurePosition(domPosition) { |
| 80 $if DART2JS | |
| 81 try { | 80 try { |
| 82 // Firefox may throw on this. | 81 // Firefox may throw on this. |
| 83 if (domPosition is Geoposition) { | 82 if (domPosition is Geoposition) { |
| 84 return domPosition; | 83 return domPosition; |
| 85 } | 84 } |
| 86 } catch(e) {} | 85 } catch(e) {} |
| 87 return new _GeopositionWrapper(domPosition); | 86 return new _GeopositionWrapper(domPosition); |
| 88 $else | |
| 89 return domPosition; | |
| 90 $endif | |
| 91 } | 87 } |
| 92 | 88 |
| 93 $!MEMBERS} | 89 $!MEMBERS} |
| 94 | 90 |
| 95 $if DART2JS | |
| 96 /** | 91 /** |
| 97 * Wrapper for Firefox- it returns an object which we cannot map correctly. | 92 * Wrapper for Firefox- it returns an object which we cannot map correctly. |
| 98 * Basically Firefox was returning a [xpconnect wrapped nsIDOMGeoPosition] but | 93 * Basically Firefox was returning a [xpconnect wrapped nsIDOMGeoPosition] but |
| 99 * which has further oddities. | 94 * which has further oddities. |
| 100 */ | 95 */ |
| 101 class _GeopositionWrapper implements Geoposition { | 96 class _GeopositionWrapper implements Geoposition { |
| 102 var _ptr; | 97 var _ptr; |
| 103 _GeopositionWrapper(this._ptr); | 98 _GeopositionWrapper(this._ptr); |
| 104 | 99 |
| 105 Coordinates get coords => JS('Coordinates', '#.coords', _ptr); | 100 Coordinates get coords => JS('Coordinates', '#.coords', _ptr); |
| 106 int get timestamp => JS('int', '#.timestamp', _ptr); | 101 int get timestamp => JS('int', '#.timestamp', _ptr); |
| 107 } | 102 } |
| 108 $endif | |
| OLD | NEW |