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

Unified Diff: third_party/WebKit/Source/core/page/scrolling/RootScroller.h

Issue 1913843004: Implementing document.setRootScroller API for main thread scrolling. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@overscrollController
Patch Set: Rebase and remove whitespace in Document.idl 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/page/scrolling/RootScroller.h
diff --git a/third_party/WebKit/Source/core/page/scrolling/RootScroller.h b/third_party/WebKit/Source/core/page/scrolling/RootScroller.h
new file mode 100644
index 0000000000000000000000000000000000000000..e6ded8f45cd0d84cc57ef23fedd75c860e049ecc
--- /dev/null
+++ b/third_party/WebKit/Source/core/page/scrolling/RootScroller.h
@@ -0,0 +1,65 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef RootScroller_h
+#define RootScroller_h
+
+#include "core/CoreExport.h"
+#include "platform/heap/Handle.h"
+
+namespace blink {
+
+class Element;
+class FrameHost;
+class ViewportScrollCallback;
+
+// This class manages the root scroller associated with the top-level document.
+// The root scroller causes top controls movement, overscroll effects and
+// prevents chaining up further in the DOM. It can be set using
+// document.setRootScroller. By default, the rootScroller is the
+// documentElement.
+//
+// Not all elements can be set as the root scroller. A valid element must be
+// in the top-level document and must have a LayoutObject that is at least a
+// LayoutBlockFlow or LayoutIFrame. In addition, only the top-level document can
+// set a non-default root scroller.
+class CORE_EXPORT RootScroller : public GarbageCollected<RootScroller> {
+public:
+ static RootScroller* create(FrameHost& frameHost)
+ {
+ return new RootScroller(frameHost);
+ }
+
+ // This method returns true if the element was set as the root scroller. If
+ // the element isn't eligible to be the root scroller or we're in some bad
+ // state, the method returns false without changing the current root
+ // scroller.
+ bool set(Element&);
+
+ // Returns the element currently set as the root scroller.
+ Element* get() const;
+
+ // This class needs to be informed of changes in layout so that it can
+ // determine if the current scroller is still valid or if it must be
+ // replaced by the defualt root scroller.
+ void didUpdateTopDocumentLayout();
+
+ DECLARE_TRACE();
+
+private:
+ RootScroller(FrameHost&);
+
+ bool isValid(Element&) const;
+ void resetToDefault();
+ void createApplyScrollIfNeeded();
+
+ WeakMember<FrameHost> m_frameHost;
+ Member<ViewportScrollCallback> m_viewportApplyScroll;
+
+ WeakMember<Element> m_rootScroller;
+};
+
+} // namespace blink
+
+#endif // RootScroller_h

Powered by Google App Engine
This is Rietveld 408576698