Index: third_party/WebKit/Source/core/dom/Document.cpp |
diff --git a/third_party/WebKit/Source/core/dom/Document.cpp b/third_party/WebKit/Source/core/dom/Document.cpp |
index f05f277465d432d8b9a6bc5a7f928ba1b961aeee..639c887a9fe110a66b4c16895ca97df321e956cb 100644 |
--- a/third_party/WebKit/Source/core/dom/Document.cpp |
+++ b/third_party/WebKit/Source/core/dom/Document.cpp |
@@ -194,6 +194,7 @@ |
#include "core/page/PointerLockController.h" |
#include "core/page/scrolling/RootScroller.h" |
#include "core/page/scrolling/ScrollingCoordinator.h" |
+#include "core/page/scrolling/ViewportScrollCallback.h" |
#include "core/svg/SVGDocumentExtensions.h" |
#include "core/svg/SVGScriptElement.h" |
#include "core/svg/SVGTitleElement.h" |
@@ -473,6 +474,13 @@ Document::Document(const DocumentInit& initializer, DocumentClassFlags documentC |
m_fetcher = ResourceFetcher::create(nullptr); |
} |
+ ViewportScrollCallback* applyScroll = nullptr; |
+ if (isInMainFrame()) { |
+ applyScroll = RootScroller::createViewportApplyScroll( |
+ frameHost()->topControls(), frameHost()->overscrollController()); |
+ } |
+ m_rootScroller = RootScroller::create(*this, applyScroll); |
esprehn
2016/05/11 17:37:05
we should rename RootScroller to something like Ro
bokan
2016/06/02 15:49:55
Acknowledged.
|
+ |
// We depend on the url getting immediately set in subframes, but we |
// also depend on the url NOT getting immediately set in opened windows. |
// See fast/dom/early-frame-url.html |
@@ -596,52 +604,20 @@ void Document::childrenChanged(const ChildrenChange& change) |
void Document::setRootScroller(Element* newScroller, ExceptionState& exceptionState) |
{ |
- DCHECK(newScroller); |
- |
- if (!frame() || !frame()->isMainFrame()) { |
- exceptionState.throwDOMException( |
- WrongDocumentError, |
- "Root scroller can only be set on the top window's document."); |
- return; |
- } |
- |
- if (newScroller->document() != this) { |
- exceptionState.throwDOMException( |
- WrongDocumentError, |
- "Element isn't in this document."); |
- return; |
- } |
- |
- FrameHost* host = frameHost(); |
- if (!host) |
- return; |
- |
- RootScroller* rootScroller = host->rootScroller(); |
- DCHECK(rootScroller); |
- |
- if (!rootScroller->set(*newScroller)) { |
- exceptionState.throwDOMException( |
- InvalidStateError, |
- "Element cannot be set as root scroller. Must be block or iframe."); |
- } |
+ m_rootScroller->set(newScroller); |
} |
-Element* Document::rootScroller() |
+Element* Document::rootScroller() const |
{ |
- // TODO(bokan): Should child frames return the documentElement or nullptr? |
- if (!isInMainFrame()) |
- return documentElement(); |
- |
- FrameHost* host = frameHost(); |
- if (!host) |
- return nullptr; |
- |
- RootScroller* rootScroller = host->rootScroller(); |
- DCHECK(rootScroller); |
+ return m_rootScroller->get(); |
+} |
- updateLayoutIgnorePendingStylesheets(); |
+bool Document::isEffectiveRootScroller(const Element* element) const |
+{ |
+ if (!element) |
+ return false; |
- return rootScroller->get(); |
+ return m_rootScroller->effectiveRootScroller() == element; |
} |
bool Document::isInMainFrame() const |
@@ -1930,10 +1906,7 @@ void Document::layoutUpdated() |
m_documentTiming.markFirstLayout(); |
} |
- if (isInMainFrame() && frameHost()) { |
- DCHECK(frameHost()->rootScroller()); |
- frameHost()->rootScroller()->didUpdateTopDocumentLayout(); |
- } |
+ m_rootScroller->didUpdateLayout(); |
} |
void Document::setNeedsFocusedElementCheck() |
@@ -5915,6 +5888,7 @@ DEFINE_TRACE(Document) |
visitor->trace(m_hoverNode); |
visitor->trace(m_activeHoverElement); |
visitor->trace(m_documentElement); |
+ visitor->trace(m_rootScroller); |
visitor->trace(m_titleElement); |
visitor->trace(m_axObjectCache); |
visitor->trace(m_markers); |