File: ScrollManager.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 (150 lines) | stat: -rw-r--r-- 5,383 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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
// 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 ScrollManager_h
#define ScrollManager_h

#include "core/CoreExport.h"
#include "core/page/EventWithHitTestResults.h"
#include "platform/PlatformEvent.h"
#include "platform/geometry/LayoutSize.h"
#include "platform/heap/Handle.h"
#include "platform/heap/Visitor.h"
#include "platform/scroll/ScrollTypes.h"
#include "public/platform/WebInputEventResult.h"
#include "wtf/Allocator.h"
#include <deque>

namespace blink {

class AutoscrollController;
class FrameHost;
class LayoutBox;
class LayoutObject;
class LocalFrame;
class PaintLayer;
class PaintLayerScrollableArea;
class Scrollbar;
class ScrollState;
class WebGestureEvent;

// This class takes care of scrolling and resizing and the related states. The
// user action that causes scrolling or resizing is determined in other *Manager
// classes and they call into this class for doing the work.
class CORE_EXPORT ScrollManager
    : public GarbageCollectedFinalized<ScrollManager> {
  WTF_MAKE_NONCOPYABLE(ScrollManager);

 public:
  explicit ScrollManager(LocalFrame&);
  DECLARE_TRACE();

  void clear();

  bool middleClickAutoscrollInProgress() const;
  AutoscrollController* autoscrollController() const;
  void stopAutoscroll();

  // Performs a chaining logical scroll, within a *single* frame, starting
  // from either a provided starting node or a default based on the focused or
  // most recently clicked node, falling back to the frame.
  // Returns true if the scroll was consumed.
  // direction - The logical direction to scroll in. This will be converted to
  //             a physical direction for each LayoutBox we try to scroll
  //             based on that box's writing mode.
  // granularity - The units that the  scroll delta parameter is in.
  // startNode - Optional. If provided, start chaining from the given node.
  //             If not, use the current focus or last clicked node.
  bool logicalScroll(ScrollDirection,
                     ScrollGranularity,
                     Node* startNode,
                     Node* mousePressNode);

  // Performs a logical scroll that chains, crossing frames, starting from
  // the given node or a reasonable default (focus/last clicked).
  bool bubblingScroll(ScrollDirection,
                      ScrollGranularity,
                      Node* startingNode,
                      Node* mousePressNode);

  void setFrameWasScrolledByUser();

  // TODO(crbug.com/616491): Consider moving all gesture related functions to
  // another class.

  // Handle the provided scroll gesture event, propagating down to child frames
  // as necessary.
  WebInputEventResult handleGestureScrollEvent(const WebGestureEvent&);

  WebInputEventResult handleGestureScrollEnd(const WebGestureEvent&);

  bool isScrollbarHandlingGestures() const;

  // Returns true if the gesture event should be handled in ScrollManager.
  bool canHandleGestureEvent(const GestureEventWithHitTestResults&);

  // These functions are related to |m_resizeScrollableArea|.
  bool inResizeMode() const;
  void resize(const PlatformMouseEvent&);
  // Clears |m_resizeScrollableArea|. if |shouldNotBeNull| is true this
  // function DCHECKs to make sure that variable is indeed not null.
  void clearResizeScrollableArea(bool shouldNotBeNull);
  void setResizeScrollableArea(PaintLayer*, IntPoint);

 private:
  WebInputEventResult handleGestureScrollUpdate(const WebGestureEvent&);
  WebInputEventResult handleGestureScrollBegin(const WebGestureEvent&);

  WebInputEventResult passScrollGestureEventToWidget(const WebGestureEvent&,
                                                     LayoutObject*);

  void clearGestureScrollState();

  void customizedScroll(const Node& startNode, ScrollState&);

  FrameHost* frameHost() const;

  bool isViewportScrollingElement(const Element&) const;

  bool handleScrollGestureOnResizer(Node*, const WebGestureEvent&);

  void recomputeScrollChain(const Node& startNode,
                            std::deque<int>& scrollChain);

  // NOTE: If adding a new field to this class please ensure that it is
  // cleared in |ScrollManager::clear()|.

  const Member<LocalFrame> m_frame;

  // Only used with the ScrollCustomization runtime enabled feature.
  std::deque<int> m_currentScrollChain;

  Member<Node> m_scrollGestureHandlingNode;

  bool m_lastGestureScrollOverWidget;

  // The most recent element to scroll natively during this scroll
  // sequence. Null if no native element has scrolled this scroll
  // sequence, or if the most recent element to scroll used scroll
  // customization.
  Member<Element> m_previousGestureScrolledElement;

  // True iff some of the delta has been consumed for the current
  // scroll sequence in this frame, or any child frames. Only used
  // with ScrollCustomization. If some delta has been consumed, a
  // scroll which shouldn't propagate can't cause any element to
  // scroll other than the |m_previousGestureScrolledNode|.
  bool m_deltaConsumedForScrollSequence;

  Member<Scrollbar> m_scrollbarHandlingScrollGesture;

  Member<PaintLayerScrollableArea> m_resizeScrollableArea;

  LayoutSize
      m_offsetFromResizeCorner;  // In the coords of m_resizeScrollableArea.
};

}  // namespace blink

#endif  // ScrollManager_h