Title: [106987] trunk/Source/WebKit/chromium
- Revision
- 106987
- Author
- commit-qu...@webkit.org
- Date
- 2012-02-07 13:52:21 -0800 (Tue, 07 Feb 2012)
Log Message
Process Scroll-gesture events from the compositor.
https://bugs.webkit.org/show_bug.cgi?id=77477
Patch by Sadrul Habib Chowdhury <sad...@chromium.org> on 2012-02-07
Reviewed by James Robinson.
* src/WebCompositorInputHandlerImpl.cpp:
(WebKit::WebCompositorInputHandlerImpl::WebCompositorInputHandlerImpl):
(WebKit::WebCompositorInputHandlerImpl::handleInputEvent):
* src/WebCompositorInputHandlerImpl.h:
(WebCompositorInputHandlerImpl):
Modified Paths
Diff
Modified: trunk/Source/WebKit/chromium/ChangeLog (106986 => 106987)
--- trunk/Source/WebKit/chromium/ChangeLog 2012-02-07 21:50:57 UTC (rev 106986)
+++ trunk/Source/WebKit/chromium/ChangeLog 2012-02-07 21:52:21 UTC (rev 106987)
@@ -1,3 +1,16 @@
+2012-02-07 Sadrul Habib Chowdhury <sad...@chromium.org>
+
+ Process Scroll-gesture events from the compositor.
+ https://bugs.webkit.org/show_bug.cgi?id=77477
+
+ Reviewed by James Robinson.
+
+ * src/WebCompositorInputHandlerImpl.cpp:
+ (WebKit::WebCompositorInputHandlerImpl::WebCompositorInputHandlerImpl):
+ (WebKit::WebCompositorInputHandlerImpl::handleInputEvent):
+ * src/WebCompositorInputHandlerImpl.h:
+ (WebCompositorInputHandlerImpl):
+
2012-02-07 Anders Carlsson <ander...@apple.com>
ScrollableAreaSet should be moved from Page to FrameView
Modified: trunk/Source/WebKit/chromium/src/WebCompositorInputHandlerImpl.cpp (106986 => 106987)
--- trunk/Source/WebKit/chromium/src/WebCompositorInputHandlerImpl.cpp 2012-02-07 21:50:57 UTC (rev 106986)
+++ trunk/Source/WebKit/chromium/src/WebCompositorInputHandlerImpl.cpp 2012-02-07 21:52:21 UTC (rev 106987)
@@ -81,6 +81,10 @@
: m_client(0)
, m_identifier(s_nextAvailableIdentifier++)
, m_inputHandlerClient(inputHandlerClient)
+#ifndef NDEBUG
+ , m_expectScrollUpdateEnd(false)
+#endif
+ , m_scrollStarted(false)
{
ASSERT(CCProxy::isImplThread());
@@ -131,6 +135,44 @@
case CCInputHandlerClient::ScrollFailed:
break;
}
+ } else if (event.type == WebInputEvent::GestureScrollBegin) {
+ ASSERT(!m_scrollStarted);
+ ASSERT(!m_expectScrollUpdateEnd);
+#ifndef NDEBUG
+ m_expectScrollUpdateEnd = true;
+#endif
+ const WebGestureEvent& gestureEvent = *static_cast<const WebGestureEvent*>(&event);
+ CCInputHandlerClient::ScrollStatus scrollStatus = m_inputHandlerClient->scrollBegin(IntPoint(gestureEvent.x, gestureEvent.y));
+ switch (scrollStatus) {
+ case CCInputHandlerClient::ScrollStarted:
+ m_scrollStarted = true;
+ m_client->didHandleInputEvent();
+ return;
+ case CCInputHandlerClient::ScrollIgnored:
+ m_client->didNotHandleInputEvent(false /* sendToWidget */);
+ return;
+ case CCInputHandlerClient::ScrollFailed:
+ break;
+ }
+ } else if (event.type == WebInputEvent::GestureScrollUpdate) {
+ ASSERT(m_expectScrollUpdateEnd);
+ if (m_scrollStarted) {
+ const WebGestureEvent& gestureEvent = *static_cast<const WebGestureEvent*>(&event);
+ m_inputHandlerClient->scrollBy(IntSize(-gestureEvent.deltaX, -gestureEvent.deltaY));
+ m_client->didHandleInputEvent();
+ return;
+ }
+ } else if (event.type == WebInputEvent::GestureScrollEnd) {
+ ASSERT(m_expectScrollUpdateEnd);
+#ifndef NDEBUG
+ m_expectScrollUpdateEnd = false;
+#endif
+ if (m_scrollStarted) {
+ m_inputHandlerClient->scrollEnd();
+ m_client->didHandleInputEvent();
+ m_scrollStarted = false;
+ return;
+ }
}
m_client->didNotHandleInputEvent(true /* sendToWidget */);
}
Modified: trunk/Source/WebKit/chromium/src/WebCompositorInputHandlerImpl.h (106986 => 106987)
--- trunk/Source/WebKit/chromium/src/WebCompositorInputHandlerImpl.h 2012-02-07 21:50:57 UTC (rev 106986)
+++ trunk/Source/WebKit/chromium/src/WebCompositorInputHandlerImpl.h 2012-02-07 21:52:21 UTC (rev 106987)
@@ -70,6 +70,11 @@
int m_identifier;
WebCore::CCInputHandlerClient* m_inputHandlerClient;
+#ifndef NDEBUG
+ bool m_expectScrollUpdateEnd;
+#endif
+ bool m_scrollStarted;
+
static int s_nextAvailableIdentifier;
static HashSet<WebCompositorInputHandlerImpl*>* s_compositors;
};
Modified: trunk/Source/WebKit/chromium/tests/WebCompositorInputHandlerImplTest.cpp (106986 => 106987)
--- trunk/Source/WebKit/chromium/tests/WebCompositorInputHandlerImplTest.cpp 2012-02-07 21:50:57 UTC (rev 106986)
+++ trunk/Source/WebKit/chromium/tests/WebCompositorInputHandlerImplTest.cpp 2012-02-07 21:52:21 UTC (rev 106987)
@@ -28,6 +28,9 @@
#include "WebCompositorInputHandlerImpl.h"
#include "WebCompositor.h"
+#include "WebCompositorInputHandlerClient.h"
+#include "WebInputEvent.h"
+#include "cc/CCInputHandler.h"
#include "cc/CCSingleThreadProxy.h"
#include <gtest/gtest.h>
@@ -38,6 +41,73 @@
namespace {
+class MockInputHandlerClient : public WebCore::CCInputHandlerClient {
+ WTF_MAKE_NONCOPYABLE(MockInputHandlerClient);
+public:
+ MockInputHandlerClient()
+ : m_scrollStatus(ScrollStarted)
+ {
+ }
+ virtual ~MockInputHandlerClient() { }
+
+ void setScrollStatus(ScrollStatus status) { m_scrollStatus = status; }
+
+private:
+ virtual void setNeedsRedraw() OVERRIDE { }
+ virtual ScrollStatus scrollBegin(const WebCore::IntPoint&) OVERRIDE
+ {
+ return m_scrollStatus;
+ }
+ virtual void scrollBy(const WebCore::IntSize&) OVERRIDE { }
+ virtual void scrollEnd() OVERRIDE { }
+
+ virtual bool haveWheelEventHandlers() OVERRIDE { return false; }
+ virtual void pinchGestureBegin() OVERRIDE { }
+ virtual void pinchGestureUpdate(float magnifyDelta, const WebCore::IntPoint& anchor) OVERRIDE { }
+ virtual void pinchGestureEnd() OVERRIDE { }
+ virtual void startPageScaleAnimation(const WebCore::IntSize& targetPosition,
+ bool anchorPoint,
+ float pageScale,
+ double startTimeMs,
+ double durationMs) OVERRIDE { }
+
+ ScrollStatus m_scrollStatus;
+};
+
+class MockWebCompositorInputHandlerClient : public WebKit::WebCompositorInputHandlerClient {
+ WTF_MAKE_NONCOPYABLE(MockWebCompositorInputHandlerClient);
+public:
+ MockWebCompositorInputHandlerClient()
+ : m_handled(false)
+ , m_sendToWidget(false)
+ {
+ }
+ virtual ~MockWebCompositorInputHandlerClient() { }
+
+ void reset()
+ {
+ m_handled = false;
+ m_sendToWidget = false;
+ }
+
+ bool handled() const { return m_handled; }
+ bool sendToWidget() const { return m_sendToWidget; }
+
+private:
+ virtual void willShutdown() OVERRIDE { }
+ virtual void didHandleInputEvent() OVERRIDE
+ {
+ m_handled = true;
+ }
+ virtual void didNotHandleInputEvent(bool sendToWidget) OVERRIDE
+ {
+ m_sendToWidget = sendToWidget;
+ }
+
+ bool m_handled;
+ bool m_sendToWidget;
+};
+
TEST(WebCompositorInputHandlerImpl, fromIdentifier)
{
WebKit::WebCompositor::initialize(0);
@@ -53,13 +123,13 @@
int compositorIdentifier = -1;
{
- OwnPtr<WebCompositorInputHandlerImpl> comp = WebCompositorInputHandlerImpl::create(0);
- compositorIdentifier = comp->identifier();
+ OwnPtr<WebCompositorInputHandlerImpl> inputHandler = WebCompositorInputHandlerImpl::create(0);
+ compositorIdentifier = inputHandler->identifier();
// The compositor we just created should be locatable.
- EXPECT_EQ(comp.get(), WebCompositorInputHandler::fromIdentifier(compositorIdentifier));
+ EXPECT_EQ(inputHandler.get(), WebCompositorInputHandler::fromIdentifier(compositorIdentifier));
// But nothing else.
- EXPECT_EQ(0, WebCompositorInputHandler::fromIdentifier(comp->identifier() + 10));
+ EXPECT_EQ(0, WebCompositorInputHandler::fromIdentifier(inputHandler->identifier() + 10));
}
// After the compositor is destroyed, its entry should be removed from the map.
@@ -68,4 +138,66 @@
WebKit::WebCompositor::shutdown();
}
+TEST(WebCompositorInputHandlerImpl, gestureScroll)
+{
+ WebKit::WebCompositor::initialize(0);
+#ifndef NDEBUG
+ // WebCompositorInputHandler APIs can only be called from the compositor thread.
+ WebCore::DebugScopedSetImplThread alwaysImplThread;
+#endif
+
+ MockInputHandlerClient mockInputHandler;
+ OwnPtr<WebCompositorInputHandlerImpl> inputHandler = WebCompositorInputHandlerImpl::create(&mockInputHandler);
+ MockWebCompositorInputHandlerClient mockClient;
+ inputHandler->setClient(&mockClient);
+
+ WebKit::WebGestureEvent gesture;
+
+ gesture.type = WebKit::WebInputEvent::GestureScrollBegin;
+ inputHandler->handleInputEvent(gesture);
+ EXPECT_TRUE(mockClient.handled());
+ EXPECT_FALSE(mockClient.sendToWidget());
+ mockClient.reset();
+
+ gesture.type = WebKit::WebInputEvent::GestureScrollUpdate;
+ gesture.deltaY = 40;
+ inputHandler->handleInputEvent(gesture);
+ EXPECT_TRUE(mockClient.handled());
+ EXPECT_FALSE(mockClient.sendToWidget());
+ mockClient.reset();
+
+ gesture.type = WebKit::WebInputEvent::GestureScrollEnd;
+ gesture.deltaY = 0;
+ inputHandler->handleInputEvent(gesture);
+ EXPECT_TRUE(mockClient.handled());
+ EXPECT_FALSE(mockClient.sendToWidget());
+ mockClient.reset();
+
+ mockInputHandler.setScrollStatus(WebCore::CCInputHandlerClient::ScrollFailed);
+
+ gesture.type = WebKit::WebInputEvent::GestureScrollBegin;
+ inputHandler->handleInputEvent(gesture);
+ EXPECT_FALSE(mockClient.handled());
+ EXPECT_TRUE(mockClient.sendToWidget());
+ mockClient.reset();
+
+ gesture.type = WebKit::WebInputEvent::GestureScrollUpdate;
+ gesture.deltaY = 40;
+ inputHandler->handleInputEvent(gesture);
+ EXPECT_FALSE(mockClient.handled());
+ EXPECT_TRUE(mockClient.sendToWidget());
+ mockClient.reset();
+
+ gesture.type = WebKit::WebInputEvent::GestureScrollEnd;
+ gesture.deltaY = 0;
+ inputHandler->handleInputEvent(gesture);
+ EXPECT_FALSE(mockClient.handled());
+ EXPECT_TRUE(mockClient.sendToWidget());
+ mockClient.reset();
+
+ inputHandler->setClient(0);
+
+ WebKit::WebCompositor::shutdown();
}
+
+}
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes