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

Side by Side Diff: tools/dom/src/KeyboardEventController.dart

Issue 12282038: Remove deprecated string features. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Merge to head Created 7 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « tests/utils/utf_test.dart ('k') | utils/css/parser.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 // 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 part of html; 5 part of html;
6 6
7 /** 7 /**
8 * Works with KeyboardEvent and KeyEvent to determine how to expose information 8 * Works with KeyboardEvent and KeyEvent to determine how to expose information
9 * about Key(board)Events. This class functions like an EventListenerList, and 9 * about Key(board)Events. This class functions like an EventListenerList, and
10 * provides a consistent interface for the Dart 10 * provides a consistent interface for the Dart
(...skipping 17 matching lines...) Expand all
28 /** The set of functions that wish to be notified when a KeyEvent happens. */ 28 /** The set of functions that wish to be notified when a KeyEvent happens. */
29 List<Function> _callbacks; 29 List<Function> _callbacks;
30 30
31 /** The type of KeyEvent we are tracking (keyup, keydown, keypress). */ 31 /** The type of KeyEvent we are tracking (keyup, keydown, keypress). */
32 String _type; 32 String _type;
33 33
34 /** The element we are watching for events to happen on. */ 34 /** The element we are watching for events to happen on. */
35 EventTarget _target; 35 EventTarget _target;
36 36
37 // The distance to shift from upper case alphabet Roman letters to lower case. 37 // The distance to shift from upper case alphabet Roman letters to lower case.
38 final int _ROMAN_ALPHABET_OFFSET = "a".charCodes[0] - "A".charCodes[0]; 38 final int _ROMAN_ALPHABET_OFFSET = "a".codeUnits[0] - "A".codeUnits[0];
39 39
40 StreamSubscription _keyUpSubscription, _keyDownSubscription, 40 StreamSubscription _keyUpSubscription, _keyDownSubscription,
41 _keyPressSubscription; 41 _keyPressSubscription;
42 42
43 /** 43 /**
44 * An enumeration of key identifiers currently part of the W3C draft for DOM3 44 * An enumeration of key identifiers currently part of the W3C draft for DOM3
45 * and their mappings to keyCodes. 45 * and their mappings to keyCodes.
46 * http://www.w3.org/TR/DOM-Level-3-Events/keyset.html#KeySet-Set 46 * http://www.w3.org/TR/DOM-Level-3-Events/keyset.html#KeySet-Set
47 */ 47 */
48 static Map<String, int> _keyIdentifier = { 48 static Map<String, int> _keyIdentifier = {
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 * reverse-engineering, we can also determine the keyCode.) Returns 163 * reverse-engineering, we can also determine the keyCode.) Returns
164 * KeyCode.UNKNOWN if the keycode could not be determined. 164 * KeyCode.UNKNOWN if the keycode could not be determined.
165 */ 165 */
166 int _determineKeyCodeForKeypress(KeyboardEvent event) { 166 int _determineKeyCodeForKeypress(KeyboardEvent event) {
167 // Note: This function is a work in progress. We'll expand this function 167 // Note: This function is a work in progress. We'll expand this function
168 // once we get more information about other keyboards. 168 // once we get more information about other keyboards.
169 for (var prevEvent in _keyDownList) { 169 for (var prevEvent in _keyDownList) {
170 if (prevEvent._shadowCharCode == event.charCode) { 170 if (prevEvent._shadowCharCode == event.charCode) {
171 return prevEvent.keyCode; 171 return prevEvent.keyCode;
172 } 172 }
173 if ((event.shiftKey || _capsLockOn) && event.charCode >= "A".charCodes[0] 173 if ((event.shiftKey || _capsLockOn) && event.charCode >= "A".codeUnits[0]
174 && event.charCode <= "Z".charCodes[0] && event.charCode + 174 && event.charCode <= "Z".codeUnits[0] && event.charCode +
175 _ROMAN_ALPHABET_OFFSET == prevEvent._shadowCharCode) { 175 _ROMAN_ALPHABET_OFFSET == prevEvent._shadowCharCode) {
176 return prevEvent.keyCode; 176 return prevEvent.keyCode;
177 } 177 }
178 } 178 }
179 return KeyCode.UNKNOWN; 179 return KeyCode.UNKNOWN;
180 } 180 }
181 181
182 /** 182 /**
183 * Given the charater code returned from a keyDown [event], try to ascertain 183 * Given the charater code returned from a keyDown [event], try to ascertain
184 * and return the corresponding charCode for the character that was pressed. 184 * and return the corresponding charCode for the character that was pressed.
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
401 _keyDownList.where((element) => element != toRemove).toList(); 401 _keyDownList.where((element) => element != toRemove).toList();
402 } else if (_keyDownList.length > 0) { 402 } else if (_keyDownList.length > 0) {
403 // This happens when we've reached some international keyboard case we 403 // This happens when we've reached some international keyboard case we
404 // haven't accounted for or we haven't correctly eliminated all browser 404 // haven't accounted for or we haven't correctly eliminated all browser
405 // inconsistencies. Filing bugs on when this is reached is welcome! 405 // inconsistencies. Filing bugs on when this is reached is welcome!
406 _keyDownList.removeLast(); 406 _keyDownList.removeLast();
407 } 407 }
408 _dispatch(e); 408 _dispatch(e);
409 } 409 }
410 } 410 }
OLDNEW
« no previous file with comments | « tests/utils/utf_test.dart ('k') | utils/css/parser.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698