Changeset 127605 in webkit
- Timestamp:
- Sep 5, 2012 10:25:42 AM (12 years ago)
- Location:
- trunk/Source
- Files:
-
- 1 added
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/Platform/ChangeLog
r127526 r127605 1 2012-09-05 Sami Kyostila <skyostil@chromium.org> 2 3 [chromium] Wire up scrollable sublayers in ScrollingCoordinatorChromium 4 https://bugs.webkit.org/show_bug.cgi?id=95679 5 6 Reviewed by James Robinson. 7 8 Introduce WebLayerScrollClient for getting notified about scroll events targeting a WebLayer. 9 10 * Platform.gypi: 11 * chromium/public/WebLayer.h: 12 (WebKit): 13 (WebLayer): 14 * chromium/public/WebLayerScrollClient.h: 15 1 16 2012-09-04 Kenichi Ishibashi <bashi@chromium.org> 2 17 -
trunk/Source/Platform/Platform.gypi
r127526 r127605 80 80 'chromium/public/WebIOSurfaceLayer.h', 81 81 'chromium/public/WebLayer.h', 82 'chromium/public/WebLayerScrollClient.h', 82 83 'chromium/public/WebLayerTreeView.h', 83 84 'chromium/public/WebLayerTreeViewClient.h', -
trunk/Source/Platform/chromium/public/WebLayer.h
r126498 r127605 41 41 class WebAnimationDelegate; 42 42 class WebFilterOperations; 43 class WebLayerScrollClient; 43 44 class WebTransformationMatrix; 44 45 struct WebFloatPoint; … … 166 167 // Scrolling 167 168 virtual void setScrollPosition(WebPoint) = 0; 169 virtual WebPoint scrollPosition() const = 0; 170 171 virtual void setMaxScrollPosition(WebSize) = 0; 168 172 virtual void setScrollable(bool) = 0; 169 173 virtual void setHaveWheelEventHandlers(bool) = 0; … … 172 176 virtual void setIsContainerForFixedPositionLayers(bool) = 0; 173 177 virtual void setFixedToContainerLayer(bool) = 0; 178 179 // The scroll client is notified when the scroll position of the WebLayer 180 // changes. Only a single scroll client can be set for a WebLayer at a time. 181 // The WebLayer does not take ownership of the scroll client, and it is the 182 // responsibility of the client to reset the layer's scroll client before 183 // deleting the scroll client. 184 virtual void setScrollClient(WebLayerScrollClient*) = 0; 174 185 175 186 // Forces this layer to use a render surface. There is no benefit in doing -
trunk/Source/WebCore/ChangeLog
r127603 r127605 1 2012-09-05 Sami Kyostila <skyostil@chromium.org> 2 3 [chromium] Wire up scrollable sublayers in ScrollingCoordinatorChromium 4 https://bugs.webkit.org/show_bug.cgi?id=95679 5 6 Reviewed by James Robinson. 7 8 Implement scrollable sublayers in ScrollingCoordinatorChromium and introduce a 9 WebLayerScrollClient which is notified of scroll events on its associated 10 scroll layer. GraphicsLayerChromium uses it to apply scroll events targeted to 11 its platform layer to a ScrollableArea, i.e., the RenderLayer corresponding to 12 the scrollable element. 13 14 Tests: GraphicsLayerChromiumTest.applyScrollToScrollableArea 15 WebLayerTest.ScrollClient 16 17 * platform/graphics/chromium/GraphicsLayerChromium.cpp: 18 (WebCore::GraphicsLayerChromium::GraphicsLayerChromium): 19 (WebCore::GraphicsLayerChromium::didScroll): 20 (WebCore): 21 * platform/graphics/chromium/GraphicsLayerChromium.h: 22 (WebCore): 23 (WebCore::GraphicsLayerChromium::setScrollableArea): 24 (WebCore::GraphicsLayerChromium::scrollableArea): 25 (GraphicsLayerChromium): 26 * platform/graphics/chromium/LayerChromium.cpp: 27 * platform/graphics/chromium/LayerChromium.h: 28 (WebKit): 29 (WebCore): 30 (WebCore::LayerChromium::setLayerScrollClient): 31 (LayerChromium): 32 1 33 2012-09-05 Peter Rybin <peter.rybin@gmail.com> 2 34 -
trunk/Source/WebCore/page/scrolling/chromium/ScrollingCoordinatorChromium.cpp
r127480 r127605 247 247 } 248 248 249 void ScrollingCoordinator::scrollableAreaScrollLayerDidChange(ScrollableArea*, GraphicsLayer*) 250 { 251 // FIXME: Implement. 252 } 253 254 } 249 void ScrollingCoordinator::scrollableAreaScrollLayerDidChange(ScrollableArea* scrollableArea, GraphicsLayer* scrollLayer) 250 { 251 if (!scrollLayer) 252 return; 253 GraphicsLayerChromium* layer = static_cast<GraphicsLayerChromium*>(scrollLayer); 254 layer->setScrollableArea(scrollableArea); 255 256 if (WebLayer* webLayer = scrollLayer->platformLayer()) { 257 webLayer->setScrollable(true); 258 webLayer->setScrollPosition(scrollableArea->scrollPosition()); 259 webLayer->setMaxScrollPosition(IntSize(scrollableArea->scrollSize(HorizontalScrollbar), scrollableArea->scrollSize(VerticalScrollbar))); 260 } 261 } 262 263 } -
trunk/Source/WebCore/platform/graphics/chromium/GraphicsLayerChromium.cpp
r127225 r127605 55 55 #include "PlatformContextSkia.h" 56 56 #include "PlatformString.h" 57 #include "ScrollableArea.h" 57 58 #include "SkMatrix44.h" 58 59 #include "SystemTime.h" … … 91 92 , m_inSetChildren(false) 92 93 , m_pageScaleChanged(false) 94 , m_scrollableArea(0) 93 95 { 94 96 m_opaqueRectTrackingContentLayerDelegate = adoptPtr(new OpaqueRectTrackingContentLayerDelegate(this)); … … 100 102 101 103 m_layer->layer()->setDrawsContent(m_drawsContent && m_contentsVisible); 104 m_layer->layer()->setScrollClient(this); 102 105 if (client) 103 106 deviceOrPageScaleFactorChanged(); … … 908 911 } 909 912 913 void GraphicsLayerChromium::didScroll() 914 { 915 if (m_scrollableArea) 916 m_scrollableArea->scrollToOffsetWithoutAnimation(IntPoint(m_layer->layer()->scrollPosition())); 917 } 918 910 919 } // namespace WebCore 911 920 -
trunk/Source/WebCore/platform/graphics/chromium/GraphicsLayerChromium.h
r127077 r127605 42 42 #include <public/WebImageLayer.h> 43 43 #include <public/WebLayer.h> 44 #include <public/WebLayerScrollClient.h> 44 45 #include <wtf/HashMap.h> 45 46 46 47 namespace WebCore { 47 48 48 class LayerChromium;49 49 class Path; 50 class ScrollableArea; 50 51 51 52 class LinkHighlightClient { … … 59 60 }; 60 61 61 class GraphicsLayerChromium : public GraphicsLayer, public GraphicsContextPainter, public WebKit::WebAnimationDelegate {62 class GraphicsLayerChromium : public GraphicsLayer, public GraphicsContextPainter, public WebKit::WebAnimationDelegate, public WebKit::WebLayerScrollClient { 62 63 public: 63 64 GraphicsLayerChromium(GraphicsLayerClient*); … … 135 136 virtual void deviceOrPageScaleFactorChanged(); 136 137 138 void setScrollableArea(ScrollableArea* scrollableArea) { m_scrollableArea = scrollableArea; } 139 ScrollableArea* scrollableArea() const { return m_scrollableArea; } 140 137 141 // GraphicsContextPainter implementation. 138 142 virtual void paint(GraphicsContext&, const IntRect& clip) OVERRIDE; … … 141 145 virtual void notifyAnimationStarted(double startTime) OVERRIDE; 142 146 virtual void notifyAnimationFinished(double finishTime) OVERRIDE; 147 148 // WebLayerScrollClient implementation. 149 virtual void didScroll() OVERRIDE; 143 150 144 151 WebKit::WebContentLayer* contentLayer() const { return m_layer.get(); } … … 201 208 typedef HashMap<String, int> AnimationIdMap; 202 209 AnimationIdMap m_animationIdMap; 210 211 ScrollableArea* m_scrollableArea; 203 212 }; 204 213 -
trunk/Source/WebCore/platform/graphics/chromium/LayerChromium.cpp
r126378 r127605 43 43 44 44 #include <public/WebAnimationDelegate.h> 45 #include <public/WebLayerScrollClient.h> 46 #include <public/WebSize.h> 45 47 46 48 using namespace std; … … 92 94 , m_contentsScale(1.0) 93 95 , m_layerAnimationDelegate(0) 94 , m_layerScroll Delegate(0)96 , m_layerScrollClient(0) 95 97 { 96 98 if (m_layerId < 0) { … … 396 398 return; 397 399 m_scrollPosition = scrollPosition; 400 if (m_layerScrollClient) 401 m_layerScrollClient->didScroll(); 398 402 setNeedsCommit(); 399 403 } … … 438 442 m_nonFastScrollableRegionChanged = true; 439 443 setNeedsCommit(); 440 }441 442 void LayerChromium::scrollBy(const IntSize& scrollDelta)443 {444 setScrollPosition(scrollPosition() + scrollDelta);445 if (m_layerScrollDelegate)446 m_layerScrollDelegate->didScroll(scrollDelta);447 444 } 448 445 -
trunk/Source/WebCore/platform/graphics/chromium/LayerChromium.h
r126378 r127605 55 55 namespace WebKit { 56 56 class WebAnimationDelegate; 57 class WebLayerScrollClient; 57 58 } 58 59 … … 69 70 struct CCRenderingStats; 70 71 71 // Delegate for handling scroll input for a LayerChromium.72 class LayerChromiumScrollDelegate {73 public:74 virtual void didScroll(const IntSize&) = 0;75 76 protected:77 virtual ~LayerChromiumScrollDelegate() { }78 };79 80 72 // Base class for composited layers. Special layer types are derived from 81 73 // this class. … … 176 168 void setNonFastScrollableRegion(const Region&); 177 169 void setNonFastScrollableRegionChanged() { m_nonFastScrollableRegionChanged = true; } 178 void setLayerScrollDelegate(LayerChromiumScrollDelegate* layerScrollDelegate) { m_layerScrollDelegate = layerScrollDelegate; } 179 void scrollBy(const IntSize&); 170 void setLayerScrollClient(WebKit::WebLayerScrollClient* layerScrollClient) { m_layerScrollClient = layerScrollClient; } 180 171 181 172 void setDrawCheckerboardForMissingTiles(bool); … … 397 388 398 389 WebKit::WebAnimationDelegate* m_layerAnimationDelegate; 399 LayerChromiumScrollDelegate* m_layerScrollDelegate;390 WebKit::WebLayerScrollClient* m_layerScrollClient; 400 391 }; 401 392 -
trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.cpp
r127311 r127605 659 659 rootScrollDelta += info.scrolls[i].scrollDelta; 660 660 else 661 layer->s crollBy(info.scrolls[i].scrollDelta);661 layer->setScrollPosition(layer->scrollPosition() + info.scrolls[i].scrollDelta); 662 662 } 663 663 if (!rootScrollDelta.isZero() || info.pageScaleDelta != 1) -
trunk/Source/WebKit/chromium/ChangeLog
r127593 r127605 1 2012-09-05 Sami Kyostila <skyostil@chromium.org> 2 3 [chromium] Wire up scrollable sublayers in ScrollingCoordinatorChromium 4 https://bugs.webkit.org/show_bug.cgi?id=95679 5 6 Reviewed by James Robinson. 7 8 Introduce WebLayerScrollClient for getting notified about scroll events targeting a WebLayer. 9 10 * src/WebLayerImpl.cpp: 11 (WebKit::WebLayerImpl::setMaxScrollPosition): 12 (WebKit): 13 (WebKit::WebLayerImpl::setScrollClient): 14 (WebKit::WebLayerImpl::scrollBy): 15 * src/WebLayerImpl.h: 16 (WebLayerImpl): 17 * tests/CCLayerTreeHostTest.cpp: 18 * tests/GraphicsLayerChromiumTest.cpp: 19 (MockScrollableArea): 20 (WebKit): 21 (WebKit::TEST_F): 22 * tests/WebLayerTest.cpp: 23 1 24 2012-09-05 Ilya Tikhonovsky <loislo@chromium.org> 2 25 -
trunk/Source/WebKit/chromium/src/WebLayerImpl.cpp
r127336 r127605 356 356 } 357 357 358 WebPoint WebLayerImpl::scrollPosition() const 359 { 360 return m_layer->scrollPosition(); 361 } 362 363 void WebLayerImpl::setMaxScrollPosition(WebSize maxScrollPosition) 364 { 365 m_layer->setMaxScrollPosition(maxScrollPosition); 366 } 367 358 368 void WebLayerImpl::setScrollable(bool scrollable) 359 369 { … … 392 402 } 393 403 404 void WebLayerImpl::setScrollClient(WebLayerScrollClient* scrollClient) 405 { 406 m_layer->setLayerScrollClient(scrollClient); 407 } 408 394 409 LayerChromium* WebLayerImpl::layer() const 395 410 { -
trunk/Source/WebKit/chromium/src/WebLayerImpl.h
r127336 r127605 95 95 virtual void setForceRenderSurface(bool) OVERRIDE; 96 96 virtual void setScrollPosition(WebPoint) OVERRIDE; 97 virtual WebPoint scrollPosition() const OVERRIDE; 98 virtual void setMaxScrollPosition(WebSize) OVERRIDE; 97 99 virtual void setScrollable(bool) OVERRIDE; 98 100 virtual void setHaveWheelEventHandlers(bool) OVERRIDE; … … 101 103 virtual void setIsContainerForFixedPositionLayers(bool) OVERRIDE; 102 104 virtual void setFixedToContainerLayer(bool) OVERRIDE; 105 virtual void setScrollClient(WebLayerScrollClient*) OVERRIDE; 103 106 104 107 WebCore::LayerChromium* layer() const; -
trunk/Source/WebKit/chromium/tests/CCLayerTreeHostTest.cpp
r127340 r127605 42 42 #include <gmock/gmock.h> 43 43 #include <public/Platform.h> 44 #include <public/WebLayerScrollClient.h> 45 #include <public/WebSize.h> 44 46 #include <wtf/MainThread.h> 45 47 #include <wtf/OwnArrayPtr.h> … … 2213 2215 SINGLE_AND_MULTI_THREAD_TEST_F(CCLayerTreeHostTestLayerAddedWithAnimation) 2214 2216 2215 class CCLayerTreeHostTestScrollChildLayer : public CCLayerTreeHostTest, public LayerChromiumScrollDelegate{2217 class CCLayerTreeHostTestScrollChildLayer : public CCLayerTreeHostTest, public WebLayerScrollClient { 2216 2218 public: 2217 2219 CCLayerTreeHostTestScrollChildLayer() … … 2236 2238 m_layerTreeHost->rootLayer()->addChild(m_rootScrollLayer); 2237 2239 m_childLayer = ContentLayerChromium::create(&m_mockDelegate); 2238 m_childLayer->setLayerScroll Delegate(this);2240 m_childLayer->setLayerScrollClient(this); 2239 2241 m_childLayer->setBounds(IntSize(50, 50)); 2240 2242 m_childLayer->setIsDrawable(true); … … 2249 2251 } 2250 2252 2251 virtual void didScroll( const IntSize& scrollDelta) OVERRIDE2252 { 2253 m_ reportedScrollAmount = scrollDelta;2253 virtual void didScroll() OVERRIDE 2254 { 2255 m_finalScrollPosition = m_childLayer->scrollPosition(); 2254 2256 } 2255 2257 … … 2281 2283 virtual void afterTest() OVERRIDE 2282 2284 { 2283 EXPECT_EQ( m_scrollAmount, m_reportedScrollAmount);2285 EXPECT_EQ(IntPoint(m_scrollAmount), m_finalScrollPosition); 2284 2286 } 2285 2287 2286 2288 private: 2287 2289 const IntSize m_scrollAmount; 2288 Int Size m_reportedScrollAmount;2290 IntPoint m_finalScrollPosition; 2289 2291 MockContentLayerChromiumClient m_mockDelegate; 2290 2292 RefPtr<LayerChromium> m_childLayer; -
trunk/Source/WebKit/chromium/tests/GraphicsLayerChromiumTest.cpp
r126652 r127605 34 34 #include "Matrix3DTransformOperation.h" 35 35 #include "RotateTransformOperation.h" 36 #include "ScrollableArea.h" 36 37 #include "TranslateTransformOperation.h" 37 38 #include "WebLayerTreeViewTestCommon.h" … … 127 128 } 128 129 130 class FakeScrollableArea : public ScrollableArea { 131 public: 132 virtual bool isActive() const OVERRIDE { return false; } 133 virtual int scrollSize(ScrollbarOrientation) const OVERRIDE { return 0; } 134 virtual int scrollPosition(Scrollbar*) const OVERRIDE { return 0; } 135 virtual bool isScrollCornerVisible() const OVERRIDE { return false; } 136 virtual IntRect scrollCornerRect() const OVERRIDE { return IntRect(); } 137 virtual int visibleWidth() const OVERRIDE { return 0; } 138 virtual int visibleHeight() const OVERRIDE { return 0; } 139 virtual IntSize contentsSize() const OVERRIDE { return IntSize(); } 140 virtual bool isOnActivePage() const OVERRIDE { return false; } 141 virtual ScrollableArea* enclosingScrollableArea() const OVERRIDE { return 0; } 142 virtual IntRect scrollableAreaBoundingBox() const OVERRIDE { return IntRect(); } 143 virtual void invalidateScrollbarRect(Scrollbar*, const IntRect&) OVERRIDE { } 144 virtual void invalidateScrollCornerRect(const IntRect&) OVERRIDE { } 145 146 virtual void setScrollOffset(const IntPoint& scrollOffset) OVERRIDE { m_scrollPosition = scrollOffset; } 147 virtual IntPoint scrollPosition() const OVERRIDE { return m_scrollPosition; } 148 149 private: 150 IntPoint m_scrollPosition; 151 }; 152 153 TEST_F(GraphicsLayerChromiumTest, applyScrollToScrollableArea) 154 { 155 FakeScrollableArea scrollableArea; 156 m_graphicsLayer->setScrollableArea(&scrollableArea); 157 158 WebPoint scrollPosition(7, 9); 159 m_platformLayer->setScrollPosition(scrollPosition); 160 161 EXPECT_EQ(scrollPosition, WebPoint(scrollableArea.scrollPosition())); 162 } 163 129 164 } // namespace -
trunk/Source/WebKit/chromium/tests/WebLayerTest.cpp
r126652 r127605 35 35 #include <public/WebFloatPoint.h> 36 36 #include <public/WebFloatRect.h> 37 #include <public/WebLayerScrollClient.h> 37 38 #include <public/WebLayerTreeView.h> 38 39 #include <public/WebLayerTreeViewClient.h> … … 173 174 } 174 175 176 class MockScrollClient : public WebLayerScrollClient { 177 public: 178 MOCK_METHOD0(didScroll, void()); 179 }; 180 181 TEST_F(WebLayerTest, notifyScrollClient) 182 { 183 MockScrollClient scrollClient; 184 185 EXPECT_CALL(scrollClient, didScroll()).Times(0); 186 m_rootLayer->setScrollClient(&scrollClient); 187 Mock::VerifyAndClearExpectations(&scrollClient); 188 189 EXPECT_CALL(scrollClient, didScroll()).Times(1); 190 m_rootLayer->setScrollPosition(WebPoint(14, 19)); 191 Mock::VerifyAndClearExpectations(&scrollClient); 192 193 EXPECT_CALL(scrollClient, didScroll()).Times(0); 194 m_rootLayer->setScrollPosition(WebPoint(14, 19)); 195 Mock::VerifyAndClearExpectations(&scrollClient); 196 197 m_rootLayer->setScrollClient(0); 175 198 } 199 200 }
Note: See TracChangeset
for help on using the changeset viewer.