1// Copyright 2014 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#ifndef CONTENT_CHILD_TOUCH_FLING_GESTURE_CURVE_H_
6#define CONTENT_CHILD_TOUCH_FLING_GESTURE_CURVE_H_
7
8#include "content/common/content_export.h"
9#include "third_party/WebKit/public/platform/WebFloatPoint.h"
10#include "third_party/WebKit/public/platform/WebFloatSize.h"
11#include "third_party/WebKit/public/platform/WebGestureCurve.h"
12#include "third_party/WebKit/public/platform/WebSize.h"
13
14namespace blink {
15class WebGestureCurveTarget;
16}
17
18namespace content {
19
20// Implementation of WebGestureCurve suitable for touch pad/screen-based
21// fling scroll. Starts with a flat velocity profile based on 'velocity', which
22// tails off to zero. Time is scaled to that duration of the fling is
23// proportional to the initial velocity.
24class TouchFlingGestureCurve : public blink::WebGestureCurve {
25 public:
26
27  static CONTENT_EXPORT WebGestureCurve* Create(
28      const blink::WebFloatPoint& initial_velocity,
29      const blink::WebSize& cumulativeScroll);
30
31 virtual bool apply(double monotonicTime,
32                    blink::WebGestureCurveTarget*) OVERRIDE;
33
34 private:
35  TouchFlingGestureCurve(const blink::WebFloatPoint& initial_velocity,
36                         const blink::WebSize& cumulativeScroll);
37  virtual ~TouchFlingGestureCurve();
38
39  blink::WebFloatPoint displacement_ratio_;
40  blink::WebFloatSize cumulative_scroll_;
41  float time_offset_;
42  float curve_duration_;
43  float position_offset_;
44
45  DISALLOW_COPY_AND_ASSIGN(TouchFlingGestureCurve);
46};
47
48} // namespace content
49
50#endif // CONTENT_CHILD_TOUCH_FLING_GESTURE_CURVE_H_
51