Title: [125061] trunk/Source
Revision
125061
Author
jap...@chromium.org
Date
2012-08-08 11:52:00 -0700 (Wed, 08 Aug 2012)

Log Message

[chromium] Upstream android's FlingAnimator
https://bugs.webkit.org/show_bug.cgi?id=92900

Reviewed by James Robinson.

No new tests yet, will be added once this code is called.

Source/Platform:

* Platform.gypi:
* chromium/public/Platform.h:
(WebKit):
(WebKit::Platform::createFlingAnimator):
* chromium/public/WebFlingAnimator.h: Added.
(WebKit):
(WebFlingAnimator):
(WebKit::WebFlingAnimator::~WebFlingAnimator):

Source/WebCore:

* WebCore.gypi:
* platform/chromium/support/PlatformGestureCurveFactory.cpp: Added.
(WebKit):
(WebKit::PlatformGestureCurveFactory::get):
(WebKit::PlatformGestureCurveFactory::createCurve):
(WebKit::PlatformGestureCurveFactory::setWebFlingAnimatorForTest):
* platform/chromium/support/PlatformGestureCurveFactory.h: Added.
(WebKit):
(PlatformGestureCurveFactory):
* platform/chromium/support/WebFlingAnimatorToGestureCurveAdapter.h: Added.
(WebKit):
(WebFlingAnimatorToGestureCurveAdapter):
(WebKit::WebFlingAnimatorToGestureCurveAdapter::create):
(WebKit::WebFlingAnimatorToGestureCurveAdapter::WebFlingAnimatorToGestureCurveAdapter):

Modified Paths

Added Paths

Diff

Modified: trunk/Source/Platform/ChangeLog (125060 => 125061)


--- trunk/Source/Platform/ChangeLog	2012-08-08 18:50:55 UTC (rev 125060)
+++ trunk/Source/Platform/ChangeLog	2012-08-08 18:52:00 UTC (rev 125061)
@@ -1,3 +1,21 @@
+2012-08-08  Nate Chapin  <jap...@chromium.org>
+
+        [chromium] Upstream android's FlingAnimator
+        https://bugs.webkit.org/show_bug.cgi?id=92900
+
+        Reviewed by James Robinson.
+
+        No new tests yet, will be added once this code is called.
+
+        * Platform.gypi:
+        * chromium/public/Platform.h:
+        (WebKit):
+        (WebKit::Platform::createFlingAnimator):
+        * chromium/public/WebFlingAnimator.h: Added.
+        (WebKit):
+        (WebFlingAnimator):
+        (WebKit::WebFlingAnimator::~WebFlingAnimator):
+
 2012-08-07  James Robinson  <jam...@chromium.org>
 
         [chromium] Switch PlatformLayer typedef to Platform API type for PLATFORM(CHROMIUM)

Modified: trunk/Source/Platform/Platform.gypi (125060 => 125061)


--- trunk/Source/Platform/Platform.gypi	2012-08-08 18:50:55 UTC (rev 125060)
+++ trunk/Source/Platform/Platform.gypi	2012-08-08 18:52:00 UTC (rev 125061)
@@ -57,6 +57,7 @@
             'chromium/public/WebFileUtilities.h',
             'chromium/public/WebFilterOperation.h',
             'chromium/public/WebFilterOperations.h',
+            'chromium/public/WebFlingAnimator.h',
             'chromium/public/WebFloatAnimationCurve.h',
             'chromium/public/WebFloatKeyframe.h',
             'chromium/public/WebFloatPoint.h',

Modified: trunk/Source/Platform/chromium/public/Platform.h (125060 => 125061)


--- trunk/Source/Platform/chromium/public/Platform.h	2012-08-08 18:50:55 UTC (rev 125060)
+++ trunk/Source/Platform/chromium/public/Platform.h	2012-08-08 18:52:00 UTC (rev 125061)
@@ -52,6 +52,7 @@
 class WebCookieJar;
 class WebFileSystem;
 class WebFileUtilities;
+class WebFlingAnimator;
 class WebMediaStreamCenter;
 class WebMediaStreamCenterClient;
 class WebMessagePortChannel;
@@ -410,6 +411,7 @@
     // This value must be checked again after a context loss event as the platform's capabilities may have changed.
     virtual bool canAccelerate2dCanvas() { return false; }
 
+    virtual WebFlingAnimator* createFlingAnimator() { return 0; }
 
     // WebRTC ----------------------------------------------------------
 

Added: trunk/Source/Platform/chromium/public/WebFlingAnimator.h (0 => 125061)


--- trunk/Source/Platform/chromium/public/WebFlingAnimator.h	                        (rev 0)
+++ trunk/Source/Platform/chromium/public/WebFlingAnimator.h	2012-08-08 18:52:00 UTC (rev 125061)
@@ -0,0 +1,48 @@
+/*
+ * 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 WebFlingAnimator_h
+#define WebFlingAnimator_h
+
+#include "WebFloatPoint.h"
+#include "WebPoint.h"
+#include "WebRect.h"
+
+namespace WebKit {
+
+class WebFlingAnimator {
+public:
+    virtual ~WebFlingAnimator() { }
+
+    virtual void startFling(const WebFloatPoint& velocity, const WebRect& range) = 0;
+    // Returns true if the animation is not yet finished.
+    virtual bool updatePosition() = 0;
+    virtual WebPoint getCurrentPosition() = 0;
+    virtual void cancelFling() = 0;
+};
+
+} // namespace WebKit
+
+#endif // WebFlingAnimator_h

Modified: trunk/Source/WebCore/ChangeLog (125060 => 125061)


--- trunk/Source/WebCore/ChangeLog	2012-08-08 18:50:55 UTC (rev 125060)
+++ trunk/Source/WebCore/ChangeLog	2012-08-08 18:52:00 UTC (rev 125061)
@@ -1,3 +1,27 @@
+2012-08-08  Nate Chapin  <jap...@chromium.org>
+
+        [chromium] Upstream android's FlingAnimator
+        https://bugs.webkit.org/show_bug.cgi?id=92900
+
+        Reviewed by James Robinson.
+
+        No new tests yet, will be added once this code is called.
+
+        * WebCore.gypi:
+        * platform/chromium/support/PlatformGestureCurveFactory.cpp: Added.
+        (WebKit):
+        (WebKit::PlatformGestureCurveFactory::get):
+        (WebKit::PlatformGestureCurveFactory::createCurve):
+        (WebKit::PlatformGestureCurveFactory::setWebFlingAnimatorForTest):
+        * platform/chromium/support/PlatformGestureCurveFactory.h: Added.
+        (WebKit):
+        (PlatformGestureCurveFactory):
+        * platform/chromium/support/WebFlingAnimatorToGestureCurveAdapter.h: Added.
+        (WebKit):
+        (WebFlingAnimatorToGestureCurveAdapter):
+        (WebKit::WebFlingAnimatorToGestureCurveAdapter::create):
+        (WebKit::WebFlingAnimatorToGestureCurveAdapter::WebFlingAnimatorToGestureCurveAdapter):
+
 2012-08-08  Anna Cavender  <ann...@chromium.org>
 
         Update HTMLMediaElement to the new OO MediaSource API.

Modified: trunk/Source/WebCore/WebCore.gypi (125060 => 125061)


--- trunk/Source/WebCore/WebCore.gypi	2012-08-08 18:50:55 UTC (rev 125060)
+++ trunk/Source/WebCore/WebCore.gypi	2012-08-08 18:52:00 UTC (rev 125061)
@@ -8211,10 +8211,13 @@
             'platform/chromium/support/GraphicsContext3DChromium.cpp',
             'platform/chromium/support/GraphicsContext3DPrivate.cpp',
             'platform/chromium/support/GraphicsContext3DPrivate.h',
+            'platform/chromium/support/PlatformGestureCurveFactory.cpp',
+            'platform/chromium/support/PlatformGestureCurveFactory.h',
             'platform/chromium/support/WebAudioBus.cpp',
             'platform/chromium/support/WebCompositorImpl.cpp',
             'platform/chromium/support/WebCompositorImpl.h',
             'platform/chromium/support/WebData.cpp',
+            'platform/chromium/support/WebFlingAnimatorToGestureCurveAdapter.h',
             'platform/chromium/support/WebHTTPBody.cpp',
             'platform/chromium/support/WebHTTPLoadInfo.cpp',
             'platform/chromium/support/WebICECandidateDescriptor.cpp',

Added: trunk/Source/WebCore/platform/chromium/support/PlatformGestureCurveFactory.cpp (0 => 125061)


--- trunk/Source/WebCore/platform/chromium/support/PlatformGestureCurveFactory.cpp	                        (rev 0)
+++ trunk/Source/WebCore/platform/chromium/support/PlatformGestureCurveFactory.cpp	2012-08-08 18:52:00 UTC (rev 125061)
@@ -0,0 +1,58 @@
+/*
+ * 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 "PlatformGestureCurveFactory.h"
+
+#include "FloatPoint.h"
+#include "IntRect.h"
+#include "TouchpadFlingPlatformGestureCurve.h"
+#include "WebFlingAnimatorToGestureCurveAdapter.h"
+
+namespace WebKit {
+
+PlatformGestureCurveFactory* PlatformGestureCurveFactory::get()
+{
+    DEFINE_STATIC_LOCAL(PlatformGestureCurveFactory, factory, ());
+    return &factory;
+}
+
+PassOwnPtr<WebCore::PlatformGestureCurve> PlatformGestureCurveFactory::createCurve(const WebCore::FloatPoint& point, const WebCore::IntRect& range)
+{
+    OwnPtr<WebFlingAnimator> flingAnimator = m_mockFlingAnimator.release();
+    if (!flingAnimator)
+        flingAnimator = adoptPtr(Platform::current()->createFlingAnimator());
+    if (!flingAnimator)
+        return WebCore::TouchpadFlingPlatformGestureCurve::create(point);
+
+    return WebFlingAnimatorToGestureCurveAdapter::create(point, range, flingAnimator.release());
+}
+
+void PlatformGestureCurveFactory::setWebFlingAnimatorForTest(PassOwnPtr<WebFlingAnimator> mockFlingAnimator)
+{
+    m_mockFlingAnimator = mockFlingAnimator;
+}
+
+} // namespace WebKit

Added: trunk/Source/WebCore/platform/chromium/support/PlatformGestureCurveFactory.h (0 => 125061)


--- trunk/Source/WebCore/platform/chromium/support/PlatformGestureCurveFactory.h	                        (rev 0)
+++ trunk/Source/WebCore/platform/chromium/support/PlatformGestureCurveFactory.h	2012-08-08 18:52:00 UTC (rev 125061)
@@ -0,0 +1,50 @@
+/*
+ * 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 PlatformGestureCurveFactory_h
+#define PlatformGestureCurveFactory_h
+
+#include "PlatformGestureCurve.h"
+#include <public/WebFlingAnimator.h>
+#include <wtf/PassOwnPtr.h>
+
+namespace WebKit {
+
+class PlatformGestureCurveFactory {
+public:
+    static PlatformGestureCurveFactory* get();
+
+    PassOwnPtr<WebCore::PlatformGestureCurve> createCurve(const WebCore::FloatPoint&, const WebCore::IntRect& range);
+    void setWebFlingAnimatorForTest(PassOwnPtr<WebFlingAnimator>);
+
+private:
+    ~PlatformGestureCurveFactory();
+
+    OwnPtr<WebFlingAnimator> m_mockFlingAnimator;
+};
+
+} // namespace WebKit
+
+#endif // PlatformGestureCurveFactory_h

Added: trunk/Source/WebCore/platform/chromium/support/WebFlingAnimatorToGestureCurveAdapter.h (0 => 125061)


--- trunk/Source/WebCore/platform/chromium/support/WebFlingAnimatorToGestureCurveAdapter.h	                        (rev 0)
+++ trunk/Source/WebCore/platform/chromium/support/WebFlingAnimatorToGestureCurveAdapter.h	2012-08-08 18:52:00 UTC (rev 125061)
@@ -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 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 WebFlingAnimatorToGestureCurveAdapter_h
+#define WebFlingAnimatorToGestureCurveAdapter_h
+
+#include "FloatPoint.h"
+#include "IntPoint.h"
+#include "IntRect.h"
+#include "PlatformGestureCurve.h"
+#include "PlatformGestureCurveTarget.h"
+#include <public/Platform.h>
+#include <public/WebFlingAnimator.h>
+
+namespace WebKit {
+
+class WebFlingAnimatorToGestureCurveAdapter : public WebCore::PlatformGestureCurve {
+public:
+    static PassOwnPtr<PlatformGestureCurve> create(const WebCore::FloatPoint& velocity, const WebCore::IntRect& range, PassOwnPtr<WebFlingAnimator> animator)
+    {
+        return adoptPtr(new WebFlingAnimatorToGestureCurveAdapter(velocity, range, animator));
+    }
+
+    // WebCore::PlatformGestureCurve implementation:
+    virtual const char* debugName() const OVERRIDE { return "WebFlingAnimatorToGestureCurveAdapter"; }
+    virtual bool apply(double time, WebCore::PlatformGestureCurveTarget* target) OVERRIDE
+    {
+        if (!m_animator->updatePosition())
+            return false;
+
+        WebCore::IntPoint currentPosition = m_animator->getCurrentPosition();
+        target->scrollBy(WebCore::IntPoint(currentPosition - m_lastPosition));
+        m_lastPosition = currentPosition;
+        return true;
+    }
+
+private:
+    WebFlingAnimatorToGestureCurveAdapter(const WebCore::FloatPoint& velocity, const WebCore::IntRect& range, PassOwnPtr<WebFlingAnimator> animator)
+        : m_animator(animator)
+    {
+        m_animator->startFling(velocity, range);
+    }
+
+    OwnPtr<WebFlingAnimator> m_animator;
+    WebCore::IntPoint m_lastPosition;
+};
+
+}
+
+#endif // WebFlingAnimatorToGestureCurveAdapter_h
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to