Index: cc/input/single_scrollbar_animation_controller_thinning.cc |
diff --git a/cc/input/single_scrollbar_animation_controller_thinning.cc b/cc/input/single_scrollbar_animation_controller_thinning.cc |
index f09756ee5e636571e659691d1c146f6424b18bc3..11e68dc4c16612e66b29628b1909eff627b21f11 100644 |
--- a/cc/input/single_scrollbar_animation_controller_thinning.cc |
+++ b/cc/input/single_scrollbar_animation_controller_thinning.cc |
@@ -36,7 +36,8 @@ SingleScrollbarAnimationControllerThinning:: |
scroll_element_id_(scroll_element_id), |
orientation_(orientation), |
captured_(false), |
- mouse_is_over_scrollbar_(false), |
+ mouse_is_over_scrollbar_thumb_(false), |
+ mouse_is_near_scrollbar_thumb_(false), |
mouse_is_near_scrollbar_(false), |
thickness_change_(NONE), |
thinning_duration_(thinning_duration) { |
@@ -92,7 +93,7 @@ void SingleScrollbarAnimationControllerThinning::StopAnimation() { |
} |
void SingleScrollbarAnimationControllerThinning::DidMouseDown() { |
- if (!mouse_is_over_scrollbar_) |
+ if (!mouse_is_over_scrollbar_thumb_) |
return; |
StopAnimation(); |
@@ -107,7 +108,7 @@ void SingleScrollbarAnimationControllerThinning::DidMouseUp() { |
captured_ = false; |
StopAnimation(); |
- if (!mouse_is_near_scrollbar_) { |
+ if (!mouse_is_near_scrollbar_thumb_) { |
thickness_change_ = DECREASE; |
StartAnimation(); |
} else { |
@@ -116,11 +117,11 @@ void SingleScrollbarAnimationControllerThinning::DidMouseUp() { |
} |
void SingleScrollbarAnimationControllerThinning::DidMouseLeave() { |
- if (!mouse_is_over_scrollbar_ && !mouse_is_near_scrollbar_) |
+ if (!mouse_is_over_scrollbar_thumb_ && !mouse_is_near_scrollbar_thumb_) |
return; |
- mouse_is_over_scrollbar_ = false; |
- mouse_is_near_scrollbar_ = false; |
+ mouse_is_over_scrollbar_thumb_ = false; |
+ mouse_is_near_scrollbar_thumb_ = false; |
if (captured_) |
return; |
@@ -130,23 +131,28 @@ void SingleScrollbarAnimationControllerThinning::DidMouseLeave() { |
} |
void SingleScrollbarAnimationControllerThinning::DidMouseMoveNear( |
bokan
2017/04/25 19:36:21
This can also just be DidMoveMouse
|
- float distance) { |
- bool mouse_is_over_scrollbar = distance == 0.0f; |
- bool mouse_is_near_scrollbar = |
- distance < kDefaultMouseMoveDistanceToTriggerAnimation; |
- |
- if (!captured_ && mouse_is_near_scrollbar != mouse_is_near_scrollbar_) { |
- thickness_change_ = mouse_is_near_scrollbar ? INCREASE : DECREASE; |
+ float distance_to_scrollbar, |
bokan
2017/04/25 19:36:21
Why does the thinning controller need to know the
|
+ float distance_to_thumb) { |
+ mouse_is_near_scrollbar_ = |
+ distance_to_scrollbar < kDefaultMouseMoveDistanceToTriggerAnimation; |
+ |
+ bool mouse_is_over_scrollbar_thumb = distance_to_thumb == 0.0f; |
+ bool mouse_is_near_scrollbar_thumb = |
+ distance_to_thumb < kDefaultMouseMoveDistanceToTriggerAnimation; |
+ |
+ if (!captured_ && |
+ mouse_is_near_scrollbar_thumb != mouse_is_near_scrollbar_thumb_) { |
+ thickness_change_ = mouse_is_near_scrollbar_thumb ? INCREASE : DECREASE; |
StartAnimation(); |
} |
- mouse_is_near_scrollbar_ = mouse_is_near_scrollbar; |
- mouse_is_over_scrollbar_ = mouse_is_over_scrollbar; |
+ mouse_is_near_scrollbar_thumb_ = mouse_is_near_scrollbar_thumb; |
+ mouse_is_over_scrollbar_thumb_ = mouse_is_over_scrollbar_thumb; |
} |
float SingleScrollbarAnimationControllerThinning::ThumbThicknessScaleAt( |
float progress) { |
if (thickness_change_ == NONE) |
- return mouse_is_near_scrollbar_ ? 1.f : kIdleThicknessScale; |
+ return mouse_is_near_scrollbar_thumb_ ? 1.f : kIdleThicknessScale; |
float factor = thickness_change_ == INCREASE ? progress : (1.f - progress); |
return ((1.f - kIdleThicknessScale) * factor) + kIdleThicknessScale; |
} |
@@ -173,8 +179,8 @@ float SingleScrollbarAnimationControllerThinning::AdjustScale( |
void SingleScrollbarAnimationControllerThinning::UpdateThumbThicknessScale() { |
StopAnimation(); |
- ApplyThumbThicknessScale(mouse_is_near_scrollbar_ ? 1.f |
- : kIdleThicknessScale); |
+ ApplyThumbThicknessScale( |
+ mouse_is_near_scrollbar_thumb_ ? 1.f : kIdleThicknessScale); |
} |
void SingleScrollbarAnimationControllerThinning::ApplyThumbThicknessScale( |