Chromium Code Reviews| 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 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 124 m_scrollOrigin = origin; | 124 m_scrollOrigin = origin; |
| 125 m_scrollOriginChanged = true; | 125 m_scrollOriginChanged = true; |
| 126 } | 126 } |
| 127 } | 127 } |
| 128 | 128 |
| 129 GraphicsLayer* ScrollableArea::layerForContainer() const | 129 GraphicsLayer* ScrollableArea::layerForContainer() const |
| 130 { | 130 { |
| 131 return layerForScrolling() ? layerForScrolling()->parent() : 0; | 131 return layerForScrolling() ? layerForScrolling()->parent() : 0; |
| 132 } | 132 } |
| 133 | 133 |
| 134 ScrollResultOneDimensional ScrollableArea::userScroll(ScrollDirectionPhysical di rection, ScrollGranularity granularity, float delta) | 134 ScrollbarOrientation ScrollableArea::scrollbarOrientationFromDirection(ScrollDir ectionPhysical direction) |
| 135 { | 135 { |
| 136 ScrollbarOrientation orientation; | 136 ScrollbarOrientation orientation; |
| 137 if (direction == ScrollUp || direction == ScrollDown) | 137 if (direction == ScrollUp || direction == ScrollDown) |
| 138 orientation = VerticalScrollbar; | 138 orientation = VerticalScrollbar; |
|
bokan
2015/12/04 20:42:52
No need for the temp, just return VerticalScrollba
ymalik
2015/12/07 17:53:14
Done.
| |
| 139 else | 139 else |
| 140 orientation = HorizontalScrollbar; | 140 orientation = HorizontalScrollbar; |
| 141 return orientation; | |
| 142 } | |
| 141 | 143 |
| 142 if (!userInputScrollable(orientation)) | 144 float ScrollableArea::scrollStep(ScrollGranularity granularity, ScrollbarOrienta tion orientation) const |
| 143 return ScrollResultOneDimensional(false, delta); | 145 { |
| 144 | |
| 145 cancelProgrammaticScrollAnimation(); | |
| 146 | |
| 147 float step = 0; | 146 float step = 0; |
| 148 switch (granularity) { | 147 switch (granularity) { |
| 149 case ScrollByLine: | 148 case ScrollByLine: |
| 150 step = lineStep(orientation); | 149 step = lineStep(orientation); |
| 151 break; | 150 break; |
| 152 case ScrollByPage: | 151 case ScrollByPage: |
| 153 step = pageStep(orientation); | 152 step = pageStep(orientation); |
| 154 break; | 153 break; |
| 155 case ScrollByDocument: | 154 case ScrollByDocument: |
| 156 step = documentStep(orientation); | 155 step = documentStep(orientation); |
| 157 break; | 156 break; |
| 158 case ScrollByPixel: | 157 case ScrollByPixel: |
| 159 case ScrollByPrecisePixel: | 158 case ScrollByPrecisePixel: |
| 160 step = pixelStep(orientation); | 159 step = pixelStep(orientation); |
| 161 break; | 160 break; |
| 162 } | 161 } |
| 162 return step; | |
| 163 } | |
| 164 | |
| 165 ScrollResultOneDimensional ScrollableArea::userScroll(ScrollDirectionPhysical di rection, ScrollGranularity granularity, float delta) | |
| 166 { | |
| 167 ScrollbarOrientation orientation = scrollbarOrientationFromDirection(directi on); | |
| 168 if (!userInputScrollable(orientation)) | |
| 169 return ScrollResultOneDimensional(false, delta); | |
| 170 | |
| 171 cancelProgrammaticScrollAnimation(); | |
| 172 | |
| 173 float step = scrollStep(granularity, orientation); | |
| 163 | 174 |
| 164 if (direction == ScrollUp || direction == ScrollLeft) | 175 if (direction == ScrollUp || direction == ScrollLeft) |
| 165 delta = -delta; | 176 delta = -delta; |
| 166 | 177 |
| 167 return scrollAnimator()->userScroll(orientation, granularity, step, delta); | 178 return scrollAnimator()->userScroll(orientation, granularity, step, delta); |
| 168 } | 179 } |
| 169 | 180 |
| 170 void ScrollableArea::setScrollPosition(const DoublePoint& position, ScrollType s crollType, ScrollBehavior behavior) | 181 void ScrollableArea::setScrollPosition(const DoublePoint& position, ScrollType s crollType, ScrollBehavior behavior) |
| 171 { | 182 { |
| 172 if (behavior == ScrollBehaviorAuto) | 183 if (behavior == ScrollBehaviorAuto) |
| (...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 578 verticalScrollbarWidth = !verticalBar->isOverlayScrollbar() ? verticalBa r->width() : 0; | 589 verticalScrollbarWidth = !verticalBar->isOverlayScrollbar() ? verticalBa r->width() : 0; |
| 579 if (Scrollbar* horizontalBar = horizontalScrollbar()) | 590 if (Scrollbar* horizontalBar = horizontalScrollbar()) |
| 580 horizontalScrollbarHeight = !horizontalBar->isOverlayScrollbar() ? horiz ontalBar->height() : 0; | 591 horizontalScrollbarHeight = !horizontalBar->isOverlayScrollbar() ? horiz ontalBar->height() : 0; |
| 581 | 592 |
| 582 return IntSize(std::max(0, size.width() - verticalScrollbarWidth), | 593 return IntSize(std::max(0, size.width() - verticalScrollbarWidth), |
| 583 std::max(0, size.height() - horizontalScrollbarHeight)); | 594 std::max(0, size.height() - horizontalScrollbarHeight)); |
| 584 | 595 |
| 585 } | 596 } |
| 586 | 597 |
| 587 } // namespace blink | 598 } // namespace blink |
| OLD | NEW |