Changeset 106987 in webkit
- Timestamp:
- Feb 7, 2012 1:52:21 PM (12 years ago)
- Location:
- trunk/Source/WebKit/chromium
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/chromium/ChangeLog
r106977 r106987 1 2012-02-07 Sadrul Habib Chowdhury <sadrul@chromium.org> 2 3 Process Scroll-gesture events from the compositor. 4 https://bugs.webkit.org/show_bug.cgi?id=77477 5 6 Reviewed by James Robinson. 7 8 * src/WebCompositorInputHandlerImpl.cpp: 9 (WebKit::WebCompositorInputHandlerImpl::WebCompositorInputHandlerImpl): 10 (WebKit::WebCompositorInputHandlerImpl::handleInputEvent): 11 * src/WebCompositorInputHandlerImpl.h: 12 (WebCompositorInputHandlerImpl): 13 1 14 2012-02-07 Anders Carlsson <andersca@apple.com> 2 15 -
trunk/Source/WebKit/chromium/src/WebCompositorInputHandlerImpl.cpp
r102044 r106987 82 82 , m_identifier(s_nextAvailableIdentifier++) 83 83 , m_inputHandlerClient(inputHandlerClient) 84 #ifndef NDEBUG 85 , m_expectScrollUpdateEnd(false) 86 #endif 87 , m_scrollStarted(false) 84 88 { 85 89 ASSERT(CCProxy::isImplThread()); … … 132 136 break; 133 137 } 138 } else if (event.type == WebInputEvent::GestureScrollBegin) { 139 ASSERT(!m_scrollStarted); 140 ASSERT(!m_expectScrollUpdateEnd); 141 #ifndef NDEBUG 142 m_expectScrollUpdateEnd = true; 143 #endif 144 const WebGestureEvent& gestureEvent = *static_cast<const WebGestureEvent*>(&event); 145 CCInputHandlerClient::ScrollStatus scrollStatus = m_inputHandlerClient->scrollBegin(IntPoint(gestureEvent.x, gestureEvent.y)); 146 switch (scrollStatus) { 147 case CCInputHandlerClient::ScrollStarted: 148 m_scrollStarted = true; 149 m_client->didHandleInputEvent(); 150 return; 151 case CCInputHandlerClient::ScrollIgnored: 152 m_client->didNotHandleInputEvent(false /* sendToWidget */); 153 return; 154 case CCInputHandlerClient::ScrollFailed: 155 break; 156 } 157 } else if (event.type == WebInputEvent::GestureScrollUpdate) { 158 ASSERT(m_expectScrollUpdateEnd); 159 if (m_scrollStarted) { 160 const WebGestureEvent& gestureEvent = *static_cast<const WebGestureEvent*>(&event); 161 m_inputHandlerClient->scrollBy(IntSize(-gestureEvent.deltaX, -gestureEvent.deltaY)); 162 m_client->didHandleInputEvent(); 163 return; 164 } 165 } else if (event.type == WebInputEvent::GestureScrollEnd) { 166 ASSERT(m_expectScrollUpdateEnd); 167 #ifndef NDEBUG 168 m_expectScrollUpdateEnd = false; 169 #endif 170 if (m_scrollStarted) { 171 m_inputHandlerClient->scrollEnd(); 172 m_client->didHandleInputEvent(); 173 m_scrollStarted = false; 174 return; 175 } 134 176 } 135 177 m_client->didNotHandleInputEvent(true /* sendToWidget */); -
trunk/Source/WebKit/chromium/src/WebCompositorInputHandlerImpl.h
r101576 r106987 71 71 WebCore::CCInputHandlerClient* m_inputHandlerClient; 72 72 73 #ifndef NDEBUG 74 bool m_expectScrollUpdateEnd; 75 #endif 76 bool m_scrollStarted; 77 73 78 static int s_nextAvailableIdentifier; 74 79 static HashSet<WebCompositorInputHandlerImpl*>* s_compositors; -
trunk/Source/WebKit/chromium/tests/WebCompositorInputHandlerImplTest.cpp
r101576 r106987 29 29 30 30 #include "WebCompositor.h" 31 #include "WebCompositorInputHandlerClient.h" 32 #include "WebInputEvent.h" 33 #include "cc/CCInputHandler.h" 31 34 #include "cc/CCSingleThreadProxy.h" 32 35 … … 38 41 39 42 namespace { 43 44 class MockInputHandlerClient : public WebCore::CCInputHandlerClient { 45 WTF_MAKE_NONCOPYABLE(MockInputHandlerClient); 46 public: 47 MockInputHandlerClient() 48 : m_scrollStatus(ScrollStarted) 49 { 50 } 51 virtual ~MockInputHandlerClient() { } 52 53 void setScrollStatus(ScrollStatus status) { m_scrollStatus = status; } 54 55 private: 56 virtual void setNeedsRedraw() OVERRIDE { } 57 virtual ScrollStatus scrollBegin(const WebCore::IntPoint&) OVERRIDE 58 { 59 return m_scrollStatus; 60 } 61 virtual void scrollBy(const WebCore::IntSize&) OVERRIDE { } 62 virtual void scrollEnd() OVERRIDE { } 63 64 virtual bool haveWheelEventHandlers() OVERRIDE { return false; } 65 virtual void pinchGestureBegin() OVERRIDE { } 66 virtual void pinchGestureUpdate(float magnifyDelta, const WebCore::IntPoint& anchor) OVERRIDE { } 67 virtual void pinchGestureEnd() OVERRIDE { } 68 virtual void startPageScaleAnimation(const WebCore::IntSize& targetPosition, 69 bool anchorPoint, 70 float pageScale, 71 double startTimeMs, 72 double durationMs) OVERRIDE { } 73 74 ScrollStatus m_scrollStatus; 75 }; 76 77 class MockWebCompositorInputHandlerClient : public WebKit::WebCompositorInputHandlerClient { 78 WTF_MAKE_NONCOPYABLE(MockWebCompositorInputHandlerClient); 79 public: 80 MockWebCompositorInputHandlerClient() 81 : m_handled(false) 82 , m_sendToWidget(false) 83 { 84 } 85 virtual ~MockWebCompositorInputHandlerClient() { } 86 87 void reset() 88 { 89 m_handled = false; 90 m_sendToWidget = false; 91 } 92 93 bool handled() const { return m_handled; } 94 bool sendToWidget() const { return m_sendToWidget; } 95 96 private: 97 virtual void willShutdown() OVERRIDE { } 98 virtual void didHandleInputEvent() OVERRIDE 99 { 100 m_handled = true; 101 } 102 virtual void didNotHandleInputEvent(bool sendToWidget) OVERRIDE 103 { 104 m_sendToWidget = sendToWidget; 105 } 106 107 bool m_handled; 108 bool m_sendToWidget; 109 }; 40 110 41 111 TEST(WebCompositorInputHandlerImpl, fromIdentifier) … … 54 124 int compositorIdentifier = -1; 55 125 { 56 OwnPtr<WebCompositorInputHandlerImpl> comp= WebCompositorInputHandlerImpl::create(0);57 compositorIdentifier = comp->identifier();126 OwnPtr<WebCompositorInputHandlerImpl> inputHandler = WebCompositorInputHandlerImpl::create(0); 127 compositorIdentifier = inputHandler->identifier(); 58 128 // The compositor we just created should be locatable. 59 EXPECT_EQ( comp.get(), WebCompositorInputHandler::fromIdentifier(compositorIdentifier));129 EXPECT_EQ(inputHandler.get(), WebCompositorInputHandler::fromIdentifier(compositorIdentifier)); 60 130 61 131 // But nothing else. 62 EXPECT_EQ(0, WebCompositorInputHandler::fromIdentifier( comp->identifier() + 10));132 EXPECT_EQ(0, WebCompositorInputHandler::fromIdentifier(inputHandler->identifier() + 10)); 63 133 } 64 134 … … 69 139 } 70 140 141 TEST(WebCompositorInputHandlerImpl, gestureScroll) 142 { 143 WebKit::WebCompositor::initialize(0); 144 #ifndef NDEBUG 145 // WebCompositorInputHandler APIs can only be called from the compositor thread. 146 WebCore::DebugScopedSetImplThread alwaysImplThread; 147 #endif 148 149 MockInputHandlerClient mockInputHandler; 150 OwnPtr<WebCompositorInputHandlerImpl> inputHandler = WebCompositorInputHandlerImpl::create(&mockInputHandler); 151 MockWebCompositorInputHandlerClient mockClient; 152 inputHandler->setClient(&mockClient); 153 154 WebKit::WebGestureEvent gesture; 155 156 gesture.type = WebKit::WebInputEvent::GestureScrollBegin; 157 inputHandler->handleInputEvent(gesture); 158 EXPECT_TRUE(mockClient.handled()); 159 EXPECT_FALSE(mockClient.sendToWidget()); 160 mockClient.reset(); 161 162 gesture.type = WebKit::WebInputEvent::GestureScrollUpdate; 163 gesture.deltaY = 40; 164 inputHandler->handleInputEvent(gesture); 165 EXPECT_TRUE(mockClient.handled()); 166 EXPECT_FALSE(mockClient.sendToWidget()); 167 mockClient.reset(); 168 169 gesture.type = WebKit::WebInputEvent::GestureScrollEnd; 170 gesture.deltaY = 0; 171 inputHandler->handleInputEvent(gesture); 172 EXPECT_TRUE(mockClient.handled()); 173 EXPECT_FALSE(mockClient.sendToWidget()); 174 mockClient.reset(); 175 176 mockInputHandler.setScrollStatus(WebCore::CCInputHandlerClient::ScrollFailed); 177 178 gesture.type = WebKit::WebInputEvent::GestureScrollBegin; 179 inputHandler->handleInputEvent(gesture); 180 EXPECT_FALSE(mockClient.handled()); 181 EXPECT_TRUE(mockClient.sendToWidget()); 182 mockClient.reset(); 183 184 gesture.type = WebKit::WebInputEvent::GestureScrollUpdate; 185 gesture.deltaY = 40; 186 inputHandler->handleInputEvent(gesture); 187 EXPECT_FALSE(mockClient.handled()); 188 EXPECT_TRUE(mockClient.sendToWidget()); 189 mockClient.reset(); 190 191 gesture.type = WebKit::WebInputEvent::GestureScrollEnd; 192 gesture.deltaY = 0; 193 inputHandler->handleInputEvent(gesture); 194 EXPECT_FALSE(mockClient.handled()); 195 EXPECT_TRUE(mockClient.sendToWidget()); 196 mockClient.reset(); 197 198 inputHandler->setClient(0); 199 200 WebKit::WebCompositor::shutdown(); 71 201 } 202 203 }
Note: See TracChangeset
for help on using the changeset viewer.