WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
Patch
bug-107101-20130307164539.patch (text/plain), 15.62 KB, created by
Eunmi Lee
on 2013-03-06 23:49:36 PST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Eunmi Lee
Created:
2013-03-06 23:49:36 PST
Size:
15.62 KB
patch
obsolete
>Subversion Revision: 144260 >diff --git a/Source/WebKit2/ChangeLog b/Source/WebKit2/ChangeLog >index 58464b4a9dfb080eb9b518c8286eeb7654ecd96a..692f46d653de72b2f2af41e6b4ccd42772b5810e 100644 >--- a/Source/WebKit2/ChangeLog >+++ b/Source/WebKit2/ChangeLog >@@ -1,3 +1,42 @@ >+2013-03-06 Eunmi Lee <eunmi15.lee@samsung.com> >+ >+ [EFL][WK2] Implement pan and flick gesture. >+ https://bugs.webkit.org/show_bug.cgi?id=107101 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Implement pan gesture to scroll page by movement of point and stop >+ scrolling smoothly using ease-in-out-quad algorithm after touched >+ point is removed from the screen. >+ >+ * PlatformEfl.cmake: >+ * UIProcess/API/efl/EasingUtilities.cpp: Added. >+ (easeInOutQuad): >+ * UIProcess/API/efl/EasingUtilities.h: Added. >+ * UIProcess/API/efl/EwkView.cpp: >+ (EwkView::boundContentsPosition): >+ (EwkView::scrollBy): >+ * UIProcess/API/efl/EwkView.h: >+ (WebCore): >+ (EwkView): >+ * UIProcess/API/efl/PanGestureHandler.cpp: >+ (WebKit::PanGestureHandler::PanGestureHandler): >+ (WebKit::PanGestureHandler::start): >+ (WebKit::PanGestureHandler::update): >+ (WebKit::PanGestureHandler::end): >+ (WebKit::PanGestureHandler::cancel): >+ (WebKit): >+ (WebKit::PanGestureHandler::panAnimatorCallback): >+ (WebKit::PanGestureHandler::processPan): >+ (WebKit::PanGestureHandler::startFlick): >+ (WebKit::PanGestureHandler::flickAnimatorCallback): >+ (WebKit::PanGestureHandler::processFlick): >+ * UIProcess/API/efl/PanGestureHandler.h: >+ (PanGestureHandler): >+ * UIProcess/PageViewportController.h: >+ (WebKit::PageViewportController::contentsSize): >+ (PageViewportController): >+ > 2013-03-05 Eunmi Lee <eunmi15.lee@samsung.com> > > [EFL][WK2] Process single tap using WebEvent::GestureSingleTap. >diff --git a/Source/WebKit2/PlatformEfl.cmake b/Source/WebKit2/PlatformEfl.cmake >index 548b2641e6de5da9317e978e8b0517bd355d03dc..9491532b5b88f5abcf46945fe0646a4dd74e2e43 100644 >--- a/Source/WebKit2/PlatformEfl.cmake >+++ b/Source/WebKit2/PlatformEfl.cmake >@@ -49,6 +49,7 @@ list(APPEND WebKit2_SOURCES > UIProcess/API/C/soup/WKCookieManagerSoup.cpp > UIProcess/API/C/soup/WKSoupRequestManager.cpp > >+ UIProcess/API/efl/EasingUtilities.cpp > UIProcess/API/efl/EwkView.cpp > UIProcess/API/efl/EvasGLContext.cpp > UIProcess/API/efl/EvasGLSurface.cpp >diff --git a/Source/WebKit2/UIProcess/API/efl/EasingUtilities.cpp b/Source/WebKit2/UIProcess/API/efl/EasingUtilities.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..f6ccf46f97615a60dbc33659917a85cd59ca8fd6 >--- /dev/null >+++ b/Source/WebKit2/UIProcess/API/efl/EasingUtilities.cpp >@@ -0,0 +1,47 @@ >+/* >+ * Copyright (C) 2001 Robert Penner All rights reserved. >+ * Copyright (C) 2013 Samsung Electronics. 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. >+ * 3. Neither the name of the author nor the names of contributors may be >+ * used to endorse or promote products derived from this software >+ * without specific prior written permission. >+ * >+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT OWNER OR 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. >+ */ >+ >+/* >+ * Robert Penner's easing equations. http://www.robertpenner.com/easing/ >+ * static function easeInOutQuad (t:Number, b:Number, c:Number, d:Number):Number { >+ * if ((t/=d/2) < 1) return c/2*t*t + b; >+ * return -c/2 * ((--t)*(t-2) - 1) + b; >+ * } >+ */ >+float easeInOutQuad(float time, const float base, const float constant, const unsigned duration) >+{ >+ if (time > duration || time < 0) >+ return 0; >+ >+ if ((time /= (duration / 2)) < 1) >+ return (constant / 2) * time * time + base; >+ >+ time -= 1; >+ return -1 * (constant / 2) * (time * (time - 2) - 1) + base; >+} >diff --git a/Source/WebKit2/UIProcess/API/efl/EasingUtilities.h b/Source/WebKit2/UIProcess/API/efl/EasingUtilities.h >new file mode 100644 >index 0000000000000000000000000000000000000000..fb604916cd3afcf455c175bbdc180373c38584d5 >--- /dev/null >+++ b/Source/WebKit2/UIProcess/API/efl/EasingUtilities.h >@@ -0,0 +1,35 @@ >+/* >+ * Copyright (C) 2001 Robert Penner All rights reserved. >+ * Copyright (C) 2013 Samsung Electronics. 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. >+ * 3. Neither the name of the author nor the names of contributors may be >+ * used to endorse or promote products derived from this software >+ * without specific prior written permission. >+ * >+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT OWNER OR 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 EasingUtilities_h >+#define EasingUtilities_h >+ >+float easeInOutQuad(float time, const float base, const float constant, const unsigned duration); >+ >+#endif // EasingUtilities_h >diff --git a/Source/WebKit2/UIProcess/API/efl/EwkView.cpp b/Source/WebKit2/UIProcess/API/efl/EwkView.cpp >index c9d5952f97433660c075278cdfffb203472c934d..65348aa939408b25c0991a862a2648eb8efc0f5a 100644 >--- a/Source/WebKit2/UIProcess/API/efl/EwkView.cpp >+++ b/Source/WebKit2/UIProcess/API/efl/EwkView.cpp >@@ -949,6 +949,36 @@ unsigned long long EwkView::informDatabaseQuotaReached(const String& databaseNam > } > #endif > >+FloatPoint EwkView::boundContentsPosition(const FloatPoint& pagePosition) >+{ >+ FloatRect bounds; >+ FloatSize contentsSize = m_pageViewportController->contentsSize(); >+ bounds.setWidth(std::max(0.f, ceilf(contentsSize.width() * m_pageScaleFactor)) - m_size.width()); >+ bounds.setHeight(std::max(0.f, ceilf(contentsSize.height() * m_pageScaleFactor)) - m_size.height()); >+ >+ FloatPoint position; >+ position.setX(clampTo(pagePosition.x(), bounds.x(), bounds.width())); >+ position.setY(clampTo(pagePosition.y(), bounds.y(), bounds.height())); >+ >+ return position; >+} >+ >+bool EwkView::scrollBy(const IntSize& offset) >+{ >+ FloatPoint oldPagePosition = m_pagePosition; >+ FloatPoint newPagePosition = boundContentsPosition(m_pagePosition + offset); >+ setPagePosition(newPagePosition); >+ >+ IntPoint contentsPosition = ceiledIntPoint(webView()->transformFromScene().mapPoint(newPagePosition)); >+ m_pageViewportController->didChangeContentsVisibility(contentsPosition, m_pageScaleFactor); >+ >+ // If the page position is not changed, notify that using returning value. >+ if (oldPagePosition == m_pagePosition) >+ return false; >+ >+ return true; >+} >+ > /** > * @internal > * The url of view was changed by the frame loader. >diff --git a/Source/WebKit2/UIProcess/API/efl/EwkView.h b/Source/WebKit2/UIProcess/API/efl/EwkView.h >index c19cf23c73970c62a4e82c0f0daf649c61640633..ce74e7ec9e8eb06261328f2b37f9ba5c994eeacb 100644 >--- a/Source/WebKit2/UIProcess/API/efl/EwkView.h >+++ b/Source/WebKit2/UIProcess/API/efl/EwkView.h >@@ -85,6 +85,7 @@ class AffineTransform; > class Color; > class CoordinatedGraphicsScene; > class Cursor; >+class FloatPoint; > class IntSize; > } > >@@ -212,6 +213,8 @@ public: > > void setPagePosition(const WebCore::FloatPoint& position) { m_pagePosition = position; } > const WebCore::FloatPoint pagePosition() const { return m_pagePosition; } >+ WebCore::FloatPoint boundContentsPosition(const WebCore::FloatPoint&); >+ bool scrollBy(const WebCore::IntSize&); > > // FIXME: needs refactoring (split callback invoke) > void informURLChange(); >diff --git a/Source/WebKit2/UIProcess/API/efl/PanGestureHandler.cpp b/Source/WebKit2/UIProcess/API/efl/PanGestureHandler.cpp >index ec4e2e38379ff64406ca65be44e0cf4e0ef81034..26c138860bbe51570b0444b8658332653cef1ebe 100644 >--- a/Source/WebKit2/UIProcess/API/efl/PanGestureHandler.cpp >+++ b/Source/WebKit2/UIProcess/API/efl/PanGestureHandler.cpp >@@ -27,6 +27,7 @@ > #include "config.h" > #include "PanGestureHandler.h" > >+#include "EasingUtilities.h" > #include "EwkView.h" > #include <WebCore/IntPoint.h> > #include <WebCore/NotImplemented.h> >@@ -37,7 +38,13 @@ namespace WebKit { > > PanGestureHandler::PanGestureHandler(EwkView* ewkView) > : GestureHandler(ewkView) >+ , m_panAnimator(0) >+ , m_flickAnimator(0) >+ , m_firstHistoryItemIndex(0) >+ , m_flickDuration(0) >+ , m_flickIndex(0) > { >+ m_history.reserveCapacity(s_historyCapacity); > } > > void PanGestureHandler::start(const Vector<IntPoint>& points) >@@ -47,7 +54,10 @@ void PanGestureHandler::start(const Vector<IntPoint>& points) > return; > } > >- notImplemented(); >+ m_currentPoint = m_lastPoint = points[0]; >+ m_panAnimator = ecore_animator_add(panAnimatorCallback, this); >+ m_firstHistoryItemIndex = 0; >+ m_history.resize(0); > } > > void PanGestureHandler::update(const Vector<IntPoint>& points) >@@ -57,17 +67,93 @@ void PanGestureHandler::update(const Vector<IntPoint>& points) > return; > } > >- notImplemented(); >+ m_currentPoint = points[0]; >+ >+ // Save current point to use to calculate offset for flick. >+ HistoryItem item = {m_currentPoint, ecore_time_get()}; >+ if (m_history.size() < m_history.capacity()) >+ m_history.append(item); >+ else { >+ m_history[m_firstHistoryItemIndex++] = item; >+ if (m_firstHistoryItemIndex >= m_history.capacity()) >+ m_firstHistoryItemIndex %= m_history.capacity(); >+ } > } > > void PanGestureHandler::end() > { >- notImplemented(); >+ if (m_panAnimator) { >+ ecore_animator_del(m_panAnimator); >+ m_panAnimator = 0; >+ >+ startFlick(); >+ } > } > > void PanGestureHandler::cancel() > { >- notImplemented(); >+ if (m_panAnimator) { >+ ecore_animator_del(m_panAnimator); >+ m_panAnimator = 0; >+ } >+ >+ if (m_flickAnimator) { >+ ecore_animator_del(m_flickAnimator); >+ m_flickAnimator = 0; >+ } >+} >+ >+Eina_Bool PanGestureHandler::panAnimatorCallback(void* data) >+{ >+ static_cast<PanGestureHandler*>(data)->processPan(); >+ return ECORE_CALLBACK_RENEW; >+} >+ >+void PanGestureHandler::processPan() >+{ >+ if (m_lastPoint == m_currentPoint) >+ return; >+ >+ m_ewkView->scrollBy(m_lastPoint - m_currentPoint); >+ m_lastPoint = m_currentPoint; >+} >+ >+void PanGestureHandler::startFlick() >+{ >+ if (m_history.isEmpty()) >+ return; >+ >+ // Calculate offset to move during one frame. >+ const HistoryItem& firstHistoryItem = m_history[m_firstHistoryItemIndex]; >+ double frame = (ecore_time_get() - firstHistoryItem.timestamp) / ecore_animator_frametime_get(); >+ m_flickOffset = firstHistoryItem.point - m_currentPoint; >+ m_flickOffset.scale(1 / frame); >+ >+ m_flickIndex = m_flickDuration = 1 / ecore_animator_frametime_get(); >+ m_flickAnimator = ecore_animator_add(flickAnimatorCallback, this); >+} >+ >+Eina_Bool PanGestureHandler::flickAnimatorCallback(void* data) >+{ >+ return static_cast<PanGestureHandler*>(data)->processFlick(); >+} >+ >+bool PanGestureHandler::processFlick() >+{ >+ float multiplier = easeInOutQuad(m_flickIndex, 0, 1.0, m_flickDuration); >+ float offsetWidth = m_flickOffset.width() * multiplier; >+ float offsetHeight = m_flickOffset.height() * multiplier; >+ offsetWidth = (offsetWidth > 0) ? ceilf(offsetWidth) : floorf(offsetWidth); >+ offsetHeight = (offsetHeight > 0) ? ceilf(offsetHeight) : floorf(offsetHeight); >+ IntSize offset(offsetWidth, offsetHeight); >+ m_flickIndex--; >+ >+ if (offset.isZero() || !m_ewkView->scrollBy(offset) || !m_flickIndex) { >+ m_flickAnimator = 0; >+ return false; >+ } >+ >+ return true; > } > > } // namespace WebKit >diff --git a/Source/WebKit2/UIProcess/API/efl/PanGestureHandler.h b/Source/WebKit2/UIProcess/API/efl/PanGestureHandler.h >index 0267724b9b123aa173d4536921a846904dcd84b1..e6e188b776abe8c171955c55ff8666fe4928d045 100644 >--- a/Source/WebKit2/UIProcess/API/efl/PanGestureHandler.h >+++ b/Source/WebKit2/UIProcess/API/efl/PanGestureHandler.h >@@ -28,10 +28,8 @@ > #define PanGestureHandler_h > > #include "GestureHandler.h" >- >-namespace WebCore { >-class IntPoint; >-} >+#include <Ecore.h> >+#include <WebCore/IntPoint.h> > > namespace WebKit { > >@@ -43,6 +41,32 @@ public: > void update(const Vector<WebCore::IntPoint>&); > void end(); > void cancel(); >+ >+private: >+ static Eina_Bool panAnimatorCallback(void*); >+ static Eina_Bool flickAnimatorCallback(void*); >+ >+ static const int s_historyCapacity = 5; >+ >+ void processPan(); >+ void startFlick(); >+ bool processFlick(); >+ >+ Ecore_Animator* m_panAnimator; >+ Ecore_Animator* m_flickAnimator; >+ WebCore::IntPoint m_lastPoint; >+ WebCore::IntPoint m_currentPoint; >+ >+ typedef struct { >+ WebCore::IntPoint point; >+ double timestamp; >+ } HistoryItem; >+ Vector<HistoryItem> m_history; >+ unsigned m_firstHistoryItemIndex; >+ >+ WebCore::IntSize m_flickOffset; >+ unsigned m_flickDuration; >+ unsigned m_flickIndex; > }; > > } // namespace WebKit >diff --git a/Source/WebKit2/UIProcess/PageViewportController.h b/Source/WebKit2/UIProcess/PageViewportController.h >index 35d4b533d20702eb29a2c22d734290bd24bbd603..6bd8914ef560dc078c7b3ed655442150abfe6f80 100644 >--- a/Source/WebKit2/UIProcess/PageViewportController.h >+++ b/Source/WebKit2/UIProcess/PageViewportController.h >@@ -72,6 +72,8 @@ public: > > void setHadUserInteraction(bool didUserInteract) { m_hadUserInteraction = didUserInteract; } > >+ WebCore::FloatSize contentsSize() const { return m_contentsSize; } >+ > // Notifications from the viewport. > void didChangeViewportSize(const WebCore::FloatSize& newSize); > void didChangeContentsVisibility(const WebCore::FloatPoint&, float scale, const WebCore::FloatPoint& trajectoryVector = WebCore::FloatPoint::zero());
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 107101
:
183136
|
191934
|
193534
|
193780
|
206058
|
207620
|
207646
|
208330
|
208388
|
208389
|
209181
|
209251
|
209252
|
209325
|
209443
|
211409
|
211524
|
211751