Changeset 127605 in webkit


Ignore:
Timestamp:
Sep 5, 2012 10:25:42 AM (12 years ago)
Author:
commit-queue@webkit.org
Message:

[chromium] Wire up scrollable sublayers in ScrollingCoordinatorChromium
https://bugs.webkit.org/show_bug.cgi?id=95679

Patch by Sami Kyostila <skyostil@chromium.org> on 2012-09-05
Reviewed by James Robinson.

Source/Platform:

Introduce WebLayerScrollClient for getting notified about scroll events targeting a WebLayer.

  • Platform.gypi:
  • chromium/public/WebLayer.h:

(WebKit):
(WebLayer):

  • chromium/public/WebLayerScrollClient.h:

Source/WebCore:

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):

Source/WebKit/chromium:

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:
Location:
trunk/Source
Files:
1 added
16 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/Platform/ChangeLog

    r127526 r127605  
     12012-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
    1162012-09-04  Kenichi Ishibashi  <bashi@chromium.org>
    217
  • trunk/Source/Platform/Platform.gypi

    r127526 r127605  
    8080            'chromium/public/WebIOSurfaceLayer.h',
    8181            'chromium/public/WebLayer.h',
     82            'chromium/public/WebLayerScrollClient.h',
    8283            'chromium/public/WebLayerTreeView.h',
    8384            'chromium/public/WebLayerTreeViewClient.h',
  • trunk/Source/Platform/chromium/public/WebLayer.h

    r126498 r127605  
    4141class WebAnimationDelegate;
    4242class WebFilterOperations;
     43class WebLayerScrollClient;
    4344class WebTransformationMatrix;
    4445struct WebFloatPoint;
     
    166167    // Scrolling
    167168    virtual void setScrollPosition(WebPoint) = 0;
     169    virtual WebPoint scrollPosition() const = 0;
     170
     171    virtual void setMaxScrollPosition(WebSize) = 0;
    168172    virtual void setScrollable(bool) = 0;
    169173    virtual void setHaveWheelEventHandlers(bool) = 0;
     
    172176    virtual void setIsContainerForFixedPositionLayers(bool) = 0;
    173177    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;
    174185
    175186    // Forces this layer to use a render surface. There is no benefit in doing
  • trunk/Source/WebCore/ChangeLog

    r127603 r127605  
     12012-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
    1332012-09-05  Peter Rybin  <peter.rybin@gmail.com>
    234
  • trunk/Source/WebCore/page/scrolling/chromium/ScrollingCoordinatorChromium.cpp

    r127480 r127605  
    247247}
    248248
    249 void ScrollingCoordinator::scrollableAreaScrollLayerDidChange(ScrollableArea*, GraphicsLayer*)
    250 {
    251     // FIXME: Implement.
    252 }
    253 
    254 }
     249void 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  
    5555#include "PlatformContextSkia.h"
    5656#include "PlatformString.h"
     57#include "ScrollableArea.h"
    5758#include "SkMatrix44.h"
    5859#include "SystemTime.h"
     
    9192    , m_inSetChildren(false)
    9293    , m_pageScaleChanged(false)
     94    , m_scrollableArea(0)
    9395{
    9496    m_opaqueRectTrackingContentLayerDelegate = adoptPtr(new OpaqueRectTrackingContentLayerDelegate(this));
     
    100102
    101103    m_layer->layer()->setDrawsContent(m_drawsContent && m_contentsVisible);
     104    m_layer->layer()->setScrollClient(this);
    102105    if (client)
    103106        deviceOrPageScaleFactorChanged();
     
    908911}
    909912
     913void GraphicsLayerChromium::didScroll()
     914{
     915    if (m_scrollableArea)
     916        m_scrollableArea->scrollToOffsetWithoutAnimation(IntPoint(m_layer->layer()->scrollPosition()));
     917}
     918
    910919} // namespace WebCore
    911920
  • trunk/Source/WebCore/platform/graphics/chromium/GraphicsLayerChromium.h

    r127077 r127605  
    4242#include <public/WebImageLayer.h>
    4343#include <public/WebLayer.h>
     44#include <public/WebLayerScrollClient.h>
    4445#include <wtf/HashMap.h>
    4546
    4647namespace WebCore {
    4748
    48 class LayerChromium;
    4949class Path;
     50class ScrollableArea;
    5051
    5152class LinkHighlightClient {
     
    5960};
    6061
    61 class GraphicsLayerChromium : public GraphicsLayer, public GraphicsContextPainter, public WebKit::WebAnimationDelegate {
     62class GraphicsLayerChromium : public GraphicsLayer, public GraphicsContextPainter, public WebKit::WebAnimationDelegate, public WebKit::WebLayerScrollClient {
    6263public:
    6364    GraphicsLayerChromium(GraphicsLayerClient*);
     
    135136    virtual void deviceOrPageScaleFactorChanged();
    136137
     138    void setScrollableArea(ScrollableArea* scrollableArea) { m_scrollableArea = scrollableArea; }
     139    ScrollableArea* scrollableArea() const { return m_scrollableArea; }
     140
    137141    // GraphicsContextPainter implementation.
    138142    virtual void paint(GraphicsContext&, const IntRect& clip) OVERRIDE;
     
    141145    virtual void notifyAnimationStarted(double startTime) OVERRIDE;
    142146    virtual void notifyAnimationFinished(double finishTime) OVERRIDE;
     147
     148    // WebLayerScrollClient implementation.
     149    virtual void didScroll() OVERRIDE;
    143150
    144151    WebKit::WebContentLayer* contentLayer() const { return m_layer.get(); }
     
    201208    typedef HashMap<String, int> AnimationIdMap;
    202209    AnimationIdMap m_animationIdMap;
     210
     211    ScrollableArea* m_scrollableArea;
    203212};
    204213
  • trunk/Source/WebCore/platform/graphics/chromium/LayerChromium.cpp

    r126378 r127605  
    4343
    4444#include <public/WebAnimationDelegate.h>
     45#include <public/WebLayerScrollClient.h>
     46#include <public/WebSize.h>
    4547
    4648using namespace std;
     
    9294    , m_contentsScale(1.0)
    9395    , m_layerAnimationDelegate(0)
    94     , m_layerScrollDelegate(0)
     96    , m_layerScrollClient(0)
    9597{
    9698    if (m_layerId < 0) {
     
    396398        return;
    397399    m_scrollPosition = scrollPosition;
     400    if (m_layerScrollClient)
     401        m_layerScrollClient->didScroll();
    398402    setNeedsCommit();
    399403}
     
    438442    m_nonFastScrollableRegionChanged = true;
    439443    setNeedsCommit();
    440 }
    441 
    442 void LayerChromium::scrollBy(const IntSize& scrollDelta)
    443 {
    444     setScrollPosition(scrollPosition() + scrollDelta);
    445     if (m_layerScrollDelegate)
    446         m_layerScrollDelegate->didScroll(scrollDelta);
    447444}
    448445
  • trunk/Source/WebCore/platform/graphics/chromium/LayerChromium.h

    r126378 r127605  
    5555namespace WebKit {
    5656class WebAnimationDelegate;
     57class WebLayerScrollClient;
    5758}
    5859
     
    6970struct CCRenderingStats;
    7071
    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 
    8072// Base class for composited layers. Special layer types are derived from
    8173// this class.
     
    176168    void setNonFastScrollableRegion(const Region&);
    177169    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; }
    180171
    181172    void setDrawCheckerboardForMissingTiles(bool);
     
    397388
    398389    WebKit::WebAnimationDelegate* m_layerAnimationDelegate;
    399     LayerChromiumScrollDelegate* m_layerScrollDelegate;
     390    WebKit::WebLayerScrollClient* m_layerScrollClient;
    400391};
    401392
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.cpp

    r127311 r127605  
    659659            rootScrollDelta += info.scrolls[i].scrollDelta;
    660660        else
    661             layer->scrollBy(info.scrolls[i].scrollDelta);
     661            layer->setScrollPosition(layer->scrollPosition() + info.scrolls[i].scrollDelta);
    662662    }
    663663    if (!rootScrollDelta.isZero() || info.pageScaleDelta != 1)
  • trunk/Source/WebKit/chromium/ChangeLog

    r127593 r127605  
     12012-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
    1242012-09-05  Ilya Tikhonovsky  <loislo@chromium.org>
    225
  • trunk/Source/WebKit/chromium/src/WebLayerImpl.cpp

    r127336 r127605  
    356356}
    357357
     358WebPoint WebLayerImpl::scrollPosition() const
     359{
     360    return m_layer->scrollPosition();
     361}
     362
     363void WebLayerImpl::setMaxScrollPosition(WebSize maxScrollPosition)
     364{
     365    m_layer->setMaxScrollPosition(maxScrollPosition);
     366}
     367
    358368void WebLayerImpl::setScrollable(bool scrollable)
    359369{
     
    392402}
    393403
     404void WebLayerImpl::setScrollClient(WebLayerScrollClient* scrollClient)
     405{
     406    m_layer->setLayerScrollClient(scrollClient);
     407}
     408
    394409LayerChromium* WebLayerImpl::layer() const
    395410{
  • trunk/Source/WebKit/chromium/src/WebLayerImpl.h

    r127336 r127605  
    9595    virtual void setForceRenderSurface(bool) OVERRIDE;
    9696    virtual void setScrollPosition(WebPoint) OVERRIDE;
     97    virtual WebPoint scrollPosition() const OVERRIDE;
     98    virtual void setMaxScrollPosition(WebSize) OVERRIDE;
    9799    virtual void setScrollable(bool) OVERRIDE;
    98100    virtual void setHaveWheelEventHandlers(bool) OVERRIDE;
     
    101103    virtual void setIsContainerForFixedPositionLayers(bool) OVERRIDE;
    102104    virtual void setFixedToContainerLayer(bool) OVERRIDE;
     105    virtual void setScrollClient(WebLayerScrollClient*) OVERRIDE;
    103106
    104107    WebCore::LayerChromium* layer() const;
  • trunk/Source/WebKit/chromium/tests/CCLayerTreeHostTest.cpp

    r127340 r127605  
    4242#include <gmock/gmock.h>
    4343#include <public/Platform.h>
     44#include <public/WebLayerScrollClient.h>
     45#include <public/WebSize.h>
    4446#include <wtf/MainThread.h>
    4547#include <wtf/OwnArrayPtr.h>
     
    22132215SINGLE_AND_MULTI_THREAD_TEST_F(CCLayerTreeHostTestLayerAddedWithAnimation)
    22142216
    2215 class CCLayerTreeHostTestScrollChildLayer : public CCLayerTreeHostTest, public LayerChromiumScrollDelegate {
     2217class CCLayerTreeHostTestScrollChildLayer : public CCLayerTreeHostTest, public WebLayerScrollClient {
    22162218public:
    22172219    CCLayerTreeHostTestScrollChildLayer()
     
    22362238        m_layerTreeHost->rootLayer()->addChild(m_rootScrollLayer);
    22372239        m_childLayer = ContentLayerChromium::create(&m_mockDelegate);
    2238         m_childLayer->setLayerScrollDelegate(this);
     2240        m_childLayer->setLayerScrollClient(this);
    22392241        m_childLayer->setBounds(IntSize(50, 50));
    22402242        m_childLayer->setIsDrawable(true);
     
    22492251    }
    22502252
    2251     virtual void didScroll(const IntSize& scrollDelta) OVERRIDE
    2252     {
    2253         m_reportedScrollAmount = scrollDelta;
     2253    virtual void didScroll() OVERRIDE
     2254    {
     2255        m_finalScrollPosition = m_childLayer->scrollPosition();
    22542256    }
    22552257
     
    22812283    virtual void afterTest() OVERRIDE
    22822284    {
    2283         EXPECT_EQ(m_scrollAmount, m_reportedScrollAmount);
     2285        EXPECT_EQ(IntPoint(m_scrollAmount), m_finalScrollPosition);
    22842286    }
    22852287
    22862288private:
    22872289    const IntSize m_scrollAmount;
    2288     IntSize m_reportedScrollAmount;
     2290    IntPoint m_finalScrollPosition;
    22892291    MockContentLayerChromiumClient m_mockDelegate;
    22902292    RefPtr<LayerChromium> m_childLayer;
  • trunk/Source/WebKit/chromium/tests/GraphicsLayerChromiumTest.cpp

    r126652 r127605  
    3434#include "Matrix3DTransformOperation.h"
    3535#include "RotateTransformOperation.h"
     36#include "ScrollableArea.h"
    3637#include "TranslateTransformOperation.h"
    3738#include "WebLayerTreeViewTestCommon.h"
     
    127128}
    128129
     130class FakeScrollableArea : public ScrollableArea {
     131public:
     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
     149private:
     150    IntPoint m_scrollPosition;
     151};
     152
     153TEST_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
    129164} // namespace
  • trunk/Source/WebKit/chromium/tests/WebLayerTest.cpp

    r126652 r127605  
    3535#include <public/WebFloatPoint.h>
    3636#include <public/WebFloatRect.h>
     37#include <public/WebLayerScrollClient.h>
    3738#include <public/WebLayerTreeView.h>
    3839#include <public/WebLayerTreeViewClient.h>
     
    173174}
    174175
     176class MockScrollClient : public WebLayerScrollClient {
     177public:
     178    MOCK_METHOD0(didScroll, void());
     179};
     180
     181TEST_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);
    175198}
     199
     200}
Note: See TracChangeset for help on using the changeset viewer.