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

Side by Side Diff: third_party/WebKit/Source/core/page/scrolling/TopDocumentRootScrollerController.h

Issue 2285253003: Move TopDocumentRootScrollerController to a separate object on FrameHost (Closed)
Patch Set: None Created 4 years, 3 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef TopDocumentRootScrollerController_h 5 #ifndef TopDocumentRootScrollerController_h
6 #define TopDocumentRootScrollerController_h 6 #define TopDocumentRootScrollerController_h
7 7
8 #include "core/CoreExport.h" 8 #include "core/CoreExport.h"
9 #include "core/page/scrolling/RootScrollerController.h" 9 #include "core/page/scrolling/RootScrollerController.h"
10 #include "platform/heap/Handle.h" 10 #include "platform/heap/Handle.h"
11 11
12 namespace blink { 12 namespace blink {
13 13
14 class Document;
15 class Element; 14 class Element;
15 class FrameHost;
16 class GraphicsLayer; 16 class GraphicsLayer;
17 class RootFrameViewport;
17 class ScrollStateCallback; 18 class ScrollStateCallback;
18 class ViewportScrollCallback; 19 class ViewportScrollCallback;
19 20
20 // The RootScrollerController used to manage the root scroller for the top 21 // This class manages the the page level aspects of the root scroller. That
21 // level Document on a page. In addition to the regular RootScroller duties, 22 // is, given all the iframes on a page and their individual root scrollers,
22 // such as keeping track of which Element is set as root scroller and which is 23 // this class will determine which ultimate Element should be used as the root
23 // the effective root scroller, this class is also manages the "global" root 24 // scroller and ensures that Element is used to scroll top controls and provide
24 // scroller. That is, given all the iframes on a page and their individual root 25 // overscroll effects.
25 // scrollers, this class will determine which ultimate Element should be used 26 // TODO(bokan): This class is currently OOPIF unaware. crbug.com/505516.
26 // as the root scroller and ensures that Element is used to scroll top controls
27 // and provide overscroll effects.
28 // TODO(bokan): This class is currently OOPIF unaware. It should be broken into
29 // a standalone class and placed on a Page level object. crbug.com/505516
30 class CORE_EXPORT TopDocumentRootScrollerController 27 class CORE_EXPORT TopDocumentRootScrollerController
31 : public RootScrollerController { 28 : public GarbageCollected<TopDocumentRootScrollerController> {
32 public: 29 public:
33 static TopDocumentRootScrollerController* create(Document&); 30 static TopDocumentRootScrollerController* create(FrameHost&);
34 31
35 DECLARE_VIRTUAL_TRACE(); 32 DECLARE_TRACE();
36 33
37 // This class needs to be informed of changes to compositing so that it can 34 // This class needs to be informed of changes to compositing so that it can
38 // update the compositor when the effective root scroller changes. 35 // update the compositor when the effective root scroller changes.
39 void didUpdateCompositing() override; 36 void didUpdateCompositing();
40 37
41 // This class needs to be informed when the document has been attached to a 38 // This method needs to be called to create a ViewportScrollCallback that
42 // FrameView so that we can initialize the viewport scroll callback. 39 // will be used to apply viewport scrolling actions like top controls
43 void didAttachDocument() override; 40 // movement and overscroll glow.
41 void initializeViewportScrollCallback(RootFrameViewport&);
44 42
45 // Returns true if the given ScrollStateCallback is the 43 // Returns true if the given ScrollStateCallback is the
46 // ViewportScrollCallback managed by this class. 44 // ViewportScrollCallback managed by this class.
47 // TODO(bokan): Temporarily needed to allow ScrollCustomization to 45 // TODO(bokan): Temporarily needed to allow ScrollCustomization to
48 // differentiate between real custom callback and the built-in viewport 46 // differentiate between real custom callback and the built-in viewport
49 // apply scroll. crbug.com/623079. 47 // apply scroll. crbug.com/623079.
50 bool isViewportScrollCallback( 48 bool isViewportScrollCallback(
51 const ScrollStateCallback*) const override; 49 const ScrollStateCallback*) const;
52 50
53 // Returns the GraphicsLayer for the global root scroller. 51 // Returns the GraphicsLayer for the global root scroller.
54 GraphicsLayer* rootScrollerLayer() override; 52 GraphicsLayer* rootScrollerLayer();
55 53
56 protected: 54 // Called when the root scroller in any frames on the page has changed.
57 TopDocumentRootScrollerController(Document&); 55 void didChangeRootScroller();
58
59 // Called when the root scroller of descendant frames changes.
60 void globalRootScrollerMayHaveChanged() override;
61 56
62 private: 57 private:
58 TopDocumentRootScrollerController(FrameHost&);
59
63 // Calculates the Element that should be the globalRootScroller. On a 60 // Calculates the Element that should be the globalRootScroller. On a
64 // simple page, this will simply the root frame's effectiveRootScroller but 61 // simple page, this will simply the root frame's effectiveRootScroller but
65 // if the root scroller is set to an iframe, this will then descend into 62 // if the root scroller is set to an iframe, this will then descend into
66 // the iframe to find its effective root scroller. 63 // the iframe to find its effective root scroller.
67 Element* findGlobalRootScrollerElement(); 64 Element* findGlobalRootScrollerElement();
68 65
69 // Should be called to recalculate the global root scroller and ensure all 66 // Should be called to ensure the correct element is currently set as the
70 // appropriate state changes are made if it changes. 67 // global root scroller and that all appropriate state changes are made if
71 void updateGlobalRootScroller(); 68 // it changes.
69 void recomputeGlobalRootScroller();
70
71 Document* topDocument() const;
72 72
73 // The apply-scroll callback that moves top controls and produces 73 // The apply-scroll callback that moves top controls and produces
74 // overscroll effects. This class makes sure this callback is set on the 74 // overscroll effects. This class makes sure this callback is set on the
75 // appropriate root scroller element. 75 // appropriate root scroller element.
76 Member<ViewportScrollCallback> m_viewportApplyScroll; 76 Member<ViewportScrollCallback> m_viewportApplyScroll;
77 77
78 // The page level root scroller. i.e. The actual element for which scrolling 78 // The page level root scroller. i.e. The actual element for which
79 // should move top controls and produce overscroll glow. 79 // scrolling should move top controls and produce overscroll glow. Once an
80 // m_viewportApplyScroll has been created, it will always be set on this
81 // Element.
80 WeakMember<Element> m_globalRootScroller; 82 WeakMember<Element> m_globalRootScroller;
83
84 WeakMember<FrameHost> m_frameHost;
81 }; 85 };
82 86
83 } // namespace blink 87 } // namespace blink
84 88
85 #endif // RootScrollerController_h 89 #endif // RootScrollerController_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698