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

Side by Side Diff: sky/engine/platform/scroll/ScrollableArea.h

Issue 711483003: Deduplicate part of RenderLayerScrollableArea/ScrollableArea. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 1 month 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) 2008, 2011 Apple Inc. All Rights Reserved. 2 * Copyright (C) 2008, 2011 Apple 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 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 54
55 class PLATFORM_EXPORT ScrollableArea { 55 class PLATFORM_EXPORT ScrollableArea {
56 WTF_MAKE_NONCOPYABLE(ScrollableArea); 56 WTF_MAKE_NONCOPYABLE(ScrollableArea);
57 public: 57 public:
58 static int pixelsPerLineStep(); 58 static int pixelsPerLineStep();
59 static float minFractionToStepWhenPaging(); 59 static float minFractionToStepWhenPaging();
60 static int maxOverlapBetweenPages(); 60 static int maxOverlapBetweenPages();
61 61
62 // The window that hosts the ScrollView. The ScrollView will communicate scr olls and repaints to the 62 // The window that hosts the ScrollView. The ScrollView will communicate scr olls and repaints to the
63 // host window in the window's coordinate space. 63 // host window in the window's coordinate space.
64 virtual HostWindow* hostWindow() const { return 0; }; 64 virtual HostWindow* hostWindow() const = 0;
65 65
66 bool scroll(ScrollDirection, ScrollGranularity, float delta = 1); 66 bool scroll(ScrollDirection, ScrollGranularity, float delta = 1);
67 void scrollToOffsetWithoutAnimation(const FloatPoint&); 67 void scrollToOffsetWithoutAnimation(const FloatPoint&);
68 void scrollToOffsetWithoutAnimation(ScrollbarOrientation, float offset); 68 void scrollToOffsetWithoutAnimation(ScrollbarOrientation, float offset);
69 69
70 void programmaticallyScrollSmoothlyToOffset(const FloatPoint&); 70 void programmaticallyScrollSmoothlyToOffset(const FloatPoint&);
71 71
72 // Should be called when the scroll position changes externally, for example if the scroll layer position 72 // Should be called when the scroll position changes externally, for example if the scroll layer position
73 // is updated on the scrolling thread and we need to notify the main thread. 73 // is updated on the scrolling thread and we need to notify the main thread.
74 void notifyScrollPositionChanged(const IntPoint&); 74 void notifyScrollPositionChanged(const IntPoint&);
(...skipping 19 matching lines...) Expand all
94 void mouseEnteredContentArea() const; 94 void mouseEnteredContentArea() const;
95 void mouseExitedContentArea() const; 95 void mouseExitedContentArea() const;
96 void mouseMovedInContentArea() const; 96 void mouseMovedInContentArea() const;
97 void mouseEnteredScrollbar(Scrollbar*) const; 97 void mouseEnteredScrollbar(Scrollbar*) const;
98 void mouseExitedScrollbar(Scrollbar*) const; 98 void mouseExitedScrollbar(Scrollbar*) const;
99 void contentAreaDidShow() const; 99 void contentAreaDidShow() const;
100 void contentAreaDidHide() const; 100 void contentAreaDidHide() const;
101 101
102 void finishCurrentScrollAnimations() const; 102 void finishCurrentScrollAnimations() const;
103 103
104 virtual void didAddScrollbar(Scrollbar*, ScrollbarOrientation); 104 void didAddScrollbar(Scrollbar*, ScrollbarOrientation);
105 virtual void willRemoveScrollbar(Scrollbar*, ScrollbarOrientation); 105 void willRemoveScrollbar(Scrollbar*, ScrollbarOrientation);
106 106
107 virtual void contentsResized(); 107 void contentsResized();
108 108
109 bool hasOverlayScrollbars() const; 109 bool hasOverlayScrollbars() const;
110 void setScrollbarOverlayStyle(ScrollbarOverlayStyle); 110 void setScrollbarOverlayStyle(ScrollbarOverlayStyle);
111 ScrollbarOverlayStyle scrollbarOverlayStyle() const { return static_cast<Scr ollbarOverlayStyle>(m_scrollbarOverlayStyle); } 111 ScrollbarOverlayStyle scrollbarOverlayStyle() const { return static_cast<Scr ollbarOverlayStyle>(m_scrollbarOverlayStyle); }
112 112
113 // This getter will create a ScrollAnimator if it doesn't already exist. 113 // This getter will create a ScrollAnimator if it doesn't already exist.
114 ScrollAnimator* scrollAnimator() const; 114 ScrollAnimator* scrollAnimator() const;
115 115
116 // This getter will return null if the ScrollAnimator hasn't been created ye t. 116 // This getter will return null if the ScrollAnimator hasn't been created ye t.
117 ScrollAnimator* existingScrollAnimator() const { return m_animators ? m_anim ators->scrollAnimator.get() : 0; } 117 ScrollAnimator* existingScrollAnimator() const { return m_animators ? m_anim ators->scrollAnimator.get() : 0; }
118 118
119 ProgrammaticScrollAnimator* programmaticScrollAnimator() const; 119 ProgrammaticScrollAnimator* programmaticScrollAnimator() const;
120 ProgrammaticScrollAnimator* existingProgrammaticScrollAnimator() const 120 ProgrammaticScrollAnimator* existingProgrammaticScrollAnimator() const
121 { 121 {
122 return m_animators ? m_animators->programmaticScrollAnimator.get() : 0; 122 return m_animators ? m_animators->programmaticScrollAnimator.get() : 0;
123 } 123 }
124 124
125 const IntPoint& scrollOrigin() const { return m_scrollOrigin; } 125 const IntPoint& scrollOrigin() const { return m_scrollOrigin; }
126 bool scrollOriginChanged() const { return m_scrollOriginChanged; } 126 bool scrollOriginChanged() const { return m_scrollOriginChanged; }
127 127
128 // FIXME(bokan): Meaningless name, rename to isActiveFocus 128 // FIXME(bokan): Meaningless name, rename to isActiveFocus
129 virtual bool isActive() const = 0; 129 virtual bool isActive() const = 0;
130 virtual int scrollSize(ScrollbarOrientation) const = 0; 130 virtual int scrollSize(ScrollbarOrientation) const = 0;
131 virtual void invalidateScrollbar(Scrollbar*, const IntRect&); 131 void invalidateScrollbar(Scrollbar*, const IntRect&);
132 132
133 // Convert points and rects between the scrollbar and its containing view. 133 // Convert points and rects between the scrollbar and its containing view.
134 // The client needs to implement these in order to be aware of layout effect s 134 // The client needs to implement these in order to be aware of layout effect s
135 // like CSS transforms. 135 // like CSS transforms.
136 virtual IntRect convertFromScrollbarToContainingView(const Scrollbar* scroll bar, const IntRect& scrollbarRect) const = 0; 136 virtual IntRect convertFromScrollbarToContainingView(const Scrollbar*, const IntRect&) const = 0;
137 virtual IntRect convertFromContainingViewToScrollbar(const Scrollbar* scroll bar, const IntRect& parentRect) const = 0; 137 virtual IntRect convertFromContainingViewToScrollbar(const Scrollbar*, const IntRect&) const = 0;
138 virtual IntPoint convertFromScrollbarToContainingView(const Scrollbar* scrol lbar, const IntPoint& scrollbarPoint) const = 0; 138 virtual IntPoint convertFromScrollbarToContainingView(const Scrollbar*, cons t IntPoint&) const = 0;
139 virtual IntPoint convertFromContainingViewToScrollbar(const Scrollbar* scrol lbar, const IntPoint& parentPoint) const = 0; 139 virtual IntPoint convertFromContainingViewToScrollbar(const Scrollbar*, cons t IntPoint&) const = 0;
140 140
141 virtual Scrollbar* horizontalScrollbar() const = 0; 141 virtual Scrollbar* horizontalScrollbar() const = 0;
142 virtual Scrollbar* verticalScrollbar() const = 0; 142 virtual Scrollbar* verticalScrollbar() const = 0;
143 143
144 // scrollPosition is relative to the scrollOrigin. i.e. If the page is RTL 144 // scrollPosition is relative to the scrollOrigin. i.e. If the page is RTL
145 // then scrollPosition will be negative. 145 // then scrollPosition will be negative.
146 virtual IntPoint scrollPosition() const = 0; 146 virtual IntPoint scrollPosition() const = 0;
147 virtual IntPoint minimumScrollPosition() const = 0; 147 virtual IntPoint minimumScrollPosition() const = 0;
148 virtual IntPoint maximumScrollPosition() const = 0; 148 virtual IntPoint maximumScrollPosition() const = 0;
149 149
150 virtual IntRect visibleContentRect(IncludeScrollbarsInRect = ExcludeScrollba rs) const;
151 virtual int visibleHeight() const = 0;
152 virtual int visibleWidth() const = 0;
153 virtual IntSize contentsSize() const = 0; 150 virtual IntSize contentsSize() const = 0;
154 virtual IntSize overhangAmount() const { return IntSize(); }
155 virtual IntPoint lastKnownMousePosition() const { return IntPoint(); }
156 151
157 virtual bool shouldSuspendScrollAnimations() const { return true; } 152 bool shouldSuspendScrollAnimations() const { return true; }
158
159 // Returns the bounding box of this scrollable area, in the coordinate syste m of the enclosing scroll view.
160 virtual IntRect scrollableAreaBoundingBox() const = 0;
161 153
162 // NOTE: Only called from Internals for testing. 154 // NOTE: Only called from Internals for testing.
163 void setScrollOffsetFromInternals(const IntPoint&); 155 void setScrollOffsetFromInternals(const IntPoint&);
164 156
165 IntPoint clampScrollPosition(const IntPoint&) const; 157 IntPoint clampScrollPosition(const IntPoint&) const;
166 158
167 // Let subclasses provide a way of asking for and servicing scroll 159 // Let subclasses provide a way of asking for and servicing scroll
168 // animations. 160 // animations.
169 bool scheduleAnimation(); 161 bool scheduleAnimation();
170 void serviceScrollAnimations(double monotonicTime); 162 void serviceScrollAnimations(double monotonicTime);
171 163
172 // Returns true if the GraphicsLayer tree needs to be rebuilt. 164 // Returns true if the GraphicsLayer tree needs to be rebuilt.
173 virtual bool updateAfterCompositingChange() { return false; } 165 virtual bool updateAfterCompositingChange() = 0;
174 166
175 virtual bool userInputScrollable(ScrollbarOrientation) const = 0; 167 virtual bool userInputScrollable(ScrollbarOrientation) const = 0;
176 virtual bool shouldPlaceVerticalScrollbarOnLeft() const = 0; 168 virtual bool shouldPlaceVerticalScrollbarOnLeft() const = 0;
177 169
178 // Convenience functions
179 int scrollPosition(ScrollbarOrientation orientation) { return orientation == HorizontalScrollbar ? scrollPosition().x() : scrollPosition().y(); } 170 int scrollPosition(ScrollbarOrientation orientation) { return orientation == HorizontalScrollbar ? scrollPosition().x() : scrollPosition().y(); }
180 int minimumScrollPosition(ScrollbarOrientation orientation) { return orienta tion == HorizontalScrollbar ? minimumScrollPosition().x() : minimumScrollPositio n().y(); } 171 int minimumScrollPosition(ScrollbarOrientation orientation) { return orienta tion == HorizontalScrollbar ? minimumScrollPosition().x() : minimumScrollPositio n().y(); }
181 int maximumScrollPosition(ScrollbarOrientation orientation) { return orienta tion == HorizontalScrollbar ? maximumScrollPosition().x() : maximumScrollPositio n().y(); } 172 int maximumScrollPosition(ScrollbarOrientation orientation) { return orienta tion == HorizontalScrollbar ? maximumScrollPosition().x() : maximumScrollPositio n().y(); }
182 int clampScrollPosition(ScrollbarOrientation orientation, int pos) { return std::max(std::min(pos, maximumScrollPosition(orientation)), minimumScrollPositi on(orientation)); } 173 int clampScrollPosition(ScrollbarOrientation orientation, int pos) { return std::max(std::min(pos, maximumScrollPosition(orientation)), minimumScrollPositi on(orientation)); }
183 174
184 bool hasVerticalBarDamage() const { return !m_verticalBarDamage.isEmpty(); } 175 bool hasVerticalBarDamage() const { return !m_verticalBarDamage.isEmpty(); }
185 bool hasHorizontalBarDamage() const { return !m_horizontalBarDamage.isEmpty( ); } 176 bool hasHorizontalBarDamage() const { return !m_horizontalBarDamage.isEmpty( ); }
186 const IntRect& verticalBarDamage() const { return m_verticalBarDamage; } 177 const IntRect& verticalBarDamage() const { return m_verticalBarDamage; }
187 const IntRect& horizontalBarDamage() const { return m_horizontalBarDamage; } 178 const IntRect& horizontalBarDamage() const { return m_horizontalBarDamage; }
188 179
189 void addScrollbarDamage(Scrollbar* scrollbar, const IntRect& rect) 180 void addScrollbarDamage(Scrollbar* scrollbar, const IntRect& rect)
190 { 181 {
191 if (scrollbar == horizontalScrollbar()) 182 if (scrollbar == horizontalScrollbar())
192 m_horizontalBarDamage.unite(rect); 183 m_horizontalBarDamage.unite(rect);
193 else 184 else
194 m_verticalBarDamage.unite(rect); 185 m_verticalBarDamage.unite(rect);
195 } 186 }
196 187
197 void resetScrollbarDamage() 188 void resetScrollbarDamage()
198 { 189 {
199 m_verticalBarDamage = IntRect(); 190 m_verticalBarDamage = IntRect();
200 m_horizontalBarDamage = IntRect(); 191 m_horizontalBarDamage = IntRect();
201 } 192 }
202 193
203 virtual GraphicsLayer* layerForContainer() const; 194 GraphicsLayer* layerForContainer() const;
204 virtual GraphicsLayer* layerForScrolling() const { return 0; } 195 virtual GraphicsLayer* layerForScrolling() const = 0;
205 virtual GraphicsLayer* layerForHorizontalScrollbar() const { return 0; } 196 virtual GraphicsLayer* layerForHorizontalScrollbar() const = 0;
206 virtual GraphicsLayer* layerForVerticalScrollbar() const { return 0; } 197 virtual GraphicsLayer* layerForVerticalScrollbar() const = 0;
207 bool hasLayerForHorizontalScrollbar() const; 198 bool hasLayerForHorizontalScrollbar() const;
208 bool hasLayerForVerticalScrollbar() const; 199 bool hasLayerForVerticalScrollbar() const;
209 200
210 void cancelProgrammaticScrollAnimation(); 201 void cancelProgrammaticScrollAnimation();
211 202
212 protected: 203 protected:
213 ScrollableArea(); 204 ScrollableArea();
214 virtual ~ScrollableArea(); 205 virtual ~ScrollableArea();
215 206
216 void setScrollOrigin(const IntPoint&); 207 void setScrollOrigin(const IntPoint&);
217 void resetScrollOriginChanged() { m_scrollOriginChanged = false; } 208 void resetScrollOriginChanged() { m_scrollOriginChanged = false; }
218 209
219 virtual void invalidateScrollbarRect(Scrollbar*, const IntRect&) = 0; 210 virtual void invalidateScrollbarRect(Scrollbar*, const IntRect&) = 0;
220 211
221 private: 212 private:
222 void scrollPositionChanged(const IntPoint&); 213 void scrollPositionChanged(const IntPoint&);
223 214
224 // NOTE: Only called from the ScrollAnimator. 215 // NOTE: Only called from the ScrollAnimator.
225 friend class ScrollAnimator; 216 friend class ScrollAnimator;
226 void setScrollOffsetFromAnimation(const IntPoint&); 217 void setScrollOffsetFromAnimation(const IntPoint&);
227 218
228 // This function should be overriden by subclasses to perform the actual 219 // This function should be overriden by subclasses to perform the actual
229 // scroll of the content. 220 // scroll of the content.
230 virtual void setScrollOffset(const IntPoint&) = 0; 221 virtual void setScrollOffset(const IntPoint&) = 0;
231 222
232 virtual int lineStep(ScrollbarOrientation) const; 223 int lineStep(ScrollbarOrientation) const;
233 virtual int pageStep(ScrollbarOrientation) const; 224 int documentStep(ScrollbarOrientation) const;
234 virtual int documentStep(ScrollbarOrientation) const; 225 virtual int pageStep(ScrollbarOrientation) const = 0;
235 virtual float pixelStep(ScrollbarOrientation) const; 226 float pixelStep(ScrollbarOrientation) const;
236 227
237 // Stores the paint invalidations for the scrollbars during layout. 228 // Stores the paint invalidations for the scrollbars during layout.
238 IntRect m_horizontalBarDamage; 229 IntRect m_horizontalBarDamage;
239 IntRect m_verticalBarDamage; 230 IntRect m_verticalBarDamage;
240 231
241 struct ScrollableAreaAnimators { 232 struct ScrollableAreaAnimators {
242 OwnPtr<ScrollAnimator> scrollAnimator; 233 OwnPtr<ScrollAnimator> scrollAnimator;
243 OwnPtr<ProgrammaticScrollAnimator> programmaticScrollAnimator; 234 OwnPtr<ProgrammaticScrollAnimator> programmaticScrollAnimator;
244 }; 235 };
245 236
(...skipping 19 matching lines...) Expand all
265 // vertical-lr / ltr NO NO 256 // vertical-lr / ltr NO NO
266 // vertical-lr / rtl NO YES 257 // vertical-lr / rtl NO YES
267 // vertical-rl / ltr YES NO 258 // vertical-rl / ltr YES NO
268 // vertical-rl / rtl YES YES 259 // vertical-rl / rtl YES YES
269 IntPoint m_scrollOrigin; 260 IntPoint m_scrollOrigin;
270 }; 261 };
271 262
272 } // namespace blink 263 } // namespace blink
273 264
274 #endif // ScrollableArea_h 265 #endif // ScrollableArea_h
OLDNEW
« no previous file with comments | « sky/engine/core/rendering/RenderLayerScrollableArea.h ('k') | sky/engine/platform/scroll/ScrollableArea.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698