| 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 19 matching lines...) Expand all Loading... |
| 30 */ | 30 */ |
| 31 | 31 |
| 32 #include "platform/scroll/ScrollableArea.h" | 32 #include "platform/scroll/ScrollableArea.h" |
| 33 | 33 |
| 34 #include "platform/PlatformChromeClient.h" | 34 #include "platform/PlatformChromeClient.h" |
| 35 #include "platform/graphics/GraphicsLayer.h" | 35 #include "platform/graphics/GraphicsLayer.h" |
| 36 #include "platform/instrumentation/tracing/TraceEvent.h" | 36 #include "platform/instrumentation/tracing/TraceEvent.h" |
| 37 #include "platform/scroll/MainThreadScrollingReason.h" | 37 #include "platform/scroll/MainThreadScrollingReason.h" |
| 38 #include "platform/scroll/ProgrammaticScrollAnimator.h" | 38 #include "platform/scroll/ProgrammaticScrollAnimator.h" |
| 39 #include "platform/scroll/ScrollbarTheme.h" | 39 #include "platform/scroll/ScrollbarTheme.h" |
| 40 #include "platform/scroll/SmoothScrollSequencer.h" | |
| 41 | 40 |
| 42 static const int kPixelsPerLineStep = 40; | 41 static const int kPixelsPerLineStep = 40; |
| 43 static const float kMinFractionToStepWhenPaging = 0.875f; | 42 static const float kMinFractionToStepWhenPaging = 0.875f; |
| 44 | 43 |
| 45 namespace blink { | 44 namespace blink { |
| 46 | 45 |
| 47 int ScrollableArea::PixelsPerLineStep(PlatformChromeClient* host) { | 46 int ScrollableArea::PixelsPerLineStep(PlatformChromeClient* host) { |
| 48 if (!host) | 47 if (!host) |
| 49 return kPixelsPerLineStep; | 48 return kPixelsPerLineStep; |
| 50 return host->WindowToViewportScalar(kPixelsPerLineStep); | 49 return host->WindowToViewportScalar(kPixelsPerLineStep); |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 // the scroll origin and the derived class versions differ on whether they | 220 // the scroll origin and the derived class versions differ on whether they |
| 222 // take that into account or not. | 221 // take that into account or not. |
| 223 ScrollableArea::SetScrollOffset(new_offset, scroll_type, behavior); | 222 ScrollableArea::SetScrollOffset(new_offset, scroll_type, behavior); |
| 224 } | 223 } |
| 225 | 224 |
| 226 void ScrollableArea::ProgrammaticScrollHelper(const ScrollOffset& offset, | 225 void ScrollableArea::ProgrammaticScrollHelper(const ScrollOffset& offset, |
| 227 ScrollBehavior scroll_behavior) { | 226 ScrollBehavior scroll_behavior) { |
| 228 CancelScrollAnimation(); | 227 CancelScrollAnimation(); |
| 229 | 228 |
| 230 if (scroll_behavior == kScrollBehaviorSmooth) | 229 if (scroll_behavior == kScrollBehaviorSmooth) |
| 231 GetProgrammaticScrollAnimator().AnimateToOffset(offset, true); | 230 GetProgrammaticScrollAnimator().AnimateToOffset(offset); |
| 232 else | 231 else |
| 233 GetProgrammaticScrollAnimator().ScrollToOffsetWithoutAnimation(offset); | 232 GetProgrammaticScrollAnimator().ScrollToOffsetWithoutAnimation(offset); |
| 234 } | 233 } |
| 235 | 234 |
| 236 void ScrollableArea::UserScrollHelper(const ScrollOffset& offset, | 235 void ScrollableArea::UserScrollHelper(const ScrollOffset& offset, |
| 237 ScrollBehavior scroll_behavior) { | 236 ScrollBehavior scroll_behavior) { |
| 238 CancelProgrammaticScrollAnimation(); | 237 CancelProgrammaticScrollAnimation(); |
| 239 | 238 |
| 240 float x = UserInputScrollable(kHorizontalScrollbar) | 239 float x = UserInputScrollable(kHorizontalScrollbar) |
| 241 ? offset.Width() | 240 ? offset.Width() |
| 242 : GetScrollAnimator().CurrentOffset().Width(); | 241 : GetScrollAnimator().CurrentOffset().Width(); |
| 243 float y = UserInputScrollable(kVerticalScrollbar) | 242 float y = UserInputScrollable(kVerticalScrollbar) |
| 244 ? offset.Height() | 243 ? offset.Height() |
| 245 : GetScrollAnimator().CurrentOffset().Height(); | 244 : GetScrollAnimator().CurrentOffset().Height(); |
| 246 | 245 |
| 247 // Smooth user scrolls (keyboard, wheel clicks) are handled via the userScroll | 246 // Smooth user scrolls (keyboard, wheel clicks) are handled via the userScroll |
| 248 // method. | 247 // method. |
| 249 // TODO(bokan): The userScroll method should probably be modified to call this | 248 // TODO(bokan): The userScroll method should probably be modified to call this |
| 250 // method and ScrollAnimatorBase to have a simpler | 249 // method and ScrollAnimatorBase to have a simpler |
| 251 // animateToOffset method like the ProgrammaticScrollAnimator. | 250 // animateToOffset method like the ProgrammaticScrollAnimator. |
| 252 DCHECK_EQ(scroll_behavior, kScrollBehaviorInstant); | 251 DCHECK_EQ(scroll_behavior, kScrollBehaviorInstant); |
| 253 GetScrollAnimator().ScrollToOffsetWithoutAnimation(ScrollOffset(x, y)); | 252 GetScrollAnimator().ScrollToOffsetWithoutAnimation(ScrollOffset(x, y)); |
| 254 } | 253 } |
| 255 | 254 |
| 256 LayoutRect ScrollableArea::ScrollIntoView(const LayoutRect& rect_in_content, | 255 LayoutRect ScrollableArea::ScrollIntoView(const LayoutRect& rect_in_content, |
| 257 const ScrollAlignment& align_x, | 256 const ScrollAlignment& align_x, |
| 258 const ScrollAlignment& align_y, | 257 const ScrollAlignment& align_y, |
| 259 bool is_smooth, | |
| 260 ScrollType) { | 258 ScrollType) { |
| 261 // TODO(bokan): This should really be implemented here but ScrollAlignment is | 259 // TODO(bokan): This should really be implemented here but ScrollAlignment is |
| 262 // in Core which is a dependency violation. | 260 // in Core which is a dependency violation. |
| 263 NOTREACHED(); | 261 NOTREACHED(); |
| 264 return LayoutRect(); | 262 return LayoutRect(); |
| 265 } | 263 } |
| 266 | 264 |
| 267 void ScrollableArea::ScrollOffsetChanged(const ScrollOffset& offset, | 265 void ScrollableArea::ScrollOffsetChanged(const ScrollOffset& offset, |
| 268 ScrollType scroll_type) { | 266 ScrollType scroll_type) { |
| 269 TRACE_EVENT0("blink", "ScrollableArea::scrollOffsetChanged"); | 267 TRACE_EVENT0("blink", "ScrollableArea::scrollOffsetChanged"); |
| (...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 673 offset.y() - ScrollOrigin().Y()); | 671 offset.y() - ScrollOrigin().Y()); |
| 674 SetScrollOffset(new_offset, kCompositorScroll); | 672 SetScrollOffset(new_offset, kCompositorScroll); |
| 675 } | 673 } |
| 676 | 674 |
| 677 DEFINE_TRACE(ScrollableArea) { | 675 DEFINE_TRACE(ScrollableArea) { |
| 678 visitor->Trace(scroll_animator_); | 676 visitor->Trace(scroll_animator_); |
| 679 visitor->Trace(programmatic_scroll_animator_); | 677 visitor->Trace(programmatic_scroll_animator_); |
| 680 } | 678 } |
| 681 | 679 |
| 682 } // namespace blink | 680 } // namespace blink |
| OLD | NEW |