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

Unified Diff: third_party/WebKit/Source/core/page/scrolling/RootScrollerController.cpp

Issue 2113483002: Make RootScroller set the outer viewport scroll layer in the compositor (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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
Index: third_party/WebKit/Source/core/page/scrolling/RootScrollerController.cpp
diff --git a/third_party/WebKit/Source/core/page/scrolling/RootScrollerController.cpp b/third_party/WebKit/Source/core/page/scrolling/RootScrollerController.cpp
index 3822b25a1edc66b69aaa002e0c44ec1a3e61c19e..ef09315de54f4a6743a688fbee2f27d38514884f 100644
--- a/third_party/WebKit/Source/core/page/scrolling/RootScrollerController.cpp
+++ b/third_party/WebKit/Source/core/page/scrolling/RootScrollerController.cpp
@@ -9,11 +9,14 @@
#include "core/frame/FrameHost.h"
#include "core/frame/FrameView.h"
#include "core/frame/TopControls.h"
+#include "core/frame/VisualViewport.h"
#include "core/layout/LayoutBox.h"
+#include "core/page/ChromeClient.h"
#include "core/page/Page.h"
#include "core/page/scrolling/OverscrollController.h"
#include "core/page/scrolling/ViewportScrollCallback.h"
#include "core/paint/PaintLayerScrollableArea.h"
+#include "platform/graphics/GraphicsLayer.h"
#include "platform/scroll/ScrollableArea.h"
namespace blink {
@@ -82,6 +85,7 @@ ViewportScrollCallback* RootScrollerController::createViewportApplyScroll(
RootScrollerController::RootScrollerController(Document& document, ViewportScrollCallback* applyScrollCallback)
: m_document(&document)
, m_viewportApplyScroll(applyScrollCallback)
+ , m_changedSinceLastCompositingUpdate(false)
{
}
@@ -128,6 +132,8 @@ void RootScrollerController::updateEffectiveRootScroller()
moveViewportApplyScroll(newEffectiveRootScroller);
m_effectiveRootScroller = newEffectiveRootScroller;
+
+ m_changedSinceLastCompositingUpdate = true;
}
void RootScrollerController::moveViewportApplyScroll(Element* target)
@@ -156,6 +162,44 @@ void RootScrollerController::moveViewportApplyScroll(Element* target)
m_viewportApplyScroll->setScroller(targetScroller);
}
+void RootScrollerController::didUpdateCompositing()
+{
+ if (!m_changedSinceLastCompositingUpdate
+ || !m_document
+ || !m_document->frameHost()
+ || !m_effectiveRootScroller)
+ return;
+
+ FrameHost& frameHost = *m_document->frameHost();
+
+ WebLayer* newRootScrollerLayer = nullptr;
+
+ if (m_effectiveRootScroller->layoutObject()
+ && m_effectiveRootScroller->layoutObject()->isBox()) {
+
+ LayoutBox* box = toLayoutBox(m_effectiveRootScroller->layoutObject());
+ GraphicsLayer* graphicsLayer = nullptr;
+
+ if (box->isDocumentElement())
+ graphicsLayer = frameHost.visualViewport().layerForScrolling();
+ else
+ graphicsLayer = box->getScrollableArea()->layerForScrolling();
+
+ // TODO(bokan): We should assert graphicsLayer here and
+ // RootScrollerController should do whatever needs to happen to ensure
+ // the root scroller gets composited.
+
+ if (graphicsLayer)
+ newRootScrollerLayer = graphicsLayer->platformLayer();
+ }
+
+ m_changedSinceLastCompositingUpdate = false;
+
+ // Let the compositor-side counterpart know about this change.
+ if (m_document->isInMainFrame())
+ frameHost.chromeClient().didUpdateRootScrollerLayer(newRootScrollerLayer);
+}
+
Element* RootScrollerController::defaultEffectiveRootScroller()
{
DCHECK(m_document);

Powered by Google App Engine
This is Rietveld 408576698