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

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

Powered by Google App Engine
This is Rietveld 408576698