Index: sdk/lib/html/dart2js/html_dart2js.dart |
diff --git a/sdk/lib/html/dart2js/html_dart2js.dart b/sdk/lib/html/dart2js/html_dart2js.dart |
index 7f284b339192632b65882fda913e20613d8d6e7d..b3bde46c036f6498d74bc26ece93a155e619e099 100644 |
--- a/sdk/lib/html/dart2js/html_dart2js.dart |
+++ b/sdk/lib/html/dart2js/html_dart2js.dart |
@@ -6441,27 +6441,6 @@ class DirectoryReaderSync native "*DirectoryReaderSync" { |
// BSD-style license that can be found in the LICENSE file. |
-/** |
- * Represents an HTML <div> element. |
Emily Fortuna
2012/11/28 22:58:12
these are "removed" because of Andrei's dartdoc ch
|
- * |
- * The [DivElement] is a generic container for content and does not have any |
- * special significance. It is functionally similar to [SpanElement]. |
- * |
- * The [DivElement] is a block-level element, as opposed to [SpanElement], |
- * which is an inline-level element. |
- * |
- * Example usage: |
- * |
- * DivElement div = new DivElement(); |
- * div.text = 'Here's my new DivElem |
- * document.body.elements.add(elem); |
- * |
- * See also: |
- * |
- * * [HTML <div> element](http://www.w3.org/TR/html-markup/div.html) from W3C. |
- * * [Block-level element](http://www.w3.org/TR/CSS2/visuren.html#block-boxes) from W3C. |
- * * [Inline-level element](http://www.w3.org/TR/CSS2/visuren.html#inline-boxes) from W3C. |
- */ |
/// @domName HTMLDivElement; @docsEditable true |
class DivElement extends Element implements Element native "*HTMLDivElement" { |
@@ -11374,6 +11353,34 @@ class JavaScriptCallFrame native "*JavaScriptCallFrame" { |
/// @domName KeyboardEvent; @docsEditable true |
class KeyboardEvent extends UIEvent native "*KeyboardEvent" { |
+ factory KeyboardEvent(String type, Window view, |
+ [bool canBubble = true, bool cancelable = true, |
+ String keyIdentifier = null, int keyLocation = 1, bool ctrlKey = false, |
+ bool altKey = false, bool shiftKey = false, bool metaKey = false, |
+ bool altGraphKey = false]) { |
+ final e = document.$dom_createEvent("KeyboardEvent"); |
+ e.$dom_initKeyboardEvent(type, canBubble, cancelable, view, keyIdentifier, |
+ keyLocation, ctrlKey, altKey, shiftKey, metaKey, altGraphKey); |
+ return e; |
+ } |
+ |
+ /** @domName KeyboardEvent.initKeyboardEvent */ |
+ void $dom_initKeyboardEvent(String type, bool canBubble, bool cancelable, |
+ LocalWindow view, String keyIdentifier, int keyLocation, bool ctrlKey, |
+ bool altKey, bool shiftKey, bool metaKey, bool altGraphKey) { |
+ var function = JS('dynamic', '#.initKeyboardEvent || #.initKeyEvent', this, |
+ this); |
+ JS('void', '#(#, #, #, #, #, #, #, #, #, #, #)', function, type, |
+ canBubble, cancelable, view, keyIdentifier, keyLocation, ctrlKey, |
+ altKey, shiftKey, metaKey, altGraphKey); |
+ } |
+ |
+ /** @domName KeyboardEvent.keyCode */ |
+ int get keyCode => $dom_keyCode; |
+ |
+ /** @domName KeyboardEvent.charCode */ |
+ int get charCode => $dom_charCode; |
+ |
/// @domName KeyboardEvent.altGraphKey; @docsEditable true |
final bool altGraphKey; |
@@ -11384,7 +11391,7 @@ class KeyboardEvent extends UIEvent native "*KeyboardEvent" { |
final bool ctrlKey; |
/// @domName KeyboardEvent.keyIdentifier; @docsEditable true |
- final String keyIdentifier; |
+ String get $dom_keyIdentifier => JS("String", "#.keyIdentifier", this); |
/// @domName KeyboardEvent.keyLocation; @docsEditable true |
final int keyLocation; |
@@ -11395,8 +11402,6 @@ class KeyboardEvent extends UIEvent native "*KeyboardEvent" { |
/// @domName KeyboardEvent.shiftKey; @docsEditable true |
final bool shiftKey; |
- /// @domName KeyboardEvent.initKeyboardEvent; @docsEditable true |
- void initKeyboardEvent(String type, bool canBubble, bool cancelable, LocalWindow view, String keyIdentifier, int keyLocation, bool ctrlKey, bool altKey, bool shiftKey, bool metaKey, bool altGraphKey) native; |
} |
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
// for details. All rights reserved. Use of this source code is governed by a |
@@ -12891,16 +12896,6 @@ class MemoryInfo native "*MemoryInfo" { |
// BSD-style license that can be found in the LICENSE file. |
-/** |
- * An HTML <menu> element. |
- * |
- * A <menu> element represents an unordered list of menu commands. |
- * |
- * See also: |
- * |
- * * [Menu Element](https://developer.mozilla.org/en-US/docs/HTML/Element/menu) from MDN. |
- * * [Menu Element](http://www.w3.org/TR/html5/the-menu-element.html#the-menu-element) from the W3C. |
- */ |
/// @domName HTMLMenuElement; @docsEditable true |
class MenuElement extends Element implements Element native "*HTMLMenuElement" { |
@@ -17741,13 +17736,13 @@ class TreeWalker native "*TreeWalker" { |
class UIEvent extends Event native "*UIEvent" { |
/// @domName UIEvent.charCode; @docsEditable true |
- final int charCode; |
+ int get $dom_charCode => JS("int", "#.charCode", this); |
/// @domName UIEvent.detail; @docsEditable true |
final int detail; |
/// @domName UIEvent.keyCode; @docsEditable true |
- final int keyCode; |
+ int get $dom_keyCode => JS("int", "#.keyCode", this); |
/// @domName UIEvent.layerX; @docsEditable true |
final int layerX; |
@@ -22555,6 +22550,377 @@ class FilteredElementList implements List { |
/** |
+ * Works with KeyboardEvent and KeyEvent to determine how to expose information |
+ * about Key(board)Events. This class functions like an EventListenerList, and |
+ * provides a consistent interface for the Dart |
+ * user, despite the fact that a multitude of browsers that have varying |
+ * keyboard default behavior. |
+ * |
+ * This class is very much a work in progress, and we'd love to get information |
+ * on how we can make this class work with as many international keyboards as |
+ * possible. Bugs welcome! |
+ */ |
+class KeyboardEventController { |
+ // This code inspired by Closure's KeyHandling library. |
+ // http://closure-library.googlecode.com/svn/docs/closure_goog_events_keyhandler.js.source.html |
+ |
+ /** |
+ * The set of keys that have been pressed down without seeing their |
+ * corresponding keyup event. |
+ */ |
+ List<KeyboardEvent> keyDownList; |
+ |
+ /** The set of functions that wish to be notified when a KeyEvent happens. */ |
+ List<Function> _callbacks; |
+ |
+ /** The type of KeyEvent we are tracking (keyup, keydown, keypress). */ |
+ String _type; |
+ |
+ // The distance to shift from upper case alphabet Roman letters to lower case. |
+ const int _ROMAN_ALPHABET_OFFSET = "a".charCodes[0] - "A".charCodes[0]; |
+ |
+ /** |
+ * An enumeration of key identifiers currently part of the W3C draft for DOM3 |
+ * and their mappings to keyCodes. |
+ * http://www.w3.org/TR/DOM-Level-3-Events/keyset.html#KeySet-Set |
+ */ |
+ static Map<String, int> _keyIdentifier = { |
+ 'Up': KeyCode.UP, |
+ 'Down': KeyCode.DOWN, |
+ 'Left': KeyCode.LEFT, |
+ 'Right': KeyCode.RIGHT, |
+ 'Enter': KeyCode.ENTER, |
+ 'F1': KeyCode.F1, |
+ 'F2': KeyCode.F2, |
+ 'F3': KeyCode.F3, |
+ 'F4': KeyCode.F4, |
+ 'F5': KeyCode.F5, |
+ 'F6': KeyCode.F6, |
+ 'F7': KeyCode.F7, |
+ 'F8': KeyCode.F8, |
+ 'F9': KeyCode.F9, |
+ 'F10': KeyCode.F10, |
+ 'F11': KeyCode.F11, |
+ 'F12': KeyCode.F12, |
+ 'U+007F': KeyCode.DELETE, |
+ 'Home': KeyCode.HOME, |
+ 'End': KeyCode.END, |
+ 'PageUp': KeyCode.PAGE_UP, |
+ 'PageDown': KeyCode.PAGE_DOWN, |
+ 'Insert': KeyCode.INSERT |
+ }; |
+ |
+ /** Named constructor to add an onKeyPress event listener to our handler. */ |
+ KeyboardEventController.keypress(EventTarget target) { |
+ _KeyboardEventController(target, 'keypress'); |
+ } |
+ |
+ /** Named constructor to add an onKeyUp event listener to our handler. */ |
+ KeyboardEventController.keyup(EventTarget target) { |
+ _KeyboardEventController(target, 'keyup'); |
+ } |
+ |
+ /** Named constructor to add an onKeyDown event listener to our handler. */ |
+ KeyboardEventController.keydown(EventTarget target) { |
+ _KeyboardEventController(target, 'keydown'); |
+ } |
+ |
+ /** |
+ * General constructor, performs basic initialization for our improved |
+ * KeyboardEvent controller. |
+ */ |
+ _KeyboardEventController(EventTarget target, String type) { |
+ keyDownList = []; |
+ _callbacks = []; |
+ _type = type; |
+ target.on.keyDown.add(processKeyDown, true); |
+ target.on.keyPress.add(processKeyPress, true); |
+ target.on.keyUp.add(processKeyUp, true); |
+ } |
+ |
+ /** Add a callback that wishes to be notified when a KeyEvent occurs. */ |
+ void add(Function callback) { |
+ _callbacks.add(callback); |
+ } |
+ |
+ /** |
+ * Notify all callback listeners that a KeyEvent of the relevant type has |
+ * occurred. |
+ */ |
+ bool _dispatch(KeyEvent event) { |
+ if (event.type == _type) { |
+ for(var callback in _callbacks) { |
+ callback(event); |
+ } |
+ } |
+ } |
+ |
+ /** Remove the given callback from the listeners list. */ |
+ void remove(Function callback) { |
+ _callbacks = _callbacks.filter((element) => element != callback); |
+ } |
+ |
+ /** Determine if caps lock is one of the currently depressed keys. */ |
+ bool get _capsLockOn() => |
+ keyDownList.some((var element) => element.keyCode == KeyCode.CAPS_LOCK); |
+ |
+ /** |
+ * Given the previously recorded keydown key codes, see if we can determine |
+ * the keycode of this keypress [event]. (Generally browsers only provide |
+ * charCode information for keypress events, but with a little |
+ * reverse-engineering, we can also determine the keyCode.) Returns |
+ * KeyCode.UNKNOWN if the keycode could not be determined. |
+ */ |
+ int _determineKeyCodeForKeypress(KeyboardEvent event) { |
+ // Note: This function is a work in progress. We'll expand this function |
+ // once we get more information about other keyboards. |
+ for (var prevEvent in keyDownList) { |
+ if (prevEvent._shadowCharCode == event.charCode) { |
+ return prevEvent.keyCode; |
+ } |
+ if ((event.shiftKey || _capsLockOn) && event.charCode >= "A".charCodes[0] |
+ && event.charCode <= "Z".charCodes[0] && event.charCode + |
+ _ROMAN_ALPHABET_OFFSET == prevEvent._shadowCharCode) { |
+ return prevEvent.keyCode; |
+ } |
+ } |
+ return KeyCode.UNKNOWN; |
+ } |
+ |
+ /** |
+ * Given the charater code returned from a keyDown [event], try to ascertain |
+ * and return the corresponding charCode for the character that was pressed. |
+ * This information is not shown to the user, but used to help polyfill |
+ * keypress events. |
+ */ |
+ int _findCharCodeKeyDown(KeyboardEvent event) { |
+ if (event.keyLocation == 3) { // Numpad keys. |
+ switch (event.keyCode) { |
+ case KeyCode.NUM_ZERO: |
+ // Even though this function returns _charCodes_, for some cases the |
+ // KeyCode == the charCode we want, in which case we use the keycode |
+ // constant for readability. |
+ return KeyCode.ZERO; |
+ case KeyCode.NUM_ONE: |
+ return KeyCode.ONE; |
+ case KeyCode.NUM_TWO: |
+ return KeyCode.TWO; |
+ case KeyCode.NUM_THREE: |
+ return KeyCode.THREE; |
+ case KeyCode.NUM_FOUR: |
+ return KeyCode.FOUR; |
+ case KeyCode.NUM_FIVE: |
+ return KeyCode.FIVE; |
+ case KeyCode.NUM_SIX: |
+ return KeyCode.SIX; |
+ case KeyCode.NUM_SEVEN: |
+ return KeyCode.SEVEN; |
+ case KeyCode.NUM_EIGHT: |
+ return KeyCode.EIGHT; |
+ case KeyCode.NUM_NINE: |
+ return KeyCode.NINE; |
+ case KeyCode.NUM_MULTIPLY: |
+ return 42; // Char code for * |
+ case KeyCode.NUM_PLUS: |
+ return 43; // + |
+ case KeyCode.NUM_MINUS: |
+ return 45; // - |
+ case KeyCode.NUM_PERIOD: |
+ return 46; // . |
+ case KeyCode.NUM_DIVISION: |
+ return 47; // / |
+ } |
+ } else if (event.keyCode >= 65 && event.keyCode <= 90) { |
+ // Set the "char code" for key down as the lower case letter. Again, this |
+ // will not show up for the user, but will be helpful in estimating |
+ // keyCode locations and other information during the keyPress event. |
+ return event.keyCode + _ROMAN_ALPHABET_OFFSET; |
+ } |
+ switch(event.keyCode) { |
+ case KeyCode.SEMICOLON: |
+ return KeyCode.FF_SEMICOLON; |
+ case KeyCode.EQUALS: |
+ return KeyCode.FF_EQUALS; |
+ case KeyCode.COMMA: |
+ return 44; // Ascii value for , |
+ case KeyCode.DASH: |
+ return 45; // - |
+ case KeyCode.PERIOD: |
+ return 46; // . |
+ case KeyCode.SLASH: |
+ return 47; // / |
+ case KeyCode.APOSTROPHE: |
+ return 96; // ` |
+ case KeyCode.OPEN_SQUARE_BRACKET: |
+ return 91; // [ |
+ case KeyCode.BACKSLASH: |
+ return 92; // \ |
+ case KeyCode.CLOSE_SQUARE_BRACKET: |
+ return 93; // ] |
+ case KeyCode.SINGLE_QUOTE: |
+ return 39; // ' |
+ } |
+ return event.keyCode; |
+ } |
+ |
+ /** |
+ * Returns true if the key fires a keypress event in the current browser. |
+ */ |
+ bool _firesKeyPressEvent(KeyEvent event) { |
+ if (!_Device.isIE && !_Device.isWebKit) { |
+ return true; |
+ } |
+ |
+ if (_Device.userAgent.contains('Mac') && event.altKey) { |
+ return KeyCode.isCharacterKey(event.keyCode); |
+ } |
+ |
+ // Alt but not AltGr which is represented as Alt+Ctrl. |
+ if (event.altKey && !event.ctrlKey) { |
+ return false; |
+ } |
+ |
+ // Saves Ctrl or Alt + key for IE and WebKit, which won't fire keypress. |
+ if (!event.shiftKey && |
+ (keyDownList.last.keyCode == KeyCode.CTRL || |
+ keyDownList.last.keyCode == KeyCode.ALT || |
+ _Device.userAgent.contains('Mac') && |
+ keyDownList.last.keyCode == KeyCode.META)) { |
+ return false; |
+ } |
+ |
+ // Some keys with Ctrl/Shift do not issue keypress in WebKit. |
+ if (_Device.isWebKit && event.ctrlKey && event.shiftKey && ( |
+ event.keycode == KeyCode.BACKSLASH || |
+ event.keycode == KeyCode.OPEN_SQUARE_BRACKET || |
+ event.keycode == KeyCode.CLOSE_SQUARE_BRACKET || |
+ event.keycode == KeyCode.TILDE || |
+ event.keycode == KeyCode.SEMICOLON || event.keycode == KeyCode.DASH || |
+ event.keycode == KeyCode.EQUALS || event.keycode == KeyCode.COMMA || |
+ event.keycode == KeyCode.PERIOD || event.keycode == KeyCode.SLASH || |
+ event.keycode == KeyCode.APOSTROPHE || |
+ event.keycode == KeyCode.SINGLE_QUOTE)) { |
+ return false; |
+ } |
+ |
+ switch (event.keyCode) { |
+ case KeyCode.ENTER: |
+ // IE9 does not fire keypress on ENTER. |
+ return !_Device.isIE; |
+ case KeyCode.ESC: |
+ return !_Device.isWebKit; |
+ } |
+ |
+ return KeyCode.isCharacterKey(event.keyCode); |
+ } |
+ |
+ /** |
+ * Normalize the keycodes to the IE KeyCodes (this is what Chrome, IE, and |
+ * Opera all use). |
+ */ |
+ int normalizeKeyCodes(KeyboardEvent event) { |
+ // Note: This may change once we get input about non-US keyboards. |
+ if (_Device.isFirefox) { |
+ switch(event.keyCode) { |
+ case KeyCode.FF_EQUALS: |
+ return KeyCode.EQUALS; |
+ case KeyCode.FF_SEMICOLON: |
+ return KeyCode.SEMICOLON; |
+ case KeyCode.MAC_FF_META: |
+ return KeyCode.META; |
+ case KeyCode.WIN_KEY_FF_LINUX: |
+ return KeyCode.WIN_KEY; |
+ } |
+ } |
+ return event.keyCode; |
+ } |
+ |
+ /** Handle keydown events. */ |
+ void processKeyDown(KeyboardEvent e) { |
+ // Ctrl-Tab and Alt-Tab can cause the focus to be moved to another window |
+ // before we've caught a key-up event. If the last-key was one of these |
+ // we reset the state. |
+ if (keyDownList.length > 0 && |
+ (keyDownList.last.keyCode == KeyCode.CTRL && !e.ctrlKey || |
+ keyDownList.last.keyCode == KeyCode.ALT && !e.altKey || |
+ _Device.userAgent.contains('Mac') && |
+ keyDownList.last.keyCode == KeyCode.META && !e.metaKey)) { |
+ keyDownList = []; |
+ } |
+ |
+ var event = new KeyEvent(e); |
+ event._shadowKeyCode = normalizeKeyCodes(event); |
+ // Technically a "keydown" event doesn't have a charCode. This is |
+ // calculated nonetheless to provide us with more information in giving |
+ // as much information as possible on keypress about keycode and also |
+ // charCode. |
+ event._shadowCharCode = _findCharCodeKeyDown(event); |
+ if (keyDownList.length > 0 && event.keyCode != keyDownList.last.keyCode && |
+ !_firesKeyPressEvent(event)) { |
+ // Some browsers have quirks not firing keypress events where all other |
+ // browsers do. This makes them more consistent. |
+ processKeyPress(event); |
+ } |
+ keyDownList.add(event); |
+ _dispatch(event); |
+ } |
+ |
+ /** Handle keypress events. */ |
+ void processKeyPress(KeyboardEvent event) { |
+ var e = new KeyEvent(event); |
+ // IE reports the character code in the keyCode field for keypress events. |
+ // There are two exceptions however, Enter and Escape. |
+ if (_Device.isIE) { |
+ if (e.keyCode == KeyCode.ENTER || e.keyCode == KeyCode.ESC) { |
+ e._shadowCharCode = 0; |
+ } else { |
+ e._shadowCharCode = e.keyCode; |
+ } |
+ } else if (_Device.isOpera) { |
+ // Opera reports the character code in the keyCode field. |
+ e._shadowCharCode = KeyCode.isCharacterKey(keyCode) ? e.keyCode : 0; |
+ } |
+ // Now we guestimate about what the keycode is that was actually |
+ // pressed, given previous keydown information. |
+ e._shadowKeyCode = _determineKeyCodeForKeypress(e); |
+ |
+ // Correct the key value for certain browser-specific quirks. |
+ if (e._shadowKeyIdentifier && |
+ _keyIdentifier.contains(e._shadowKeyIdentifier)) { |
+ // This is needed for Safari Windows because it currently doesn't give a |
+ // keyCode/which for non printable keys. |
+ e._shadowKeyCode = _keyIdentifier[keyIdentifier]; |
+ } |
+ e._shadowAltKey = keyDownList.some((var element) => element.altKey); |
+ _dispatch(e); |
+ } |
+ |
+ /** Handle keyup events. */ |
+ void processKeyUp(KeyboardEvent event) { |
+ var e = new KeyEvent(event); |
+ KeyboardEvent toRemove = null; |
+ for (var key in keyDownList) { |
+ if (key.keyCode == e.keyCode) { |
+ toRemove = key; |
+ } |
+ } |
+ if (toRemove != null) { |
+ keyDownList = keyDownList.filter((element) => element != toRemove); |
+ } else if (keyDownList.length > 0) { |
+ // This happens when we've reached some international keyboard case we |
+ // haven't accounted for or we haven't correctly eliminated all browser |
+ // inconsistencies. Filing bugs on when this is reached is welcome! |
+ keyDownList.removeLast(); |
+ } |
+ _dispatch(e); |
+ } |
+} |
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
+// for details. All rights reserved. Use of this source code is governed by a |
+// BSD-style license that can be found in the LICENSE file. |
+ |
+ |
+/** |
* Defines the keycode values for keys that are returned by |
* KeyboardEvent.keyCode. |
* |
@@ -22745,6 +23111,36 @@ abstract class KeyCode { |
static const int WIN_KEY = 224; |
static const int MAC_FF_META = 224; |
static const int WIN_IME = 229; |
+ |
+ /** A sentinel value if the keycode could not be determined. */ |
+ static const int UNKNOWN = -1; |
+ |
+ /** |
+ * Returns true if the keyCode produces a (US keyboard) character. |
+ * Note: This does not (yet) cover characters on non-US keyboards (Russian, |
+ * Hebrew, etc.). |
+ */ |
+ static bool isCharacterKey(int keyCode) { |
+ if ((keyCode >= ZERO && keyCode <= NINE) || |
+ (keyCode >= NUM_ZERO && keyCode <= NUM_MULTIPLY) || |
+ (keyCode >= A && keyCode <= Z)) { |
+ return true; |
+ } |
+ |
+ // Safari sends zero key code for non-latin characters. |
+ if (_Device.isWebKit && keyCode == 0) { |
+ return true; |
+ } |
+ |
+ return (keyCode == SPACE || keyCode == QUESTION_MARK || keyCode == NUM_PLUS |
+ || keyCode == NUM_MINUS || keyCode == NUM_PERIOD || |
+ keyCode == NUM_DIVISION || keyCode == SEMICOLON || |
+ keyCode == FF_SEMICOLON || keyCode == DASH || keyCode == EQUALS || |
+ keyCode == FF_EQUALS || keyCode == COMMA || keyCode == PERIOD || |
+ keyCode == SLASH || keyCode == APOSTROPHE || keyCode == SINGLE_QUOTE || |
+ keyCode == OPEN_SQUARE_BRACKET || keyCode == BACKSLASH || |
+ keyCode == CLOSE_SQUARE_BRACKET); |
+ } |
} |
// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
// for details. All rights reserved. Use of this source code is governed by a |
@@ -24678,6 +25074,110 @@ class _HistoryCrossFrame implements History { |
} |
} |
} |
+/** |
+ * A custom KeyboardEvent that attempts to eliminate cross-browser |
+ * inconsistencies, and also provide both keyCode and charCode information |
+ * for all key events (when such information can be determined). |
+ * |
+ * This class is very much a work in progress, and we'd love to get information |
+ * on how we can make this class work with as many international keyboards as |
+ * possible. Bugs welcome! |
+ */ |
+class KeyEvent implements KeyboardEvent { |
+ /** The parent KeyboardEvent that this KeyEvent is wrapping and "fixing". */ |
+ KeyboardEvent _parent; |
+ |
+ /** The "fixed" value of whether the alt key is being pressed. */ |
+ bool _shadowAltKey; |
+ |
+ /** Caculated value of what the estimated charCode is for this event. */ |
+ int _shadowCharCode; |
+ |
+ /** Caculated value of what the estimated keyCode is for this event. */ |
+ int _shadowKeyCode; |
+ |
+ /** Caculated value of what the estimated keyCode is for this event. */ |
+ int get keyCode => _shadowKeyCode; |
+ |
+ /** Caculated value of what the estimated charCode is for this event. */ |
+ int get charCode => this.type == 'keypress' ? _shadowCharCode : 0; |
+ |
+ /** Caculated value of whether the alt key is pressed is for this event. */ |
+ bool get altKey => _shadowAltKey; |
+ |
+ /** Caculated value of what the estimated keyCode is for this event. */ |
+ int get which => keyCode; |
+ |
+ /** Accessor to the underlying keyCode value is the parent event. */ |
+ int get _realKeyCode => JS('int', '#.keyCode', _parent); |
+ |
+ /** Accessor to the underlying charCode value is the parent event. */ |
+ int get _realCharCode => JS('int', '#.charCode', _parent); |
+ |
+ /** Accessor to the underlying altKey value is the parent event. */ |
+ bool get _realAltKey => JS('int', '#.altKey', _parent); |
+ |
+ /** Construct a KeyEvent with [parent] as event we're emulating. */ |
+ KeyEvent(KeyboardEvent parent) { |
+ _parent = parent; |
+ _shadowAltKey = _realAltKey; |
+ _shadowCharCode = _realCharCode; |
+ _shadowKeyCode = _realKeyCode; |
+ } |
+ |
+ /** |
+ * Catch-all to behave for all other methods not defined here just like the |
+ * _parent. |
+ */ |
+ void noSuchMethod(InvocationMirror invocation) { |
+ invocation.invokeOn(_parent); |
+ } |
+ |
+ // ----------------------------------------------------------------------- |
+ // This code duplication is unfortunate... It's like this because dart2js |
+ // generates code accessing fields like KeyEvent.bubbles as |
+ // KeyEvent.get$bubbles, which without these getters, would hit noSuchMethod, |
+ // and try to call get$bubbles on KeyBoardEvent, which just has a bubbles |
+ // field, not a get$bubbles. |
+ /** True if the altGraphKey is pressed during this event. */ |
+ bool get altGraphKey => _parent.altGraphKey; |
+ bool get bubbles => _parent.bubbles; |
+ /** True if this event can be cancelled. */ |
+ bool get cancelable => _parent.cancelable; |
+ bool get cancelBubble => _parent.cancelBubble; |
+ /** Accessor to the clipboardData available for this event. */ |
+ Clipboard get clipboardData => _parent.clipboardData; |
+ /** True if the ctrl key is pressed during this event. */ |
+ bool get ctrlKey => _parent.ctrlKey; |
+ /** Accessor to the target this event is listening to for changes. */ |
+ EventTarget get currentTarget => _parent.currentTarget; |
+ bool get defaultPrevented => _parent.defaultPrevented; |
+ int get detail => _parent.detail; |
+ int get eventPhase => _parent.eventPhase; |
+ /** |
+ * Accessor to the part of the keyboard that the key was pressed from (one of |
+ * KeyLocation.STANDARD, KeyLocation.RIGHT, KeyLocation.LEFT, |
+ * KeyLocation.NUMPAD, KeyLocation.MOBILE, KeyLocation.JOYSTICK). |
+ */ |
+ int get keyLocation => _parent.keyLocation; |
+ int get layerX => _parent.layerX; |
+ int get layerY => _parent.layerY; |
+ /** True if the Meta (or Mac command) key is pressed during this event. */ |
+ bool get metaKey => _parent.metaKey; |
+ int get pageX => _parent.pageX; |
+ int get pageY => _parent.pageY; |
+ bool get returnValue => _parent.returnValue; |
+ /** True if the shift key was pressed during this event. */ |
+ bool get shiftKey => _parent.shiftKey; |
+ int get timeStamp => _parent.timeStamp; |
+ /** |
+ * The type of key event that occurred. One of "keydown", "keyup", or |
+ * "keypress". |
+ */ |
+ String get type => _parent.type; |
+ Window get view => _parent.view; |
+ String get _shadowKeyIdentifier => JS('String', '#.keyIdentifier', _parent); |
+} |
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
// for details. All rights reserved. Use of this source code is governed by a |
// BSD-style license that can be found in the LICENSE file. |