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; | 14 class Document; |
15 class Element; | 15 class Element; |
16 class GraphicsLayer; | 16 class GraphicsLayer; |
17 class ScrollStateCallback; | 17 class ScrollStateCallback; |
18 class ViewportScrollCallback; | 18 class ViewportScrollCallback; |
19 | 19 |
20 // The RootScrollerController used to manage the root scroller for the top | 20 // The RootScrollerController used to manage the root scroller for the top |
21 // level Document on a page. In addition to the regular RootScroller duties | 21 // level Document on a page. In addition to the regular RootScroller duties, |
22 // such as keeping track of which Element is set as root scroller and which is | 22 // such as keeping track of which Element is set as root scroller and which is |
23 // the effective root scroller, this class is also responsible for setting the | 23 // the effective root scroller, this class is also manages the "global" root |
24 // ViewportApplyScroll on the one Element on a page that should apply viewport | 24 // scroller. That is, given all the iframes on a page and their individual root |
25 // scrolling actions. | 25 // scrollers, this class will determine which ultimate Element should be used |
| 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 |
26 class CORE_EXPORT TopDocumentRootScrollerController | 30 class CORE_EXPORT TopDocumentRootScrollerController |
27 : public RootScrollerController { | 31 : public RootScrollerController { |
28 public: | 32 public: |
29 static TopDocumentRootScrollerController* create(Document&); | 33 static TopDocumentRootScrollerController* create(Document&); |
30 | 34 |
31 DECLARE_VIRTUAL_TRACE(); | 35 DECLARE_VIRTUAL_TRACE(); |
32 | 36 |
33 // This class needs to be informed of changes to compositing so that it can | 37 // This class needs to be informed of changes to compositing so that it can |
34 // update the compositor when the effective root scroller changes. | 38 // update the compositor when the effective root scroller changes. |
35 void didUpdateCompositing() override; | 39 void didUpdateCompositing() override; |
36 | 40 |
37 // This class needs to be informed when the document has been attached to a | 41 // This class needs to be informed when the document has been attached to a |
38 // FrameView so that we can initialize the viewport scroll callback. | 42 // FrameView so that we can initialize the viewport scroll callback. |
39 void didAttachDocument() override; | 43 void didAttachDocument() override; |
40 | 44 |
41 // Returns true if the given ScrollStateCallback is the ViewportScrollCallba
ck managed | 45 // Returns true if the given ScrollStateCallback is the |
42 // by this class. | 46 // ViewportScrollCallback managed by this class. |
43 // TODO(bokan): Temporarily needed to allow ScrollCustomization to | 47 // TODO(bokan): Temporarily needed to allow ScrollCustomization to |
44 // differentiate between real custom callback and the built-in viewport | 48 // differentiate between real custom callback and the built-in viewport |
45 // apply scroll. crbug.com/623079. | 49 // apply scroll. crbug.com/623079. |
46 bool isViewportScrollCallback( | 50 bool isViewportScrollCallback( |
47 const ScrollStateCallback*) const override; | 51 const ScrollStateCallback*) const override; |
48 | 52 |
| 53 // Returns the GraphicsLayer for the global root scroller. |
| 54 GraphicsLayer* rootScrollerLayer() override; |
| 55 |
49 protected: | 56 protected: |
50 TopDocumentRootScrollerController(Document&); | 57 TopDocumentRootScrollerController(Document&); |
51 | 58 |
52 // Ensures the effective root scroller is currently valid and replaces it | 59 // Called when the root scroller of descendant frames changes. |
53 // with the default if not. | 60 void globalRootScrollerMayHaveChanged() override; |
54 void updateEffectiveRootScroller() override; | |
55 | 61 |
56 private: | 62 private: |
57 // Ensures that the element that should be used as the root scroller on the | 63 // Calculates the Element that should be the globalRootScroller. On a |
58 // page has the m_viewportApplyScroll callback set on it. | 64 // simple page, this will simply the root frame's effectiveRootScroller but |
59 void setViewportApplyScrollOnRootScroller(); | 65 // if the root scroller is set to an iframe, this will then descend into |
| 66 // the iframe to find its effective root scroller. |
| 67 Element* findGlobalRootScrollerElement(); |
| 68 |
| 69 // Should be called to recalculate the global root scroller and ensure all |
| 70 // appropriate state changes are made if it changes. |
| 71 void updateGlobalRootScroller(); |
60 | 72 |
61 // The apply-scroll callback that moves top controls and produces | 73 // The apply-scroll callback that moves top controls and produces |
62 // 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 |
63 // appropriate root scroller element. | 75 // appropriate root scroller element. |
64 Member<ViewportScrollCallback> m_viewportApplyScroll; | 76 Member<ViewportScrollCallback> m_viewportApplyScroll; |
65 | 77 |
66 // Tracks which element currently has the m_viewportApplyScroll set to it. | 78 // The page level root scroller. i.e. The actual element for which scrolling |
67 WeakMember<Element> m_currentViewportApplyScrollHost; | 79 // should move top controls and produce overscroll glow. |
| 80 WeakMember<Element> m_globalRootScroller; |
68 }; | 81 }; |
69 | 82 |
70 } // namespace blink | 83 } // namespace blink |
71 | 84 |
72 #endif // RootScrollerController_h | 85 #endif // RootScrollerController_h |
OLD | NEW |