[chromium] Create a WebKit::Web* wrapper for the cc animation classes
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 2 Jul 2012 02:21:19 +0000 (02:21 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 2 Jul 2012 02:21:19 +0000 (02:21 +0000)
https://bugs.webkit.org/show_bug.cgi?id=90303

Patch by Ian Vollick <vollick@chromium.org> on 2012-07-01
Reviewed by James Robinson.

Source/Platform:

* Platform.gypi:
* chromium/public/WebAnimation.h: Added.
(WebCore):
(WebKit):
(WebAnimation):
(WebKit::WebAnimation::WebAnimation):
(WebKit::WebAnimation::~WebAnimation):
* chromium/public/WebAnimationCurve.h: Added.
(WebCore):
(WebKit):
(WebAnimationCurve):
(WebKit::WebAnimationCurve::~WebAnimationCurve):
(WebKit::WebAnimationCurve::WebAnimationCurve):
* chromium/public/WebFloatAnimationCurve.h: Added.
(WebCore):
(WebKit):
(WebFloatAnimationCurve):
(WebKit::WebFloatAnimationCurve::WebFloatAnimationCurve):
(WebKit::WebFloatAnimationCurve::~WebFloatAnimationCurve):
* chromium/public/WebFloatKeyframe.h: Added.
(WebKit):
(WebKit::WebFloatKeyframe::WebFloatKeyframe):
(WebFloatKeyframe):
* chromium/public/WebTransformAnimationCurve.h: Added.
(WebCore):
(WebKit):
(WebTransformAnimationCurve):
(WebKit::WebTransformAnimationCurve::WebTransformAnimationCurve):
(WebKit::WebTransformAnimationCurve::~WebTransformAnimationCurve):
* chromium/public/WebTransformKeyframe.h: Added.
(WebKit):
(WebKit::WebTransformKeyframe::WebTransformKeyframe):
(WebTransformKeyframe):

Source/WebKit/chromium:

* WebKit.gyp:
* WebKit.gypi:
* src/WebAnimation.cpp: Added.
(WebKit):
(WebKit::WebAnimation::iterations):
(WebKit::WebAnimation::setIterations):
(WebKit::WebAnimation::startTime):
(WebKit::WebAnimation::setStartTime):
(WebKit::WebAnimation::timeOffset):
(WebKit::WebAnimation::setTimeOffset):
(WebKit::WebAnimation::alternatesDirection):
(WebKit::WebAnimation::setAlternatesDirection):
(WebKit::WebAnimation::toCCActiveAnimation):
(WebKit::WebAnimation::initialize):
(WebKit::WebAnimation::destroy):
* src/WebAnimationCurveCommon.cpp: Added.
(WebKit):
(WebKit::createTimingFunction):
* src/WebAnimationCurveCommon.h: Added.
(WebCore):
(WebKit):
* src/WebFloatAnimationCurve.cpp: Added.
(WebKit):
(WebKit::WebFloatAnimationCurve::add):
(WebKit::WebFloatAnimationCurve::toCCAnimationCurve):
(WebKit::WebFloatAnimationCurve::initialize):
(WebKit::WebFloatAnimationCurve::destroy):
* src/WebTransformAnimationCurve.cpp: Added.
(WebKit):
(WebKit::WebTransformAnimationCurve::add):
(WebKit::WebTransformAnimationCurve::toCCAnimationCurve):
(WebKit::WebTransformAnimationCurve::initialize):
(WebKit::WebTransformAnimationCurve::destroy):
* tests/WebAnimationTest.cpp: Added.
* tests/WebFloatAnimationCurveTest.cpp: Added.
* tests/WebTransformAnimationCurveTest.cpp: Added.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@121650 268f45cc-cd09-0410-ab3c-d52691b4dbfc

19 files changed:
Source/Platform/ChangeLog
Source/Platform/Platform.gypi
Source/Platform/chromium/public/WebAnimation.h [new file with mode: 0644]
Source/Platform/chromium/public/WebAnimationCurve.h [new file with mode: 0644]
Source/Platform/chromium/public/WebFloatAnimationCurve.h [new file with mode: 0644]
Source/Platform/chromium/public/WebFloatKeyframe.h [new file with mode: 0644]
Source/Platform/chromium/public/WebTransformAnimationCurve.h [new file with mode: 0644]
Source/Platform/chromium/public/WebTransformKeyframe.h [new file with mode: 0644]
Source/WebKit/chromium/ChangeLog
Source/WebKit/chromium/WebKit.gyp
Source/WebKit/chromium/WebKit.gypi
Source/WebKit/chromium/src/WebAnimation.cpp [new file with mode: 0644]
Source/WebKit/chromium/src/WebAnimationCurveCommon.cpp [new file with mode: 0644]
Source/WebKit/chromium/src/WebAnimationCurveCommon.h [new file with mode: 0644]
Source/WebKit/chromium/src/WebFloatAnimationCurve.cpp [new file with mode: 0644]
Source/WebKit/chromium/src/WebTransformAnimationCurve.cpp [new file with mode: 0644]
Source/WebKit/chromium/tests/WebAnimationTest.cpp [new file with mode: 0644]
Source/WebKit/chromium/tests/WebFloatAnimationCurveTest.cpp [new file with mode: 0644]
Source/WebKit/chromium/tests/WebTransformAnimationCurveTest.cpp [new file with mode: 0644]

index ab2cf9a..bbf2d59 100644 (file)
@@ -1,3 +1,44 @@
+2012-07-01  Ian Vollick  <vollick@chromium.org>
+
+        [chromium] Create a WebKit::Web* wrapper for the cc animation classes
+        https://bugs.webkit.org/show_bug.cgi?id=90303
+
+        Reviewed by James Robinson.
+
+        * Platform.gypi:
+        * chromium/public/WebAnimation.h: Added.
+        (WebCore):
+        (WebKit):
+        (WebAnimation):
+        (WebKit::WebAnimation::WebAnimation):
+        (WebKit::WebAnimation::~WebAnimation):
+        * chromium/public/WebAnimationCurve.h: Added.
+        (WebCore):
+        (WebKit):
+        (WebAnimationCurve):
+        (WebKit::WebAnimationCurve::~WebAnimationCurve):
+        (WebKit::WebAnimationCurve::WebAnimationCurve):
+        * chromium/public/WebFloatAnimationCurve.h: Added.
+        (WebCore):
+        (WebKit):
+        (WebFloatAnimationCurve):
+        (WebKit::WebFloatAnimationCurve::WebFloatAnimationCurve):
+        (WebKit::WebFloatAnimationCurve::~WebFloatAnimationCurve):
+        * chromium/public/WebFloatKeyframe.h: Added.
+        (WebKit):
+        (WebKit::WebFloatKeyframe::WebFloatKeyframe):
+        (WebFloatKeyframe):
+        * chromium/public/WebTransformAnimationCurve.h: Added.
+        (WebCore):
+        (WebKit):
+        (WebTransformAnimationCurve):
+        (WebKit::WebTransformAnimationCurve::WebTransformAnimationCurve):
+        (WebKit::WebTransformAnimationCurve::~WebTransformAnimationCurve):
+        * chromium/public/WebTransformKeyframe.h: Added.
+        (WebKit):
+        (WebKit::WebTransformKeyframe::WebTransformKeyframe):
+        (WebTransformKeyframe):
+
 2012-06-30  Ian Vollick  <vollick@chromium.org>
 
         [chromium] CanvasLayerTextureUpdater needs to convert opaque rects back to content space.
index 7d564f7..6290ca9 100644 (file)
@@ -32,6 +32,8 @@
     'variables': {
         'platform_files': [
             'chromium/public/Platform.h',
+            'chromium/public/WebAnimation.h'
+            'chromium/public/WebAnimationCurve.h',
             'chromium/public/WebAudioBus.h',
             'chromium/public/WebAudioDevice.h',
             'chromium/public/WebBlobData.h',
@@ -54,6 +56,8 @@
             'chromium/public/WebFileUtilities.h',
             'chromium/public/WebFilterOperation.h',
             'chromium/public/WebFilterOperations.h',
+            'chromium/public/WebFloatAnimationCurve.h',
+            'chromium/public/WebFloatKeyframe.h',
             'chromium/public/WebFloatPoint.h',
             'chromium/public/WebFloatQuad.h',
             'chromium/public/WebFloatRect.h',
             'chromium/public/WebThread.h',
             'chromium/public/WebThreadSafeData.h',
             'chromium/public/WebTransformationMatrix.h',
+            'chromium/public/WebTransformAnimationCurve.h',
+            'chromium/public/WebTransformKeyframe.h',
             'chromium/public/WebTransformOperations.h',
             'chromium/public/WebPrerender.h',
             'chromium/public/WebURL.h',
diff --git a/Source/Platform/chromium/public/WebAnimation.h b/Source/Platform/chromium/public/WebAnimation.h
new file mode 100644 (file)
index 0000000..b715e05
--- /dev/null
@@ -0,0 +1,93 @@
+/*
+ * 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 WebAnimation_h
+#define WebAnimation_h
+
+#include "WebCommon.h"
+#include "WebNonCopyable.h"
+#include "WebPrivateOwnPtr.h"
+
+#if WEBKIT_IMPLEMENTATION
+#include <wtf/Forward.h>
+#endif
+
+namespace WebCore {
+class CCActiveAnimation;
+}
+
+namespace WebKit {
+
+class WebAnimationCurve;
+
+// A compositor driven animation.
+class WebAnimation : public WebNonCopyable {
+public:
+    enum TargetProperty {
+        WebAnimationTransform = 1,
+        WebAnimationOpacity
+    };
+
+    WebAnimation(const WebAnimationCurve& curve, TargetProperty targetProperty)
+    {
+        initialize(curve, targetProperty);
+    }
+
+    ~WebAnimation()
+    {
+        destroy();
+    }
+
+    // This is the number of times that the animation will play. If this
+    // value is zero the animation will not play. If it is negative, then
+    // the animation will loop indefinitely.
+    WEBKIT_EXPORT int iterations() const;
+    WEBKIT_EXPORT void setIterations(int);
+
+    WEBKIT_EXPORT double startTime() const;
+    WEBKIT_EXPORT void setStartTime(double monotonicTime);
+    WEBKIT_EXPORT bool hasSetStartTime() const;
+
+    WEBKIT_EXPORT double timeOffset() const;
+    WEBKIT_EXPORT void setTimeOffset(double monotonicTime);
+
+    // If alternatesDirection is true, on odd numbered iterations we reverse the curve.
+    WEBKIT_EXPORT bool alternatesDirection() const;
+    WEBKIT_EXPORT void setAlternatesDirection(bool);
+
+#if WEBKIT_IMPLEMENTATION
+    operator PassOwnPtr<WebCore::CCActiveAnimation>() const;
+#endif
+
+private:
+    WEBKIT_EXPORT void initialize(const WebAnimationCurve&, TargetProperty);
+    WEBKIT_EXPORT void initialize(const WebAnimation&);
+    WEBKIT_EXPORT void destroy();
+
+    WebPrivateOwnPtr<WebCore::CCActiveAnimation> m_private;
+};
+
+} // namespace WebKit
+
+#endif // WebAnimation_h
diff --git a/Source/Platform/chromium/public/WebAnimationCurve.h b/Source/Platform/chromium/public/WebAnimationCurve.h
new file mode 100644 (file)
index 0000000..e9ecc1e
--- /dev/null
@@ -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 WebAnimationCurve_h
+#define WebAnimationCurve_h
+
+#include "WebCommon.h"
+#include "WebNonCopyable.h"
+
+#if WEBKIT_IMPLEMENTATION
+#include <wtf/Forward.h>
+#endif
+
+namespace WebCore {
+class CCAnimationCurve;
+}
+
+namespace WebKit {
+
+class WebAnimationCurve : public WebNonCopyable {
+public:
+    virtual ~WebAnimationCurve() { }
+
+    enum TimingFunctionType {
+        TimingFunctionTypeEase,
+        TimingFunctionTypeEaseIn,
+        TimingFunctionTypeEaseOut,
+        TimingFunctionTypeEaseInOut,
+        TimingFunctionTypeLinear
+    };
+
+#if WEBKIT_IMPLEMENTATION
+    virtual operator PassOwnPtr<WebCore::CCAnimationCurve>() const = 0;
+#endif
+
+protected:
+    WebAnimationCurve() { }
+};
+
+} // namespace WebKit
+
+#endif // WebAnimationCurve_h
+
diff --git a/Source/Platform/chromium/public/WebFloatAnimationCurve.h b/Source/Platform/chromium/public/WebFloatAnimationCurve.h
new file mode 100644 (file)
index 0000000..65a7f24
--- /dev/null
@@ -0,0 +1,73 @@
+/*
+ * 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 WebFloatAnimationCurve_h
+#define WebFloatAnimationCurve_h
+
+#include "WebAnimationCurve.h"
+
+#include "WebCommon.h"
+#include "WebFloatKeyframe.h"
+#include "WebPrivateOwnPtr.h"
+
+#if WEBKIT_IMPLEMENTATION
+#include <wtf/Forward.h>
+#endif
+
+namespace WebCore {
+class CCAnimationCurve;
+class CCKeyframedFloatAnimationCurve;
+}
+
+namespace WebKit {
+
+// A keyframed float animation curve.
+class WebFloatAnimationCurve : public WebAnimationCurve {
+public:
+    WebFloatAnimationCurve() { initialize(); }
+    virtual ~WebFloatAnimationCurve() { destroy(); }
+
+    // Adds the keyframe with the default timing function (ease).
+    WEBKIT_EXPORT void add(const WebFloatKeyframe&);
+    WEBKIT_EXPORT void add(const WebFloatKeyframe&, TimingFunctionType);
+    // Adds the keyframe with a custom, bezier timing function. Note, it is
+    // assumed that x0 = y0 = 0, and x3 = y3 = 1.
+    WEBKIT_EXPORT void add(const WebFloatKeyframe&, double x1, double y1, double x2, double y2);
+
+    WEBKIT_EXPORT float getValue(double time) const;
+
+#if WEBKIT_IMPLEMENTATION
+    virtual operator PassOwnPtr<WebCore::CCAnimationCurve>() const;
+#endif
+
+private:
+    WEBKIT_EXPORT void initialize();
+    WEBKIT_EXPORT void destroy();
+
+    WebPrivateOwnPtr<WebCore::CCKeyframedFloatAnimationCurve> m_private;
+};
+
+} // namespace WebKit
+
+#endif // WebFloatAnimationCurve_h
diff --git a/Source/Platform/chromium/public/WebFloatKeyframe.h b/Source/Platform/chromium/public/WebFloatKeyframe.h
new file mode 100644 (file)
index 0000000..d276418
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ * 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 WebFloatKeyframe_h
+#define WebFloatKeyframe_h
+
+namespace WebKit {
+
+struct WebFloatKeyframe {
+    WebFloatKeyframe(double time, float value)
+        : time(time)
+        , value(value)
+    {
+    }
+
+    double time;
+    float value;
+};
+
+} // namespace WebKit
+
+#endif // WebFloatKeyframe_h
diff --git a/Source/Platform/chromium/public/WebTransformAnimationCurve.h b/Source/Platform/chromium/public/WebTransformAnimationCurve.h
new file mode 100644 (file)
index 0000000..99cb670
--- /dev/null
@@ -0,0 +1,74 @@
+/*
+ * 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 WebTransformAnimationCurve_h
+#define WebTransformAnimationCurve_h
+
+#include "WebAnimationCurve.h"
+
+#include "WebCommon.h"
+#include "WebPrivateOwnPtr.h"
+#include "WebTransformKeyframe.h"
+#include "WebTransformationMatrix.h"
+
+#if WEBKIT_IMPLEMENTATION
+#include <wtf/Forward.h>
+#endif
+
+namespace WebCore {
+class CCAnimationCurve;
+class CCKeyframedTransformAnimationCurve;
+}
+
+namespace WebKit {
+
+// A keyframed transform animation curve.
+class WebTransformAnimationCurve : public WebAnimationCurve {
+public:
+    WebTransformAnimationCurve() { initialize(); }
+    virtual ~WebTransformAnimationCurve() { destroy(); }
+
+    // Adds the keyframe with the default timing function (ease).
+    WEBKIT_EXPORT void add(const WebTransformKeyframe&);
+    WEBKIT_EXPORT void add(const WebTransformKeyframe&, TimingFunctionType);
+    // Adds the keyframe with a custom, bezier timing function. Note, it is
+    // assumed that x0 = y0 = 0, and x3 = y3 = 1.
+    WEBKIT_EXPORT void add(const WebTransformKeyframe&, double x1, double y1, double x2, double y2);
+
+    WEBKIT_EXPORT WebTransformationMatrix getValue(double time) const;
+
+#if WEBKIT_IMPLEMENTATION
+    virtual operator PassOwnPtr<WebCore::CCAnimationCurve>() const;
+#endif
+
+protected:
+    WEBKIT_EXPORT void initialize();
+    WEBKIT_EXPORT void destroy();
+
+    WebPrivateOwnPtr<WebCore::CCKeyframedTransformAnimationCurve> m_private;
+};
+
+} // namespace WebKit
+
+#endif // WebTransformAnimationCurve_h
diff --git a/Source/Platform/chromium/public/WebTransformKeyframe.h b/Source/Platform/chromium/public/WebTransformKeyframe.h
new file mode 100644 (file)
index 0000000..c99ef55
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * 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 WebTransformKeyframe_h
+#define WebTransformKeyframe_h
+
+#include "WebTransformOperations.h"
+
+namespace WebKit {
+
+struct WebTransformKeyframe {
+    WebTransformKeyframe(double time, const WebTransformOperations& value)
+        : time(time)
+        , value(value)
+    {
+    }
+
+    double time;
+    WebTransformOperations value;
+};
+
+} // namespace WebKit
+
+#endif // WebTransformKeyframe_h
index 722569f..8b9d110 100644 (file)
@@ -1,3 +1,47 @@
+2012-07-01  Ian Vollick  <vollick@chromium.org>
+
+        [chromium] Create a WebKit::Web* wrapper for the cc animation classes
+        https://bugs.webkit.org/show_bug.cgi?id=90303
+
+        Reviewed by James Robinson.
+
+        * WebKit.gyp:
+        * WebKit.gypi:
+        * src/WebAnimation.cpp: Added.
+        (WebKit):
+        (WebKit::WebAnimation::iterations):
+        (WebKit::WebAnimation::setIterations):
+        (WebKit::WebAnimation::startTime):
+        (WebKit::WebAnimation::setStartTime):
+        (WebKit::WebAnimation::timeOffset):
+        (WebKit::WebAnimation::setTimeOffset):
+        (WebKit::WebAnimation::alternatesDirection):
+        (WebKit::WebAnimation::setAlternatesDirection):
+        (WebKit::WebAnimation::toCCActiveAnimation):
+        (WebKit::WebAnimation::initialize):
+        (WebKit::WebAnimation::destroy):
+        * src/WebAnimationCurveCommon.cpp: Added.
+        (WebKit):
+        (WebKit::createTimingFunction):
+        * src/WebAnimationCurveCommon.h: Added.
+        (WebCore):
+        (WebKit):
+        * src/WebFloatAnimationCurve.cpp: Added.
+        (WebKit):
+        (WebKit::WebFloatAnimationCurve::add):
+        (WebKit::WebFloatAnimationCurve::toCCAnimationCurve):
+        (WebKit::WebFloatAnimationCurve::initialize):
+        (WebKit::WebFloatAnimationCurve::destroy):
+        * src/WebTransformAnimationCurve.cpp: Added.
+        (WebKit):
+        (WebKit::WebTransformAnimationCurve::add):
+        (WebKit::WebTransformAnimationCurve::toCCAnimationCurve):
+        (WebKit::WebTransformAnimationCurve::initialize):
+        (WebKit::WebTransformAnimationCurve::destroy):
+        * tests/WebAnimationTest.cpp: Added.
+        * tests/WebFloatAnimationCurveTest.cpp: Added.
+        * tests/WebTransformAnimationCurveTest.cpp: Added.
+
 2012-06-30  Ian Vollick  <vollick@chromium.org>
 
         [chromium] CanvasLayerTextureUpdater needs to convert opaque rects back to content space.
index 78e428b..2feecc7 100644 (file)
                 'src/WebTextCheckingCompletionImpl.cpp',
                 'src/WebTextCheckingResult.cpp',
                 'src/WebAccessibilityObject.cpp',
+                'src/WebAnimation.cpp',
                 'src/WebAnimationControllerImpl.cpp',
                 'src/WebAnimationControllerImpl.h',
+                'src/WebAnimationCurveCommon.cpp',
+                'src/WebAnimationCurveCommon.h',
                 'src/WebArrayBuffer.cpp',
                 'src/WebArrayBufferView.cpp',
                 'src/WebBindings.cpp',
                 'src/WebFileChooserCompletionImpl.h',
                 'src/WebFileSystemCallbacksImpl.cpp',
                 'src/WebFileSystemCallbacksImpl.h',
+                'src/WebFloatAnimationCurve.cpp',
                 'src/WebFontCache.cpp',
                 'src/WebFontDescription.cpp',
                 'src/WebFontImpl.cpp',
                 'src/WebSurroundingText.cpp',
                 'src/WebTextInputInfo.cpp',
                 'src/WebTextRun.cpp',
+                'src/WebTransformAnimationCurve.cpp',
                 'src/WebURLLoadTiming.cpp',
                 'src/WebScopedUserGesture.cpp',
                 'src/WebTextFieldDecoratorClient.cpp',
index 5e28903..7b3e68c 100644 (file)
             'tests/TreeSynchronizerTest.cpp',
             'tests/TreeTestHelpers.cpp',
             'tests/TreeTestHelpers.h',
+            'tests/WebAnimationTest.cpp',
             'tests/WebCompositorInputHandlerImplTest.cpp',
+            'tests/WebFloatAnimationCurveTest.cpp',
             'tests/WebFrameTest.cpp',
             'tests/WebLayerTest.cpp',
             'tests/WebLayerTreeViewTest.cpp',
             'tests/WebPageSerializerTest.cpp',
             'tests/WebSocketDeflaterTest.cpp',
             'tests/WebSocketExtensionDispatcherTest.cpp',
+            'tests/WebTransformAnimationCurveTest.cpp',
             'tests/WebTransformationMatrixTest.cpp',
             'tests/WebTransformOperationsTest.cpp',
             'tests/WebURLRequestTest.cpp',
diff --git a/Source/WebKit/chromium/src/WebAnimation.cpp b/Source/WebKit/chromium/src/WebAnimation.cpp
new file mode 100644 (file)
index 0000000..7dddfc2
--- /dev/null
@@ -0,0 +1,101 @@
+/*
+ * 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 <public/WebAnimation.h>
+
+#include "AnimationIdVendor.h"
+#include "cc/CCActiveAnimation.h"
+#include "cc/CCAnimationCurve.h"
+#include <public/WebAnimationCurve.h>
+#include <wtf/OwnPtr.h>
+#include <wtf/PassOwnPtr.h>
+
+using WebCore::AnimationIdVendor;
+using WebCore::CCActiveAnimation;
+
+namespace WebKit {
+
+int WebAnimation::iterations() const
+{
+    return m_private->iterations();
+}
+
+void WebAnimation::setIterations(int n)
+{
+    m_private->setIterations(n);
+}
+
+double WebAnimation::startTime() const
+{
+    return m_private->startTime();
+}
+
+void WebAnimation::setStartTime(double monotonicTime)
+{
+    m_private->setStartTime(monotonicTime);
+}
+
+double WebAnimation::timeOffset() const
+{
+    return m_private->timeOffset();
+}
+
+void WebAnimation::setTimeOffset(double monotonicTime)
+{
+    m_private->setTimeOffset(monotonicTime);
+}
+
+bool WebAnimation::alternatesDirection() const
+{
+    return m_private->alternatesDirection();
+}
+
+void WebAnimation::setAlternatesDirection(bool alternates)
+{
+    m_private->setAlternatesDirection(alternates);
+}
+
+WebAnimation::operator PassOwnPtr<WebCore::CCActiveAnimation>() const
+{
+    OwnPtr<WebCore::CCActiveAnimation> toReturn(m_private->cloneForImplThread());
+    toReturn->setNeedsSynchronizedStartTime(true);
+    return toReturn.release();
+}
+
+void WebAnimation::initialize(const WebAnimationCurve& curve, TargetProperty targetProperty)
+{
+    m_private.reset(CCActiveAnimation::create(curve,
+                                              AnimationIdVendor::getNextAnimationId(),
+                                              AnimationIdVendor::getNextGroupId(),
+                                              static_cast<WebCore::CCActiveAnimation::TargetProperty>(targetProperty)).leakPtr());
+}
+
+void WebAnimation::destroy()
+{
+    m_private.reset(0);
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit/chromium/src/WebAnimationCurveCommon.cpp b/Source/WebKit/chromium/src/WebAnimationCurveCommon.cpp
new file mode 100644 (file)
index 0000000..b5b98b0
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+ * 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 "WebAnimationCurveCommon.h"
+
+#include "cc/CCTimingFunction.h"
+
+#include <wtf/OwnPtr.h>
+#include <wtf/PassOwnPtr.h>
+
+namespace WebKit {
+
+PassOwnPtr<WebCore::CCTimingFunction> createTimingFunction(WebAnimationCurve::TimingFunctionType type)
+{
+    switch (type) {
+    case WebAnimationCurve::TimingFunctionTypeEase:
+        return WebCore::CCEaseTimingFunction::create();
+    case WebAnimationCurve::TimingFunctionTypeEaseIn:
+        return WebCore::CCEaseInTimingFunction::create();
+    case WebAnimationCurve::TimingFunctionTypeEaseOut:
+        return WebCore::CCEaseOutTimingFunction::create();
+    case WebAnimationCurve::TimingFunctionTypeEaseInOut:
+        return WebCore::CCEaseInOutTimingFunction::create();
+    case WebAnimationCurve::TimingFunctionTypeLinear:
+        return nullptr;
+    }
+    return nullptr;
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit/chromium/src/WebAnimationCurveCommon.h b/Source/WebKit/chromium/src/WebAnimationCurveCommon.h
new file mode 100644 (file)
index 0000000..562b6eb
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ * 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 WebAnimationCurveCommon_h
+#define WebAnimationCurveCommon_h
+
+#include <public/WebAnimationCurve.h>
+#include <wtf/Forward.h>
+
+namespace WebCore {
+class CCTimingFunction;
+}
+
+namespace WebKit {
+PassOwnPtr<WebCore::CCTimingFunction> createTimingFunction(WebAnimationCurve::TimingFunctionType);
+}
+
+#endif // WebAnimationCurveCommon_h
diff --git a/Source/WebKit/chromium/src/WebFloatAnimationCurve.cpp b/Source/WebKit/chromium/src/WebFloatAnimationCurve.cpp
new file mode 100644 (file)
index 0000000..d8cc9bb
--- /dev/null
@@ -0,0 +1,72 @@
+/*
+ * 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 <public/WebFloatAnimationCurve.h>
+
+#include "WebAnimationCurveCommon.h"
+#include "cc/CCKeyframedAnimationCurve.h"
+#include "cc/CCTimingFunction.h"
+#include <wtf/OwnPtr.h>
+#include <wtf/PassOwnPtr.h>
+
+namespace WebKit {
+
+void WebFloatAnimationCurve::add(const WebFloatKeyframe& keyframe)
+{
+    add(keyframe, TimingFunctionTypeEase);
+}
+
+void WebFloatAnimationCurve::add(const WebFloatKeyframe& keyframe, TimingFunctionType type)
+{
+    m_private->addKeyframe(WebCore::CCFloatKeyframe::create(keyframe.time, keyframe.value, createTimingFunction(type)));
+}
+
+void WebFloatAnimationCurve::add(const WebFloatKeyframe& keyframe, double x1, double y1, double x2, double y2)
+{
+    m_private->addKeyframe(WebCore::CCFloatKeyframe::create(keyframe.time, keyframe.value, WebCore::CCCubicBezierTimingFunction::create(x1, y1, x2, y2)));
+}
+
+float WebFloatAnimationCurve::getValue(double time) const
+{
+    return m_private->getValue(time);
+}
+
+WebFloatAnimationCurve::operator PassOwnPtr<WebCore::CCAnimationCurve>() const
+{
+    return m_private->clone();
+}
+
+void WebFloatAnimationCurve::initialize()
+{
+    m_private.reset(WebCore::CCKeyframedFloatAnimationCurve::create().leakPtr());
+}
+
+void WebFloatAnimationCurve::destroy()
+{
+    m_private.reset(0);
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit/chromium/src/WebTransformAnimationCurve.cpp b/Source/WebKit/chromium/src/WebTransformAnimationCurve.cpp
new file mode 100644 (file)
index 0000000..ca95fa3
--- /dev/null
@@ -0,0 +1,72 @@
+/*
+ * 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 <public/WebTransformAnimationCurve.h>
+
+#include "WebAnimationCurveCommon.h"
+#include "cc/CCKeyframedAnimationCurve.h"
+#include "cc/CCTimingFunction.h"
+#include <wtf/OwnPtr.h>
+#include <wtf/PassOwnPtr.h>
+
+namespace WebKit {
+
+void WebTransformAnimationCurve::add(const WebTransformKeyframe& keyframe)
+{
+    add(keyframe, TimingFunctionTypeEase);
+}
+
+void WebTransformAnimationCurve::add(const WebTransformKeyframe& keyframe, TimingFunctionType type)
+{
+    m_private->addKeyframe(WebCore::CCTransformKeyframe::create(keyframe.time, keyframe.value, createTimingFunction(type)));
+}
+
+void WebTransformAnimationCurve::add(const WebTransformKeyframe& keyframe, double x1, double y1, double x2, double y2)
+{
+    m_private->addKeyframe(WebCore::CCTransformKeyframe::create(keyframe.time, keyframe.value, WebCore::CCCubicBezierTimingFunction::create(x1, y1, x2, y2)));
+}
+
+WebTransformationMatrix WebTransformAnimationCurve::getValue(double time) const
+{
+    return m_private->getValue(time);
+}
+
+WebTransformAnimationCurve::operator PassOwnPtr<WebCore::CCAnimationCurve>() const
+{
+    return m_private->clone();
+}
+
+void WebTransformAnimationCurve::initialize()
+{
+    m_private.reset(WebCore::CCKeyframedTransformAnimationCurve::create().leakPtr());
+}
+
+void WebTransformAnimationCurve::destroy()
+{
+    m_private.reset(0);
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit/chromium/tests/WebAnimationTest.cpp b/Source/WebKit/chromium/tests/WebAnimationTest.cpp
new file mode 100644 (file)
index 0000000..ac0f2d5
--- /dev/null
@@ -0,0 +1,65 @@
+/*
+ * 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 <public/WebAnimation.h>
+
+#include <gtest/gtest.h>
+#include <public/WebFloatAnimationCurve.h>
+#include <wtf/OwnPtr.h>
+#include <wtf/PassOwnPtr.h>
+
+using namespace WebKit;
+
+namespace {
+
+TEST(WebAnimationTest, DefaultSettings)
+{
+    WebFloatAnimationCurve curve;
+    WebAnimation animation(curve, WebAnimation::WebAnimationOpacity);
+
+    // Ensure that the defaults are correct.
+    EXPECT_EQ(1, animation.iterations());
+    EXPECT_EQ(0, animation.startTime());
+    EXPECT_EQ(0, animation.timeOffset());
+    EXPECT_FALSE(animation.alternatesDirection());
+}
+
+TEST(WebAnimationTest, ModifiedSettings)
+{
+    WebFloatAnimationCurve curve;
+    WebAnimation animation(curve, WebAnimation::WebAnimationOpacity);
+    animation.setIterations(2);
+    animation.setStartTime(2);
+    animation.setTimeOffset(2);
+    animation.setAlternatesDirection(true);
+
+    EXPECT_EQ(2, animation.iterations());
+    EXPECT_EQ(2, animation.startTime());
+    EXPECT_EQ(2, animation.timeOffset());
+    EXPECT_TRUE(animation.alternatesDirection());
+}
+
+} // namespace
diff --git a/Source/WebKit/chromium/tests/WebFloatAnimationCurveTest.cpp b/Source/WebKit/chromium/tests/WebFloatAnimationCurveTest.cpp
new file mode 100644 (file)
index 0000000..bdfe4ec
--- /dev/null
@@ -0,0 +1,236 @@
+/*
+ * 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 <public/WebFloatAnimationCurve.h>
+
+#include "cc/CCTimingFunction.h"
+
+#include <gtest/gtest.h>
+#include <wtf/OwnPtr.h>
+#include <wtf/PassOwnPtr.h>
+
+using namespace WebKit;
+
+namespace {
+
+// Tests that a float animation with one keyframe works as expected.
+TEST(WebFloatAnimationCurveTest, OneFloatKeyframe)
+{
+    WebFloatAnimationCurve curve;
+    curve.add(WebFloatKeyframe(0, 2), WebAnimationCurve::TimingFunctionTypeLinear);
+    EXPECT_FLOAT_EQ(2, curve.getValue(-1));
+    EXPECT_FLOAT_EQ(2, curve.getValue(0));
+    EXPECT_FLOAT_EQ(2, curve.getValue(0.5));
+    EXPECT_FLOAT_EQ(2, curve.getValue(1));
+    EXPECT_FLOAT_EQ(2, curve.getValue(2));
+}
+
+// Tests that a float animation with two keyframes works as expected.
+TEST(WebFloatAnimationCurveTest, TwoFloatKeyframe)
+{
+    WebFloatAnimationCurve curve;
+    curve.add(WebFloatKeyframe(0, 2), WebAnimationCurve::TimingFunctionTypeLinear);
+    curve.add(WebFloatKeyframe(1, 4), WebAnimationCurve::TimingFunctionTypeLinear);
+    EXPECT_FLOAT_EQ(2, curve.getValue(-1));
+    EXPECT_FLOAT_EQ(2, curve.getValue(0));
+    EXPECT_FLOAT_EQ(3, curve.getValue(0.5));
+    EXPECT_FLOAT_EQ(4, curve.getValue(1));
+    EXPECT_FLOAT_EQ(4, curve.getValue(2));
+}
+
+// Tests that a float animation with three keyframes works as expected.
+TEST(WebFloatAnimationCurveTest, ThreeFloatKeyframe)
+{
+    WebFloatAnimationCurve curve;
+    curve.add(WebFloatKeyframe(0, 2), WebAnimationCurve::TimingFunctionTypeLinear);
+    curve.add(WebFloatKeyframe(1, 4), WebAnimationCurve::TimingFunctionTypeLinear);
+    curve.add(WebFloatKeyframe(2, 8), WebAnimationCurve::TimingFunctionTypeLinear);
+    EXPECT_FLOAT_EQ(2, curve.getValue(-1));
+    EXPECT_FLOAT_EQ(2, curve.getValue(0));
+    EXPECT_FLOAT_EQ(3, curve.getValue(0.5));
+    EXPECT_FLOAT_EQ(4, curve.getValue(1));
+    EXPECT_FLOAT_EQ(6, curve.getValue(1.5));
+    EXPECT_FLOAT_EQ(8, curve.getValue(2));
+    EXPECT_FLOAT_EQ(8, curve.getValue(3));
+}
+
+// Tests that a float animation with multiple keys at a given time works sanely.
+TEST(WebFloatAnimationCurveTest, RepeatedFloatKeyTimes)
+{
+    WebFloatAnimationCurve curve;
+    curve.add(WebFloatKeyframe(0, 4), WebAnimationCurve::TimingFunctionTypeLinear);
+    curve.add(WebFloatKeyframe(1, 4), WebAnimationCurve::TimingFunctionTypeLinear);
+    curve.add(WebFloatKeyframe(1, 6), WebAnimationCurve::TimingFunctionTypeLinear);
+    curve.add(WebFloatKeyframe(2, 6), WebAnimationCurve::TimingFunctionTypeLinear);
+
+    EXPECT_FLOAT_EQ(4, curve.getValue(-1));
+    EXPECT_FLOAT_EQ(4, curve.getValue(0));
+    EXPECT_FLOAT_EQ(4, curve.getValue(0.5));
+
+    // There is a discontinuity at 1. Any value between 4 and 6 is valid.
+    float value = curve.getValue(1);
+    EXPECT_TRUE(value >= 4 && value <= 6);
+
+    EXPECT_FLOAT_EQ(6, curve.getValue(1.5));
+    EXPECT_FLOAT_EQ(6, curve.getValue(2));
+    EXPECT_FLOAT_EQ(6, curve.getValue(3));
+}
+
+// Tests that the keyframes may be added out of order.
+TEST(WebFloatAnimationCurveTest, UnsortedKeyframes)
+{
+    WebFloatAnimationCurve curve;
+    curve.add(WebFloatKeyframe(2, 8), WebAnimationCurve::TimingFunctionTypeLinear);
+    curve.add(WebFloatKeyframe(0, 2), WebAnimationCurve::TimingFunctionTypeLinear);
+    curve.add(WebFloatKeyframe(1, 4), WebAnimationCurve::TimingFunctionTypeLinear);
+
+    EXPECT_FLOAT_EQ(2, curve.getValue(-1));
+    EXPECT_FLOAT_EQ(2, curve.getValue(0));
+    EXPECT_FLOAT_EQ(3, curve.getValue(0.5));
+    EXPECT_FLOAT_EQ(4, curve.getValue(1));
+    EXPECT_FLOAT_EQ(6, curve.getValue(1.5));
+    EXPECT_FLOAT_EQ(8, curve.getValue(2));
+    EXPECT_FLOAT_EQ(8, curve.getValue(3));
+}
+
+// Tests that a cubic bezier timing function works as expected.
+TEST(WebFloatAnimationCurveTest, CubicBezierTimingFunction)
+{
+    WebFloatAnimationCurve curve;
+    curve.add(WebFloatKeyframe(0, 0), 0.25, 0, 0.75, 1);
+    curve.add(WebFloatKeyframe(1, 1), WebAnimationCurve::TimingFunctionTypeLinear);
+
+    EXPECT_FLOAT_EQ(0, curve.getValue(0));
+    EXPECT_LT(0, curve.getValue(0.25));
+    EXPECT_GT(0.25, curve.getValue(0.25));
+    EXPECT_FLOAT_EQ(0.5, curve.getValue(0.5));
+    EXPECT_LT(0.75, curve.getValue(0.75));
+    EXPECT_GT(1, curve.getValue(0.75));
+    EXPECT_FLOAT_EQ(1, curve.getValue(1));
+}
+
+// Tests that an ease timing function works as expected.
+TEST(WebFloatAnimationCurveTest, EaseTimingFunction)
+{
+    WebFloatAnimationCurve curve;
+    curve.add(WebFloatKeyframe(0, 0), WebAnimationCurve::TimingFunctionTypeEase);
+    curve.add(WebFloatKeyframe(1, 1), WebAnimationCurve::TimingFunctionTypeLinear);
+
+    OwnPtr<WebCore::CCTimingFunction> timingFunction(WebCore::CCEaseTimingFunction::create());
+    for (int i = 0; i <= 4; ++i) {
+        const double time = i * 0.25;
+        EXPECT_FLOAT_EQ(timingFunction->getValue(time), curve.getValue(time));
+    }
+}
+
+// Tests using a linear timing function.
+TEST(WebFloatAnimationCurveTest, LinearTimingFunction)
+{
+    WebFloatAnimationCurve curve;
+    curve.add(WebFloatKeyframe(0, 0), WebAnimationCurve::TimingFunctionTypeLinear);
+    curve.add(WebFloatKeyframe(1, 1), WebAnimationCurve::TimingFunctionTypeLinear);
+
+    for (int i = 0; i <= 4; ++i) {
+        const double time = i * 0.25;
+        EXPECT_FLOAT_EQ(time, curve.getValue(time));
+    }
+}
+
+// Tests that an ease in timing function works as expected.
+TEST(WebFloatAnimationCurveTest, EaseInTimingFunction)
+{
+    WebFloatAnimationCurve curve;
+    curve.add(WebFloatKeyframe(0, 0), WebAnimationCurve::TimingFunctionTypeEaseIn);
+    curve.add(WebFloatKeyframe(1, 1), WebAnimationCurve::TimingFunctionTypeLinear);
+
+    OwnPtr<WebCore::CCTimingFunction> timingFunction(WebCore::CCEaseInTimingFunction::create());
+    for (int i = 0; i <= 4; ++i) {
+        const double time = i * 0.25;
+        EXPECT_FLOAT_EQ(timingFunction->getValue(time), curve.getValue(time));
+    }
+}
+
+// Tests that an ease in timing function works as expected.
+TEST(WebFloatAnimationCurveTest, EaseOutTimingFunction)
+{
+    WebFloatAnimationCurve curve;
+    curve.add(WebFloatKeyframe(0, 0), WebAnimationCurve::TimingFunctionTypeEaseOut);
+    curve.add(WebFloatKeyframe(1, 1), WebAnimationCurve::TimingFunctionTypeLinear);
+
+    OwnPtr<WebCore::CCTimingFunction> timingFunction(WebCore::CCEaseOutTimingFunction::create());
+    for (int i = 0; i <= 4; ++i) {
+        const double time = i * 0.25;
+        EXPECT_FLOAT_EQ(timingFunction->getValue(time), curve.getValue(time));
+    }
+}
+
+// Tests that an ease in timing function works as expected.
+TEST(WebFloatAnimationCurveTest, EaseInOutTimingFunction)
+{
+    WebFloatAnimationCurve curve;
+    curve.add(WebFloatKeyframe(0, 0), WebAnimationCurve::TimingFunctionTypeEaseInOut);
+    curve.add(WebFloatKeyframe(1, 1), WebAnimationCurve::TimingFunctionTypeLinear);
+
+    OwnPtr<WebCore::CCTimingFunction> timingFunction(WebCore::CCEaseInOutTimingFunction::create());
+    for (int i = 0; i <= 4; ++i) {
+        const double time = i * 0.25;
+        EXPECT_FLOAT_EQ(timingFunction->getValue(time), curve.getValue(time));
+    }
+}
+
+// Tests that an ease in timing function works as expected.
+TEST(WebFloatAnimationCurveTest, CustomBezierTimingFunction)
+{
+    WebFloatAnimationCurve curve;
+    double x1 = 0.3;
+    double y1 = 0.2;
+    double x2 = 0.8;
+    double y2 = 0.7;
+    curve.add(WebFloatKeyframe(0, 0), x1, y1, x2, y2);
+    curve.add(WebFloatKeyframe(1, 1), WebAnimationCurve::TimingFunctionTypeLinear);
+
+    OwnPtr<WebCore::CCTimingFunction> timingFunction(WebCore::CCCubicBezierTimingFunction::create(x1, y1, x2, y2));
+    for (int i = 0; i <= 4; ++i) {
+        const double time = i * 0.25;
+        EXPECT_FLOAT_EQ(timingFunction->getValue(time), curve.getValue(time));
+    }
+}
+
+// Tests that the default timing function is indeed ease.
+TEST(WebFloatAnimationCurveTest, DefaultTimingFunction)
+{
+    WebFloatAnimationCurve curve;
+    curve.add(WebFloatKeyframe(0, 0));
+    curve.add(WebFloatKeyframe(1, 1), WebAnimationCurve::TimingFunctionTypeLinear);
+
+    OwnPtr<WebCore::CCTimingFunction> timingFunction(WebCore::CCEaseTimingFunction::create());
+    for (int i = 0; i <= 4; ++i) {
+        const double time = i * 0.25;
+        EXPECT_FLOAT_EQ(timingFunction->getValue(time), curve.getValue(time));
+    }
+}
+
+} // namespace
diff --git a/Source/WebKit/chromium/tests/WebTransformAnimationCurveTest.cpp b/Source/WebKit/chromium/tests/WebTransformAnimationCurveTest.cpp
new file mode 100644 (file)
index 0000000..f18f87b
--- /dev/null
@@ -0,0 +1,297 @@
+/*
+ * 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 <public/WebTransformAnimationCurve.h>
+
+#include "cc/CCTimingFunction.h"
+
+#include <gtest/gtest.h>
+#include <public/WebTransformOperations.h>
+#include <public/WebTransformationMatrix.h>
+#include <wtf/OwnPtr.h>
+#include <wtf/PassOwnPtr.h>
+
+using namespace WebKit;
+
+namespace {
+
+// Tests that a transform animation with one keyframe works as expected.
+TEST(WebTransformAnimationCurveTest, OneTransformKeyframe)
+{
+    WebTransformAnimationCurve curve;
+    WebKit::WebTransformOperations operations;
+    operations.appendTranslate(2, 0, 0);
+    curve.add(WebTransformKeyframe(0, operations), WebAnimationCurve::TimingFunctionTypeLinear);
+
+    EXPECT_FLOAT_EQ(2, curve.getValue(-1).m41());
+    EXPECT_FLOAT_EQ(2, curve.getValue(0).m41());
+    EXPECT_FLOAT_EQ(2, curve.getValue(0.5).m41());
+    EXPECT_FLOAT_EQ(2, curve.getValue(1).m41());
+    EXPECT_FLOAT_EQ(2, curve.getValue(2).m41());
+}
+
+// Tests that a transform animation with two keyframes works as expected.
+TEST(WebTransformAnimationCurveTest, TwoTransformKeyframe)
+{
+    WebTransformAnimationCurve curve;
+    WebKit::WebTransformOperations operations1;
+    operations1.appendTranslate(2, 0, 0);
+    WebKit::WebTransformOperations operations2;
+    operations2.appendTranslate(4, 0, 0);
+    curve.add(WebTransformKeyframe(0, operations1), WebAnimationCurve::TimingFunctionTypeLinear);
+    curve.add(WebTransformKeyframe(1, operations2), WebAnimationCurve::TimingFunctionTypeLinear);
+    EXPECT_FLOAT_EQ(2, curve.getValue(-1).m41());
+    EXPECT_FLOAT_EQ(2, curve.getValue(0).m41());
+    EXPECT_FLOAT_EQ(3, curve.getValue(0.5).m41());
+    EXPECT_FLOAT_EQ(4, curve.getValue(1).m41());
+    EXPECT_FLOAT_EQ(4, curve.getValue(2).m41());
+}
+
+// Tests that a transform animation with three keyframes works as expected.
+TEST(WebTransformAnimationCurveTest, ThreeTransformKeyframe)
+{
+    WebTransformAnimationCurve curve;
+    WebKit::WebTransformOperations operations1;
+    operations1.appendTranslate(2, 0, 0);
+    WebKit::WebTransformOperations operations2;
+    operations2.appendTranslate(4, 0, 0);
+    WebKit::WebTransformOperations operations3;
+    operations3.appendTranslate(8, 0, 0);
+    curve.add(WebTransformKeyframe(0, operations1), WebAnimationCurve::TimingFunctionTypeLinear);
+    curve.add(WebTransformKeyframe(1, operations2), WebAnimationCurve::TimingFunctionTypeLinear);
+    curve.add(WebTransformKeyframe(2, operations3), WebAnimationCurve::TimingFunctionTypeLinear);
+    EXPECT_FLOAT_EQ(2, curve.getValue(-1).m41());
+    EXPECT_FLOAT_EQ(2, curve.getValue(0).m41());
+    EXPECT_FLOAT_EQ(3, curve.getValue(0.5).m41());
+    EXPECT_FLOAT_EQ(4, curve.getValue(1).m41());
+    EXPECT_FLOAT_EQ(6, curve.getValue(1.5).m41());
+    EXPECT_FLOAT_EQ(8, curve.getValue(2).m41());
+    EXPECT_FLOAT_EQ(8, curve.getValue(3).m41());
+}
+
+// Tests that a transform animation with multiple keys at a given time works sanely.
+TEST(WebTransformAnimationCurveTest, RepeatedTransformKeyTimes)
+{
+    // A step function.
+    WebTransformAnimationCurve curve;
+    WebKit::WebTransformOperations operations1;
+    operations1.appendTranslate(4, 0, 0);
+    WebKit::WebTransformOperations operations2;
+    operations2.appendTranslate(4, 0, 0);
+    WebKit::WebTransformOperations operations3;
+    operations3.appendTranslate(6, 0, 0);
+    WebKit::WebTransformOperations operations4;
+    operations4.appendTranslate(6, 0, 0);
+    curve.add(WebTransformKeyframe(0, operations1), WebAnimationCurve::TimingFunctionTypeLinear);
+    curve.add(WebTransformKeyframe(1, operations2), WebAnimationCurve::TimingFunctionTypeLinear);
+    curve.add(WebTransformKeyframe(1, operations3), WebAnimationCurve::TimingFunctionTypeLinear);
+    curve.add(WebTransformKeyframe(2, operations4), WebAnimationCurve::TimingFunctionTypeLinear);
+
+    EXPECT_FLOAT_EQ(4, curve.getValue(-1).m41());
+    EXPECT_FLOAT_EQ(4, curve.getValue(0).m41());
+    EXPECT_FLOAT_EQ(4, curve.getValue(0.5).m41());
+
+    // There is a discontinuity at 1. Any value between 4 and 6 is valid.
+    WebTransformationMatrix value = curve.getValue(1);
+    EXPECT_TRUE(value.m41() >= 4 && value.m41() <= 6);
+
+    EXPECT_FLOAT_EQ(6, curve.getValue(1.5).m41());
+    EXPECT_FLOAT_EQ(6, curve.getValue(2).m41());
+    EXPECT_FLOAT_EQ(6, curve.getValue(3).m41());
+}
+
+// Tests that the keyframes may be added out of order.
+TEST(WebTransformAnimationCurveTest, UnsortedKeyframes)
+{
+    WebTransformAnimationCurve curve;
+    WebKit::WebTransformOperations operations1;
+    operations1.appendTranslate(2, 0, 0);
+    WebKit::WebTransformOperations operations2;
+    operations2.appendTranslate(4, 0, 0);
+    WebKit::WebTransformOperations operations3;
+    operations3.appendTranslate(8, 0, 0);
+    curve.add(WebTransformKeyframe(2, operations3), WebAnimationCurve::TimingFunctionTypeLinear);
+    curve.add(WebTransformKeyframe(0, operations1), WebAnimationCurve::TimingFunctionTypeLinear);
+    curve.add(WebTransformKeyframe(1, operations2), WebAnimationCurve::TimingFunctionTypeLinear);
+
+    EXPECT_FLOAT_EQ(2, curve.getValue(-1).m41());
+    EXPECT_FLOAT_EQ(2, curve.getValue(0).m41());
+    EXPECT_FLOAT_EQ(3, curve.getValue(0.5).m41());
+    EXPECT_FLOAT_EQ(4, curve.getValue(1).m41());
+    EXPECT_FLOAT_EQ(6, curve.getValue(1.5).m41());
+    EXPECT_FLOAT_EQ(8, curve.getValue(2).m41());
+    EXPECT_FLOAT_EQ(8, curve.getValue(3).m41());
+}
+
+// Tests that a cubic bezier timing function works as expected.
+TEST(WebTransformAnimationCurveTest, CubicBezierTimingFunction)
+{
+    WebTransformAnimationCurve curve;
+    WebKit::WebTransformOperations operations1;
+    operations1.appendTranslate(0, 0, 0);
+    WebKit::WebTransformOperations operations2;
+    operations2.appendTranslate(1, 0, 0);
+    curve.add(WebTransformKeyframe(0, operations1), 0.25, 0, 0.75, 1);
+    curve.add(WebTransformKeyframe(1, operations2), WebAnimationCurve::TimingFunctionTypeLinear);
+    EXPECT_FLOAT_EQ(0, curve.getValue(0).m41());
+    EXPECT_LT(0, curve.getValue(0.25).m41());
+    EXPECT_GT(0.25, curve.getValue(0.25).m41());
+    EXPECT_FLOAT_EQ(0.5, curve.getValue(0.5).m41());
+    EXPECT_LT(0.75, curve.getValue(0.75).m41());
+    EXPECT_GT(1, curve.getValue(0.75).m41());
+    EXPECT_FLOAT_EQ(1, curve.getValue(1).m41());
+}
+
+// Tests that an ease timing function works as expected.
+TEST(WebTransformAnimationCurveTest, EaseTimingFunction)
+{
+    WebTransformAnimationCurve curve;
+    WebKit::WebTransformOperations operations1;
+    operations1.appendTranslate(0, 0, 0);
+    WebKit::WebTransformOperations operations2;
+    operations2.appendTranslate(1, 0, 0);
+    curve.add(WebTransformKeyframe(0, operations1), WebAnimationCurve::TimingFunctionTypeEase);
+    curve.add(WebTransformKeyframe(1, operations2), WebAnimationCurve::TimingFunctionTypeLinear);
+
+    OwnPtr<WebCore::CCTimingFunction> timingFunction(WebCore::CCEaseTimingFunction::create());
+    for (int i = 0; i <= 4; ++i) {
+        const double time = i * 0.25;
+        EXPECT_FLOAT_EQ(timingFunction->getValue(time), curve.getValue(time).m41());
+    }
+}
+
+// Tests using a linear timing function.
+TEST(WebTransformAnimationCurveTest, LinearTimingFunction)
+{
+    WebTransformAnimationCurve curve;
+    WebKit::WebTransformOperations operations1;
+    operations1.appendTranslate(0, 0, 0);
+    WebKit::WebTransformOperations operations2;
+    operations2.appendTranslate(1, 0, 0);
+    curve.add(WebTransformKeyframe(0, operations1), WebAnimationCurve::TimingFunctionTypeLinear);
+    curve.add(WebTransformKeyframe(1, operations2), WebAnimationCurve::TimingFunctionTypeLinear);
+
+    for (int i = 0; i <= 4; ++i) {
+        const double time = i * 0.25;
+        EXPECT_FLOAT_EQ(time, curve.getValue(time).m41());
+    }
+}
+
+// Tests that an ease in timing function works as expected.
+TEST(WebTransformAnimationCurveTest, EaseInTimingFunction)
+{
+    WebTransformAnimationCurve curve;
+    WebKit::WebTransformOperations operations1;
+    operations1.appendTranslate(0, 0, 0);
+    WebKit::WebTransformOperations operations2;
+    operations2.appendTranslate(1, 0, 0);
+    curve.add(WebTransformKeyframe(0, operations1), WebAnimationCurve::TimingFunctionTypeEaseIn);
+    curve.add(WebTransformKeyframe(1, operations2), WebAnimationCurve::TimingFunctionTypeLinear);
+
+    OwnPtr<WebCore::CCTimingFunction> timingFunction(WebCore::CCEaseInTimingFunction::create());
+    for (int i = 0; i <= 4; ++i) {
+        const double time = i * 0.25;
+        EXPECT_FLOAT_EQ(timingFunction->getValue(time), curve.getValue(time).m41());
+    }
+}
+
+// Tests that an ease in timing function works as expected.
+TEST(WebTransformAnimationCurveTest, EaseOutTimingFunction)
+{
+    WebTransformAnimationCurve curve;
+    WebKit::WebTransformOperations operations1;
+    operations1.appendTranslate(0, 0, 0);
+    WebKit::WebTransformOperations operations2;
+    operations2.appendTranslate(1, 0, 0);
+    curve.add(WebTransformKeyframe(0, operations1), WebAnimationCurve::TimingFunctionTypeEaseOut);
+    curve.add(WebTransformKeyframe(1, operations2), WebAnimationCurve::TimingFunctionTypeLinear);
+
+    OwnPtr<WebCore::CCTimingFunction> timingFunction(WebCore::CCEaseOutTimingFunction::create());
+    for (int i = 0; i <= 4; ++i) {
+        const double time = i * 0.25;
+        EXPECT_FLOAT_EQ(timingFunction->getValue(time), curve.getValue(time).m41());
+    }
+}
+
+// Tests that an ease in timing function works as expected.
+TEST(WebTransformAnimationCurveTest, EaseInOutTimingFunction)
+{
+    WebTransformAnimationCurve curve;
+    WebKit::WebTransformOperations operations1;
+    operations1.appendTranslate(0, 0, 0);
+    WebKit::WebTransformOperations operations2;
+    operations2.appendTranslate(1, 0, 0);
+    curve.add(WebTransformKeyframe(0, operations1), WebAnimationCurve::TimingFunctionTypeEaseInOut);
+    curve.add(WebTransformKeyframe(1, operations2), WebAnimationCurve::TimingFunctionTypeLinear);
+
+    OwnPtr<WebCore::CCTimingFunction> timingFunction(WebCore::CCEaseInOutTimingFunction::create());
+    for (int i = 0; i <= 4; ++i) {
+        const double time = i * 0.25;
+        EXPECT_FLOAT_EQ(timingFunction->getValue(time), curve.getValue(time).m41());
+    }
+}
+
+// Tests that an ease in timing function works as expected.
+TEST(WebTransformAnimationCurveTest, CustomBezierTimingFunction)
+{
+    WebTransformAnimationCurve curve;
+    double x1 = 0.3;
+    double y1 = 0.2;
+    double x2 = 0.8;
+    double y2 = 0.7;
+    WebKit::WebTransformOperations operations1;
+    operations1.appendTranslate(0, 0, 0);
+    WebKit::WebTransformOperations operations2;
+    operations2.appendTranslate(1, 0, 0);
+    curve.add(WebTransformKeyframe(0, operations1), x1, y1, x2, y2);
+    curve.add(WebTransformKeyframe(1, operations2), WebAnimationCurve::TimingFunctionTypeLinear);
+
+    OwnPtr<WebCore::CCTimingFunction> timingFunction(WebCore::CCCubicBezierTimingFunction::create(x1, y1, x2, y2));
+    for (int i = 0; i <= 4; ++i) {
+        const double time = i * 0.25;
+        EXPECT_FLOAT_EQ(timingFunction->getValue(time), curve.getValue(time).m41());
+    }
+}
+
+// Tests that the default timing function is indeed ease.
+TEST(WebTransformAnimationCurveTest, DefaultTimingFunction)
+{
+    WebTransformAnimationCurve curve;
+    WebKit::WebTransformOperations operations1;
+    operations1.appendTranslate(0, 0, 0);
+    WebKit::WebTransformOperations operations2;
+    operations2.appendTranslate(1, 0, 0);
+    curve.add(WebTransformKeyframe(0, operations1));
+    curve.add(WebTransformKeyframe(1, operations2), WebAnimationCurve::TimingFunctionTypeLinear);
+
+    OwnPtr<WebCore::CCTimingFunction> timingFunction(WebCore::CCEaseTimingFunction::create());
+    for (int i = 0; i <= 4; ++i) {
+        const double time = i * 0.25;
+        EXPECT_FLOAT_EQ(timingFunction->getValue(time), curve.getValue(time).m41());
+    }
+}
+
+} // namespace