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

Side by Side Diff: content/browser/renderer_host/render_widget_host_impl.cc

Issue 2482853002: Suppress KeyUp events after PreHandleKeyboardEvent consumes RawKeyDown (Closed)
Patch Set: Created 4 years, 1 month 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
« no previous file with comments | « no previous file | content/browser/renderer_host/render_widget_host_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "content/browser/renderer_host/render_widget_host_impl.h" 5 #include "content/browser/renderer_host/render_widget_host_impl.h"
6 6
7 #include <math.h> 7 #include <math.h>
8 8
9 #include <set> 9 #include <set>
10 #include <tuple> 10 #include <tuple>
(...skipping 1125 matching lines...) Expand 10 before | Expand all | Expand 10 after
1136 suppress_next_char_events_ = true; 1136 suppress_next_char_events_ = true;
1137 return; 1137 return;
1138 } 1138 }
1139 1139
1140 // Double check the type to make sure caller hasn't sent us nonsense that 1140 // Double check the type to make sure caller hasn't sent us nonsense that
1141 // will mess up our key queue. 1141 // will mess up our key queue.
1142 if (!WebInputEvent::isKeyboardEventType(key_event.type)) 1142 if (!WebInputEvent::isKeyboardEventType(key_event.type))
1143 return; 1143 return;
1144 1144
1145 if (suppress_next_char_events_) { 1145 if (suppress_next_char_events_) {
1146 // If preceding RawKeyDown event was handled by the browser, then we need 1146 // If the preceding RawKeyDown event was handled by the browser, then we
1147 // suppress all Char events generated by it. Please note that, one 1147 // need to suppress all events generated by it until the next RawKeyDown or
dtapuska 2016/11/07 16:00:44 The member variable name is slightly confusing now
Matt Giuca 2016/11/08 03:04:15 +1
1148 // RawKeyDown event may generate multiple Char events, so we can't reset 1148 // KeyDown event.
1149 // |suppress_next_char_events_| until we get a KeyUp or a RawKeyDown. 1149 if (key_event.type == WebKeyboardEvent::KeyUp ||
1150 if (key_event.type == WebKeyboardEvent::Char) 1150 key_event.type == WebKeyboardEvent::Char)
Matt Giuca 2016/11/08 03:04:15 So I thought about the case where you interleave t
1151 return; 1151 return;
1152 // We get a KeyUp or a RawKeyDown event. 1152 DCHECK(key_event.type == WebKeyboardEvent::RawKeyDown ||
1153 key_event.type == WebKeyboardEvent::KeyDown);
1153 suppress_next_char_events_ = false; 1154 suppress_next_char_events_ = false;
1154 } 1155 }
1155 1156
1156 bool is_shortcut = false; 1157 bool is_shortcut = false;
1157 1158
1158 // Only pre-handle the key event if it's not handled by the input method. 1159 // Only pre-handle the key event if it's not handled by the input method.
1159 if (delegate_ && !key_event.skip_in_browser) { 1160 if (delegate_ && !key_event.skip_in_browser) {
1160 // We need to set |suppress_next_char_events_| to true if 1161 // We need to set |suppress_next_char_events_| to true if
1161 // PreHandleKeyboardEvent() returns true, but |this| may already be 1162 // PreHandleKeyboardEvent() returns true, but |this| may already be
1162 // destroyed at that time. So set |suppress_next_char_events_| true here, 1163 // destroyed at that time. So set |suppress_next_char_events_| true here,
(...skipping 1052 matching lines...) Expand 10 before | Expand all | Expand 10 after
2215 return delegate_ ? delegate_->GetRootBrowserAccessibilityManager() : NULL; 2216 return delegate_ ? delegate_->GetRootBrowserAccessibilityManager() : NULL;
2216 } 2217 }
2217 2218
2218 BrowserAccessibilityManager* 2219 BrowserAccessibilityManager*
2219 RenderWidgetHostImpl::GetOrCreateRootBrowserAccessibilityManager() { 2220 RenderWidgetHostImpl::GetOrCreateRootBrowserAccessibilityManager() {
2220 return delegate_ ? 2221 return delegate_ ?
2221 delegate_->GetOrCreateRootBrowserAccessibilityManager() : NULL; 2222 delegate_->GetOrCreateRootBrowserAccessibilityManager() : NULL;
2222 } 2223 }
2223 2224
2224 } // namespace content 2225 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/browser/renderer_host/render_widget_host_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698