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, |
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 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
598 return IntSize(std::max(0, size.width() - verticalScrollbarWidth()), | 604 return IntSize(std::max(0, size.width() - verticalScrollbarWidth()), |
599 std::max(0, size.height() - horizontalScrollbarHeight())); | 605 std::max(0, size.height() - horizontalScrollbarHeight())); |
600 } | 606 } |
601 | 607 |
602 DEFINE_TRACE(ScrollableArea) { | 608 DEFINE_TRACE(ScrollableArea) { |
603 visitor->trace(m_scrollAnimator); | 609 visitor->trace(m_scrollAnimator); |
604 visitor->trace(m_programmaticScrollAnimator); | 610 visitor->trace(m_programmaticScrollAnimator); |
605 } | 611 } |
606 | 612 |
607 } // namespace blink | 613 } // namespace blink |
OLD | NEW |