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 ScrollbarOrientation ScrollableArea::scrollbarOrientationFromDirection(ScrollDir
ectionPhysical direction) const |
| 134 { |
| 135 return (direction == ScrollUp || direction == ScrollDown) ? VerticalScrollb
ar : HorizontalScrollbar; |
| 136 } |
| 137 |
| 138 float ScrollableArea::scrollStep(ScrollGranularity granularity, ScrollbarOrienta
tion orientation) const |
| 139 { |
| 140 switch (granularity) { |
| 141 case ScrollByLine: |
| 142 return lineStep(orientation); |
| 143 case ScrollByPage: |
| 144 return pageStep(orientation); |
| 145 case ScrollByDocument: |
| 146 return documentStep(orientation); |
| 147 case ScrollByPixel: |
| 148 case ScrollByPrecisePixel: |
| 149 return pixelStep(orientation); |
| 150 default: |
| 151 ASSERT_NOT_REACHED(); |
| 152 return 0.0f; |
| 153 } |
| 154 } |
| 155 |
133 ScrollResultOneDimensional ScrollableArea::userScroll(ScrollDirectionPhysical di
rection, ScrollGranularity granularity, float delta) | 156 ScrollResultOneDimensional ScrollableArea::userScroll(ScrollDirectionPhysical di
rection, ScrollGranularity granularity, float delta) |
134 { | 157 { |
135 ScrollbarOrientation orientation; | 158 ScrollbarOrientation orientation = scrollbarOrientationFromDirection(directi
on); |
136 if (direction == ScrollUp || direction == ScrollDown) | |
137 orientation = VerticalScrollbar; | |
138 else | |
139 orientation = HorizontalScrollbar; | |
140 | |
141 if (!userInputScrollable(orientation)) | 159 if (!userInputScrollable(orientation)) |
142 return ScrollResultOneDimensional(false, delta); | 160 return ScrollResultOneDimensional(false, delta); |
143 | 161 |
144 cancelProgrammaticScrollAnimation(); | 162 cancelProgrammaticScrollAnimation(); |
145 | 163 |
146 float step = 0; | 164 float step = scrollStep(granularity, orientation); |
147 switch (granularity) { | |
148 case ScrollByLine: | |
149 step = lineStep(orientation); | |
150 break; | |
151 case ScrollByPage: | |
152 step = pageStep(orientation); | |
153 break; | |
154 case ScrollByDocument: | |
155 step = documentStep(orientation); | |
156 break; | |
157 case ScrollByPixel: | |
158 case ScrollByPrecisePixel: | |
159 step = pixelStep(orientation); | |
160 break; | |
161 } | |
162 | 165 |
163 if (direction == ScrollUp || direction == ScrollLeft) | 166 if (direction == ScrollUp || direction == ScrollLeft) |
164 delta = -delta; | 167 delta = -delta; |
165 | 168 |
166 return scrollAnimator().userScroll(orientation, granularity, step, delta); | 169 return scrollAnimator().userScroll(orientation, granularity, step, delta); |
167 } | 170 } |
168 | 171 |
169 void ScrollableArea::setScrollPosition(const DoublePoint& position, ScrollType s
crollType, ScrollBehavior behavior) | 172 void ScrollableArea::setScrollPosition(const DoublePoint& position, ScrollType s
crollType, ScrollBehavior behavior) |
170 { | 173 { |
171 if (behavior == ScrollBehaviorAuto) | 174 if (behavior == ScrollBehaviorAuto) |
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
567 | 570 |
568 } | 571 } |
569 | 572 |
570 DEFINE_TRACE(ScrollableArea) | 573 DEFINE_TRACE(ScrollableArea) |
571 { | 574 { |
572 visitor->trace(m_scrollAnimator); | 575 visitor->trace(m_scrollAnimator); |
573 visitor->trace(m_programmaticScrollAnimator); | 576 visitor->trace(m_programmaticScrollAnimator); |
574 } | 577 } |
575 | 578 |
576 } // namespace blink | 579 } // namespace blink |
OLD | NEW |