Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Unified Diff: Source/core/page/scrolling/ScrollingCoordinator.cpp

Issue 234913005: Refactor wheel event handler registration in ScrollingCoordinator (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: More concise. Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/page/scrolling/ScrollingCoordinator.h ('k') | public/platform/WebLayer.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/page/scrolling/ScrollingCoordinator.cpp
diff --git a/Source/core/page/scrolling/ScrollingCoordinator.cpp b/Source/core/page/scrolling/ScrollingCoordinator.cpp
index f514094eb16320cb5ebf0f93dd3e08f741767306..8cde1e9869c73606b91e6b93a423e98add2416ee 100644
--- a/Source/core/page/scrolling/ScrollingCoordinator.cpp
+++ b/Source/core/page/scrolling/ScrollingCoordinator.cpp
@@ -647,15 +647,35 @@ void ScrollingCoordinator::willDestroyRenderLayer(RenderLayer* layer)
m_layersWithTouchRects.remove(layer);
}
-void ScrollingCoordinator::setWheelEventHandlerCount(unsigned count)
+void ScrollingCoordinator::updateHaveWheelEventHandlers()
{
- if (WebLayer* scrollLayer = toWebLayer(m_page->mainFrame()->view()->layerForScrolling()))
- scrollLayer->setHaveWheelEventHandlers(count > 0);
+ ASSERT(isMainThread());
+ ASSERT(m_page);
+
+ if (WebLayer* scrollLayer = toWebLayer(m_page->mainFrame()->view()->layerForScrolling())) {
+ unsigned wheelEventHandlerCount = 0;
+
+ for (LocalFrame* frame = m_page->mainFrame(); frame; frame = frame->tree().traverseNext()) {
+ wheelEventHandlerCount += WheelController::from(*frame->document())->wheelEventHandlerCount();
+ }
+
+ scrollLayer->setHaveWheelEventHandlers(wheelEventHandlerCount);
+ }
}
-void ScrollingCoordinator::recomputeWheelEventHandlerCountForFrameView(FrameView*)
+void ScrollingCoordinator::updateHaveScrollEventHandlers()
{
- setWheelEventHandlerCount(computeCurrentWheelEventHandlerCount());
+ ASSERT(isMainThread());
+ ASSERT(m_page);
+
+ // Currently the compositor only cares whether there are scroll handlers anywhere on the page
+ // instead on a per-layer basis. We therefore only update this information for the root
+ // scrolling layer.
+ if (WebLayer* scrollLayer = toWebLayer(m_page->mainFrame()->view()->layerForScrolling())) {
+ // TODO(skyostil): Hook this up.
+ bool haveHandlers = false;
+ scrollLayer->setHaveScrollEventHandlers(haveHandlers);
+ }
}
void ScrollingCoordinator::setShouldUpdateScrollLayerPositionOnMainThread(MainThreadScrollingReasons reasons)
@@ -819,26 +839,6 @@ void ScrollingCoordinator::computeTouchEventTargetRects(LayerHitTestRects& rects
accumulateDocumentTouchEventTargetRects(rects, document);
}
-unsigned ScrollingCoordinator::computeCurrentWheelEventHandlerCount()
-{
- unsigned wheelEventHandlerCount = 0;
-
- for (LocalFrame* frame = m_page->mainFrame(); frame; frame = frame->tree().traverseNext()) {
- if (frame->document())
- wheelEventHandlerCount += WheelController::from(*frame->document())->wheelEventHandlerCount();
- }
-
- return wheelEventHandlerCount;
-}
-
-void ScrollingCoordinator::frameViewWheelEventHandlerCountChanged(FrameView* frameView)
-{
- ASSERT(isMainThread());
- ASSERT(m_page);
-
- recomputeWheelEventHandlerCountForFrameView(frameView);
-}
-
void ScrollingCoordinator::frameViewHasSlowRepaintObjectsDidChange(FrameView* frameView)
{
ASSERT(isMainThread());
@@ -888,7 +888,8 @@ void ScrollingCoordinator::frameViewRootLayerDidChange(FrameView* frameView)
return;
notifyLayoutUpdated();
- recomputeWheelEventHandlerCountForFrameView(frameView);
+ updateHaveWheelEventHandlers();
+ updateHaveScrollEventHandlers();
}
#if OS(MACOSX)
« no previous file with comments | « Source/core/page/scrolling/ScrollingCoordinator.h ('k') | public/platform/WebLayer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698