OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/renderer/render_widget.h" | 5 #include "content/renderer/render_widget.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 needs_repainting_on_restore_(false), | 84 needs_repainting_on_restore_(false), |
85 has_focus_(false), | 85 has_focus_(false), |
86 handling_input_event_(false), | 86 handling_input_event_(false), |
87 closing_(false), | 87 closing_(false), |
88 is_swapped_out_(false), | 88 is_swapped_out_(false), |
89 input_method_is_active_(false), | 89 input_method_is_active_(false), |
90 text_input_type_(ui::TEXT_INPUT_TYPE_NONE), | 90 text_input_type_(ui::TEXT_INPUT_TYPE_NONE), |
91 can_compose_inline_(true), | 91 can_compose_inline_(true), |
92 popup_type_(popup_type), | 92 popup_type_(popup_type), |
93 pending_window_rect_count_(0), | 93 pending_window_rect_count_(0), |
| 94 suppress_next_char_events_(false), |
94 is_accelerated_compositing_active_(false), | 95 is_accelerated_compositing_active_(false), |
95 animation_update_pending_(false), | 96 animation_update_pending_(false), |
96 animation_task_posted_(false), | 97 animation_task_posted_(false), |
97 invalidation_task_posted_(false) { | 98 invalidation_task_posted_(false) { |
98 RenderProcess::current()->AddRefProcess(); | 99 RenderProcess::current()->AddRefProcess(); |
99 DCHECK(RenderThread::Get()); | 100 DCHECK(RenderThread::Get()); |
100 has_disable_gpu_vsync_switch_ = CommandLine::ForCurrentProcess()->HasSwitch( | 101 has_disable_gpu_vsync_switch_ = CommandLine::ForCurrentProcess()->HasSwitch( |
101 switches::kDisableGpuVsync); | 102 switches::kDisableGpuVsync); |
102 } | 103 } |
103 | 104 |
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
438 int data_length; | 439 int data_length; |
439 handling_input_event_ = true; | 440 handling_input_event_ = true; |
440 if (!message.ReadData(&iter, &data, &data_length)) { | 441 if (!message.ReadData(&iter, &data, &data_length)) { |
441 handling_input_event_ = false; | 442 handling_input_event_ = false; |
442 return; | 443 return; |
443 } | 444 } |
444 | 445 |
445 const WebInputEvent* input_event = | 446 const WebInputEvent* input_event = |
446 reinterpret_cast<const WebInputEvent*>(data); | 447 reinterpret_cast<const WebInputEvent*>(data); |
447 | 448 |
| 449 bool is_keyboard_shortcut = false; |
| 450 // is_keyboard_shortcut flag is only available for RawKeyDown events. |
| 451 if (input_event->type == WebInputEvent::RawKeyDown) |
| 452 message.ReadBool(&iter, &is_keyboard_shortcut); |
| 453 |
448 bool prevent_default = false; | 454 bool prevent_default = false; |
449 if (WebInputEvent::isMouseEventType(input_event->type)) { | 455 if (WebInputEvent::isMouseEventType(input_event->type)) { |
450 prevent_default = WillHandleMouseEvent( | 456 prevent_default = WillHandleMouseEvent( |
451 *(static_cast<const WebMouseEvent*>(input_event))); | 457 *(static_cast<const WebMouseEvent*>(input_event))); |
452 } | 458 } |
453 | 459 |
454 bool processed = prevent_default; | 460 bool processed = prevent_default; |
455 if (!processed && webwidget_) | 461 if (input_event->type != WebInputEvent::Char || !suppress_next_char_events_) { |
456 processed = webwidget_->handleInputEvent(*input_event); | 462 suppress_next_char_events_ = false; |
| 463 if (!processed && webwidget_) |
| 464 processed = webwidget_->handleInputEvent(*input_event); |
| 465 } |
| 466 |
| 467 // If this RawKeyDown event corresponds to a browser keyboard shortcut and |
| 468 // it's not processed by webkit, then we need to suppress the upcoming Char |
| 469 // events. |
| 470 if (!processed && is_keyboard_shortcut) |
| 471 suppress_next_char_events_ = true; |
457 | 472 |
458 IPC::Message* response = | 473 IPC::Message* response = |
459 new ViewHostMsg_HandleInputEvent_ACK(routing_id_, input_event->type, | 474 new ViewHostMsg_HandleInputEvent_ACK(routing_id_, input_event->type, |
460 processed); | 475 processed); |
461 | 476 |
462 if ((input_event->type == WebInputEvent::MouseMove || | 477 if ((input_event->type == WebInputEvent::MouseMove || |
463 input_event->type == WebInputEvent::MouseWheel || | 478 input_event->type == WebInputEvent::MouseWheel || |
464 input_event->type == WebInputEvent::TouchMove) && | 479 input_event->type == WebInputEvent::TouchMove) && |
465 paint_aggregator_.HasPendingUpdate()) { | 480 paint_aggregator_.HasPendingUpdate()) { |
466 // We want to rate limit the input events in this case, so we'll wait for | 481 // We want to rate limit the input events in this case, so we'll wait for |
(...skipping 1021 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1488 } | 1503 } |
1489 } | 1504 } |
1490 | 1505 |
1491 bool RenderWidget::WillHandleMouseEvent(const WebKit::WebMouseEvent& event) { | 1506 bool RenderWidget::WillHandleMouseEvent(const WebKit::WebMouseEvent& event) { |
1492 return false; | 1507 return false; |
1493 } | 1508 } |
1494 | 1509 |
1495 bool RenderWidget::WebWidgetHandlesCompositorScheduling() const { | 1510 bool RenderWidget::WebWidgetHandlesCompositorScheduling() const { |
1496 return false; | 1511 return false; |
1497 } | 1512 } |
OLD | NEW |