OLD | NEW |
1 /// The Dart HTML library. | 1 /// The Dart HTML library. |
2 library dart.dom.html; | 2 library dart.dom.html; |
3 | 3 |
4 import 'dart:async'; | 4 import 'dart:async'; |
5 import 'dart:collection'; | 5 import 'dart:collection'; |
6 import 'dart:_collection-dev' hide Symbol; | 6 import 'dart:_collection-dev' hide Symbol; |
7 import 'dart:html_common'; | 7 import 'dart:html_common'; |
8 import 'dart:indexed_db'; | 8 import 'dart:indexed_db'; |
9 import 'dart:isolate'; | 9 import 'dart:isolate'; |
10 import 'dart:json' as json; | 10 import 'dart:json' as json; |
(...skipping 5943 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5954 } | 5954 } |
5955 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 5955 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
5956 // for details. All rights reserved. Use of this source code is governed by a | 5956 // for details. All rights reserved. Use of this source code is governed by a |
5957 // BSD-style license that can be found in the LICENSE file. | 5957 // BSD-style license that can be found in the LICENSE file. |
5958 | 5958 |
5959 | 5959 |
5960 @DomName('DirectoryEntry') | 5960 @DomName('DirectoryEntry') |
5961 // http://www.w3.org/TR/file-system-api/#the-directoryentry-interface | 5961 // http://www.w3.org/TR/file-system-api/#the-directoryentry-interface |
5962 @Experimental | 5962 @Experimental |
5963 class DirectoryEntry extends Entry native "DirectoryEntry" { | 5963 class DirectoryEntry extends Entry native "DirectoryEntry" { |
5964 | 5964 |
5965 /** | 5965 /** |
5966 * Create a new directory with the specified `path`. If `exclusive` is true, | 5966 * Create a new directory with the specified `path`. If `exclusive` is true, |
5967 * the returned Future will complete with an error if a directory already | 5967 * the returned Future will complete with an error if a directory already |
5968 * exists with the specified `path`. | 5968 * exists with the specified `path`. |
5969 */ | 5969 */ |
5970 Future<Entry> createDirectory(String path, {bool exclusive: false}) { | 5970 Future<Entry> createDirectory(String path, {bool exclusive: false}) { |
5971 return _getDirectory(path, options: | 5971 return _getDirectory(path, options: |
5972 {'create': true, 'exclusive': exclusive}); | 5972 {'create': true, 'exclusive': exclusive}); |
5973 } | 5973 } |
5974 | 5974 |
5975 /** | 5975 /** |
5976 * Retrieve an already existing directory entry. The returned future will | 5976 * Retrieve an already existing directory entry. The returned future will |
5977 * result in an error if a directory at `path` does not exist or if the item | 5977 * result in an error if a directory at `path` does not exist or if the item |
5978 * at `path` is not a directory. | 5978 * at `path` is not a directory. |
5979 */ | 5979 */ |
5980 Future<Entry> getDirectory(String path) { | 5980 Future<Entry> getDirectory(String path) { |
5981 return _getDirectory(path); | 5981 return _getDirectory(path); |
5982 } | 5982 } |
5983 | 5983 |
5984 /** | 5984 /** |
5985 * Create a new file with the specified `path`. If `exclusive` is true, | 5985 * Create a new file with the specified `path`. If `exclusive` is true, |
5986 * the returned Future will complete with an error if a file already | 5986 * the returned Future will complete with an error if a file already |
5987 * exists at the specified `path`. | 5987 * exists at the specified `path`. |
5988 */ | 5988 */ |
5989 Future<Entry> createFile(String path, {bool exclusive: false}) { | 5989 Future<Entry> createFile(String path, {bool exclusive: false}) { |
5990 return _getFile(path, options: {'create': true, 'exclusive': exclusive}); | 5990 return _getFile(path, options: {'create': true, 'exclusive': exclusive}); |
5991 } | 5991 } |
5992 | 5992 |
5993 /** | 5993 /** |
5994 * Retrieve an already existing file entry. The returned future will | 5994 * Retrieve an already existing file entry. The returned future will |
5995 * result in an error if a file at `path` does not exist or if the item at | 5995 * result in an error if a file at `path` does not exist or if the item at |
5996 * `path` is not a file. | 5996 * `path` is not a file. |
5997 */ | 5997 */ |
5998 Future<Entry> getFile(String path) { | 5998 Future<Entry> getFile(String path) { |
5999 return _getFile(path); | 5999 return _getFile(path); |
6000 } | 6000 } |
6001 | 6001 |
6002 @DomName('DirectoryEntry.createReader') | 6002 @DomName('DirectoryEntry.createReader') |
(...skipping 4620 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10623 } | 10623 } |
10624 if (timeout != null) { | 10624 if (timeout != null) { |
10625 options['timeout'] = timeout.inMilliseconds; | 10625 options['timeout'] = timeout.inMilliseconds; |
10626 } | 10626 } |
10627 if (maximumAge != null) { | 10627 if (maximumAge != null) { |
10628 options['maximumAge'] = maximumAge.inMilliseconds; | 10628 options['maximumAge'] = maximumAge.inMilliseconds; |
10629 } | 10629 } |
10630 | 10630 |
10631 int watchId; | 10631 int watchId; |
10632 var controller; | 10632 var controller; |
10633 controller = new StreamController<Geoposition>( | 10633 controller = new StreamController<Geoposition>(sync: true, |
10634 onListen: () { | 10634 onListen: () { |
10635 assert(watchId == null); | 10635 assert(watchId == null); |
10636 watchId = $dom_watchPosition( | 10636 watchId = $dom_watchPosition( |
10637 (position) { | 10637 (position) { |
10638 controller.add(_ensurePosition(position)); | 10638 controller.add(_ensurePosition(position)); |
10639 }, | 10639 }, |
10640 (error) { | 10640 (error) { |
10641 controller.addError(error); | 10641 controller.addError(error); |
10642 }, | 10642 }, |
10643 options); | 10643 options); |
(...skipping 4733 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15377 * | 15377 * |
15378 * Simple example usage: | 15378 * Simple example usage: |
15379 * | 15379 * |
15380 * window.navigator.getUserMedia(audio: true, video: true).then((stream) { | 15380 * window.navigator.getUserMedia(audio: true, video: true).then((stream) { |
15381 * var video = new VideoElement() | 15381 * var video = new VideoElement() |
15382 * ..autoplay = true | 15382 * ..autoplay = true |
15383 * ..src = Url.createObjectUrl(stream); | 15383 * ..src = Url.createObjectUrl(stream); |
15384 * document.body.append(video); | 15384 * document.body.append(video); |
15385 * }); | 15385 * }); |
15386 * | 15386 * |
15387 * The user can also pass in Maps to the audio or video parameters to specify | 15387 * The user can also pass in Maps to the audio or video parameters to specify |
15388 * mandatory and optional constraints for the media stream. Not passing in a | 15388 * mandatory and optional constraints for the media stream. Not passing in a |
15389 * map, but passing in `true` will provide a MediaStream with audio or | 15389 * map, but passing in `true` will provide a MediaStream with audio or |
15390 * video capabilities, but without any additional constraints. The particular | 15390 * video capabilities, but without any additional constraints. The particular |
15391 * constraint names for audio and video are still in flux, but as of this | 15391 * constraint names for audio and video are still in flux, but as of this |
15392 * writing, here is an example providing more constraints. | 15392 * writing, here is an example providing more constraints. |
15393 * | 15393 * |
15394 * window.navigator.getUserMedia( | 15394 * window.navigator.getUserMedia( |
15395 * audio: true, | 15395 * audio: true, |
15396 * video: {'mandatory': | 15396 * video: {'mandatory': |
15397 * { 'minAspectRatio': 1.333, 'maxAspectRatio': 1.334 }, | 15397 * { 'minAspectRatio': 1.333, 'maxAspectRatio': 1.334 }, |
15398 * 'optional': | 15398 * 'optional': |
15399 * [{ 'minFrameRate': 60 }, | 15399 * [{ 'minFrameRate': 60 }, |
15400 * { 'maxWidth': 640 }] | 15400 * { 'maxWidth': 640 }] |
15401 * }); | 15401 * }); |
15402 * | 15402 * |
15403 * See also: | 15403 * See also: |
15404 * * [MediaStream.supported] | 15404 * * [MediaStream.supported] |
15405 */ | 15405 */ |
15406 @DomName('Navigator.webkitGetUserMedia') | 15406 @DomName('Navigator.webkitGetUserMedia') |
15407 @SupportedBrowser(SupportedBrowser.CHROME) | 15407 @SupportedBrowser(SupportedBrowser.CHROME) |
15408 @Experimental | 15408 @Experimental |
(...skipping 826 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
16235 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 16235 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
16236 // for details. All rights reserved. Use of this source code is governed by a | 16236 // for details. All rights reserved. Use of this source code is governed by a |
16237 // BSD-style license that can be found in the LICENSE file. | 16237 // BSD-style license that can be found in the LICENSE file. |
16238 | 16238 |
16239 | 16239 |
16240 @DomName('Notification') | 16240 @DomName('Notification') |
16241 // http://www.w3.org/TR/notifications/#notification | 16241 // http://www.w3.org/TR/notifications/#notification |
16242 @Experimental // experimental | 16242 @Experimental // experimental |
16243 class Notification extends EventTarget native "Notification" { | 16243 class Notification extends EventTarget native "Notification" { |
16244 | 16244 |
16245 factory Notification(String title, {String titleDir: null, String body: null, | 16245 factory Notification(String title, {String titleDir: null, String body: null, |
16246 String bodyDir: null, String tag: null, String iconUrl: null}) { | 16246 String bodyDir: null, String tag: null, String iconUrl: null}) { |
16247 | 16247 |
16248 var parsedOptions = {}; | 16248 var parsedOptions = {}; |
16249 if (titleDir != null) parsedOptions['titleDir'] = titleDir; | 16249 if (titleDir != null) parsedOptions['titleDir'] = titleDir; |
16250 if (body != null) parsedOptions['body'] = body; | 16250 if (body != null) parsedOptions['body'] = body; |
16251 if (bodyDir != null) parsedOptions['bodyDir'] = bodyDir; | 16251 if (bodyDir != null) parsedOptions['bodyDir'] = bodyDir; |
16252 if (tag != null) parsedOptions['tag'] = tag; | 16252 if (tag != null) parsedOptions['tag'] = tag; |
16253 if (iconUrl != null) parsedOptions['iconUrl'] = iconUrl; | 16253 if (iconUrl != null) parsedOptions['iconUrl'] = iconUrl; |
16254 | 16254 |
16255 return Notification._factoryNotification(title, parsedOptions); | 16255 return Notification._factoryNotification(title, parsedOptions); |
(...skipping 1607 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
17863 @DomName('RTCIceCandidate') | 17863 @DomName('RTCIceCandidate') |
17864 @SupportedBrowser(SupportedBrowser.CHROME) | 17864 @SupportedBrowser(SupportedBrowser.CHROME) |
17865 @Experimental | 17865 @Experimental |
17866 // http://dev.w3.org/2011/webrtc/editor/webrtc.html#idl-def-RTCIceCandidate | 17866 // http://dev.w3.org/2011/webrtc/editor/webrtc.html#idl-def-RTCIceCandidate |
17867 class RtcIceCandidate native "RTCIceCandidate,mozRTCIceCandidate" { | 17867 class RtcIceCandidate native "RTCIceCandidate,mozRTCIceCandidate" { |
17868 factory RtcIceCandidate(Map dictionary) { | 17868 factory RtcIceCandidate(Map dictionary) { |
17869 // TODO(efortuna): Remove this check if when you can actually construct with | 17869 // TODO(efortuna): Remove this check if when you can actually construct with |
17870 // the unprefixed RTCIceCandidate in Firefox (currently both are defined, | 17870 // the unprefixed RTCIceCandidate in Firefox (currently both are defined, |
17871 // but one can't be used as a constructor). | 17871 // but one can't be used as a constructor). |
17872 var constructorName = JS('', 'window[#]', | 17872 var constructorName = JS('', 'window[#]', |
17873 Device.isFirefox ? '${Device.propertyPrefix}RTCIceCandidate' : | 17873 Device.isFirefox ? '${Device.propertyPrefix}RTCIceCandidate' : |
17874 'RTCIceCandidate'); | 17874 'RTCIceCandidate'); |
17875 return JS('RtcIceCandidate', 'new #(#)', constructorName, | 17875 return JS('RtcIceCandidate', 'new #(#)', constructorName, |
17876 convertDartToNative_SerializedScriptValue(dictionary)); | 17876 convertDartToNative_SerializedScriptValue(dictionary)); |
17877 } | 17877 } |
17878 | 17878 |
17879 @DomName('RTCIceCandidate.candidate') | 17879 @DomName('RTCIceCandidate.candidate') |
17880 @DocsEditable | 17880 @DocsEditable |
17881 final String candidate; | 17881 final String candidate; |
17882 | 17882 |
17883 @DomName('RTCIceCandidate.sdpMLineIndex') | 17883 @DomName('RTCIceCandidate.sdpMLineIndex') |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
17928 } | 17928 } |
17929 | 17929 |
17930 /** | 17930 /** |
17931 * Checks if Real Time Communication (RTC) APIs are supported and enabled on | 17931 * Checks if Real Time Communication (RTC) APIs are supported and enabled on |
17932 * the current platform. | 17932 * the current platform. |
17933 */ | 17933 */ |
17934 static bool get supported { | 17934 static bool get supported { |
17935 // Currently in Firefox some of the RTC elements are defined but throw an | 17935 // Currently in Firefox some of the RTC elements are defined but throw an |
17936 // error unless the user has specifically enabled them in their | 17936 // error unless the user has specifically enabled them in their |
17937 // about:config. So we have to construct an element to actually test if RTC | 17937 // about:config. So we have to construct an element to actually test if RTC |
17938 // is supported at the given time. | 17938 // is supported at the given time. |
17939 try { | 17939 try { |
17940 new RtcPeerConnection( | 17940 new RtcPeerConnection( |
17941 {"iceServers": [ {"url":"stun:localhost"}]}); | 17941 {"iceServers": [ {"url":"stun:localhost"}]}); |
17942 return true; | 17942 return true; |
17943 } catch (_) { return false;} | 17943 } catch (_) { return false;} |
17944 return false; | 17944 return false; |
17945 } | 17945 } |
17946 Future<RtcSessionDescription> createOffer([Map mediaConstraints]) { | 17946 Future<RtcSessionDescription> createOffer([Map mediaConstraints]) { |
17947 var completer = new Completer<RtcSessionDescription>(); | 17947 var completer = new Completer<RtcSessionDescription>(); |
17948 _createOffer( | 17948 _createOffer( |
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
18231 @DomName('RTCSessionDescription') | 18231 @DomName('RTCSessionDescription') |
18232 @SupportedBrowser(SupportedBrowser.CHROME) | 18232 @SupportedBrowser(SupportedBrowser.CHROME) |
18233 @Experimental | 18233 @Experimental |
18234 // http://dev.w3.org/2011/webrtc/editor/webrtc.html#idl-def-RTCSessionDescriptio
n | 18234 // http://dev.w3.org/2011/webrtc/editor/webrtc.html#idl-def-RTCSessionDescriptio
n |
18235 class RtcSessionDescription native "RTCSessionDescription,mozRTCSessionDescripti
on" { | 18235 class RtcSessionDescription native "RTCSessionDescription,mozRTCSessionDescripti
on" { |
18236 factory RtcSessionDescription(Map dictionary) { | 18236 factory RtcSessionDescription(Map dictionary) { |
18237 // TODO(efortuna): Remove this check if when you can actually construct with | 18237 // TODO(efortuna): Remove this check if when you can actually construct with |
18238 // the unprefixed RTCIceCandidate in Firefox (currently both are defined, | 18238 // the unprefixed RTCIceCandidate in Firefox (currently both are defined, |
18239 // but one can't be used as a constructor). | 18239 // but one can't be used as a constructor). |
18240 var constructorName = JS('', 'window[#]', | 18240 var constructorName = JS('', 'window[#]', |
18241 Device.isFirefox ? '${Device.propertyPrefix}RTCSessionDescription' : | 18241 Device.isFirefox ? '${Device.propertyPrefix}RTCSessionDescription' : |
18242 'RTCSessionDescription'); | 18242 'RTCSessionDescription'); |
18243 return JS('RtcSessionDescription', | 18243 return JS('RtcSessionDescription', |
18244 'new #(#)', constructorName, | 18244 'new #(#)', constructorName, |
18245 convertDartToNative_SerializedScriptValue(dictionary)); | 18245 convertDartToNative_SerializedScriptValue(dictionary)); |
18246 } | 18246 } |
18247 | 18247 |
18248 @DomName('RTCSessionDescription.sdp') | 18248 @DomName('RTCSessionDescription.sdp') |
18249 @DocsEditable | 18249 @DocsEditable |
18250 String sdp; | 18250 String sdp; |
18251 | 18251 |
18252 @DomName('RTCSessionDescription.type') | 18252 @DomName('RTCSessionDescription.type') |
18253 @DocsEditable | 18253 @DocsEditable |
(...skipping 1654 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
19908 var completer = new Completer<int>(); | 19908 var completer = new Completer<int>(); |
19909 _requestQuota(storageType, newQuotaInBytes, | 19909 _requestQuota(storageType, newQuotaInBytes, |
19910 (value) { completer.complete(value); }, | 19910 (value) { completer.complete(value); }, |
19911 (error) { completer.completeError(error); }); | 19911 (error) { completer.completeError(error); }); |
19912 return completer.future; | 19912 return completer.future; |
19913 } | 19913 } |
19914 | 19914 |
19915 Future<StorageInfoUsage> queryUsageAndQuota(int storageType) { | 19915 Future<StorageInfoUsage> queryUsageAndQuota(int storageType) { |
19916 var completer = new Completer<StorageInfoUsage>(); | 19916 var completer = new Completer<StorageInfoUsage>(); |
19917 _queryUsageAndQuota(storageType, | 19917 _queryUsageAndQuota(storageType, |
19918 (currentUsageInBytes, currentQuotaInBytes) { | 19918 (currentUsageInBytes, currentQuotaInBytes) { |
19919 completer.complete(new StorageInfoUsage(currentUsageInBytes, | 19919 completer.complete(new StorageInfoUsage(currentUsageInBytes, |
19920 currentQuotaInBytes)); | 19920 currentQuotaInBytes)); |
19921 }, | 19921 }, |
19922 (error) { completer.completeError(error); }); | 19922 (error) { completer.completeError(error); }); |
19923 return completer.future; | 19923 return completer.future; |
19924 } | 19924 } |
19925 } | 19925 } |
19926 | 19926 |
19927 /** | 19927 /** |
19928 * A simple container class for the two values that are returned from the | 19928 * A simple container class for the two values that are returned from the |
19929 * futures in requestQuota and queryUsageAndQuota. | 19929 * futures in requestQuota and queryUsageAndQuota. |
19930 */ | 19930 */ |
19931 class StorageInfoUsage { | 19931 class StorageInfoUsage { |
19932 final int currentUsageInBytes; | 19932 final int currentUsageInBytes; |
19933 final int currentQuotaInBytes; | 19933 final int currentQuotaInBytes; |
19934 const StorageInfoUsage(this.currentUsageInBytes, this.currentQuotaInBytes); | 19934 const StorageInfoUsage(this.currentUsageInBytes, this.currentQuotaInBytes); |
19935 } | 19935 } |
19936 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 19936 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
19937 // for details. All rights reserved. Use of this source code is governed by a | 19937 // for details. All rights reserved. Use of this source code is governed by a |
(...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
20360 * should not be used in your code. | 20360 * should not be used in your code. |
20361 * | 20361 * |
20362 * This event is fired whenever a template is instantiated via | 20362 * This event is fired whenever a template is instantiated via |
20363 * [createInstance]. | 20363 * [createInstance]. |
20364 */ | 20364 */ |
20365 // TODO(rafaelw): This is a hack, and is neccesary for the polyfill | 20365 // TODO(rafaelw): This is a hack, and is neccesary for the polyfill |
20366 // because custom elements are not upgraded during clone() | 20366 // because custom elements are not upgraded during clone() |
20367 @Experimental | 20367 @Experimental |
20368 static Stream<DocumentFragment> get instanceCreated { | 20368 static Stream<DocumentFragment> get instanceCreated { |
20369 if (_instanceCreated == null) { | 20369 if (_instanceCreated == null) { |
20370 _instanceCreated = new StreamController<DocumentFragment>(); | 20370 _instanceCreated = new StreamController<DocumentFragment>(sync: true); |
20371 } | 20371 } |
20372 return _instanceCreated.stream; | 20372 return _instanceCreated.stream; |
20373 } | 20373 } |
20374 | 20374 |
20375 /** | 20375 /** |
20376 * Ensures proper API and content model for template elements. | 20376 * Ensures proper API and content model for template elements. |
20377 * | 20377 * |
20378 * [instanceRef] can be used to set the [Element.ref] property of [template], | 20378 * [instanceRef] can be used to set the [Element.ref] property of [template], |
20379 * and use the ref's content will be used as source when createInstance() is | 20379 * and use the ref's content will be used as source when createInstance() is |
20380 * invoked. | 20380 * invoked. |
(...skipping 2906 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
23287 } | 23287 } |
23288 } | 23288 } |
23289 | 23289 |
23290 class _BeforeUnloadEventStreamProvider implements | 23290 class _BeforeUnloadEventStreamProvider implements |
23291 EventStreamProvider<BeforeUnloadEvent> { | 23291 EventStreamProvider<BeforeUnloadEvent> { |
23292 final String _eventType; | 23292 final String _eventType; |
23293 | 23293 |
23294 const _BeforeUnloadEventStreamProvider(this._eventType); | 23294 const _BeforeUnloadEventStreamProvider(this._eventType); |
23295 | 23295 |
23296 Stream<BeforeUnloadEvent> forTarget(EventTarget e, {bool useCapture: false}) { | 23296 Stream<BeforeUnloadEvent> forTarget(EventTarget e, {bool useCapture: false}) { |
23297 var controller = new StreamController(); | 23297 var controller = new StreamController(sync: true); |
23298 var stream = new _EventStream(e, _eventType, useCapture); | 23298 var stream = new _EventStream(e, _eventType, useCapture); |
23299 stream.listen((event) { | 23299 stream.listen((event) { |
23300 var wrapped = new _BeforeUnloadEvent(event); | 23300 var wrapped = new _BeforeUnloadEvent(event); |
23301 controller.add(wrapped); | 23301 controller.add(wrapped); |
23302 return wrapped.returnValue; | 23302 return wrapped.returnValue; |
23303 }); | 23303 }); |
23304 | 23304 |
23305 return controller.stream; | 23305 return controller.stream; |
23306 } | 23306 } |
23307 | 23307 |
(...skipping 2320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
25628 /** The type of KeyEvent we are tracking (keyup, keydown, keypress). */ | 25628 /** The type of KeyEvent we are tracking (keyup, keydown, keypress). */ |
25629 final String _type; | 25629 final String _type; |
25630 | 25630 |
25631 /** The element we are watching for events to happen on. */ | 25631 /** The element we are watching for events to happen on. */ |
25632 final EventTarget _target; | 25632 final EventTarget _target; |
25633 | 25633 |
25634 // The distance to shift from upper case alphabet Roman letters to lower case. | 25634 // The distance to shift from upper case alphabet Roman letters to lower case. |
25635 static final int _ROMAN_ALPHABET_OFFSET = "a".codeUnits[0] - "A".codeUnits[0]; | 25635 static final int _ROMAN_ALPHABET_OFFSET = "a".codeUnits[0] - "A".codeUnits[0]; |
25636 | 25636 |
25637 /** Controller to produce KeyEvents for the stream. */ | 25637 /** Controller to produce KeyEvents for the stream. */ |
25638 final StreamController _controller = new StreamController(); | 25638 final StreamController _controller = new StreamController(sync: true); |
25639 | 25639 |
25640 static const _EVENT_TYPE = 'KeyEvent'; | 25640 static const _EVENT_TYPE = 'KeyEvent'; |
25641 | 25641 |
25642 /** | 25642 /** |
25643 * An enumeration of key identifiers currently part of the W3C draft for DOM3 | 25643 * An enumeration of key identifiers currently part of the W3C draft for DOM3 |
25644 * and their mappings to keyCodes. | 25644 * and their mappings to keyCodes. |
25645 * http://www.w3.org/TR/DOM-Level-3-Events/keyset.html#KeySet-Set | 25645 * http://www.w3.org/TR/DOM-Level-3-Events/keyset.html#KeySet-Set |
25646 */ | 25646 */ |
25647 static const Map<String, int> _keyIdentifier = const { | 25647 static const Map<String, int> _keyIdentifier = const { |
25648 'Up': KeyCode.UP, | 25648 'Up': KeyCode.UP, |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
25697 * KeyboardEvent controller. | 25697 * KeyboardEvent controller. |
25698 */ | 25698 */ |
25699 _KeyboardEventHandler(this._type) : | 25699 _KeyboardEventHandler(this._type) : |
25700 _target = null, super(_EVENT_TYPE) { | 25700 _target = null, super(_EVENT_TYPE) { |
25701 } | 25701 } |
25702 | 25702 |
25703 /** | 25703 /** |
25704 * Hook up all event listeners under the covers so we can estimate keycodes | 25704 * Hook up all event listeners under the covers so we can estimate keycodes |
25705 * and charcodes when they are not provided. | 25705 * and charcodes when they are not provided. |
25706 */ | 25706 */ |
25707 _KeyboardEventHandler.initializeAllEventListeners(this._type, this._target) : | 25707 _KeyboardEventHandler.initializeAllEventListeners(this._type, this._target) : |
25708 super(_EVENT_TYPE) { | 25708 super(_EVENT_TYPE) { |
25709 Element.keyDownEvent.forTarget(_target, useCapture: true).listen( | 25709 Element.keyDownEvent.forTarget(_target, useCapture: true).listen( |
25710 processKeyDown); | 25710 processKeyDown); |
25711 Element.keyPressEvent.forTarget(_target, useCapture: true).listen( | 25711 Element.keyPressEvent.forTarget(_target, useCapture: true).listen( |
25712 processKeyPress); | 25712 processKeyPress); |
25713 Element.keyUpEvent.forTarget(_target, useCapture: true).listen( | 25713 Element.keyUpEvent.forTarget(_target, useCapture: true).listen( |
25714 processKeyUp); | 25714 processKeyUp); |
25715 } | 25715 } |
25716 | 25716 |
25717 /** | 25717 /** |
(...skipping 1124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
26842 * Observes [path] on [object] for changes. This returns an object that can be | 26842 * Observes [path] on [object] for changes. This returns an object that can be |
26843 * used to get the changes and get/set the value at this path. | 26843 * used to get the changes and get/set the value at this path. |
26844 * See [PathObserver.values] and [PathObserver.value]. | 26844 * See [PathObserver.values] and [PathObserver.value]. |
26845 */ | 26845 */ |
26846 PathObserver(this.object, String path) | 26846 PathObserver(this.object, String path) |
26847 : path = path, _isValid = _isPathValid(path) { | 26847 : path = path, _isValid = _isPathValid(path) { |
26848 | 26848 |
26849 // TODO(jmesserly): if the path is empty, or the object is! Observable, we | 26849 // TODO(jmesserly): if the path is empty, or the object is! Observable, we |
26850 // can optimize the PathObserver to be more lightweight. | 26850 // can optimize the PathObserver to be more lightweight. |
26851 | 26851 |
26852 _values = new StreamController.broadcast(onListen: _observe, | 26852 _values = new StreamController.broadcast(sync: true, |
| 26853 onListen: _observe, |
26853 onCancel: _unobserve); | 26854 onCancel: _unobserve); |
26854 | 26855 |
26855 if (_isValid) { | 26856 if (_isValid) { |
26856 var segments = []; | 26857 var segments = []; |
26857 for (var segment in path.trim().split('.')) { | 26858 for (var segment in path.trim().split('.')) { |
26858 if (segment == '') continue; | 26859 if (segment == '') continue; |
26859 var index = int.parse(segment, onError: (_) {}); | 26860 var index = int.parse(segment, onError: (_) {}); |
26860 segments.add(index != null ? index : new Symbol(segment)); | 26861 segments.add(index != null ? index : new Symbol(segment)); |
26861 } | 26862 } |
26862 | 26863 |
(...skipping 2390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
29253 // for details. All rights reserved. Use of this source code is governed by a | 29254 // for details. All rights reserved. Use of this source code is governed by a |
29254 // BSD-style license that can be found in the LICENSE file. | 29255 // BSD-style license that can be found in the LICENSE file. |
29255 | 29256 |
29256 | 29257 |
29257 // Iterator for arrays with fixed size. | 29258 // Iterator for arrays with fixed size. |
29258 class FixedSizeListIterator<T> implements Iterator<T> { | 29259 class FixedSizeListIterator<T> implements Iterator<T> { |
29259 final List<T> _array; | 29260 final List<T> _array; |
29260 final int _length; // Cache array length for faster access. | 29261 final int _length; // Cache array length for faster access. |
29261 int _position; | 29262 int _position; |
29262 T _current; | 29263 T _current; |
29263 | 29264 |
29264 FixedSizeListIterator(List<T> array) | 29265 FixedSizeListIterator(List<T> array) |
29265 : _array = array, | 29266 : _array = array, |
29266 _position = -1, | 29267 _position = -1, |
29267 _length = array.length; | 29268 _length = array.length; |
29268 | 29269 |
29269 bool moveNext() { | 29270 bool moveNext() { |
29270 int nextPosition = _position + 1; | 29271 int nextPosition = _position + 1; |
29271 if (nextPosition < _length) { | 29272 if (nextPosition < _length) { |
29272 _current = _array[nextPosition]; | 29273 _current = _array[nextPosition]; |
29273 _position = nextPosition; | 29274 _position = nextPosition; |
(...skipping 24 matching lines...) Expand all Loading... |
29298 _position = nextPosition; | 29299 _position = nextPosition; |
29299 return true; | 29300 return true; |
29300 } | 29301 } |
29301 _current = null; | 29302 _current = null; |
29302 _position = _array.length; | 29303 _position = _array.length; |
29303 return false; | 29304 return false; |
29304 } | 29305 } |
29305 | 29306 |
29306 T get current => _current; | 29307 T get current => _current; |
29307 } | 29308 } |
OLD | NEW |