Diff
Modified: trunk/Source/Platform/ChangeLog (133202 => 133203)
--- trunk/Source/Platform/ChangeLog 2012-11-01 18:53:40 UTC (rev 133202)
+++ trunk/Source/Platform/ChangeLog 2012-11-01 18:56:07 UTC (rev 133203)
@@ -1,3 +1,41 @@
+2012-11-01 Robert Kroeger <rjkro...@chromium.org>
+
+ [chromium] Provide WebKit API interface for platform gesture curves
+ https://bugs.webkit.org/show_bug.cgi?id=100675
+
+ Reviewed by James Robinson.
+
+ Define interfaces to permit the Chromium embedder to provide its own
+ implementation of a gesture animation curve and add an entry point
+ to Platform.h that permits WebKit to obtain an instance of an embedder-
+ provided gesture curve.
+
+ No tests needed in this CL: only interfaces are being added.
+
+ * Platform.gypi:
+ * chromium/public/Platform.h:
+ (WebKit):
+ (Platform):
+ (WebKit::Platform::createFlingAnimationCurve):
+ * chromium/public/WebGestureCurve.h: Added.
+ (WebKit):
+ (WebGestureCurve):
+ (WebKit::WebGestureCurve::~WebGestureCurve):
+ * chromium/public/WebGestureCurveTarget.h: Added.
+ (WebKit):
+ (WebGestureCurveTarget):
+ (WebKit::WebGestureCurveTarget::~WebGestureCurveTarget):
+ * chromium/src/WebActiveGestureAnimation.cpp: Added.
+ (WebKit):
+ (WebKit::WebActiveGestureAnimation::createAtAnimationStart):
+ (WebKit::WebActiveGestureAnimation::createWithTimeOffset):
+ (WebKit::WebActiveGestureAnimation::~WebActiveGestureAnimation):
+ (WebKit::WebActiveGestureAnimation::WebActiveGestureAnimation):
+ (WebKit::WebActiveGestureAnimation::animate):
+ * chromium/src/WebActiveGestureAnimation.h: Added.
+ (WebKit):
+ (WebActiveGestureAnimation):
+
2012-11-01 Dana Jansens <dan...@chromium.org>
[chromium] Allow implicit conversion between gfx::Vector2d and WebSize
Modified: trunk/Source/Platform/Platform.gypi (133202 => 133203)
--- trunk/Source/Platform/Platform.gypi 2012-11-01 18:53:40 UTC (rev 133202)
+++ trunk/Source/Platform/Platform.gypi 2012-11-01 18:56:07 UTC (rev 133203)
@@ -71,6 +71,8 @@
'chromium/public/WebFloatRect.h',
'chromium/public/WebGamepad.h',
'chromium/public/WebGamepads.h',
+ 'chromium/public/WebGestureCurveTarget.h',
+ 'chromium/public/WebGestureCurve.h',
'chromium/public/WebGraphicsContext3D.h',
'chromium/public/WebHTTPBody.h',
'chromium/public/WebHTTPHeaderVisitor.h',
@@ -164,6 +166,8 @@
'chromium/public/win/WebSandboxSupport.h',
'chromium/public/win/WebThemeEngine.h',
'chromium/src/Platform.cpp',
+ 'chromium/src/WebActiveGestureAnimation.cpp',
+ 'chromium/src/WebActiveGestureAnimation.h',
'chromium/src/WebCString.cpp',
'chromium/src/WebFilterOperation.cpp',
'chromium/src/WebFilterOperations.cpp',
Modified: trunk/Source/Platform/chromium/public/Platform.h (133202 => 133203)
--- trunk/Source/Platform/chromium/public/Platform.h 2012-11-01 18:53:40 UTC (rev 133202)
+++ trunk/Source/Platform/chromium/public/Platform.h 2012-11-01 18:56:07 UTC (rev 133203)
@@ -54,6 +54,8 @@
class WebFileSystem;
class WebFileUtilities;
class WebFlingAnimator;
+class WebGestureCurveTarget;
+class WebGestureCurve;
class WebMediaStreamCenter;
class WebMediaStreamCenterClient;
class WebMessagePortChannel;
@@ -71,6 +73,8 @@
class WebURLLoader;
class WebWorkerRunLoop;
struct WebLocalizedString;
+struct WebFloatPoint;
+struct WebSize;
class Platform {
public:
@@ -416,6 +420,10 @@
virtual WebFlingAnimator* createFlingAnimator() { return 0; }
+ // Creates a new fling animation curve instance for device |deviceSource|
+ // with |velocity| and already scrolled |cumulativeScroll| pixels.
+ virtual WebGestureCurve* createFlingAnimationCurve(int deviceSource, const WebFloatPoint& velocity, const WebSize& cumulativeScroll) { return 0; }
+
// WebRTC ----------------------------------------------------------
// DEPRECATED
Added: trunk/Source/Platform/chromium/public/WebGestureCurve.h (0 => 133203)
--- trunk/Source/Platform/chromium/public/WebGestureCurve.h (rev 0)
+++ trunk/Source/Platform/chromium/public/WebGestureCurve.h 2012-11-01 18:56:07 UTC (rev 133203)
@@ -0,0 +1,46 @@
+/*
+ * 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 WebGestureCurve_h
+#define WebGestureCurve_h
+
+namespace WebKit {
+
+class WebGestureCurveTarget;
+
+// Abstract interface for curves used by ActivePlatformGestureAnimation. A
+// WebGestureCurve defines the animation parameters as a function of time
+// (zero-based), and applies the parameters directly to the target of the
+// animation.
+class WebGestureCurve {
+public:
+ virtual ~WebGestureCurve() { }
+
+ // Returns false if curve has finished and can no longer be applied.
+ virtual bool apply(double time, WebGestureCurveTarget*) = 0;
+};
+
+} // namespace WebKit
+
+#endif
Added: trunk/Source/Platform/chromium/public/WebGestureCurveTarget.h (0 => 133203)
--- trunk/Source/Platform/chromium/public/WebGestureCurveTarget.h (rev 0)
+++ trunk/Source/Platform/chromium/public/WebGestureCurveTarget.h 2012-11-01 18:56:07 UTC (rev 133203)
@@ -0,0 +1,42 @@
+/*
+ * 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 WebGestureCurveTarget_h
+#define WebGestureCurveTarget_h
+
+namespace WebKit {
+
+class WebPoint;
+
+class WebGestureCurveTarget {
+public:
+ virtual void scrollBy(const WebPoint&) = 0;
+
+protected:
+ virtual ~WebGestureCurveTarget() { }
+};
+
+} // namespace WebKit
+
+#endif
Added: trunk/Source/Platform/chromium/src/WebActiveGestureAnimation.cpp (0 => 133203)
--- trunk/Source/Platform/chromium/src/WebActiveGestureAnimation.cpp (rev 0)
+++ trunk/Source/Platform/chromium/src/WebActiveGestureAnimation.cpp 2012-11-01 18:56:07 UTC (rev 133203)
@@ -0,0 +1,67 @@
+/*
+ * 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 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 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 "WebActiveGestureAnimation.h"
+
+#include <public/WebGestureCurve.h>
+#include <public/WebGestureCurveTarget.h>
+
+namespace WebKit {
+
+PassOwnPtr<WebActiveGestureAnimation> WebActiveGestureAnimation::createAtAnimationStart(PassOwnPtr<WebGestureCurve> curve, WebGestureCurveTarget* target)
+{
+ return adoptPtr(new WebActiveGestureAnimation(curve, target, 0, true));
+}
+
+PassOwnPtr<WebActiveGestureAnimation> WebActiveGestureAnimation::createWithTimeOffset(PassOwnPtr<WebGestureCurve> curve, WebGestureCurveTarget* target, double startTime)
+{
+ return adoptPtr(new WebActiveGestureAnimation(curve, target, startTime, false));
+}
+
+WebActiveGestureAnimation::~WebActiveGestureAnimation()
+{
+}
+
+WebActiveGestureAnimation::WebActiveGestureAnimation(PassOwnPtr<WebGestureCurve> curve, WebGestureCurveTarget* target, double startTime, bool waitingForFirstTick)
+ : m_startTime(startTime)
+ , m_waitingForFirstTick(waitingForFirstTick)
+ , m_curve(curve)
+ , m_target(target)
+{
+}
+
+bool WebActiveGestureAnimation::animate(double time)
+{
+ if (m_waitingForFirstTick) {
+ m_startTime = time;
+ m_waitingForFirstTick = false;
+ }
+ // All WebGestureCurves assume zero-based time, so we subtract
+ // the animation start time before passing to the curve.
+ return m_curve->apply(time - m_startTime, m_target);
+}
+
+} // namespace WebKit
Added: trunk/Source/Platform/chromium/src/WebActiveGestureAnimation.h (0 => 133203)
--- trunk/Source/Platform/chromium/src/WebActiveGestureAnimation.h (rev 0)
+++ trunk/Source/Platform/chromium/src/WebActiveGestureAnimation.h 2012-11-01 18:56:07 UTC (rev 133203)
@@ -0,0 +1,63 @@
+/*
+ * 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 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 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 WebActiveGestureAnimation_h
+#define WebActiveGestureAnimation_h
+
+#include <wtf/Noncopyable.h>
+#include <wtf/OwnPtr.h>
+#include <wtf/PassOwnPtr.h>
+
+namespace WebKit {
+
+class WebGestureCurve;
+class WebGestureCurveTarget;
+
+// Implements a gesture animation (fling scroll, etc.) using a curve with a generic interface
+// to define the animation parameters as a function of time, and applies the animation
+// to a target, again via a generic interface. It is assumed that animate() is called
+// on a more-or-less regular basis by the owner.
+class WebActiveGestureAnimation {
+ WTF_MAKE_NONCOPYABLE(WebActiveGestureAnimation);
+public:
+ static PassOwnPtr<WebActiveGestureAnimation> createAtAnimationStart(PassOwnPtr<WebGestureCurve>, WebGestureCurveTarget*);
+ static PassOwnPtr<WebActiveGestureAnimation> createWithTimeOffset(PassOwnPtr<WebGestureCurve>, WebGestureCurveTarget*, double startTime);
+ ~WebActiveGestureAnimation();
+
+ bool animate(double time);
+
+private:
+ // Assumes a valid WebGestureCurveTarget that outlives the animation.
+ WebActiveGestureAnimation(PassOwnPtr<WebGestureCurve>, WebGestureCurveTarget*, double startTime, bool waitingForFirstTick);
+
+ double m_startTime;
+ bool m_waitingForFirstTick;
+ OwnPtr<WebGestureCurve> m_curve;
+ WebGestureCurveTarget* m_target;
+};
+
+} // namespace WebKit
+
+#endif