| 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:svg' as svg; | 8 import 'dart:svg' as svg; |
| 9 import 'dart:web_audio' as web_audio; | 9 import 'dart:web_audio' as web_audio; |
| 10 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 10 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| (...skipping 21674 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 21685 * window.location('http://www.mysite.com', 'foo'); | 21685 * window.location('http://www.mysite.com', 'foo'); |
| 21686 * // Does not close this window, as the history has changed. | 21686 * // Does not close this window, as the history has changed. |
| 21687 * window.close(); | 21687 * window.close(); |
| 21688 * print(window.closed()); // 'false' | 21688 * print(window.closed()); // 'false' |
| 21689 * | 21689 * |
| 21690 * See also: | 21690 * See also: |
| 21691 * | 21691 * |
| 21692 * * [Window close discussion](http://www.w3.org/TR/html5/browsers.html#dom-wi
ndow-close) from the W3C | 21692 * * [Window close discussion](http://www.w3.org/TR/html5/browsers.html#dom-wi
ndow-close) from the W3C |
| 21693 */ | 21693 */ |
| 21694 void close(); | 21694 void close(); |
| 21695 void postMessage(var message, String targetOrigin, [List messagePorts = null])
; | 21695 void postMessage(var message, String targetOrigin, [List messagePorts]); |
| 21696 } | 21696 } |
| 21697 | 21697 |
| 21698 abstract class Location { | 21698 abstract class Location { |
| 21699 void set href(String val); | 21699 void set href(String val); |
| 21700 } | 21700 } |
| 21701 | 21701 |
| 21702 abstract class History { | 21702 abstract class History { |
| 21703 void back(); | 21703 void back(); |
| 21704 void forward(); | 21704 void forward(); |
| 21705 void go(int distance); | 21705 void go(int distance); |
| (...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 22016 */ | 22016 */ |
| 22017 List<KeyboardEvent> _keyDownList; | 22017 List<KeyboardEvent> _keyDownList; |
| 22018 | 22018 |
| 22019 /** The set of functions that wish to be notified when a KeyEvent happens. */ | 22019 /** The set of functions that wish to be notified when a KeyEvent happens. */ |
| 22020 List<Function> _callbacks; | 22020 List<Function> _callbacks; |
| 22021 | 22021 |
| 22022 /** The type of KeyEvent we are tracking (keyup, keydown, keypress). */ | 22022 /** The type of KeyEvent we are tracking (keyup, keydown, keypress). */ |
| 22023 String _type; | 22023 String _type; |
| 22024 | 22024 |
| 22025 /** The element we are watching for events to happen on. */ | 22025 /** The element we are watching for events to happen on. */ |
| 22026 EventTarget _target; | 22026 Element _target; |
| 22027 | 22027 |
| 22028 // The distance to shift from upper case alphabet Roman letters to lower case. | 22028 // The distance to shift from upper case alphabet Roman letters to lower case. |
| 22029 final int _ROMAN_ALPHABET_OFFSET = "a".charCodes[0] - "A".charCodes[0]; | 22029 final int _ROMAN_ALPHABET_OFFSET = "a".charCodes[0] - "A".charCodes[0]; |
| 22030 | 22030 |
| 22031 // Instance members referring to the internal event handlers because closures | 22031 // Instance members referring to the internal event handlers because closures |
| 22032 // are not hashable. | 22032 // are not hashable. |
| 22033 var _keyUp, _keyDown, _keyPress; | 22033 var _keyUp, _keyDown, _keyPress; |
| 22034 | 22034 |
| 22035 /** | 22035 /** |
| 22036 * An enumeration of key identifiers currently part of the W3C draft for DOM3 | 22036 * 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... |
| 22075 | 22075 |
| 22076 /** Named constructor to add an onKeyDown event listener to our handler. */ | 22076 /** Named constructor to add an onKeyDown event listener to our handler. */ |
| 22077 KeyboardEventController.keydown(EventTarget target) { | 22077 KeyboardEventController.keydown(EventTarget target) { |
| 22078 _KeyboardEventController(target, 'keydown'); | 22078 _KeyboardEventController(target, 'keydown'); |
| 22079 } | 22079 } |
| 22080 | 22080 |
| 22081 /** | 22081 /** |
| 22082 * General constructor, performs basic initialization for our improved | 22082 * General constructor, performs basic initialization for our improved |
| 22083 * KeyboardEvent controller. | 22083 * KeyboardEvent controller. |
| 22084 */ | 22084 */ |
| 22085 _KeyboardEventController(EventTarget target, String type) { | 22085 _KeyboardEventController(Element target, String type) { |
| 22086 _callbacks = []; | 22086 _callbacks = []; |
| 22087 _type = type; | 22087 _type = type; |
| 22088 _target = target; | 22088 _target = target; |
| 22089 _keyDown = processKeyDown; | 22089 _keyDown = processKeyDown; |
| 22090 _keyUp = processKeyUp; | 22090 _keyUp = processKeyUp; |
| 22091 _keyPress = processKeyPress; | 22091 _keyPress = processKeyPress; |
| 22092 } | 22092 } |
| 22093 | 22093 |
| 22094 /** | 22094 /** |
| 22095 * Hook up all event listeners under the covers so we can estimate keycodes | 22095 * Hook up all event listeners under the covers so we can estimate keycodes |
| (...skipping 1168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 23264 | 23264 |
| 23265 visitJsSendPortSync(_JsSendPortSync x) { | 23265 visitJsSendPortSync(_JsSendPortSync x) { |
| 23266 return [ 'sendport', 'nativejs', x._id ]; | 23266 return [ 'sendport', 'nativejs', x._id ]; |
| 23267 } | 23267 } |
| 23268 | 23268 |
| 23269 visitLocalSendPortSync(_LocalSendPortSync x) { | 23269 visitLocalSendPortSync(_LocalSendPortSync x) { |
| 23270 return [ 'sendport', 'dart', | 23270 return [ 'sendport', 'dart', |
| 23271 ReceivePortSync._isolateId, x._receivePort._portId ]; | 23271 ReceivePortSync._isolateId, x._receivePort._portId ]; |
| 23272 } | 23272 } |
| 23273 | 23273 |
| 23274 visitSendPort(SendPort x) { |
| 23275 throw new UnimplementedError('Asynchronous send port not yet implemented.'); |
| 23276 } |
| 23277 |
| 23274 visitRemoteSendPortSync(_RemoteSendPortSync x) { | 23278 visitRemoteSendPortSync(_RemoteSendPortSync x) { |
| 23275 return [ 'sendport', 'dart', | 23279 return [ 'sendport', 'dart', x._isolateId, x._portId ]; |
| 23276 x._receivePort._isolateId, x._receivePort._portId ]; | |
| 23277 } | 23280 } |
| 23278 } | 23281 } |
| 23279 | 23282 |
| 23280 _deserialize(var message) { | 23283 _deserialize(var message) { |
| 23281 return new _JsDeserializer().deserialize(message); | 23284 return new _JsDeserializer().deserialize(message); |
| 23282 } | 23285 } |
| 23283 | 23286 |
| 23284 | 23287 |
| 23285 class _JsDeserializer extends _Deserializer { | 23288 class _JsDeserializer extends _Deserializer { |
| 23286 | 23289 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 23324 int _portId; | 23327 int _portId; |
| 23325 _RemoteSendPortSync(this._isolateId, this._portId); | 23328 _RemoteSendPortSync(this._isolateId, this._portId); |
| 23326 | 23329 |
| 23327 callSync(var message) { | 23330 callSync(var message) { |
| 23328 var serialized = _serialize(message); | 23331 var serialized = _serialize(message); |
| 23329 var result = _call(_isolateId, _portId, serialized); | 23332 var result = _call(_isolateId, _portId, serialized); |
| 23330 return _deserialize(result); | 23333 return _deserialize(result); |
| 23331 } | 23334 } |
| 23332 | 23335 |
| 23333 static _call(int isolateId, int portId, var message) { | 23336 static _call(int isolateId, int portId, var message) { |
| 23334 var target = 'dart-port-$isolateId-$portId'; | 23337 var target = 'dart-port-$isolateId-$portId'; |
| 23335 // TODO(vsm): Make this re-entrant. | 23338 // TODO(vsm): Make this re-entrant. |
| 23336 // TODO(vsm): Set this up set once, on the first call. | 23339 // TODO(vsm): Set this up set once, on the first call. |
| 23337 var source = '$target-result'; | 23340 var source = '$target-result'; |
| 23338 var result = null; | 23341 var result = null; |
| 23339 var listener = (Event e) { | 23342 var listener = (Event e) { |
| 23340 result = JSON.parse(_getPortSyncEventData(e)); | 23343 result = JSON.parse(_getPortSyncEventData(e)); |
| 23341 }; | 23344 }; |
| 23342 window.on[source].add(listener); | 23345 window.on[source].add(listener); |
| 23343 _dispatchEvent(target, [source, message]); | 23346 _dispatchEvent(target, [source, message]); |
| 23344 window.on[source].remove(listener); | 23347 window.on[source].remove(listener); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 23389 _portIdCount = 0; | 23392 _portIdCount = 0; |
| 23390 _portMap = new Map<int, ReceivePortSync>(); | 23393 _portMap = new Map<int, ReceivePortSync>(); |
| 23391 } | 23394 } |
| 23392 _portId = _portIdCount++; | 23395 _portId = _portIdCount++; |
| 23393 _portMap[_portId] = this; | 23396 _portMap[_portId] = this; |
| 23394 } | 23397 } |
| 23395 | 23398 |
| 23396 static int get _isolateId { | 23399 static int get _isolateId { |
| 23397 // TODO(vsm): Make this coherent with existing isolate code. | 23400 // TODO(vsm): Make this coherent with existing isolate code. |
| 23398 if (_cachedIsolateId == null) { | 23401 if (_cachedIsolateId == null) { |
| 23399 _cachedIsolateId = _getNewIsolateId(); | 23402 _cachedIsolateId = _getNewIsolateId(); |
| 23400 } | 23403 } |
| 23401 return _cachedIsolateId; | 23404 return _cachedIsolateId; |
| 23402 } | 23405 } |
| 23403 | 23406 |
| 23404 static String _getListenerName(isolateId, portId) => | 23407 static String _getListenerName(isolateId, portId) => |
| 23405 'dart-port-$isolateId-$portId'; | 23408 'dart-port-$isolateId-$portId'; |
| 23406 String get _listenerName => _getListenerName(_isolateId, _portId); | 23409 String get _listenerName => _getListenerName(_isolateId, _portId); |
| 23407 | 23410 |
| 23408 void receive(callback(var message)) { | 23411 void receive(callback(var message)) { |
| 23409 _callback = callback; | 23412 _callback = callback; |
| 23410 if (_listener == null) { | 23413 if (_listener == null) { |
| 23411 _listener = (Event e) { | 23414 _listener = (Event e) { |
| 23412 var data = JSON.parse(_getPortSyncEventData(e)); | 23415 var data = JSON.parse(_getPortSyncEventData(e)); |
| 23413 var replyTo = data[0]; | 23416 var replyTo = data[0]; |
| 23414 var message = _deserialize(data[1]); | 23417 var message = _deserialize(data[1]); |
| 23415 var result = _callback(message); | 23418 var result = _callback(message); |
| (...skipping 766 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 24182 void stopPropagation() => _parent.stopPropagation(); | 24185 void stopPropagation() => _parent.stopPropagation(); |
| 24183 void $dom_initUIEvent(String type, bool canBubble, bool cancelable, | 24186 void $dom_initUIEvent(String type, bool canBubble, bool cancelable, |
| 24184 LocalWindow view, int detail) { | 24187 LocalWindow view, int detail) { |
| 24185 throw new UnsupportedError("Cannot initialize a UI Event from a KeyEvent."); | 24188 throw new UnsupportedError("Cannot initialize a UI Event from a KeyEvent."); |
| 24186 } | 24189 } |
| 24187 void $dom_initEvent(String eventTypeArg, bool canBubbleArg, | 24190 void $dom_initEvent(String eventTypeArg, bool canBubbleArg, |
| 24188 bool cancelableArg) { | 24191 bool cancelableArg) { |
| 24189 throw new UnsupportedError("Cannot initialize an Event from a KeyEvent."); | 24192 throw new UnsupportedError("Cannot initialize an Event from a KeyEvent."); |
| 24190 } | 24193 } |
| 24191 String get _shadowKeyIdentifier => JS('String', '#.keyIdentifier', _parent); | 24194 String get _shadowKeyIdentifier => JS('String', '#.keyIdentifier', _parent); |
| 24195 |
| 24196 int get $dom_charCode => charCode; |
| 24197 int get $dom_keyCode => keyCode; |
| 24198 EventTarget get target => _parent.target; |
| 24199 String get $dom_keyIdentifier { |
| 24200 throw new UnsupportedError("keyIdentifier is unsupported."); |
| 24201 } |
| 24202 void $dom_initKeyboardEvent(String type, bool canBubble, bool cancelable, |
| 24203 LocalWindow view, String keyIdentifier, int keyLocation, bool ctrlKey, |
| 24204 bool altKey, bool shiftKey, bool metaKey, |
| 24205 bool altGraphKey) { |
| 24206 throw new UnsupportedError( |
| 24207 "Cannot initialize a KeyboardEvent from a KeyEvent."); |
| 24208 } |
| 24192 } | 24209 } |
| 24193 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 24210 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 24194 // for details. All rights reserved. Use of this source code is governed by a | 24211 // for details. All rights reserved. Use of this source code is governed by a |
| 24195 // BSD-style license that can be found in the LICENSE file. | 24212 // BSD-style license that can be found in the LICENSE file. |
| 24196 | 24213 |
| 24197 | 24214 |
| 24198 class _PointFactoryProvider { | 24215 class _PointFactoryProvider { |
| 24199 static Point createPoint(num x, num y) => | 24216 static Point createPoint(num x, num y) => |
| 24200 JS('Point', 'new WebKitPoint(#, #)', x, y); | 24217 JS('Point', 'new WebKitPoint(#, #)', x, y); |
| 24201 } | 24218 } |
| (...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 24500 T next() { | 24517 T next() { |
| 24501 if (!hasNext) { | 24518 if (!hasNext) { |
| 24502 throw new StateError("No more elements"); | 24519 throw new StateError("No more elements"); |
| 24503 } | 24520 } |
| 24504 return _array[_pos++]; | 24521 return _array[_pos++]; |
| 24505 } | 24522 } |
| 24506 | 24523 |
| 24507 final List<T> _array; | 24524 final List<T> _array; |
| 24508 int _pos; | 24525 int _pos; |
| 24509 } | 24526 } |
| OLD | NEW |