| Index: cc/input/single_scrollbar_animation_controller_thinning.cc
|
| diff --git a/cc/input/scrollbar_animation_controller_thinning.cc b/cc/input/single_scrollbar_animation_controller_thinning.cc
|
| similarity index 74%
|
| copy from cc/input/scrollbar_animation_controller_thinning.cc
|
| copy to cc/input/single_scrollbar_animation_controller_thinning.cc
|
| index 2006d98fddb44a0779c850a7be0c32edb12c5d1c..595288c97e8621b0cb25ba0cd5624c63abd2b152 100644
|
| --- a/cc/input/scrollbar_animation_controller_thinning.cc
|
| +++ b/cc/input/single_scrollbar_animation_controller_thinning.cc
|
| @@ -2,7 +2,7 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| -#include "cc/input/scrollbar_animation_controller_thinning.h"
|
| +#include "cc/input/single_scrollbar_animation_controller_thinning.h"
|
|
|
| #include "base/memory/ptr_util.h"
|
| #include "base/time/time.h"
|
| @@ -17,30 +17,34 @@ const float kDefaultMouseMoveDistanceToTriggerAnimation = 25.f;
|
|
|
| namespace cc {
|
|
|
| -std::unique_ptr<ScrollbarAnimationControllerThinning>
|
| -ScrollbarAnimationControllerThinning::Create(
|
| +std::unique_ptr<SingleScrollbarAnimationControllerThinning>
|
| +SingleScrollbarAnimationControllerThinning::Create(
|
| int scroll_layer_id,
|
| + ScrollbarOrientation orientation,
|
| ScrollbarAnimationControllerClient* client,
|
| base::TimeDelta delay_before_starting,
|
| base::TimeDelta resize_delay_before_starting,
|
| base::TimeDelta fade_duration,
|
| base::TimeDelta thinning_duration) {
|
| - return base::WrapUnique(new ScrollbarAnimationControllerThinning(
|
| - scroll_layer_id, client, delay_before_starting,
|
| + return base::WrapUnique(new SingleScrollbarAnimationControllerThinning(
|
| + scroll_layer_id, orientation, client, delay_before_starting,
|
| resize_delay_before_starting, fade_duration, thinning_duration));
|
| }
|
|
|
| -ScrollbarAnimationControllerThinning::ScrollbarAnimationControllerThinning(
|
| - int scroll_layer_id,
|
| - ScrollbarAnimationControllerClient* client,
|
| - base::TimeDelta delay_before_starting,
|
| - base::TimeDelta resize_delay_before_starting,
|
| - base::TimeDelta fade_duration,
|
| - base::TimeDelta thinning_duration)
|
| +SingleScrollbarAnimationControllerThinning::
|
| + SingleScrollbarAnimationControllerThinning(
|
| + int scroll_layer_id,
|
| + ScrollbarOrientation orientation,
|
| + ScrollbarAnimationControllerClient* client,
|
| + base::TimeDelta delay_before_starting,
|
| + base::TimeDelta resize_delay_before_starting,
|
| + base::TimeDelta fade_duration,
|
| + base::TimeDelta thinning_duration)
|
| : ScrollbarAnimationController(scroll_layer_id,
|
| client,
|
| delay_before_starting,
|
| resize_delay_before_starting),
|
| + orientation_(orientation),
|
| opacity_(0.0f),
|
| captured_(false),
|
| mouse_is_over_scrollbar_(false),
|
| @@ -55,9 +59,8 @@ ScrollbarAnimationControllerThinning::ScrollbarAnimationControllerThinning(
|
| ApplyThumbThicknessScale(kIdleThicknessScale);
|
| }
|
|
|
| -ScrollbarAnimationControllerThinning::~ScrollbarAnimationControllerThinning() {}
|
| -
|
| -void ScrollbarAnimationControllerThinning::RunAnimationFrame(float progress) {
|
| +void SingleScrollbarAnimationControllerThinning::RunAnimationFrame(
|
| + float progress) {
|
| if (captured_)
|
| return;
|
|
|
| @@ -77,14 +80,14 @@ void ScrollbarAnimationControllerThinning::RunAnimationFrame(float progress) {
|
| }
|
| }
|
|
|
| -const base::TimeDelta& ScrollbarAnimationControllerThinning::Duration() {
|
| +const base::TimeDelta& SingleScrollbarAnimationControllerThinning::Duration() {
|
| if (current_animating_property_ == OPACITY)
|
| return fade_duration_;
|
| else
|
| return thinning_duration_;
|
| }
|
|
|
| -void ScrollbarAnimationControllerThinning::DidMouseDown() {
|
| +void SingleScrollbarAnimationControllerThinning::DidMouseDown() {
|
| if (!mouse_is_over_scrollbar_ || opacity_ == 0.0f)
|
| return;
|
|
|
| @@ -94,7 +97,7 @@ void ScrollbarAnimationControllerThinning::DidMouseDown() {
|
| ApplyThumbThicknessScale(1.f);
|
| }
|
|
|
| -void ScrollbarAnimationControllerThinning::DidMouseUp() {
|
| +void SingleScrollbarAnimationControllerThinning::DidMouseUp() {
|
| if (!captured_ || opacity_ == 0.0f)
|
| return;
|
|
|
| @@ -111,7 +114,7 @@ void ScrollbarAnimationControllerThinning::DidMouseUp() {
|
| }
|
| }
|
|
|
| -void ScrollbarAnimationControllerThinning::DidMouseLeave() {
|
| +void SingleScrollbarAnimationControllerThinning::DidMouseLeave() {
|
| if (!mouse_is_over_scrollbar_ && !mouse_is_near_scrollbar_)
|
| return;
|
|
|
| @@ -126,7 +129,8 @@ void ScrollbarAnimationControllerThinning::DidMouseLeave() {
|
| StartAnimation();
|
| }
|
|
|
| -void ScrollbarAnimationControllerThinning::DidScrollUpdate(bool on_resize) {
|
| +void SingleScrollbarAnimationControllerThinning::DidScrollUpdate(
|
| + bool on_resize) {
|
| if (captured_)
|
| return;
|
|
|
| @@ -137,7 +141,9 @@ void ScrollbarAnimationControllerThinning::DidScrollUpdate(bool on_resize) {
|
| SetCurrentAnimatingProperty(OPACITY);
|
| }
|
|
|
| -void ScrollbarAnimationControllerThinning::DidMouseMoveNear(float distance) {
|
| +void SingleScrollbarAnimationControllerThinning::DidMouseMoveNear(
|
| + ScrollbarOrientation orientation,
|
| + float distance) {
|
| bool mouse_is_over_scrollbar = distance == 0.0f;
|
| bool mouse_is_near_scrollbar =
|
| distance < mouse_move_distance_to_trigger_animation_;
|
| @@ -164,11 +170,11 @@ void ScrollbarAnimationControllerThinning::DidMouseMoveNear(float distance) {
|
| StartAnimation();
|
| }
|
|
|
| -bool ScrollbarAnimationControllerThinning::ScrollbarsHidden() const {
|
| +bool SingleScrollbarAnimationControllerThinning::ScrollbarsHidden() const {
|
| return opacity_ == 0.0f;
|
| }
|
|
|
| -float ScrollbarAnimationControllerThinning::ThumbThicknessScaleAt(
|
| +float SingleScrollbarAnimationControllerThinning::ThumbThicknessScaleAt(
|
| float progress) {
|
| if (thickness_change_ == NONE)
|
| return mouse_is_near_scrollbar_ ? 1.f : kIdleThicknessScale;
|
| @@ -176,7 +182,7 @@ float ScrollbarAnimationControllerThinning::ThumbThicknessScaleAt(
|
| return ((1.f - kIdleThicknessScale) * factor) + kIdleThicknessScale;
|
| }
|
|
|
| -float ScrollbarAnimationControllerThinning::AdjustScale(
|
| +float SingleScrollbarAnimationControllerThinning::AdjustScale(
|
| float new_value,
|
| float current_value,
|
| AnimationChange animation_change,
|
| @@ -196,10 +202,13 @@ float ScrollbarAnimationControllerThinning::AdjustScale(
|
| return result;
|
| }
|
|
|
| -void ScrollbarAnimationControllerThinning::ApplyOpacity(float opacity) {
|
| +void SingleScrollbarAnimationControllerThinning::ApplyOpacity(float opacity) {
|
| for (ScrollbarLayerImplBase* scrollbar : Scrollbars()) {
|
| + if (scrollbar->orientation() != orientation_)
|
| + continue;
|
| if (!scrollbar->is_overlay_scrollbar())
|
| continue;
|
| +
|
| float effective_opacity = scrollbar->CanScrollOrientation() ? opacity : 0;
|
| PropertyTrees* property_trees =
|
| scrollbar->layer_tree_impl()->property_trees();
|
| @@ -226,19 +235,23 @@ void ScrollbarAnimationControllerThinning::ApplyOpacity(float opacity) {
|
| client_->DidChangeScrollbarVisibility();
|
| }
|
|
|
| -void ScrollbarAnimationControllerThinning::ApplyThumbThicknessScale(
|
| +void SingleScrollbarAnimationControllerThinning::ApplyThumbThicknessScale(
|
| float thumb_thickness_scale) {
|
| for (ScrollbarLayerImplBase* scrollbar : Scrollbars()) {
|
| + if (scrollbar->orientation() != orientation_)
|
| + continue;
|
| if (!scrollbar->is_overlay_scrollbar())
|
| continue;
|
|
|
| - scrollbar->SetThumbThicknessScaleFactor(AdjustScale(
|
| - thumb_thickness_scale, scrollbar->thumb_thickness_scale_factor(),
|
| - thickness_change_, kIdleThicknessScale, 1));
|
| + float scale = AdjustScale(thumb_thickness_scale,
|
| + scrollbar->thumb_thickness_scale_factor(),
|
| + thickness_change_, kIdleThicknessScale, 1);
|
| +
|
| + scrollbar->SetThumbThicknessScaleFactor(scale);
|
| }
|
| }
|
|
|
| -void ScrollbarAnimationControllerThinning::SetCurrentAnimatingProperty(
|
| +void SingleScrollbarAnimationControllerThinning::SetCurrentAnimatingProperty(
|
| AnimatingProperty property) {
|
| if (current_animating_property_ == property)
|
| return;
|
|
|