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

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

Issue 393005: Revert 31877 - Revert 31869 Ignore keyboard messages from enter key in rende... (Closed) Base URL: svn://svn.chromium.org/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 951 matching lines...) Expand 10 before | Expand all | Expand 10 after
1180 // It is harmless to call this function if we aren't going to send it. 1181 // It is harmless to call this function if we aren't going to send it.
1181 render_widget_host_->CancelUpdateTextDirection(); 1182 render_widget_host_->CancelUpdateTextDirection();
1182 } 1183 }
1183 } else if (message == WM_KEYUP && 1184 } else if (message == WM_KEYUP &&
1184 (wparam == VK_SHIFT || wparam == VK_CONTROL)) { 1185 (wparam == VK_SHIFT || wparam == VK_CONTROL)) {
1185 // We send an IPC message only if we need to update the text direction. 1186 // We send an IPC message only if we need to update the text direction.
1186 render_widget_host_->NotifyTextDirection(); 1187 render_widget_host_->NotifyTextDirection();
1187 } 1188 }
1188 } 1189 }
1189 1190
1190 if (render_widget_host_) { 1191 // Special processing for enter key: When user hits enter in omnibox
1192 // we change focus to render host after the navigation, so repeat WM_KEYDOWNs
1193 // and WM_KEYUP are going to render host, despite being initiated in other
1194 // window. This code filters out these messages.
1195 bool ignore_keyboard_event = false;
1196 if (wparam == VK_RETURN) {
1197 if (message == WM_KEYDOWN) {
1198 if (KF_REPEAT & HIWORD(lparam)) {
1199 // this is a repeated key
1200 if (!capture_enter_key_)
1201 ignore_keyboard_event = true;
1202 } else {
1203 capture_enter_key_ = true;
1204 }
1205 } else if (message == WM_KEYUP) {
1206 if (!capture_enter_key_)
1207 ignore_keyboard_event = true;
1208 capture_enter_key_ = false;
1209 } else {
1210 // Ignore all other keyboard events for the enter key if not captured.
1211 if (!capture_enter_key_)
1212 ignore_keyboard_event = true;
1213 }
1214 }
1215
1216 if (render_widget_host_ && !ignore_keyboard_event) {
1191 render_widget_host_->ForwardKeyboardEvent( 1217 render_widget_host_->ForwardKeyboardEvent(
1192 NativeWebKeyboardEvent(m_hWnd, message, wparam, lparam)); 1218 NativeWebKeyboardEvent(m_hWnd, message, wparam, lparam));
1193 } 1219 }
1194 return 0; 1220 return 0;
1195 } 1221 }
1196 1222
1197 LRESULT RenderWidgetHostViewWin::OnWheelEvent(UINT message, WPARAM wparam, 1223 LRESULT RenderWidgetHostViewWin::OnWheelEvent(UINT message, WPARAM wparam,
1198 LPARAM lparam, BOOL& handled) { 1224 LPARAM lparam, BOOL& handled) {
1199 // Forward the mouse-wheel message to the window under the mouse if it belongs 1225 // Forward the mouse-wheel message to the window under the mouse if it belongs
1200 // to us. 1226 // to us.
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
1413 SetFocus(); 1439 SetFocus();
1414 } 1440 }
1415 } 1441 }
1416 1442
1417 void RenderWidgetHostViewWin::ShutdownHost() { 1443 void RenderWidgetHostViewWin::ShutdownHost() {
1418 shutdown_factory_.RevokeAll(); 1444 shutdown_factory_.RevokeAll();
1419 if (render_widget_host_) 1445 if (render_widget_host_)
1420 render_widget_host_->Shutdown(); 1446 render_widget_host_->Shutdown();
1421 // Do not touch any members at this point, |this| has been deleted. 1447 // Do not touch any members at this point, |this| has been deleted.
1422 } 1448 }
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