File: TopDocumentRootScrollerController.h

package info (click to toggle)
chromium-browser 57.0.2987.98-1~deb8u1
  • links: PTS, VCS
  • area: main
  • in suites: jessie
  • size: 2,637,852 kB
  • ctags: 2,544,394
  • sloc: cpp: 12,815,961; ansic: 3,676,222; python: 1,147,112; asm: 526,608; java: 523,212; xml: 286,794; perl: 92,654; sh: 86,408; objc: 73,271; makefile: 27,698; cs: 18,487; yacc: 13,031; tcl: 12,957; pascal: 4,875; ml: 4,716; lex: 3,904; sql: 3,862; ruby: 1,982; lisp: 1,508; php: 1,368; exp: 404; awk: 325; csh: 117; jsp: 39; sed: 37
file content (114 lines) | stat: -rw-r--r-- 4,427 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
// 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 TopDocumentRootScrollerController_h
#define TopDocumentRootScrollerController_h

#include "core/CoreExport.h"
#include "core/page/scrolling/RootScrollerController.h"
#include "platform/geometry/IntSize.h"
#include "platform/heap/Handle.h"

namespace blink {

class Element;
class FrameHost;
class GraphicsLayer;
class PaintLayer;
class RootFrameViewport;
class ScrollStateCallback;
class ScrollableArea;
class ViewportScrollCallback;

// This class manages the the page level aspects of the root scroller.  That
// is, given all the iframes on a page and their individual root scrollers,
// this class will determine which ultimate Element should be used as the root
// scroller and ensures that Element is used to scroll browser controls and
// provide overscroll effects.
// TODO(bokan): This class is currently OOPIF unaware. crbug.com/642378.
class CORE_EXPORT TopDocumentRootScrollerController
    : public GarbageCollected<TopDocumentRootScrollerController> {
 public:
  static TopDocumentRootScrollerController* create(FrameHost&);

  DECLARE_TRACE();

  // This class needs to be informed of changes to compositing so that it can
  // update the compositor when the effective root scroller changes.
  void didUpdateCompositing();

  // PaintLayerScrollableAreas need to notify this class when they're being
  // disposed so that we can remove them as the root scroller.
  void didDisposeScrollableArea(ScrollableArea&);

  // This method needs to be called to create a ViewportScrollCallback that
  // will be used to apply viewport scrolling actions like browser controls
  // movement and overscroll glow.
  void initializeViewportScrollCallback(RootFrameViewport&);

  // Returns true if the given ScrollStateCallback is the
  // ViewportScrollCallback managed by this class.
  // TODO(bokan): Temporarily needed to allow ScrollCustomization to
  // differentiate between real custom callback and the built-in viewport
  // apply scroll. crbug.com/623079.
  bool isViewportScrollCallback(const ScrollStateCallback*) const;

  // Returns the GraphicsLayer for the global root scroller.
  GraphicsLayer* rootScrollerLayer() const;

  PaintLayer* rootScrollerPaintLayer() const;

  // Returns the Element that's the global root scroller.
  Element* globalRootScroller() const;

  // Called when the root scroller in any frames on the page has changed.
  void didChangeRootScroller();

  void mainFrameViewResized();

  // Returns the ScrollableArea associated with the globalRootScroller(). Note,
  // this isn't necessarily the PLSA belonging to the root scroller Element's
  // LayoutBox.  If the root scroller is the documentElement then we use the
  // FrameView (or LayoutView if root-layer-scrolls).
  ScrollableArea* rootScrollerArea() const;

  // Returns the size we should use for the root scroller, accounting for top
  // controls adjustment and using the root FrameView.
  IntSize rootScrollerVisibleArea() const;

 private:
  TopDocumentRootScrollerController(FrameHost&);

  // Calculates the Element that should be the globalRootScroller. On a
  // simple page, this will simply the root frame's effectiveRootScroller but
  // if the root scroller is set to an iframe, this will then descend into
  // the iframe to find its effective root scroller.
  Element* findGlobalRootScrollerElement();

  // Should be called to ensure the correct element is currently set as the
  // global root scroller and that all appropriate state changes are made if
  // it changes.
  void recomputeGlobalRootScroller();

  Document* topDocument() const;

  void setNeedsCompositingInputsUpdateOnGlobalRootScroller();

  // The apply-scroll callback that moves browser controls and produces
  // overscroll effects. This class makes sure this callback is set on the
  // appropriate root scroller element.
  Member<ViewportScrollCallback> m_viewportApplyScroll;

  // The page level root scroller. i.e. The actual element for which
  // scrolling should move browser controls and produce overscroll glow. Once an
  // m_viewportApplyScroll has been created, it will always be set on this
  // Element.
  WeakMember<Element> m_globalRootScroller;

  WeakMember<FrameHost> m_frameHost;
};

}  // namespace blink

#endif  // RootScrollerController_h