| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "base/bind_helpers.h" | 5 #include "base/bind_helpers.h" |
| 6 #include "base/command_line.h" | 6 #include "base/command_line.h" |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "cc/surfaces/surface.h" | 9 #include "cc/surfaces/surface.h" |
| 10 #include "cc/surfaces/surface_factory.h" | 10 #include "cc/surfaces/surface_factory.h" |
| (...skipping 607 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 618 return static_cast<RenderWidgetHostViewBase*>( | 618 return static_cast<RenderWidgetHostViewBase*>( |
| 619 guest_->GetOwnerRenderWidgetHostView()); | 619 guest_->GetOwnerRenderWidgetHostView()); |
| 620 } | 620 } |
| 621 | 621 |
| 622 void RenderWidgetHostViewGuest::OnHandleInputEvent( | 622 void RenderWidgetHostViewGuest::OnHandleInputEvent( |
| 623 RenderWidgetHostImpl* embedder, | 623 RenderWidgetHostImpl* embedder, |
| 624 int browser_plugin_instance_id, | 624 int browser_plugin_instance_id, |
| 625 const gfx::Rect& guest_window_rect, | 625 const gfx::Rect& guest_window_rect, |
| 626 const blink::WebInputEvent* event) { | 626 const blink::WebInputEvent* event) { |
| 627 if (blink::WebInputEvent::isMouseEventType(event->type)) { | 627 if (blink::WebInputEvent::isMouseEventType(event->type)) { |
| 628 host_->ForwardMouseEvent( | 628 // The mouse events for BrowserPlugin are modified by all |
| 629 *static_cast<const blink::WebMouseEvent*>(event)); | 629 // the CSS transforms applied on the <object> and embedder. As a result of |
| 630 // this, the coordinates passed on to the guest renderer are potentially |
| 631 // incorrect to determine the position of the context menu(they are not the |
| 632 // actual X, Y of the window). As a hack, we report the last location of a |
| 633 // right mouse up to the BrowserPluginGuest to inform it of the next |
| 634 // potential location for context menu (BUG=470087). |
| 635 // TODO(ekaramad): Find a better and more fundamental solution. Could the |
| 636 // ContextMenuParams be based on global X, Y? |
| 637 const blink::WebMouseEvent& mouse_event = |
| 638 static_cast<const blink::WebMouseEvent&>(*event); |
| 639 // A MouseDown on the ButtonRight could suggest a ContextMenu. |
| 640 if (guest_ && mouse_event.type == blink::WebInputEvent::MouseDown && |
| 641 mouse_event.button == blink::WebPointerProperties::ButtonRight) |
| 642 guest_->SetContextMenuPosition( |
| 643 gfx::Point(mouse_event.globalX - GetViewBounds().x(), |
| 644 mouse_event.globalY - GetViewBounds().y())); |
| 645 host_->ForwardMouseEvent(mouse_event); |
| 630 return; | 646 return; |
| 631 } | 647 } |
| 632 | 648 |
| 633 if (event->type == blink::WebInputEvent::MouseWheel) { | 649 if (event->type == blink::WebInputEvent::MouseWheel) { |
| 634 host_->ForwardWheelEvent( | 650 host_->ForwardWheelEvent( |
| 635 *static_cast<const blink::WebMouseWheelEvent*>(event)); | 651 *static_cast<const blink::WebMouseWheelEvent*>(event)); |
| 636 return; | 652 return; |
| 637 } | 653 } |
| 638 | 654 |
| 639 if (blink::WebInputEvent::isKeyboardEventType(event->type)) { | 655 if (blink::WebInputEvent::isKeyboardEventType(event->type)) { |
| (...skipping 17 matching lines...) Expand all Loading... |
| 657 } | 673 } |
| 658 | 674 |
| 659 if (blink::WebInputEvent::isGestureEventType(event->type)) { | 675 if (blink::WebInputEvent::isGestureEventType(event->type)) { |
| 660 host_->ForwardGestureEvent( | 676 host_->ForwardGestureEvent( |
| 661 *static_cast<const blink::WebGestureEvent*>(event)); | 677 *static_cast<const blink::WebGestureEvent*>(event)); |
| 662 return; | 678 return; |
| 663 } | 679 } |
| 664 } | 680 } |
| 665 | 681 |
| 666 } // namespace content | 682 } // namespace content |
| OLD | NEW |