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-20130808212844.patch (text/plain), 17.09 KB, created by
Eunmi Lee
on 2013-08-08 05:28:46 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Eunmi Lee
Created:
2013-08-08 05:28:46 PDT
Size:
17.09 KB
patch
obsolete
>Subversion Revision: 153774 >diff --git a/Source/WebKit2/ChangeLog b/Source/WebKit2/ChangeLog >index 00e7162582987377091bc48787ace5cd4f2db4f6..91e3c886148ff57b2c52c5c9dddcb881f041834c 100644 >--- a/Source/WebKit2/ChangeLog >+++ b/Source/WebKit2/ChangeLog >@@ -1,3 +1,40 @@ >+2013-08-08 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. >+ >+ Use Ecore_Animator in order to process movement once per each framing >+ time slot instead of processing all movement. >+ >+ * PlatformEfl.cmake: >+ * UIProcess/API/efl/EwkView.cpp: >+ (EwkView::scrollBy): >+ * UIProcess/API/efl/EwkView.h: >+ * UIProcess/API/efl/GestureRecognizer.cpp: >+ (WebKit::GestureHandler::GestureHandler): >+ (WebKit::GestureHandler::~GestureHandler): >+ (WebKit::GestureHandler::reset): >+ (WebKit::GestureHandler::panAnimatorCallback): >+ (WebKit::GestureHandler::handlePanStarted): >+ (WebKit::GestureHandler::handlePan): >+ (WebKit::GestureHandler::handlePanFinished): >+ (WebKit::GestureHandler::flickAnimatorCallback): >+ (WebKit::GestureHandler::handleFlick): >+ (WebKit::GestureRecognizer::noGesture): >+ (WebKit::GestureRecognizer::reset): >+ * UIProcess/CoordinatedGraphics/WebView.cpp: >+ (WebKit::WebView::setContentPosition): >+ * UIProcess/CoordinatedGraphics/WebView.h: >+ * UIProcess/efl/EasingCurves.cpp: Added. >+ (easeInOutQuad): >+ * UIProcess/efl/EasingCurves.h: Added. >+ > 2013-08-07 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 0571498e12e7456ad579038bfd7512da221752f4..4763382ca75cb74fb5c8f2c0526b204071d5d400 100644 >--- a/Source/WebKit2/PlatformEfl.cmake >+++ b/Source/WebKit2/PlatformEfl.cmake >@@ -106,6 +106,7 @@ list(APPEND WebKit2_SOURCES > UIProcess/efl/ContextHistoryClientEfl.cpp > UIProcess/efl/ContextMenuClientEfl.cpp > UIProcess/efl/DownloadManagerEfl.cpp >+ UIProcess/efl/EasingCurves.cpp > UIProcess/efl/EwkGestureEvent.cpp > UIProcess/efl/EwkTouchEvent.cpp > UIProcess/efl/EwkTouchPoint.cpp >diff --git a/Source/WebKit2/UIProcess/API/efl/EwkView.cpp b/Source/WebKit2/UIProcess/API/efl/EwkView.cpp >index 5bb8497a3fbd75b5e22c837e86556e39934fe539..75b93d8e88d09526cf25719251473d74cf4412f3 100644 >--- a/Source/WebKit2/UIProcess/API/efl/EwkView.cpp >+++ b/Source/WebKit2/UIProcess/API/efl/EwkView.cpp >@@ -1392,6 +1392,23 @@ void EwkView::didFindZoomableArea(const WKPoint& point, const WKRect& area) > notImplemented(); > } > >+bool EwkView::scrollBy(const IntSize& offset) >+{ >+ WKPoint oldPosition = WKViewGetContentPosition(wkView()); >+ FloatPoint newPosition = FloatPoint(oldPosition.x + offset.width(), oldPosition.y + offset.height()); >+ WKViewSetContentPosition(wkView(), WKPointMake(newPosition.x(), newPosition.y())); >+ >+ WKPoint position = WKViewGetContentPosition(wkView()); >+ float contentScale = WKViewGetContentScaleFactor(wkView()); >+ m_pageViewportController->didChangeContentsVisibility(FloatPoint(position.x / contentScale, position.y / contentScale), contentScale); >+ >+ // If the page position is not changed, notify that using returning value. >+ if (oldPosition == position) >+ return false; >+ >+ return true; >+} >+ > Evas_Smart_Class EwkView::parentSmartClass = EVAS_SMART_CLASS_INIT_NULL; > > // Free Ewk View functions. >diff --git a/Source/WebKit2/UIProcess/API/efl/EwkView.h b/Source/WebKit2/UIProcess/API/efl/EwkView.h >index c46b151a0dd91dce141f529e6e3905500104bea8..306e36f01cbc88f0bdad2c7f03e059411a0cb18c 100644 >--- a/Source/WebKit2/UIProcess/API/efl/EwkView.h >+++ b/Source/WebKit2/UIProcess/API/efl/EwkView.h >@@ -202,6 +202,7 @@ public: > void informURLChange(); > > PassRefPtr<cairo_surface_t> takeSnapshot(); >+ bool scrollBy(const WebCore::IntSize&); > > void didFindZoomableArea(const WKPoint&, const WKRect&); > >diff --git a/Source/WebKit2/UIProcess/API/efl/GestureRecognizer.cpp b/Source/WebKit2/UIProcess/API/efl/GestureRecognizer.cpp >index 81fa5a817cc88670e719137cce643d58696339ab..c1d0943d86b437c468e8fd7da046332d2794df49 100644 >--- a/Source/WebKit2/UIProcess/API/efl/GestureRecognizer.cpp >+++ b/Source/WebKit2/UIProcess/API/efl/GestureRecognizer.cpp >@@ -27,6 +27,7 @@ > #include "config.h" > #include "GestureRecognizer.h" > >+#include "EasingCurves.h" > #include "EwkView.h" > #include "NotImplemented.h" > #include "WKSharedAPICast.h" >@@ -44,13 +45,16 @@ public: > { > return adoptPtr(new GestureHandler(ewkView)); > } >+ ~GestureHandler(); > >+ void reset(); > void handleSingleTap(const WebCore::IntPoint&); > void handleDoubleTap(const WebCore::IntPoint&); > void handleTapAndHold(const WebCore::IntPoint&); > void handlePanStarted(const WebCore::IntPoint&); > void handlePan(const WebCore::IntPoint&); > void handlePanFinished(); >+ void handleFlick(const WebCore::IntSize&); > void handlePinchStarted(const Vector<WebCore::IntPoint>&); > void handlePinch(const Vector<WebCore::IntPoint>&); > void handlePinchFinished(); >@@ -58,12 +62,57 @@ public: > private: > explicit GestureHandler(EwkView*); > >+ static Eina_Bool panAnimatorCallback(void*); >+ static Eina_Bool flickAnimatorCallback(void*); >+ >+ static const int s_historyCapacity = 5; >+ > EwkView* m_ewkView; >+ WebCore::IntPoint m_lastPoint; >+ WebCore::IntPoint m_currentPoint; >+ bool m_isCurrentPointUpdated; >+ Ecore_Animator* m_panAnimator; >+ Ecore_Animator* m_flickAnimator; >+ WebCore::IntSize m_flickOffset; >+ unsigned m_flickDuration; >+ unsigned m_flickIndex; >+ >+ typedef struct { >+ WebCore::IntPoint point; >+ double timestamp; >+ } HistoryItem; >+ Vector<HistoryItem> m_history; >+ unsigned m_firstHistoryItemIndex; > }; > > GestureHandler::GestureHandler(EwkView* ewkView) > : m_ewkView(ewkView) >+ , m_isCurrentPointUpdated(false) >+ , m_panAnimator(0) >+ , m_flickAnimator(0) >+ , m_flickDuration(0) >+ , m_flickIndex(0) >+ , m_firstHistoryItemIndex(0) >+{ >+ m_history.reserveCapacity(s_historyCapacity); >+} >+ >+GestureHandler::~GestureHandler() > { >+ reset(); >+} >+ >+void GestureHandler::reset() >+{ >+ if (m_panAnimator) { >+ ecore_animator_del(m_panAnimator); >+ m_panAnimator = 0; >+ } >+ >+ if (m_flickAnimator) { >+ ecore_animator_del(m_flickAnimator); >+ m_flickAnimator = 0; >+ } > } > > void GestureHandler::handleSingleTap(const IntPoint& position) >@@ -85,19 +134,84 @@ void GestureHandler::handleTapAndHold(const IntPoint&) > notImplemented(); > } > >-void GestureHandler::handlePanStarted(const IntPoint&) >+Eina_Bool GestureHandler::panAnimatorCallback(void* data) > { >- notImplemented(); >+ GestureHandler* gestureHandler = static_cast<GestureHandler*>(data); >+ if (!gestureHandler->m_isCurrentPointUpdated || gestureHandler->m_lastPoint == gestureHandler->m_currentPoint) >+ return ECORE_CALLBACK_RENEW; >+ >+ gestureHandler->m_ewkView->scrollBy(gestureHandler->m_lastPoint - gestureHandler->m_currentPoint); >+ gestureHandler->m_lastPoint = gestureHandler->m_currentPoint; >+ gestureHandler->m_isCurrentPointUpdated = false; >+ >+ return ECORE_CALLBACK_RENEW; > } > >-void GestureHandler::handlePan(const IntPoint&) >+void GestureHandler::handlePanStarted(const IntPoint& point) > { >- notImplemented(); >+ ASSERT(!m_panAnimator); >+ m_panAnimator = ecore_animator_add(panAnimatorCallback, this); >+ m_lastPoint = m_currentPoint = point; >+ m_firstHistoryItemIndex = 0; >+ m_history.resize(0); >+} >+ >+void GestureHandler::handlePan(const IntPoint& point) >+{ >+ m_currentPoint = point; >+ m_isCurrentPointUpdated = true; >+ >+ // Save current point to use to calculate offset of flick. >+ HistoryItem item = {m_currentPoint, ecore_time_get()}; >+ if (m_history.size() < m_history.capacity()) >+ m_history.uncheckedAppend(item); >+ else { >+ m_history[m_firstHistoryItemIndex++] = item; >+ if (m_firstHistoryItemIndex == m_history.capacity()) >+ m_firstHistoryItemIndex = 0; >+ } > } > > void GestureHandler::handlePanFinished() > { >- notImplemented(); >+ ASSERT(m_panAnimator); >+ ecore_animator_del(m_panAnimator); >+ m_panAnimator = 0; >+ >+ if (!m_history.isEmpty()) { >+ // 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(); >+ IntSize offset = firstHistoryItem.point - m_currentPoint; >+ offset.scale(1 / frame); >+ handleFlick(offset); >+ } >+} >+ >+Eina_Bool GestureHandler::flickAnimatorCallback(void* data) >+{ >+ GestureHandler* gestureHandler = static_cast<GestureHandler*>(data); >+ float multiplier = easeInOutQuad(gestureHandler->m_flickIndex, 0, 1.0, gestureHandler->m_flickDuration); >+ float offsetWidth = gestureHandler->m_flickOffset.width() * multiplier; >+ float offsetHeight = gestureHandler->m_flickOffset.height() * multiplier; >+ offsetWidth = (offsetWidth > 0) ? ceilf(offsetWidth) : floorf(offsetWidth); >+ offsetHeight = (offsetHeight > 0) ? ceilf(offsetHeight) : floorf(offsetHeight); >+ IntSize offset(offsetWidth, offsetHeight); >+ gestureHandler->m_flickIndex--; >+ >+ if (offset.isZero() || !gestureHandler->m_ewkView->scrollBy(offset) || !gestureHandler->m_flickIndex) { >+ gestureHandler->m_flickAnimator = 0; >+ return false; >+ } >+ >+ return true; >+} >+ >+void GestureHandler::handleFlick(const IntSize& offset) >+{ >+ m_flickOffset = offset; >+ m_flickIndex = m_flickDuration = 1 / ecore_animator_frametime_get(); >+ m_flickAnimator = ecore_animator_add(flickAnimatorCallback, this); > } > > void GestureHandler::handlePinchStarted(const Vector<IntPoint>&) >@@ -201,6 +315,8 @@ void GestureRecognizer::noGesture(WKEventType type, WKArrayRef touchPoints) > { > switch (type) { > case kWKEventTypeTouchStart: >+ m_gestureHandler->reset(); >+ > m_recognizerFunction = &GestureRecognizer::singleTapGesture; > m_firstPressedPoint = toIntPoint(getPointAtIndex(touchPoints, 0)); > ASSERT(!m_tapAndHoldTimer); >@@ -345,6 +461,7 @@ void GestureRecognizer::pinchGesture(WKEventType type, WKArrayRef touchPoints) > void GestureRecognizer::reset() > { > stopTapTimers(); >+ m_gestureHandler->reset(); > > m_recognizerFunction = &GestureRecognizer::noGesture; > } >diff --git a/Source/WebKit2/UIProcess/CoordinatedGraphics/WebView.cpp b/Source/WebKit2/UIProcess/CoordinatedGraphics/WebView.cpp >index c6c7987542cb0819d69011c119be5dcc8354b36b..f1b6a656e5ed37127d6e6b473e6a74215cf8b8b8 100644 >--- a/Source/WebKit2/UIProcess/CoordinatedGraphics/WebView.cpp >+++ b/Source/WebKit2/UIProcess/CoordinatedGraphics/WebView.cpp >@@ -114,6 +114,16 @@ void WebView::setVisible(bool visible) > m_page->viewStateDidChange(WebPageProxy::ViewIsVisible); > } > >+void WebView::setContentPosition(const WebCore::FloatPoint& position) >+{ >+ FloatRect bounds; >+ bounds.setWidth(std::max(0.f, ceilf(m_contentsSize.width() * m_contentScaleFactor)) - size().width()); >+ bounds.setHeight(std::max(0.f, ceilf(m_contentsSize.height() * m_contentScaleFactor)) - size().height()); >+ >+ m_contentPosition.setX(clampTo(position.x(), bounds.x(), bounds.width())); >+ m_contentPosition.setY(clampTo(position.y(), bounds.y(), bounds.height())); >+} >+ > void WebView::setUserViewportTranslation(double tx, double ty) > { > m_userViewportTransform = TransformationMatrix().translate(tx, ty); >diff --git a/Source/WebKit2/UIProcess/CoordinatedGraphics/WebView.h b/Source/WebKit2/UIProcess/CoordinatedGraphics/WebView.h >index f5533a5899e1bd469ebcc748d475235983c1dcbc..a055b0bd3cb2d3eafacbfef80aaed7150906b902 100644 >--- a/Source/WebKit2/UIProcess/CoordinatedGraphics/WebView.h >+++ b/Source/WebKit2/UIProcess/CoordinatedGraphics/WebView.h >@@ -69,7 +69,7 @@ public: > void setContentScaleFactor(float scaleFactor) { m_contentScaleFactor = scaleFactor; } > float contentScaleFactor() const { return m_contentScaleFactor; } > >- void setContentPosition(const WebCore::FloatPoint& position) { m_contentPosition = position; } >+ void setContentPosition(const WebCore::FloatPoint&); > const WebCore::FloatPoint& contentPosition() const { return m_contentPosition; } > > void setUserViewportTranslation(double tx, double ty); >diff --git a/Source/WebKit2/UIProcess/efl/EasingCurves.cpp b/Source/WebKit2/UIProcess/efl/EasingCurves.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..f6ccf46f97615a60dbc33659917a85cd59ca8fd6 >--- /dev/null >+++ b/Source/WebKit2/UIProcess/efl/EasingCurves.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/efl/EasingCurves.h b/Source/WebKit2/UIProcess/efl/EasingCurves.h >new file mode 100644 >index 0000000000000000000000000000000000000000..b726c6fc407631d6aa8f3f5be0b8cc5fad52a400 >--- /dev/null >+++ b/Source/WebKit2/UIProcess/efl/EasingCurves.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 EasingCurves_h >+#define EasingCurves_h >+ >+float easeInOutQuad(float time, const float base, const float constant, const unsigned duration); >+ >+#endif // EasingCurves_h
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