OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 15 matching lines...) Expand all Loading... |
26 | 26 |
27 #include "TouchpadFlingPlatformGestureCurve.h" | 27 #include "TouchpadFlingPlatformGestureCurve.h" |
28 | 28 |
29 #include "PlatformGestureCurveTarget.h" | 29 #include "PlatformGestureCurveTarget.h" |
30 #include <math.h> | 30 #include <math.h> |
31 | 31 |
32 namespace WebCore { | 32 namespace WebCore { |
33 | 33 |
34 using namespace std; | 34 using namespace std; |
35 | 35 |
36 PassOwnPtr<PlatformGestureCurve> TouchpadFlingPlatformGestureCurve::create(const
FloatPoint& velocity) | 36 PassOwnPtr<PlatformGestureCurve> TouchpadFlingPlatformGestureCurve::create(const
FloatPoint& velocity, IntPoint cumulativeScroll) |
37 { | 37 { |
38 return create(velocity, 3, FloatPoint(0.3333, 0.6666), FloatPoint(0.6666, 1)
); | 38 return create(velocity, 3, FloatPoint(0.3333, 0.6666), FloatPoint(0.6666, 1)
, cumulativeScroll); |
39 } | 39 } |
40 | 40 |
41 PassOwnPtr<PlatformGestureCurve> TouchpadFlingPlatformGestureCurve::create(const
FloatPoint& velocity, const float unitTimeScaleLog10, const FloatPoint& bezierP
1, const FloatPoint& bezierP2) | 41 PassOwnPtr<PlatformGestureCurve> TouchpadFlingPlatformGestureCurve::create(const
FloatPoint& velocity, const float unitTimeScaleLog10, const FloatPoint& bezierP
1, const FloatPoint& bezierP2, IntPoint cumulativeScroll) |
42 { | 42 { |
43 return adoptPtr(new TouchpadFlingPlatformGestureCurve(velocity, unitTimeScal
eLog10, bezierP1, bezierP2)); | 43 return adoptPtr(new TouchpadFlingPlatformGestureCurve(velocity, unitTimeScal
eLog10, bezierP1, bezierP2, cumulativeScroll)); |
44 } | 44 } |
45 | 45 |
46 TouchpadFlingPlatformGestureCurve::TouchpadFlingPlatformGestureCurve(const Float
Point& velocity, const float unitTimeScaleLog10, const FloatPoint& bezierP1, con
st FloatPoint& bezierP2) | 46 TouchpadFlingPlatformGestureCurve::TouchpadFlingPlatformGestureCurve(const Float
Point& velocity, const float unitTimeScaleLog10, const FloatPoint& bezierP1, con
st FloatPoint& bezierP2, const IntPoint& cumulativeScroll) |
47 : m_velocity(velocity) | 47 : m_velocity(velocity) |
48 , m_timeScaleFactor(unitTimeScaleLog10 / log10(max(10.f, max(fabs(velocity.x
()), fabs(velocity.y()))))) | 48 , m_timeScaleFactor(unitTimeScaleLog10 / log10(max(10.f, max(fabs(velocity.x
()), fabs(velocity.y()))))) |
| 49 , m_cumulativeScroll(cumulativeScroll) |
49 , m_flingBezier(bezierP1.x(), bezierP1.y(), bezierP2.x(), bezierP2.y()) | 50 , m_flingBezier(bezierP1.x(), bezierP1.y(), bezierP2.x(), bezierP2.y()) |
50 { | 51 { |
51 ASSERT(velocity != FloatPoint::zero()); | 52 ASSERT(velocity != FloatPoint::zero()); |
52 } | 53 } |
53 | 54 |
54 TouchpadFlingPlatformGestureCurve::~TouchpadFlingPlatformGestureCurve() | 55 TouchpadFlingPlatformGestureCurve::~TouchpadFlingPlatformGestureCurve() |
55 { | 56 { |
56 } | 57 } |
57 | 58 |
58 bool TouchpadFlingPlatformGestureCurve::apply(double time, PlatformGestureCurveT
arget* target) | 59 bool TouchpadFlingPlatformGestureCurve::apply(double time, PlatformGestureCurveT
arget* target) |
(...skipping 19 matching lines...) Expand all Loading... |
78 | 79 |
79 if (time < 1 || scrollIncrement != IntPoint::zero()) { | 80 if (time < 1 || scrollIncrement != IntPoint::zero()) { |
80 target->scrollBy(scrollIncrement); | 81 target->scrollBy(scrollIncrement); |
81 return true; | 82 return true; |
82 } | 83 } |
83 | 84 |
84 return false; | 85 return false; |
85 } | 86 } |
86 | 87 |
87 } // namespace WebCore | 88 } // namespace WebCore |
OLD | NEW |