Chromium Code Reviews| 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 "content/browser/frame_host/render_widget_host_view_guest.h" | 5 #include "content/browser/frame_host/render_widget_host_view_guest.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind_helpers.h" | 9 #include "base/bind_helpers.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/memory/ptr_util.h" | 12 #include "base/memory/ptr_util.h" |
| 13 #include "base/message_loop/message_loop.h" | 13 #include "base/message_loop/message_loop.h" |
| 14 #include "build/build_config.h" | 14 #include "build/build_config.h" |
| 15 #include "cc/surfaces/surface.h" | 15 #include "cc/surfaces/surface.h" |
| 16 #include "cc/surfaces/surface_factory.h" | 16 #include "cc/surfaces/surface_factory.h" |
| 17 #include "cc/surfaces/surface_manager.h" | 17 #include "cc/surfaces/surface_manager.h" |
| 18 #include "cc/surfaces/surface_sequence.h" | 18 #include "cc/surfaces/surface_sequence.h" |
| 19 #include "content/browser/browser_plugin/browser_plugin_guest.h" | 19 #include "content/browser/browser_plugin/browser_plugin_guest.h" |
| 20 #include "content/browser/compositor/surface_utils.h" | 20 #include "content/browser/compositor/surface_utils.h" |
| 21 #include "content/browser/renderer_host/input/input_router.h" | |
| 21 #include "content/browser/renderer_host/render_view_host_impl.h" | 22 #include "content/browser/renderer_host/render_view_host_impl.h" |
| 22 #include "content/browser/renderer_host/render_widget_host_delegate.h" | 23 #include "content/browser/renderer_host/render_widget_host_delegate.h" |
| 23 #include "content/browser/renderer_host/render_widget_host_input_event_router.h" | 24 #include "content/browser/renderer_host/render_widget_host_input_event_router.h" |
| 24 #include "content/common/browser_plugin/browser_plugin_messages.h" | 25 #include "content/common/browser_plugin/browser_plugin_messages.h" |
| 26 #include "content/common/content_switches_internal.h" | |
| 25 #include "content/common/frame_messages.h" | 27 #include "content/common/frame_messages.h" |
| 26 #include "content/common/input/web_touch_event_traits.h" | 28 #include "content/common/input/web_touch_event_traits.h" |
| 27 #include "content/common/site_isolation_policy.h" | 29 #include "content/common/site_isolation_policy.h" |
| 28 #include "content/common/view_messages.h" | 30 #include "content/common/view_messages.h" |
| 29 #include "content/public/common/content_switches.h" | 31 #include "content/public/common/content_switches.h" |
| 30 #include "gpu/ipc/common/gpu_messages.h" | 32 #include "gpu/ipc/common/gpu_messages.h" |
| 31 #include "skia/ext/platform_canvas.h" | 33 #include "skia/ext/platform_canvas.h" |
| 32 #include "third_party/WebKit/public/platform/WebScreenInfo.h" | 34 #include "third_party/WebKit/public/platform/WebScreenInfo.h" |
| 33 | 35 |
| 34 #if defined(OS_MACOSX) | 36 #if defined(OS_MACOSX) |
| 35 #import "content/browser/renderer_host/render_widget_host_view_mac_dictionary_he lper.h" | 37 #import "content/browser/renderer_host/render_widget_host_view_mac_dictionary_he lper.h" |
| 36 #endif | 38 #endif |
| 37 | 39 |
| 38 #if defined(USE_AURA) | 40 #if defined(USE_AURA) |
| 39 #include "content/browser/renderer_host/ui_events_helper.h" | 41 #include "content/browser/renderer_host/ui_events_helper.h" |
| 40 #endif | 42 #endif |
| 41 | 43 |
| 42 namespace content { | 44 namespace content { |
| 45 namespace { | |
| 46 | |
| 47 class ScopedInputScaleDisabler { | |
| 48 public: | |
| 49 ScopedInputScaleDisabler(RenderWidgetHostImpl* host, float scale_factor) | |
| 50 : host_(host), scale_factor_(scale_factor) { | |
| 51 if (IsUseZoomForDSFEnabled()) | |
| 52 host_->input_router()->SetDeviceScaleFactor(1.0f); | |
| 53 } | |
| 54 | |
| 55 ~ScopedInputScaleDisabler() { | |
| 56 if (IsUseZoomForDSFEnabled()) | |
| 57 host_->input_router()->SetDeviceScaleFactor(scale_factor_); | |
| 58 } | |
| 59 | |
| 60 private: | |
| 61 RenderWidgetHostImpl* host_; | |
| 62 float scale_factor_; | |
| 63 | |
| 64 DISALLOW_COPY_AND_ASSIGN(ScopedInputScaleDisabler); | |
| 65 }; | |
| 66 | |
| 67 } // namespace | |
| 43 | 68 |
| 44 RenderWidgetHostViewGuest::RenderWidgetHostViewGuest( | 69 RenderWidgetHostViewGuest::RenderWidgetHostViewGuest( |
| 45 RenderWidgetHost* widget_host, | 70 RenderWidgetHost* widget_host, |
| 46 BrowserPluginGuest* guest, | 71 BrowserPluginGuest* guest, |
| 47 base::WeakPtr<RenderWidgetHostViewBase> platform_view) | 72 base::WeakPtr<RenderWidgetHostViewBase> platform_view) |
| 48 : RenderWidgetHostViewChildFrame(widget_host), | 73 : RenderWidgetHostViewChildFrame(widget_host), |
| 49 // |guest| is NULL during test. | 74 // |guest| is NULL during test. |
| 50 guest_(guest ? guest->AsWeakPtr() : base::WeakPtr<BrowserPluginGuest>()), | 75 guest_(guest ? guest->AsWeakPtr() : base::WeakPtr<BrowserPluginGuest>()), |
| 51 platform_view_(platform_view) { | 76 platform_view_(platform_view) { |
| 52 // Inputs for guest view are already scaled. | |
| 53 host_->set_scale_input_to_viewport(false); | |
| 54 } | 77 } |
| 55 | 78 |
| 56 RenderWidgetHostViewGuest::~RenderWidgetHostViewGuest() {} | 79 RenderWidgetHostViewGuest::~RenderWidgetHostViewGuest() {} |
| 57 | 80 |
| 58 bool RenderWidgetHostViewGuest::OnMessageReceivedFromEmbedder( | 81 bool RenderWidgetHostViewGuest::OnMessageReceivedFromEmbedder( |
| 59 const IPC::Message& message, | 82 const IPC::Message& message, |
| 60 RenderWidgetHostImpl* embedder) { | 83 RenderWidgetHostImpl* embedder) { |
| 61 bool handled = true; | 84 bool handled = true; |
| 62 IPC_BEGIN_MESSAGE_MAP_WITH_PARAM(RenderWidgetHostViewGuest, message, | 85 IPC_BEGIN_MESSAGE_MAP_WITH_PARAM(RenderWidgetHostViewGuest, message, |
| 63 embedder) | 86 embedder) |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 136 const TouchEventWithLatencyInfo& touch, InputEventAckState ack_result) { | 159 const TouchEventWithLatencyInfo& touch, InputEventAckState ack_result) { |
| 137 // TODO(tdresser): Since all ProcessAckedTouchEvent() uses is the event id, | 160 // TODO(tdresser): Since all ProcessAckedTouchEvent() uses is the event id, |
| 138 // don't pass the full event object here. https://crbug.com/550581. | 161 // don't pass the full event object here. https://crbug.com/550581. |
| 139 GetOwnerRenderWidgetHostView()->ProcessAckedTouchEvent(touch, ack_result); | 162 GetOwnerRenderWidgetHostView()->ProcessAckedTouchEvent(touch, ack_result); |
| 140 } | 163 } |
| 141 #endif | 164 #endif |
| 142 | 165 |
| 143 void RenderWidgetHostViewGuest::ProcessTouchEvent( | 166 void RenderWidgetHostViewGuest::ProcessTouchEvent( |
| 144 const blink::WebTouchEvent& event, | 167 const blink::WebTouchEvent& event, |
| 145 const ui::LatencyInfo& latency) { | 168 const ui::LatencyInfo& latency) { |
| 169 LOG(ERROR) << "Touch Event:" << WebInputEventTraits::ToString(event); | |
|
wjmaclean
2016/05/13 18:17:57
I'm not sure I understand what this is here for?
oshima
2016/05/13 18:47:04
Oops, sorry. It's was just debug message. Removed.
| |
| 170 | |
| 146 if (event.type == blink::WebInputEvent::TouchStart) { | 171 if (event.type == blink::WebInputEvent::TouchStart) { |
| 147 DCHECK(guest_->GetOwnerRenderWidgetHostView()); | 172 DCHECK(guest_->GetOwnerRenderWidgetHostView()); |
| 148 RenderWidgetHostImpl* embedder = static_cast<RenderWidgetHostImpl*>( | 173 RenderWidgetHostImpl* embedder = static_cast<RenderWidgetHostImpl*>( |
| 149 guest_->GetOwnerRenderWidgetHostView()->GetRenderWidgetHost()); | 174 guest_->GetOwnerRenderWidgetHostView()->GetRenderWidgetHost()); |
| 150 if (!embedder->GetView()->HasFocus()) | 175 if (!embedder->GetView()->HasFocus()) |
| 151 embedder->GetView()->Focus(); | 176 embedder->GetView()->Focus(); |
| 152 } | 177 } |
| 153 | 178 |
| 154 host_->ForwardTouchEventWithLatencyInfo(event, latency); | 179 host_->ForwardTouchEventWithLatencyInfo(event, latency); |
| 155 } | 180 } |
| (...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 505 // GestureScrollBegin/End are always consumed by the guest, so we only | 530 // GestureScrollBegin/End are always consumed by the guest, so we only |
| 506 // forward GestureScrollUpdate. | 531 // forward GestureScrollUpdate. |
| 507 if (event.type == blink::WebInputEvent::GestureScrollUpdate && not_consumed) | 532 if (event.type == blink::WebInputEvent::GestureScrollUpdate && not_consumed) |
| 508 guest_->ResendEventToEmbedder(event); | 533 guest_->ResendEventToEmbedder(event); |
| 509 } | 534 } |
| 510 | 535 |
| 511 void RenderWidgetHostViewGuest::OnHandleInputEvent( | 536 void RenderWidgetHostViewGuest::OnHandleInputEvent( |
| 512 RenderWidgetHostImpl* embedder, | 537 RenderWidgetHostImpl* embedder, |
| 513 int browser_plugin_instance_id, | 538 int browser_plugin_instance_id, |
| 514 const blink::WebInputEvent* event) { | 539 const blink::WebInputEvent* event) { |
| 540 ScopedInputScaleDisabler disable(host_, current_device_scale_factor()); | |
| 515 if (blink::WebInputEvent::isMouseEventType(event->type)) { | 541 if (blink::WebInputEvent::isMouseEventType(event->type)) { |
| 516 // The mouse events for BrowserPlugin are modified by all | 542 // The mouse events for BrowserPlugin are modified by all |
| 517 // the CSS transforms applied on the <object> and embedder. As a result of | 543 // the CSS transforms applied on the <object> and embedder. As a result of |
| 518 // this, the coordinates passed on to the guest renderer are potentially | 544 // this, the coordinates passed on to the guest renderer are potentially |
| 519 // incorrect to determine the position of the context menu(they are not the | 545 // incorrect to determine the position of the context menu(they are not the |
| 520 // actual X, Y of the window). As a hack, we report the last location of a | 546 // actual X, Y of the window). As a hack, we report the last location of a |
| 521 // right mouse up to the BrowserPluginGuest to inform it of the next | 547 // right mouse up to the BrowserPluginGuest to inform it of the next |
| 522 // potential location for context menu (BUG=470087). | 548 // potential location for context menu (BUG=470087). |
| 523 // TODO(ekaramad): Find a better and more fundamental solution. Could the | 549 // TODO(ekaramad): Find a better and more fundamental solution. Could the |
| 524 // ContextMenuParams be based on global X, Y? | 550 // ContextMenuParams be based on global X, Y? |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 575 if (gesture_event.type == blink::WebInputEvent::GestureScrollUpdate && | 601 if (gesture_event.type == blink::WebInputEvent::GestureScrollUpdate && |
| 576 gesture_event.data.scrollUpdate.inertial) { | 602 gesture_event.data.scrollUpdate.inertial) { |
| 577 return; | 603 return; |
| 578 } | 604 } |
| 579 host_->ForwardGestureEvent(gesture_event); | 605 host_->ForwardGestureEvent(gesture_event); |
| 580 return; | 606 return; |
| 581 } | 607 } |
| 582 } | 608 } |
| 583 | 609 |
| 584 } // namespace content | 610 } // namespace content |
| OLD | NEW |