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

Side by Side Diff: third_party/WebKit/Source/platform/scroll/ScrollAnimatorBase.h

Issue 2387883002: Use float for scroll offset. (Closed)
Patch Set: Fix README.md Created 4 years, 2 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 /* 1 /*
2 * Copyright (c) 2010, Google Inc. All rights reserved. 2 * Copyright (c) 2010, Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 15 matching lines...) Expand all
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #ifndef ScrollAnimatorBase_h 31 #ifndef ScrollAnimatorBase_h
32 #define ScrollAnimatorBase_h 32 #define ScrollAnimatorBase_h
33 33
34 #include "platform/PlatformExport.h" 34 #include "platform/PlatformExport.h"
35 #include "platform/PlatformWheelEvent.h" 35 #include "platform/PlatformWheelEvent.h"
36 #include "platform/geometry/FloatPoint.h"
37 #include "platform/geometry/FloatSize.h"
38 #include "platform/heap/Handle.h" 36 #include "platform/heap/Handle.h"
39 #include "platform/scroll/ScrollAnimatorCompositorCoordinator.h" 37 #include "platform/scroll/ScrollAnimatorCompositorCoordinator.h"
40 #include "platform/scroll/ScrollTypes.h" 38 #include "platform/scroll/ScrollTypes.h"
41 #include "wtf/Forward.h" 39 #include "wtf/Forward.h"
42 40
43 namespace blink { 41 namespace blink {
44 42
45 class CompositorAnimationTimeline; 43 class CompositorAnimationTimeline;
46 class ScrollableArea; 44 class ScrollableArea;
47 class Scrollbar; 45 class Scrollbar;
48 46
49 class PLATFORM_EXPORT ScrollAnimatorBase 47 class PLATFORM_EXPORT ScrollAnimatorBase
50 : public ScrollAnimatorCompositorCoordinator { 48 : public ScrollAnimatorCompositorCoordinator {
51 public: 49 public:
52 static ScrollAnimatorBase* create(ScrollableArea*); 50 static ScrollAnimatorBase* create(ScrollableArea*);
53 51
54 virtual ~ScrollAnimatorBase(); 52 virtual ~ScrollAnimatorBase();
55 53
56 virtual void dispose() {} 54 virtual void dispose() {}
57 55
58 // A possibly animated scroll. The base class implementation always scrolls 56 // A possibly animated scroll. The base class implementation always scrolls
59 // immediately, never animates. If the scroll is animated and currently the 57 // immediately, never animates. If the scroll is animated and currently the
60 // animator has an in-progress animation, the ScrollResult will always return 58 // animator has an in-progress animation, the ScrollResult will always return
61 // no unusedDelta and didScroll=true, i.e. fully consuming the scroll request. 59 // no unusedDelta and didScroll=true, i.e. fully consuming the scroll request.
62 // This makes animations latch to a single scroller. Note, the semantics are 60 // This makes animations latch to a single scroller. Note, the semantics are
63 // currently somewhat different on Mac - see ScrollAnimatorMac.mm. 61 // currently somewhat different on Mac - see ScrollAnimatorMac.mm.
64 virtual ScrollResult userScroll(ScrollGranularity, const FloatSize& delta); 62 virtual ScrollResult userScroll(ScrollGranularity, const ScrollOffset& delta);
65 63
66 virtual void scrollToOffsetWithoutAnimation(const FloatPoint&); 64 virtual void scrollToOffsetWithoutAnimation(const ScrollOffset&);
67 65
68 #if OS(MACOSX) 66 #if OS(MACOSX)
69 virtual void handleWheelEventPhase(PlatformWheelEventPhase) {} 67 virtual void handleWheelEventPhase(PlatformWheelEventPhase) {}
70 #endif 68 #endif
71 69
72 void setCurrentPosition(const FloatPoint&); 70 void setCurrentOffset(const ScrollOffset&);
73 FloatPoint currentPosition() const; 71 ScrollOffset currentOffset() const;
74 virtual FloatPoint desiredTargetPosition() const { return currentPosition(); } 72 virtual ScrollOffset desiredTargetOffset() const { return currentOffset(); }
75 73
76 // Returns how much of pixelDelta will be used by the underlying scrollable 74 // Returns how much of pixelDelta will be used by the underlying scrollable
77 // area. 75 // area.
78 virtual FloatSize computeDeltaToConsume(const FloatSize& delta) const; 76 virtual ScrollOffset computeDeltaToConsume(const ScrollOffset& delta) const;
79 77
80 // ScrollAnimatorCompositorCoordinator implementation. 78 // ScrollAnimatorCompositorCoordinator implementation.
81 ScrollableArea* getScrollableArea() const override { 79 ScrollableArea* getScrollableArea() const override {
82 return m_scrollableArea; 80 return m_scrollableArea;
83 } 81 }
84 void tickAnimation(double monotonicTime) override{}; 82 void tickAnimation(double monotonicTime) override{};
85 void cancelAnimation() override {} 83 void cancelAnimation() override {}
86 void takeOverCompositorAnimation() override {} 84 void takeOverCompositorAnimation() override {}
87 void updateCompositorAnimations() override{}; 85 void updateCompositorAnimations() override{};
88 void notifyCompositorAnimationFinished(int groupId) override{}; 86 void notifyCompositorAnimationFinished(int groupId) override{};
(...skipping 16 matching lines...) Expand all
105 103
106 virtual void didAddVerticalScrollbar(Scrollbar&) {} 104 virtual void didAddVerticalScrollbar(Scrollbar&) {}
107 virtual void willRemoveVerticalScrollbar(Scrollbar&) {} 105 virtual void willRemoveVerticalScrollbar(Scrollbar&) {}
108 virtual void didAddHorizontalScrollbar(Scrollbar&) {} 106 virtual void didAddHorizontalScrollbar(Scrollbar&) {}
109 virtual void willRemoveHorizontalScrollbar(Scrollbar&) {} 107 virtual void willRemoveHorizontalScrollbar(Scrollbar&) {}
110 108
111 virtual bool shouldScrollbarParticipateInHitTesting(Scrollbar&) { 109 virtual bool shouldScrollbarParticipateInHitTesting(Scrollbar&) {
112 return true; 110 return true;
113 } 111 }
114 112
115 virtual void notifyContentAreaScrolled(const FloatSize&) {} 113 virtual void notifyContentAreaScrolled(const ScrollOffset&) {}
116 114
117 virtual bool setScrollbarsVisibleForTesting(bool) { return false; } 115 virtual bool setScrollbarsVisibleForTesting(bool) { return false; }
118 116
119 DECLARE_VIRTUAL_TRACE(); 117 DECLARE_VIRTUAL_TRACE();
120 118
121 protected: 119 protected:
122 explicit ScrollAnimatorBase(ScrollableArea*); 120 explicit ScrollAnimatorBase(ScrollableArea*);
123 121
124 virtual void notifyPositionChanged(); 122 virtual void notifyOffsetChanged();
125 123
126 Member<ScrollableArea> m_scrollableArea; 124 Member<ScrollableArea> m_scrollableArea;
127 125
128 FloatPoint m_currentPos; 126 ScrollOffset m_currentOffset;
129 }; 127 };
130 128
131 } // namespace blink 129 } // namespace blink
132 130
133 #endif // ScrollAnimatorBase_h 131 #endif // ScrollAnimatorBase_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698