| 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(int(WebKit::webkit_name) == int(cc::cc_name), \ |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 : handler_(handler.Pass()) {} | 34 : handler_(handler.Pass()) {} |
| 35 | 35 |
| 36 WebToCCInputHandlerAdapter::~WebToCCInputHandlerAdapter() {} | 36 WebToCCInputHandlerAdapter::~WebToCCInputHandlerAdapter() {} |
| 37 | 37 |
| 38 class WebToCCInputHandlerAdapter::ClientAdapter : public WebInputHandlerClient { | 38 class WebToCCInputHandlerAdapter::ClientAdapter : public WebInputHandlerClient { |
| 39 public: | 39 public: |
| 40 ClientAdapter(cc::InputHandlerClient* client) : client_(client) {} | 40 ClientAdapter(cc::InputHandlerClient* client) : client_(client) {} |
| 41 | 41 |
| 42 virtual ~ClientAdapter() {} | 42 virtual ~ClientAdapter() {} |
| 43 | 43 |
| 44 virtual ScrollStatus scrollBegin(WebPoint point, ScrollInputType type) | 44 virtual ScrollStatus scrollBegin(WebPoint point, ScrollInputType type) { |
| 45 OVERRIDE { | |
| 46 return static_cast<WebInputHandlerClient::ScrollStatus>( | 45 return static_cast<WebInputHandlerClient::ScrollStatus>( |
| 47 client_->scrollBegin( | 46 client_->scrollBegin( |
| 48 point, static_cast<cc::InputHandlerClient::ScrollInputType>(type))); | 47 point, static_cast<cc::InputHandlerClient::ScrollInputType>(type))); |
| 49 } | 48 } |
| 50 | 49 |
| 51 virtual bool scrollByIfPossible(WebPoint point, WebSize offset) OVERRIDE { | 50 virtual bool scrollByIfPossible(WebPoint point, WebSize offset) { |
| 52 return client_->scrollBy(point, offset); | 51 return client_->scrollBy(point, offset); |
| 53 } | 52 } |
| 54 | 53 |
| 55 virtual void scrollEnd() OVERRIDE { client_->scrollEnd(); } | 54 virtual void scrollEnd() { client_->scrollEnd(); } |
| 56 | 55 |
| 57 virtual void pinchGestureBegin() OVERRIDE { client_->pinchGestureBegin(); } | 56 virtual void pinchGestureBegin() { client_->pinchGestureBegin(); } |
| 58 | 57 |
| 59 virtual void pinchGestureUpdate(float magnify_delta, WebPoint anchor) | 58 virtual void pinchGestureUpdate(float magnify_delta, WebPoint anchor) { |
| 60 OVERRIDE { | |
| 61 client_->pinchGestureUpdate(magnify_delta, anchor); | 59 client_->pinchGestureUpdate(magnify_delta, anchor); |
| 62 } | 60 } |
| 63 | 61 |
| 64 virtual void pinchGestureEnd() OVERRIDE { client_->pinchGestureEnd(); } | 62 virtual void pinchGestureEnd() { client_->pinchGestureEnd(); } |
| 65 | 63 |
| 66 virtual void startPageScaleAnimation(WebSize target_position, | 64 virtual void startPageScaleAnimation(WebSize target_position, |
| 67 bool anchor_point, | 65 bool anchor_point, |
| 68 float page_scale, | 66 float page_scale, |
| 69 double start_time_sec, | 67 double start_time_sec, |
| 70 double duration_sec) OVERRIDE { | 68 double duration_sec) { |
| 71 base::TimeTicks start_time = base::TimeTicks::FromInternalValue( | 69 base::TimeTicks start_time = base::TimeTicks::FromInternalValue( |
| 72 start_time_sec * base::Time::kMicrosecondsPerSecond); | 70 start_time_sec * base::Time::kMicrosecondsPerSecond); |
| 73 base::TimeDelta duration = base::TimeDelta::FromMicroseconds( | 71 base::TimeDelta duration = base::TimeDelta::FromMicroseconds( |
| 74 duration_sec * base::Time::kMicrosecondsPerSecond); | 72 duration_sec * base::Time::kMicrosecondsPerSecond); |
| 75 client_->startPageScaleAnimation( | 73 client_->startPageScaleAnimation( |
| 76 target_position, anchor_point, page_scale, start_time, duration); | 74 target_position, anchor_point, page_scale, start_time, duration); |
| 77 } | 75 } |
| 78 | 76 |
| 79 virtual void scheduleAnimation() OVERRIDE { client_->scheduleAnimation(); } | 77 virtual void scheduleAnimation() { client_->scheduleAnimation(); } |
| 80 | 78 |
| 81 virtual bool haveTouchEventHandlersAt(WebPoint point) { | 79 virtual bool haveTouchEventHandlersAt(WebPoint point) { |
| 82 return client_->haveTouchEventHandlersAt(point); | 80 return client_->haveTouchEventHandlersAt(point); |
| 83 } | 81 } |
| 84 | 82 |
| 85 private: | 83 private: |
| 86 cc::InputHandlerClient* client_; | 84 cc::InputHandlerClient* client_; |
| 87 }; | 85 }; |
| 88 | 86 |
| 89 void WebToCCInputHandlerAdapter::bindToClient(cc::InputHandlerClient* client) { | 87 void WebToCCInputHandlerAdapter::bindToClient(cc::InputHandlerClient* client) { |
| 90 client_adapter_.reset(new ClientAdapter(client)); | 88 client_adapter_.reset(new ClientAdapter(client)); |
| 91 handler_->bindToClient(client_adapter_.get()); | 89 handler_->bindToClient(client_adapter_.get()); |
| 92 } | 90 } |
| 93 | 91 |
| 94 void WebToCCInputHandlerAdapter::animate(base::TimeTicks time) { | 92 void WebToCCInputHandlerAdapter::animate(base::TimeTicks time) { |
| 95 double monotonic_time_seconds = (time - base::TimeTicks()).InSecondsF(); | 93 double monotonic_time_seconds = (time - base::TimeTicks()).InSecondsF(); |
| 96 handler_->animate(monotonic_time_seconds); | 94 handler_->animate(monotonic_time_seconds); |
| 97 } | 95 } |
| 98 | 96 |
| 99 void WebToCCInputHandlerAdapter::mainThreadHasStoppedFlinging() { | 97 void WebToCCInputHandlerAdapter::mainThreadHasStoppedFlinging() { |
| 100 handler_->mainThreadHasStoppedFlinging(); | 98 handler_->mainThreadHasStoppedFlinging(); |
| 101 } | 99 } |
| 102 | 100 |
| 103 } // namespace WebKit | 101 } // namespace WebKit |
| OLD | NEW |