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 "webkit/compositor_bindings/web_to_ccinput_handler_adapter.h" | 5 #include "webkit/compositor_bindings/web_to_ccinput_handler_adapter.h" |
6 | 6 |
7 #include "third_party/WebKit/Source/Platform/chromium/public/WebInputHandlerClie
nt.h" | 7 #include "third_party/WebKit/Source/Platform/chromium/public/WebInputHandlerClie
nt.h" |
8 | 8 |
9 #define COMPILE_ASSERT_MATCHING_ENUM(webkit_name, cc_name) \ | 9 #define COMPILE_ASSERT_MATCHING_ENUM(webkit_name, cc_name) \ |
10 COMPILE_ASSERT(int(WebKit::webkit_name) == int(cc::cc_name), \ | 10 COMPILE_ASSERT(static_cast<int>(WebKit::webkit_name) == \ |
| 11 static_cast<int>(cc::cc_name), \ |
11 mismatching_enums) | 12 mismatching_enums) |
12 | 13 |
13 COMPILE_ASSERT_MATCHING_ENUM(WebInputHandlerClient::ScrollStatusOnMainThread, | 14 COMPILE_ASSERT_MATCHING_ENUM(WebInputHandlerClient::ScrollStatusOnMainThread, |
14 InputHandlerClient::ScrollOnMainThread); | 15 InputHandlerClient::ScrollOnMainThread); |
15 COMPILE_ASSERT_MATCHING_ENUM(WebInputHandlerClient::ScrollStatusStarted, | 16 COMPILE_ASSERT_MATCHING_ENUM(WebInputHandlerClient::ScrollStatusStarted, |
16 InputHandlerClient::ScrollStarted); | 17 InputHandlerClient::ScrollStarted); |
17 COMPILE_ASSERT_MATCHING_ENUM(WebInputHandlerClient::ScrollStatusIgnored, | 18 COMPILE_ASSERT_MATCHING_ENUM(WebInputHandlerClient::ScrollStatusIgnored, |
18 InputHandlerClient::ScrollIgnored); | 19 InputHandlerClient::ScrollIgnored); |
19 COMPILE_ASSERT_MATCHING_ENUM(WebInputHandlerClient::ScrollInputTypeGesture, | 20 COMPILE_ASSERT_MATCHING_ENUM(WebInputHandlerClient::ScrollInputTypeGesture, |
20 InputHandlerClient::Gesture); | 21 InputHandlerClient::Gesture); |
21 COMPILE_ASSERT_MATCHING_ENUM(WebInputHandlerClient::ScrollInputTypeWheel, | 22 COMPILE_ASSERT_MATCHING_ENUM(WebInputHandlerClient::ScrollInputTypeWheel, |
22 InputHandlerClient::Wheel); | 23 InputHandlerClient::Wheel); |
23 | 24 |
24 namespace WebKit { | 25 namespace WebKit { |
25 | 26 |
26 scoped_ptr<WebToCCInputHandlerAdapter> WebToCCInputHandlerAdapter::create( | 27 scoped_ptr<WebToCCInputHandlerAdapter> WebToCCInputHandlerAdapter::create( |
27 scoped_ptr<WebInputHandler> handler) { | 28 scoped_ptr<WebInputHandler> handler) { |
28 return scoped_ptr<WebToCCInputHandlerAdapter>( | 29 return scoped_ptr<WebToCCInputHandlerAdapter>( |
29 new WebToCCInputHandlerAdapter(handler.Pass())); | 30 new WebToCCInputHandlerAdapter(handler.Pass())); |
30 } | 31 } |
31 | 32 |
32 WebToCCInputHandlerAdapter::WebToCCInputHandlerAdapter( | 33 WebToCCInputHandlerAdapter::WebToCCInputHandlerAdapter( |
33 scoped_ptr<WebInputHandler> handler) | 34 scoped_ptr<WebInputHandler> handler) |
34 : handler_(handler.Pass()) {} | 35 : handler_(handler.Pass()) {} |
35 | 36 |
36 WebToCCInputHandlerAdapter::~WebToCCInputHandlerAdapter() {} | 37 WebToCCInputHandlerAdapter::~WebToCCInputHandlerAdapter() {} |
37 | 38 |
38 class WebToCCInputHandlerAdapter::ClientAdapter : public WebInputHandlerClient { | 39 class WebToCCInputHandlerAdapter::ClientAdapter : public WebInputHandlerClient { |
39 public: | 40 public: |
40 ClientAdapter(cc::InputHandlerClient* client) : client_(client) {} | 41 explicit ClientAdapter(cc::InputHandlerClient* client) : client_(client) {} |
41 | 42 |
42 virtual ~ClientAdapter() {} | 43 virtual ~ClientAdapter() {} |
43 | 44 |
44 virtual ScrollStatus scrollBegin(WebPoint point, ScrollInputType type) { | 45 virtual ScrollStatus scrollBegin(WebPoint point, ScrollInputType type) { |
45 return static_cast<WebInputHandlerClient::ScrollStatus>( | 46 return static_cast<WebInputHandlerClient::ScrollStatus>( |
46 client_->ScrollBegin( | 47 client_->ScrollBegin( |
47 point, static_cast<cc::InputHandlerClient::ScrollInputType>(type))); | 48 point, static_cast<cc::InputHandlerClient::ScrollInputType>(type))); |
48 } | 49 } |
49 | 50 |
50 virtual bool scrollByIfPossible(WebPoint point, WebFloatSize delta) { | 51 virtual bool scrollByIfPossible(WebPoint point, WebFloatSize delta) { |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 void WebToCCInputHandlerAdapter::Animate(base::TimeTicks time) { | 93 void WebToCCInputHandlerAdapter::Animate(base::TimeTicks time) { |
93 double monotonic_time_seconds = (time - base::TimeTicks()).InSecondsF(); | 94 double monotonic_time_seconds = (time - base::TimeTicks()).InSecondsF(); |
94 handler_->animate(monotonic_time_seconds); | 95 handler_->animate(monotonic_time_seconds); |
95 } | 96 } |
96 | 97 |
97 void WebToCCInputHandlerAdapter::MainThreadHasStoppedFlinging() { | 98 void WebToCCInputHandlerAdapter::MainThreadHasStoppedFlinging() { |
98 handler_->mainThreadHasStoppedFlinging(); | 99 handler_->mainThreadHasStoppedFlinging(); |
99 } | 100 } |
100 | 101 |
101 } // namespace WebKit | 102 } // namespace WebKit |
OLD | NEW |