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 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 123 m_scrollOrigin = origin; | 123 m_scrollOrigin = origin; |
| 124 m_scrollOriginChanged = true; | 124 m_scrollOriginChanged = true; |
| 125 } | 125 } |
| 126 } | 126 } |
| 127 | 127 |
| 128 GraphicsLayer* ScrollableArea::layerForContainer() const | 128 GraphicsLayer* ScrollableArea::layerForContainer() const |
| 129 { | 129 { |
| 130 return layerForScrolling() ? layerForScrolling()->parent() : 0; | 130 return layerForScrolling() ? layerForScrolling()->parent() : 0; |
| 131 } | 131 } |
| 132 | 132 |
| 133 ScrollResultOneDimensional ScrollableArea::userScroll(ScrollDirectionPhysical di rection, ScrollGranularity granularity, float delta) | 133 ScrollbarOrientation ScrollableArea::scrollbarOrientationFromDirection(ScrollDir ectionPhysical direction) const |
| 134 { | 134 { |
| 135 ScrollbarOrientation orientation; | 135 return (direction == ScrollUp || direction == ScrollDown) ? VerticalScrollb ar : HorizontalScrollbar; |
| 136 if (direction == ScrollUp || direction == ScrollDown) | 136 } |
| 137 orientation = VerticalScrollbar; | |
| 138 else | |
| 139 orientation = HorizontalScrollbar; | |
| 140 | 137 |
| 141 if (!userInputScrollable(orientation)) | 138 float ScrollableArea::scrollStep(ScrollGranularity granularity, ScrollbarOrienta tion orientation) const |
| 142 return ScrollResultOneDimensional(false, delta); | 139 { |
| 143 | |
| 144 cancelProgrammaticScrollAnimation(); | |
| 145 | |
| 146 float step = 0; | 140 float step = 0; |
| 147 switch (granularity) { | 141 switch (granularity) { |
| 148 case ScrollByLine: | 142 case ScrollByLine: |
| 149 step = lineStep(orientation); | 143 step = lineStep(orientation); |
| 150 break; | 144 break; |
| 151 case ScrollByPage: | 145 case ScrollByPage: |
| 152 step = pageStep(orientation); | 146 step = pageStep(orientation); |
| 153 break; | 147 break; |
| 154 case ScrollByDocument: | 148 case ScrollByDocument: |
| 155 step = documentStep(orientation); | 149 step = documentStep(orientation); |
| 156 break; | 150 break; |
| 157 case ScrollByPixel: | 151 case ScrollByPixel: |
| 158 case ScrollByPrecisePixel: | 152 case ScrollByPrecisePixel: |
| 159 step = pixelStep(orientation); | 153 step = pixelStep(orientation); |
|
jbroman
2015/12/09 15:29:35
nit: This line is unreachable; please remove dupli
jbroman
2015/12/09 15:31:22
If this line isn't duplicated in your code, please
ymalik
2015/12/09 15:59:42
Yes. Not duplicated. Moved to using return. Thanks
| |
| 160 break; | 154 break; |
| 161 } | 155 } |
| 156 return step; | |
| 157 } | |
| 158 | |
| 159 ScrollResultOneDimensional ScrollableArea::userScroll(ScrollDirectionPhysical di rection, ScrollGranularity granularity, float delta) | |
| 160 { | |
| 161 ScrollbarOrientation orientation = scrollbarOrientationFromDirection(directi on); | |
| 162 if (!userInputScrollable(orientation)) | |
| 163 return ScrollResultOneDimensional(false, delta); | |
| 164 | |
| 165 cancelProgrammaticScrollAnimation(); | |
| 166 | |
| 167 float step = scrollStep(granularity, orientation); | |
| 162 | 168 |
| 163 if (direction == ScrollUp || direction == ScrollLeft) | 169 if (direction == ScrollUp || direction == ScrollLeft) |
| 164 delta = -delta; | 170 delta = -delta; |
| 165 | 171 |
| 166 return scrollAnimator()->userScroll(orientation, granularity, step, delta); | 172 return scrollAnimator()->userScroll(orientation, granularity, step, delta); |
| 167 } | 173 } |
| 168 | 174 |
| 169 void ScrollableArea::setScrollPosition(const DoublePoint& position, ScrollType s crollType, ScrollBehavior behavior) | 175 void ScrollableArea::setScrollPosition(const DoublePoint& position, ScrollType s crollType, ScrollBehavior behavior) |
| 170 { | 176 { |
| 171 if (behavior == ScrollBehaviorAuto) | 177 if (behavior == ScrollBehaviorAuto) |
| (...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 583 | 589 |
| 584 } | 590 } |
| 585 | 591 |
| 586 DEFINE_TRACE(ScrollableArea) | 592 DEFINE_TRACE(ScrollableArea) |
| 587 { | 593 { |
| 588 visitor->trace(m_scrollAnimator); | 594 visitor->trace(m_scrollAnimator); |
| 589 visitor->trace(m_programmaticScrollAnimator); | 595 visitor->trace(m_programmaticScrollAnimator); |
| 590 } | 596 } |
| 591 | 597 |
| 592 } // namespace blink | 598 } // namespace blink |
| OLD | NEW |