Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(412)

Side by Side Diff: sdk/lib/html/dart2js/html_dart2js.dart

Issue 11416249: Make KeyboardEvent cross-browser consistent. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: moved instance variables to constructor Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | sdk/lib/html/dartium/html_dartium.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
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
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
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
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
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
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
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 // Instance members referring to the internal event handlers because closures
21956 // are not hashable.
21957 var _keyUp, _keyDown, _keyPress;
21958
21959 /**
21960 * An enumeration of key identifiers currently part of the W3C draft for DOM3
21961 * and their mappings to keyCodes.
21962 * http://www.w3.org/TR/DOM-Level-3-Events/keyset.html#KeySet-Set
21963 */
21964 static Map<String, int> _keyIdentifier = {
21965 'Up': KeyCode.UP,
21966 'Down': KeyCode.DOWN,
21967 'Left': KeyCode.LEFT,
21968 'Right': KeyCode.RIGHT,
21969 'Enter': KeyCode.ENTER,
21970 'F1': KeyCode.F1,
21971 'F2': KeyCode.F2,
21972 'F3': KeyCode.F3,
21973 'F4': KeyCode.F4,
21974 'F5': KeyCode.F5,
21975 'F6': KeyCode.F6,
21976 'F7': KeyCode.F7,
21977 'F8': KeyCode.F8,
21978 'F9': KeyCode.F9,
21979 'F10': KeyCode.F10,
21980 'F11': KeyCode.F11,
21981 'F12': KeyCode.F12,
21982 'U+007F': KeyCode.DELETE,
21983 'Home': KeyCode.HOME,
21984 'End': KeyCode.END,
21985 'PageUp': KeyCode.PAGE_UP,
21986 'PageDown': KeyCode.PAGE_DOWN,
21987 'Insert': KeyCode.INSERT
21988 };
21989
21990 /** Named constructor to add an onKeyPress event listener to our handler. */
21991 KeyboardEventController.keypress(EventTarget target) {
21992 _KeyboardEventController(target, 'keypress');
21993 }
21994
21995 /** Named constructor to add an onKeyUp event listener to our handler. */
21996 KeyboardEventController.keyup(EventTarget target) {
21997 _KeyboardEventController(target, 'keyup');
21998 }
21999
22000 /** Named constructor to add an onKeyDown event listener to our handler. */
22001 KeyboardEventController.keydown(EventTarget target) {
22002 _KeyboardEventController(target, 'keydown');
22003 }
22004
22005 /**
22006 * General constructor, performs basic initialization for our improved
22007 * KeyboardEvent controller.
22008 */
22009 _KeyboardEventController(EventTarget target, String type) {
22010 _callbacks = [];
22011 _type = type;
22012 _target = target;
22013 _keyDown = processKeyDown;
22014 _keyUp = processKeyUp;
22015 _keyPress = processKeyPress;
22016 }
22017
22018 /**
22019 * Hook up all event listeners under the covers so we can estimate keycodes
22020 * and charcodes when they are not provided.
22021 */
22022 void _initializeAllEventListeners() {
22023 _keyDownList = [];
22024 _target.on.keyDown.add(_keyDown, true);
22025 _target.on.keyPress.add(_keyPress, true);
22026 _target.on.keyUp.add(_keyUp, true);
22027 }
22028
22029 /** Add a callback that wishes to be notified when a KeyEvent occurs. */
22030 void add(void callback(KeyEvent)) {
22031 if (_callbacks.length == 0) {
22032 _initializeAllEventListeners();
22033 }
22034 _callbacks.add(callback);
22035 }
22036
22037 /**
22038 * Notify all callback listeners that a KeyEvent of the relevant type has
22039 * occurred.
22040 */
22041 bool _dispatch(KeyEvent event) {
22042 if (event.type == _type) {
22043 // Make a copy of the listeners in case a callback gets removed while
22044 // dispatching from the list.
22045 List callbacksCopy = new List.from(_callbacks);
22046 for(var callback in callbacksCopy) {
22047 callback(event);
22048 }
22049 }
22050 }
22051
22052 /** Remove the given callback from the listeners list. */
22053 void remove(void callback(KeyEvent)) {
22054 var index = _callbacks.indexOf(callback);
22055 if (index != -1) {
22056 _callbacks.removeAt(index);
22057 }
22058 if (_callbacks.length == 0) {
22059 // If we have no listeners, don't bother keeping track of keypresses.
22060 _target.on.keyDown.remove(_keyDown);
22061 _target.on.keyPress.remove(_keyPress);
22062 _target.on.keyUp.remove(_keyUp);
22063 }
22064 }
22065
22066 /** Determine if caps lock is one of the currently depressed keys. */
22067 bool get _capsLockOn() =>
22068 _keyDownList.some((var element) => element.keyCode == KeyCode.CAPS_LOCK);
22069
22070 /**
22071 * Given the previously recorded keydown key codes, see if we can determine
22072 * the keycode of this keypress [event]. (Generally browsers only provide
22073 * charCode information for keypress events, but with a little
22074 * reverse-engineering, we can also determine the keyCode.) Returns
22075 * KeyCode.UNKNOWN if the keycode could not be determined.
22076 */
22077 int _determineKeyCodeForKeypress(KeyboardEvent event) {
22078 // Note: This function is a work in progress. We'll expand this function
22079 // once we get more information about other keyboards.
22080 for (var prevEvent in _keyDownList) {
22081 if (prevEvent._shadowCharCode == event.charCode) {
22082 return prevEvent.keyCode;
22083 }
22084 if ((event.shiftKey || _capsLockOn) && event.charCode >= "A".charCodes[0]
22085 && event.charCode <= "Z".charCodes[0] && event.charCode +
22086 _ROMAN_ALPHABET_OFFSET == prevEvent._shadowCharCode) {
22087 return prevEvent.keyCode;
22088 }
22089 }
22090 return KeyCode.UNKNOWN;
22091 }
22092
22093 /**
22094 * Given the charater code returned from a keyDown [event], try to ascertain
22095 * and return the corresponding charCode for the character that was pressed.
22096 * This information is not shown to the user, but used to help polyfill
22097 * keypress events.
22098 */
22099 int _findCharCodeKeyDown(KeyboardEvent event) {
22100 if (event.keyLocation == 3) { // Numpad keys.
22101 switch (event.keyCode) {
22102 case KeyCode.NUM_ZERO:
22103 // Even though this function returns _charCodes_, for some cases the
22104 // KeyCode == the charCode we want, in which case we use the keycode
22105 // constant for readability.
22106 return KeyCode.ZERO;
22107 case KeyCode.NUM_ONE:
22108 return KeyCode.ONE;
22109 case KeyCode.NUM_TWO:
22110 return KeyCode.TWO;
22111 case KeyCode.NUM_THREE:
22112 return KeyCode.THREE;
22113 case KeyCode.NUM_FOUR:
22114 return KeyCode.FOUR;
22115 case KeyCode.NUM_FIVE:
22116 return KeyCode.FIVE;
22117 case KeyCode.NUM_SIX:
22118 return KeyCode.SIX;
22119 case KeyCode.NUM_SEVEN:
22120 return KeyCode.SEVEN;
22121 case KeyCode.NUM_EIGHT:
22122 return KeyCode.EIGHT;
22123 case KeyCode.NUM_NINE:
22124 return KeyCode.NINE;
22125 case KeyCode.NUM_MULTIPLY:
22126 return 42; // Char code for *
22127 case KeyCode.NUM_PLUS:
22128 return 43; // +
22129 case KeyCode.NUM_MINUS:
22130 return 45; // -
22131 case KeyCode.NUM_PERIOD:
22132 return 46; // .
22133 case KeyCode.NUM_DIVISION:
22134 return 47; // /
22135 }
22136 } else if (event.keyCode >= 65 && event.keyCode <= 90) {
22137 // Set the "char code" for key down as the lower case letter. Again, this
22138 // will not show up for the user, but will be helpful in estimating
22139 // keyCode locations and other information during the keyPress event.
22140 return event.keyCode + _ROMAN_ALPHABET_OFFSET;
22141 }
22142 switch(event.keyCode) {
22143 case KeyCode.SEMICOLON:
22144 return KeyCode.FF_SEMICOLON;
22145 case KeyCode.EQUALS:
22146 return KeyCode.FF_EQUALS;
22147 case KeyCode.COMMA:
22148 return 44; // Ascii value for ,
22149 case KeyCode.DASH:
22150 return 45; // -
22151 case KeyCode.PERIOD:
22152 return 46; // .
22153 case KeyCode.SLASH:
22154 return 47; // /
22155 case KeyCode.APOSTROPHE:
22156 return 96; // `
22157 case KeyCode.OPEN_SQUARE_BRACKET:
22158 return 91; // [
22159 case KeyCode.BACKSLASH:
22160 return 92; // \
22161 case KeyCode.CLOSE_SQUARE_BRACKET:
22162 return 93; // ]
22163 case KeyCode.SINGLE_QUOTE:
22164 return 39; // '
22165 }
22166 return event.keyCode;
22167 }
22168
22169 /**
22170 * Returns true if the key fires a keypress event in the current browser.
22171 */
22172 bool _firesKeyPressEvent(KeyEvent event) {
22173 if (!_Device.isIE && !_Device.isWebKit) {
22174 return true;
22175 }
22176
22177 if (_Device.userAgent.contains('Mac') && event.altKey) {
22178 return KeyCode.isCharacterKey(event.keyCode);
22179 }
22180
22181 // Alt but not AltGr which is represented as Alt+Ctrl.
22182 if (event.altKey && !event.ctrlKey) {
22183 return false;
22184 }
22185
22186 // Saves Ctrl or Alt + key for IE and WebKit, which won't fire keypress.
22187 if (!event.shiftKey &&
22188 (_keyDownList.last.keyCode == KeyCode.CTRL ||
22189 _keyDownList.last.keyCode == KeyCode.ALT ||
22190 _Device.userAgent.contains('Mac') &&
22191 _keyDownList.last.keyCode == KeyCode.META)) {
22192 return false;
22193 }
22194
22195 // Some keys with Ctrl/Shift do not issue keypress in WebKit.
22196 if (_Device.isWebKit && event.ctrlKey && event.shiftKey && (
22197 event.keycode == KeyCode.BACKSLASH ||
22198 event.keycode == KeyCode.OPEN_SQUARE_BRACKET ||
22199 event.keycode == KeyCode.CLOSE_SQUARE_BRACKET ||
22200 event.keycode == KeyCode.TILDE ||
22201 event.keycode == KeyCode.SEMICOLON || event.keycode == KeyCode.DASH ||
22202 event.keycode == KeyCode.EQUALS || event.keycode == KeyCode.COMMA ||
22203 event.keycode == KeyCode.PERIOD || event.keycode == KeyCode.SLASH ||
22204 event.keycode == KeyCode.APOSTROPHE ||
22205 event.keycode == KeyCode.SINGLE_QUOTE)) {
22206 return false;
22207 }
22208
22209 switch (event.keyCode) {
22210 case KeyCode.ENTER:
22211 // IE9 does not fire keypress on ENTER.
22212 return !_Device.isIE;
22213 case KeyCode.ESC:
22214 return !_Device.isWebKit;
22215 }
22216
22217 return KeyCode.isCharacterKey(event.keyCode);
22218 }
22219
22220 /**
22221 * Normalize the keycodes to the IE KeyCodes (this is what Chrome, IE, and
22222 * Opera all use).
22223 */
22224 int _normalizeKeyCodes(KeyboardEvent event) {
22225 // Note: This may change once we get input about non-US keyboards.
22226 if (_Device.isFirefox) {
22227 switch(event.keyCode) {
22228 case KeyCode.FF_EQUALS:
22229 return KeyCode.EQUALS;
22230 case KeyCode.FF_SEMICOLON:
22231 return KeyCode.SEMICOLON;
22232 case KeyCode.MAC_FF_META:
22233 return KeyCode.META;
22234 case KeyCode.WIN_KEY_FF_LINUX:
22235 return KeyCode.WIN_KEY;
22236 }
22237 }
22238 return event.keyCode;
22239 }
22240
22241 /** Handle keydown events. */
22242 void processKeyDown(KeyboardEvent e) {
22243 // Ctrl-Tab and Alt-Tab can cause the focus to be moved to another window
22244 // before we've caught a key-up event. If the last-key was one of these
22245 // we reset the state.
22246 if (_keyDownList.length > 0 &&
22247 (_keyDownList.last.keyCode == KeyCode.CTRL && !e.ctrlKey ||
22248 _keyDownList.last.keyCode == KeyCode.ALT && !e.altKey ||
22249 _Device.userAgent.contains('Mac') &&
22250 _keyDownList.last.keyCode == KeyCode.META && !e.metaKey)) {
22251 _keyDownList = [];
22252 }
22253
22254 var event = new KeyEvent(e);
22255 event._shadowKeyCode = _normalizeKeyCodes(event);
22256 // Technically a "keydown" event doesn't have a charCode. This is
22257 // calculated nonetheless to provide us with more information in giving
22258 // as much information as possible on keypress about keycode and also
22259 // charCode.
22260 event._shadowCharCode = _findCharCodeKeyDown(event);
22261 if (_keyDownList.length > 0 && event.keyCode != _keyDownList.last.keyCode &&
22262 !_firesKeyPressEvent(event)) {
22263 // Some browsers have quirks not firing keypress events where all other
22264 // browsers do. This makes them more consistent.
22265 processKeyPress(event);
22266 }
22267 _keyDownList.add(event);
22268 _dispatch(event);
22269 }
22270
22271 /** Handle keypress events. */
22272 void processKeyPress(KeyboardEvent event) {
22273 var e = new KeyEvent(event);
22274 // IE reports the character code in the keyCode field for keypress events.
22275 // There are two exceptions however, Enter and Escape.
22276 if (_Device.isIE) {
22277 if (e.keyCode == KeyCode.ENTER || e.keyCode == KeyCode.ESC) {
22278 e._shadowCharCode = 0;
22279 } else {
22280 e._shadowCharCode = e.keyCode;
22281 }
22282 } else if (_Device.isOpera) {
22283 // Opera reports the character code in the keyCode field.
22284 e._shadowCharCode = KeyCode.isCharacterKey(keyCode) ? e.keyCode : 0;
22285 }
22286 // Now we guestimate about what the keycode is that was actually
22287 // pressed, given previous keydown information.
22288 e._shadowKeyCode = _determineKeyCodeForKeypress(e);
22289
22290 // Correct the key value for certain browser-specific quirks.
22291 if (e._shadowKeyIdentifier &&
22292 _keyIdentifier.contains(e._shadowKeyIdentifier)) {
22293 // This is needed for Safari Windows because it currently doesn't give a
22294 // keyCode/which for non printable keys.
22295 e._shadowKeyCode = _keyIdentifier[keyIdentifier];
22296 }
22297 e._shadowAltKey = _keyDownList.some((var element) => element.altKey);
22298 _dispatch(e);
22299 }
22300
22301 /** Handle keyup events. */
22302 void processKeyUp(KeyboardEvent event) {
22303 var e = new KeyEvent(event);
22304 KeyboardEvent toRemove = null;
22305 for (var key in _keyDownList) {
22306 if (key.keyCode == e.keyCode) {
22307 toRemove = key;
22308 }
22309 }
22310 if (toRemove != null) {
22311 _keyDownList = _keyDownList.filter((element) => element != toRemove);
22312 } else if (_keyDownList.length > 0) {
22313 // This happens when we've reached some international keyboard case we
22314 // haven't accounted for or we haven't correctly eliminated all browser
22315 // inconsistencies. Filing bugs on when this is reached is welcome!
22316 _keyDownList.removeLast();
22317 }
22318 _dispatch(e);
22319 }
22320 }
22321 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
22322 // for details. All rights reserved. Use of this source code is governed by a
22323 // BSD-style license that can be found in the LICENSE file.
22324
22325
22326 /**
21911 * Defines the keycode values for keys that are returned by 22327 * Defines the keycode values for keys that are returned by
21912 * KeyboardEvent.keyCode. 22328 * KeyboardEvent.keyCode.
21913 * 22329 *
21914 * Important note: There is substantial divergence in how different browsers 22330 * Important note: There is substantial divergence in how different browsers
21915 * handle keycodes and their variants in different locales/keyboard layouts. We 22331 * handle keycodes and their variants in different locales/keyboard layouts. We
21916 * provide these constants to help make code processing keys more readable. 22332 * provide these constants to help make code processing keys more readable.
21917 */ 22333 */
21918 abstract class KeyCode { 22334 abstract class KeyCode {
21919 // These constant names were borrowed from Closure's Keycode enumeration 22335 // These constant names were borrowed from Closure's Keycode enumeration
21920 // class. 22336 // class.
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
22091 */ 22507 */
22092 static const int BACKSLASH = 220; 22508 static const int BACKSLASH = 220;
22093 /** 22509 /**
22094 * CAUTION: This constant requires localization for other locales and keyboard 22510 * CAUTION: This constant requires localization for other locales and keyboard
22095 * layouts. 22511 * layouts.
22096 */ 22512 */
22097 static const int CLOSE_SQUARE_BRACKET = 221; 22513 static const int CLOSE_SQUARE_BRACKET = 221;
22098 static const int WIN_KEY = 224; 22514 static const int WIN_KEY = 224;
22099 static const int MAC_FF_META = 224; 22515 static const int MAC_FF_META = 224;
22100 static const int WIN_IME = 229; 22516 static const int WIN_IME = 229;
22517
22518 /** A sentinel value if the keycode could not be determined. */
22519 static const int UNKNOWN = -1;
22520
22521 /**
22522 * Returns true if the keyCode produces a (US keyboard) character.
22523 * Note: This does not (yet) cover characters on non-US keyboards (Russian,
22524 * Hebrew, etc.).
22525 */
22526 static bool isCharacterKey(int keyCode) {
22527 if ((keyCode >= ZERO && keyCode <= NINE) ||
22528 (keyCode >= NUM_ZERO && keyCode <= NUM_MULTIPLY) ||
22529 (keyCode >= A && keyCode <= Z)) {
22530 return true;
22531 }
22532
22533 // Safari sends zero key code for non-latin characters.
22534 if (_Device.isWebKit && keyCode == 0) {
22535 return true;
22536 }
22537
22538 return (keyCode == SPACE || keyCode == QUESTION_MARK || keyCode == NUM_PLUS
22539 || keyCode == NUM_MINUS || keyCode == NUM_PERIOD ||
22540 keyCode == NUM_DIVISION || keyCode == SEMICOLON ||
22541 keyCode == FF_SEMICOLON || keyCode == DASH || keyCode == EQUALS ||
22542 keyCode == FF_EQUALS || keyCode == COMMA || keyCode == PERIOD ||
22543 keyCode == SLASH || keyCode == APOSTROPHE || keyCode == SINGLE_QUOTE ||
22544 keyCode == OPEN_SQUARE_BRACKET || keyCode == BACKSLASH ||
22545 keyCode == CLOSE_SQUARE_BRACKET);
22546 }
22101 } 22547 }
22102 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 22548 // 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 22549 // 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. 22550 // BSD-style license that can be found in the LICENSE file.
22105 22551
22106 22552
22107 /** 22553 /**
22108 * Defines the standard key locations returned by 22554 * Defines the standard key locations returned by
22109 * KeyboardEvent.getKeyLocation. 22555 * KeyboardEvent.getKeyLocation.
22110 */ 22556 */
(...skipping 1913 matching lines...) Expand 10 before | Expand all | Expand 10 after
24024 24470
24025 static History _createSafe(h) { 24471 static History _createSafe(h) {
24026 if (identical(h, window.history)) { 24472 if (identical(h, window.history)) {
24027 return h; 24473 return h;
24028 } else { 24474 } else {
24029 // TODO(vsm): Cache or implement equality. 24475 // TODO(vsm): Cache or implement equality.
24030 return new _HistoryCrossFrame(h); 24476 return new _HistoryCrossFrame(h);
24031 } 24477 }
24032 } 24478 }
24033 } 24479 }
24480 /**
24481 * A custom KeyboardEvent that attempts to eliminate cross-browser
24482 * inconsistencies, and also provide both keyCode and charCode information
24483 * for all key events (when such information can be determined).
24484 *
24485 * This class is very much a work in progress, and we'd love to get information
24486 * on how we can make this class work with as many international keyboards as
24487 * possible. Bugs welcome!
24488 */
24489 class KeyEvent implements KeyboardEvent {
24490 /** The parent KeyboardEvent that this KeyEvent is wrapping and "fixing". */
24491 KeyboardEvent _parent;
24492
24493 /** The "fixed" value of whether the alt key is being pressed. */
24494 bool _shadowAltKey;
24495
24496 /** Caculated value of what the estimated charCode is for this event. */
24497 int _shadowCharCode;
24498
24499 /** Caculated value of what the estimated keyCode is for this event. */
24500 int _shadowKeyCode;
24501
24502 /** Caculated value of what the estimated keyCode is for this event. */
24503 int get keyCode => _shadowKeyCode;
24504
24505 /** Caculated value of what the estimated charCode is for this event. */
24506 int get charCode => this.type == 'keypress' ? _shadowCharCode : 0;
24507
24508 /** Caculated value of whether the alt key is pressed is for this event. */
24509 bool get altKey => _shadowAltKey;
24510
24511 /** Caculated value of what the estimated keyCode is for this event. */
24512 int get which => keyCode;
24513
24514 /** Accessor to the underlying keyCode value is the parent event. */
24515 int get _realKeyCode => JS('int', '#.keyCode', _parent);
24516
24517 /** Accessor to the underlying charCode value is the parent event. */
24518 int get _realCharCode => JS('int', '#.charCode', _parent);
24519
24520 /** Accessor to the underlying altKey value is the parent event. */
24521 bool get _realAltKey => JS('int', '#.altKey', _parent);
24522
24523 /** Construct a KeyEvent with [parent] as event we're emulating. */
24524 KeyEvent(KeyboardEvent parent) {
24525 _parent = parent;
24526 _shadowAltKey = _realAltKey;
24527 _shadowCharCode = _realCharCode;
24528 _shadowKeyCode = _realKeyCode;
24529 }
24530
24531 /** True if the altGraphKey is pressed during this event. */
24532 bool get altGraphKey => _parent.altGraphKey;
24533 bool get bubbles => _parent.bubbles;
24534 /** True if this event can be cancelled. */
24535 bool get cancelable => _parent.cancelable;
24536 bool get cancelBubble => _parent.cancelBubble;
24537 set cancelBubble(bool cancel) => _parent = cancel;
24538 /** Accessor to the clipboardData available for this event. */
24539 Clipboard get clipboardData => _parent.clipboardData;
24540 /** True if the ctrl key is pressed during this event. */
24541 bool get ctrlKey => _parent.ctrlKey;
24542 /** Accessor to the target this event is listening to for changes. */
24543 EventTarget get currentTarget => _parent.currentTarget;
24544 bool get defaultPrevented => _parent.defaultPrevented;
24545 int get detail => _parent.detail;
24546 int get eventPhase => _parent.eventPhase;
24547 /**
24548 * Accessor to the part of the keyboard that the key was pressed from (one of
24549 * KeyLocation.STANDARD, KeyLocation.RIGHT, KeyLocation.LEFT,
24550 * KeyLocation.NUMPAD, KeyLocation.MOBILE, KeyLocation.JOYSTICK).
24551 */
24552 int get keyLocation => _parent.keyLocation;
24553 int get layerX => _parent.layerX;
24554 int get layerY => _parent.layerY;
24555 /** True if the Meta (or Mac command) key is pressed during this event. */
24556 bool get metaKey => _parent.metaKey;
24557 int get pageX => _parent.pageX;
24558 int get pageY => _parent.pageY;
24559 bool get returnValue => _parent.returnValue;
24560 set returnValue(bool value) => _parent = value;
24561 /** True if the shift key was pressed during this event. */
24562 bool get shiftKey => _parent.shiftKey;
24563 int get timeStamp => _parent.timeStamp;
24564 /**
24565 * The type of key event that occurred. One of "keydown", "keyup", or
24566 * "keypress".
24567 */
24568 String get type => _parent.type;
24569 Window get view => _parent.view;
24570 void preventDefault() => _parent.preventDefault();
24571 void stopImmediatePropagation() => _parent.stopImmediatePropagation();
24572 void stopPropagation() => _parent.stopPropagation();
24573 void $dom_initUIEvent(String type, bool canBubble, bool cancelable,
24574 LocalWindow view, int detail) {
24575 throw new UnsupportedError("Cannot initialize a UI Event from a KeyEvent.");
24576 }
24577 void $dom_initEvent(String eventTypeArg, bool canBubbleArg,
24578 bool cancelableArg) {
24579 throw new UnsupportedError("Cannot initialize an Event from a KeyEvent.");
24580 }
24581 String get _shadowKeyIdentifier => JS('String', '#.keyIdentifier', _parent);
24582 }
24034 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 24583 // 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 24584 // 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. 24585 // BSD-style license that can be found in the LICENSE file.
24037 24586
24038 24587
24039 class _PointFactoryProvider { 24588 class _PointFactoryProvider {
24040 static Point createPoint(num x, num y) => 24589 static Point createPoint(num x, num y) =>
24041 JS('Point', 'new WebKitPoint(#, #)', x, y); 24590 JS('Point', 'new WebKitPoint(#, #)', x, y);
24042 } 24591 }
24043 24592
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after
24459 if (length < 0) throw new ArgumentError('length'); 25008 if (length < 0) throw new ArgumentError('length');
24460 if (start < 0) throw new RangeError.value(start); 25009 if (start < 0) throw new RangeError.value(start);
24461 int end = start + length; 25010 int end = start + length;
24462 if (end > a.length) throw new RangeError.value(end); 25011 if (end > a.length) throw new RangeError.value(end);
24463 for (int i = start; i < end; i++) { 25012 for (int i = start; i < end; i++) {
24464 accumulator.add(a[i]); 25013 accumulator.add(a[i]);
24465 } 25014 }
24466 return accumulator; 25015 return accumulator;
24467 } 25016 }
24468 } 25017 }
OLDNEW
« no previous file with comments | « no previous file | sdk/lib/html/dartium/html_dartium.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698