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

Side by Side Diff: tools/dom/templates/html/dart2js/impl_KeyboardEvent.darttemplate

Issue 2883623004: fix KeyEvent and KeyboardEvent (Closed)
Patch Set: Created 3 years, 7 months 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
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 5
6 /** 6 /**
7 * An event that describes user interaction with the keyboard. 7 * An event that describes user interaction with the keyboard.
8 * 8 *
9 * The [type] of the event identifies what kind of interaction occurred. 9 * The [type] of the event identifies what kind of interaction occurred.
10 * 10 *
11 * See also: 11 * See also:
12 * 12 *
13 * * [KeyboardEvent](https://developer.mozilla.org/en/DOM/KeyboardEvent) at MDN. 13 * * [KeyboardEvent](https://developer.mozilla.org/en/DOM/KeyboardEvent) at MDN.
14 */ 14 */
15 $(ANNOTATIONS)$(NATIVESPEC)$(CLASS_MODIFIERS)class $CLASSNAME$EXTENDS$IMPLEMENTS { 15 $(ANNOTATIONS)$(NATIVESPEC)$(CLASS_MODIFIERS)class $CLASSNAME$EXTENDS$IMPLEMENTS {
16 16
17 /** 17 /**
18 * Programmatically create a KeyboardEvent. 18 * Programmatically create a KeyboardEvent.
19 * 19 *
20 * Due to browser differences, keyCode, charCode, or keyIdentifier values 20 * Due to browser differences, keyCode, charCode, or keyIdentifier values
21 * cannot be specified in this base level constructor. This constructor 21 * cannot be specified in this base level constructor. This constructor
22 * enables the user to programmatically create and dispatch a [KeyboardEvent], 22 * enables the user to programmatically create and dispatch a [KeyboardEvent],
23 * but it will not contain any particular key content. For programmatically 23 * but it will not contain any particular key content. For programmatically
24 * creating keyboard events with specific key value contents, see the custom 24 * creating keyboard events with specific key value contents, see the custom
25 * Event [KeyEvent]. 25 * Event [KeyEvent].
26 */ 26 */
27 factory $CLASSNAME(String type, 27 factory $CLASSNAME(String type,
28 {Window view, bool canBubble: true, bool cancelable: true, 28 {Window view, bool canBubble: true, bool cancelable: true,
29 int keyLocation: 1, bool ctrlKey: false, 29 int location: 1, bool ctrlKey: false,
Jacob 2017/05/12 23:28:18 We shouldn't be making breaking changes to the Dar
30 bool altKey: false, bool shiftKey: false, bool metaKey: false}) { 30 bool altKey: false, bool shiftKey: false, bool metaKey: false}) {
31 if (view == null) { 31 if (view == null) {
32 view = window; 32 view = window;
33 } 33 }
34 KeyboardEvent e = document._createEvent("KeyboardEvent"); 34 KeyboardEvent e = document._createEvent("KeyboardEvent");
35 e._initKeyboardEvent(type, canBubble, cancelable, view, "", 35 e._initKeyboardEvent(type, canBubble, cancelable, view, "",
36 keyLocation, ctrlKey, altKey, shiftKey, metaKey); 36 location, ctrlKey, altKey, shiftKey, metaKey);
37 return e; 37 return e;
38 } 38 }
39 39
40 @DomName('KeyboardEvent.initKeyboardEvent') 40 @DomName('KeyboardEvent.initKeyboardEvent')
41 void _initKeyboardEvent(String type, bool canBubble, bool cancelable, 41 void _initKeyboardEvent(String type, bool canBubble, bool cancelable,
42 Window view, String keyIdentifier, int keyLocation, bool ctrlKey, 42 Window view, String keyIdentifier, int location, bool ctrlKey,
43 bool altKey, bool shiftKey, bool metaKey) { 43 bool altKey, bool shiftKey, bool metaKey) {
44 if (JS('bool', 'typeof(#.initKeyEvent) == "function"', this)) { 44 if (JS('bool', 'typeof(#.initKeyEvent) == "function"', this)) {
45 // initKeyEvent is only in Firefox (instead of initKeyboardEvent). It has 45 // initKeyEvent is only in Firefox (instead of initKeyboardEvent). It has
46 // a slightly different signature, and allows you to specify keyCode and 46 // a slightly different signature, and allows you to specify keyCode and
47 // charCode as the last two arguments, but we just set them as the default 47 // charCode as the last two arguments, but we just set them as the default
48 // since they can't be specified in other browsers. 48 // since they can't be specified in other browsers.
49 JS('void', '#.initKeyEvent(#, #, #, #, #, #, #, #, 0, 0)', this, 49 JS('void', '#.initKeyEvent(#, #, #, #, #, #, #, #, 0, 0)', this,
50 type, canBubble, cancelable, view, 50 type, canBubble, cancelable, view,
51 ctrlKey, altKey, shiftKey, metaKey); 51 ctrlKey, altKey, shiftKey, metaKey);
52 } else { 52 } else {
53 // initKeyboardEvent is for all other browsers. 53 // initKeyboardEvent is for all other browsers.
54 JS('void', '#.initKeyboardEvent(#, #, #, #, #, #, #, #, #, #)', this, 54 JS('void', '#.initKeyboardEvent(#, #, #, #, #, #, #, #, #, #)', this,
55 type, canBubble, cancelable, view, keyIdentifier, keyLocation, 55 type, canBubble, cancelable, view, keyIdentifier, location,
56 ctrlKey, altKey, shiftKey, metaKey); 56 ctrlKey, altKey, shiftKey, metaKey);
57 } 57 }
58 } 58 }
59 59
60 @DomName('KeyboardEvent.keyCode') 60 @DomName('KeyboardEvent.keyCode')
61 int get keyCode => _keyCode; 61 int get keyCode => _keyCode;
62 62
63 @DomName('KeyboardEvent.charCode') 63 @DomName('KeyboardEvent.charCode')
64 int get charCode => _charCode; 64 int get charCode => _charCode;
65 65
66 @DomName('KeyboardEvent.which') 66 @DomName('KeyboardEvent.which')
67 int get which => _which; 67 int get which => _which;
68 $!MEMBERS 68 $!MEMBERS
69 } 69 }
OLDNEW
« no previous file with comments | « tools/dom/src/dart2js_KeyEvent.dart ('k') | tools/dom/templates/html/dartium/impl_KeyboardEvent.darttemplate » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698