OLD | NEW |
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/642378. |
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/642378. | |
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() const; |
55 | 53 |
56 // Returns the Element that's the global root scroller. | 54 // Returns the Element that's the global root scroller. |
57 Element* globalRootScroller() const; | 55 Element* globalRootScroller() const; |
58 | 56 |
59 protected: | 57 // Called when the root scroller in any frames on the page has changed. |
60 TopDocumentRootScrollerController(Document&); | 58 void didChangeRootScroller(); |
61 | |
62 // Called when the root scroller of descendant frames changes. | |
63 void globalRootScrollerMayHaveChanged() override; | |
64 | 59 |
65 private: | 60 private: |
| 61 TopDocumentRootScrollerController(FrameHost&); |
| 62 |
66 // Calculates the Element that should be the globalRootScroller. On a | 63 // Calculates the Element that should be the globalRootScroller. On a |
67 // simple page, this will simply the root frame's effectiveRootScroller but | 64 // simple page, this will simply the root frame's effectiveRootScroller but |
68 // if the root scroller is set to an iframe, this will then descend into | 65 // if the root scroller is set to an iframe, this will then descend into |
69 // the iframe to find its effective root scroller. | 66 // the iframe to find its effective root scroller. |
70 Element* findGlobalRootScrollerElement(); | 67 Element* findGlobalRootScrollerElement(); |
71 | 68 |
72 // Should be called to recalculate the global root scroller and ensure all | 69 // Should be called to ensure the correct element is currently set as the |
73 // appropriate state changes are made if it changes. | 70 // global root scroller and that all appropriate state changes are made if |
74 void updateGlobalRootScroller(); | 71 // it changes. |
| 72 void recomputeGlobalRootScroller(); |
| 73 |
| 74 Document* topDocument() const; |
75 | 75 |
76 void setNeedsCompositingInputsUpdateOnGlobalRootScroller(); | 76 void setNeedsCompositingInputsUpdateOnGlobalRootScroller(); |
77 | 77 |
78 // The apply-scroll callback that moves top controls and produces | 78 // The apply-scroll callback that moves top controls and produces |
79 // overscroll effects. This class makes sure this callback is set on the | 79 // overscroll effects. This class makes sure this callback is set on the |
80 // appropriate root scroller element. | 80 // appropriate root scroller element. |
81 Member<ViewportScrollCallback> m_viewportApplyScroll; | 81 Member<ViewportScrollCallback> m_viewportApplyScroll; |
82 | 82 |
83 // The page level root scroller. i.e. The actual element for which scrolling | 83 // The page level root scroller. i.e. The actual element for which |
84 // should move top controls and produce overscroll glow. | 84 // scrolling should move top controls and produce overscroll glow. Once an |
| 85 // m_viewportApplyScroll has been created, it will always be set on this |
| 86 // Element. |
85 WeakMember<Element> m_globalRootScroller; | 87 WeakMember<Element> m_globalRootScroller; |
| 88 |
| 89 WeakMember<FrameHost> m_frameHost; |
86 }; | 90 }; |
87 | 91 |
88 } // namespace blink | 92 } // namespace blink |
89 | 93 |
90 #endif // RootScrollerController_h | 94 #endif // RootScrollerController_h |
OLD | NEW |