| 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 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 return documentStep(orientation); | 150 return documentStep(orientation); |
| 151 case ScrollByPixel: | 151 case ScrollByPixel: |
| 152 case ScrollByPrecisePixel: | 152 case ScrollByPrecisePixel: |
| 153 return pixelStep(orientation); | 153 return pixelStep(orientation); |
| 154 default: | 154 default: |
| 155 ASSERT_NOT_REACHED(); | 155 ASSERT_NOT_REACHED(); |
| 156 return 0.0f; | 156 return 0.0f; |
| 157 } | 157 } |
| 158 } | 158 } |
| 159 | 159 |
| 160 ScrollResultOneDimensional ScrollableArea::userScroll(ScrollDirectionPhysical di
rection, ScrollGranularity granularity, float delta) | 160 ScrollResult ScrollableArea::userScroll(ScrollGranularity granularity, const Flo
atSize& delta) |
| 161 { | 161 { |
| 162 ScrollbarOrientation orientation = scrollbarOrientationFromDirection(directi
on); | 162 float stepX = scrollStep(granularity, HorizontalScrollbar); |
| 163 if (!userInputScrollable(orientation)) | 163 float stepY = scrollStep(granularity, VerticalScrollbar); |
| 164 return ScrollResultOneDimensional(false, delta); | 164 |
| 165 FloatSize pixelDelta(delta); |
| 166 pixelDelta.scale(stepX, stepY); |
| 167 |
| 168 FloatSize scrollableAxisDelta( |
| 169 userInputScrollable(HorizontalScrollbar) ? pixelDelta.width() : 0, |
| 170 userInputScrollable(VerticalScrollbar) ? pixelDelta.height() : 0); |
| 171 |
| 172 if (scrollableAxisDelta.isZero()) { |
| 173 return ScrollResult( |
| 174 false, |
| 175 false, |
| 176 pixelDelta.width(), |
| 177 pixelDelta.height()); |
| 178 } |
| 165 | 179 |
| 166 cancelProgrammaticScrollAnimation(); | 180 cancelProgrammaticScrollAnimation(); |
| 167 | 181 |
| 168 float step = scrollStep(granularity, orientation); | 182 ScrollResult result = scrollAnimator().userScroll(granularity, pixelDelta); |
| 169 | 183 |
| 170 if (direction == ScrollUp || direction == ScrollLeft) | 184 // Delta that wasn't scrolled because the axis is !userInputScrollable |
| 171 delta = -delta; | 185 // should count as unusedScrollDelta. |
| 186 FloatSize unscrollableAxisDelta = pixelDelta - scrollableAxisDelta; |
| 187 result.unusedScrollDeltaX += unscrollableAxisDelta.width(); |
| 188 result.unusedScrollDeltaY += unscrollableAxisDelta.height(); |
| 172 | 189 |
| 173 return scrollAnimator().userScroll(orientation, granularity, step * delta); | 190 return result; |
| 174 } | 191 } |
| 175 | 192 |
| 176 void ScrollableArea::setScrollPosition(const DoublePoint& position, ScrollType s
crollType, ScrollBehavior behavior) | 193 void ScrollableArea::setScrollPosition(const DoublePoint& position, ScrollType s
crollType, ScrollBehavior behavior) |
| 177 { | 194 { |
| 178 if (behavior == ScrollBehaviorAuto) | 195 if (behavior == ScrollBehaviorAuto) |
| 179 behavior = scrollBehaviorStyle(); | 196 behavior = scrollBehaviorStyle(); |
| 180 | 197 |
| 181 switch (scrollType) { | 198 switch (scrollType) { |
| 182 case CompositorScroll: | 199 case CompositorScroll: |
| 183 case AnchoringScroll: | 200 case AnchoringScroll: |
| (...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 617 std::max(0, size.height() - horizontalScrollbarHeight)); | 634 std::max(0, size.height() - horizontalScrollbarHeight)); |
| 618 } | 635 } |
| 619 | 636 |
| 620 DEFINE_TRACE(ScrollableArea) | 637 DEFINE_TRACE(ScrollableArea) |
| 621 { | 638 { |
| 622 visitor->trace(m_scrollAnimator); | 639 visitor->trace(m_scrollAnimator); |
| 623 visitor->trace(m_programmaticScrollAnimator); | 640 visitor->trace(m_programmaticScrollAnimator); |
| 624 } | 641 } |
| 625 | 642 |
| 626 } // namespace blink | 643 } // namespace blink |
| OLD | NEW |