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

Side by Side Diff: third_party/WebKit/Source/core/editing/EditorKeyBindings.cpp

Issue 2290313002: Remove PlatformKeyboardEvent (Closed)
Patch Set: One more fix Created 4 years, 3 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 * Copyright (C) 2006, 2007 Apple, Inc. All rights reserved. 2 * Copyright (C) 2006, 2007 Apple, Inc. All rights reserved.
3 * Copyright (C) 2012 Google, Inc. All rights reserved. 3 * Copyright (C) 2012 Google, Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 12 matching lines...) Expand all
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */ 25 */
26 26
27 #include "core/editing/Editor.h" 27 #include "core/editing/Editor.h"
28 28
29 #include "core/editing/EditingUtilities.h" 29 #include "core/editing/EditingUtilities.h"
30 #include "core/events/KeyboardEvent.h" 30 #include "core/events/KeyboardEvent.h"
31 #include "core/frame/LocalFrame.h" 31 #include "core/frame/LocalFrame.h"
32 #include "core/page/EditorClient.h" 32 #include "core/page/EditorClient.h"
33 #include "platform/PlatformKeyboardEvent.h" 33 #include "public/platform/WebInputEvent.h"
34 34
35 namespace blink { 35 namespace blink {
36 36
37 bool Editor::handleEditingKeyboardEvent(KeyboardEvent* evt) 37 bool Editor::handleEditingKeyboardEvent(KeyboardEvent* evt)
38 { 38 {
39 const PlatformKeyboardEvent* keyEvent = evt->keyEvent(); 39 const WebKeyboardEvent* keyEvent = evt->keyEvent();
40 // do not treat this as text input if it's a system key event 40 // do not treat this as text input if it's a system key event
41 if (!keyEvent || keyEvent->isSystemKey()) 41 if (!keyEvent || keyEvent->isSystemKey)
42 return false; 42 return false;
43 43
44 String commandName = behavior().interpretKeyEvent(*evt); 44 String commandName = behavior().interpretKeyEvent(*evt);
45 Command command = this->createCommand(commandName); 45 Command command = this->createCommand(commandName);
46 46
47 if (keyEvent->type() == PlatformEvent::RawKeyDown) { 47 if (keyEvent->type == WebInputEvent::RawKeyDown) {
48 // WebKit doesn't have enough information about mode to decide how 48 // WebKit doesn't have enough information about mode to decide how
49 // commands that just insert text if executed via Editor should be treat ed, 49 // commands that just insert text if executed via Editor should be treat ed,
50 // so we leave it upon WebCore to either handle them immediately 50 // so we leave it upon WebCore to either handle them immediately
51 // (e.g. Tab that changes focus) or let a keypress event be generated 51 // (e.g. Tab that changes focus) or let a keypress event be generated
52 // (e.g. Tab that inserts a Tab character, or Enter). 52 // (e.g. Tab that inserts a Tab character, or Enter).
53 if (command.isTextInsertion() || commandName.isEmpty()) 53 if (command.isTextInsertion() || commandName.isEmpty())
54 return false; 54 return false;
55 return command.execute(evt); 55 return command.execute(evt);
56 } 56 }
57 57
58 if (command.execute(evt)) 58 if (command.execute(evt))
59 return true; 59 return true;
60 60
61 if (!behavior().shouldInsertCharacter(*evt) || !canEdit()) 61 if (!behavior().shouldInsertCharacter(*evt) || !canEdit())
62 return false; 62 return false;
63 63
64 // Return true to prevent default action. e.g. Space key scroll. 64 // Return true to prevent default action. e.g. Space key scroll.
65 if (dispatchBeforeInputInsertText(evt->target(), evt->keyEvent()->text()) != DispatchEventResult::NotCanceled) 65 if (dispatchBeforeInputInsertText(evt->target(), keyEvent->text) != Dispatch EventResult::NotCanceled)
66 return true; 66 return true;
67 67
68 return insertText(evt->keyEvent()->text(), evt); 68 return insertText(keyEvent->text, evt);
69 } 69 }
70 70
71 void Editor::handleKeyboardEvent(KeyboardEvent* evt) 71 void Editor::handleKeyboardEvent(KeyboardEvent* evt)
72 { 72 {
73 // Give the embedder a chance to handle the keyboard event. 73 // Give the embedder a chance to handle the keyboard event.
74 if (client().handleKeyboardEvent() || handleEditingKeyboardEvent(evt)) 74 if (client().handleKeyboardEvent() || handleEditingKeyboardEvent(evt))
75 evt->setDefaultHandled(); 75 evt->setDefaultHandled();
76 } 76 }
77 77
78 } // namespace blink 78 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698