Chromium Code Reviews| Index: third_party/WebKit/Source/core/page/scrolling/TopDocumentRootScrollerController.cpp |
| diff --git a/third_party/WebKit/Source/core/page/scrolling/TopDocumentRootScrollerController.cpp b/third_party/WebKit/Source/core/page/scrolling/TopDocumentRootScrollerController.cpp |
| index ff09de5b56c79b5a263f812a1455aa12a7647854..f1ccd47f56a00a1962fe209f51d9a52deef049e1 100644 |
| --- a/third_party/WebKit/Source/core/page/scrolling/TopDocumentRootScrollerController.cpp |
| +++ b/third_party/WebKit/Source/core/page/scrolling/TopDocumentRootScrollerController.cpp |
| @@ -10,7 +10,9 @@ |
| #include "core/frame/FrameView.h" |
| #include "core/html/HTMLFrameOwnerElement.h" |
| #include "core/page/ChromeClient.h" |
| +#include "core/page/Page.h" |
| #include "core/page/scrolling/OverscrollController.h" |
| +#include "core/page/scrolling/RootScrollerUtil.h" |
| #include "core/page/scrolling/ViewportScrollCallback.h" |
| #include "platform/scroll/ScrollableArea.h" |
| @@ -18,14 +20,14 @@ namespace blink { |
| // static |
| TopDocumentRootScrollerController* TopDocumentRootScrollerController::create( |
| - Document& document) |
| + FrameHost& host) |
| { |
| - return new TopDocumentRootScrollerController(document); |
| + return new TopDocumentRootScrollerController(host); |
| } |
| TopDocumentRootScrollerController::TopDocumentRootScrollerController( |
| - Document& document) |
| - : RootScrollerController(document) |
| + FrameHost& host) |
| +: m_frameHost(&host) |
| { |
| } |
| @@ -33,17 +35,22 @@ DEFINE_TRACE(TopDocumentRootScrollerController) |
| { |
| visitor->trace(m_viewportApplyScroll); |
| visitor->trace(m_globalRootScroller); |
| - RootScrollerController::trace(visitor); |
| + visitor->trace(m_frameHost); |
| } |
| -void TopDocumentRootScrollerController::globalRootScrollerMayHaveChanged() |
| +void TopDocumentRootScrollerController::didChangeRootScroller() |
| { |
| - updateGlobalRootScroller(); |
| + recomputeGlobalRootScroller(); |
| } |
| Element* TopDocumentRootScrollerController::findGlobalRootScrollerElement() |
| { |
| - Element* element = effectiveRootScroller(); |
| + if (!topDocument()) |
| + return nullptr; |
| + |
| + DCHECK(topDocument()->rootScrollerController()); |
| + Element* element = |
| + topDocument()->rootScrollerController()->effectiveRootScroller(); |
| while (element && element->isFrameOwnerElement()) { |
| HTMLFrameOwnerElement* frameOwner = toHTMLFrameOwnerElement(element); |
| @@ -61,15 +68,17 @@ Element* TopDocumentRootScrollerController::findGlobalRootScrollerElement() |
| return element; |
| } |
| -void TopDocumentRootScrollerController::updateGlobalRootScroller() |
| +void TopDocumentRootScrollerController::recomputeGlobalRootScroller() |
| { |
| - Element* target = findGlobalRootScrollerElement(); |
| + if (!m_viewportApplyScroll) |
| + return; |
| - if (!m_viewportApplyScroll || !target) |
| + Element* target = findGlobalRootScrollerElement(); |
| + if (!target) |
| return; |
| ScrollableArea* targetScroller = |
| - scrollableAreaFor(*target); |
| + RootScrollerUtil::scrollableAreaFor(*target); |
| if (!targetScroller) |
| return; |
| @@ -92,32 +101,37 @@ void TopDocumentRootScrollerController::updateGlobalRootScroller() |
| m_viewportApplyScroll->setScroller(targetScroller); |
| } |
| -void TopDocumentRootScrollerController::didUpdateCompositing() |
| +Document* TopDocumentRootScrollerController::topDocument() const |
| { |
| - RootScrollerController::didUpdateCompositing(); |
| + if (!m_frameHost) |
| + return nullptr; |
| - // Let the compositor-side counterpart know about this change. |
| - if (FrameHost* frameHost = m_document->frameHost()) |
| - frameHost->chromeClient().registerViewportLayers(); |
| + if (!m_frameHost->page().mainFrame() |
| + || !m_frameHost->page().mainFrame()->isLocalFrame()) |
| + return nullptr; |
| + |
| + return toLocalFrame(m_frameHost->page().mainFrame())->document(); |
| } |
| -void TopDocumentRootScrollerController::didAttachDocument() |
| +void TopDocumentRootScrollerController::didUpdateCompositing() |
| { |
| - FrameHost* frameHost = m_document->frameHost(); |
| - FrameView* frameView = m_document->view(); |
| - |
| - if (!frameHost || !frameView) |
| + if (!m_frameHost) |
| return; |
| - RootFrameViewport* rootFrameViewport = frameView->getRootFrameViewport(); |
| - DCHECK(rootFrameViewport); |
| + // Let the compositor-side counterpart know about this change. |
| + m_frameHost->chromeClient().registerViewportLayers(); |
| +} |
| +void TopDocumentRootScrollerController::initializeViewportScrollCallback( |
| + RootFrameViewport& rfv) |
|
tdresser
2016/08/30 15:05:30
Might as well write out the whole:
rootFrameViewpo
bokan
2016/08/30 16:13:39
Done.
|
| +{ |
| + DCHECK(m_frameHost); |
| m_viewportApplyScroll = ViewportScrollCallback::create( |
| - &frameHost->topControls(), |
| - &frameHost->overscrollController(), |
| - *rootFrameViewport); |
| + &m_frameHost->topControls(), |
| + &m_frameHost->overscrollController(), |
| + rfv); |
| - updateGlobalRootScroller(); |
| + recomputeGlobalRootScroller(); |
| } |
| bool TopDocumentRootScrollerController::isViewportScrollCallback( |
| @@ -134,7 +148,8 @@ GraphicsLayer* TopDocumentRootScrollerController::rootScrollerLayer() |
| if (!m_globalRootScroller) |
| return nullptr; |
| - ScrollableArea* area = scrollableAreaFor(*m_globalRootScroller); |
| + ScrollableArea* area = |
| + RootScrollerUtil::scrollableAreaFor(*m_globalRootScroller); |
| if (!area) |
| return nullptr; |