Diff
Modified: trunk/Source/WebCore/CMakeLists.txt (127923 => 127924)
--- trunk/Source/WebCore/CMakeLists.txt 2012-09-07 21:45:23 UTC (rev 127923)
+++ trunk/Source/WebCore/CMakeLists.txt 2012-09-07 21:57:15 UTC (rev 127924)
@@ -2490,7 +2490,7 @@
LIST(APPEND WebCore_SOURCES
platform/ActivePlatformGestureAnimation.cpp
platform/ScrollAnimatorNone.cpp
- platform/TouchpadFlingPlatformGestureCurve.cpp
+ platform/TouchFlingPlatformGestureCurve.cpp
)
ENDIF ()
Modified: trunk/Source/WebCore/ChangeLog (127923 => 127924)
--- trunk/Source/WebCore/ChangeLog 2012-09-07 21:45:23 UTC (rev 127923)
+++ trunk/Source/WebCore/ChangeLog 2012-09-07 21:57:15 UTC (rev 127924)
@@ -1,3 +1,42 @@
+2012-09-07 Robert Kroeger <rjkro...@chromium.org>
+
+ [chromium] Add touchscreen specific fling curve parametrization
+ https://bugs.webkit.org/show_bug.cgi?id=95997
+
+ Reviewed by James Robinson.
+
+ Added a new set of fling curve parameters with a good feel for touchscreen
+ initiated flings. Renamed TouchpadFlingPlatformGestureCurve to
+ TouchFlingPlatformGestureCurve to better reflect that the class
+ can serve for both touchscreen and touchpad flings when appropriately
+ parametrized. Updated build files as necessary for the rename.
+
+ No new tests - existing tests apply.
+
+ * CMakeLists.txt:
+ * GNUmakefile.list.am:
+ * WebCore.gypi:
+ * platform/ScrollAnimatorNone.cpp:
+ (WebCore::ScrollAnimatorNone::fireUpAnAnimation):
+ * platform/TouchFlingPlatformGestureCurve.cpp: Renamed from Source/WebCore/platform/TouchpadFlingPlatformGestureCurve.cpp.
+ (WebCore):
+ (WebCore::TouchFlingPlatformGestureCurve::createForTouchPad):
+ (WebCore::TouchFlingPlatformGestureCurve::createForTouchScreen):
+ Added with touchscreen parameters.
+ (WebCore::TouchFlingPlatformGestureCurve::create):
+ (WebCore::position):
+ (WebCore::velocity):
+ (WebCore::TouchFlingPlatformGestureCurve::TouchFlingPlatformGestureCurve):
+ (WebCore::TouchFlingPlatformGestureCurve::~TouchFlingPlatformGestureCurve):
+ (WebCore::TouchFlingPlatformGestureCurve::debugName):
+ (WebCore::TouchFlingPlatformGestureCurve::apply):
+ * platform/TouchFlingPlatformGestureCurve.h: Renamed from Source/WebCore/platform/TouchpadFlingPlatformGestureCurve.h.
+ (WebCore):
+ (TouchFlingPlatformGestureCurve):
+ * platform/chromium/support/PlatformGestureCurveFactory.cpp: invokes
+ createForTouchPad or createForTouchScreen as appropriate.
+ (WebKit::PlatformGestureCurveFactory::createCurve):
+
2012-09-07 Adam Barth <aba...@chromium.org>
Enter the creationContext before creating DOM wrappers
Modified: trunk/Source/WebCore/GNUmakefile.list.am (127923 => 127924)
--- trunk/Source/WebCore/GNUmakefile.list.am 2012-09-07 21:45:23 UTC (rev 127923)
+++ trunk/Source/WebCore/GNUmakefile.list.am 2012-09-07 21:57:15 UTC (rev 127924)
@@ -4805,8 +4805,8 @@
Source/WebCore/platform/text/UnicodeBidi.h \
Source/WebCore/platform/text/UnicodeRange.cpp \
Source/WebCore/platform/text/UnicodeRange.h \
- Source/WebCore/platform/TouchpadFlingPlatformGestureCurve.cpp \
- Source/WebCore/platform/TouchpadFlingPlatformGestureCurve.h \
+ Source/WebCore/platform/TouchFlingPlatformGestureCurve.cpp \
+ Source/WebCore/platform/TouchFlingPlatformGestureCurve.h \
Source/WebCore/platform/ThemeTypes.h \
Source/WebCore/platform/ThreadCheck.h \
Source/WebCore/platform/ThreadGlobalData.cpp \
Modified: trunk/Source/WebCore/WebCore.gypi (127923 => 127924)
--- trunk/Source/WebCore/WebCore.gypi 2012-09-07 21:45:23 UTC (rev 127923)
+++ trunk/Source/WebCore/WebCore.gypi 2012-09-07 21:57:15 UTC (rev 127924)
@@ -4520,8 +4520,8 @@
'platform/ThreadTimers.cpp',
'platform/ThreadTimers.h',
'platform/Timer.cpp',
- 'platform/TouchpadFlingPlatformGestureCurve.cpp',
- 'platform/TouchpadFlingPlatformGestureCurve.h',
+ 'platform/TouchFlingPlatformGestureCurve.cpp',
+ 'platform/TouchFlingPlatformGestureCurve.h',
'platform/UUID.cpp',
'platform/UUID.h',
'platform/WheelFlingPlatformGestureCurve.cpp',
Modified: trunk/Source/WebCore/platform/ScrollAnimatorNone.cpp (127923 => 127924)
--- trunk/Source/WebCore/platform/ScrollAnimatorNone.cpp 2012-09-07 21:45:23 UTC (rev 127923)
+++ trunk/Source/WebCore/platform/ScrollAnimatorNone.cpp 2012-09-07 21:57:15 UTC (rev 127924)
@@ -46,7 +46,7 @@
#if ENABLE(GESTURE_ANIMATION)
#include "ActivePlatformGestureAnimation.h"
-#include "TouchpadFlingPlatformGestureCurve.h"
+#include "TouchFlingPlatformGestureCurve.h"
#endif
@@ -408,7 +408,7 @@
#if ENABLE(GESTURE_ANIMATION)
if (m_gestureAnimation)
m_gestureAnimation.clear();
- m_gestureAnimation = ActivePlatformGestureAnimation::create(TouchpadFlingPlatformGestureCurve::create(fp), this);
+ m_gestureAnimation = ActivePlatformGestureAnimation::create(TouchFlingPlatformGestureCurve::createForTouchPad(fp), this);
#endif
#if USE(REQUEST_ANIMATION_FRAME_TIMER)
startNextTimer(0);
Copied: trunk/Source/WebCore/platform/TouchFlingPlatformGestureCurve.cpp (from rev 127923, trunk/Source/WebCore/platform/TouchpadFlingPlatformGestureCurve.cpp) (0 => 127924)
--- trunk/Source/WebCore/platform/TouchFlingPlatformGestureCurve.cpp (rev 0)
+++ trunk/Source/WebCore/platform/TouchFlingPlatformGestureCurve.cpp 2012-09-07 21:57:15 UTC (rev 127924)
@@ -0,0 +1,162 @@
+/*
+ * Copyright (C) 2012 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#include "TouchFlingPlatformGestureCurve.h"
+
+#include "PlatformGestureCurveTarget.h"
+#include <math.h>
+
+namespace WebCore {
+
+using namespace std;
+
+// This curve implementation is based on the notion of a single, absolute curve, which starts at
+// a large velocity and smoothly decreases to zero. For a given input velocity, we find where on
+// the curve this velocity occurs, and start the animation at this point---denoted by (m_timeOffset,
+// m_positionOffset).
+//
+// This has the effect of automatically determining an animation duration that scales with input
+// velocity, as faster initial velocities start earlier on the curve and thus take longer to reach the end.
+// No complicated time scaling is required.
+//
+// Since the starting velocity is implicitly determined by our starting point, we only store the
+// relative magnitude and direction of both initial x- and y-velocities, and use this to scale the
+// computed displacement at any point in time. This guarantees that fling trajectories are straight
+// lines when viewed in x-y space. Initial velocities that lie outside the max velocity are constrained
+// to start at zero (and thus are implicitly scaled).
+//
+// The curve is modelled as a 4th order polynomial, starting at t = 0, and ending at t = m_curveDuration.
+// Attempts to generate position/velocity estimates outside this range are undefined.
+
+static const int cMaxSearchIterations = 20;
+
+PassOwnPtr<PlatformGestureCurve> TouchFlingPlatformGestureCurve::createForTouchPad(const FloatPoint& velocity, IntPoint cumulativeScroll)
+{
+ // The default parameters listed below are a matched set, and should not be changed independently of one another.
+ return create(velocity, -5.70762e+03, 1.72e+02, 3.7e+00, 1.3, cumulativeScroll);
+}
+
+PassOwnPtr<PlatformGestureCurve> TouchFlingPlatformGestureCurve::createForTouchScreen(const FloatPoint& velocity, IntPoint cumulativeScroll)
+{
+ // The touchscreen-specific parameters listed below are a matched set, and should not be changed independently of one another.
+ return create(velocity, -3.5e+03, 90, 3.0e+00, 1.5864, cumulativeScroll);
+}
+
+PassOwnPtr<PlatformGestureCurve> TouchFlingPlatformGestureCurve::create(const FloatPoint& velocity, float p0, float p1, float p2, float curveDuration, IntPoint cumulativeScroll)
+{
+ return adoptPtr(new TouchFlingPlatformGestureCurve(velocity, p0, p1, p2, curveDuration, cumulativeScroll));
+}
+
+inline double position(double t, float* p)
+{
+ return p[0] * exp(-p[2] * t) - p[1] * t - p[0];
+}
+
+inline double velocity(double t, float* p)
+{
+ return -p[0] * p[2] * exp(-p[2] * t) - p[1];
+}
+
+TouchFlingPlatformGestureCurve::TouchFlingPlatformGestureCurve(const FloatPoint& initialVelocity, float p0, float p1, float p2, float curveDuration, const IntPoint& cumulativeScroll)
+ : m_cumulativeScroll(cumulativeScroll)
+ , m_curveDuration(curveDuration)
+{
+ ASSERT(initialVelocity != FloatPoint::zero());
+
+ m_coefficients[0] = p0; // alpha
+ m_coefficients[1] = p1; // beta
+ m_coefficients[2] = p2; // gamma
+
+ float maxInitialVelocity = max(fabs(initialVelocity.x()), fabs(initialVelocity.y()));
+
+ // Force maxInitialVelocity to lie in the range v(0) to v(curveDuration), and assume that
+ // the curve parameters define a monotonically decreasing velocity, or else bisection search may
+ // fail.
+ if (maxInitialVelocity > velocity(0, m_coefficients))
+ maxInitialVelocity = velocity(0, m_coefficients);
+
+ if (maxInitialVelocity < velocity(m_curveDuration, m_coefficients))
+ maxInitialVelocity = velocity(m_curveDuration, m_coefficients);
+
+ // We keep track of relative magnitudes and directions of the velocity/displacement components here.
+ m_displacementRatio = FloatPoint(initialVelocity.x() / maxInitialVelocity, initialVelocity.y() / maxInitialVelocity);
+
+ // Use basic bisection to estimate where we should start on the curve.
+ // FIXME: Would Newton's method be better?
+ const double epsilon = 1; // It is probably good enough to get the start point to within 1 pixel/sec.
+ double t0 = 0;
+ double t1 = curveDuration;
+ int numIterations = 0;
+ while (t0 < t1 && numIterations < cMaxSearchIterations) {
+ numIterations++;
+ m_timeOffset = (t0 + t1) * 0.5;
+ double vOffset = velocity(m_timeOffset, m_coefficients);
+ if (fabs(maxInitialVelocity - vOffset) < epsilon)
+ break;
+
+ if (vOffset > maxInitialVelocity)
+ t0 = m_timeOffset;
+ else
+ t1 = m_timeOffset;
+ }
+
+ // Compute curve position at offset time
+ m_positionOffset = position(m_timeOffset, m_coefficients);
+}
+
+TouchFlingPlatformGestureCurve::~TouchFlingPlatformGestureCurve()
+{
+}
+
+const char* TouchFlingPlatformGestureCurve::debugName() const
+{
+ return "TouchpadFling";
+}
+
+bool TouchFlingPlatformGestureCurve::apply(double time, PlatformGestureCurveTarget* target)
+{
+ float displacement;
+ if (time < 0)
+ displacement = 0;
+ else if (time + m_timeOffset < m_curveDuration)
+ displacement = position(time + m_timeOffset, m_coefficients) - m_positionOffset;
+ else
+ displacement = position(m_curveDuration, m_coefficients) - m_positionOffset;
+
+ // Keep track of integer portion of scroll thus far, and prepare increment.
+ IntPoint scroll(displacement * m_displacementRatio.x(), displacement * m_displacementRatio.y());
+ IntPoint scrollIncrement(scroll - m_cumulativeScroll);
+ m_cumulativeScroll = scroll;
+
+ if (time + m_timeOffset < m_curveDuration || scrollIncrement != IntPoint::zero()) {
+ target->scrollBy(scrollIncrement);
+ return true;
+ }
+
+ return false;
+}
+
+} // namespace WebCore
Copied: trunk/Source/WebCore/platform/TouchFlingPlatformGestureCurve.h (from rev 127923, trunk/Source/WebCore/platform/TouchpadFlingPlatformGestureCurve.h) (0 => 127924)
--- trunk/Source/WebCore/platform/TouchFlingPlatformGestureCurve.h (rev 0)
+++ trunk/Source/WebCore/platform/TouchFlingPlatformGestureCurve.h 2012-09-07 21:57:15 UTC (rev 127924)
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2012 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef TouchFlingPlatformGestureCurve_h
+#define TouchFlingPlatformGestureCurve_h
+
+#include "FloatPoint.h"
+#include "PlatformGestureCurve.h"
+#include <wtf/OwnPtr.h>
+#include <wtf/PassOwnPtr.h>
+
+namespace WebCore {
+
+class PlatformGestureCurveTarget;
+
+// Implementation of PlatformGestureCurve suitable for touch pad/screen-based
+// fling scroll. Starts with a flat velocity profile based on 'velocity', which
+// tails off to zero. Time is scaled to that duration of the fling is proportional
+// the initial velocity.
+class TouchFlingPlatformGestureCurve : public PlatformGestureCurve {
+public:
+ static PassOwnPtr<PlatformGestureCurve> createForTouchPad(const FloatPoint& velocity, IntPoint cumulativeScroll = IntPoint());
+ static PassOwnPtr<PlatformGestureCurve> createForTouchScreen(const FloatPoint& velocity, IntPoint cumulativeScroll = IntPoint());
+ static PassOwnPtr<PlatformGestureCurve> create(const FloatPoint& velocity, float p0, float p1, float p2, float curveDuration, IntPoint cumulativeScroll = IntPoint());
+ virtual ~TouchFlingPlatformGestureCurve();
+
+ virtual const char* debugName() const OVERRIDE;
+ virtual bool apply(double monotonicTime, PlatformGestureCurveTarget*) OVERRIDE;
+
+private:
+ TouchFlingPlatformGestureCurve(const FloatPoint& velocity, float p0, float p1, float p2, float curveDuration, const IntPoint& cumulativeScroll);
+
+ FloatPoint m_displacementRatio;
+ IntPoint m_cumulativeScroll;
+ float m_coefficients[3];
+ float m_timeOffset;
+ float m_curveDuration;
+ float m_positionOffset;
+};
+
+} // namespace WebCore
+
+#endif
Deleted: trunk/Source/WebCore/platform/TouchpadFlingPlatformGestureCurve.cpp (127923 => 127924)
--- trunk/Source/WebCore/platform/TouchpadFlingPlatformGestureCurve.cpp 2012-09-07 21:45:23 UTC (rev 127923)
+++ trunk/Source/WebCore/platform/TouchpadFlingPlatformGestureCurve.cpp 2012-09-07 21:57:15 UTC (rev 127924)
@@ -1,160 +0,0 @@
-/*
- * Copyright (C) 2012 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-
-#include "TouchpadFlingPlatformGestureCurve.h"
-
-#include "PlatformGestureCurveTarget.h"
-#include <math.h>
-
-namespace WebCore {
-
-using namespace std;
-
-// This curve implementation is based on the notion of a single, absolute curve, which starts at
-// a large velocity and smoothly decreases to zero. For a given input velocity, we find where on
-// the curve this velocity occurs, and start the animation at this point---denoted by (m_timeOffset,
-// m_positionOffset).
-//
-// This has the effect of automatically determining an animation duration that scales with input
-// velocity, as faster initial velocities start earlier on the curve and thus take longer to reach the end.
-// No complicated time scaling is required.
-//
-// Since the starting velocity is implicitly determined by our starting point, we only store the
-// relative magnitude and direction of both initial x- and y-velocities, and use this to scale the
-// computed displacement at any point in time. This guarantees that fling trajectories are straight
-// lines when viewed in x-y space. Initial velocities that lie outside the max velocity are constrained
-// to start at zero (and thus are implicitly scaled).
-//
-// The curve is modelled as a 4th order polynomial, starting at t = 0, and ending at t = m_curveDuration.
-// Attempts to generate position/velocity estimates outside this range are undefined.
-
-const int TouchpadFlingPlatformGestureCurve::m_maxSearchIterations = 20;
-
-PassOwnPtr<PlatformGestureCurve> TouchpadFlingPlatformGestureCurve::create(const FloatPoint& velocity, IntPoint cumulativeScroll)
-{
- // The default parameters listed below are a matched set, and should not be changed independently of one another.
- return create(velocity, -5.70762e+03, 1.72e+02, 3.7e+00, 0, 0, 1.3, cumulativeScroll);
-}
-
-// FIXME: need to remove p3, p4 here and below as they are not used in the exponential curve, but leave in for now to facilitate
-// the in-flight patch for https://bugs.webkit.org/show_bug.cgi?id=81663 .
-PassOwnPtr<PlatformGestureCurve> TouchpadFlingPlatformGestureCurve::create(const FloatPoint& velocity, float p0, float p1, float p2, float p3, float p4, float curveDuration, IntPoint cumulativeScroll)
-{
- return adoptPtr(new TouchpadFlingPlatformGestureCurve(velocity, p0, p1, p2, p3, p4, curveDuration, cumulativeScroll));
-}
-
-inline double position(double t, float* p)
-{
- return p[0] * exp(-p[2] * t) - p[1] * t - p[0];
-}
-
-inline double velocity(double t, float* p)
-{
- return -p[0] * p[2] * exp(-p[2] * t) - p[1];
-}
-
-TouchpadFlingPlatformGestureCurve::TouchpadFlingPlatformGestureCurve(const FloatPoint& initialVelocity, float p0, float p1, float p2, float p3, float p4, float curveDuration, const IntPoint& cumulativeScroll)
- : m_cumulativeScroll(cumulativeScroll)
- , m_curveDuration(curveDuration)
-{
- ASSERT(initialVelocity != FloatPoint::zero());
-
- m_coeffs[0] = p0; // alpha
- m_coeffs[1] = p1; // beta
- m_coeffs[2] = p2; // gamma
- m_coeffs[3] = p3; // not used
- m_coeffs[4] = p4; // not used
-
- float maxInitialVelocity = max(fabs(initialVelocity.x()), fabs(initialVelocity.y()));
-
- // Force maxInitialVelocity to lie in the range v(0) to v(curveDuration), and assume that
- // the curve parameters define a monotonically decreasing velocity, or else bisection search may
- // fail.
- if (maxInitialVelocity > velocity(0, m_coeffs))
- maxInitialVelocity = velocity(0, m_coeffs);
-
- if (maxInitialVelocity < velocity(m_curveDuration, m_coeffs))
- maxInitialVelocity = velocity(m_curveDuration, m_coeffs);
-
- // We keep track of relative magnitudes and directions of the velocity/displacement components here.
- m_displacementRatio = FloatPoint(initialVelocity.x() / maxInitialVelocity, initialVelocity.y() / maxInitialVelocity);
-
- // Use basic bisection to estimate where we should start on the curve.
- // FIXME: Would Newton's method be better?
- const double epsilon = 1; // It is probably good enough to get the start point to within 1 pixel/sec.
- double t0 = 0;
- double t1 = curveDuration;
- int numIterations = 0;
- while (t0 < t1 && numIterations < m_maxSearchIterations) {
- numIterations++;
- m_timeOffset = (t0 + t1) * 0.5;
- double vOffset = velocity(m_timeOffset, m_coeffs);
- if (fabs(maxInitialVelocity - vOffset) < epsilon)
- break;
-
- if (vOffset > maxInitialVelocity)
- t0 = m_timeOffset;
- else
- t1 = m_timeOffset;
- }
-
- // Compute curve position at offset time
- m_positionOffset = position(m_timeOffset, m_coeffs);
-}
-
-TouchpadFlingPlatformGestureCurve::~TouchpadFlingPlatformGestureCurve()
-{
-}
-
-const char* TouchpadFlingPlatformGestureCurve::debugName() const
-{
- return "TouchpadFling";
-}
-
-bool TouchpadFlingPlatformGestureCurve::apply(double time, PlatformGestureCurveTarget* target)
-{
- float displacement;
- if (time < 0)
- displacement = 0;
- else if (time + m_timeOffset < m_curveDuration)
- displacement = position(time + m_timeOffset, m_coeffs) - m_positionOffset;
- else
- displacement = position(m_curveDuration, m_coeffs) - m_positionOffset;
-
- // Keep track of integer portion of scroll thus far, and prepare increment.
- IntPoint scroll(displacement * m_displacementRatio.x(), displacement * m_displacementRatio.y());
- IntPoint scrollIncrement(scroll - m_cumulativeScroll);
- m_cumulativeScroll = scroll;
-
- if (time + m_timeOffset < m_curveDuration || scrollIncrement != IntPoint::zero()) {
- target->scrollBy(scrollIncrement);
- return true;
- }
-
- return false;
-}
-
-} // namespace WebCore
Deleted: trunk/Source/WebCore/platform/TouchpadFlingPlatformGestureCurve.h (127923 => 127924)
--- trunk/Source/WebCore/platform/TouchpadFlingPlatformGestureCurve.h 2012-09-07 21:45:23 UTC (rev 127923)
+++ trunk/Source/WebCore/platform/TouchpadFlingPlatformGestureCurve.h 2012-09-07 21:57:15 UTC (rev 127924)
@@ -1,65 +0,0 @@
-/*
- * Copyright (C) 2012 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef TouchpadFlingPlatformGestureCurve_h
-#define TouchpadFlingPlatformGestureCurve_h
-
-#include "FloatPoint.h"
-#include "PlatformGestureCurve.h"
-#include <wtf/OwnPtr.h>
-#include <wtf/PassOwnPtr.h>
-
-namespace WebCore {
-
-class PlatformGestureCurveTarget;
-
-// Implementation of PlatformGestureCurve suitable for touch pad/screen-based
-// fling scroll. Starts with a flat velocity profile based on 'velocity', which
-// tails off to zero. Time is scaled to that duration of the fling is proportional
-// the initial velocity.
-class TouchpadFlingPlatformGestureCurve : public PlatformGestureCurve {
-public:
- static PassOwnPtr<PlatformGestureCurve> create(const FloatPoint& velocity, IntPoint cumulativeScroll = IntPoint());
- static PassOwnPtr<PlatformGestureCurve> create(const FloatPoint& velocity, float p0, float p1, float p2, float p3, float p4, float curveDuration, IntPoint cumulativeScroll = IntPoint());
- virtual ~TouchpadFlingPlatformGestureCurve();
-
- virtual const char* debugName() const OVERRIDE;
- virtual bool apply(double monotonicTime, PlatformGestureCurveTarget*) OVERRIDE;
-
-private:
- TouchpadFlingPlatformGestureCurve(const FloatPoint& velocity, float p0, float p1, float p2, float p3, float p4, float curveDuration, const IntPoint& cumulativeScroll);
-
- FloatPoint m_displacementRatio;
- IntPoint m_cumulativeScroll;
- float m_coeffs[5];
- float m_timeOffset;
- float m_curveDuration;
- float m_positionOffset;
-
- static const int m_maxSearchIterations;
-};
-
-} // namespace WebCore
-
-#endif
Modified: trunk/Source/WebCore/platform/chromium/support/PlatformGestureCurveFactory.cpp (127923 => 127924)
--- trunk/Source/WebCore/platform/chromium/support/PlatformGestureCurveFactory.cpp 2012-09-07 21:45:23 UTC (rev 127923)
+++ trunk/Source/WebCore/platform/chromium/support/PlatformGestureCurveFactory.cpp 2012-09-07 21:57:15 UTC (rev 127924)
@@ -29,7 +29,7 @@
#include "FloatPoint.h"
#include "IntRect.h"
-#include "TouchpadFlingPlatformGestureCurve.h"
+#include "TouchFlingPlatformGestureCurve.h"
#include "WebFlingAnimatorToGestureCurveAdapter.h"
#include "WebInputEvent.h"
@@ -50,11 +50,10 @@
if (flingAnimator)
return WebFlingAnimatorToGestureCurveAdapter::create(point, WebCore::IntRect(), flingAnimator.release());
- // FIXME: Add a touch-screen sourced specific curve.
if (deviceSource == WebGestureEvent::Touchscreen)
- return WebCore::TouchpadFlingPlatformGestureCurve::create(point, cumulativeScroll);
+ return WebCore::TouchFlingPlatformGestureCurve::createForTouchScreen(point, cumulativeScroll);
- return WebCore::TouchpadFlingPlatformGestureCurve::create(point, cumulativeScroll);
+ return WebCore::TouchFlingPlatformGestureCurve::createForTouchPad(point, cumulativeScroll);
}
void PlatformGestureCurveFactory::setWebFlingAnimatorForTest(PassOwnPtr<WebFlingAnimator> mockFlingAnimator)
Modified: trunk/Source/WebKit/chromium/ChangeLog (127923 => 127924)
--- trunk/Source/WebKit/chromium/ChangeLog 2012-09-07 21:45:23 UTC (rev 127923)
+++ trunk/Source/WebKit/chromium/ChangeLog 2012-09-07 21:57:15 UTC (rev 127924)
@@ -1,3 +1,21 @@
+2012-09-07 Robert Kroeger <rjkro...@chromium.org>
+
+ [chromium] Add touchscreen specific fling curve parametrization
+ https://bugs.webkit.org/show_bug.cgi?id=95997
+
+ Reviewed by James Robinson.
+
+ Added a new set of fling curve parameters with a good feel for touchscreen
+ initiated flings. Renamed TouchpadFlingPlatformGestureCurve to
+ TouchFlingPlatformGestureCurve to better reflect that the class
+ can serve for both touchscreen and touchpad flings when appropriately
+ parametrized. Updated build files as necessary for the rename.
+
+ No new tests - existing tests apply.
+
+
+ * tests/PlatformGestureCurveTest.cpp: To use the renamed curve constructor.
+
2012-09-07 Dana Jansens <dan...@chromium.org>
[chromium] Make RenderPass ids hold both generating layer id and an index
Modified: trunk/Source/WebKit/chromium/tests/PlatformGestureCurveTest.cpp (127923 => 127924)
--- trunk/Source/WebKit/chromium/tests/PlatformGestureCurveTest.cpp 2012-09-07 21:45:23 UTC (rev 127923)
+++ trunk/Source/WebKit/chromium/tests/PlatformGestureCurveTest.cpp 2012-09-07 21:57:15 UTC (rev 127924)
@@ -29,7 +29,7 @@
#include "ActivePlatformGestureAnimation.h"
#include "PlatformGestureCurveTarget.h"
-#include "TouchpadFlingPlatformGestureCurve.h"
+#include "TouchFlingPlatformGestureCurve.h"
#include "WheelFlingPlatformGestureCurve.h"
#include <gtest/gtest.h>
#include <wtf/OwnPtr.h>
@@ -99,7 +99,7 @@
{
double initialVelocity = 5000;
MockPlatformGestureCurveTarget target;
- OwnPtr<ActivePlatformGestureAnimation> animation = ActivePlatformGestureAnimation::create(TouchpadFlingPlatformGestureCurve::create(FloatPoint(initialVelocity, 0)), &target);
+ OwnPtr<ActivePlatformGestureAnimation> animation = ActivePlatformGestureAnimation::create(TouchFlingPlatformGestureCurve::createForTouchPad(FloatPoint(initialVelocity, 0)), &target);
// Note: the expectations below are dependent on the value of sigma hard-coded in the curve parameters.
// If the parameters change, then the tests values/expectations will need to be updated.