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

Side by Side Diff: chrome/browser/renderer_host/render_widget_host_view_win.cc

Issue 384101: Ignore keyboard messages from enter key in renderer if they were not initiate... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/renderer_host/render_widget_host_view_win.h ('k') | no next file » | 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) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 "chrome/browser/renderer_host/render_widget_host_view_win.h" 5 #include "chrome/browser/renderer_host/render_widget_host_view_win.h"
6 6
7 #include "app/gfx/canvas.h" 7 #include "app/gfx/canvas.h"
8 #include "app/gfx/gdi_util.h" 8 #include "app/gfx/gdi_util.h"
9 #include "app/l10n_util.h" 9 #include "app/l10n_util.h"
10 #include "app/l10n_util_win.h" 10 #include "app/l10n_util_win.h"
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 return new RenderWidgetHostViewWin(widget); 209 return new RenderWidgetHostViewWin(widget);
210 } 210 }
211 211
212 /////////////////////////////////////////////////////////////////////////////// 212 ///////////////////////////////////////////////////////////////////////////////
213 // RenderWidgetHostViewWin, public: 213 // RenderWidgetHostViewWin, public:
214 214
215 RenderWidgetHostViewWin::RenderWidgetHostViewWin(RenderWidgetHost* widget) 215 RenderWidgetHostViewWin::RenderWidgetHostViewWin(RenderWidgetHost* widget)
216 : render_widget_host_(widget), 216 : render_widget_host_(widget),
217 track_mouse_leave_(false), 217 track_mouse_leave_(false),
218 ime_notification_(false), 218 ime_notification_(false),
219 capture_enter_key_(false),
219 is_hidden_(false), 220 is_hidden_(false),
220 about_to_validate_and_paint_(false), 221 about_to_validate_and_paint_(false),
221 close_on_deactivate_(false), 222 close_on_deactivate_(false),
222 being_destroyed_(false), 223 being_destroyed_(false),
223 tooltip_hwnd_(NULL), 224 tooltip_hwnd_(NULL),
224 tooltip_showing_(false), 225 tooltip_showing_(false),
225 shutdown_factory_(this), 226 shutdown_factory_(this),
226 parent_hwnd_(NULL), 227 parent_hwnd_(NULL),
227 is_loading_(false) { 228 is_loading_(false) {
228 render_widget_host_->set_view(this); 229 render_widget_host_->set_view(this);
(...skipping 940 matching lines...) Expand 10 before | Expand all | Expand 10 after
1169 // It is harmless to call this function if we aren't going to send it. 1170 // It is harmless to call this function if we aren't going to send it.
1170 render_widget_host_->CancelUpdateTextDirection(); 1171 render_widget_host_->CancelUpdateTextDirection();
1171 } 1172 }
1172 } else if (message == WM_KEYUP && 1173 } else if (message == WM_KEYUP &&
1173 (wparam == VK_SHIFT || wparam == VK_CONTROL)) { 1174 (wparam == VK_SHIFT || wparam == VK_CONTROL)) {
1174 // We send an IPC message only if we need to update the text direction. 1175 // We send an IPC message only if we need to update the text direction.
1175 render_widget_host_->NotifyTextDirection(); 1176 render_widget_host_->NotifyTextDirection();
1176 } 1177 }
1177 } 1178 }
1178 1179
1179 if (render_widget_host_) { 1180 // Special processing for enter key: When user hits enter in omnibox
1181 // we change focus to render host after the navigation, so repeat WM_KEYDOWNs
1182 // and WM_KEYUP are going to render host, despite being initiated in other
1183 // window. This code filters out these messages.
1184 bool ignore_keyboard_event = false;
1185 if (wparam == VK_RETURN) {
1186 if (message == WM_KEYDOWN) {
1187 if (KF_REPEAT & HIWORD(lparam)) {
1188 // this is a repeated key
1189 if (!capture_enter_key_)
1190 ignore_keyboard_event = true;
1191 } else {
1192 capture_enter_key_ = true;
1193 }
1194 } else if (message == WM_KEYUP) {
1195 if (!capture_enter_key_)
1196 ignore_keyboard_event = true;
1197 capture_enter_key_ = false;
1198 } else {
1199 // Ignore all other keyboard events for the enter key if not captured.
1200 if (!capture_enter_key_)
1201 ignore_keyboard_event = true;
1202 }
1203 }
1204
1205 if (render_widget_host_ && !ignore_keyboard_event) {
1180 render_widget_host_->ForwardKeyboardEvent( 1206 render_widget_host_->ForwardKeyboardEvent(
1181 NativeWebKeyboardEvent(m_hWnd, message, wparam, lparam)); 1207 NativeWebKeyboardEvent(m_hWnd, message, wparam, lparam));
1182 } 1208 }
1183 return 0; 1209 return 0;
1184 } 1210 }
1185 1211
1186 LRESULT RenderWidgetHostViewWin::OnWheelEvent(UINT message, WPARAM wparam, 1212 LRESULT RenderWidgetHostViewWin::OnWheelEvent(UINT message, WPARAM wparam,
1187 LPARAM lparam, BOOL& handled) { 1213 LPARAM lparam, BOOL& handled) {
1188 // Forward the mouse-wheel message to the window under the mouse if it belongs 1214 // Forward the mouse-wheel message to the window under the mouse if it belongs
1189 // to us. 1215 // to us.
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
1402 SetFocus(); 1428 SetFocus();
1403 } 1429 }
1404 } 1430 }
1405 1431
1406 void RenderWidgetHostViewWin::ShutdownHost() { 1432 void RenderWidgetHostViewWin::ShutdownHost() {
1407 shutdown_factory_.RevokeAll(); 1433 shutdown_factory_.RevokeAll();
1408 if (render_widget_host_) 1434 if (render_widget_host_)
1409 render_widget_host_->Shutdown(); 1435 render_widget_host_->Shutdown();
1410 // Do not touch any members at this point, |this| has been deleted. 1436 // Do not touch any members at this point, |this| has been deleted.
1411 } 1437 }
OLDNEW
« no previous file with comments | « chrome/browser/renderer_host/render_widget_host_view_win.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698