Title: [98778] trunk/Source
Revision
98778
Author
[email protected]
Date
2011-10-28 16:30:07 -0700 (Fri, 28 Oct 2011)

Log Message

[chromium] Track wheel event handler registration and pass to input filter
https://bugs.webkit.org/show_bug.cgi?id=71078

Reviewed by Kenneth Russell.

Source/WebCore:

This propagates mouse wheel registration notifications to the compositor input filter. If there are any handlers
registered, which includes JS handlers and scrollable areas other than the main view, the input filter will pass
mouse wheel events to the widget. Otherwise when threaded compositing is enabled the input filter translates
wheel events into root layer scrolling.

Only changes behavior with an off-by-default flag enabled, so no tests.

* platform/graphics/chromium/cc/CCLayerTreeHost.cpp:
(WebCore::CCLayerTreeHost::CCLayerTreeHost):
(WebCore::CCLayerTreeHost::finishCommitOnImplThread):
(WebCore::CCLayerTreeHost::setHaveWheelEventHandlers):
* platform/graphics/chromium/cc/CCLayerTreeHost.h:
* platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp:
(WebCore::CCLayerTreeHostImpl::CCLayerTreeHostImpl):
(WebCore::CCLayerTreeHostImpl::haveWheelEventHandlers):
* platform/graphics/chromium/cc/CCLayerTreeHostImpl.h:
(WebCore::CCLayerTreeHostImpl::setHaveWheelEventHandlers):
* platform/graphics/chromium/cc/CCScrollController.h:

Source/WebKit/chromium:

Pushes mouse wheel event handler notifications to CCLayerTreeHost when compositing.

* src/ChromeClientImpl.cpp:
(WebKit::ChromeClientImpl::numWheelEventHandlersChanged):
* src/WebCompositorImpl.cpp:
(WebKit::WebCompositorImpl::handleInputEvent):
* src/WebViewImpl.cpp:
(WebKit::WebViewImpl::numberOfWheelEventHandlersChanged):
(WebKit::WebViewImpl::setIsAcceleratedCompositingActive):
* src/WebViewImpl.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (98777 => 98778)


--- trunk/Source/WebCore/ChangeLog	2011-10-28 23:27:32 UTC (rev 98777)
+++ trunk/Source/WebCore/ChangeLog	2011-10-28 23:30:07 UTC (rev 98778)
@@ -1,3 +1,29 @@
+2011-10-28  James Robinson  <[email protected]>
+
+        [chromium] Track wheel event handler registration and pass to input filter
+        https://bugs.webkit.org/show_bug.cgi?id=71078
+
+        Reviewed by Kenneth Russell.
+
+        This propagates mouse wheel registration notifications to the compositor input filter. If there are any handlers
+        registered, which includes JS handlers and scrollable areas other than the main view, the input filter will pass
+        mouse wheel events to the widget. Otherwise when threaded compositing is enabled the input filter translates
+        wheel events into root layer scrolling.
+
+        Only changes behavior with an off-by-default flag enabled, so no tests.
+
+        * platform/graphics/chromium/cc/CCLayerTreeHost.cpp:
+        (WebCore::CCLayerTreeHost::CCLayerTreeHost):
+        (WebCore::CCLayerTreeHost::finishCommitOnImplThread):
+        (WebCore::CCLayerTreeHost::setHaveWheelEventHandlers):
+        * platform/graphics/chromium/cc/CCLayerTreeHost.h:
+        * platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp:
+        (WebCore::CCLayerTreeHostImpl::CCLayerTreeHostImpl):
+        (WebCore::CCLayerTreeHostImpl::haveWheelEventHandlers):
+        * platform/graphics/chromium/cc/CCLayerTreeHostImpl.h:
+        (WebCore::CCLayerTreeHostImpl::setHaveWheelEventHandlers):
+        * platform/graphics/chromium/cc/CCScrollController.h:
+
 2011-10-28  Tim Horton  <[email protected]>
 
         Unreviewed build fix due to r98775.

Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.cpp (98777 => 98778)


--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.cpp	2011-10-28 23:27:32 UTC (rev 98777)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.cpp	2011-10-28 23:30:07 UTC (rev 98778)
@@ -56,6 +56,7 @@
     , m_rootLayer(rootLayer)
     , m_settings(settings)
     , m_visible(true)
+    , m_haveWheelEventHandlers(false)
 {
     CCMainThread::initialize();
     ASSERT(CCProxy::isMainThread());
@@ -128,6 +129,7 @@
     ASSERT(CCProxy::isImplThread());
     hostImpl->setSourceFrameNumber(frameNumber());
     hostImpl->setVisible(m_visible);
+    hostImpl->setHaveWheelEventHandlers(m_haveWheelEventHandlers);
     hostImpl->setZoomAnimatorTransform(m_zoomAnimatorTransform);
     hostImpl->setViewport(viewportSize());
 
@@ -236,6 +238,15 @@
     }
 }
 
+void CCLayerTreeHost::setHaveWheelEventHandlers(bool haveWheelEventHandlers)
+{
+    if (m_haveWheelEventHandlers == haveWheelEventHandlers)
+        return;
+    m_haveWheelEventHandlers = haveWheelEventHandlers;
+    m_proxy->setNeedsCommit();
+}
+
+
 void CCLayerTreeHost::loseCompositorContext(int numTimes)
 {
     m_proxy->loseCompositorContext(numTimes);

Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.h (98777 => 98778)


--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.h	2011-10-28 23:27:32 UTC (rev 98777)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.h	2011-10-28 23:30:07 UTC (rev 98778)
@@ -157,6 +157,7 @@
     TextureManager* contentsTextureManager() const;
 
     void setVisible(bool);
+    void setHaveWheelEventHandlers(bool);
 
     void updateLayers();
 
@@ -164,6 +165,7 @@
     void applyScrollDeltas(const CCScrollUpdateSet&);
     void startRateLimiter(GraphicsContext3D*);
     void stopRateLimiter(GraphicsContext3D*);
+
 protected:
     CCLayerTreeHost(CCLayerTreeHostClient*, PassRefPtr<LayerChromium> rootLayer, const CCSettings&);
     bool initialize();
@@ -198,6 +200,7 @@
     IntSize m_viewportSize;
     TransformationMatrix m_zoomAnimatorTransform;
     bool m_visible;
+    bool m_haveWheelEventHandlers;
     typedef HashMap<GraphicsContext3D*, RefPtr<RateLimiter> > RateLimiterMap;
     RateLimiterMap m_rateLimiters;
 };

Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp (98777 => 98778)


--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp	2011-10-28 23:27:32 UTC (rev 98777)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp	2011-10-28 23:30:07 UTC (rev 98778)
@@ -49,6 +49,7 @@
     , m_frameNumber(0)
     , m_settings(settings)
     , m_visible(true)
+    , m_haveWheelEventHandlers(false)
 {
     ASSERT(CCProxy::isImplThread());
 }
@@ -181,6 +182,11 @@
     m_client->setNeedsRedrawOnImplThread();
 }
 
+bool CCLayerTreeHostImpl::haveWheelEventHandlers()
+{
+    return m_haveWheelEventHandlers;
+}
+
 PassOwnPtr<CCScrollUpdateSet> CCLayerTreeHostImpl::processScrollDeltas()
 {
     OwnPtr<CCScrollUpdateSet> scrollInfo = adoptPtr(new CCScrollUpdateSet());

Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.h (98777 => 98778)


--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.h	2011-10-28 23:27:32 UTC (rev 98777)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.h	2011-10-28 23:30:07 UTC (rev 98778)
@@ -60,6 +60,7 @@
 
     // CCScrollController implementation
     virtual void scrollRootLayer(const IntSize&);
+    virtual bool haveWheelEventHandlers();
 
     // Virtual for testing
     virtual void beginCommit();
@@ -86,6 +87,7 @@
     void setRootLayer(PassRefPtr<CCLayerImpl>);
 
     void setVisible(bool);
+    void setHaveWheelEventHandlers(bool haveWheelEventHandlers) { m_haveWheelEventHandlers = haveWheelEventHandlers; }
 
     int sourceFrameNumber() const { return m_sourceFrameNumber; }
     void setSourceFrameNumber(int frameNumber) { m_sourceFrameNumber = frameNumber; }
@@ -110,6 +112,7 @@
     CCSettings m_settings;
     IntSize m_viewportSize;
     bool m_visible;
+    bool m_haveWheelEventHandlers;
 };
 
 };

Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCScrollController.h (98777 => 98778)


--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCScrollController.h	2011-10-28 23:27:32 UTC (rev 98777)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCScrollController.h	2011-10-28 23:30:07 UTC (rev 98778)
@@ -35,6 +35,7 @@
     WTF_MAKE_NONCOPYABLE(CCScrollController);
 public:
     virtual void scrollRootLayer(const IntSize&) = 0;
+    virtual bool haveWheelEventHandlers() = 0;
 
 protected:
     CCScrollController() { }

Modified: trunk/Source/WebKit/chromium/ChangeLog (98777 => 98778)


--- trunk/Source/WebKit/chromium/ChangeLog	2011-10-28 23:27:32 UTC (rev 98777)
+++ trunk/Source/WebKit/chromium/ChangeLog	2011-10-28 23:30:07 UTC (rev 98778)
@@ -1,3 +1,21 @@
+2011-10-28  James Robinson  <[email protected]>
+
+        [chromium] Track wheel event handler registration and pass to input filter
+        https://bugs.webkit.org/show_bug.cgi?id=71078
+
+        Reviewed by Kenneth Russell.
+
+        Pushes mouse wheel event handler notifications to CCLayerTreeHost when compositing.
+
+        * src/ChromeClientImpl.cpp:
+        (WebKit::ChromeClientImpl::numWheelEventHandlersChanged):
+        * src/WebCompositorImpl.cpp:
+        (WebKit::WebCompositorImpl::handleInputEvent):
+        * src/WebViewImpl.cpp:
+        (WebKit::WebViewImpl::numberOfWheelEventHandlersChanged):
+        (WebKit::WebViewImpl::setIsAcceleratedCompositingActive):
+        * src/WebViewImpl.h:
+
 2011-10-28  Jochen Eisinger  <[email protected]>
 
         Rename a number of methods mentioning _javascript_ to just Script instead

Modified: trunk/Source/WebKit/chromium/src/ChromeClientImpl.cpp (98777 => 98778)


--- trunk/Source/WebKit/chromium/src/ChromeClientImpl.cpp	2011-10-28 23:27:32 UTC (rev 98777)
+++ trunk/Source/WebKit/chromium/src/ChromeClientImpl.cpp	2011-10-28 23:30:07 UTC (rev 98778)
@@ -999,8 +999,7 @@
 
 void ChromeClientImpl::numWheelEventHandlersChanged(unsigned numberOfWheelHandlers)
 {
-    if (m_webView->client())
-        m_webView->client()->numberOfWheelEventHandlersChanged(numberOfWheelHandlers);
+    m_webView->numberOfWheelEventHandlersChanged(numberOfWheelHandlers);
 }
 
 } // namespace WebKit

Modified: trunk/Source/WebKit/chromium/src/WebCompositorImpl.cpp (98777 => 98778)


--- trunk/Source/WebKit/chromium/src/WebCompositorImpl.cpp	2011-10-28 23:27:32 UTC (rev 98777)
+++ trunk/Source/WebKit/chromium/src/WebCompositorImpl.cpp	2011-10-28 23:30:07 UTC (rev 98778)
@@ -116,7 +116,13 @@
 {
     ASSERT(CCProxy::isImplThread());
     ASSERT(m_client);
-    // FIXME: Do something interesting with this input event like inform our m_scrollController.
+
+    if (event.type == WebInputEvent::MouseWheel && !m_scrollController->haveWheelEventHandlers()) {
+        const WebMouseWheelEvent& wheelEvent = *static_cast<const WebMouseWheelEvent*>(&event);
+        m_scrollController->scrollRootLayer(IntSize(-wheelEvent.deltaX, -wheelEvent.deltaY));
+        m_client->didHandleInputEvent();
+        return;
+    }
     m_client->didNotHandleInputEvent(true /* sendToWidget */);
 }
 

Modified: trunk/Source/WebKit/chromium/src/WebViewImpl.cpp (98777 => 98778)


--- trunk/Source/WebKit/chromium/src/WebViewImpl.cpp	2011-10-28 23:27:32 UTC (rev 98777)
+++ trunk/Source/WebKit/chromium/src/WebViewImpl.cpp	2011-10-28 23:30:07 UTC (rev 98778)
@@ -781,6 +781,17 @@
 }
 #endif
 
+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
+}
+
 #if !OS(DARWIN)
 // Mac has no way to open a context menu based on a keyboard event.
 bool WebViewImpl::sendContextMenuEvent(const WebKeyboardEvent& event)
@@ -2612,6 +2623,7 @@
         m_nonCompositedContentHost = NonCompositedContentHost::create(WebViewImplContentPainter::create(this));
         m_layerTreeHost = CCLayerTreeHost::create(this, m_nonCompositedContentHost->topLevelRootLayer()->platformLayer(), ccSettings);
         if (m_layerTreeHost) {
+            m_layerTreeHost->setHaveWheelEventHandlers(m_haveWheelEventHandlers);
             updateLayerTreeViewport();
             m_client->didActivateCompositor(m_layerTreeHost->compositorIdentifier());
             m_isAcceleratedCompositingActive = true;

Modified: trunk/Source/WebKit/chromium/src/WebViewImpl.h (98777 => 98778)


--- trunk/Source/WebKit/chromium/src/WebViewImpl.h	2011-10-28 23:27:32 UTC (rev 98777)
+++ trunk/Source/WebKit/chromium/src/WebViewImpl.h	2011-10-28 23:30:07 UTC (rev 98778)
@@ -294,6 +294,8 @@
     bool charEvent(const WebKeyboardEvent&);
     bool touchEvent(const WebTouchEvent&);
 
+    void numberOfWheelEventHandlersChanged(unsigned);
+
     // Handles context menu events orignated via the the keyboard. These
     // include the VK_APPS virtual key and the Shift+F10 combine. Code is
     // based on the Webkit function bool WebView::handleContextMenuEvent(WPARAM
@@ -578,6 +580,7 @@
     // If true, the graphics context is being restored.
     bool m_recreatingGraphicsContext;
 #endif
+    bool m_haveWheelEventHandlers;
     static const WebInputEvent* m_currentInputEvent;
 
 #if ENABLE(INPUT_SPEECH)
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to