| OLD | NEW |
| 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 Loading... |
| 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), | |
| 220 is_hidden_(false), | 219 is_hidden_(false), |
| 221 about_to_validate_and_paint_(false), | 220 about_to_validate_and_paint_(false), |
| 222 close_on_deactivate_(false), | 221 close_on_deactivate_(false), |
| 223 being_destroyed_(false), | 222 being_destroyed_(false), |
| 224 tooltip_hwnd_(NULL), | 223 tooltip_hwnd_(NULL), |
| 225 tooltip_showing_(false), | 224 tooltip_showing_(false), |
| 226 shutdown_factory_(this), | 225 shutdown_factory_(this), |
| 227 parent_hwnd_(NULL), | 226 parent_hwnd_(NULL), |
| 228 is_loading_(false) { | 227 is_loading_(false) { |
| 229 render_widget_host_->set_view(this); | 228 render_widget_host_->set_view(this); |
| (...skipping 951 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1181 // It is harmless to call this function if we aren't going to send it. | 1180 // It is harmless to call this function if we aren't going to send it. |
| 1182 render_widget_host_->CancelUpdateTextDirection(); | 1181 render_widget_host_->CancelUpdateTextDirection(); |
| 1183 } | 1182 } |
| 1184 } else if (message == WM_KEYUP && | 1183 } else if (message == WM_KEYUP && |
| 1185 (wparam == VK_SHIFT || wparam == VK_CONTROL)) { | 1184 (wparam == VK_SHIFT || wparam == VK_CONTROL)) { |
| 1186 // We send an IPC message only if we need to update the text direction. | 1185 // We send an IPC message only if we need to update the text direction. |
| 1187 render_widget_host_->NotifyTextDirection(); | 1186 render_widget_host_->NotifyTextDirection(); |
| 1188 } | 1187 } |
| 1189 } | 1188 } |
| 1190 | 1189 |
| 1191 // Special processing for enter key: When user hits enter in omnibox | 1190 if (render_widget_host_) { |
| 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) { | |
| 1217 render_widget_host_->ForwardKeyboardEvent( | 1191 render_widget_host_->ForwardKeyboardEvent( |
| 1218 NativeWebKeyboardEvent(m_hWnd, message, wparam, lparam)); | 1192 NativeWebKeyboardEvent(m_hWnd, message, wparam, lparam)); |
| 1219 } | 1193 } |
| 1220 return 0; | 1194 return 0; |
| 1221 } | 1195 } |
| 1222 | 1196 |
| 1223 LRESULT RenderWidgetHostViewWin::OnWheelEvent(UINT message, WPARAM wparam, | 1197 LRESULT RenderWidgetHostViewWin::OnWheelEvent(UINT message, WPARAM wparam, |
| 1224 LPARAM lparam, BOOL& handled) { | 1198 LPARAM lparam, BOOL& handled) { |
| 1225 // Forward the mouse-wheel message to the window under the mouse if it belongs | 1199 // Forward the mouse-wheel message to the window under the mouse if it belongs |
| 1226 // to us. | 1200 // to us. |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1439 SetFocus(); | 1413 SetFocus(); |
| 1440 } | 1414 } |
| 1441 } | 1415 } |
| 1442 | 1416 |
| 1443 void RenderWidgetHostViewWin::ShutdownHost() { | 1417 void RenderWidgetHostViewWin::ShutdownHost() { |
| 1444 shutdown_factory_.RevokeAll(); | 1418 shutdown_factory_.RevokeAll(); |
| 1445 if (render_widget_host_) | 1419 if (render_widget_host_) |
| 1446 render_widget_host_->Shutdown(); | 1420 render_widget_host_->Shutdown(); |
| 1447 // Do not touch any members at this point, |this| has been deleted. | 1421 // Do not touch any members at this point, |this| has been deleted. |
| 1448 } | 1422 } |
| OLD | NEW |