Commit 790e070c authored by Xida Chen's avatar Xida Chen Committed by Commit Bot

[Code health] Convert 3 enums-->enum class in cc/input

These 3 enums are all private, so relatively easy to convert.

Bug: 720553
Change-Id: Ide43578b526677b8da9317decd550a12f40d3f80
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2377557Reviewed-by: default avatarDavid Bokan <bokan@chromium.org>
Commit-Queue: Xida Chen <xidachen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#802461}
parent a18be1fc
......@@ -50,7 +50,7 @@ ScrollbarAnimationController::ScrollbarAnimationController(
fade_duration_(fade_duration),
need_trigger_scrollbar_fade_in_(false),
is_animating_(false),
animation_change_(NONE),
animation_change_(AnimationChange::NONE),
scroll_element_id_(scroll_element_id),
opacity_(initial_opacity),
show_scrollbars_on_scroll_gesture_(false),
......@@ -70,7 +70,7 @@ ScrollbarAnimationController::ScrollbarAnimationController(
fade_duration_(fade_duration),
need_trigger_scrollbar_fade_in_(false),
is_animating_(false),
animation_change_(NONE),
animation_change_(AnimationChange::NONE),
scroll_element_id_(scroll_element_id),
opacity_(initial_opacity),
show_scrollbars_on_scroll_gesture_(true),
......@@ -102,7 +102,7 @@ ScrollbarAnimationController::GetScrollbarAnimationController(
}
void ScrollbarAnimationController::StartAnimation() {
DCHECK(animation_change_ != NONE);
DCHECK(animation_change_ != AnimationChange::NONE);
delayed_scrollbar_animation_.Cancel();
need_trigger_scrollbar_fade_in_ = false;
is_animating_ = true;
......@@ -114,7 +114,7 @@ void ScrollbarAnimationController::StopAnimation() {
delayed_scrollbar_animation_.Cancel();
need_trigger_scrollbar_fade_in_ = false;
is_animating_ = false;
animation_change_ = NONE;
animation_change_ = AnimationChange::NONE;
}
void ScrollbarAnimationController::PostDelayedAnimation(
......@@ -137,7 +137,7 @@ bool ScrollbarAnimationController::Animate(base::TimeTicks now) {
}
if (is_animating_) {
DCHECK(animation_change_ != NONE);
DCHECK(animation_change_ != AnimationChange::NONE);
if (last_awaken_time_.is_null())
last_awaken_time_ = now;
......@@ -166,8 +166,8 @@ float ScrollbarAnimationController::AnimationProgressAtTime(
void ScrollbarAnimationController::RunAnimationFrame(float progress) {
float opacity;
DCHECK(animation_change_ != NONE);
if (animation_change_ == FADE_IN) {
DCHECK(animation_change_ != AnimationChange::NONE);
if (animation_change_ == AnimationChange::FADE_IN) {
opacity = std::max(progress, opacity_);
} else {
opacity = std::min(1.f - progress, opacity_);
......@@ -194,9 +194,9 @@ void ScrollbarAnimationController::UpdateScrollbarState() {
// Overlay) and mouse is near or tickmarks show.
if (need_thinning_animation_) {
if (!MouseIsNearAnyScrollbar() && !tickmarks_showing_)
PostDelayedAnimation(FADE_OUT);
PostDelayedAnimation(AnimationChange::FADE_OUT);
} else {
PostDelayedAnimation(FADE_OUT);
PostDelayedAnimation(AnimationChange::FADE_OUT);
}
if (need_thinning_animation_) {
......@@ -251,7 +251,7 @@ void ScrollbarAnimationController::DidMouseUp() {
if (!Captured()) {
if (MouseIsNearAnyScrollbar() && ScrollbarsHidden()) {
PostDelayedAnimation(FADE_IN);
PostDelayedAnimation(AnimationChange::FADE_IN);
need_trigger_scrollbar_fade_in_ = true;
}
return;
......@@ -261,7 +261,7 @@ void ScrollbarAnimationController::DidMouseUp() {
horizontal_controller_->DidMouseUp();
if (!MouseIsNearAnyScrollbar() && !ScrollbarsHidden() && !tickmarks_showing_)
PostDelayedAnimation(FADE_OUT);
PostDelayedAnimation(AnimationChange::FADE_OUT);
}
void ScrollbarAnimationController::DidMouseLeave() {
......@@ -277,7 +277,7 @@ void ScrollbarAnimationController::DidMouseLeave() {
if (ScrollbarsHidden() || Captured() || tickmarks_showing_)
return;
PostDelayedAnimation(FADE_OUT);
PostDelayedAnimation(AnimationChange::FADE_OUT);
}
void ScrollbarAnimationController::DidMouseMove(
......@@ -304,7 +304,7 @@ void ScrollbarAnimationController::DidMouseMove(
if (need_trigger_scrollbar_fade_in_before !=
need_trigger_scrollbar_fade_in_) {
if (need_trigger_scrollbar_fade_in_) {
PostDelayedAnimation(FADE_IN);
PostDelayedAnimation(AnimationChange::FADE_IN);
} else {
delayed_scrollbar_animation_.Cancel();
}
......@@ -314,7 +314,7 @@ void ScrollbarAnimationController::DidMouseMove(
Show();
StopAnimation();
} else if (!is_animating_) {
PostDelayedAnimation(FADE_OUT);
PostDelayedAnimation(AnimationChange::FADE_OUT);
}
}
}
......
......@@ -95,7 +95,7 @@ class CC_EXPORT ScrollbarAnimationController {
private:
// Describes whether the current animation should FadeIn or FadeOut.
enum AnimationChange { NONE, FADE_IN, FADE_OUT };
enum class AnimationChange { NONE, FADE_IN, FADE_OUT };
ScrollbarAnimationController(ElementId scroll_element_id,
ScrollbarAnimationControllerClient* client,
......
......@@ -152,7 +152,7 @@ class CC_EXPORT ScrollbarController {
// "Autoscroll" here means the continuous scrolling that occurs when the
// pointer is held down on a hit-testable area of the scrollbar such as an
// arrows of the track itself.
enum AutoScrollDirection { AUTOSCROLL_FORWARD, AUTOSCROLL_BACKWARD };
enum class AutoScrollDirection { AUTOSCROLL_FORWARD, AUTOSCROLL_BACKWARD };
struct CC_EXPORT AutoScrollState {
// Can only be either AUTOSCROLL_FORWARD or AUTOSCROLL_BACKWARD.
......
......@@ -61,7 +61,7 @@ SingleScrollbarAnimationControllerThinning::
mouse_is_over_scrollbar_thumb_(false),
mouse_is_near_scrollbar_thumb_(false),
mouse_is_near_scrollbar_track_(false),
thickness_change_(NONE),
thickness_change_(AnimationChange::NONE),
thinning_duration_(thinning_duration) {
ApplyThumbThicknessScale(kIdleThicknessScale);
}
......@@ -112,7 +112,7 @@ void SingleScrollbarAnimationControllerThinning::RunAnimationFrame(
client_->SetNeedsRedrawForScrollbarAnimation();
if (progress == 1.f) {
StopAnimation();
thickness_change_ = NONE;
thickness_change_ = AnimationChange::NONE;
}
}
......@@ -143,10 +143,10 @@ void SingleScrollbarAnimationControllerThinning::DidMouseUp() {
StopAnimation();
if (!mouse_is_near_scrollbar_thumb_) {
thickness_change_ = DECREASE;
thickness_change_ = AnimationChange::DECREASE;
StartAnimation();
} else {
thickness_change_ = NONE;
thickness_change_ = AnimationChange::NONE;
}
}
......@@ -161,7 +161,7 @@ void SingleScrollbarAnimationControllerThinning::DidMouseLeave() {
if (captured_)
return;
thickness_change_ = DECREASE;
thickness_change_ = AnimationChange::DECREASE;
StartAnimation();
}
......@@ -188,7 +188,9 @@ void SingleScrollbarAnimationControllerThinning::DidMouseMove(
if (!captured_ &&
mouse_is_near_scrollbar_thumb != mouse_is_near_scrollbar_thumb_) {
thickness_change_ = mouse_is_near_scrollbar_thumb ? INCREASE : DECREASE;
thickness_change_ = mouse_is_near_scrollbar_thumb
? AnimationChange::INCREASE
: AnimationChange::DECREASE;
StartAnimation();
}
mouse_is_near_scrollbar_thumb_ = mouse_is_near_scrollbar_thumb;
......@@ -197,9 +199,11 @@ void SingleScrollbarAnimationControllerThinning::DidMouseMove(
float SingleScrollbarAnimationControllerThinning::ThumbThicknessScaleAt(
float progress) {
if (thickness_change_ == NONE)
if (thickness_change_ == AnimationChange::NONE)
return mouse_is_near_scrollbar_thumb_ ? 1.f : kIdleThicknessScale;
float factor = thickness_change_ == INCREASE ? progress : (1.f - progress);
float factor = thickness_change_ == AnimationChange::INCREASE
? progress
: (1.f - progress);
return ((1.f - kIdleThicknessScale) * factor) + kIdleThicknessScale;
}
......@@ -210,9 +214,11 @@ float SingleScrollbarAnimationControllerThinning::AdjustScale(
float min_value,
float max_value) {
float result;
if (animation_change == INCREASE && current_value > new_value)
if (animation_change == AnimationChange::INCREASE &&
current_value > new_value)
result = current_value;
else if (animation_change == DECREASE && current_value < new_value)
else if (animation_change == AnimationChange::DECREASE &&
current_value < new_value)
result = current_value;
else
result = new_value;
......
......@@ -73,7 +73,7 @@ class CC_EXPORT SingleScrollbarAnimationControllerThinning {
// Describes whether the current animation should INCREASE (thicken)
// a bar or DECREASE it (thin).
enum AnimationChange { NONE, INCREASE, DECREASE };
enum class AnimationChange { NONE, INCREASE, DECREASE };
float ThumbThicknessScaleAt(float progress);
float AdjustScale(float new_value,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment