| OLD | NEW |
| 1 library html; | 1 library html; |
| 2 | 2 |
| 3 import 'dart:collection'; | 3 import 'dart:collection'; |
| 4 import 'dart:html_common'; | 4 import 'dart:html_common'; |
| 5 import 'dart:indexed_db'; | 5 import 'dart:indexed_db'; |
| 6 import 'dart:isolate'; | 6 import 'dart:isolate'; |
| 7 import 'dart:json'; | 7 import 'dart:json'; |
| 8 import 'dart:nativewrappers'; | 8 import 'dart:nativewrappers'; |
| 9 import 'dart:svg' as svg; | 9 import 'dart:svg' as svg; |
| 10 import 'dart:web_audio' as web_audio; | 10 import 'dart:web_audio' as web_audio; |
| (...skipping 27203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 27214 * window.location('http://www.mysite.com', 'foo'); | 27214 * window.location('http://www.mysite.com', 'foo'); |
| 27215 * // Does not close this window, as the history has changed. | 27215 * // Does not close this window, as the history has changed. |
| 27216 * window.close(); | 27216 * window.close(); |
| 27217 * print(window.closed()); // 'false' | 27217 * print(window.closed()); // 'false' |
| 27218 * | 27218 * |
| 27219 * See also: | 27219 * See also: |
| 27220 * | 27220 * |
| 27221 * * [Window close discussion](http://www.w3.org/TR/html5/browsers.html#dom-wi
ndow-close) from the W3C | 27221 * * [Window close discussion](http://www.w3.org/TR/html5/browsers.html#dom-wi
ndow-close) from the W3C |
| 27222 */ | 27222 */ |
| 27223 void close(); | 27223 void close(); |
| 27224 void postMessage(var message, String targetOrigin, [List messagePorts = null])
; | 27224 void postMessage(var message, String targetOrigin, [List messagePorts]); |
| 27225 } | 27225 } |
| 27226 | 27226 |
| 27227 abstract class Location { | 27227 abstract class Location { |
| 27228 void set href(String val); | 27228 void set href(String val); |
| 27229 } | 27229 } |
| 27230 | 27230 |
| 27231 abstract class History { | 27231 abstract class History { |
| 27232 void back(); | 27232 void back(); |
| 27233 void forward(); | 27233 void forward(); |
| 27234 void go(int distance); | 27234 void go(int distance); |
| (...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 27509 */ | 27509 */ |
| 27510 List<KeyboardEvent> _keyDownList; | 27510 List<KeyboardEvent> _keyDownList; |
| 27511 | 27511 |
| 27512 /** The set of functions that wish to be notified when a KeyEvent happens. */ | 27512 /** The set of functions that wish to be notified when a KeyEvent happens. */ |
| 27513 List<Function> _callbacks; | 27513 List<Function> _callbacks; |
| 27514 | 27514 |
| 27515 /** The type of KeyEvent we are tracking (keyup, keydown, keypress). */ | 27515 /** The type of KeyEvent we are tracking (keyup, keydown, keypress). */ |
| 27516 String _type; | 27516 String _type; |
| 27517 | 27517 |
| 27518 /** The element we are watching for events to happen on. */ | 27518 /** The element we are watching for events to happen on. */ |
| 27519 EventTarget _target; | 27519 Element _target; |
| 27520 | 27520 |
| 27521 // The distance to shift from upper case alphabet Roman letters to lower case. | 27521 // The distance to shift from upper case alphabet Roman letters to lower case. |
| 27522 final int _ROMAN_ALPHABET_OFFSET = "a".charCodes[0] - "A".charCodes[0]; | 27522 final int _ROMAN_ALPHABET_OFFSET = "a".charCodes[0] - "A".charCodes[0]; |
| 27523 | 27523 |
| 27524 // Instance members referring to the internal event handlers because closures | 27524 // Instance members referring to the internal event handlers because closures |
| 27525 // are not hashable. | 27525 // are not hashable. |
| 27526 var _keyUp, _keyDown, _keyPress; | 27526 var _keyUp, _keyDown, _keyPress; |
| 27527 | 27527 |
| 27528 /** | 27528 /** |
| 27529 * An enumeration of key identifiers currently part of the W3C draft for DOM3 | 27529 * An enumeration of key identifiers currently part of the W3C draft for DOM3 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 27568 | 27568 |
| 27569 /** Named constructor to add an onKeyDown event listener to our handler. */ | 27569 /** Named constructor to add an onKeyDown event listener to our handler. */ |
| 27570 KeyboardEventController.keydown(EventTarget target) { | 27570 KeyboardEventController.keydown(EventTarget target) { |
| 27571 _KeyboardEventController(target, 'keydown'); | 27571 _KeyboardEventController(target, 'keydown'); |
| 27572 } | 27572 } |
| 27573 | 27573 |
| 27574 /** | 27574 /** |
| 27575 * General constructor, performs basic initialization for our improved | 27575 * General constructor, performs basic initialization for our improved |
| 27576 * KeyboardEvent controller. | 27576 * KeyboardEvent controller. |
| 27577 */ | 27577 */ |
| 27578 _KeyboardEventController(EventTarget target, String type) { | 27578 _KeyboardEventController(Element target, String type) { |
| 27579 _callbacks = []; | 27579 _callbacks = []; |
| 27580 _type = type; | 27580 _type = type; |
| 27581 _target = target; | 27581 _target = target; |
| 27582 _keyDown = processKeyDown; | 27582 _keyDown = processKeyDown; |
| 27583 _keyUp = processKeyUp; | 27583 _keyUp = processKeyUp; |
| 27584 _keyPress = processKeyPress; | 27584 _keyPress = processKeyPress; |
| 27585 } | 27585 } |
| 27586 | 27586 |
| 27587 /** | 27587 /** |
| 27588 * Hook up all event listeners under the covers so we can estimate keycodes | 27588 * Hook up all event listeners under the covers so we can estimate keycodes |
| (...skipping 1330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 28919 void stopPropagation() => _parent.stopPropagation(); | 28919 void stopPropagation() => _parent.stopPropagation(); |
| 28920 void $dom_initUIEvent(String type, bool canBubble, bool cancelable, | 28920 void $dom_initUIEvent(String type, bool canBubble, bool cancelable, |
| 28921 LocalWindow view, int detail) { | 28921 LocalWindow view, int detail) { |
| 28922 throw new UnsupportedError("Cannot initialize a UI Event from a KeyEvent."); | 28922 throw new UnsupportedError("Cannot initialize a UI Event from a KeyEvent."); |
| 28923 } | 28923 } |
| 28924 void $dom_initEvent(String eventTypeArg, bool canBubbleArg, | 28924 void $dom_initEvent(String eventTypeArg, bool canBubbleArg, |
| 28925 bool cancelableArg) { | 28925 bool cancelableArg) { |
| 28926 throw new UnsupportedError("Cannot initialize an Event from a KeyEvent."); | 28926 throw new UnsupportedError("Cannot initialize an Event from a KeyEvent."); |
| 28927 } | 28927 } |
| 28928 String get _shadowKeyIdentifier => _parent.$dom_keyIdentifier; | 28928 String get _shadowKeyIdentifier => _parent.$dom_keyIdentifier; |
| 28929 |
| 28930 int get $dom_charCode => charCode; |
| 28931 int get $dom_keyCode => keyCode; |
| 28932 EventTarget get target => _parent.target; |
| 28933 String get $dom_keyIdentifier { |
| 28934 throw new UnsupportedError("keyIdentifier is unsupported."); |
| 28935 } |
| 28936 void $dom_initKeyboardEvent(String type, bool canBubble, bool cancelable, |
| 28937 LocalWindow view, String keyIdentifier, int keyLocation, bool ctrlKey, |
| 28938 bool altKey, bool shiftKey, bool metaKey, |
| 28939 bool altGraphKey) { |
| 28940 throw new UnsupportedError( |
| 28941 "Cannot initialize a KeyboardEvent from a KeyEvent."); |
| 28942 } |
| 28929 } | 28943 } |
| 28930 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 28944 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 28931 // for details. All rights reserved. Use of this source code is governed by a | 28945 // for details. All rights reserved. Use of this source code is governed by a |
| 28932 // BSD-style license that can be found in the LICENSE file. | 28946 // BSD-style license that can be found in the LICENSE file. |
| 28933 | 28947 |
| 28934 | 28948 |
| 28935 class _TypedArrayFactoryProvider { | 28949 class _TypedArrayFactoryProvider { |
| 28936 static Float32Array createFloat32Array(int length) => _F32(length); | 28950 static Float32Array createFloat32Array(int length) => _F32(length); |
| 28937 static Float32Array createFloat32Array_fromList(List<num> list) => | 28951 static Float32Array createFloat32Array_fromList(List<num> list) => |
| 28938 _F32(ensureNative(list)); | 28952 _F32(ensureNative(list)); |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 29069 | 29083 |
| 29070 visitJsSendPortSync(_JsSendPortSync x) { | 29084 visitJsSendPortSync(_JsSendPortSync x) { |
| 29071 return [ 'sendport', 'nativejs', x._id ]; | 29085 return [ 'sendport', 'nativejs', x._id ]; |
| 29072 } | 29086 } |
| 29073 | 29087 |
| 29074 visitLocalSendPortSync(_LocalSendPortSync x) { | 29088 visitLocalSendPortSync(_LocalSendPortSync x) { |
| 29075 return [ 'sendport', 'dart', | 29089 return [ 'sendport', 'dart', |
| 29076 ReceivePortSync._isolateId, x._receivePort._portId ]; | 29090 ReceivePortSync._isolateId, x._receivePort._portId ]; |
| 29077 } | 29091 } |
| 29078 | 29092 |
| 29093 visitSendPort(SendPort x) { |
| 29094 throw new UnimplementedError('Asynchronous send port not yet implemented.'); |
| 29095 } |
| 29096 |
| 29079 visitRemoteSendPortSync(_RemoteSendPortSync x) { | 29097 visitRemoteSendPortSync(_RemoteSendPortSync x) { |
| 29080 return [ 'sendport', 'dart', | 29098 return [ 'sendport', 'dart', x._isolateId, x._portId ]; |
| 29081 x._receivePort._isolateId, x._receivePort._portId ]; | |
| 29082 } | 29099 } |
| 29083 } | 29100 } |
| 29084 | 29101 |
| 29085 _deserialize(var message) { | 29102 _deserialize(var message) { |
| 29086 return new _JsDeserializer().deserialize(message); | 29103 return new _JsDeserializer().deserialize(message); |
| 29087 } | 29104 } |
| 29088 | 29105 |
| 29089 | 29106 |
| 29090 class _JsDeserializer extends _Deserializer { | 29107 class _JsDeserializer extends _Deserializer { |
| 29091 | 29108 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 29129 int _portId; | 29146 int _portId; |
| 29130 _RemoteSendPortSync(this._isolateId, this._portId); | 29147 _RemoteSendPortSync(this._isolateId, this._portId); |
| 29131 | 29148 |
| 29132 callSync(var message) { | 29149 callSync(var message) { |
| 29133 var serialized = _serialize(message); | 29150 var serialized = _serialize(message); |
| 29134 var result = _call(_isolateId, _portId, serialized); | 29151 var result = _call(_isolateId, _portId, serialized); |
| 29135 return _deserialize(result); | 29152 return _deserialize(result); |
| 29136 } | 29153 } |
| 29137 | 29154 |
| 29138 static _call(int isolateId, int portId, var message) { | 29155 static _call(int isolateId, int portId, var message) { |
| 29139 var target = 'dart-port-$isolateId-$portId'; | 29156 var target = 'dart-port-$isolateId-$portId'; |
| 29140 // TODO(vsm): Make this re-entrant. | 29157 // TODO(vsm): Make this re-entrant. |
| 29141 // TODO(vsm): Set this up set once, on the first call. | 29158 // TODO(vsm): Set this up set once, on the first call. |
| 29142 var source = '$target-result'; | 29159 var source = '$target-result'; |
| 29143 var result = null; | 29160 var result = null; |
| 29144 var listener = (Event e) { | 29161 var listener = (Event e) { |
| 29145 result = JSON.parse(_getPortSyncEventData(e)); | 29162 result = JSON.parse(_getPortSyncEventData(e)); |
| 29146 }; | 29163 }; |
| 29147 window.on[source].add(listener); | 29164 window.on[source].add(listener); |
| 29148 _dispatchEvent(target, [source, message]); | 29165 _dispatchEvent(target, [source, message]); |
| 29149 window.on[source].remove(listener); | 29166 window.on[source].remove(listener); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 29194 _portIdCount = 0; | 29211 _portIdCount = 0; |
| 29195 _portMap = new Map<int, ReceivePortSync>(); | 29212 _portMap = new Map<int, ReceivePortSync>(); |
| 29196 } | 29213 } |
| 29197 _portId = _portIdCount++; | 29214 _portId = _portIdCount++; |
| 29198 _portMap[_portId] = this; | 29215 _portMap[_portId] = this; |
| 29199 } | 29216 } |
| 29200 | 29217 |
| 29201 static int get _isolateId { | 29218 static int get _isolateId { |
| 29202 // TODO(vsm): Make this coherent with existing isolate code. | 29219 // TODO(vsm): Make this coherent with existing isolate code. |
| 29203 if (_cachedIsolateId == null) { | 29220 if (_cachedIsolateId == null) { |
| 29204 _cachedIsolateId = _getNewIsolateId(); | 29221 _cachedIsolateId = _getNewIsolateId(); |
| 29205 } | 29222 } |
| 29206 return _cachedIsolateId; | 29223 return _cachedIsolateId; |
| 29207 } | 29224 } |
| 29208 | 29225 |
| 29209 static String _getListenerName(isolateId, portId) => | 29226 static String _getListenerName(isolateId, portId) => |
| 29210 'dart-port-$isolateId-$portId'; | 29227 'dart-port-$isolateId-$portId'; |
| 29211 String get _listenerName => _getListenerName(_isolateId, _portId); | 29228 String get _listenerName => _getListenerName(_isolateId, _portId); |
| 29212 | 29229 |
| 29213 void receive(callback(var message)) { | 29230 void receive(callback(var message)) { |
| 29214 _callback = callback; | 29231 _callback = callback; |
| 29215 if (_listener == null) { | 29232 if (_listener == null) { |
| 29216 _listener = (Event e) { | 29233 _listener = (Event e) { |
| 29217 var data = JSON.parse(_getPortSyncEventData(e)); | 29234 var data = JSON.parse(_getPortSyncEventData(e)); |
| 29218 var replyTo = data[0]; | 29235 var replyTo = data[0]; |
| 29219 var message = _deserialize(data[1]); | 29236 var message = _deserialize(data[1]); |
| 29220 var result = _callback(message); | 29237 var result = _callback(message); |
| (...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 29832 bool get isEmpty => Maps.isEmpty(this); | 29849 bool get isEmpty => Maps.isEmpty(this); |
| 29833 } | 29850 } |
| 29834 | 29851 |
| 29835 get _printClosure => (s) { | 29852 get _printClosure => (s) { |
| 29836 try { | 29853 try { |
| 29837 window.console.log(s); | 29854 window.console.log(s); |
| 29838 } catch (_) { | 29855 } catch (_) { |
| 29839 _Utils.print(s); | 29856 _Utils.print(s); |
| 29840 } | 29857 } |
| 29841 }; | 29858 }; |
| OLD | NEW |