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

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

Issue 2628763003: Keyboard event should not insert a character at selection if selection doesn't have focus (Closed)
Patch Set: 2017-01-12T13:25:32 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 /* 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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 return false; 53 return false;
54 return command.execute(evt); 54 return command.execute(evt);
55 } 55 }
56 56
57 if (command.execute(evt)) 57 if (command.execute(evt))
58 return true; 58 return true;
59 59
60 if (!behavior().shouldInsertCharacter(*evt) || !canEdit()) 60 if (!behavior().shouldInsertCharacter(*evt) || !canEdit())
61 return false; 61 return false;
62 62
63 const Element* const focusedElement = m_frame->document()->focusedElement();
64 if (!focusedElement) {
65 // We may lose focused element by |command.execute(evt)|.
66 return false;
67 }
68 if (!focusedElement->containsIncludingHostElements(
69 *m_frame->selection().start().computeContainerNode())) {
70 // We should not insert text at selection start if selection doesn't have
71 // focus. See http://crbug.com/89026
72 return false;
73 }
74
63 // Return true to prevent default action. e.g. Space key scroll. 75 // Return true to prevent default action. e.g. Space key scroll.
64 if (dispatchBeforeInputInsertText(evt->target(), keyEvent->text) != 76 if (dispatchBeforeInputInsertText(evt->target(), keyEvent->text) !=
65 DispatchEventResult::NotCanceled) 77 DispatchEventResult::NotCanceled)
66 return true; 78 return true;
67 79
68 return insertText(keyEvent->text, evt); 80 return insertText(keyEvent->text, evt);
69 } 81 }
70 82
71 void Editor::handleKeyboardEvent(KeyboardEvent* evt) { 83 void Editor::handleKeyboardEvent(KeyboardEvent* evt) {
72 // Give the embedder a chance to handle the keyboard event. 84 // Give the embedder a chance to handle the keyboard event.
73 if (client().handleKeyboardEvent(m_frame) || handleEditingKeyboardEvent(evt)) 85 if (client().handleKeyboardEvent(m_frame) || handleEditingKeyboardEvent(evt))
74 evt->setDefaultHandled(); 86 evt->setDefaultHandled();
75 } 87 }
76 88
77 } // namespace blink 89 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698