| 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 if (!userInputScrollable(HorizontalScrollbar)) |
| 169 pixelDelta.setWidth(0); |
| 170 if (!userInputScrollable(VerticalScrollbar)) |
| 171 pixelDelta.setHeight(0); |
| 172 |
| 173 if (pixelDelta.isZero()) |
| 174 return ScrollResult(false, false, delta.width(), delta.height()); |
| 165 | 175 |
| 166 cancelProgrammaticScrollAnimation(); | 176 cancelProgrammaticScrollAnimation(); |
| 167 | 177 |
| 168 float step = scrollStep(granularity, orientation); | 178 return scrollAnimator().userScroll(granularity, pixelDelta); |
| 169 | |
| 170 if (direction == ScrollUp || direction == ScrollLeft) | |
| 171 delta = -delta; | |
| 172 | |
| 173 return scrollAnimator().userScroll(orientation, granularity, step * delta); | |
| 174 } | 179 } |
| 175 | 180 |
| 176 void ScrollableArea::setScrollPosition(const DoublePoint& position, ScrollType s
crollType, ScrollBehavior behavior) | 181 void ScrollableArea::setScrollPosition(const DoublePoint& position, ScrollType s
crollType, ScrollBehavior behavior) |
| 177 { | 182 { |
| 178 if (behavior == ScrollBehaviorAuto) | 183 if (behavior == ScrollBehaviorAuto) |
| 179 behavior = scrollBehaviorStyle(); | 184 behavior = scrollBehaviorStyle(); |
| 180 | 185 |
| 181 switch (scrollType) { | 186 switch (scrollType) { |
| 182 case CompositorScroll: | 187 case CompositorScroll: |
| 183 case AnchoringScroll: | 188 case AnchoringScroll: |
| (...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 617 std::max(0, size.height() - horizontalScrollbarHeight)); | 622 std::max(0, size.height() - horizontalScrollbarHeight)); |
| 618 } | 623 } |
| 619 | 624 |
| 620 DEFINE_TRACE(ScrollableArea) | 625 DEFINE_TRACE(ScrollableArea) |
| 621 { | 626 { |
| 622 visitor->trace(m_scrollAnimator); | 627 visitor->trace(m_scrollAnimator); |
| 623 visitor->trace(m_programmaticScrollAnimator); | 628 visitor->trace(m_programmaticScrollAnimator); |
| 624 } | 629 } |
| 625 | 630 |
| 626 } // namespace blink | 631 } // namespace blink |
| OLD | NEW |