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

Side by Side Diff: third_party/WebKit/Source/core/input/KeyboardEventManager.cpp

Issue 2569273002: Add constructors to WebInputEvents and setters so we can work at cleaning up these public structs. (Closed)
Patch Set: Rebase Created 3 years, 11 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "KeyboardEventManager.h" 5 #include "KeyboardEventManager.h"
6 6
7 #include "core/dom/DocumentUserGestureToken.h" 7 #include "core/dom/DocumentUserGestureToken.h"
8 #include "core/dom/Element.h" 8 #include "core/dom/Element.h"
9 #include "core/editing/Editor.h" 9 #include "core/editing/Editor.h"
10 #include "core/events/KeyboardEvent.h" 10 #include "core/events/KeyboardEvent.h"
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 initialKeyEvent.type == WebInputEvent::Char) { 197 initialKeyEvent.type == WebInputEvent::Char) {
198 KeyboardEvent* domEvent = KeyboardEvent::create( 198 KeyboardEvent* domEvent = KeyboardEvent::create(
199 initialKeyEvent, m_frame->document()->domWindow()); 199 initialKeyEvent, m_frame->document()->domWindow());
200 200
201 return EventHandlingUtil::toWebInputEventResult( 201 return EventHandlingUtil::toWebInputEventResult(
202 node->dispatchEvent(domEvent)); 202 node->dispatchEvent(domEvent));
203 } 203 }
204 204
205 WebKeyboardEvent keyDownEvent = initialKeyEvent; 205 WebKeyboardEvent keyDownEvent = initialKeyEvent;
206 if (keyDownEvent.type != WebInputEvent::RawKeyDown) 206 if (keyDownEvent.type != WebInputEvent::RawKeyDown)
207 keyDownEvent.type = WebInputEvent::RawKeyDown; 207 keyDownEvent.setType(WebInputEvent::RawKeyDown);
208 KeyboardEvent* keydown = 208 KeyboardEvent* keydown =
209 KeyboardEvent::create(keyDownEvent, m_frame->document()->domWindow()); 209 KeyboardEvent::create(keyDownEvent, m_frame->document()->domWindow());
210 if (matchedAnAccessKey) 210 if (matchedAnAccessKey)
211 keydown->setDefaultPrevented(true); 211 keydown->setDefaultPrevented(true);
212 keydown->setTarget(node); 212 keydown->setTarget(node);
213 213
214 DispatchEventResult dispatchResult = node->dispatchEvent(keydown); 214 DispatchEventResult dispatchResult = node->dispatchEvent(keydown);
215 if (dispatchResult != DispatchEventResult::NotCanceled) 215 if (dispatchResult != DispatchEventResult::NotCanceled)
216 return EventHandlingUtil::toWebInputEventResult(dispatchResult); 216 return EventHandlingUtil::toWebInputEventResult(dispatchResult);
217 // If frame changed as a result of keydown dispatch, then return early to 217 // If frame changed as a result of keydown dispatch, then return early to
(...skipping 19 matching lines...) Expand all
237 // function keys. However, some actual private use characters happen to be 237 // function keys. However, some actual private use characters happen to be
238 // in this range, e.g. the Apple logo (Option+Shift+K). 0xF7FF is an 238 // in this range, e.g. the Apple logo (Option+Shift+K). 0xF7FF is an
239 // arbitrary cut-off. 239 // arbitrary cut-off.
240 if (initialKeyEvent.text[0U] >= 0xF700 && 240 if (initialKeyEvent.text[0U] >= 0xF700 &&
241 initialKeyEvent.text[0U] <= 0xF7FF) { 241 initialKeyEvent.text[0U] <= 0xF7FF) {
242 return WebInputEventResult::NotHandled; 242 return WebInputEventResult::NotHandled;
243 } 243 }
244 #endif 244 #endif
245 245
246 WebKeyboardEvent keyPressEvent = initialKeyEvent; 246 WebKeyboardEvent keyPressEvent = initialKeyEvent;
247 keyPressEvent.type = WebInputEvent::Char; 247 keyPressEvent.setType(WebInputEvent::Char);
248 if (keyPressEvent.text[0] == 0) 248 if (keyPressEvent.text[0] == 0)
249 return WebInputEventResult::NotHandled; 249 return WebInputEventResult::NotHandled;
250 KeyboardEvent* keypress = 250 KeyboardEvent* keypress =
251 KeyboardEvent::create(keyPressEvent, m_frame->document()->domWindow()); 251 KeyboardEvent::create(keyPressEvent, m_frame->document()->domWindow());
252 keypress->setTarget(node); 252 keypress->setTarget(node);
253 return EventHandlingUtil::toWebInputEventResult( 253 return EventHandlingUtil::toWebInputEventResult(
254 node->dispatchEvent(keypress)); 254 node->dispatchEvent(keypress));
255 } 255 }
256 256
257 void KeyboardEventManager::capsLockStateMayHaveChanged() { 257 void KeyboardEventManager::capsLockStateMayHaveChanged() {
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
452 if (currentModifiers & ::cmdKey) 452 if (currentModifiers & ::cmdKey)
453 modifiers |= WebInputEvent::MetaKey; 453 modifiers |= WebInputEvent::MetaKey;
454 #else 454 #else
455 // TODO(crbug.com/538289): Implement on other platforms. 455 // TODO(crbug.com/538289): Implement on other platforms.
456 return static_cast<WebInputEvent::Modifiers>(0); 456 return static_cast<WebInputEvent::Modifiers>(0);
457 #endif 457 #endif
458 return static_cast<WebInputEvent::Modifiers>(modifiers); 458 return static_cast<WebInputEvent::Modifiers>(modifiers);
459 } 459 }
460 460
461 } // namespace blink 461 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698