| 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 441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 505 // GestureScrollBegin/End are always consumed by the guest, so we only | 528 // GestureScrollBegin/End are always consumed by the guest, so we only |
| 506 // forward GestureScrollUpdate. | 529 // forward GestureScrollUpdate. |
| 507 if (event.type == blink::WebInputEvent::GestureScrollUpdate && not_consumed) | 530 if (event.type == blink::WebInputEvent::GestureScrollUpdate && not_consumed) |
| 508 guest_->ResendEventToEmbedder(event); | 531 guest_->ResendEventToEmbedder(event); |
| 509 } | 532 } |
| 510 | 533 |
| 511 void RenderWidgetHostViewGuest::OnHandleInputEvent( | 534 void RenderWidgetHostViewGuest::OnHandleInputEvent( |
| 512 RenderWidgetHostImpl* embedder, | 535 RenderWidgetHostImpl* embedder, |
| 513 int browser_plugin_instance_id, | 536 int browser_plugin_instance_id, |
| 514 const blink::WebInputEvent* event) { | 537 const blink::WebInputEvent* event) { |
| 538 ScopedInputScaleDisabler disable(host_, current_device_scale_factor()); |
| 515 if (blink::WebInputEvent::isMouseEventType(event->type)) { | 539 if (blink::WebInputEvent::isMouseEventType(event->type)) { |
| 516 // The mouse events for BrowserPlugin are modified by all | 540 // The mouse events for BrowserPlugin are modified by all |
| 517 // the CSS transforms applied on the <object> and embedder. As a result of | 541 // 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 | 542 // 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 | 543 // 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 | 544 // 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 | 545 // right mouse up to the BrowserPluginGuest to inform it of the next |
| 522 // potential location for context menu (BUG=470087). | 546 // potential location for context menu (BUG=470087). |
| 523 // TODO(ekaramad): Find a better and more fundamental solution. Could the | 547 // TODO(ekaramad): Find a better and more fundamental solution. Could the |
| 524 // ContextMenuParams be based on global X, Y? | 548 // 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 && | 599 if (gesture_event.type == blink::WebInputEvent::GestureScrollUpdate && |
| 576 gesture_event.data.scrollUpdate.inertial) { | 600 gesture_event.data.scrollUpdate.inertial) { |
| 577 return; | 601 return; |
| 578 } | 602 } |
| 579 host_->ForwardGestureEvent(gesture_event); | 603 host_->ForwardGestureEvent(gesture_event); |
| 580 return; | 604 return; |
| 581 } | 605 } |
| 582 } | 606 } |
| 583 | 607 |
| 584 } // namespace content | 608 } // namespace content |
| OLD | NEW |