| 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 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 m_scrollOrigin = origin; | 115 m_scrollOrigin = origin; |
| 116 m_scrollOriginChanged = true; | 116 m_scrollOriginChanged = true; |
| 117 } | 117 } |
| 118 } | 118 } |
| 119 | 119 |
| 120 GraphicsLayer* ScrollableArea::layerForContainer() const | 120 GraphicsLayer* ScrollableArea::layerForContainer() const |
| 121 { | 121 { |
| 122 return layerForScrolling() ? layerForScrolling()->parent() : 0; | 122 return layerForScrolling() ? layerForScrolling()->parent() : 0; |
| 123 } | 123 } |
| 124 | 124 |
| 125 bool ScrollableArea::userScroll(ScrollDirectionPhysical direction, ScrollGranula
rity granularity, float delta) | 125 ScrollResultOneDimensional ScrollableArea::userScroll(ScrollDirectionPhysical di
rection, ScrollGranularity granularity, float delta) |
| 126 { | 126 { |
| 127 ScrollbarOrientation orientation; | 127 ScrollbarOrientation orientation; |
| 128 if (direction == ScrollUp || direction == ScrollDown) | 128 if (direction == ScrollUp || direction == ScrollDown) |
| 129 orientation = VerticalScrollbar; | 129 orientation = VerticalScrollbar; |
| 130 else | 130 else |
| 131 orientation = HorizontalScrollbar; | 131 orientation = HorizontalScrollbar; |
| 132 | 132 |
| 133 if (!userInputScrollable(orientation)) | 133 if (!userInputScrollable(orientation)) |
| 134 return false; | 134 return ScrollResultOneDimensional(false, delta); |
| 135 | 135 |
| 136 cancelProgrammaticScrollAnimation(); | 136 cancelProgrammaticScrollAnimation(); |
| 137 | 137 |
| 138 float step = 0; | 138 float step = 0; |
| 139 switch (granularity) { | 139 switch (granularity) { |
| 140 case ScrollByLine: | 140 case ScrollByLine: |
| 141 step = lineStep(orientation); | 141 step = lineStep(orientation); |
| 142 break; | 142 break; |
| 143 case ScrollByPage: | 143 case ScrollByPage: |
| 144 step = pageStep(orientation); | 144 step = pageStep(orientation); |
| 145 break; | 145 break; |
| 146 case ScrollByDocument: | 146 case ScrollByDocument: |
| 147 step = documentStep(orientation); | 147 step = documentStep(orientation); |
| 148 break; | 148 break; |
| 149 case ScrollByPixel: | 149 case ScrollByPixel: |
| 150 case ScrollByPrecisePixel: | 150 case ScrollByPrecisePixel: |
| 151 step = pixelStep(orientation); | 151 step = pixelStep(orientation); |
| 152 break; | 152 break; |
| 153 } | 153 } |
| 154 | 154 |
| 155 if (direction == ScrollUp || direction == ScrollLeft) | 155 if (direction == ScrollUp || direction == ScrollLeft) |
| 156 delta = -delta; | 156 delta = -delta; |
| 157 | 157 |
| 158 return scrollAnimator()->userScroll(orientation, granularity, step, delta).d
idScroll; | 158 return scrollAnimator()->userScroll(orientation, granularity, step, delta); |
| 159 } | 159 } |
| 160 | 160 |
| 161 void ScrollableArea::setScrollPosition(const DoublePoint& position, ScrollBehavi
or behavior) | 161 void ScrollableArea::setScrollPosition(const DoublePoint& position, ScrollBehavi
or behavior) |
| 162 { | 162 { |
| 163 // FIXME(417782): This should be unified with LayerScrollableArea::scrollToO
ffset. | 163 // FIXME(417782): This should be unified with LayerScrollableArea::scrollToO
ffset. |
| 164 ASSERT_NOT_REACHED(); | 164 ASSERT_NOT_REACHED(); |
| 165 } | 165 } |
| 166 | 166 |
| 167 void ScrollableArea::scrollToOffsetWithoutAnimation(const FloatPoint& offset, bo
ol cancelProgrammaticAnimations) | 167 void ScrollableArea::scrollToOffsetWithoutAnimation(const FloatPoint& offset, bo
ol cancelProgrammaticAnimations) |
| 168 { | 168 { |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 else | 268 else |
| 269 return false; | 269 return false; |
| 270 | 270 |
| 271 return true; | 271 return true; |
| 272 } | 272 } |
| 273 | 273 |
| 274 ScrollResult ScrollableArea::handleWheel(const PlatformWheelEvent& wheelEvent) | 274 ScrollResult ScrollableArea::handleWheel(const PlatformWheelEvent& wheelEvent) |
| 275 { | 275 { |
| 276 // Wheel events which do not scroll are used to trigger zooming. | 276 // Wheel events which do not scroll are used to trigger zooming. |
| 277 if (!wheelEvent.canScroll()) | 277 if (!wheelEvent.canScroll()) |
| 278 return ScrollResult(false); | 278 return ScrollResult(); |
| 279 | 279 |
| 280 cancelProgrammaticScrollAnimation(); | 280 cancelProgrammaticScrollAnimation(); |
| 281 return scrollAnimator()->handleWheelEvent(wheelEvent); | 281 return scrollAnimator()->handleWheelEvent(wheelEvent); |
| 282 } | 282 } |
| 283 | 283 |
| 284 IntPoint ScrollableArea::adjustScrollPositionWithinRange(const IntPoint& scrollP
oint) const | 284 IntPoint ScrollableArea::adjustScrollPositionWithinRange(const IntPoint& scrollP
oint) const |
| 285 { | 285 { |
| 286 if (!constrainsScrollingToContentEdge()) | 286 if (!constrainsScrollingToContentEdge()) |
| 287 return scrollPoint; | 287 return scrollPoint; |
| 288 | 288 |
| (...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 595 verticalScrollbarWidth = !verticalBar->isOverlayScrollbar() ? verticalBa
r->width() : 0; | 595 verticalScrollbarWidth = !verticalBar->isOverlayScrollbar() ? verticalBa
r->width() : 0; |
| 596 if (Scrollbar* horizontalBar = horizontalScrollbar()) | 596 if (Scrollbar* horizontalBar = horizontalScrollbar()) |
| 597 horizontalScrollbarHeight = !horizontalBar->isOverlayScrollbar() ? horiz
ontalBar->height() : 0; | 597 horizontalScrollbarHeight = !horizontalBar->isOverlayScrollbar() ? horiz
ontalBar->height() : 0; |
| 598 | 598 |
| 599 return IntSize(std::max(0, size.width() - verticalScrollbarWidth), | 599 return IntSize(std::max(0, size.width() - verticalScrollbarWidth), |
| 600 std::max(0, size.height() - horizontalScrollbarHeight)); | 600 std::max(0, size.height() - horizontalScrollbarHeight)); |
| 601 | 601 |
| 602 } | 602 } |
| 603 | 603 |
| 604 } // namespace blink | 604 } // namespace blink |
| OLD | NEW |