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

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

Issue 2827793002: Format all files under tools and utils directory. (Closed)
Patch Set: Format all files under tools and utils directory. Created 3 years, 8 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 /** 1 /**
2 * A custom KeyboardEvent that attempts to eliminate cross-browser 2 * A custom KeyboardEvent that attempts to eliminate cross-browser
3 * inconsistencies, and also provide both keyCode and charCode information 3 * inconsistencies, and also provide both keyCode and charCode information
4 * for all key events (when such information can be determined). 4 * for all key events (when such information can be determined).
5 * 5 *
6 * KeyEvent tries to provide a higher level, more polished keyboard event 6 * KeyEvent tries to provide a higher level, more polished keyboard event
7 * information on top of the "raw" [KeyboardEvent]. 7 * information on top of the "raw" [KeyboardEvent].
8 * 8 *
9 * The mechanics of using KeyEvents is a little different from the underlying 9 * The mechanics of using KeyEvents is a little different from the underlying
10 * [KeyboardEvent]. To use KeyEvents, you need to create a stream and then add 10 * [KeyboardEvent]. To use KeyEvents, you need to create a stream and then add
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 /** Accessor to the underlying charCode value is the parent event. */ 61 /** Accessor to the underlying charCode value is the parent event. */
62 int get _realCharCode => _parent.charCode; 62 int get _realCharCode => _parent.charCode;
63 63
64 /** Accessor to the underlying altKey value is the parent event. */ 64 /** Accessor to the underlying altKey value is the parent event. */
65 bool get _realAltKey => _parent.altKey; 65 bool get _realAltKey => _parent.altKey;
66 66
67 /** Shadows on top of the parent's currentTarget. */ 67 /** Shadows on top of the parent's currentTarget. */
68 EventTarget _currentTarget; 68 EventTarget _currentTarget;
69 69
70 /** Construct a KeyEvent with [parent] as the event we're emulating. */ 70 /** Construct a KeyEvent with [parent] as the event we're emulating. */
71 KeyEvent.wrap(KeyboardEvent parent): super(parent) { 71 KeyEvent.wrap(KeyboardEvent parent) : super(parent) {
72 _parent = parent; 72 _parent = parent;
73 _shadowAltKey = _realAltKey; 73 _shadowAltKey = _realAltKey;
74 _shadowCharCode = _realCharCode; 74 _shadowCharCode = _realCharCode;
75 _shadowKeyCode = _realKeyCode; 75 _shadowKeyCode = _realKeyCode;
76 _currentTarget = _parent.currentTarget == null? window : 76 _currentTarget =
77 _parent.currentTarget; 77 _parent.currentTarget == null ? window : _parent.currentTarget;
78 } 78 }
79 79
80 /** Programmatically create a new KeyEvent (and KeyboardEvent). */ 80 /** Programmatically create a new KeyEvent (and KeyboardEvent). */
81 factory KeyEvent(String type, 81 factory KeyEvent(String type,
82 {Window view, bool canBubble: true, bool cancelable: true, int keyCode: 0, 82 {Window view,
83 int charCode: 0, int keyLocation: 1, bool ctrlKey: false, 83 bool canBubble: true,
84 bool altKey: false, bool shiftKey: false, bool metaKey: false, 84 bool cancelable: true,
85 EventTarget currentTarget}) { 85 int keyCode: 0,
86 var parent = new KeyboardEvent(type, view: view, canBubble: canBubble, 86 int charCode: 0,
87 cancelable: cancelable, keyLocation: keyLocation, ctrlKey: ctrlKey, 87 int keyLocation: 1,
88 altKey: altKey, shiftKey: shiftKey, metaKey: metaKey); 88 bool ctrlKey: false,
89 var keyEvent = new KeyEvent.wrap(parent); 89 bool altKey: false,
90 keyEvent._shadowAltKey = altKey; 90 bool shiftKey: false,
91 keyEvent._shadowCharCode = charCode; 91 bool metaKey: false,
92 keyEvent._shadowKeyCode = keyCode; 92 EventTarget currentTarget}) {
93 keyEvent._currentTarget = currentTarget == null ? window : currentTarget; 93 var parent = new KeyboardEvent(type,
94 return keyEvent; 94 view: view,
95 } 95 canBubble: canBubble,
96 cancelable: cancelable,
97 keyLocation: keyLocation,
98 ctrlKey: ctrlKey,
99 altKey: altKey,
100 shiftKey: shiftKey,
101 metaKey: metaKey);
102 var keyEvent = new KeyEvent.wrap(parent);
103 keyEvent._shadowAltKey = altKey;
104 keyEvent._shadowCharCode = charCode;
105 keyEvent._shadowKeyCode = keyCode;
106 keyEvent._currentTarget = currentTarget == null ? window : currentTarget;
107 return keyEvent;
108 }
96 109
97 /** Accessor to provide a stream of KeyEvents on the desired target. */ 110 /** Accessor to provide a stream of KeyEvents on the desired target. */
98 static EventStreamProvider<KeyEvent> keyDownEvent = 111 static EventStreamProvider<KeyEvent> keyDownEvent =
99 new _KeyboardEventHandler('keydown'); 112 new _KeyboardEventHandler('keydown');
100 /** Accessor to provide a stream of KeyEvents on the desired target. */ 113 /** Accessor to provide a stream of KeyEvents on the desired target. */
101 static EventStreamProvider<KeyEvent> keyUpEvent = 114 static EventStreamProvider<KeyEvent> keyUpEvent =
102 new _KeyboardEventHandler('keyup'); 115 new _KeyboardEventHandler('keyup');
103 /** Accessor to provide a stream of KeyEvents on the desired target. */ 116 /** Accessor to provide a stream of KeyEvents on the desired target. */
104 static EventStreamProvider<KeyEvent> keyPressEvent = 117 static EventStreamProvider<KeyEvent> keyPressEvent =
105 new _KeyboardEventHandler('keypress'); 118 new _KeyboardEventHandler('keypress');
106 119
107 /** The currently registered target for this event. */ 120 /** The currently registered target for this event. */
108 EventTarget get currentTarget => _currentTarget; 121 EventTarget get currentTarget => _currentTarget;
109 122
110 /** True if the ctrl key is pressed during this event. */ 123 /** True if the ctrl key is pressed during this event. */
111 bool get ctrlKey => _parent.ctrlKey; 124 bool get ctrlKey => _parent.ctrlKey;
112 int get detail => _parent.detail; 125 int get detail => _parent.detail;
113 /** 126 /**
114 * Accessor to the part of the keyboard that the key was pressed from (one of 127 * Accessor to the part of the keyboard that the key was pressed from (one of
115 * KeyLocation.STANDARD, KeyLocation.RIGHT, KeyLocation.LEFT, 128 * KeyLocation.STANDARD, KeyLocation.RIGHT, KeyLocation.LEFT,
116 * KeyLocation.NUMPAD, KeyLocation.MOBILE, KeyLocation.JOYSTICK). 129 * KeyLocation.NUMPAD, KeyLocation.MOBILE, KeyLocation.JOYSTICK).
117 */ 130 */
118 int get keyLocation => _parent.keyLocation; 131 int get keyLocation => _parent.keyLocation;
119 /** True if the Meta (or Mac command) key is pressed during this event. */ 132 /** True if the Meta (or Mac command) key is pressed during this event. */
120 bool get metaKey => _parent.metaKey; 133 bool get metaKey => _parent.metaKey;
121 /** True if the shift key was pressed during this event. */ 134 /** True if the shift key was pressed during this event. */
122 bool get shiftKey => _parent.shiftKey; 135 bool get shiftKey => _parent.shiftKey;
123 Window get view => _parent.view; 136 Window get view => _parent.view;
124 void _initUIEvent(String type, bool canBubble, bool cancelable, 137 void _initUIEvent(
125 Window view, int detail) { 138 String type, bool canBubble, bool cancelable, Window view, int detail) {
126 throw new UnsupportedError("Cannot initialize a UI Event from a KeyEvent."); 139 throw new UnsupportedError("Cannot initialize a UI Event from a KeyEvent.");
127 } 140 }
141
128 String get _shadowKeyIdentifier => _parent._keyIdentifier; 142 String get _shadowKeyIdentifier => _parent._keyIdentifier;
129 143
130 int get _charCode => charCode; 144 int get _charCode => charCode;
131 int get _keyCode => keyCode; 145 int get _keyCode => keyCode;
132 int get _which => which; 146 int get _which => which;
133 String get _keyIdentifier { 147 String get _keyIdentifier {
134 throw new UnsupportedError("keyIdentifier is unsupported."); 148 throw new UnsupportedError("keyIdentifier is unsupported.");
135 } 149 }
136 void _initKeyboardEvent(String type, bool canBubble, bool cancelable, 150
137 Window view, String keyIdentifier, int keyLocation, bool ctrlKey, 151 void _initKeyboardEvent(
138 bool altKey, bool shiftKey, bool metaKey) { 152 String type,
153 bool canBubble,
154 bool cancelable,
155 Window view,
156 String keyIdentifier,
157 int keyLocation,
158 bool ctrlKey,
159 bool altKey,
160 bool shiftKey,
161 bool metaKey) {
139 throw new UnsupportedError( 162 throw new UnsupportedError(
140 "Cannot initialize a KeyboardEvent from a KeyEvent."); 163 "Cannot initialize a KeyboardEvent from a KeyEvent.");
141 } 164 }
165
142 @Experimental() // untriaged 166 @Experimental() // untriaged
143 bool getModifierState(String keyArgument) => throw new UnimplementedError(); 167 bool getModifierState(String keyArgument) => throw new UnimplementedError();
144 @Experimental() // untriaged 168 @Experimental() // untriaged
145 int get location => throw new UnimplementedError(); 169 int get location => throw new UnimplementedError();
146 @Experimental() // untriaged 170 @Experimental() // untriaged
147 bool get repeat => throw new UnimplementedError(); 171 bool get repeat => throw new UnimplementedError();
148 dynamic get _get_view => throw new UnimplementedError(); 172 dynamic get _get_view => throw new UnimplementedError();
149 } 173 }
OLDNEW
« no previous file with comments | « tools/dom/src/dartium_CustomElementSupport.dart ('k') | tools/dom/src/dartium_WrappedEvent.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698