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

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

Issue 1646663002: Refactor Scroll Customization to share cc::ScrollStateData with blink. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix linking. Created 4 years, 10 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 ScrollState_h 5 #ifndef ScrollState_h
6 #define ScrollState_h 6 #define ScrollState_h
7 7
8 #include "bindings/core/v8/ExceptionState.h" 8 #include "bindings/core/v8/ExceptionState.h"
9 #include "bindings/core/v8/ScriptWrappable.h" 9 #include "bindings/core/v8/ScriptWrappable.h"
10 #include "core/CoreExport.h" 10 #include "core/CoreExport.h"
11 #include "core/dom/Element.h" 11 #include "core/dom/Element.h"
12 #include "public/platform/WebScrollStateData.h" 12 #include "core/page/scrolling/ScrollStateInit.h"
13 #include "platform/scroll/ScrollStateData.h"
14 #include <deque>
13 15
14 namespace blink { 16 namespace blink {
15 17
16 class CORE_EXPORT ScrollState final : public RefCountedWillBeGarbageCollectedFin alized<ScrollState>, public ScriptWrappable { 18 class CORE_EXPORT ScrollState final : public RefCountedWillBeGarbageCollectedFin alized<ScrollState>, public ScriptWrappable {
17 DEFINE_WRAPPERTYPEINFO(); 19 DEFINE_WRAPPERTYPEINFO();
18 20
19 public: 21 public:
20 static PassRefPtrWillBeRawPtr<ScrollState> create( 22 static PassRefPtrWillBeRawPtr<ScrollState> create(ScrollStateInit);
21 double deltaX, double deltaY, double deltaGranularity, double velocityX, 23 static PassRefPtrWillBeRawPtr<ScrollState> create(PassOwnPtr<ScrollStateData >);
22 double velocityY, bool inInertialPhase,
23 bool isBeginning = false, bool isEnding = false,
24 bool fromUserInput = false, bool shouldPropagate = true,
25 bool deltaConsumedForScrollSequence = false);
26
27 static PassRefPtrWillBeRawPtr<ScrollState> create(PassOwnPtr<WebScrollStateD ata>);
28 24
29 ~ScrollState() 25 ~ScrollState()
30 { 26 {
31 } 27 }
32 28
33 // Web exposed methods. 29 // Web exposed methods.
34 30
35 // Reduce deltas by x, y. 31 // Reduce deltas by x, y.
36 void consumeDelta(double x, double y, ExceptionState&); 32 void consumeDelta(double x, double y, ExceptionState&);
37 // Pops the first element off of |m_scrollChain| and calls |distributeScroll | on it. 33 // Pops the first element off of |m_scrollChain| and calls |distributeScroll | on it.
38 void distributeToScrollChainDescendant(); 34 void distributeToScrollChainDescendant();
35 int startPositionX() { return m_data->start_position_x; };
36 int startPositionY() { return m_data->start_position_y; };
39 // Positive when scrolling left. 37 // Positive when scrolling left.
40 double deltaX() const { return m_data->deltaX; }; 38 double deltaX() const { return m_data->delta_x; };
41 // Positive when scrolling up. 39 // Positive when scrolling up.
42 double deltaY() const { return m_data->deltaY; }; 40 double deltaY() const { return m_data->delta_y; };
43 // Indicates the smallest delta the input device can produce. 0 for unquanti zed inputs. 41 // Indicates the smallest delta the input device can produce. 0 for unquanti zed inputs.
44 double deltaGranularity() const { return m_data->deltaGranularity; }; 42 double deltaGranularity() const { return m_data->delta_granularity; };
45 // Positive if moving right. 43 // Positive if moving right.
46 double velocityX() const { return m_data->velocityX; }; 44 double velocityX() const { return m_data->velocity_x; };
47 // Positive if moving down. 45 // Positive if moving down.
48 double velocityY() const { return m_data->velocityY; }; 46 double velocityY() const { return m_data->velocity_y; };
49 // True for events dispatched after the users's gesture has finished. 47 // True for events dispatched after the users's gesture has finished.
50 bool inInertialPhase() const { return m_data->inInertialPhase; }; 48 bool inInertialPhase() const { return m_data->is_in_inertial_phase; };
51 // True if this is the first event for this scroll. 49 // True if this is the first event for this scroll.
52 bool isBeginning() const { return m_data->isBeginning; }; 50 bool isBeginning() const { return m_data->is_beginning; };
53 // True if this is the last event for this scroll. 51 // True if this is the last event for this scroll.
54 bool isEnding() const { return m_data->isEnding; }; 52 bool isEnding() const { return m_data->is_ending; };
55 // True if this scroll is the direct result of user input. 53 // True if this scroll is the direct result of user input.
56 bool fromUserInput() const { return m_data->fromUserInput; }; 54 bool fromUserInput() const { return m_data->from_user_input; };
55 // True if this scroll is the result of the user interacting directly with
56 // the screen, e.g., via touch.
57 bool isDirectManipulation() const { return m_data->is_direct_manipulation; }
57 // True if this scroll is allowed to bubble upwards. 58 // True if this scroll is allowed to bubble upwards.
58 bool shouldPropagate() const { return m_data->shouldPropagate; }; 59 bool shouldPropagate() const { return m_data->should_propagate; };
59 60
60 // Non web exposed methods. 61 // Non web exposed methods.
61 void consumeDeltaNative(double x, double y); 62 void consumeDeltaNative(double x, double y);
62 63
63 // TODO(tdresser): this needs to be web exposed. See crbug.com/483091. 64 // TODO(tdresser): this needs to be web exposed. See crbug.com/483091.
64 void setScrollChain(std::deque<int> scrollChain) 65 void setScrollChain(std::deque<int> scrollChain)
65 { 66 {
66 m_scrollChain = scrollChain; 67 m_scrollChain = scrollChain;
67 } 68 }
68 69
69 Element* currentNativeScrollingElement() const; 70 Element* currentNativeScrollingElement() const;
70 void setCurrentNativeScrollingElement(Element*); 71 void setCurrentNativeScrollingElement(Element*);
71 72
72 int currentNativeScrollingElementId() const;
73 void setCurrentNativeScrollingElementById(int elementId); 73 void setCurrentNativeScrollingElementById(int elementId);
74 74
75 bool deltaConsumedForScrollSequence() const 75 bool deltaConsumedForScrollSequence() const
76 { 76 {
77 return m_data->deltaConsumedForScrollSequence; 77 return m_data->delta_consumed_for_scroll_sequence;
78 } 78 }
79 79
80 // Scroll begin and end must propagate to all nodes to ensure 80 // Scroll begin and end must propagate to all nodes to ensure
81 // their state is updated. 81 // their state is updated.
82 bool fullyConsumed() const 82 bool fullyConsumed() const
83 { 83 {
84 return !m_data->deltaX && !m_data->deltaY && !m_data->isEnding && !m_dat a->isBeginning; 84 return !m_data->delta_x && !m_data->delta_y && !m_data->is_ending && !m_ data->is_beginning;
85 } 85 }
86 86
87 // These are only used for CompositorWorker scrolling, and should be gotten 87 ScrollStateData* data() const { return m_data.get(); }
88 // rid of eventually.
89 void setCausedScroll(bool x, bool y)
90 {
91 m_data->causedScrollX = x;
92 m_data->causedScrollY = y;
93 }
94
95 bool causedScrollX() const
96 {
97 return m_data->causedScrollX;
98 }
99
100 bool causedScrollY() const
101 {
102 return m_data->causedScrollY;
103 }
104
105 WebScrollStateData* data() const { return m_data.get(); }
106 88
107 DEFINE_INLINE_TRACE() {} 89 DEFINE_INLINE_TRACE() {}
108 90
109 private: 91 private:
110 ScrollState(); 92 ScrollState();
111 ScrollState(PassOwnPtr<WebScrollStateData>); 93 ScrollState(PassOwnPtr<ScrollStateData>);
112 PassOwnPtr<WebScrollStateData> m_data; 94 PassOwnPtr<ScrollStateData> m_data;
113 std::deque<int> m_scrollChain; 95 std::deque<int> m_scrollChain;
114 }; 96 };
115 97
116 } // namespace blink 98 } // namespace blink
117 99
118 #endif // ScrollState_h 100 #endif // ScrollState_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/input/EventHandler.cpp ('k') | third_party/WebKit/Source/core/page/scrolling/ScrollState.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698