| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/renderer_host/render_widget_host_impl.h" | 5 #include "content/browser/renderer_host/render_widget_host_impl.h" |
| 6 | 6 |
| 7 #include <math.h> | 7 #include <math.h> |
| 8 | 8 |
| 9 #include <set> | 9 #include <set> |
| 10 #include <tuple> | 10 #include <tuple> |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 #include "storage/browser/fileapi/isolated_context.h" | 84 #include "storage/browser/fileapi/isolated_context.h" |
| 85 #include "third_party/WebKit/public/web/WebCompositionUnderline.h" | 85 #include "third_party/WebKit/public/web/WebCompositionUnderline.h" |
| 86 #include "ui/base/clipboard/clipboard.h" | 86 #include "ui/base/clipboard/clipboard.h" |
| 87 #include "ui/display/display_switches.h" | 87 #include "ui/display/display_switches.h" |
| 88 #include "ui/events/blink/web_input_event_traits.h" | 88 #include "ui/events/blink/web_input_event_traits.h" |
| 89 #include "ui/events/event.h" | 89 #include "ui/events/event.h" |
| 90 #include "ui/events/keycodes/keyboard_codes.h" | 90 #include "ui/events/keycodes/keyboard_codes.h" |
| 91 #include "ui/gfx/color_space.h" | 91 #include "ui/gfx/color_space.h" |
| 92 #include "ui/gfx/geometry/size_conversions.h" | 92 #include "ui/gfx/geometry/size_conversions.h" |
| 93 #include "ui/gfx/geometry/vector2d_conversions.h" | 93 #include "ui/gfx/geometry/vector2d_conversions.h" |
| 94 #include "ui/gfx/geometry/vector2d_f.h" |
| 94 #include "ui/gfx/image/image.h" | 95 #include "ui/gfx/image/image.h" |
| 95 #include "ui/gfx/image/image_skia.h" | 96 #include "ui/gfx/image/image_skia.h" |
| 96 #include "ui/gfx/skbitmap_operations.h" | 97 #include "ui/gfx/skbitmap_operations.h" |
| 97 #include "ui/snapshot/snapshot.h" | 98 #include "ui/snapshot/snapshot.h" |
| 98 | 99 |
| 99 #if defined(OS_ANDROID) | 100 #if defined(OS_ANDROID) |
| 100 #include "ui/android/view_android.h" | 101 #include "ui/android/view_android.h" |
| 101 #else | 102 #else |
| 102 #include "content/browser/compositor/image_transport_factory.h" | 103 #include "content/browser/compositor/image_transport_factory.h" |
| 103 // nogncheck as dependency of "ui/compositor" is on non-Android platforms only. | 104 // nogncheck as dependency of "ui/compositor" is on non-Android platforms only. |
| (...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 556 IPC_MESSAGE_HANDLER(InputHostMsg_ImeCancelComposition, | 557 IPC_MESSAGE_HANDLER(InputHostMsg_ImeCancelComposition, |
| 557 OnImeCancelComposition) | 558 OnImeCancelComposition) |
| 558 IPC_MESSAGE_HANDLER(ViewHostMsg_Close, OnClose) | 559 IPC_MESSAGE_HANDLER(ViewHostMsg_Close, OnClose) |
| 559 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateScreenRects_ACK, | 560 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateScreenRects_ACK, |
| 560 OnUpdateScreenRectsAck) | 561 OnUpdateScreenRectsAck) |
| 561 IPC_MESSAGE_HANDLER(ViewHostMsg_RequestMove, OnRequestMove) | 562 IPC_MESSAGE_HANDLER(ViewHostMsg_RequestMove, OnRequestMove) |
| 562 IPC_MESSAGE_HANDLER(ViewHostMsg_SetTooltipText, OnSetTooltipText) | 563 IPC_MESSAGE_HANDLER(ViewHostMsg_SetTooltipText, OnSetTooltipText) |
| 563 IPC_MESSAGE_HANDLER(ViewHostMsg_DidNotProduceFrame, DidNotProduceFrame) | 564 IPC_MESSAGE_HANDLER(ViewHostMsg_DidNotProduceFrame, DidNotProduceFrame) |
| 564 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateRect, OnUpdateRect) | 565 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateRect, OnUpdateRect) |
| 565 IPC_MESSAGE_HANDLER(ViewHostMsg_SetCursor, OnSetCursor) | 566 IPC_MESSAGE_HANDLER(ViewHostMsg_SetCursor, OnSetCursor) |
| 567 IPC_MESSAGE_HANDLER(ViewHostMsg_AutoscrollStart, OnAutoscrollStart) |
| 568 IPC_MESSAGE_HANDLER(ViewHostMsg_AutoscrollFling, OnAutoscrollFling) |
| 569 IPC_MESSAGE_HANDLER(ViewHostMsg_AutoscrollEnd, OnAutoscrollEnd) |
| 566 IPC_MESSAGE_HANDLER(ViewHostMsg_TextInputStateChanged, | 570 IPC_MESSAGE_HANDLER(ViewHostMsg_TextInputStateChanged, |
| 567 OnTextInputStateChanged) | 571 OnTextInputStateChanged) |
| 568 IPC_MESSAGE_HANDLER(ViewHostMsg_LockMouse, OnLockMouse) | 572 IPC_MESSAGE_HANDLER(ViewHostMsg_LockMouse, OnLockMouse) |
| 569 IPC_MESSAGE_HANDLER(ViewHostMsg_UnlockMouse, OnUnlockMouse) | 573 IPC_MESSAGE_HANDLER(ViewHostMsg_UnlockMouse, OnUnlockMouse) |
| 570 IPC_MESSAGE_HANDLER(ViewHostMsg_ShowDisambiguationPopup, | 574 IPC_MESSAGE_HANDLER(ViewHostMsg_ShowDisambiguationPopup, |
| 571 OnShowDisambiguationPopup) | 575 OnShowDisambiguationPopup) |
| 572 IPC_MESSAGE_HANDLER(ViewHostMsg_SelectionBoundsChanged, | 576 IPC_MESSAGE_HANDLER(ViewHostMsg_SelectionBoundsChanged, |
| 573 OnSelectionBoundsChanged) | 577 OnSelectionBoundsChanged) |
| 574 IPC_MESSAGE_HANDLER(InputHostMsg_ImeCompositionRangeChanged, | 578 IPC_MESSAGE_HANDLER(InputHostMsg_ImeCompositionRangeChanged, |
| 575 OnImeCompositionRangeChanged) | 579 OnImeCompositionRangeChanged) |
| (...skipping 1453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2029 QueueSyntheticGesture( | 2033 QueueSyntheticGesture( |
| 2030 SyntheticGesture::Create(*gesture_packet.gesture_params()), | 2034 SyntheticGesture::Create(*gesture_packet.gesture_params()), |
| 2031 base::Bind(&RenderWidgetHostImpl::OnSyntheticGestureCompleted, | 2035 base::Bind(&RenderWidgetHostImpl::OnSyntheticGestureCompleted, |
| 2032 weak_factory_.GetWeakPtr())); | 2036 weak_factory_.GetWeakPtr())); |
| 2033 } | 2037 } |
| 2034 | 2038 |
| 2035 void RenderWidgetHostImpl::OnSetCursor(const WebCursor& cursor) { | 2039 void RenderWidgetHostImpl::OnSetCursor(const WebCursor& cursor) { |
| 2036 SetCursor(cursor); | 2040 SetCursor(cursor); |
| 2037 } | 2041 } |
| 2038 | 2042 |
| 2043 void RenderWidgetHostImpl::OnAutoscrollStart(const gfx::PointF& position) { |
| 2044 WebGestureEvent scroll_begin = SyntheticWebGestureEventBuilder::Build( |
| 2045 WebInputEvent::kGestureScrollBegin, |
| 2046 blink::kWebGestureDeviceSyntheticAutoscroll); |
| 2047 |
| 2048 scroll_begin.x = position.x(); |
| 2049 scroll_begin.y = position.y(); |
| 2050 scroll_begin.source_device = blink::kWebGestureDeviceSyntheticAutoscroll; |
| 2051 |
| 2052 input_router_->SendGestureEvent(GestureEventWithLatencyInfo(scroll_begin)); |
| 2053 } |
| 2054 |
| 2055 void RenderWidgetHostImpl::OnAutoscrollFling(const gfx::Vector2dF& velocity) { |
| 2056 WebGestureEvent event = SyntheticWebGestureEventBuilder::Build( |
| 2057 WebInputEvent::kGestureFlingStart, |
| 2058 blink::kWebGestureDeviceSyntheticAutoscroll); |
| 2059 event.data.fling_start.velocity_x = velocity.x(); |
| 2060 event.data.fling_start.velocity_y = velocity.y(); |
| 2061 event.source_device = blink::kWebGestureDeviceSyntheticAutoscroll; |
| 2062 |
| 2063 input_router_->SendGestureEvent(GestureEventWithLatencyInfo(event)); |
| 2064 } |
| 2065 |
| 2066 void RenderWidgetHostImpl::OnAutoscrollEnd() { |
| 2067 WebGestureEvent cancel_event = SyntheticWebGestureEventBuilder::Build( |
| 2068 WebInputEvent::kGestureFlingCancel, |
| 2069 blink::kWebGestureDeviceSyntheticAutoscroll); |
| 2070 cancel_event.data.fling_cancel.prevent_boosting = true; |
| 2071 input_router_->SendGestureEvent(GestureEventWithLatencyInfo(cancel_event)); |
| 2072 |
| 2073 WebGestureEvent end_event = SyntheticWebGestureEventBuilder::Build( |
| 2074 WebInputEvent::kGestureScrollEnd, |
| 2075 blink::kWebGestureDeviceSyntheticAutoscroll); |
| 2076 input_router_->SendGestureEvent(GestureEventWithLatencyInfo(end_event)); |
| 2077 } |
| 2078 |
| 2039 void RenderWidgetHostImpl::SetTouchEventEmulationEnabled( | 2079 void RenderWidgetHostImpl::SetTouchEventEmulationEnabled( |
| 2040 bool enabled, ui::GestureProviderConfigType config_type) { | 2080 bool enabled, ui::GestureProviderConfigType config_type) { |
| 2041 if (enabled) { | 2081 if (enabled) { |
| 2042 if (!touch_emulator_) { | 2082 if (!touch_emulator_) { |
| 2043 touch_emulator_.reset(new TouchEmulator( | 2083 touch_emulator_.reset(new TouchEmulator( |
| 2044 this, | 2084 this, |
| 2045 view_.get() ? content::GetScaleFactorForView(view_.get()) : 1.0f)); | 2085 view_.get() ? content::GetScaleFactorForView(view_.get()) : 1.0f)); |
| 2046 } | 2086 } |
| 2047 touch_emulator_->Enable(config_type); | 2087 touch_emulator_->Enable(config_type); |
| 2048 } else { | 2088 } else { |
| (...skipping 620 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2669 device::mojom::WakeLockType::PreventDisplaySleep, | 2709 device::mojom::WakeLockType::PreventDisplaySleep, |
| 2670 device::mojom::WakeLockReason::ReasonOther, "GetSnapshot", | 2710 device::mojom::WakeLockReason::ReasonOther, "GetSnapshot", |
| 2671 std::move(request)); | 2711 std::move(request)); |
| 2672 } | 2712 } |
| 2673 } | 2713 } |
| 2674 return wake_lock_.get(); | 2714 return wake_lock_.get(); |
| 2675 } | 2715 } |
| 2676 #endif | 2716 #endif |
| 2677 | 2717 |
| 2678 } // namespace content | 2718 } // namespace content |
| OLD | NEW |