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/renderer/render_widget.h" | 5 #include "chrome/renderer/render_widget.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/gfx/point.h" | 8 #include "base/gfx/point.h" |
9 #include "base/gfx/size.h" | 9 #include "base/gfx/size.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 handling_input_event_(false), | 60 handling_input_event_(false), |
61 closing_(false), | 61 closing_(false), |
62 ime_is_active_(false), | 62 ime_is_active_(false), |
63 ime_control_enable_ime_(true), | 63 ime_control_enable_ime_(true), |
64 ime_control_x_(-1), | 64 ime_control_x_(-1), |
65 ime_control_y_(-1), | 65 ime_control_y_(-1), |
66 ime_control_new_state_(false), | 66 ime_control_new_state_(false), |
67 ime_control_updated_(false), | 67 ime_control_updated_(false), |
68 ime_control_busy_(false), | 68 ime_control_busy_(false), |
69 activatable_(activatable), | 69 activatable_(activatable), |
70 pending_window_rect_count_(0) { | 70 pending_window_rect_count_(0), |
| 71 suppress_next_char_events_(false) { |
71 RenderProcess::current()->AddRefProcess(); | 72 RenderProcess::current()->AddRefProcess(); |
72 DCHECK(render_thread_); | 73 DCHECK(render_thread_); |
73 } | 74 } |
74 | 75 |
75 RenderWidget::~RenderWidget() { | 76 RenderWidget::~RenderWidget() { |
76 DCHECK(!webwidget_) << "Leaking our WebWidget!"; | 77 DCHECK(!webwidget_) << "Leaking our WebWidget!"; |
77 if (current_paint_buf_) { | 78 if (current_paint_buf_) { |
78 RenderProcess::current()->ReleaseTransportDIB(current_paint_buf_); | 79 RenderProcess::current()->ReleaseTransportDIB(current_paint_buf_); |
79 current_paint_buf_ = NULL; | 80 current_paint_buf_ = NULL; |
80 } | 81 } |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
297 const char* data; | 298 const char* data; |
298 int data_length; | 299 int data_length; |
299 handling_input_event_ = true; | 300 handling_input_event_ = true; |
300 if (!message.ReadData(&iter, &data, &data_length)) { | 301 if (!message.ReadData(&iter, &data, &data_length)) { |
301 handling_input_event_ = false; | 302 handling_input_event_ = false; |
302 return; | 303 return; |
303 } | 304 } |
304 | 305 |
305 const WebInputEvent* input_event = | 306 const WebInputEvent* input_event = |
306 reinterpret_cast<const WebInputEvent*>(data); | 307 reinterpret_cast<const WebInputEvent*>(data); |
| 308 |
| 309 bool is_keyboard_shortcut = false; |
| 310 // is_keyboard_shortcut flag is only available for RawKeyDown events. |
| 311 if (input_event->type == WebInputEvent::RawKeyDown) |
| 312 message.ReadBool(&iter, &is_keyboard_shortcut); |
| 313 |
307 bool processed = false; | 314 bool processed = false; |
308 if (webwidget_) | 315 if (input_event->type != WebInputEvent::Char || !suppress_next_char_events_) { |
309 processed = webwidget_->handleInputEvent(*input_event); | 316 suppress_next_char_events_ = false; |
| 317 if (webwidget_) |
| 318 processed = webwidget_->handleInputEvent(*input_event); |
| 319 } |
| 320 |
| 321 // If this RawKeyDown event corresponds to a browser keyboard shortcut and |
| 322 // it's not processed by webkit, then we need to suppress the upcoming Char |
| 323 // events. |
| 324 if (!processed && is_keyboard_shortcut) |
| 325 suppress_next_char_events_ = true; |
310 | 326 |
311 IPC::Message* response = new ViewHostMsg_HandleInputEvent_ACK(routing_id_); | 327 IPC::Message* response = new ViewHostMsg_HandleInputEvent_ACK(routing_id_); |
312 response->WriteInt(input_event->type); | 328 response->WriteInt(input_event->type); |
313 response->WriteBool(processed); | 329 response->WriteBool(processed); |
314 | 330 |
315 if (input_event->type == WebInputEvent::MouseMove && | 331 if (input_event->type == WebInputEvent::MouseMove && |
316 paint_aggregator_.HasPendingUpdate()) { | 332 paint_aggregator_.HasPendingUpdate()) { |
317 // We want to rate limit the input events in this case, so we'll wait for | 333 // We want to rate limit the input events in this case, so we'll wait for |
318 // painting to finish before ACKing this message. | 334 // painting to finish before ACKing this message. |
319 pending_input_event_ack_.reset(response); | 335 pending_input_event_ack_.reset(response); |
320 } else { | 336 } else { |
321 Send(response); | 337 Send(response); |
322 } | 338 } |
323 | 339 |
324 handling_input_event_ = false; | 340 handling_input_event_ = false; |
325 | 341 |
326 WebInputEvent::Type type = input_event->type; | 342 if (WebInputEvent::isKeyboardEventType(input_event->type)) |
327 if (type == WebInputEvent::RawKeyDown || type == WebInputEvent::KeyDown || | |
328 type == WebInputEvent::KeyUp || type == WebInputEvent::Char) | |
329 DidHandleKeyEvent(); | 343 DidHandleKeyEvent(); |
330 } | 344 } |
331 | 345 |
332 void RenderWidget::OnMouseCaptureLost() { | 346 void RenderWidget::OnMouseCaptureLost() { |
333 if (webwidget_) | 347 if (webwidget_) |
334 webwidget_->mouseCaptureLost(); | 348 webwidget_->mouseCaptureLost(); |
335 } | 349 } |
336 | 350 |
337 void RenderWidget::OnSetFocus(bool enable) { | 351 void RenderWidget::OnSetFocus(bool enable) { |
338 has_focus_ = enable; | 352 has_focus_ = enable; |
(...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
868 | 882 |
869 void RenderWidget::CleanupWindowInPluginMoves(gfx::PluginWindowHandle window) { | 883 void RenderWidget::CleanupWindowInPluginMoves(gfx::PluginWindowHandle window) { |
870 for (WebPluginGeometryVector::iterator i = plugin_window_moves_.begin(); | 884 for (WebPluginGeometryVector::iterator i = plugin_window_moves_.begin(); |
871 i != plugin_window_moves_.end(); ++i) { | 885 i != plugin_window_moves_.end(); ++i) { |
872 if (i->window == window) { | 886 if (i->window == window) { |
873 plugin_window_moves_.erase(i); | 887 plugin_window_moves_.erase(i); |
874 break; | 888 break; |
875 } | 889 } |
876 } | 890 } |
877 } | 891 } |
OLD | NEW |