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

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

Issue 1913843004: Implementing document.setRootScroller API for main thread scrolling. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@overscrollController
Patch Set: Fixing bad rebase Created 4 years, 8 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 07eebddf33c3a85c0f39b62889e77d5e5184f5b0..45a91520ec31434010ac96e70b77e51e429b7f9c 100644
--- a/third_party/WebKit/Source/core/dom/Document.cpp
+++ b/third_party/WebKit/Source/core/dom/Document.cpp
@@ -193,8 +193,8 @@
#include "core/page/FrameTree.h"
#include "core/page/Page.h"
#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/SVGTitleElement.h"
#include "core/svg/SVGUseElement.h"
@@ -248,31 +248,6 @@ static const unsigned cMaxWriteRecursionDepth = 21;
// for dual G5s. :)
static const int cLayoutScheduleThreshold = 250;
-namespace {
-
-void updateViewportApplyScroll(Element* documentElement)
-{
- if (!documentElement
- || !documentElement->isHTMLElement()
- || documentElement->document().ownerElement())
- return;
-
- if (documentElement->getApplyScroll())
- return;
-
- ScrollStateCallback* applyScroll =
- new ViewportScrollCallback(documentElement->document());
-
- // Use disable-native-scroll since the ViewportScrollCallback needs to
- // apply scroll actions before (TopControls) and after (overscroll)
- // scrolling the element so it applies scroll to the element itself.
- documentElement->setApplyScroll(
- applyScroll,
- "disable-native-scroll");
-}
-
-} // namespace
-
// DOM Level 2 says (letters added):
//
// a) Name start characters must have one of the categories Ll, Lu, Lo, Lt, Nl.
@@ -617,13 +592,55 @@ void Document::childrenChanged(const ChildrenChange& change)
// frames when there's only a <head>, but such documents are pretty rare.
if (m_documentElement && !isHTMLDocument())
beginLifecycleUpdatesIfRenderingReady();
+}
- // Installs the viewport scrolling callback (the "applyScroll" in Scroll
- // Customization lingo) on the documentElement. This callback is
- // responsible for viewport related scroll actions like top controls
- // movement and overscroll glow as well as actually scrolling the root
- // viewport.
- updateViewportApplyScroll(m_documentElement);
+void Document::setRootScroller(Element* newScroller, ExceptionState& exceptionState)
+{
+ DCHECK(newScroller);
+
+ if (ownerElement()) {
+ exceptionState.throwDOMException(
+ WrongDocumentError,
+ "Root scroller cannot be set on a document within a frame.");
+ 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.");
+ }
+}
+
+Element* Document::rootScroller()
+{
+ if (ownerElement())
+ return documentElement();
+
+ FrameHost* host = frameHost();
+ if (!host)
+ return nullptr;
+
+ RootScroller* rootScroller = host->rootScroller();
+ DCHECK(rootScroller);
+
+ updateLayoutIgnorePendingStylesheets();
+
+ return rootScroller->get();
}
AtomicString Document::convertLocalName(const AtomicString& name)
@@ -1922,6 +1939,11 @@ void Document::layoutUpdated()
if (!m_documentTiming.firstLayout())
m_documentTiming.markFirstLayout();
}
+
+ if (!ownerElement() && frameHost()) {
+ if (RootScroller* rootScroller = frameHost()->rootScroller())
+ rootScroller->didUpdateTopDocumentLayout();
+ }
}
void Document::setNeedsFocusedElementCheck()

Powered by Google App Engine
This is Rietveld 408576698