OLD | NEW |
1 library html; | 1 library html; |
2 | 2 |
3 import 'dart:isolate'; | 3 import 'dart:isolate'; |
4 import 'dart:json'; | 4 import 'dart:json'; |
5 import 'dart:svg' as svg; | 5 import 'dart:svg' as svg; |
6 import 'dart:web_audio' as web_audio; | 6 import 'dart:web_audio' as web_audio; |
7 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 7 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
8 // for details. All rights reserved. Use of this source code is governed by a | 8 // for details. All rights reserved. Use of this source code is governed by a |
9 // BSD-style license that can be found in the LICENSE file. | 9 // BSD-style license that can be found in the LICENSE file. |
10 | 10 |
(...skipping 5963 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5974 | 5974 |
5975 /// @domName DirectoryReaderSync.readEntries; @docsEditable true | 5975 /// @domName DirectoryReaderSync.readEntries; @docsEditable true |
5976 @Returns('_EntryArraySync') @Creates('_EntryArraySync') | 5976 @Returns('_EntryArraySync') @Creates('_EntryArraySync') |
5977 List<EntrySync> readEntries() native; | 5977 List<EntrySync> readEntries() native; |
5978 } | 5978 } |
5979 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 5979 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
5980 // for details. All rights reserved. Use of this source code is governed by a | 5980 // for details. All rights reserved. Use of this source code is governed by a |
5981 // BSD-style license that can be found in the LICENSE file. | 5981 // BSD-style license that can be found in the LICENSE file. |
5982 | 5982 |
5983 | 5983 |
5984 /** | |
5985 * Represents an HTML <div> element. | |
5986 * | |
5987 * The [DivElement] is a generic container for content and does not have any | |
5988 * special significance. It is functionally similar to [SpanElement]. | |
5989 * | |
5990 * The [DivElement] is a block-level element, as opposed to [SpanElement], | |
5991 * which is an inline-level element. | |
5992 * | |
5993 * Example usage: | |
5994 * | |
5995 * DivElement div = new DivElement(); | |
5996 * div.text = 'Here's my new DivElem | |
5997 * document.body.elements.add(elem); | |
5998 * | |
5999 * See also: | |
6000 * | |
6001 * * [HTML <div> element](http://www.w3.org/TR/html-markup/div.html) from W3C. | |
6002 * * [Block-level element](http://www.w3.org/TR/CSS2/visuren.html#block-boxes) f
rom W3C. | |
6003 * * [Inline-level element](http://www.w3.org/TR/CSS2/visuren.html#inline-boxes)
from W3C. | |
6004 */ | |
6005 /// @domName HTMLDivElement; @docsEditable true | 5984 /// @domName HTMLDivElement; @docsEditable true |
6006 class DivElement extends Element implements Element native "*HTMLDivElement" { | 5985 class DivElement extends Element implements Element native "*HTMLDivElement" { |
6007 | 5986 |
6008 factory DivElement() => document.$dom_createElement("div"); | 5987 factory DivElement() => document.$dom_createElement("div"); |
6009 } | 5988 } |
6010 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 5989 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
6011 // for details. All rights reserved. Use of this source code is governed by a | 5990 // for details. All rights reserved. Use of this source code is governed by a |
6012 // BSD-style license that can be found in the LICENSE file. | 5991 // BSD-style license that can be found in the LICENSE file. |
6013 | 5992 |
6014 | 5993 |
(...skipping 4874 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10889 int scopeType(int scopeIndex) native; | 10868 int scopeType(int scopeIndex) native; |
10890 } | 10869 } |
10891 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 10870 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
10892 // for details. All rights reserved. Use of this source code is governed by a | 10871 // for details. All rights reserved. Use of this source code is governed by a |
10893 // BSD-style license that can be found in the LICENSE file. | 10872 // BSD-style license that can be found in the LICENSE file. |
10894 | 10873 |
10895 | 10874 |
10896 /// @domName KeyboardEvent; @docsEditable true | 10875 /// @domName KeyboardEvent; @docsEditable true |
10897 class KeyboardEvent extends UIEvent native "*KeyboardEvent" { | 10876 class KeyboardEvent extends UIEvent native "*KeyboardEvent" { |
10898 | 10877 |
| 10878 factory KeyboardEvent(String type, Window view, |
| 10879 [bool canBubble = true, bool cancelable = true, |
| 10880 String keyIdentifier = null, int keyLocation = 1, bool ctrlKey = false, |
| 10881 bool altKey = false, bool shiftKey = false, bool metaKey = false, |
| 10882 bool altGraphKey = false]) { |
| 10883 final e = document.$dom_createEvent("KeyboardEvent"); |
| 10884 e.$dom_initKeyboardEvent(type, canBubble, cancelable, view, keyIdentifier, |
| 10885 keyLocation, ctrlKey, altKey, shiftKey, metaKey, altGraphKey); |
| 10886 return e; |
| 10887 } |
| 10888 |
| 10889 /** @domName KeyboardEvent.initKeyboardEvent */ |
| 10890 void $dom_initKeyboardEvent(String type, bool canBubble, bool cancelable, |
| 10891 LocalWindow view, String keyIdentifier, int keyLocation, bool ctrlKey, |
| 10892 bool altKey, bool shiftKey, bool metaKey, bool altGraphKey) { |
| 10893 // initKeyEvent is the call in Firefox, initKeyboardEvent for all other |
| 10894 // browsers. |
| 10895 var function = JS('dynamic', '#.initKeyboardEvent || #.initKeyEvent', this, |
| 10896 this); |
| 10897 JS('void', '#(#, #, #, #, #, #, #, #, #, #, #)', function, type, |
| 10898 canBubble, cancelable, view, keyIdentifier, keyLocation, ctrlKey, |
| 10899 altKey, shiftKey, metaKey, altGraphKey); |
| 10900 } |
| 10901 |
| 10902 /** @domName KeyboardEvent.keyCode */ |
| 10903 int get keyCode => $dom_keyCode; |
| 10904 |
| 10905 /** @domName KeyboardEvent.charCode */ |
| 10906 int get charCode => $dom_charCode; |
| 10907 |
10899 /// @domName KeyboardEvent.altGraphKey; @docsEditable true | 10908 /// @domName KeyboardEvent.altGraphKey; @docsEditable true |
10900 final bool altGraphKey; | 10909 final bool altGraphKey; |
10901 | 10910 |
10902 /// @domName KeyboardEvent.altKey; @docsEditable true | 10911 /// @domName KeyboardEvent.altKey; @docsEditable true |
10903 final bool altKey; | 10912 final bool altKey; |
10904 | 10913 |
10905 /// @domName KeyboardEvent.ctrlKey; @docsEditable true | 10914 /// @domName KeyboardEvent.ctrlKey; @docsEditable true |
10906 final bool ctrlKey; | 10915 final bool ctrlKey; |
10907 | 10916 |
10908 /// @domName KeyboardEvent.keyIdentifier; @docsEditable true | 10917 /// @domName KeyboardEvent.keyIdentifier; @docsEditable true |
10909 final String keyIdentifier; | 10918 String get $dom_keyIdentifier => JS("String", "#.keyIdentifier", this); |
10910 | 10919 |
10911 /// @domName KeyboardEvent.keyLocation; @docsEditable true | 10920 /// @domName KeyboardEvent.keyLocation; @docsEditable true |
10912 final int keyLocation; | 10921 final int keyLocation; |
10913 | 10922 |
10914 /// @domName KeyboardEvent.metaKey; @docsEditable true | 10923 /// @domName KeyboardEvent.metaKey; @docsEditable true |
10915 final bool metaKey; | 10924 final bool metaKey; |
10916 | 10925 |
10917 /// @domName KeyboardEvent.shiftKey; @docsEditable true | 10926 /// @domName KeyboardEvent.shiftKey; @docsEditable true |
10918 final bool shiftKey; | 10927 final bool shiftKey; |
10919 | 10928 |
10920 /// @domName KeyboardEvent.initKeyboardEvent; @docsEditable true | |
10921 void initKeyboardEvent(String type, bool canBubble, bool cancelable, LocalWind
ow view, String keyIdentifier, int keyLocation, bool ctrlKey, bool altKey, bool
shiftKey, bool metaKey, bool altGraphKey) native; | |
10922 } | 10929 } |
10923 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 10930 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
10924 // for details. All rights reserved. Use of this source code is governed by a | 10931 // for details. All rights reserved. Use of this source code is governed by a |
10925 // BSD-style license that can be found in the LICENSE file. | 10932 // BSD-style license that can be found in the LICENSE file. |
10926 | 10933 |
10927 | 10934 |
10928 /// @domName HTMLKeygenElement; @docsEditable true | 10935 /// @domName HTMLKeygenElement; @docsEditable true |
10929 class KeygenElement extends Element implements Element native "*HTMLKeygenElemen
t" { | 10936 class KeygenElement extends Element implements Element native "*HTMLKeygenElemen
t" { |
10930 | 10937 |
10931 factory KeygenElement() => document.$dom_createElement("keygen"); | 10938 factory KeygenElement() => document.$dom_createElement("keygen"); |
(...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11365 /// @domName Window.opener; @docsEditable true | 11372 /// @domName Window.opener; @docsEditable true |
11366 Window get opener => _convertNativeToDart_Window(this._opener); | 11373 Window get opener => _convertNativeToDart_Window(this._opener); |
11367 dynamic get _opener => JS("dynamic", "#.opener", this); | 11374 dynamic get _opener => JS("dynamic", "#.opener", this); |
11368 | 11375 |
11369 /// @domName Window.outerHeight; @docsEditable true | 11376 /// @domName Window.outerHeight; @docsEditable true |
11370 final int outerHeight; | 11377 final int outerHeight; |
11371 | 11378 |
11372 /// @domName Window.outerWidth; @docsEditable true | 11379 /// @domName Window.outerWidth; @docsEditable true |
11373 final int outerWidth; | 11380 final int outerWidth; |
11374 | 11381 |
11375 /// @domName DOMWindow.pagePopupController; @docsEditable true | 11382 /// @domName Window.pagePopupController; @docsEditable true |
11376 final PagePopupController pagePopupController; | 11383 final PagePopupController pagePopupController; |
11377 | 11384 |
11378 /// @domName Window.pageXOffset; @docsEditable true | 11385 /// @domName Window.pageXOffset; @docsEditable true |
11379 final int pageXOffset; | 11386 final int pageXOffset; |
11380 | 11387 |
11381 /// @domName Window.pageYOffset; @docsEditable true | 11388 /// @domName Window.pageYOffset; @docsEditable true |
11382 final int pageYOffset; | 11389 final int pageYOffset; |
11383 | 11390 |
11384 /// @domName Window.parent; @docsEditable true | 11391 /// @domName Window.parent; @docsEditable true |
11385 Window get parent => _convertNativeToDart_Window(this._parent); | 11392 Window get parent => _convertNativeToDart_Window(this._parent); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11431 /// @domName Window.styleMedia; @docsEditable true | 11438 /// @domName Window.styleMedia; @docsEditable true |
11432 final StyleMedia styleMedia; | 11439 final StyleMedia styleMedia; |
11433 | 11440 |
11434 /// @domName Window.toolbar; @docsEditable true | 11441 /// @domName Window.toolbar; @docsEditable true |
11435 final BarInfo toolbar; | 11442 final BarInfo toolbar; |
11436 | 11443 |
11437 /// @domName Window.top; @docsEditable true | 11444 /// @domName Window.top; @docsEditable true |
11438 Window get top => _convertNativeToDart_Window(this._top); | 11445 Window get top => _convertNativeToDart_Window(this._top); |
11439 dynamic get _top => JS("dynamic", "#.top", this); | 11446 dynamic get _top => JS("dynamic", "#.top", this); |
11440 | 11447 |
11441 /// @domName DOMWindow.webkitIndexedDB; @docsEditable true | 11448 /// @domName Window.webkitIndexedDB; @docsEditable true |
11442 final IDBFactory webkitIndexedDB; | 11449 final IDBFactory webkitIndexedDB; |
11443 | 11450 |
11444 /// @domName DOMWindow.webkitNotifications; @docsEditable true | 11451 /// @domName Window.webkitNotifications; @docsEditable true |
11445 final NotificationCenter webkitNotifications; | 11452 final NotificationCenter webkitNotifications; |
11446 | 11453 |
11447 /// @domName DOMWindow.webkitStorageInfo; @docsEditable true | 11454 /// @domName Window.webkitStorageInfo; @docsEditable true |
11448 final StorageInfo webkitStorageInfo; | 11455 final StorageInfo webkitStorageInfo; |
11449 | 11456 |
11450 /// @domName Window.window; @docsEditable true | 11457 /// @domName Window.window; @docsEditable true |
11451 Window get window => _convertNativeToDart_Window(this._window); | 11458 Window get window => _convertNativeToDart_Window(this._window); |
11452 dynamic get _window => JS("dynamic", "#.window", this); | 11459 dynamic get _window => JS("dynamic", "#.window", this); |
11453 | 11460 |
11454 /// @domName Window.addEventListener; @docsEditable true | 11461 /// @domName Window.addEventListener; @docsEditable true |
11455 void $dom_addEventListener(String type, EventListener listener, [bool useCaptu
re]) native "addEventListener"; | 11462 void $dom_addEventListener(String type, EventListener listener, [bool useCaptu
re]) native "addEventListener"; |
11456 | 11463 |
11457 /// @domName Window.alert; @docsEditable true | 11464 /// @domName Window.alert; @docsEditable true |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11496 | 11503 |
11497 /// @domName Window.matchMedia; @docsEditable true | 11504 /// @domName Window.matchMedia; @docsEditable true |
11498 MediaQueryList matchMedia(String query) native; | 11505 MediaQueryList matchMedia(String query) native; |
11499 | 11506 |
11500 /// @domName Window.moveBy; @docsEditable true | 11507 /// @domName Window.moveBy; @docsEditable true |
11501 void moveBy(num x, num y) native; | 11508 void moveBy(num x, num y) native; |
11502 | 11509 |
11503 /// @domName Window.moveTo; @docsEditable true | 11510 /// @domName Window.moveTo; @docsEditable true |
11504 void moveTo(num x, num y) native; | 11511 void moveTo(num x, num y) native; |
11505 | 11512 |
11506 /// @domName DOMWindow.openDatabase; @docsEditable true | 11513 /// @domName Window.openDatabase; @docsEditable true |
11507 @Creates('Database') @Creates('DatabaseSync') | 11514 @Creates('Database') @Creates('DatabaseSync') |
11508 Database openDatabase(String name, String version, String displayName, int est
imatedSize, [DatabaseCallback creationCallback]) native; | 11515 Database openDatabase(String name, String version, String displayName, int est
imatedSize, [DatabaseCallback creationCallback]) native; |
11509 | 11516 |
11510 /// @domName Window.postMessage; @docsEditable true | 11517 /// @domName Window.postMessage; @docsEditable true |
11511 void postMessage(/*SerializedScriptValue*/ message, String targetOrigin, [List
messagePorts]) { | 11518 void postMessage(/*SerializedScriptValue*/ message, String targetOrigin, [List
messagePorts]) { |
11512 if (?message && | 11519 if (?message && |
11513 !?messagePorts) { | 11520 !?messagePorts) { |
11514 var message_1 = _convertDartToNative_SerializedScriptValue(message); | 11521 var message_1 = _convertDartToNative_SerializedScriptValue(message); |
11515 _postMessage_1(message_1, targetOrigin); | 11522 _postMessage_1(message_1, targetOrigin); |
11516 return; | 11523 return; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11560 | 11567 |
11561 /// @domName Window.stop; @docsEditable true | 11568 /// @domName Window.stop; @docsEditable true |
11562 void stop() native; | 11569 void stop() native; |
11563 | 11570 |
11564 /// @domName Window.webkitConvertPointFromNodeToPage; @docsEditable true | 11571 /// @domName Window.webkitConvertPointFromNodeToPage; @docsEditable true |
11565 Point webkitConvertPointFromNodeToPage(Node node, Point p) native; | 11572 Point webkitConvertPointFromNodeToPage(Node node, Point p) native; |
11566 | 11573 |
11567 /// @domName Window.webkitConvertPointFromPageToNode; @docsEditable true | 11574 /// @domName Window.webkitConvertPointFromPageToNode; @docsEditable true |
11568 Point webkitConvertPointFromPageToNode(Node node, Point p) native; | 11575 Point webkitConvertPointFromPageToNode(Node node, Point p) native; |
11569 | 11576 |
11570 /// @domName DOMWindow.webkitRequestFileSystem; @docsEditable true | 11577 /// @domName Window.webkitRequestFileSystem; @docsEditable true |
11571 void webkitRequestFileSystem(int type, int size, FileSystemCallback successCal
lback, [ErrorCallback errorCallback]) native; | 11578 void webkitRequestFileSystem(int type, int size, FileSystemCallback successCal
lback, [ErrorCallback errorCallback]) native; |
11572 | 11579 |
11573 /// @domName DOMWindow.webkitResolveLocalFileSystemURL; @docsEditable true | 11580 /// @domName Window.webkitResolveLocalFileSystemURL; @docsEditable true |
11574 void webkitResolveLocalFileSystemUrl(String url, EntryCallback successCallback
, [ErrorCallback errorCallback]) native "webkitResolveLocalFileSystemURL"; | 11581 void webkitResolveLocalFileSystemUrl(String url, EntryCallback successCallback
, [ErrorCallback errorCallback]) native "webkitResolveLocalFileSystemURL"; |
11575 | 11582 |
11576 } | 11583 } |
11577 | 11584 |
11578 class LocalWindowEvents extends Events { | 11585 class LocalWindowEvents extends Events { |
11579 LocalWindowEvents(EventTarget _ptr) : super(_ptr); | 11586 LocalWindowEvents(EventTarget _ptr) : super(_ptr); |
11580 | 11587 |
11581 EventListenerList get abort => this['abort']; | 11588 EventListenerList get abort => this['abort']; |
11582 | 11589 |
11583 EventListenerList get beforeUnload => this['beforeunload']; | 11590 EventListenerList get beforeUnload => this['beforeunload']; |
(...skipping 801 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12385 final int totalJSHeapSize; | 12392 final int totalJSHeapSize; |
12386 | 12393 |
12387 /// @domName MemoryInfo.usedJSHeapSize; @docsEditable true | 12394 /// @domName MemoryInfo.usedJSHeapSize; @docsEditable true |
12388 final int usedJSHeapSize; | 12395 final int usedJSHeapSize; |
12389 } | 12396 } |
12390 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 12397 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
12391 // for details. All rights reserved. Use of this source code is governed by a | 12398 // for details. All rights reserved. Use of this source code is governed by a |
12392 // BSD-style license that can be found in the LICENSE file. | 12399 // BSD-style license that can be found in the LICENSE file. |
12393 | 12400 |
12394 | 12401 |
12395 /** | |
12396 * An HTML <menu> element. | |
12397 * | |
12398 * A <menu> element represents an unordered list of menu commands. | |
12399 * | |
12400 * See also: | |
12401 * | |
12402 * * [Menu Element](https://developer.mozilla.org/en-US/docs/HTML/Element/menu)
from MDN. | |
12403 * * [Menu Element](http://www.w3.org/TR/html5/the-menu-element.html#the-menu-e
lement) from the W3C. | |
12404 */ | |
12405 /// @domName HTMLMenuElement; @docsEditable true | 12402 /// @domName HTMLMenuElement; @docsEditable true |
12406 class MenuElement extends Element implements Element native "*HTMLMenuElement" { | 12403 class MenuElement extends Element implements Element native "*HTMLMenuElement" { |
12407 | 12404 |
12408 factory MenuElement() => document.$dom_createElement("menu"); | 12405 factory MenuElement() => document.$dom_createElement("menu"); |
12409 } | 12406 } |
12410 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 12407 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
12411 // for details. All rights reserved. Use of this source code is governed by a | 12408 // for details. All rights reserved. Use of this source code is governed by a |
12412 // BSD-style license that can be found in the LICENSE file. | 12409 // BSD-style license that can be found in the LICENSE file. |
12413 | 12410 |
12414 | 12411 |
(...skipping 4686 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
17101 /// @domName TreeWalker.previousNode; @docsEditable true | 17098 /// @domName TreeWalker.previousNode; @docsEditable true |
17102 Node previousNode() native; | 17099 Node previousNode() native; |
17103 | 17100 |
17104 /// @domName TreeWalker.previousSibling; @docsEditable true | 17101 /// @domName TreeWalker.previousSibling; @docsEditable true |
17105 Node previousSibling() native; | 17102 Node previousSibling() native; |
17106 } | 17103 } |
17107 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 17104 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
17108 // for details. All rights reserved. Use of this source code is governed by a | 17105 // for details. All rights reserved. Use of this source code is governed by a |
17109 // BSD-style license that can be found in the LICENSE file. | 17106 // BSD-style license that can be found in the LICENSE file. |
17110 | 17107 |
| 17108 // WARNING: Do not edit - generated code. |
| 17109 |
17111 | 17110 |
17112 /// @domName UIEvent; @docsEditable true | 17111 /// @domName UIEvent; @docsEditable true |
17113 class UIEvent extends Event native "*UIEvent" { | 17112 class UIEvent extends Event native "*UIEvent" { |
| 17113 // In JS, canBubble and cancelable are technically required parameters to |
| 17114 // init*Event. In practice, though, if they aren't provided they simply |
| 17115 // default to false (since that's Boolean(undefined)). |
| 17116 // |
| 17117 // Contrary to JS, we default canBubble and cancelable to true, since that's |
| 17118 // what people want most of the time anyway. |
| 17119 factory UIEvent(String type, Window view, int detail, |
| 17120 [bool canBubble = true, bool cancelable = true]) { |
| 17121 final e = document.$dom_createEvent("UIEvent"); |
| 17122 e.$dom_initUIEvent(type, canBubble, cancelable, view, detail); |
| 17123 return e; |
| 17124 } |
17114 | 17125 |
17115 /// @domName UIEvent.charCode; @docsEditable true | 17126 /// @domName UIEvent.charCode; @docsEditable true |
17116 final int charCode; | 17127 int get $dom_charCode => JS("int", "#.charCode", this); |
17117 | 17128 |
17118 /// @domName UIEvent.detail; @docsEditable true | 17129 /// @domName UIEvent.detail; @docsEditable true |
17119 final int detail; | 17130 final int detail; |
17120 | 17131 |
17121 /// @domName UIEvent.keyCode; @docsEditable true | 17132 /// @domName UIEvent.keyCode; @docsEditable true |
17122 final int keyCode; | 17133 int get $dom_keyCode => JS("int", "#.keyCode", this); |
17123 | 17134 |
17124 /// @domName UIEvent.layerX; @docsEditable true | 17135 /// @domName UIEvent.layerX; @docsEditable true |
17125 final int layerX; | 17136 final int layerX; |
17126 | 17137 |
17127 /// @domName UIEvent.layerY; @docsEditable true | 17138 /// @domName UIEvent.layerY; @docsEditable true |
17128 final int layerY; | 17139 final int layerY; |
17129 | 17140 |
17130 /// @domName UIEvent.pageX; @docsEditable true | 17141 /// @domName UIEvent.pageX; @docsEditable true |
17131 final int pageX; | 17142 final int pageX; |
17132 | 17143 |
17133 /// @domName UIEvent.pageY; @docsEditable true | 17144 /// @domName UIEvent.pageY; @docsEditable true |
17134 final int pageY; | 17145 final int pageY; |
17135 | 17146 |
17136 /// @domName UIEvent.view; @docsEditable true | 17147 /// @domName UIEvent.view; @docsEditable true |
17137 Window get view => _convertNativeToDart_Window(this._view); | 17148 Window get view => _convertNativeToDart_Window(this._view); |
17138 dynamic get _view => JS("dynamic", "#.view", this); | 17149 dynamic get _view => JS("dynamic", "#.view", this); |
17139 | 17150 |
17140 /// @domName UIEvent.which; @docsEditable true | 17151 /// @domName UIEvent.which; @docsEditable true |
17141 final int which; | 17152 final int which; |
17142 | 17153 |
17143 /// @domName UIEvent.initUIEvent; @docsEditable true | 17154 /// @domName UIEvent.initUIEvent; @docsEditable true |
17144 void initUIEvent(String type, bool canBubble, bool cancelable, LocalWindow vie
w, int detail) native; | 17155 void $dom_initUIEvent(String type, bool canBubble, bool cancelable, LocalWindo
w view, int detail) native "initUIEvent"; |
| 17156 |
17145 } | 17157 } |
17146 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 17158 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
17147 // for details. All rights reserved. Use of this source code is governed by a | 17159 // for details. All rights reserved. Use of this source code is governed by a |
17148 // BSD-style license that can be found in the LICENSE file. | 17160 // BSD-style license that can be found in the LICENSE file. |
17149 | 17161 |
17150 | 17162 |
17151 /// @domName HTMLUListElement; @docsEditable true | 17163 /// @domName HTMLUListElement; @docsEditable true |
17152 class UListElement extends Element implements Element native "*HTMLUListElement"
{ | 17164 class UListElement extends Element implements Element native "*HTMLUListElement"
{ |
17153 | 17165 |
17154 factory UListElement() => document.$dom_createElement("ul"); | 17166 factory UListElement() => document.$dom_createElement("ul"); |
(...skipping 4746 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
21901 Element get first => _filtered.first; | 21913 Element get first => _filtered.first; |
21902 | 21914 |
21903 Element get last => _filtered.last; | 21915 Element get last => _filtered.last; |
21904 } | 21916 } |
21905 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 21917 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
21906 // for details. All rights reserved. Use of this source code is governed by a | 21918 // for details. All rights reserved. Use of this source code is governed by a |
21907 // BSD-style license that can be found in the LICENSE file. | 21919 // BSD-style license that can be found in the LICENSE file. |
21908 | 21920 |
21909 | 21921 |
21910 /** | 21922 /** |
| 21923 * Works with KeyboardEvent and KeyEvent to determine how to expose information |
| 21924 * about Key(board)Events. This class functions like an EventListenerList, and |
| 21925 * provides a consistent interface for the Dart |
| 21926 * user, despite the fact that a multitude of browsers that have varying |
| 21927 * keyboard default behavior. |
| 21928 * |
| 21929 * This class is very much a work in progress, and we'd love to get information |
| 21930 * on how we can make this class work with as many international keyboards as |
| 21931 * possible. Bugs welcome! |
| 21932 */ |
| 21933 class KeyboardEventController { |
| 21934 // This code inspired by Closure's KeyHandling library. |
| 21935 // http://closure-library.googlecode.com/svn/docs/closure_goog_events_keyhandl
er.js.source.html |
| 21936 |
| 21937 /** |
| 21938 * The set of keys that have been pressed down without seeing their |
| 21939 * corresponding keyup event. |
| 21940 */ |
| 21941 List<KeyboardEvent> keyDownList; |
| 21942 |
| 21943 /** The set of functions that wish to be notified when a KeyEvent happens. */ |
| 21944 List<Function> _callbacks; |
| 21945 |
| 21946 /** The type of KeyEvent we are tracking (keyup, keydown, keypress). */ |
| 21947 String _type; |
| 21948 |
| 21949 /** The element we are watching for events to happen on. */ |
| 21950 EventTarget _target; |
| 21951 |
| 21952 // The distance to shift from upper case alphabet Roman letters to lower case. |
| 21953 const int _ROMAN_ALPHABET_OFFSET = "a".charCodes[0] - "A".charCodes[0]; |
| 21954 |
| 21955 /** |
| 21956 * An enumeration of key identifiers currently part of the W3C draft for DOM3 |
| 21957 * and their mappings to keyCodes. |
| 21958 * http://www.w3.org/TR/DOM-Level-3-Events/keyset.html#KeySet-Set |
| 21959 */ |
| 21960 static Map<String, int> _keyIdentifier = { |
| 21961 'Up': KeyCode.UP, |
| 21962 'Down': KeyCode.DOWN, |
| 21963 'Left': KeyCode.LEFT, |
| 21964 'Right': KeyCode.RIGHT, |
| 21965 'Enter': KeyCode.ENTER, |
| 21966 'F1': KeyCode.F1, |
| 21967 'F2': KeyCode.F2, |
| 21968 'F3': KeyCode.F3, |
| 21969 'F4': KeyCode.F4, |
| 21970 'F5': KeyCode.F5, |
| 21971 'F6': KeyCode.F6, |
| 21972 'F7': KeyCode.F7, |
| 21973 'F8': KeyCode.F8, |
| 21974 'F9': KeyCode.F9, |
| 21975 'F10': KeyCode.F10, |
| 21976 'F11': KeyCode.F11, |
| 21977 'F12': KeyCode.F12, |
| 21978 'U+007F': KeyCode.DELETE, |
| 21979 'Home': KeyCode.HOME, |
| 21980 'End': KeyCode.END, |
| 21981 'PageUp': KeyCode.PAGE_UP, |
| 21982 'PageDown': KeyCode.PAGE_DOWN, |
| 21983 'Insert': KeyCode.INSERT |
| 21984 }; |
| 21985 |
| 21986 /** Named constructor to add an onKeyPress event listener to our handler. */ |
| 21987 KeyboardEventController.keypress(EventTarget target) { |
| 21988 _KeyboardEventController(target, 'keypress'); |
| 21989 } |
| 21990 |
| 21991 /** Named constructor to add an onKeyUp event listener to our handler. */ |
| 21992 KeyboardEventController.keyup(EventTarget target) { |
| 21993 _KeyboardEventController(target, 'keyup'); |
| 21994 } |
| 21995 |
| 21996 /** Named constructor to add an onKeyDown event listener to our handler. */ |
| 21997 KeyboardEventController.keydown(EventTarget target) { |
| 21998 _KeyboardEventController(target, 'keydown'); |
| 21999 } |
| 22000 |
| 22001 /** |
| 22002 * General constructor, performs basic initialization for our improved |
| 22003 * KeyboardEvent controller. |
| 22004 */ |
| 22005 _KeyboardEventController(EventTarget target, String type) { |
| 22006 _callbacks = []; |
| 22007 _type = type; |
| 22008 _target = target; |
| 22009 _initializeAllEventListeners(); |
| 22010 } |
| 22011 |
| 22012 /** |
| 22013 * Hook up all event listeners under the covers so we can estimate keycodes |
| 22014 * and charcodes when they are not provided. |
| 22015 */ |
| 22016 void _initializeAllEventListeners() { |
| 22017 keyDownList = []; |
| 22018 _target.on.keyDown.add(processKeyDown, true); |
| 22019 _target.on.keyPress.add(processKeyPress, true); |
| 22020 _target.on.keyUp.add(processKeyUp, true); |
| 22021 } |
| 22022 |
| 22023 /** Add a callback that wishes to be notified when a KeyEvent occurs. */ |
| 22024 void add(void callback(KeyEvent)) { |
| 22025 if (_callbacks.length == 0) { |
| 22026 _initializeAllEventListeners(); |
| 22027 } |
| 22028 _callbacks.add(callback); |
| 22029 } |
| 22030 |
| 22031 /** |
| 22032 * Notify all callback listeners that a KeyEvent of the relevant type has |
| 22033 * occurred. |
| 22034 */ |
| 22035 bool _dispatch(KeyEvent event) { |
| 22036 if (event.type == _type) { |
| 22037 // Make a copy of the listeners in case a callback gets removed while |
| 22038 // dispatching from the list. |
| 22039 List callbacksCopy = new List.from(_callbacks); |
| 22040 for(var callback in callbacksCopy) { |
| 22041 callback(event); |
| 22042 } |
| 22043 } |
| 22044 } |
| 22045 |
| 22046 /** Remove the given callback from the listeners list. */ |
| 22047 void remove(void callback(KeyEvent)) { |
| 22048 var index = _callbacks.indexOf(callback); |
| 22049 if (index != -1) { |
| 22050 _callbacks.removeAd(index); |
| 22051 } |
| 22052 if (_callbacks.length == 0) { |
| 22053 // If we have no listeners, don't bother keeping track of keypresses. |
| 22054 target.on.keyDown.remove(processKeyDown); |
| 22055 target.on.keyPress.remove(processKeyPress); |
| 22056 target.on.keyUp.remove(processKeyUp); |
| 22057 } |
| 22058 } |
| 22059 |
| 22060 /** Determine if caps lock is one of the currently depressed keys. */ |
| 22061 bool get _capsLockOn() => |
| 22062 keyDownList.some((var element) => element.keyCode == KeyCode.CAPS_LOCK); |
| 22063 |
| 22064 /** |
| 22065 * Given the previously recorded keydown key codes, see if we can determine |
| 22066 * the keycode of this keypress [event]. (Generally browsers only provide |
| 22067 * charCode information for keypress events, but with a little |
| 22068 * reverse-engineering, we can also determine the keyCode.) Returns |
| 22069 * KeyCode.UNKNOWN if the keycode could not be determined. |
| 22070 */ |
| 22071 int _determineKeyCodeForKeypress(KeyboardEvent event) { |
| 22072 // Note: This function is a work in progress. We'll expand this function |
| 22073 // once we get more information about other keyboards. |
| 22074 for (var prevEvent in keyDownList) { |
| 22075 if (prevEvent._shadowCharCode == event.charCode) { |
| 22076 return prevEvent.keyCode; |
| 22077 } |
| 22078 if ((event.shiftKey || _capsLockOn) && event.charCode >= "A".charCodes[0] |
| 22079 && event.charCode <= "Z".charCodes[0] && event.charCode + |
| 22080 _ROMAN_ALPHABET_OFFSET == prevEvent._shadowCharCode) { |
| 22081 return prevEvent.keyCode; |
| 22082 } |
| 22083 } |
| 22084 return KeyCode.UNKNOWN; |
| 22085 } |
| 22086 |
| 22087 /** |
| 22088 * Given the charater code returned from a keyDown [event], try to ascertain |
| 22089 * and return the corresponding charCode for the character that was pressed. |
| 22090 * This information is not shown to the user, but used to help polyfill |
| 22091 * keypress events. |
| 22092 */ |
| 22093 int _findCharCodeKeyDown(KeyboardEvent event) { |
| 22094 if (event.keyLocation == 3) { // Numpad keys. |
| 22095 switch (event.keyCode) { |
| 22096 case KeyCode.NUM_ZERO: |
| 22097 // Even though this function returns _charCodes_, for some cases the |
| 22098 // KeyCode == the charCode we want, in which case we use the keycode |
| 22099 // constant for readability. |
| 22100 return KeyCode.ZERO; |
| 22101 case KeyCode.NUM_ONE: |
| 22102 return KeyCode.ONE; |
| 22103 case KeyCode.NUM_TWO: |
| 22104 return KeyCode.TWO; |
| 22105 case KeyCode.NUM_THREE: |
| 22106 return KeyCode.THREE; |
| 22107 case KeyCode.NUM_FOUR: |
| 22108 return KeyCode.FOUR; |
| 22109 case KeyCode.NUM_FIVE: |
| 22110 return KeyCode.FIVE; |
| 22111 case KeyCode.NUM_SIX: |
| 22112 return KeyCode.SIX; |
| 22113 case KeyCode.NUM_SEVEN: |
| 22114 return KeyCode.SEVEN; |
| 22115 case KeyCode.NUM_EIGHT: |
| 22116 return KeyCode.EIGHT; |
| 22117 case KeyCode.NUM_NINE: |
| 22118 return KeyCode.NINE; |
| 22119 case KeyCode.NUM_MULTIPLY: |
| 22120 return 42; // Char code for * |
| 22121 case KeyCode.NUM_PLUS: |
| 22122 return 43; // + |
| 22123 case KeyCode.NUM_MINUS: |
| 22124 return 45; // - |
| 22125 case KeyCode.NUM_PERIOD: |
| 22126 return 46; // . |
| 22127 case KeyCode.NUM_DIVISION: |
| 22128 return 47; // / |
| 22129 } |
| 22130 } else if (event.keyCode >= 65 && event.keyCode <= 90) { |
| 22131 // Set the "char code" for key down as the lower case letter. Again, this |
| 22132 // will not show up for the user, but will be helpful in estimating |
| 22133 // keyCode locations and other information during the keyPress event. |
| 22134 return event.keyCode + _ROMAN_ALPHABET_OFFSET; |
| 22135 } |
| 22136 switch(event.keyCode) { |
| 22137 case KeyCode.SEMICOLON: |
| 22138 return KeyCode.FF_SEMICOLON; |
| 22139 case KeyCode.EQUALS: |
| 22140 return KeyCode.FF_EQUALS; |
| 22141 case KeyCode.COMMA: |
| 22142 return 44; // Ascii value for , |
| 22143 case KeyCode.DASH: |
| 22144 return 45; // - |
| 22145 case KeyCode.PERIOD: |
| 22146 return 46; // . |
| 22147 case KeyCode.SLASH: |
| 22148 return 47; // / |
| 22149 case KeyCode.APOSTROPHE: |
| 22150 return 96; // ` |
| 22151 case KeyCode.OPEN_SQUARE_BRACKET: |
| 22152 return 91; // [ |
| 22153 case KeyCode.BACKSLASH: |
| 22154 return 92; // \ |
| 22155 case KeyCode.CLOSE_SQUARE_BRACKET: |
| 22156 return 93; // ] |
| 22157 case KeyCode.SINGLE_QUOTE: |
| 22158 return 39; // ' |
| 22159 } |
| 22160 return event.keyCode; |
| 22161 } |
| 22162 |
| 22163 /** |
| 22164 * Returns true if the key fires a keypress event in the current browser. |
| 22165 */ |
| 22166 bool _firesKeyPressEvent(KeyEvent event) { |
| 22167 if (!_Device.isIE && !_Device.isWebKit) { |
| 22168 return true; |
| 22169 } |
| 22170 |
| 22171 if (_Device.userAgent.contains('Mac') && event.altKey) { |
| 22172 return KeyCode.isCharacterKey(event.keyCode); |
| 22173 } |
| 22174 |
| 22175 // Alt but not AltGr which is represented as Alt+Ctrl. |
| 22176 if (event.altKey && !event.ctrlKey) { |
| 22177 return false; |
| 22178 } |
| 22179 |
| 22180 // Saves Ctrl or Alt + key for IE and WebKit, which won't fire keypress. |
| 22181 if (!event.shiftKey && |
| 22182 (keyDownList.last.keyCode == KeyCode.CTRL || |
| 22183 keyDownList.last.keyCode == KeyCode.ALT || |
| 22184 _Device.userAgent.contains('Mac') && |
| 22185 keyDownList.last.keyCode == KeyCode.META)) { |
| 22186 return false; |
| 22187 } |
| 22188 |
| 22189 // Some keys with Ctrl/Shift do not issue keypress in WebKit. |
| 22190 if (_Device.isWebKit && event.ctrlKey && event.shiftKey && ( |
| 22191 event.keycode == KeyCode.BACKSLASH || |
| 22192 event.keycode == KeyCode.OPEN_SQUARE_BRACKET || |
| 22193 event.keycode == KeyCode.CLOSE_SQUARE_BRACKET || |
| 22194 event.keycode == KeyCode.TILDE || |
| 22195 event.keycode == KeyCode.SEMICOLON || event.keycode == KeyCode.DASH || |
| 22196 event.keycode == KeyCode.EQUALS || event.keycode == KeyCode.COMMA || |
| 22197 event.keycode == KeyCode.PERIOD || event.keycode == KeyCode.SLASH || |
| 22198 event.keycode == KeyCode.APOSTROPHE || |
| 22199 event.keycode == KeyCode.SINGLE_QUOTE)) { |
| 22200 return false; |
| 22201 } |
| 22202 |
| 22203 switch (event.keyCode) { |
| 22204 case KeyCode.ENTER: |
| 22205 // IE9 does not fire keypress on ENTER. |
| 22206 return !_Device.isIE; |
| 22207 case KeyCode.ESC: |
| 22208 return !_Device.isWebKit; |
| 22209 } |
| 22210 |
| 22211 return KeyCode.isCharacterKey(event.keyCode); |
| 22212 } |
| 22213 |
| 22214 /** |
| 22215 * Normalize the keycodes to the IE KeyCodes (this is what Chrome, IE, and |
| 22216 * Opera all use). |
| 22217 */ |
| 22218 int _normalizeKeyCodes(KeyboardEvent event) { |
| 22219 // Note: This may change once we get input about non-US keyboards. |
| 22220 if (_Device.isFirefox) { |
| 22221 switch(event.keyCode) { |
| 22222 case KeyCode.FF_EQUALS: |
| 22223 return KeyCode.EQUALS; |
| 22224 case KeyCode.FF_SEMICOLON: |
| 22225 return KeyCode.SEMICOLON; |
| 22226 case KeyCode.MAC_FF_META: |
| 22227 return KeyCode.META; |
| 22228 case KeyCode.WIN_KEY_FF_LINUX: |
| 22229 return KeyCode.WIN_KEY; |
| 22230 } |
| 22231 } |
| 22232 return event.keyCode; |
| 22233 } |
| 22234 |
| 22235 /** Handle keydown events. */ |
| 22236 void processKeyDown(KeyboardEvent e) { |
| 22237 // Ctrl-Tab and Alt-Tab can cause the focus to be moved to another window |
| 22238 // before we've caught a key-up event. If the last-key was one of these |
| 22239 // we reset the state. |
| 22240 if (keyDownList.length > 0 && |
| 22241 (keyDownList.last.keyCode == KeyCode.CTRL && !e.ctrlKey || |
| 22242 keyDownList.last.keyCode == KeyCode.ALT && !e.altKey || |
| 22243 _Device.userAgent.contains('Mac') && |
| 22244 keyDownList.last.keyCode == KeyCode.META && !e.metaKey)) { |
| 22245 keyDownList = []; |
| 22246 } |
| 22247 |
| 22248 var event = new KeyEvent(e); |
| 22249 event._shadowKeyCode = _normalizeKeyCodes(event); |
| 22250 // Technically a "keydown" event doesn't have a charCode. This is |
| 22251 // calculated nonetheless to provide us with more information in giving |
| 22252 // as much information as possible on keypress about keycode and also |
| 22253 // charCode. |
| 22254 event._shadowCharCode = _findCharCodeKeyDown(event); |
| 22255 if (keyDownList.length > 0 && event.keyCode != keyDownList.last.keyCode && |
| 22256 !_firesKeyPressEvent(event)) { |
| 22257 // Some browsers have quirks not firing keypress events where all other |
| 22258 // browsers do. This makes them more consistent. |
| 22259 processKeyPress(event); |
| 22260 } |
| 22261 keyDownList.add(event); |
| 22262 _dispatch(event); |
| 22263 } |
| 22264 |
| 22265 /** Handle keypress events. */ |
| 22266 void processKeyPress(KeyboardEvent event) { |
| 22267 var e = new KeyEvent(event); |
| 22268 // IE reports the character code in the keyCode field for keypress events. |
| 22269 // There are two exceptions however, Enter and Escape. |
| 22270 if (_Device.isIE) { |
| 22271 if (e.keyCode == KeyCode.ENTER || e.keyCode == KeyCode.ESC) { |
| 22272 e._shadowCharCode = 0; |
| 22273 } else { |
| 22274 e._shadowCharCode = e.keyCode; |
| 22275 } |
| 22276 } else if (_Device.isOpera) { |
| 22277 // Opera reports the character code in the keyCode field. |
| 22278 e._shadowCharCode = KeyCode.isCharacterKey(keyCode) ? e.keyCode : 0; |
| 22279 } |
| 22280 // Now we guestimate about what the keycode is that was actually |
| 22281 // pressed, given previous keydown information. |
| 22282 e._shadowKeyCode = _determineKeyCodeForKeypress(e); |
| 22283 |
| 22284 // Correct the key value for certain browser-specific quirks. |
| 22285 if (e._shadowKeyIdentifier && |
| 22286 _keyIdentifier.contains(e._shadowKeyIdentifier)) { |
| 22287 // This is needed for Safari Windows because it currently doesn't give a |
| 22288 // keyCode/which for non printable keys. |
| 22289 e._shadowKeyCode = _keyIdentifier[keyIdentifier]; |
| 22290 } |
| 22291 e._shadowAltKey = keyDownList.some((var element) => element.altKey); |
| 22292 _dispatch(e); |
| 22293 } |
| 22294 |
| 22295 /** Handle keyup events. */ |
| 22296 void processKeyUp(KeyboardEvent event) { |
| 22297 var e = new KeyEvent(event); |
| 22298 KeyboardEvent toRemove = null; |
| 22299 for (var key in keyDownList) { |
| 22300 if (key.keyCode == e.keyCode) { |
| 22301 toRemove = key; |
| 22302 } |
| 22303 } |
| 22304 if (toRemove != null) { |
| 22305 keyDownList = keyDownList.filter((element) => element != toRemove); |
| 22306 } else if (keyDownList.length > 0) { |
| 22307 // This happens when we've reached some international keyboard case we |
| 22308 // haven't accounted for or we haven't correctly eliminated all browser |
| 22309 // inconsistencies. Filing bugs on when this is reached is welcome! |
| 22310 keyDownList.removeLast(); |
| 22311 } |
| 22312 _dispatch(e); |
| 22313 } |
| 22314 } |
| 22315 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 22316 // for details. All rights reserved. Use of this source code is governed by a |
| 22317 // BSD-style license that can be found in the LICENSE file. |
| 22318 |
| 22319 |
| 22320 /** |
21911 * Defines the keycode values for keys that are returned by | 22321 * Defines the keycode values for keys that are returned by |
21912 * KeyboardEvent.keyCode. | 22322 * KeyboardEvent.keyCode. |
21913 * | 22323 * |
21914 * Important note: There is substantial divergence in how different browsers | 22324 * Important note: There is substantial divergence in how different browsers |
21915 * handle keycodes and their variants in different locales/keyboard layouts. We | 22325 * handle keycodes and their variants in different locales/keyboard layouts. We |
21916 * provide these constants to help make code processing keys more readable. | 22326 * provide these constants to help make code processing keys more readable. |
21917 */ | 22327 */ |
21918 abstract class KeyCode { | 22328 abstract class KeyCode { |
21919 // These constant names were borrowed from Closure's Keycode enumeration | 22329 // These constant names were borrowed from Closure's Keycode enumeration |
21920 // class. | 22330 // class. |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
22091 */ | 22501 */ |
22092 static const int BACKSLASH = 220; | 22502 static const int BACKSLASH = 220; |
22093 /** | 22503 /** |
22094 * CAUTION: This constant requires localization for other locales and keyboard | 22504 * CAUTION: This constant requires localization for other locales and keyboard |
22095 * layouts. | 22505 * layouts. |
22096 */ | 22506 */ |
22097 static const int CLOSE_SQUARE_BRACKET = 221; | 22507 static const int CLOSE_SQUARE_BRACKET = 221; |
22098 static const int WIN_KEY = 224; | 22508 static const int WIN_KEY = 224; |
22099 static const int MAC_FF_META = 224; | 22509 static const int MAC_FF_META = 224; |
22100 static const int WIN_IME = 229; | 22510 static const int WIN_IME = 229; |
| 22511 |
| 22512 /** A sentinel value if the keycode could not be determined. */ |
| 22513 static const int UNKNOWN = -1; |
| 22514 |
| 22515 /** |
| 22516 * Returns true if the keyCode produces a (US keyboard) character. |
| 22517 * Note: This does not (yet) cover characters on non-US keyboards (Russian, |
| 22518 * Hebrew, etc.). |
| 22519 */ |
| 22520 static bool isCharacterKey(int keyCode) { |
| 22521 if ((keyCode >= ZERO && keyCode <= NINE) || |
| 22522 (keyCode >= NUM_ZERO && keyCode <= NUM_MULTIPLY) || |
| 22523 (keyCode >= A && keyCode <= Z)) { |
| 22524 return true; |
| 22525 } |
| 22526 |
| 22527 // Safari sends zero key code for non-latin characters. |
| 22528 if (_Device.isWebKit && keyCode == 0) { |
| 22529 return true; |
| 22530 } |
| 22531 |
| 22532 return (keyCode == SPACE || keyCode == QUESTION_MARK || keyCode == NUM_PLUS |
| 22533 || keyCode == NUM_MINUS || keyCode == NUM_PERIOD || |
| 22534 keyCode == NUM_DIVISION || keyCode == SEMICOLON || |
| 22535 keyCode == FF_SEMICOLON || keyCode == DASH || keyCode == EQUALS || |
| 22536 keyCode == FF_EQUALS || keyCode == COMMA || keyCode == PERIOD || |
| 22537 keyCode == SLASH || keyCode == APOSTROPHE || keyCode == SINGLE_QUOTE || |
| 22538 keyCode == OPEN_SQUARE_BRACKET || keyCode == BACKSLASH || |
| 22539 keyCode == CLOSE_SQUARE_BRACKET); |
| 22540 } |
22101 } | 22541 } |
22102 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 22542 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
22103 // for details. All rights reserved. Use of this source code is governed by a | 22543 // for details. All rights reserved. Use of this source code is governed by a |
22104 // BSD-style license that can be found in the LICENSE file. | 22544 // BSD-style license that can be found in the LICENSE file. |
22105 | 22545 |
22106 | 22546 |
22107 /** | 22547 /** |
22108 * Defines the standard key locations returned by | 22548 * Defines the standard key locations returned by |
22109 * KeyboardEvent.getKeyLocation. | 22549 * KeyboardEvent.getKeyLocation. |
22110 */ | 22550 */ |
(...skipping 1913 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
24024 | 24464 |
24025 static History _createSafe(h) { | 24465 static History _createSafe(h) { |
24026 if (identical(h, window.history)) { | 24466 if (identical(h, window.history)) { |
24027 return h; | 24467 return h; |
24028 } else { | 24468 } else { |
24029 // TODO(vsm): Cache or implement equality. | 24469 // TODO(vsm): Cache or implement equality. |
24030 return new _HistoryCrossFrame(h); | 24470 return new _HistoryCrossFrame(h); |
24031 } | 24471 } |
24032 } | 24472 } |
24033 } | 24473 } |
| 24474 /** |
| 24475 * A custom KeyboardEvent that attempts to eliminate cross-browser |
| 24476 * inconsistencies, and also provide both keyCode and charCode information |
| 24477 * for all key events (when such information can be determined). |
| 24478 * |
| 24479 * This class is very much a work in progress, and we'd love to get information |
| 24480 * on how we can make this class work with as many international keyboards as |
| 24481 * possible. Bugs welcome! |
| 24482 */ |
| 24483 class KeyEvent implements KeyboardEvent { |
| 24484 /** The parent KeyboardEvent that this KeyEvent is wrapping and "fixing". */ |
| 24485 KeyboardEvent _parent; |
| 24486 |
| 24487 /** The "fixed" value of whether the alt key is being pressed. */ |
| 24488 bool _shadowAltKey; |
| 24489 |
| 24490 /** Caculated value of what the estimated charCode is for this event. */ |
| 24491 int _shadowCharCode; |
| 24492 |
| 24493 /** Caculated value of what the estimated keyCode is for this event. */ |
| 24494 int _shadowKeyCode; |
| 24495 |
| 24496 /** Caculated value of what the estimated keyCode is for this event. */ |
| 24497 int get keyCode => _shadowKeyCode; |
| 24498 |
| 24499 /** Caculated value of what the estimated charCode is for this event. */ |
| 24500 int get charCode => this.type == 'keypress' ? _shadowCharCode : 0; |
| 24501 |
| 24502 /** Caculated value of whether the alt key is pressed is for this event. */ |
| 24503 bool get altKey => _shadowAltKey; |
| 24504 |
| 24505 /** Caculated value of what the estimated keyCode is for this event. */ |
| 24506 int get which => keyCode; |
| 24507 |
| 24508 /** Accessor to the underlying keyCode value is the parent event. */ |
| 24509 int get _realKeyCode => JS('int', '#.keyCode', _parent); |
| 24510 |
| 24511 /** Accessor to the underlying charCode value is the parent event. */ |
| 24512 int get _realCharCode => JS('int', '#.charCode', _parent); |
| 24513 |
| 24514 /** Accessor to the underlying altKey value is the parent event. */ |
| 24515 bool get _realAltKey => JS('int', '#.altKey', _parent); |
| 24516 |
| 24517 /** Construct a KeyEvent with [parent] as event we're emulating. */ |
| 24518 KeyEvent(KeyboardEvent parent) { |
| 24519 _parent = parent; |
| 24520 _shadowAltKey = _realAltKey; |
| 24521 _shadowCharCode = _realCharCode; |
| 24522 _shadowKeyCode = _realKeyCode; |
| 24523 } |
| 24524 |
| 24525 /** True if the altGraphKey is pressed during this event. */ |
| 24526 bool get altGraphKey => _parent.altGraphKey; |
| 24527 bool get bubbles => _parent.bubbles; |
| 24528 /** True if this event can be cancelled. */ |
| 24529 bool get cancelable => _parent.cancelable; |
| 24530 bool get cancelBubble => _parent.cancelBubble; |
| 24531 set cancelBubble(bool cancel) => _parent = cancel; |
| 24532 /** Accessor to the clipboardData available for this event. */ |
| 24533 Clipboard get clipboardData => _parent.clipboardData; |
| 24534 /** True if the ctrl key is pressed during this event. */ |
| 24535 bool get ctrlKey => _parent.ctrlKey; |
| 24536 /** Accessor to the target this event is listening to for changes. */ |
| 24537 EventTarget get currentTarget => _parent.currentTarget; |
| 24538 bool get defaultPrevented => _parent.defaultPrevented; |
| 24539 int get detail => _parent.detail; |
| 24540 int get eventPhase => _parent.eventPhase; |
| 24541 /** |
| 24542 * Accessor to the part of the keyboard that the key was pressed from (one of |
| 24543 * KeyLocation.STANDARD, KeyLocation.RIGHT, KeyLocation.LEFT, |
| 24544 * KeyLocation.NUMPAD, KeyLocation.MOBILE, KeyLocation.JOYSTICK). |
| 24545 */ |
| 24546 int get keyLocation => _parent.keyLocation; |
| 24547 int get layerX => _parent.layerX; |
| 24548 int get layerY => _parent.layerY; |
| 24549 /** True if the Meta (or Mac command) key is pressed during this event. */ |
| 24550 bool get metaKey => _parent.metaKey; |
| 24551 int get pageX => _parent.pageX; |
| 24552 int get pageY => _parent.pageY; |
| 24553 bool get returnValue => _parent.returnValue; |
| 24554 set returnValue(bool value) => _parent = value; |
| 24555 /** True if the shift key was pressed during this event. */ |
| 24556 bool get shiftKey => _parent.shiftKey; |
| 24557 int get timeStamp => _parent.timeStamp; |
| 24558 /** |
| 24559 * The type of key event that occurred. One of "keydown", "keyup", or |
| 24560 * "keypress". |
| 24561 */ |
| 24562 String get type => _parent.type; |
| 24563 Window get view => _parent.view; |
| 24564 void preventDefault() => _parent.preventDefault(); |
| 24565 void stopImmediatePropagation() => _parent.stopImmediatePropagation(); |
| 24566 void stopPropagation() => _parent.stopPropagation(); |
| 24567 void $dom_initUIEvent(String type, bool canBubble, bool cancelable, |
| 24568 LocalWindow view, int detail) { |
| 24569 throw new UnsupportedError("Cannot initialize a UI Event from a KeyEvent."); |
| 24570 } |
| 24571 void $dom_initEvent(String eventTypeArg, bool canBubbleArg, |
| 24572 bool cancelableArg) { |
| 24573 throw new UnsupportedError("Cannot initialize an Event from a KeyEvent."); |
| 24574 } |
| 24575 String get _shadowKeyIdentifier => JS('String', '#.keyIdentifier', _parent); |
| 24576 } |
24034 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 24577 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
24035 // for details. All rights reserved. Use of this source code is governed by a | 24578 // for details. All rights reserved. Use of this source code is governed by a |
24036 // BSD-style license that can be found in the LICENSE file. | 24579 // BSD-style license that can be found in the LICENSE file. |
24037 | 24580 |
24038 | 24581 |
24039 class _PointFactoryProvider { | 24582 class _PointFactoryProvider { |
24040 static Point createPoint(num x, num y) => | 24583 static Point createPoint(num x, num y) => |
24041 JS('Point', 'new WebKitPoint(#, #)', x, y); | 24584 JS('Point', 'new WebKitPoint(#, #)', x, y); |
24042 } | 24585 } |
24043 | 24586 |
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
24459 if (length < 0) throw new ArgumentError('length'); | 25002 if (length < 0) throw new ArgumentError('length'); |
24460 if (start < 0) throw new RangeError.value(start); | 25003 if (start < 0) throw new RangeError.value(start); |
24461 int end = start + length; | 25004 int end = start + length; |
24462 if (end > a.length) throw new RangeError.value(end); | 25005 if (end > a.length) throw new RangeError.value(end); |
24463 for (int i = start; i < end; i++) { | 25006 for (int i = start; i < end; i++) { |
24464 accumulator.add(a[i]); | 25007 accumulator.add(a[i]); |
24465 } | 25008 } |
24466 return accumulator; | 25009 return accumulator; |
24467 } | 25010 } |
24468 } | 25011 } |
OLD | NEW |