Diff
Modified: trunk/Source/Platform/ChangeLog (127604 => 127605)
--- trunk/Source/Platform/ChangeLog 2012-09-05 17:05:40 UTC (rev 127604)
+++ trunk/Source/Platform/ChangeLog 2012-09-05 17:25:42 UTC (rev 127605)
@@ -1,3 +1,18 @@
+2012-09-05 Sami Kyostila <[email protected]>
+
+ [chromium] Wire up scrollable sublayers in ScrollingCoordinatorChromium
+ https://bugs.webkit.org/show_bug.cgi?id=95679
+
+ Reviewed by James Robinson.
+
+ Introduce WebLayerScrollClient for getting notified about scroll events targeting a WebLayer.
+
+ * Platform.gypi:
+ * chromium/public/WebLayer.h:
+ (WebKit):
+ (WebLayer):
+ * chromium/public/WebLayerScrollClient.h:
+
2012-09-04 Kenichi Ishibashi <[email protected]>
[Chromium] Attempt to fix build failure on Win
Modified: trunk/Source/Platform/Platform.gypi (127604 => 127605)
--- trunk/Source/Platform/Platform.gypi 2012-09-05 17:05:40 UTC (rev 127604)
+++ trunk/Source/Platform/Platform.gypi 2012-09-05 17:25:42 UTC (rev 127605)
@@ -79,6 +79,7 @@
'chromium/public/WebImageLayer.h',
'chromium/public/WebIOSurfaceLayer.h',
'chromium/public/WebLayer.h',
+ 'chromium/public/WebLayerScrollClient.h',
'chromium/public/WebLayerTreeView.h',
'chromium/public/WebLayerTreeViewClient.h',
'chromium/public/WebLocalizedString.h',
Modified: trunk/Source/Platform/chromium/public/WebLayer.h (127604 => 127605)
--- trunk/Source/Platform/chromium/public/WebLayer.h 2012-09-05 17:05:40 UTC (rev 127604)
+++ trunk/Source/Platform/chromium/public/WebLayer.h 2012-09-05 17:25:42 UTC (rev 127605)
@@ -40,6 +40,7 @@
namespace WebKit {
class WebAnimationDelegate;
class WebFilterOperations;
+class WebLayerScrollClient;
class WebTransformationMatrix;
struct WebFloatPoint;
struct WebFloatRect;
@@ -165,6 +166,9 @@
// Scrolling
virtual void setScrollPosition(WebPoint) = 0;
+ virtual WebPoint scrollPosition() const = 0;
+
+ virtual void setMaxScrollPosition(WebSize) = 0;
virtual void setScrollable(bool) = 0;
virtual void setHaveWheelEventHandlers(bool) = 0;
virtual void setShouldScrollOnMainThread(bool) = 0;
@@ -172,6 +176,13 @@
virtual void setIsContainerForFixedPositionLayers(bool) = 0;
virtual void setFixedToContainerLayer(bool) = 0;
+ // The scroll client is notified when the scroll position of the WebLayer
+ // changes. Only a single scroll client can be set for a WebLayer at a time.
+ // The WebLayer does not take ownership of the scroll client, and it is the
+ // responsibility of the client to reset the layer's scroll client before
+ // deleting the scroll client.
+ virtual void setScrollClient(WebLayerScrollClient*) = 0;
+
// Forces this layer to use a render surface. There is no benefit in doing
// so, but this is to facilitate benchmarks and tests.
virtual void setForceRenderSurface(bool) = 0;
Added: trunk/Source/Platform/chromium/public/WebLayerScrollClient.h (0 => 127605)
--- trunk/Source/Platform/chromium/public/WebLayerScrollClient.h (rev 0)
+++ trunk/Source/Platform/chromium/public/WebLayerScrollClient.h 2012-09-05 17:25:42 UTC (rev 127605)
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2012 Google Inc. 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS 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 APPLE INC. OR ITS 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 WebLayerScrollClient_h
+#define WebLayerScrollClient_h
+
+namespace WebKit {
+
+// A client that is notified of scrolling on a WebLayer.
+class WebLayerScrollClient {
+public:
+ virtual void didScroll() = 0;
+protected:
+ virtual ~WebLayerScrollClient() { }
+};
+
+} // namespace WebKit
+
+#endif // WebLayerScrollClient_h
Modified: trunk/Source/WebCore/ChangeLog (127604 => 127605)
--- trunk/Source/WebCore/ChangeLog 2012-09-05 17:05:40 UTC (rev 127604)
+++ trunk/Source/WebCore/ChangeLog 2012-09-05 17:25:42 UTC (rev 127605)
@@ -1,3 +1,35 @@
+2012-09-05 Sami Kyostila <[email protected]>
+
+ [chromium] Wire up scrollable sublayers in ScrollingCoordinatorChromium
+ https://bugs.webkit.org/show_bug.cgi?id=95679
+
+ Reviewed by James Robinson.
+
+ Implement scrollable sublayers in ScrollingCoordinatorChromium and introduce a
+ WebLayerScrollClient which is notified of scroll events on its associated
+ scroll layer. GraphicsLayerChromium uses it to apply scroll events targeted to
+ its platform layer to a ScrollableArea, i.e., the RenderLayer corresponding to
+ the scrollable element.
+
+ Tests: GraphicsLayerChromiumTest.applyScrollToScrollableArea
+ WebLayerTest.ScrollClient
+
+ * platform/graphics/chromium/GraphicsLayerChromium.cpp:
+ (WebCore::GraphicsLayerChromium::GraphicsLayerChromium):
+ (WebCore::GraphicsLayerChromium::didScroll):
+ (WebCore):
+ * platform/graphics/chromium/GraphicsLayerChromium.h:
+ (WebCore):
+ (WebCore::GraphicsLayerChromium::setScrollableArea):
+ (WebCore::GraphicsLayerChromium::scrollableArea):
+ (GraphicsLayerChromium):
+ * platform/graphics/chromium/LayerChromium.cpp:
+ * platform/graphics/chromium/LayerChromium.h:
+ (WebKit):
+ (WebCore):
+ (WebCore::LayerChromium::setLayerScrollClient):
+ (LayerChromium):
+
2012-09-05 Peter Rybin <[email protected]>
Web Inspector: CodeGeneratorInspector.py: support asynchronous command implementation
Modified: trunk/Source/WebCore/page/scrolling/chromium/ScrollingCoordinatorChromium.cpp (127604 => 127605)
--- trunk/Source/WebCore/page/scrolling/chromium/ScrollingCoordinatorChromium.cpp 2012-09-05 17:05:40 UTC (rev 127604)
+++ trunk/Source/WebCore/page/scrolling/chromium/ScrollingCoordinatorChromium.cpp 2012-09-05 17:25:42 UTC (rev 127605)
@@ -246,9 +246,18 @@
scrollableLayer->setFixedToContainerLayer(enable);
}
-void ScrollingCoordinator::scrollableAreaScrollLayerDidChange(ScrollableArea*, GraphicsLayer*)
+void ScrollingCoordinator::scrollableAreaScrollLayerDidChange(ScrollableArea* scrollableArea, GraphicsLayer* scrollLayer)
{
- // FIXME: Implement.
+ if (!scrollLayer)
+ return;
+ GraphicsLayerChromium* layer = static_cast<GraphicsLayerChromium*>(scrollLayer);
+ layer->setScrollableArea(scrollableArea);
+
+ if (WebLayer* webLayer = scrollLayer->platformLayer()) {
+ webLayer->setScrollable(true);
+ webLayer->setScrollPosition(scrollableArea->scrollPosition());
+ webLayer->setMaxScrollPosition(IntSize(scrollableArea->scrollSize(HorizontalScrollbar), scrollableArea->scrollSize(VerticalScrollbar)));
+ }
}
}
Modified: trunk/Source/WebCore/platform/graphics/chromium/GraphicsLayerChromium.cpp (127604 => 127605)
--- trunk/Source/WebCore/platform/graphics/chromium/GraphicsLayerChromium.cpp 2012-09-05 17:05:40 UTC (rev 127604)
+++ trunk/Source/WebCore/platform/graphics/chromium/GraphicsLayerChromium.cpp 2012-09-05 17:25:42 UTC (rev 127605)
@@ -54,6 +54,7 @@
#include "NativeImageSkia.h"
#include "PlatformContextSkia.h"
#include "PlatformString.h"
+#include "ScrollableArea.h"
#include "SkMatrix44.h"
#include "SystemTime.h"
#include <public/Platform.h>
@@ -90,6 +91,7 @@
, m_contentsLayerHasBackgroundColor(false)
, m_inSetChildren(false)
, m_pageScaleChanged(false)
+ , m_scrollableArea(0)
{
m_opaqueRectTrackingContentLayerDelegate = adoptPtr(new OpaqueRectTrackingContentLayerDelegate(this));
@@ -99,6 +101,7 @@
m_layer = adoptPtr(WebContentLayer::create(m_opaqueRectTrackingContentLayerDelegate.get()));
m_layer->layer()->setDrawsContent(m_drawsContent && m_contentsVisible);
+ m_layer->layer()->setScrollClient(this);
if (client)
deviceOrPageScaleFactorChanged();
updateDebugIndicators();
@@ -907,6 +910,12 @@
// Do nothing.
}
+void GraphicsLayerChromium::didScroll()
+{
+ if (m_scrollableArea)
+ m_scrollableArea->scrollToOffsetWithoutAnimation(IntPoint(m_layer->layer()->scrollPosition()));
+}
+
} // namespace WebCore
#endif // USE(ACCELERATED_COMPOSITING)
Modified: trunk/Source/WebCore/platform/graphics/chromium/GraphicsLayerChromium.h (127604 => 127605)
--- trunk/Source/WebCore/platform/graphics/chromium/GraphicsLayerChromium.h 2012-09-05 17:05:40 UTC (rev 127604)
+++ trunk/Source/WebCore/platform/graphics/chromium/GraphicsLayerChromium.h 2012-09-05 17:25:42 UTC (rev 127605)
@@ -41,12 +41,13 @@
#include <public/WebContentLayer.h>
#include <public/WebImageLayer.h>
#include <public/WebLayer.h>
+#include <public/WebLayerScrollClient.h>
#include <wtf/HashMap.h>
namespace WebCore {
-class LayerChromium;
class Path;
+class ScrollableArea;
class LinkHighlightClient {
public:
@@ -58,7 +59,7 @@
virtual ~LinkHighlightClient() { }
};
-class GraphicsLayerChromium : public GraphicsLayer, public GraphicsContextPainter, public WebKit::WebAnimationDelegate {
+class GraphicsLayerChromium : public GraphicsLayer, public GraphicsContextPainter, public WebKit::WebAnimationDelegate, public WebKit::WebLayerScrollClient {
public:
GraphicsLayerChromium(GraphicsLayerClient*);
virtual ~GraphicsLayerChromium();
@@ -134,6 +135,9 @@
virtual void setDebugBorder(const Color&, float borderWidth);
virtual void deviceOrPageScaleFactorChanged();
+ void setScrollableArea(ScrollableArea* scrollableArea) { m_scrollableArea = scrollableArea; }
+ ScrollableArea* scrollableArea() const { return m_scrollableArea; }
+
// GraphicsContextPainter implementation.
virtual void paint(GraphicsContext&, const IntRect& clip) OVERRIDE;
@@ -141,6 +145,9 @@
virtual void notifyAnimationStarted(double startTime) OVERRIDE;
virtual void notifyAnimationFinished(double finishTime) OVERRIDE;
+ // WebLayerScrollClient implementation.
+ virtual void didScroll() OVERRIDE;
+
WebKit::WebContentLayer* contentLayer() const { return m_layer.get(); }
// Exposed for tests.
@@ -200,6 +207,8 @@
typedef HashMap<String, int> AnimationIdMap;
AnimationIdMap m_animationIdMap;
+
+ ScrollableArea* m_scrollableArea;
};
} // namespace WebCore
Modified: trunk/Source/WebCore/platform/graphics/chromium/LayerChromium.cpp (127604 => 127605)
--- trunk/Source/WebCore/platform/graphics/chromium/LayerChromium.cpp 2012-09-05 17:05:40 UTC (rev 127604)
+++ trunk/Source/WebCore/platform/graphics/chromium/LayerChromium.cpp 2012-09-05 17:25:42 UTC (rev 127605)
@@ -42,6 +42,8 @@
#include "TextStream.h"
#include <public/WebAnimationDelegate.h>
+#include <public/WebLayerScrollClient.h>
+#include <public/WebSize.h>
using namespace std;
using WebKit::WebTransformationMatrix;
@@ -91,7 +93,7 @@
, m_screenSpaceTransformIsAnimating(false)
, m_contentsScale(1.0)
, m_layerAnimationDelegate(0)
- , m_layerScrollDelegate(0)
+ , m_layerScrollClient(0)
{
if (m_layerId < 0) {
s_nextLayerId = 1;
@@ -395,6 +397,8 @@
if (m_scrollPosition == scrollPosition)
return;
m_scrollPosition = scrollPosition;
+ if (m_layerScrollClient)
+ m_layerScrollClient->didScroll();
setNeedsCommit();
}
@@ -439,13 +443,6 @@
setNeedsCommit();
}
-void LayerChromium::scrollBy(const IntSize& scrollDelta)
-{
- setScrollPosition(scrollPosition() + scrollDelta);
- if (m_layerScrollDelegate)
- m_layerScrollDelegate->didScroll(scrollDelta);
-}
-
void LayerChromium::setDrawCheckerboardForMissingTiles(bool checkerboard)
{
if (m_drawCheckerboardForMissingTiles == checkerboard)
Modified: trunk/Source/WebCore/platform/graphics/chromium/LayerChromium.h (127604 => 127605)
--- trunk/Source/WebCore/platform/graphics/chromium/LayerChromium.h 2012-09-05 17:05:40 UTC (rev 127604)
+++ trunk/Source/WebCore/platform/graphics/chromium/LayerChromium.h 2012-09-05 17:25:42 UTC (rev 127605)
@@ -54,6 +54,7 @@
namespace WebKit {
class WebAnimationDelegate;
+class WebLayerScrollClient;
}
namespace WebCore {
@@ -68,15 +69,6 @@
struct CCAnimationEvent;
struct CCRenderingStats;
-// Delegate for handling scroll input for a LayerChromium.
-class LayerChromiumScrollDelegate {
-public:
- virtual void didScroll(const IntSize&) = 0;
-
-protected:
- virtual ~LayerChromiumScrollDelegate() { }
-};
-
// Base class for composited layers. Special layer types are derived from
// this class.
class LayerChromium : public RefCounted<LayerChromium>, public CCLayerAnimationControllerClient {
@@ -175,8 +167,7 @@
const Region& nonFastScrollableRegion() { return m_nonFastScrollableRegion; }
void setNonFastScrollableRegion(const Region&);
void setNonFastScrollableRegionChanged() { m_nonFastScrollableRegionChanged = true; }
- void setLayerScrollDelegate(LayerChromiumScrollDelegate* layerScrollDelegate) { m_layerScrollDelegate = layerScrollDelegate; }
- void scrollBy(const IntSize&);
+ void setLayerScrollClient(WebKit::WebLayerScrollClient* layerScrollClient) { m_layerScrollClient = layerScrollClient; }
void setDrawCheckerboardForMissingTiles(bool);
bool drawCheckerboardForMissingTiles() const { return m_drawCheckerboardForMissingTiles; }
@@ -396,7 +387,7 @@
float m_contentsScale;
WebKit::WebAnimationDelegate* m_layerAnimationDelegate;
- LayerChromiumScrollDelegate* m_layerScrollDelegate;
+ WebKit::WebLayerScrollClient* m_layerScrollClient;
};
void sortLayers(Vector<RefPtr<LayerChromium> >::iterator, Vector<RefPtr<LayerChromium> >::iterator, void*);
Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.cpp (127604 => 127605)
--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.cpp 2012-09-05 17:05:40 UTC (rev 127604)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.cpp 2012-09-05 17:25:42 UTC (rev 127605)
@@ -658,7 +658,7 @@
if (layer == rootScrollLayer)
rootScrollDelta += info.scrolls[i].scrollDelta;
else
- layer->scrollBy(info.scrolls[i].scrollDelta);
+ layer->setScrollPosition(layer->scrollPosition() + info.scrolls[i].scrollDelta);
}
if (!rootScrollDelta.isZero() || info.pageScaleDelta != 1)
m_client->applyScrollAndScale(rootScrollDelta, info.pageScaleDelta);
Modified: trunk/Source/WebKit/chromium/ChangeLog (127604 => 127605)
--- trunk/Source/WebKit/chromium/ChangeLog 2012-09-05 17:05:40 UTC (rev 127604)
+++ trunk/Source/WebKit/chromium/ChangeLog 2012-09-05 17:25:42 UTC (rev 127605)
@@ -1,3 +1,26 @@
+2012-09-05 Sami Kyostila <[email protected]>
+
+ [chromium] Wire up scrollable sublayers in ScrollingCoordinatorChromium
+ https://bugs.webkit.org/show_bug.cgi?id=95679
+
+ Reviewed by James Robinson.
+
+ Introduce WebLayerScrollClient for getting notified about scroll events targeting a WebLayer.
+
+ * src/WebLayerImpl.cpp:
+ (WebKit::WebLayerImpl::setMaxScrollPosition):
+ (WebKit):
+ (WebKit::WebLayerImpl::setScrollClient):
+ (WebKit::WebLayerImpl::scrollBy):
+ * src/WebLayerImpl.h:
+ (WebLayerImpl):
+ * tests/CCLayerTreeHostTest.cpp:
+ * tests/GraphicsLayerChromiumTest.cpp:
+ (MockScrollableArea):
+ (WebKit):
+ (WebKit::TEST_F):
+ * tests/WebLayerTest.cpp:
+
2012-09-05 Ilya Tikhonovsky <[email protected]>
Web Inspector: NMI: extract MemoryObjectType constants from MemoryInstrumentation.
Modified: trunk/Source/WebKit/chromium/src/WebLayerImpl.cpp (127604 => 127605)
--- trunk/Source/WebKit/chromium/src/WebLayerImpl.cpp 2012-09-05 17:05:40 UTC (rev 127604)
+++ trunk/Source/WebKit/chromium/src/WebLayerImpl.cpp 2012-09-05 17:25:42 UTC (rev 127605)
@@ -355,6 +355,16 @@
m_layer->setScrollPosition(position);
}
+WebPoint WebLayerImpl::scrollPosition() const
+{
+ return m_layer->scrollPosition();
+}
+
+void WebLayerImpl::setMaxScrollPosition(WebSize maxScrollPosition)
+{
+ m_layer->setMaxScrollPosition(maxScrollPosition);
+}
+
void WebLayerImpl::setScrollable(bool scrollable)
{
m_layer->setScrollable(scrollable);
@@ -391,6 +401,11 @@
m_layer->setFixedToContainerLayer(enable);
}
+void WebLayerImpl::setScrollClient(WebLayerScrollClient* scrollClient)
+{
+ m_layer->setLayerScrollClient(scrollClient);
+}
+
LayerChromium* WebLayerImpl::layer() const
{
return m_layer.get();
Modified: trunk/Source/WebKit/chromium/src/WebLayerImpl.h (127604 => 127605)
--- trunk/Source/WebKit/chromium/src/WebLayerImpl.h 2012-09-05 17:05:40 UTC (rev 127604)
+++ trunk/Source/WebKit/chromium/src/WebLayerImpl.h 2012-09-05 17:25:42 UTC (rev 127605)
@@ -94,12 +94,15 @@
virtual void transferAnimationsTo(WebLayer*) OVERRIDE;
virtual void setForceRenderSurface(bool) OVERRIDE;
virtual void setScrollPosition(WebPoint) OVERRIDE;
+ virtual WebPoint scrollPosition() const OVERRIDE;
+ virtual void setMaxScrollPosition(WebSize) OVERRIDE;
virtual void setScrollable(bool) OVERRIDE;
virtual void setHaveWheelEventHandlers(bool) OVERRIDE;
virtual void setShouldScrollOnMainThread(bool) OVERRIDE;
virtual void setNonFastScrollableRegion(const WebVector<WebRect>&) OVERRIDE;
virtual void setIsContainerForFixedPositionLayers(bool) OVERRIDE;
virtual void setFixedToContainerLayer(bool) OVERRIDE;
+ virtual void setScrollClient(WebLayerScrollClient*) OVERRIDE;
WebCore::LayerChromium* layer() const;
Modified: trunk/Source/WebKit/chromium/tests/CCLayerTreeHostTest.cpp (127604 => 127605)
--- trunk/Source/WebKit/chromium/tests/CCLayerTreeHostTest.cpp 2012-09-05 17:05:40 UTC (rev 127604)
+++ trunk/Source/WebKit/chromium/tests/CCLayerTreeHostTest.cpp 2012-09-05 17:25:42 UTC (rev 127605)
@@ -41,6 +41,8 @@
#include "FakeWebCompositorOutputSurface.h"
#include <gmock/gmock.h>
#include <public/Platform.h>
+#include <public/WebLayerScrollClient.h>
+#include <public/WebSize.h>
#include <wtf/MainThread.h>
#include <wtf/OwnArrayPtr.h>
@@ -2212,7 +2214,7 @@
SINGLE_AND_MULTI_THREAD_TEST_F(CCLayerTreeHostTestLayerAddedWithAnimation)
-class CCLayerTreeHostTestScrollChildLayer : public CCLayerTreeHostTest, public LayerChromiumScrollDelegate {
+class CCLayerTreeHostTestScrollChildLayer : public CCLayerTreeHostTest, public WebLayerScrollClient {
public:
CCLayerTreeHostTestScrollChildLayer()
: m_scrollAmount(2, 1)
@@ -2235,7 +2237,7 @@
m_rootScrollLayer->setMaxScrollPosition(IntSize(100, 100));
m_layerTreeHost->rootLayer()->addChild(m_rootScrollLayer);
m_childLayer = ContentLayerChromium::create(&m_mockDelegate);
- m_childLayer->setLayerScrollDelegate(this);
+ m_childLayer->setLayerScrollClient(this);
m_childLayer->setBounds(IntSize(50, 50));
m_childLayer->setIsDrawable(true);
m_childLayer->setScrollable(true);
@@ -2248,9 +2250,9 @@
postSetNeedsCommitToMainThread();
}
- virtual void didScroll(const IntSize& scrollDelta) OVERRIDE
+ virtual void didScroll() OVERRIDE
{
- m_reportedScrollAmount = scrollDelta;
+ m_finalScrollPosition = m_childLayer->scrollPosition();
}
virtual void applyScrollAndScale(const IntSize& scrollDelta, float) OVERRIDE
@@ -2280,12 +2282,12 @@
virtual void afterTest() OVERRIDE
{
- EXPECT_EQ(m_scrollAmount, m_reportedScrollAmount);
+ EXPECT_EQ(IntPoint(m_scrollAmount), m_finalScrollPosition);
}
private:
const IntSize m_scrollAmount;
- IntSize m_reportedScrollAmount;
+ IntPoint m_finalScrollPosition;
MockContentLayerChromiumClient m_mockDelegate;
RefPtr<LayerChromium> m_childLayer;
RefPtr<LayerChromium> m_rootScrollLayer;
Modified: trunk/Source/WebKit/chromium/tests/GraphicsLayerChromiumTest.cpp (127604 => 127605)
--- trunk/Source/WebKit/chromium/tests/GraphicsLayerChromiumTest.cpp 2012-09-05 17:05:40 UTC (rev 127604)
+++ trunk/Source/WebKit/chromium/tests/GraphicsLayerChromiumTest.cpp 2012-09-05 17:25:42 UTC (rev 127605)
@@ -33,6 +33,7 @@
#include "GraphicsLayer.h"
#include "Matrix3DTransformOperation.h"
#include "RotateTransformOperation.h"
+#include "ScrollableArea.h"
#include "TranslateTransformOperation.h"
#include "WebLayerTreeViewTestCommon.h"
#include <gtest/gtest.h>
@@ -126,4 +127,38 @@
EXPECT_EQ(2, m_graphicsLayer->contentsScale());
}
+class FakeScrollableArea : public ScrollableArea {
+public:
+ virtual bool isActive() const OVERRIDE { return false; }
+ virtual int scrollSize(ScrollbarOrientation) const OVERRIDE { return 0; }
+ virtual int scrollPosition(Scrollbar*) const OVERRIDE { return 0; }
+ virtual bool isScrollCornerVisible() const OVERRIDE { return false; }
+ virtual IntRect scrollCornerRect() const OVERRIDE { return IntRect(); }
+ virtual int visibleWidth() const OVERRIDE { return 0; }
+ virtual int visibleHeight() const OVERRIDE { return 0; }
+ virtual IntSize contentsSize() const OVERRIDE { return IntSize(); }
+ virtual bool isOnActivePage() const OVERRIDE { return false; }
+ virtual ScrollableArea* enclosingScrollableArea() const OVERRIDE { return 0; }
+ virtual IntRect scrollableAreaBoundingBox() const OVERRIDE { return IntRect(); }
+ virtual void invalidateScrollbarRect(Scrollbar*, const IntRect&) OVERRIDE { }
+ virtual void invalidateScrollCornerRect(const IntRect&) OVERRIDE { }
+
+ virtual void setScrollOffset(const IntPoint& scrollOffset) OVERRIDE { m_scrollPosition = scrollOffset; }
+ virtual IntPoint scrollPosition() const OVERRIDE { return m_scrollPosition; }
+
+private:
+ IntPoint m_scrollPosition;
+};
+
+TEST_F(GraphicsLayerChromiumTest, applyScrollToScrollableArea)
+{
+ FakeScrollableArea scrollableArea;
+ m_graphicsLayer->setScrollableArea(&scrollableArea);
+
+ WebPoint scrollPosition(7, 9);
+ m_platformLayer->setScrollPosition(scrollPosition);
+
+ EXPECT_EQ(scrollPosition, WebPoint(scrollableArea.scrollPosition()));
+}
+
} // namespace
Modified: trunk/Source/WebKit/chromium/tests/WebLayerTest.cpp (127604 => 127605)
--- trunk/Source/WebKit/chromium/tests/WebLayerTest.cpp 2012-09-05 17:05:40 UTC (rev 127604)
+++ trunk/Source/WebKit/chromium/tests/WebLayerTest.cpp 2012-09-05 17:25:42 UTC (rev 127605)
@@ -34,6 +34,7 @@
#include <public/WebExternalTextureLayer.h>
#include <public/WebFloatPoint.h>
#include <public/WebFloatRect.h>
+#include <public/WebLayerScrollClient.h>
#include <public/WebLayerTreeView.h>
#include <public/WebLayerTreeViewClient.h>
#include <public/WebRect.h>
@@ -172,4 +173,28 @@
EXPECT_FALSE(contentLayer->layer()->drawsContent());
}
+class MockScrollClient : public WebLayerScrollClient {
+public:
+ MOCK_METHOD0(didScroll, void());
+};
+
+TEST_F(WebLayerTest, notifyScrollClient)
+{
+ MockScrollClient scrollClient;
+
+ EXPECT_CALL(scrollClient, didScroll()).Times(0);
+ m_rootLayer->setScrollClient(&scrollClient);
+ Mock::VerifyAndClearExpectations(&scrollClient);
+
+ EXPECT_CALL(scrollClient, didScroll()).Times(1);
+ m_rootLayer->setScrollPosition(WebPoint(14, 19));
+ Mock::VerifyAndClearExpectations(&scrollClient);
+
+ EXPECT_CALL(scrollClient, didScroll()).Times(0);
+ m_rootLayer->setScrollPosition(WebPoint(14, 19));
+ Mock::VerifyAndClearExpectations(&scrollClient);
+
+ m_rootLayer->setScrollClient(0);
}
+
+}