Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(69)

Unified Diff: cc/input/scrollbar_animation_controller.cc

Issue 2841943002: Overlay scrollbars expand only when mouse is near thumb (Closed)
Patch Set: pass point to SingleScrollbarController Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: cc/input/scrollbar_animation_controller.cc
diff --git a/cc/input/scrollbar_animation_controller.cc b/cc/input/scrollbar_animation_controller.cc
index f3f1a48121f113abcdb926d304e04dee22d948b0..b9397ed68a0fd3a278c2d6fd2122488c9af86097 100644
--- a/cc/input/scrollbar_animation_controller.cc
+++ b/cc/input/scrollbar_animation_controller.cc
@@ -46,7 +46,7 @@ ScrollbarAnimationController::ScrollbarAnimationController(
fade_delay_(fade_delay),
fade_out_resize_delay_(fade_out_resize_delay),
fade_duration_(fade_duration),
- need_trigger_scrollbar_show_(false),
+ need_trigger_scrollbar_fade_in_(false),
is_animating_(false),
animation_change_(NONE),
scroll_element_id_(scroll_element_id),
@@ -70,7 +70,7 @@ ScrollbarAnimationController::ScrollbarAnimationController(
fade_delay_(fade_delay),
fade_out_resize_delay_(fade_out_resize_delay),
fade_duration_(fade_duration),
- need_trigger_scrollbar_show_(false),
+ need_trigger_scrollbar_fade_in_(false),
is_animating_(false),
animation_change_(NONE),
scroll_element_id_(scroll_element_id),
@@ -86,6 +86,7 @@ ScrollbarAnimationController::ScrollbarAnimationController(
horizontal_controller_ = SingleScrollbarAnimationControllerThinning::Create(
scroll_element_id, ScrollbarOrientation::HORIZONTAL, client,
thinning_duration);
+
ApplyOpacityToScrollbars(0.0f);
}
@@ -273,7 +274,7 @@ void ScrollbarAnimationController::DidMouseLeave() {
horizontal_controller_->DidMouseLeave();
delayed_scrollbar_animation_.Cancel();
- need_trigger_scrollbar_show_ = false;
+ need_trigger_scrollbar_fade_in_ = false;
if (ScrollbarsHidden() || Captured())
return;
@@ -281,25 +282,28 @@ void ScrollbarAnimationController::DidMouseLeave() {
PostDelayedAnimation(FADE_OUT, false);
}
-void ScrollbarAnimationController::DidMouseMoveNear(
- ScrollbarOrientation orientation,
- float distance) {
+void ScrollbarAnimationController::DidMouseMove(
+ const gfx::PointF& device_viewport_point) {
if (!need_thinning_animation_)
return;
- bool need_trigger_scrollbar_show_before = need_trigger_scrollbar_show_;
+ bool need_trigger_scrollbar_fade_in_before = need_trigger_scrollbar_fade_in_;
- GetScrollbarAnimationController(orientation).DidMouseMoveNear(distance);
+ const ScrollbarOrientation orientations[] = {HORIZONTAL, VERTICAL};
bokan 2017/04/28 18:08:11 No need for loop, just: vertical_controller_->Di
+ for (ScrollbarOrientation orientation : orientations) {
+ GetScrollbarAnimationController(orientation)
+ .DidMouseMove(device_viewport_point);
+ }
- need_trigger_scrollbar_show_ =
- CalcNeedTriggerScrollbarShow(orientation, distance);
+ need_trigger_scrollbar_fade_in_ = MouseIsNearAnyScrollbar();
if (Captured())
return;
if (ScrollbarsHidden()) {
- if (need_trigger_scrollbar_show_before != need_trigger_scrollbar_show_) {
- if (need_trigger_scrollbar_show_) {
+ if (need_trigger_scrollbar_fade_in_before !=
+ need_trigger_scrollbar_fade_in_) {
+ if (need_trigger_scrollbar_fade_in_) {
PostDelayedAnimation(FADE_IN, false);
} else {
delayed_scrollbar_animation_.Cancel();
@@ -315,42 +319,31 @@ void ScrollbarAnimationController::DidMouseMoveNear(
}
}
-bool ScrollbarAnimationController::CalcNeedTriggerScrollbarShow(
- ScrollbarOrientation orientation,
- float distance) const {
+bool ScrollbarAnimationController::MouseIsOverScrollbarThumb(
+ ScrollbarOrientation orientation) const {
DCHECK(need_thinning_animation_);
-
- if (vertical_controller_->mouse_is_over_scrollbar() ||
- horizontal_controller_->mouse_is_over_scrollbar())
- return true;
-
- for (ScrollbarLayerImplBase* scrollbar : Scrollbars()) {
- if (scrollbar->orientation() != orientation)
- continue;
-
- if (distance < kMouseMoveDistanceToTriggerFadeIn)
- return true;
- }
-
- return false;
+ return GetScrollbarAnimationController(orientation)
+ .mouse_is_over_scrollbar_thumb();
}
-bool ScrollbarAnimationController::MouseIsOverScrollbar(
+bool ScrollbarAnimationController::MouseIsNearScrollbarThumb(
ScrollbarOrientation orientation) const {
DCHECK(need_thinning_animation_);
- return GetScrollbarAnimationController(orientation).mouse_is_over_scrollbar();
+ return GetScrollbarAnimationController(orientation)
+ .mouse_is_near_scrollbar_thumb();
}
bool ScrollbarAnimationController::MouseIsNearScrollbar(
ScrollbarOrientation orientation) const {
DCHECK(need_thinning_animation_);
- return GetScrollbarAnimationController(orientation).mouse_is_near_scrollbar();
+ return GetScrollbarAnimationController(orientation)
+ .mouse_is_near_scrollbar_track();
}
bool ScrollbarAnimationController::MouseIsNearAnyScrollbar() const {
DCHECK(need_thinning_animation_);
- return vertical_controller_->mouse_is_near_scrollbar() ||
- horizontal_controller_->mouse_is_near_scrollbar();
+ return vertical_controller_->mouse_is_near_scrollbar_track() ||
+ horizontal_controller_->mouse_is_near_scrollbar_track();
}
bool ScrollbarAnimationController::ScrollbarsHidden() const {
@@ -359,7 +352,8 @@ bool ScrollbarAnimationController::ScrollbarsHidden() const {
bool ScrollbarAnimationController::Captured() const {
DCHECK(need_thinning_animation_);
- return vertical_controller_->captured() || horizontal_controller_->captured();
+ return GetScrollbarAnimationController(VERTICAL).captured() ||
+ GetScrollbarAnimationController(HORIZONTAL).captured();
}
void ScrollbarAnimationController::Show() {

Powered by Google App Engine
This is Rietveld 408576698