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

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

Issue 1895323002: Viewport apply scroll should be on the document element not scrollingElement. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 5ba449da09f6838f13fb7d2f535a713d92be2708..05e9766f5920f39e427359abed06468385bc5ccd 100644
--- a/third_party/WebKit/Source/core/dom/Document.cpp
+++ b/third_party/WebKit/Source/core/dom/Document.cpp
@@ -248,6 +248,31 @@ 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.
@@ -584,47 +609,13 @@ void Document::childrenChanged(const ChildrenChange& change)
{
ContainerNode::childrenChanged(change);
m_documentElement = ElementTraversal::firstWithin(*this);
-}
-void Document::updateViewportApplyScroll()
-{
- if (!m_documentElement
- || !m_documentElement->isHTMLElement()
- || ownerElement())
- return;
-
- Element* newScrollingElement = scrollingElement();
-
- // If there is no scrolling element (in QuirksMode and body is scrollable),
- // install the viewport scroll callback on the <HTML> element.
- if (!newScrollingElement)
- newScrollingElement = m_documentElement;
-
- if (newScrollingElement == m_oldScrollingElement)
- return;
-
- ScrollStateCallback* applyScroll = nullptr;
-
- // If the scrolling element changed, remove the apply scroll from the
- // old one and keep it to put on the new scrolling element.
- if (m_oldScrollingElement) {
- applyScroll = m_oldScrollingElement->getApplyScroll();
- m_oldScrollingElement->removeApplyScroll();
- }
-
- if (newScrollingElement) {
- if (!applyScroll)
- applyScroll = new ViewportScrollCallback(*this, *frameHost());
-
- // 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.
- newScrollingElement->setApplyScroll(
- applyScroll,
- "disable-native-scroll");
- }
-
- m_oldScrollingElement = newScrollingElement;
+ // 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);
}
AtomicString Document::convertLocalName(const AtomicString& name)
@@ -1905,8 +1896,6 @@ void Document::updateLayout()
void Document::layoutUpdated()
{
- updateViewportApplyScroll();
-
// Plugins can run script inside layout which can detach the page.
// TODO(esprehn): Can this still happen now that all plugins are out of
// process?
@@ -5875,7 +5864,6 @@ DEFINE_TRACE(Document)
visitor->trace(m_contextFeatures);
visitor->trace(m_styleSheetList);
visitor->trace(m_documentTiming);
- visitor->trace(m_oldScrollingElement);
visitor->trace(m_mediaQueryMatcher);
visitor->trace(m_scriptedAnimationController);
visitor->trace(m_scriptedIdleTaskController);
« no previous file with comments | « third_party/WebKit/Source/core/dom/Document.h ('k') | third_party/WebKit/Source/core/input/EventHandler.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698