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/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/debug/trace_event.h" | 8 #include "base/debug/trace_event.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
439 } | 439 } |
440 | 440 |
441 const WebInputEvent* input_event = | 441 const WebInputEvent* input_event = |
442 reinterpret_cast<const WebInputEvent*>(data); | 442 reinterpret_cast<const WebInputEvent*>(data); |
443 | 443 |
444 bool is_keyboard_shortcut = false; | 444 bool is_keyboard_shortcut = false; |
445 // is_keyboard_shortcut flag is only available for RawKeyDown events. | 445 // is_keyboard_shortcut flag is only available for RawKeyDown events. |
446 if (input_event->type == WebInputEvent::RawKeyDown) | 446 if (input_event->type == WebInputEvent::RawKeyDown) |
447 message.ReadBool(&iter, &is_keyboard_shortcut); | 447 message.ReadBool(&iter, &is_keyboard_shortcut); |
448 | 448 |
449 bool processed = false; | 449 bool prevent_default = false; |
| 450 if (WebInputEvent::isMouseEventType(input_event->type)) { |
| 451 prevent_default = WillHandleMouseEvent( |
| 452 *(static_cast<const WebMouseEvent*>(input_event))); |
| 453 } |
| 454 |
| 455 bool processed = prevent_default; |
450 if (input_event->type != WebInputEvent::Char || !suppress_next_char_events_) { | 456 if (input_event->type != WebInputEvent::Char || !suppress_next_char_events_) { |
451 suppress_next_char_events_ = false; | 457 suppress_next_char_events_ = false; |
452 if (webwidget_) | 458 if (!processed && webwidget_) |
453 processed = webwidget_->handleInputEvent(*input_event); | 459 processed = webwidget_->handleInputEvent(*input_event); |
454 } | 460 } |
455 | 461 |
456 // If this RawKeyDown event corresponds to a browser keyboard shortcut and | 462 // If this RawKeyDown event corresponds to a browser keyboard shortcut and |
457 // it's not processed by webkit, then we need to suppress the upcoming Char | 463 // it's not processed by webkit, then we need to suppress the upcoming Char |
458 // events. | 464 // events. |
459 if (!processed && is_keyboard_shortcut) | 465 if (!processed && is_keyboard_shortcut) |
460 suppress_next_char_events_ = true; | 466 suppress_next_char_events_ = true; |
461 | 467 |
462 IPC::Message* response = new ViewHostMsg_HandleInputEvent_ACK(routing_id_); | 468 IPC::Message* response = new ViewHostMsg_HandleInputEvent_ACK(routing_id_); |
(...skipping 12 matching lines...) Expand all Loading... |
475 // send us the same kind of event we are delaying the ack for. | 481 // send us the same kind of event we are delaying the ack for. |
476 Send(pending_input_event_ack_.release()); | 482 Send(pending_input_event_ack_.release()); |
477 } | 483 } |
478 pending_input_event_ack_.reset(response); | 484 pending_input_event_ack_.reset(response); |
479 } else { | 485 } else { |
480 Send(response); | 486 Send(response); |
481 } | 487 } |
482 | 488 |
483 handling_input_event_ = false; | 489 handling_input_event_ = false; |
484 | 490 |
485 if (WebInputEvent::isKeyboardEventType(input_event->type)) | 491 if (!prevent_default) { |
486 DidHandleKeyEvent(); | 492 if (WebInputEvent::isKeyboardEventType(input_event->type)) |
487 if (WebInputEvent::isMouseEventType(input_event->type)) | 493 DidHandleKeyEvent(); |
488 DidHandleMouseEvent(*(static_cast<const WebMouseEvent*>(input_event))); | 494 if (WebInputEvent::isMouseEventType(input_event->type)) |
| 495 DidHandleMouseEvent(*(static_cast<const WebMouseEvent*>(input_event))); |
| 496 } |
489 } | 497 } |
490 | 498 |
491 void RenderWidget::OnMouseCaptureLost() { | 499 void RenderWidget::OnMouseCaptureLost() { |
492 if (webwidget_) | 500 if (webwidget_) |
493 webwidget_->mouseCaptureLost(); | 501 webwidget_->mouseCaptureLost(); |
494 } | 502 } |
495 | 503 |
496 void RenderWidget::OnSetFocus(bool enable) { | 504 void RenderWidget::OnSetFocus(bool enable) { |
497 has_focus_ = enable; | 505 has_focus_ = enable; |
498 if (webwidget_) | 506 if (webwidget_) |
(...skipping 887 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1386 | 1394 |
1387 void RenderWidget::CleanupWindowInPluginMoves(gfx::PluginWindowHandle window) { | 1395 void RenderWidget::CleanupWindowInPluginMoves(gfx::PluginWindowHandle window) { |
1388 for (WebPluginGeometryVector::iterator i = plugin_window_moves_.begin(); | 1396 for (WebPluginGeometryVector::iterator i = plugin_window_moves_.begin(); |
1389 i != plugin_window_moves_.end(); ++i) { | 1397 i != plugin_window_moves_.end(); ++i) { |
1390 if (i->window == window) { | 1398 if (i->window == window) { |
1391 plugin_window_moves_.erase(i); | 1399 plugin_window_moves_.erase(i); |
1392 break; | 1400 break; |
1393 } | 1401 } |
1394 } | 1402 } |
1395 } | 1403 } |
| 1404 |
| 1405 bool RenderWidget::WillHandleMouseEvent(const WebKit::WebMouseEvent& event) { |
| 1406 return false; |
| 1407 } |
OLD | NEW |