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 case kScrollByLine: | 124 case kScrollByLine: |
125 return LineStep(orientation); | 125 return LineStep(orientation); |
126 case kScrollByPage: | 126 case kScrollByPage: |
127 return PageStep(orientation); | 127 return PageStep(orientation); |
128 case kScrollByDocument: | 128 case kScrollByDocument: |
129 return DocumentStep(orientation); | 129 return DocumentStep(orientation); |
130 case kScrollByPixel: | 130 case kScrollByPixel: |
131 case kScrollByPrecisePixel: | 131 case kScrollByPrecisePixel: |
132 return PixelStep(orientation); | 132 return PixelStep(orientation); |
133 default: | 133 default: |
134 ASSERT_NOT_REACHED(); | 134 NOTREACHED(); |
135 return 0.0f; | 135 return 0.0f; |
136 } | 136 } |
137 } | 137 } |
138 | 138 |
139 ScrollResult ScrollableArea::UserScroll(ScrollGranularity granularity, | 139 ScrollResult ScrollableArea::UserScroll(ScrollGranularity granularity, |
140 const ScrollOffset& delta) { | 140 const ScrollOffset& delta) { |
141 float step_x = ScrollStep(granularity, kHorizontalScrollbar); | 141 float step_x = ScrollStep(granularity, kHorizontalScrollbar); |
142 float step_y = ScrollStep(granularity, kVerticalScrollbar); | 142 float step_y = ScrollStep(granularity, kVerticalScrollbar); |
143 | 143 |
144 ScrollOffset pixel_delta(delta); | 144 ScrollOffset pixel_delta(delta); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 GetScrollAnimator().AdjustAnimationAndSetScrollOffset(clamped_offset, | 186 GetScrollAnimator().AdjustAnimationAndSetScrollOffset(clamped_offset, |
187 scroll_type); | 187 scroll_type); |
188 break; | 188 break; |
189 case kProgrammaticScroll: | 189 case kProgrammaticScroll: |
190 ProgrammaticScrollHelper(clamped_offset, behavior); | 190 ProgrammaticScrollHelper(clamped_offset, behavior); |
191 break; | 191 break; |
192 case kUserScroll: | 192 case kUserScroll: |
193 UserScrollHelper(clamped_offset, behavior); | 193 UserScrollHelper(clamped_offset, behavior); |
194 break; | 194 break; |
195 default: | 195 default: |
196 ASSERT_NOT_REACHED(); | 196 NOTREACHED(); |
197 } | 197 } |
198 } | 198 } |
199 | 199 |
200 void ScrollableArea::ScrollBy(const ScrollOffset& delta, | 200 void ScrollableArea::ScrollBy(const ScrollOffset& delta, |
201 ScrollType type, | 201 ScrollType type, |
202 ScrollBehavior behavior) { | 202 ScrollBehavior behavior) { |
203 SetScrollOffset(GetScrollOffset() + delta, type, behavior); | 203 SetScrollOffset(GetScrollOffset() + delta, type, behavior); |
204 } | 204 } |
205 | 205 |
206 void ScrollableArea::SetScrollOffsetSingleAxis(ScrollbarOrientation orientation, | 206 void ScrollableArea::SetScrollOffsetSingleAxis(ScrollbarOrientation orientation, |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
251 ASSERT(scroll_behavior == kScrollBehaviorInstant); | 251 ASSERT(scroll_behavior == kScrollBehaviorInstant); |
252 GetScrollAnimator().ScrollToOffsetWithoutAnimation(ScrollOffset(x, y)); | 252 GetScrollAnimator().ScrollToOffsetWithoutAnimation(ScrollOffset(x, y)); |
253 } | 253 } |
254 | 254 |
255 LayoutRect ScrollableArea::ScrollIntoView(const LayoutRect& rect_in_content, | 255 LayoutRect ScrollableArea::ScrollIntoView(const LayoutRect& rect_in_content, |
256 const ScrollAlignment& align_x, | 256 const ScrollAlignment& align_x, |
257 const ScrollAlignment& align_y, | 257 const ScrollAlignment& align_y, |
258 ScrollType) { | 258 ScrollType) { |
259 // TODO(bokan): This should really be implemented here but ScrollAlignment is | 259 // TODO(bokan): This should really be implemented here but ScrollAlignment is |
260 // in Core which is a dependency violation. | 260 // in Core which is a dependency violation. |
261 ASSERT_NOT_REACHED(); | 261 NOTREACHED(); |
262 return LayoutRect(); | 262 return LayoutRect(); |
263 } | 263 } |
264 | 264 |
265 void ScrollableArea::ScrollOffsetChanged(const ScrollOffset& offset, | 265 void ScrollableArea::ScrollOffsetChanged(const ScrollOffset& offset, |
266 ScrollType scroll_type) { | 266 ScrollType scroll_type) { |
267 TRACE_EVENT0("blink", "ScrollableArea::scrollOffsetChanged"); | 267 TRACE_EVENT0("blink", "ScrollableArea::scrollOffsetChanged"); |
268 | 268 |
269 ScrollOffset old_offset = GetScrollOffset(); | 269 ScrollOffset old_offset = GetScrollOffset(); |
270 ScrollOffset truncated_offset = ShouldUseIntegerScrollOffset() | 270 ScrollOffset truncated_offset = ShouldUseIntegerScrollOffset() |
271 ? ScrollOffset(FlooredIntSize(offset)) | 271 ? ScrollOffset(FlooredIntSize(offset)) |
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
671 offset.y() - ScrollOrigin().Y()); | 671 offset.y() - ScrollOrigin().Y()); |
672 SetScrollOffset(new_offset, kCompositorScroll); | 672 SetScrollOffset(new_offset, kCompositorScroll); |
673 } | 673 } |
674 | 674 |
675 DEFINE_TRACE(ScrollableArea) { | 675 DEFINE_TRACE(ScrollableArea) { |
676 visitor->Trace(scroll_animator_); | 676 visitor->Trace(scroll_animator_); |
677 visitor->Trace(programmatic_scroll_animator_); | 677 visitor->Trace(programmatic_scroll_animator_); |
678 } | 678 } |
679 | 679 |
680 } // namespace blink | 680 } // namespace blink |
OLD | NEW |