Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(103)

Side by Side Diff: webkit/compositor_bindings/web_to_ccinput_handler_adapter.cc

Issue 14651027: Move webkit/compositor_bindings into webkit/renderer (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "webkit/compositor_bindings/web_to_ccinput_handler_adapter.h"
6
7 #include "third_party/WebKit/Source/Platform/chromium/public/WebInputHandlerClie nt.h"
8
9 #define COMPILE_ASSERT_MATCHING_ENUM(webkit_name, cc_name) \
10 COMPILE_ASSERT(static_cast<int>(WebKit::webkit_name) == \
11 static_cast<int>(cc::cc_name), \
12 mismatching_enums)
13
14 COMPILE_ASSERT_MATCHING_ENUM(WebInputHandlerClient::ScrollStatusOnMainThread,
15 InputHandler::ScrollOnMainThread);
16 COMPILE_ASSERT_MATCHING_ENUM(WebInputHandlerClient::ScrollStatusStarted,
17 InputHandler::ScrollStarted);
18 COMPILE_ASSERT_MATCHING_ENUM(WebInputHandlerClient::ScrollStatusIgnored,
19 InputHandler::ScrollIgnored);
20 COMPILE_ASSERT_MATCHING_ENUM(WebInputHandlerClient::ScrollInputTypeGesture,
21 InputHandler::Gesture);
22 COMPILE_ASSERT_MATCHING_ENUM(WebInputHandlerClient::ScrollInputTypeWheel,
23 InputHandler::Wheel);
24
25 namespace WebKit {
26
27 scoped_ptr<WebToCCInputHandlerAdapter> WebToCCInputHandlerAdapter::create(
28 scoped_ptr<WebInputHandler> handler) {
29 return scoped_ptr<WebToCCInputHandlerAdapter>(
30 new WebToCCInputHandlerAdapter(handler.Pass()));
31 }
32
33 WebToCCInputHandlerAdapter::WebToCCInputHandlerAdapter(
34 scoped_ptr<WebInputHandler> handler)
35 : handler_(handler.Pass()) {}
36
37 WebToCCInputHandlerAdapter::~WebToCCInputHandlerAdapter() {}
38
39 class WebToCCInputHandlerAdapter::HandlerAdapter
40 : public WebInputHandlerClient {
41 public:
42 explicit HandlerAdapter(cc::InputHandler* handler) : handler_(handler) {}
43
44 virtual ~HandlerAdapter() {}
45
46 virtual ScrollStatus scrollBegin(WebPoint point, ScrollInputType type) {
47 return static_cast<WebInputHandlerClient::ScrollStatus>(
48 handler_->ScrollBegin(
49 point, static_cast<cc::InputHandler::ScrollInputType>(type)));
50 }
51
52 virtual bool scrollByIfPossible(WebPoint point, WebFloatSize delta) {
53 return handler_->ScrollBy(point, delta);
54 }
55
56 virtual bool scrollVerticallyByPageIfPossible(
57 WebPoint point, WebScrollbar::ScrollDirection direction) {
58 return handler_->ScrollVerticallyByPage(point, direction);
59 }
60
61 virtual ScrollStatus flingScrollBegin() {
62 return static_cast<WebInputHandlerClient::ScrollStatus>(
63 handler_->FlingScrollBegin());
64 }
65
66 virtual void notifyCurrentFlingVelocity(WebFloatSize velocity) {
67 handler_->NotifyCurrentFlingVelocity(velocity);
68 }
69
70 virtual void scrollEnd() { handler_->ScrollEnd(); }
71
72 virtual void pinchGestureBegin() { handler_->PinchGestureBegin(); }
73
74 virtual void pinchGestureUpdate(float magnify_delta, WebPoint anchor) {
75 handler_->PinchGestureUpdate(magnify_delta, anchor);
76 }
77
78 virtual void pinchGestureEnd() { handler_->PinchGestureEnd(); }
79
80 virtual void startPageScaleAnimation(WebSize target_position,
81 bool anchor_point,
82 float page_scale,
83 double start_time_sec,
84 double duration_sec) {
85 base::TimeTicks start_time = base::TimeTicks::FromInternalValue(
86 start_time_sec * base::Time::kMicrosecondsPerSecond);
87 base::TimeDelta duration = base::TimeDelta::FromMicroseconds(
88 duration_sec * base::Time::kMicrosecondsPerSecond);
89 handler_->StartPageScaleAnimation(
90 target_position, anchor_point, page_scale, start_time, duration);
91 }
92
93 virtual void scheduleAnimation() { handler_->ScheduleAnimation(); }
94
95 virtual bool haveTouchEventHandlersAt(WebPoint point) {
96 return handler_->HaveTouchEventHandlersAt(point);
97 }
98
99 virtual void didReceiveLastInputEventForVSync(double frame_time_sec)
100 OVERRIDE {
101 base::TimeTicks frame_time = base::TimeTicks::FromInternalValue(
102 frame_time_sec * base::Time::kMicrosecondsPerSecond);
103 handler_->DidReceiveLastInputEventForVSync(frame_time);
104 }
105
106 private:
107 cc::InputHandler* handler_;
108 };
109
110 void WebToCCInputHandlerAdapter::BindToHandler(cc::InputHandler* handler) {
111 handler_adapter_.reset(new HandlerAdapter(handler));
112 handler_->bindToClient(handler_adapter_.get());
113 }
114
115 void WebToCCInputHandlerAdapter::Animate(base::TimeTicks time) {
116 double monotonic_time_seconds = (time - base::TimeTicks()).InSecondsF();
117 handler_->animate(monotonic_time_seconds);
118 }
119
120 void WebToCCInputHandlerAdapter::MainThreadHasStoppedFlinging() {
121 handler_->mainThreadHasStoppedFlinging();
122 }
123
124 } // namespace WebKit
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698