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

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: Created 4 years, 7 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/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);

Powered by Google App Engine
This is Rietveld 408576698