[chromium] Notify compositor of wheel event registration via ScrollingCoordinator
authorjamesr@google.com <jamesr@google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 24 Feb 2012 00:29:53 +0000 (00:29 +0000)
committerjamesr@google.com <jamesr@google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 24 Feb 2012 00:29:53 +0000 (00:29 +0000)
https://bugs.webkit.org/show_bug.cgi?id=79133

Reviewed by Dimitri Glazkov.

Source/WebCore:

This notifies the chromium compositor of changes to the number of wheel event handlers via ScrollingCoordinator
instead of through ChromeClient/WebViewImpl. This is the path we'll use for other properties in the future and
is more extensible for handling things other than the root layer.

Property behavior is covered by new unit tests in LayerChromiumTests and CCLayerTreeHostImplTest.

* page/scrolling/ScrollingCoordinator.cpp:
* page/scrolling/ScrollingCoordinator.h:
(WebCore):
(ScrollingCoordinator):
    Add a ScrollingCoordinatorPrivate so implementations can tack on additional data without having to #ifdef up
    ScrollingCoordinator.h/cpp
* page/scrolling/ScrollingCoordinatorNone.cpp:
(WebCore):
(WebCore::ScrollingCoordinator::~ScrollingCoordinator):
* page/scrolling/chromium/ScrollingCoordinatorChromium.cpp:
(ScrollingCoordinatorPrivate):
    ScrollingCoordinatorPrivate in the chromium implementation keeps a reference to the scroll layer.
(WebCore::ScrollingCoordinatorPrivate::ScrollingCoordinatorPrivate):
(WebCore::ScrollingCoordinatorPrivate::~ScrollingCoordinatorPrivate):
(WebCore::ScrollingCoordinatorPrivate::setScrollLayer):
(WebCore::ScrollingCoordinatorPrivate::scrollLayer):
(WebCore):
(WebCore::ScrollingCoordinator::create):
(WebCore::ScrollingCoordinator::~ScrollingCoordinator):
(WebCore::ScrollingCoordinator::frameViewHorizontalScrollbarLayerDidChange):
(WebCore::ScrollingCoordinator::frameViewVerticalScrollbarLayerDidChange):
(WebCore::ScrollingCoordinator::setScrollLayer):
(WebCore::ScrollingCoordinator::setNonFastScrollableRegion):
(WebCore::ScrollingCoordinator::setScrollParameters):
(WebCore::ScrollingCoordinator::setWheelEventHandlerCount):
(WebCore::ScrollingCoordinator::setShouldUpdateScrollLayerPositionOnMainThread):
* page/scrolling/mac/ScrollingCoordinatorMac.mm:
(WebCore):
(WebCore::ScrollingCoordinator::~ScrollingCoordinator):
* platform/graphics/chromium/LayerChromium.cpp:
(WebCore::LayerChromium::LayerChromium):
(WebCore::LayerChromium::setHaveWheelEventHandlers):
(WebCore):
(WebCore::LayerChromium::pushPropertiesTo):
* platform/graphics/chromium/LayerChromium.h:
(LayerChromium):
* platform/graphics/chromium/cc/CCInputHandler.h:
* platform/graphics/chromium/cc/CCLayerImpl.cpp:
(WebCore::CCLayerImpl::CCLayerImpl):
* platform/graphics/chromium/cc/CCLayerImpl.h:
(WebCore::CCLayerImpl::haveWheelEventHandlers):
(WebCore::CCLayerImpl::setHaveWheelEventHandlers):
(CCLayerImpl):
* platform/graphics/chromium/cc/CCLayerTreeHost.cpp:
(WebCore::CCLayerTreeHost::CCLayerTreeHost):
(WebCore::CCLayerTreeHost::finishCommitOnImplThread):
* platform/graphics/chromium/cc/CCLayerTreeHost.h:
(CCLayerTreeHost):
* platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp:
(WebCore::CCLayerTreeHostImpl::CCLayerTreeHostImpl):
(WebCore::CCLayerTreeHostImpl::scrollBegin):
* platform/graphics/chromium/cc/CCLayerTreeHostImpl.h:
(CCLayerTreeHostImpl):

Source/WebKit/chromium:

Rips out old wheel event notification and adds unit tests for new LayerChromium property.

* src/NonCompositedContentHost.cpp:
(WebKit::NonCompositedContentHost::setViewport):
* src/WebCompositorInputHandlerImpl.cpp:
(WebKit::WebCompositorInputHandlerImpl::handleInputEvent):
* src/WebViewImpl.cpp:
(WebKit::WebViewImpl::numberOfWheelEventHandlersChanged):
(WebKit::WebViewImpl::setIsAcceleratedCompositingActive):
* src/WebViewImpl.h:
* tests/CCLayerTreeHostImplTest.cpp:
(WebKit::TEST_F):
(WebKit):
* tests/LayerChromiumTest.cpp:
* tests/WebCompositorInputHandlerImplTest.cpp:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@108698 268f45cc-cd09-0410-ab3c-d52691b4dbfc

22 files changed:
Source/WebCore/ChangeLog
Source/WebCore/page/scrolling/ScrollingCoordinator.cpp
Source/WebCore/page/scrolling/ScrollingCoordinator.h
Source/WebCore/page/scrolling/ScrollingCoordinatorNone.cpp
Source/WebCore/page/scrolling/chromium/ScrollingCoordinatorChromium.cpp
Source/WebCore/page/scrolling/mac/ScrollingCoordinatorMac.mm
Source/WebCore/platform/graphics/chromium/LayerChromium.cpp
Source/WebCore/platform/graphics/chromium/LayerChromium.h
Source/WebCore/platform/graphics/chromium/cc/CCInputHandler.h
Source/WebCore/platform/graphics/chromium/cc/CCLayerImpl.cpp
Source/WebCore/platform/graphics/chromium/cc/CCLayerImpl.h
Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.cpp
Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.h
Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp
Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.h
Source/WebKit/chromium/ChangeLog
Source/WebKit/chromium/src/WebCompositorInputHandlerImpl.cpp
Source/WebKit/chromium/src/WebViewImpl.cpp
Source/WebKit/chromium/src/WebViewImpl.h
Source/WebKit/chromium/tests/CCLayerTreeHostImplTest.cpp
Source/WebKit/chromium/tests/LayerChromiumTest.cpp
Source/WebKit/chromium/tests/WebCompositorInputHandlerImplTest.cpp

index 94ed90e..741c394 100644 (file)
@@ -1,3 +1,70 @@
+2012-02-21  James Robinson  <jamesr@chromium.org>
+
+        [chromium] Notify compositor of wheel event registration via ScrollingCoordinator
+        https://bugs.webkit.org/show_bug.cgi?id=79133
+
+        Reviewed by Dimitri Glazkov.
+
+        This notifies the chromium compositor of changes to the number of wheel event handlers via ScrollingCoordinator
+        instead of through ChromeClient/WebViewImpl. This is the path we'll use for other properties in the future and
+        is more extensible for handling things other than the root layer.
+
+        Property behavior is covered by new unit tests in LayerChromiumTests and CCLayerTreeHostImplTest.
+
+        * page/scrolling/ScrollingCoordinator.cpp:
+        * page/scrolling/ScrollingCoordinator.h:
+        (WebCore):
+        (ScrollingCoordinator):
+            Add a ScrollingCoordinatorPrivate so implementations can tack on additional data without having to #ifdef up
+            ScrollingCoordinator.h/cpp
+        * page/scrolling/ScrollingCoordinatorNone.cpp:
+        (WebCore):
+        (WebCore::ScrollingCoordinator::~ScrollingCoordinator):
+        * page/scrolling/chromium/ScrollingCoordinatorChromium.cpp:
+        (ScrollingCoordinatorPrivate):
+            ScrollingCoordinatorPrivate in the chromium implementation keeps a reference to the scroll layer.
+        (WebCore::ScrollingCoordinatorPrivate::ScrollingCoordinatorPrivate):
+        (WebCore::ScrollingCoordinatorPrivate::~ScrollingCoordinatorPrivate):
+        (WebCore::ScrollingCoordinatorPrivate::setScrollLayer):
+        (WebCore::ScrollingCoordinatorPrivate::scrollLayer):
+        (WebCore):
+        (WebCore::ScrollingCoordinator::create):
+        (WebCore::ScrollingCoordinator::~ScrollingCoordinator):
+        (WebCore::ScrollingCoordinator::frameViewHorizontalScrollbarLayerDidChange):
+        (WebCore::ScrollingCoordinator::frameViewVerticalScrollbarLayerDidChange):
+        (WebCore::ScrollingCoordinator::setScrollLayer):
+        (WebCore::ScrollingCoordinator::setNonFastScrollableRegion):
+        (WebCore::ScrollingCoordinator::setScrollParameters):
+        (WebCore::ScrollingCoordinator::setWheelEventHandlerCount):
+        (WebCore::ScrollingCoordinator::setShouldUpdateScrollLayerPositionOnMainThread):
+        * page/scrolling/mac/ScrollingCoordinatorMac.mm:
+        (WebCore):
+        (WebCore::ScrollingCoordinator::~ScrollingCoordinator):
+        * platform/graphics/chromium/LayerChromium.cpp:
+        (WebCore::LayerChromium::LayerChromium):
+        (WebCore::LayerChromium::setHaveWheelEventHandlers):
+        (WebCore):
+        (WebCore::LayerChromium::pushPropertiesTo):
+        * platform/graphics/chromium/LayerChromium.h:
+        (LayerChromium):
+        * platform/graphics/chromium/cc/CCInputHandler.h:
+        * platform/graphics/chromium/cc/CCLayerImpl.cpp:
+        (WebCore::CCLayerImpl::CCLayerImpl):
+        * platform/graphics/chromium/cc/CCLayerImpl.h:
+        (WebCore::CCLayerImpl::haveWheelEventHandlers):
+        (WebCore::CCLayerImpl::setHaveWheelEventHandlers):
+        (CCLayerImpl):
+        * platform/graphics/chromium/cc/CCLayerTreeHost.cpp:
+        (WebCore::CCLayerTreeHost::CCLayerTreeHost):
+        (WebCore::CCLayerTreeHost::finishCommitOnImplThread):
+        * platform/graphics/chromium/cc/CCLayerTreeHost.h:
+        (CCLayerTreeHost):
+        * platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp:
+        (WebCore::CCLayerTreeHostImpl::CCLayerTreeHostImpl):
+        (WebCore::CCLayerTreeHostImpl::scrollBegin):
+        * platform/graphics/chromium/cc/CCLayerTreeHostImpl.h:
+        (CCLayerTreeHostImpl):
+
 2012-02-23  No'am Rosenthal  <noam.rosenthal@nokia.com>
 
         [Qt][WK2] Clipping is broken
index 8aec61e..5c14d99 100644 (file)
@@ -61,14 +61,6 @@ ScrollingCoordinator::ScrollingCoordinator(Page* page)
 {
 }
 
-ScrollingCoordinator::~ScrollingCoordinator()
-{
-    ASSERT(!m_page);
-#if ENABLE(THREADED_SCROLLING)
-    ASSERT(!m_scrollingTree);
-#endif
-}
-
 void ScrollingCoordinator::pageDestroyed()
 {
     ASSERT(m_page);
index 8c0cab1..00b289f 100644 (file)
@@ -48,6 +48,7 @@ class GraphicsLayer;
 class Page;
 class PlatformWheelEvent;
 class Region;
+class ScrollingCoordinatorPrivate;
 class ScrollingTreeState;
 
 #if ENABLE(THREADED_SCROLLING)
@@ -133,6 +134,8 @@ private:
     RefPtr<ScrollingTree> m_scrollingTree;
     Timer<ScrollingCoordinator> m_scrollingTreeStateCommitterTimer;
 #endif
+
+    ScrollingCoordinatorPrivate* m_private;
 };
 
 } // namespace WebCore
index 9ba1794..d06d6bb 100644 (file)
 
 namespace WebCore {
 
+class ScrollingCoordinatorPrivate {
+};
+
 #if !ENABLE(THREADED_SCROLLING)
 PassRefPtr<ScrollingCoordinator> ScrollingCoordinator::create(Page* page)
 {
     return adoptRef(new ScrollingCoordinator(page));
 }
 
+ScrollingCoordinator::~ScrollingCoordinator()
+{
+    ASSERT(!m_page);
+}
+
 void ScrollingCoordinator::frameViewHorizontalScrollbarLayerDidChange(FrameView*, GraphicsLayer*)
 {
 }
index 890e098..e590138 100644 (file)
 
 #include "ScrollingCoordinator.h"
 
+#include "LayerChromium.h"
+#include "Region.h"
+
 namespace WebCore {
 
+class ScrollingCoordinatorPrivate {
+WTF_MAKE_NONCOPYABLE(ScrollingCoordinatorPrivate);
+public:
+    ScrollingCoordinatorPrivate() { }
+    ~ScrollingCoordinatorPrivate() { }
+
+    void setScrollLayer(LayerChromium* layer) { m_scrollLayer = layer; }
+    LayerChromium* scrollLayer() const { return m_scrollLayer.get(); }
+
+private:
+    RefPtr<LayerChromium> m_scrollLayer;
+};
+
 PassRefPtr<ScrollingCoordinator> ScrollingCoordinator::create(Page* page)
 {
-    return adoptRef(new ScrollingCoordinator(page));
+    RefPtr<ScrollingCoordinator> coordinator(adoptRef(new ScrollingCoordinator(page)));
+    coordinator->m_private = new ScrollingCoordinatorPrivate;
+    return coordinator.release();
+}
+
+ScrollingCoordinator::~ScrollingCoordinator()
+{
+    ASSERT(!m_page);
+    delete m_private;
 }
 
 void ScrollingCoordinator::frameViewHorizontalScrollbarLayerDidChange(FrameView*, GraphicsLayer* horizontalScrollbarLayer)
@@ -46,7 +70,7 @@ void ScrollingCoordinator::frameViewVerticalScrollbarLayerDidChange(FrameView*,
 
 void ScrollingCoordinator::setScrollLayer(GraphicsLayer* scrollLayer)
 {
-    // FIXME: Implement!
+    m_private->setScrollLayer(scrollLayer ? scrollLayer->platformLayer() : 0);
 }
 
 void ScrollingCoordinator::setNonFastScrollableRegion(const Region&)
@@ -61,12 +85,13 @@ void ScrollingCoordinator::setScrollParameters(ScrollElasticity horizontalScroll
     // FIXME: Implement!
 }
 
-void ScrollingCoordinator::setWheelEventHandlerCount(unsigned)
+void ScrollingCoordinator::setWheelEventHandlerCount(unsigned wheelEventHandlerCount)
 {
-    // FIXME: Implement!
+    if (LayerChromium* layer = m_private->scrollLayer())
+        layer->setHaveWheelEventHandlers(wheelEventHandlerCount > 0);
 }
 
-void ScrollingCoordinator::setShouldUpdateScrollLayerPositionOnMainThread(bool)
+void ScrollingCoordinator::setShouldUpdateScrollLayerPositionOnMainThread(bool should)
 {
     // FIXME: Implement!
 }
index 37e2677..94335b0 100644 (file)
 
 namespace WebCore {
 
+class ScrollingCoordinatorPrivate {
+};
+
 PassRefPtr<ScrollingCoordinator> ScrollingCoordinator::create(Page* page)
 {
     return adoptRef(new ScrollingCoordinator(page));
 }
 
+ScrollingCoordinator::~ScrollingCoordinator()
+{
+    ASSERT(!m_page);
+    ASSERT(!m_scrollingTree);
+}
 
 void ScrollingCoordinator::frameViewHorizontalScrollbarLayerDidChange(FrameView* frameView, GraphicsLayer*)
 {
index 533d19c..b59a6a1 100644 (file)
@@ -62,6 +62,7 @@ LayerChromium::LayerChromium()
     , m_parent(0)
     , m_layerAnimationController(CCLayerAnimationController::create())
     , m_scrollable(false)
+    , m_haveWheelEventHandlers(false)
     , m_anchorPoint(0.5, 0.5)
     , m_backgroundColor(0, 0, 0, 0)
     , m_backgroundCoversViewport(false)
@@ -412,6 +413,14 @@ void LayerChromium::setScrollable(bool scrollable)
     setNeedsCommit();
 }
 
+void LayerChromium::setHaveWheelEventHandlers(bool haveWheelEventHandlers)
+{
+    if (m_haveWheelEventHandlers == haveWheelEventHandlers)
+        return;
+    m_haveWheelEventHandlers = haveWheelEventHandlers;
+    setNeedsCommit();
+}
+
 void LayerChromium::setDoubleSided(bool doubleSided)
 {
     if (m_doubleSided == doubleSided)
@@ -466,6 +475,7 @@ void LayerChromium::pushPropertiesTo(CCLayerImpl* layer)
     layer->setIsNonCompositedContent(m_isNonCompositedContent);
     layer->setMasksToBounds(m_masksToBounds);
     layer->setScrollable(m_scrollable);
+    layer->setHaveWheelEventHandlers(m_haveWheelEventHandlers);
     layer->setName(m_name);
     layer->setOpaque(m_opaque);
     layer->setOpacity(m_opacity);
index 92fb013..2f7cf68 100644 (file)
@@ -131,7 +131,7 @@ public:
     const IntPoint& scrollPosition() const { return m_scrollPosition; }
 
     void setScrollable(bool);
-    bool scrollable() const { return m_scrollable; }
+    void setHaveWheelEventHandlers(bool);
 
     IntSize scrollDelta() const { return IntSize(); }
 
@@ -275,6 +275,7 @@ private:
     IntRect m_visibleLayerRect;
     IntPoint m_scrollPosition;
     bool m_scrollable;
+    bool m_haveWheelEventHandlers;
     FloatPoint m_position;
     FloatPoint m_anchorPoint;
     Color m_backgroundColor;
index 057d79b..6c05599 100644 (file)
@@ -46,13 +46,14 @@ public:
     virtual void setNeedsRedraw() = 0;
 
     enum ScrollStatus { ScrollFailed, ScrollStarted, ScrollIgnored };
+    enum ScrollInputType { Gesture, Wheel };
 
     // Attempt to start scrolling a layer at a given point in window
     // coordinates. Returns ScrollStarted if the layer at the coordinates can
     // be scrolled, ScrollFailed if the scroll event should instead be
     // delegated to the main thread, or ScrollIgnored if there is nothing to
     // be scrolled at the given coordinates.
-    virtual ScrollStatus scrollBegin(const IntPoint&) = 0;
+    virtual ScrollStatus scrollBegin(const IntPoint&, ScrollInputType) = 0;
 
     // Scroll the layer selected with scrollBegin(). If there is no room to
     // move the layer in the requested direction, its first ancestor layer that
@@ -64,7 +65,6 @@ public:
     // called if scrollBegin() returned ScrollStarted.
     virtual void scrollEnd() = 0;
 
-    virtual bool haveWheelEventHandlers() = 0;
     virtual void pinchGestureBegin() = 0;
     virtual void pinchGestureUpdate(float magnifyDelta, const IntPoint& anchor) = 0;
     virtual void pinchGestureEnd() = 0;
index d4babe2..0589dca 100644 (file)
@@ -46,6 +46,7 @@ CCLayerImpl::CCLayerImpl(int id)
     , m_anchorPoint(0.5, 0.5)
     , m_anchorPointZ(0)
     , m_scrollable(false)
+    , m_haveWheelEventHandlers(false)
     , m_backgroundCoversViewport(false)
     , m_doubleSided(true)
     , m_layerPropertyChanged(false)
index d0d5241..c7a4f08 100644 (file)
@@ -181,6 +181,9 @@ public:
     bool scrollable() const { return m_scrollable; }
     void setScrollable(bool scrollable) { m_scrollable = scrollable; }
 
+    bool haveWheelEventHandlers() const { return m_haveWheelEventHandlers; }
+    void setHaveWheelEventHandlers(bool haveWheelEventHandlers) { m_haveWheelEventHandlers = haveWheelEventHandlers; }
+
     const IntRect& visibleLayerRect() const { return m_visibleLayerRect; }
     void setVisibleLayerRect(const IntRect& visibleLayerRect) { m_visibleLayerRect = visibleLayerRect; }
 
@@ -245,6 +248,7 @@ private:
     IntSize m_contentBounds;
     IntPoint m_scrollPosition;
     bool m_scrollable;
+    bool m_haveWheelEventHandlers;
     Color m_backgroundColor;
     bool m_backgroundCoversViewport;
 
index ea17e8c..501ee17 100644 (file)
@@ -68,7 +68,6 @@ CCLayerTreeHost::CCLayerTreeHost(CCLayerTreeHostClient* client, const CCSettings
     , m_layerRendererInitialized(false)
     , m_settings(settings)
     , m_visible(true)
-    , m_haveWheelEventHandlers(false)
     , m_pageScaleFactor(1)
     , m_minPageScaleFactor(1)
     , m_maxPageScaleFactor(1)
@@ -179,7 +178,6 @@ void CCLayerTreeHost::finishCommitOnImplThread(CCLayerTreeHostImpl* hostImpl)
         hostImpl->setRootLayer(0);
 
     hostImpl->setSourceFrameNumber(frameNumber());
-    hostImpl->setHaveWheelEventHandlers(m_haveWheelEventHandlers);
     hostImpl->setViewportSize(viewportSize());
     hostImpl->setPageScaleFactorAndLimits(m_pageScaleFactor, m_minPageScaleFactor, m_maxPageScaleFactor);
 
@@ -351,14 +349,6 @@ void CCLayerTreeHost::didBecomeInvisibleOnImplThread(CCLayerTreeHostImpl* hostIm
         hostImpl->setRootLayer(0);
 }
 
-void CCLayerTreeHost::setHaveWheelEventHandlers(bool haveWheelEventHandlers)
-{
-    if (m_haveWheelEventHandlers == haveWheelEventHandlers)
-        return;
-    m_haveWheelEventHandlers = haveWheelEventHandlers;
-    m_proxy->setNeedsCommit();
-}
-
 void CCLayerTreeHost::startPageScaleAnimation(const IntSize& targetPosition, bool useAnchor, float scale, double durationSec)
 {
     m_proxy->startPageScaleAnimation(targetPosition, useAnchor, scale, durationSec);
index 4ed8da9..1662f50 100644 (file)
@@ -185,8 +185,6 @@ public:
     bool visible() const { return m_visible; }
     void setVisible(bool);
 
-    void setHaveWheelEventHandlers(bool);
-
     // Returns false if we should abort this frame due to initialization failure.
     bool updateLayers();
 
@@ -240,7 +238,6 @@ private:
 
     IntSize m_viewportSize;
     bool m_visible;
-    bool m_haveWheelEventHandlers;
     typedef HashMap<GraphicsContext3D*, RefPtr<RateLimiter> > RateLimiterMap;
     RateLimiterMap m_rateLimiters;
 
index ce31951..4b3242d 100644 (file)
@@ -52,7 +52,6 @@ CCLayerTreeHostImpl::CCLayerTreeHostImpl(const CCSettings& settings, CCLayerTree
     , m_frameNumber(0)
     , m_settings(settings)
     , m_visible(true)
-    , m_haveWheelEventHandlers(false)
     , m_pageScale(1)
     , m_pageScaleDelta(1)
     , m_sentPageScaleDelta(1)
@@ -486,11 +485,18 @@ void CCLayerTreeHostImpl::setNeedsRedraw()
     m_client->setNeedsRedrawOnImplThread();
 }
 
-CCInputHandlerClient::ScrollStatus CCLayerTreeHostImpl::scrollBegin(const IntPoint&)
+CCInputHandlerClient::ScrollStatus CCLayerTreeHostImpl::scrollBegin(const IntPoint& point, CCInputHandlerClient::ScrollInputType type)
 {
     // TODO: Check for scrollable sublayers.
-    if (!m_scrollLayerImpl || !m_scrollLayerImpl->scrollable())
+    if (!m_scrollLayerImpl || !m_scrollLayerImpl->scrollable()) {
+        TRACE_EVENT("scrollBegin Ignored no scrollable", this, 0);
         return ScrollIgnored;
+    }
+
+    if (type == CCInputHandlerClient::Wheel && m_scrollLayerImpl->haveWheelEventHandlers()) {
+        TRACE_EVENT("scrollBegin Failed wheelEventHandlers", this, 0);
+        return ScrollFailed;
+    }
 
     return ScrollStarted;
 }
@@ -510,11 +516,6 @@ void CCLayerTreeHostImpl::scrollEnd()
 {
 }
 
-bool CCLayerTreeHostImpl::haveWheelEventHandlers()
-{
-    return m_haveWheelEventHandlers;
-}
-
 void CCLayerTreeHostImpl::pinchGestureBegin()
 {
     m_pinchGestureActive = true;
index 69a8a9a..e438db0 100644 (file)
@@ -62,10 +62,9 @@ public:
 
     // CCInputHandlerClient implementation
     virtual void setNeedsRedraw();
-    virtual CCInputHandlerClient::ScrollStatus scrollBegin(const IntPoint&);
+    virtual CCInputHandlerClient::ScrollStatus scrollBegin(const IntPoint&, CCInputHandlerClient::ScrollInputType);
     virtual void scrollBy(const IntSize&);
     virtual void scrollEnd();
-    virtual bool haveWheelEventHandlers();
     virtual void pinchGestureBegin();
     virtual void pinchGestureUpdate(float, const IntPoint&);
     virtual void pinchGestureEnd();
@@ -101,7 +100,6 @@ public:
 
     bool visible() const { return m_visible; }
     void setVisible(bool);
-    void setHaveWheelEventHandlers(bool haveWheelEventHandlers) { m_haveWheelEventHandlers = haveWheelEventHandlers; }
 
     int sourceFrameNumber() const { return m_sourceFrameNumber; }
     void setSourceFrameNumber(int frameNumber) { m_sourceFrameNumber = frameNumber; }
@@ -160,7 +158,6 @@ private:
     CCSettings m_settings;
     IntSize m_viewportSize;
     bool m_visible;
-    bool m_haveWheelEventHandlers;
 
     float m_pageScale;
     float m_pageScaleDelta;
index c4acf03..b9c5c14 100644 (file)
@@ -1,3 +1,26 @@
+2012-02-21  James Robinson  <jamesr@chromium.org>
+
+        [chromium] Notify compositor of wheel event registration via ScrollingCoordinator
+        https://bugs.webkit.org/show_bug.cgi?id=79133
+
+        Reviewed by Dimitri Glazkov.
+
+        Rips out old wheel event notification and adds unit tests for new LayerChromium property.
+
+        * src/NonCompositedContentHost.cpp:
+        (WebKit::NonCompositedContentHost::setViewport):
+        * src/WebCompositorInputHandlerImpl.cpp:
+        (WebKit::WebCompositorInputHandlerImpl::handleInputEvent):
+        * src/WebViewImpl.cpp:
+        (WebKit::WebViewImpl::numberOfWheelEventHandlersChanged):
+        (WebKit::WebViewImpl::setIsAcceleratedCompositingActive):
+        * src/WebViewImpl.h:
+        * tests/CCLayerTreeHostImplTest.cpp:
+        (WebKit::TEST_F):
+        (WebKit):
+        * tests/LayerChromiumTest.cpp:
+        * tests/WebCompositorInputHandlerImplTest.cpp:
+
 2012-02-23  Adrienne Walker  <enne@google.com>
 
         Unreviewed, rolling out r108666.
index 40c151d..397308b 100644 (file)
@@ -121,9 +121,9 @@ void WebCompositorInputHandlerImpl::handleInputEvent(const WebInputEvent& event)
     ASSERT(CCProxy::isImplThread());
     ASSERT(m_client);
 
-    if (event.type == WebInputEvent::MouseWheel && !m_inputHandlerClient->haveWheelEventHandlers()) {
+    if (event.type == WebInputEvent::MouseWheel) {
         const WebMouseWheelEvent& wheelEvent = *static_cast<const WebMouseWheelEvent*>(&event);
-        CCInputHandlerClient::ScrollStatus scrollStatus = m_inputHandlerClient->scrollBegin(IntPoint(wheelEvent.x, wheelEvent.y));
+        CCInputHandlerClient::ScrollStatus scrollStatus = m_inputHandlerClient->scrollBegin(IntPoint(wheelEvent.x, wheelEvent.y), CCInputHandlerClient::Wheel);
         switch (scrollStatus) {
         case CCInputHandlerClient::ScrollStarted:
             m_inputHandlerClient->scrollBy(IntSize(-wheelEvent.deltaX, -wheelEvent.deltaY));
@@ -143,7 +143,7 @@ void WebCompositorInputHandlerImpl::handleInputEvent(const WebInputEvent& event)
         m_expectScrollUpdateEnd = true;
 #endif
         const WebGestureEvent& gestureEvent = *static_cast<const WebGestureEvent*>(&event);
-        CCInputHandlerClient::ScrollStatus scrollStatus = m_inputHandlerClient->scrollBegin(IntPoint(gestureEvent.x, gestureEvent.y));
+        CCInputHandlerClient::ScrollStatus scrollStatus = m_inputHandlerClient->scrollBegin(IntPoint(gestureEvent.x, gestureEvent.y), CCInputHandlerClient::Gesture);
         switch (scrollStatus) {
         case CCInputHandlerClient::ScrollStarted:
             m_scrollStarted = true;
index 9c514ba..ea4c263 100644 (file)
@@ -948,13 +948,8 @@ void WebViewImpl::computeScaleAndScrollForHitRect(const WebRect& hitRect, AutoZo
 
 void WebViewImpl::numberOfWheelEventHandlersChanged(unsigned numberOfWheelHandlers)
 {
-    m_haveWheelEventHandlers = numberOfWheelHandlers > 0;
     if (m_client)
         m_client->numberOfWheelEventHandlersChanged(numberOfWheelHandlers);
-#if USE(ACCELERATED_COMPOSITING)
-    if (m_layerTreeHost)
-        m_layerTreeHost->setHaveWheelEventHandlers(m_haveWheelEventHandlers);
-#endif
 }
 
 void WebViewImpl::numberOfTouchEventHandlersChanged(unsigned numberOfTouchHandlers)
@@ -3178,7 +3173,6 @@ void WebViewImpl::setIsAcceleratedCompositingActive(bool active)
 
         m_layerTreeHost = CCLayerTreeHost::create(this, ccSettings);
         if (m_layerTreeHost) {
-            m_layerTreeHost->setHaveWheelEventHandlers(m_haveWheelEventHandlers);
             m_layerTreeHost->setPageScaleFactorAndLimits(pageScaleFactor(), m_minimumPageScaleFactor, m_maximumPageScaleFactor);
             updateLayerTreeViewport();
             m_client->didActivateCompositor(m_layerTreeHost->compositorIdentifier());
index e8d53bb..3558c1d 100644 (file)
@@ -692,7 +692,6 @@ private:
     // If true, the graphics context is being restored.
     bool m_recreatingGraphicsContext;
 #endif
-    bool m_haveWheelEventHandlers;
     static const WebInputEvent* m_currentInputEvent;
 
 #if ENABLE(INPUT_SPEECH)
index 5b7f502..695207d 100644 (file)
@@ -165,13 +165,28 @@ TEST_F(CCLayerTreeHostImplTest, scrollRootCallsCommitAndRedraw)
     root->setScrollPosition(IntPoint(0, 0));
     root->setMaxScrollPosition(IntSize(100, 100));
     m_hostImpl->setRootLayer(root);
-    EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0)), CCInputHandlerClient::ScrollStarted);
+    EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0), CCInputHandlerClient::Wheel), CCInputHandlerClient::ScrollStarted);
     m_hostImpl->scrollBy(IntSize(0, 10));
     m_hostImpl->scrollEnd();
     EXPECT_TRUE(m_didRequestRedraw);
     EXPECT_TRUE(m_didRequestCommit);
 }
 
+TEST_F(CCLayerTreeHostImplTest, wheelEventHandlers)
+{
+    RefPtr<CCLayerImpl> root = CCLayerImpl::create(0);
+    root->setScrollable(true);
+    root->setScrollPosition(IntPoint(0, 0));
+    root->setMaxScrollPosition(IntSize(100, 100));
+    m_hostImpl->setRootLayer(root);
+    root->setHaveWheelEventHandlers(true);
+    // With registered event handlers, wheel scrolls have to go to the main thread.
+    EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0), CCInputHandlerClient::Wheel), CCInputHandlerClient::ScrollFailed);
+
+    // But gesture scrolls can still be handled.
+    EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0), CCInputHandlerClient::Gesture), CCInputHandlerClient::ScrollStarted);
+}
+
 TEST_F(CCLayerTreeHostImplTest, pinchGesture)
 {
     setupScrollAndContentsLayers(IntSize(100, 100));
index d555a6b..2e9ca96 100644 (file)
@@ -515,6 +515,7 @@ TEST_F(LayerChromiumTest, checkPropertyChangeCausesCorrectBehavior)
     EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setReplicaLayer(dummyLayer.get()));
     EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setSublayerTransform(TransformationMatrix(0, 0, 0, 0, 0, 0)));
     EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setScrollable(true));
+    EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setHaveWheelEventHandlers(true));
     EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setScrollPosition(IntPoint(10, 10)));
     EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setTransform(TransformationMatrix(0, 0, 0, 0, 0, 0)));
     EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setDoubleSided(false));
index ad58105..459255e 100644 (file)
@@ -67,14 +67,13 @@ public:
 
 private:
     virtual void setNeedsRedraw() OVERRIDE { }
-    virtual ScrollStatus scrollBegin(const WebCore::IntPoint&) OVERRIDE
+    virtual ScrollStatus scrollBegin(const WebCore::IntPoint&, WebCore::CCInputHandlerClient::ScrollInputType) 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
     {
         m_pinchStarted = true;