Chromium Code Reviews| Index: content/renderer/input/input_scroll_elasticity_controller.h |
| diff --git a/content/renderer/input/input_scroll_elasticity_controller.h b/content/renderer/input/input_scroll_elasticity_controller.h |
| index 79cb4ed4c137e71894b274f8a6a4067340eedbc3..2bf43a60efaf7a41b97f73a882962d8143c984f0 100644 |
| --- a/content/renderer/input/input_scroll_elasticity_controller.h |
| +++ b/content/renderer/input/input_scroll_elasticity_controller.h |
| @@ -6,11 +6,11 @@ |
| #define CONTENT_RENDERER_INPUT_INPUT_SCROLL_ELASTICITY_CONTROLLER_H_ |
| #include "base/macros.h" |
| -#include "base/time/time.h" |
| +#include "base/memory/weak_ptr.h" |
| +#include "cc/input/scroll_elasticity_controller.h" |
| #include "third_party/WebKit/public/web/WebInputEvent.h" |
| -#include "ui/gfx/geometry/vector2d_f.h" |
| -// ScrollElasticityController and ScrollElasticityControllerClient are based on |
| +// InputScrollElasticityController is based on |
| // WebKit/Source/platform/mac/ScrollElasticityController.h |
| /* |
| * Copyright (C) 2011 Apple Inc. All rights reserved. |
| @@ -37,41 +37,28 @@ |
| * THE POSSIBILITY OF SUCH DAMAGE. |
| */ |
| -namespace content { |
| +namespace cc { |
| +struct InputHandlerScrollResult; |
| +} // namespace cc |
| -class ScrollElasticityControllerClient { |
| - protected: |
| - virtual ~ScrollElasticityControllerClient() {} |
| +namespace content { |
| +class InputScrollElasticityController : public cc::ScrollElasticityController { |
| public: |
| - virtual bool AllowsHorizontalStretching() = 0; |
| - virtual bool AllowsVerticalStretching() = 0; |
| - // The amount that the view is stretched past the normal allowable bounds. |
| - // The "overhang" amount. |
| - virtual gfx::Vector2dF StretchAmount() = 0; |
| - virtual bool PinnedInDirection(const gfx::Vector2dF& direction) = 0; |
| - virtual bool CanScrollHorizontally() = 0; |
| - virtual bool CanScrollVertically() = 0; |
| - |
| - // Return the absolute scroll position, not relative to the scroll origin. |
| - virtual gfx::Vector2dF AbsoluteScrollPosition() = 0; |
| - |
| - virtual void ImmediateScrollBy(const gfx::Vector2dF& scroll) = 0; |
| - virtual void ImmediateScrollByWithoutContentEdgeConstraints( |
| - const gfx::Vector2dF& scroll) = 0; |
| - virtual void StartSnapRubberbandTimer() = 0; |
| - virtual void StopSnapRubberbandTimer() = 0; |
| - |
| - // If the current scroll position is within the overhang area, this function |
| - // will cause |
| - // the page to scroll to the nearest boundary point. |
| - virtual void AdjustScrollPositionToBoundsIfNecessary() = 0; |
| -}; |
| + explicit InputScrollElasticityController( |
| + cc::ScrollElasticityControllerClient* client); |
| + virtual ~InputScrollElasticityController(); |
|
jdduke (slow)
2014/11/12 02:32:24
Nit: ~InputScrollElasticityController() override;
jdduke (slow)
2014/11/12 02:45:59
Oh, hmm, I didn't notice that the base class doesn
|
| -class ScrollElasticityController { |
| - public: |
| - explicit ScrollElasticityController(ScrollElasticityControllerClient*); |
| + base::WeakPtr<InputScrollElasticityController> GetWeakPtr(); |
| + void ObserveWheelEventAndResult( |
| + const blink::WebMouseWheelEvent& wheel_event, |
| + const cc::InputHandlerScrollResult& scroll_result); |
| + // cc::ScrollElasticityController implementation: |
| + void WillShutdown() override; |
| + void Animate(base::TimeTicks time) override; |
| + |
| + private: |
| // This method is responsible for both scrolling and rubber-banding. |
| // |
| // Events are passed by IPC from the embedder. Events on Mac are grouped |
| @@ -89,7 +76,6 @@ class ScrollElasticityController { |
| bool IsRubberbandInProgress() const; |
| - private: |
| void StopSnapRubberbandTimer(); |
| void SnapRubberband(); |
| @@ -107,7 +93,7 @@ class ScrollElasticityController { |
| // of the event. |
| bool ShouldHandleEvent(const blink::WebMouseWheelEvent& wheel_event); |
| - ScrollElasticityControllerClient* client_; |
| + cc::ScrollElasticityControllerClient* client_; |
| // There is an active scroll gesture event. This parameter only gets set to |
| // false after the rubber band has been snapped, and before a new gesture |
| @@ -135,7 +121,8 @@ class ScrollElasticityController { |
| bool snap_rubberband_timer_is_active_; |
| - DISALLOW_COPY_AND_ASSIGN(ScrollElasticityController); |
| + base::WeakPtrFactory<InputScrollElasticityController> weak_factory_; |
| + DISALLOW_COPY_AND_ASSIGN(InputScrollElasticityController); |
| }; |
| } // namespace content |