OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2010, Google Inc. All rights reserved. | 2 * Copyright (c) 2010, Google Inc. All rights reserved. |
3 * Copyright (C) 2008, 2011 Apple Inc. All Rights Reserved. | 3 * Copyright (C) 2008, 2011 Apple Inc. All Rights Reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
7 * met: | 7 * met: |
8 * | 8 * |
9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
171 FloatSize unscrollableAxisDelta = pixelDelta - scrollableAxisDelta; | 171 FloatSize unscrollableAxisDelta = pixelDelta - scrollableAxisDelta; |
172 result.unusedScrollDeltaX += unscrollableAxisDelta.width(); | 172 result.unusedScrollDeltaX += unscrollableAxisDelta.width(); |
173 result.unusedScrollDeltaY += unscrollableAxisDelta.height(); | 173 result.unusedScrollDeltaY += unscrollableAxisDelta.height(); |
174 | 174 |
175 return result; | 175 return result; |
176 } | 176 } |
177 | 177 |
178 void ScrollableArea::setScrollPosition(const DoublePoint& position, | 178 void ScrollableArea::setScrollPosition(const DoublePoint& position, |
179 ScrollType scrollType, | 179 ScrollType scrollType, |
180 ScrollBehavior behavior) { | 180 ScrollBehavior behavior) { |
181 DoublePoint clampedPosition = clampScrollPosition(position); | |
182 if (shouldUseIntegerScrollOffset()) | |
183 clampedPosition = flooredIntPoint(clampedPosition); | |
184 if (clampedPosition == scrollPositionDouble()) | |
185 return; | |
186 | |
181 if (behavior == ScrollBehaviorAuto) | 187 if (behavior == ScrollBehaviorAuto) |
182 behavior = scrollBehaviorStyle(); | 188 behavior = scrollBehaviorStyle(); |
183 | 189 |
184 switch (scrollType) { | 190 switch (scrollType) { |
185 case CompositorScroll: | 191 case CompositorScroll: |
186 scrollPositionChanged(clampScrollPosition(position), scrollType); | 192 scrollPositionChanged(clampedPosition, scrollType); |
187 break; | 193 break; |
188 case AnchoringScroll: | 194 case AnchoringScroll: |
189 scrollAnimator().adjustAnimationAndSetScrollPosition(position, | 195 scrollAnimator().adjustAnimationAndSetScrollPosition(clampedPosition, |
bokan
2016/10/01 20:32:47
I think you can remove the clamps in ScrollAnimato
szager1
2016/10/02 19:35:28
Done.
| |
190 scrollType); | 196 scrollType); |
191 break; | 197 break; |
192 case ProgrammaticScroll: | 198 case ProgrammaticScroll: |
193 programmaticScrollHelper(position, behavior); | 199 programmaticScrollHelper(clampedPosition, behavior); |
194 break; | 200 break; |
195 case UserScroll: | 201 case UserScroll: |
196 userScrollHelper(position, behavior); | 202 userScrollHelper(clampedPosition, behavior); |
197 break; | 203 break; |
198 default: | 204 default: |
199 ASSERT_NOT_REACHED(); | 205 ASSERT_NOT_REACHED(); |
200 } | 206 } |
201 } | 207 } |
202 | 208 |
203 void ScrollableArea::scrollBy(const DoubleSize& delta, | 209 void ScrollableArea::scrollBy(const DoubleSize& delta, |
204 ScrollType type, | 210 ScrollType type, |
205 ScrollBehavior behavior) { | 211 ScrollBehavior behavior) { |
206 setScrollPosition(scrollPositionDouble() + delta, type, behavior); | 212 setScrollPosition(scrollPositionDouble() + delta, type, behavior); |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
264 | 270 |
265 void ScrollableArea::scrollPositionChanged(const DoublePoint& position, | 271 void ScrollableArea::scrollPositionChanged(const DoublePoint& position, |
266 ScrollType scrollType) { | 272 ScrollType scrollType) { |
267 TRACE_EVENT0("blink", "ScrollableArea::scrollPositionChanged"); | 273 TRACE_EVENT0("blink", "ScrollableArea::scrollPositionChanged"); |
268 | 274 |
269 DoublePoint oldPosition = scrollPositionDouble(); | 275 DoublePoint oldPosition = scrollPositionDouble(); |
270 DoublePoint truncatedPosition = | 276 DoublePoint truncatedPosition = |
271 shouldUseIntegerScrollOffset() ? flooredIntPoint(position) : position; | 277 shouldUseIntegerScrollOffset() ? flooredIntPoint(position) : position; |
272 | 278 |
273 // Tell the derived class to scroll its contents. | 279 // Tell the derived class to scroll its contents. |
274 setScrollOffset(truncatedPosition, scrollType); | 280 updateScrollPosition(truncatedPosition, scrollType); |
275 | 281 |
276 // Tell the scrollbars to update their thumb postions. | 282 // Tell the scrollbars to update their thumb postions. |
277 // If the scrollbar does not have its own layer, it must always be | 283 // If the scrollbar does not have its own layer, it must always be |
278 // invalidated to reflect the new thumb position, even if the theme did not | 284 // invalidated to reflect the new thumb position, even if the theme did not |
279 // invalidate any individual part. | 285 // invalidate any individual part. |
280 if (Scrollbar* horizontalScrollbar = this->horizontalScrollbar()) | 286 if (Scrollbar* horizontalScrollbar = this->horizontalScrollbar()) |
281 horizontalScrollbar->offsetDidChange(); | 287 horizontalScrollbar->offsetDidChange(); |
282 if (Scrollbar* verticalScrollbar = this->verticalScrollbar()) | 288 if (Scrollbar* verticalScrollbar = this->verticalScrollbar()) |
283 verticalScrollbar->offsetDidChange(); | 289 verticalScrollbar->offsetDidChange(); |
284 | 290 |
(...skipping 14 matching lines...) Expand all Loading... | |
299 behavior = ScrollBehaviorInstant; | 305 behavior = ScrollBehaviorInstant; |
300 else if (behaviorString == "smooth") | 306 else if (behaviorString == "smooth") |
301 behavior = ScrollBehaviorSmooth; | 307 behavior = ScrollBehaviorSmooth; |
302 else | 308 else |
303 return false; | 309 return false; |
304 | 310 |
305 return true; | 311 return true; |
306 } | 312 } |
307 | 313 |
308 // NOTE: Only called from Internals for testing. | 314 // NOTE: Only called from Internals for testing. |
309 void ScrollableArea::setScrollOffsetFromInternals(const IntPoint& offset) { | 315 void ScrollableArea::updateScrollPositionFromInternals( |
310 scrollPositionChanged(DoublePoint(offset), ProgrammaticScroll); | 316 const IntPoint& position) { |
317 scrollPositionChanged(DoublePoint(position), ProgrammaticScroll); | |
311 } | 318 } |
312 | 319 |
313 void ScrollableArea::contentAreaWillPaint() const { | 320 void ScrollableArea::contentAreaWillPaint() const { |
314 if (ScrollAnimatorBase* scrollAnimator = existingScrollAnimator()) | 321 if (ScrollAnimatorBase* scrollAnimator = existingScrollAnimator()) |
315 scrollAnimator->contentAreaWillPaint(); | 322 scrollAnimator->contentAreaWillPaint(); |
316 } | 323 } |
317 | 324 |
318 void ScrollableArea::mouseEnteredContentArea() const { | 325 void ScrollableArea::mouseEnteredContentArea() const { |
319 if (ScrollAnimatorBase* scrollAnimator = existingScrollAnimator()) | 326 if (ScrollAnimatorBase* scrollAnimator = existingScrollAnimator()) |
320 scrollAnimator->mouseEnteredContentArea(); | 327 scrollAnimator->mouseEnteredContentArea(); |
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
594 return IntSize(std::max(0, size.width() - verticalScrollbarWidth()), | 601 return IntSize(std::max(0, size.width() - verticalScrollbarWidth()), |
595 std::max(0, size.height() - horizontalScrollbarHeight())); | 602 std::max(0, size.height() - horizontalScrollbarHeight())); |
596 } | 603 } |
597 | 604 |
598 DEFINE_TRACE(ScrollableArea) { | 605 DEFINE_TRACE(ScrollableArea) { |
599 visitor->trace(m_scrollAnimator); | 606 visitor->trace(m_scrollAnimator); |
600 visitor->trace(m_programmaticScrollAnimator); | 607 visitor->trace(m_programmaticScrollAnimator); |
601 } | 608 } |
602 | 609 |
603 } // namespace blink | 610 } // namespace blink |
OLD | NEW |