OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "config.h" | 5 #include "config.h" |
6 | 6 |
7 #include "web_to_ccinput_handler_adapter.h" | 7 #include "web_to_ccinput_handler_adapter.h" |
8 | 8 |
9 #include "cc/stubs/int_point.h" | |
10 #include "cc/stubs/int_size.h" | |
11 #include "third_party/WebKit/Source/Platform/chromium/public/WebInputHandlerClie
nt.h" | 9 #include "third_party/WebKit/Source/Platform/chromium/public/WebInputHandlerClie
nt.h" |
12 #include "webcore_convert.h" | |
13 | 10 |
14 #define COMPILE_ASSERT_MATCHING_ENUM(webkit_name, cc_name) \ | 11 #define COMPILE_ASSERT_MATCHING_ENUM(webkit_name, cc_name) \ |
15 COMPILE_ASSERT(int(WebKit::webkit_name) == int(cc::cc_name), mismatching_enu
ms) | 12 COMPILE_ASSERT(int(WebKit::webkit_name) == int(cc::cc_name), mismatching_enu
ms) |
16 | 13 |
17 COMPILE_ASSERT_MATCHING_ENUM(WebInputHandlerClient::ScrollStatusOnMainThread, In
putHandlerClient::ScrollOnMainThread); | 14 COMPILE_ASSERT_MATCHING_ENUM(WebInputHandlerClient::ScrollStatusOnMainThread, In
putHandlerClient::ScrollOnMainThread); |
18 COMPILE_ASSERT_MATCHING_ENUM(WebInputHandlerClient::ScrollStatusStarted, InputHa
ndlerClient::ScrollStarted); | 15 COMPILE_ASSERT_MATCHING_ENUM(WebInputHandlerClient::ScrollStatusStarted, InputHa
ndlerClient::ScrollStarted); |
19 COMPILE_ASSERT_MATCHING_ENUM(WebInputHandlerClient::ScrollStatusIgnored, InputHa
ndlerClient::ScrollIgnored); | 16 COMPILE_ASSERT_MATCHING_ENUM(WebInputHandlerClient::ScrollStatusIgnored, InputHa
ndlerClient::ScrollIgnored); |
20 COMPILE_ASSERT_MATCHING_ENUM(WebInputHandlerClient::ScrollInputTypeGesture, Inpu
tHandlerClient::Gesture); | 17 COMPILE_ASSERT_MATCHING_ENUM(WebInputHandlerClient::ScrollInputTypeGesture, Inpu
tHandlerClient::Gesture); |
21 COMPILE_ASSERT_MATCHING_ENUM(WebInputHandlerClient::ScrollInputTypeWheel, InputH
andlerClient::Wheel); | 18 COMPILE_ASSERT_MATCHING_ENUM(WebInputHandlerClient::ScrollInputTypeWheel, InputH
andlerClient::Wheel); |
22 | 19 |
(...skipping 24 matching lines...) Expand all Loading... |
47 { | 44 { |
48 } | 45 } |
49 | 46 |
50 virtual ScrollStatus scrollBegin(WebPoint point, ScrollInputType type) OVERR
IDE | 47 virtual ScrollStatus scrollBegin(WebPoint point, ScrollInputType type) OVERR
IDE |
51 { | 48 { |
52 return static_cast<WebInputHandlerClient::ScrollStatus>(m_client->scroll
Begin(point, static_cast<cc::InputHandlerClient::ScrollInputType>(type))); | 49 return static_cast<WebInputHandlerClient::ScrollStatus>(m_client->scroll
Begin(point, static_cast<cc::InputHandlerClient::ScrollInputType>(type))); |
53 } | 50 } |
54 | 51 |
55 virtual void scrollBy(WebPoint point, WebSize offset) OVERRIDE | 52 virtual void scrollBy(WebPoint point, WebSize offset) OVERRIDE |
56 { | 53 { |
57 m_client->scrollBy(point, convert(offset)); | 54 m_client->scrollBy(point, offset); |
58 } | 55 } |
59 | 56 |
60 virtual void scrollEnd() OVERRIDE | 57 virtual void scrollEnd() OVERRIDE |
61 { | 58 { |
62 m_client->scrollEnd(); | 59 m_client->scrollEnd(); |
63 } | 60 } |
64 | 61 |
65 virtual void pinchGestureBegin() OVERRIDE | 62 virtual void pinchGestureBegin() OVERRIDE |
66 { | 63 { |
67 m_client->pinchGestureBegin(); | 64 m_client->pinchGestureBegin(); |
68 } | 65 } |
69 | 66 |
70 virtual void pinchGestureUpdate(float magnifyDelta, WebPoint anchor) OVERRID
E | 67 virtual void pinchGestureUpdate(float magnifyDelta, WebPoint anchor) OVERRID
E |
71 { | 68 { |
72 m_client->pinchGestureUpdate(magnifyDelta, convert(anchor)); | 69 m_client->pinchGestureUpdate(magnifyDelta, anchor); |
73 } | 70 } |
74 | 71 |
75 virtual void pinchGestureEnd() OVERRIDE | 72 virtual void pinchGestureEnd() OVERRIDE |
76 { | 73 { |
77 m_client->pinchGestureEnd(); | 74 m_client->pinchGestureEnd(); |
78 } | 75 } |
79 | 76 |
80 virtual void startPageScaleAnimation(WebSize targetPosition, | 77 virtual void startPageScaleAnimation(WebSize targetPosition, |
81 bool anchorPoint, | 78 bool anchorPoint, |
82 float pageScale, | 79 float pageScale, |
83 double startTimeSec, | 80 double startTimeSec, |
84 double durationSec) OVERRIDE | 81 double durationSec) OVERRIDE |
85 { | 82 { |
86 base::TimeTicks startTime = base::TimeTicks::FromInternalValue(startTime
Sec * base::Time::kMicrosecondsPerSecond); | 83 base::TimeTicks startTime = base::TimeTicks::FromInternalValue(startTime
Sec * base::Time::kMicrosecondsPerSecond); |
87 base::TimeDelta duration = base::TimeDelta::FromMicroseconds(durationSec
* base::Time::kMicrosecondsPerSecond); | 84 base::TimeDelta duration = base::TimeDelta::FromMicroseconds(durationSec
* base::Time::kMicrosecondsPerSecond); |
88 m_client->startPageScaleAnimation(convert(targetPosition), anchorPoint,
pageScale, startTime, duration); | 85 m_client->startPageScaleAnimation(targetPosition, anchorPoint, pageScale
, startTime, duration); |
89 } | 86 } |
90 | 87 |
91 virtual void scheduleAnimation() OVERRIDE | 88 virtual void scheduleAnimation() OVERRIDE |
92 { | 89 { |
93 m_client->scheduleAnimation(); | 90 m_client->scheduleAnimation(); |
94 } | 91 } |
95 | 92 |
96 private: | 93 private: |
97 cc::InputHandlerClient* m_client; | 94 cc::InputHandlerClient* m_client; |
98 }; | 95 }; |
99 | 96 |
100 | 97 |
101 void WebToCCInputHandlerAdapter::bindToClient(cc::InputHandlerClient* client) | 98 void WebToCCInputHandlerAdapter::bindToClient(cc::InputHandlerClient* client) |
102 { | 99 { |
103 m_clientAdapter.reset(new ClientAdapter(client)); | 100 m_clientAdapter.reset(new ClientAdapter(client)); |
104 m_handler->bindToClient(m_clientAdapter.get()); | 101 m_handler->bindToClient(m_clientAdapter.get()); |
105 } | 102 } |
106 | 103 |
107 void WebToCCInputHandlerAdapter::animate(base::TimeTicks time) | 104 void WebToCCInputHandlerAdapter::animate(base::TimeTicks time) |
108 { | 105 { |
109 double monotonicTimeSeconds = (time - base::TimeTicks()).InSecondsF(); | 106 double monotonicTimeSeconds = (time - base::TimeTicks()).InSecondsF(); |
110 m_handler->animate(monotonicTimeSeconds); | 107 m_handler->animate(monotonicTimeSeconds); |
111 } | 108 } |
112 | 109 |
113 } | 110 } |
OLD | NEW |