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

Unified Diff: third_party/WebKit/Source/core/dom/Document.cpp

Issue 1970763002: Fixed up root scroller API to be more webby (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Sigh...fix test expectation again, fix crash when there's no renderer 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
« no previous file with comments | « third_party/WebKit/Source/core/dom/Document.h ('k') | third_party/WebKit/Source/core/dom/Document.idl » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 587c08a0dbf5b3bc767b255262741682be3266e7..3d3620f7bc72a1466493b2fb8f27dd059f611505 100644
--- a/third_party/WebKit/Source/core/dom/Document.cpp
+++ b/third_party/WebKit/Source/core/dom/Document.cpp
@@ -197,6 +197,7 @@
#include "core/page/scrolling/RootScroller.h"
#include "core/page/scrolling/ScrollingCoordinator.h"
#include "core/page/scrolling/SnapCoordinator.h"
+#include "core/page/scrolling/ViewportScrollCallback.h"
#include "core/svg/SVGDocumentExtensions.h"
#include "core/svg/SVGScriptElement.h"
#include "core/svg/SVGTitleElement.h"
@@ -479,6 +480,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);
+
// 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
@@ -602,52 +610,17 @@ 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);
-
- updateStyleAndLayoutIgnorePendingStylesheets();
+ return m_rootScroller->get();
+}
- return rootScroller->get();
+bool Document::isEffectiveRootScroller(const Element& element) const
+{
+ return m_rootScroller->effectiveRootScroller() == element;
}
bool Document::isInMainFrame() const
@@ -1947,11 +1920,7 @@ void Document::layoutUpdated()
m_documentTiming.markFirstLayout();
}
- // TODO(bokan): Not sure how rootScroller can be null here if we're in the
- // main frame. In any case, I'm moving rootScroller to be owned by Document
- // soon so this will go away: https://codereview.chromium.org/1970763002/
- if (isInMainFrame() && frameHost() && frameHost()->rootScroller())
- frameHost()->rootScroller()->didUpdateTopDocumentLayout();
+ m_rootScroller->didUpdateLayout();
}
void Document::setNeedsFocusedElementCheck()
@@ -5960,6 +5929,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);
« no previous file with comments | « third_party/WebKit/Source/core/dom/Document.h ('k') | third_party/WebKit/Source/core/dom/Document.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698