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: third_party/WebKit/Source/core/input/KeyboardEventManager.cpp

Issue 2350433002: Extract more of the mouse logic from EventHandler (Closed)
Patch Set: Yet another rebase because of a presubmit rule bug Created 4 years, 2 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/Element.h" 7 #include "core/dom/Element.h"
8 #include "core/editing/Editor.h" 8 #include "core/editing/Editor.h"
9 #include "core/events/KeyboardEvent.h" 9 #include "core/events/KeyboardEvent.h"
10 #include "core/html/HTMLDialogElement.h" 10 #include "core/html/HTMLDialogElement.h"
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 retVal = WebFocusTypeRight; 49 retVal = WebFocusTypeRight;
50 return retVal; 50 return retVal;
51 } 51 }
52 52
53 } // namespace 53 } // namespace
54 54
55 KeyboardEventManager::KeyboardEventManager(LocalFrame* frame, 55 KeyboardEventManager::KeyboardEventManager(LocalFrame* frame,
56 ScrollManager* scrollManager) 56 ScrollManager* scrollManager)
57 : m_frame(frame), m_scrollManager(scrollManager) {} 57 : m_frame(frame), m_scrollManager(scrollManager) {}
58 58
59 DEFINE_TRACE(KeyboardEventManager) {
60 visitor->trace(m_frame);
61 visitor->trace(m_scrollManager);
62 }
63
59 bool KeyboardEventManager::handleAccessKey(const WebKeyboardEvent& evt) { 64 bool KeyboardEventManager::handleAccessKey(const WebKeyboardEvent& evt) {
60 // FIXME: Ignoring the state of Shift key is what neither IE nor Firefox do. 65 // FIXME: Ignoring the state of Shift key is what neither IE nor Firefox do.
61 // IE matches lower and upper case access keys regardless of Shift key state - but if both upper and 66 // IE matches lower and upper case access keys regardless of Shift key state - but if both upper and
62 // lower case variants are present in a document, the correct element is match ed based on Shift key state. 67 // lower case variants are present in a document, the correct element is match ed based on Shift key state.
63 // Firefox only matches an access key if Shift is not pressed, and does that c ase-insensitively. 68 // Firefox only matches an access key if Shift is not pressed, and does that c ase-insensitively.
64 DCHECK(!(kAccessKeyModifiers & WebInputEvent::ShiftKey)); 69 DCHECK(!(kAccessKeyModifiers & WebInputEvent::ShiftKey));
65 if ((evt.modifiers & (WebKeyboardEvent::KeyModifiers & 70 if ((evt.modifiers & (WebKeyboardEvent::KeyModifiers &
66 ~WebInputEvent::ShiftKey)) != kAccessKeyModifiers) 71 ~WebInputEvent::ShiftKey)) != kAccessKeyModifiers)
67 return false; 72 return false;
68 String key = String(evt.unmodifiedText); 73 String key = String(evt.unmodifiedText);
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 focusType, 308 focusType,
304 InputDeviceCapabilities::doesntFireTouchEventsSourceCapabilities())) 309 InputDeviceCapabilities::doesntFireTouchEventsSourceCapabilities()))
305 event->setDefaultHandled(); 310 event->setDefaultHandled();
306 } 311 }
307 312
308 void KeyboardEventManager::defaultEscapeEventHandler(KeyboardEvent* event) { 313 void KeyboardEventManager::defaultEscapeEventHandler(KeyboardEvent* event) {
309 if (HTMLDialogElement* dialog = m_frame->document()->activeModalDialog()) 314 if (HTMLDialogElement* dialog = m_frame->document()->activeModalDialog())
310 dialog->dispatchEvent(Event::createCancelable(EventTypeNames::cancel)); 315 dialog->dispatchEvent(Event::createCancelable(EventTypeNames::cancel));
311 } 316 }
312 317
313 DEFINE_TRACE(KeyboardEventManager) {
314 visitor->trace(m_frame);
315 visitor->trace(m_scrollManager);
316 }
317
318 static OverrideCapsLockState s_overrideCapsLockState; 318 static OverrideCapsLockState s_overrideCapsLockState;
319 319
320 void KeyboardEventManager::setCurrentCapsLockState( 320 void KeyboardEventManager::setCurrentCapsLockState(
321 OverrideCapsLockState state) { 321 OverrideCapsLockState state) {
322 s_overrideCapsLockState = state; 322 s_overrideCapsLockState = state;
323 } 323 }
324 324
325 bool KeyboardEventManager::currentCapsLockState() { 325 bool KeyboardEventManager::currentCapsLockState() {
326 switch (s_overrideCapsLockState) { 326 switch (s_overrideCapsLockState) {
327 case OverrideCapsLockState::Default: 327 case OverrideCapsLockState::Default:
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 if (currentModifiers & ::cmdKey) 362 if (currentModifiers & ::cmdKey)
363 modifiers |= WebInputEvent::MetaKey; 363 modifiers |= WebInputEvent::MetaKey;
364 #else 364 #else
365 // TODO(crbug.com/538289): Implement on other platforms. 365 // TODO(crbug.com/538289): Implement on other platforms.
366 return static_cast<WebInputEvent::Modifiers>(0); 366 return static_cast<WebInputEvent::Modifiers>(0);
367 #endif 367 #endif
368 return static_cast<WebInputEvent::Modifiers>(modifiers); 368 return static_cast<WebInputEvent::Modifiers>(modifiers);
369 } 369 }
370 370
371 } // namespace blink 371 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/input/GestureManager.cpp ('k') | third_party/WebKit/Source/core/input/MouseEventManager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698