Chromium Code Reviews| 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 b86aa5a532da018a9a98e39bd5e21599a99de2a2..27b4dc8dd148fbbb1e28a0faa51f61c60fe5e365 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. |
| @@ -609,13 +584,55 @@ void Document::childrenChanged(const ChildrenChange& change) |
| { |
| ContainerNode::childrenChanged(change); |
| m_documentElement = ElementTraversal::firstWithin(*this); |
| +} |
| - // 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 can only be set on the top-level document."); |
|
tdresser
2016/04/26 20:43:49
These are web developer facing - would we devs kno
bokan
2016/04/26 23:06:23
Done.
|
| + return; |
| + } |
| + |
| + if (newScroller->document() != this) { |
| + exceptionState.throwDOMException( |
| + WrongDocumentError, |
| + "Element isn't part of 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."); |
|
tdresser
2016/04/26 20:43:50
In what cases could this happen? Can we be more sp
bokan
2016/04/26 23:06:23
I'm being intentionally vague here, it's one of th
|
| + } |
| +} |
| + |
| +Element* Document::rootScroller() |
| +{ |
| + if (ownerElement()) |
| + return documentElement(); |
| + |
| + FrameHost* host = frameHost(); |
| + if (!host) |
| + return nullptr; |
| + |
| + RootScroller* rootScroller = host->rootScroller(); |
| + DCHECK(rootScroller); |
| + |
| + updateLayoutIgnorePendingStylesheets(); |
| + |
| + return rootScroller->getCurrent(); |
| } |
| AtomicString Document::convertLocalName(const AtomicString& name) |
| @@ -1914,6 +1931,11 @@ void Document::layoutUpdated() |
| if (!m_documentTiming.firstLayout()) |
| m_documentTiming.markFirstLayout(); |
| } |
| + |
| + if (!ownerElement() && frameHost()) { |
| + if (RootScroller* rootScroller = frameHost()->rootScroller()) |
| + rootScroller->didUpdateTopDocumentLayout(); |
| + } |
| } |
| void Document::setNeedsFocusedElementCheck() |