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( ...@@ -50,7 +50,7 @@ ScrollbarAnimationController::ScrollbarAnimationController(
fade_duration_(fade_duration), fade_duration_(fade_duration),
need_trigger_scrollbar_fade_in_(false), need_trigger_scrollbar_fade_in_(false),
is_animating_(false), is_animating_(false),
animation_change_(NONE), animation_change_(AnimationChange::NONE),
scroll_element_id_(scroll_element_id), scroll_element_id_(scroll_element_id),
opacity_(initial_opacity), opacity_(initial_opacity),
show_scrollbars_on_scroll_gesture_(false), show_scrollbars_on_scroll_gesture_(false),
...@@ -70,7 +70,7 @@ ScrollbarAnimationController::ScrollbarAnimationController( ...@@ -70,7 +70,7 @@ ScrollbarAnimationController::ScrollbarAnimationController(
fade_duration_(fade_duration), fade_duration_(fade_duration),
need_trigger_scrollbar_fade_in_(false), need_trigger_scrollbar_fade_in_(false),
is_animating_(false), is_animating_(false),
animation_change_(NONE), animation_change_(AnimationChange::NONE),
scroll_element_id_(scroll_element_id), scroll_element_id_(scroll_element_id),
opacity_(initial_opacity), opacity_(initial_opacity),
show_scrollbars_on_scroll_gesture_(true), show_scrollbars_on_scroll_gesture_(true),
...@@ -102,7 +102,7 @@ ScrollbarAnimationController::GetScrollbarAnimationController( ...@@ -102,7 +102,7 @@ ScrollbarAnimationController::GetScrollbarAnimationController(
} }
void ScrollbarAnimationController::StartAnimation() { void ScrollbarAnimationController::StartAnimation() {
DCHECK(animation_change_ != NONE); DCHECK(animation_change_ != AnimationChange::NONE);
delayed_scrollbar_animation_.Cancel(); delayed_scrollbar_animation_.Cancel();
need_trigger_scrollbar_fade_in_ = false; need_trigger_scrollbar_fade_in_ = false;
is_animating_ = true; is_animating_ = true;
...@@ -114,7 +114,7 @@ void ScrollbarAnimationController::StopAnimation() { ...@@ -114,7 +114,7 @@ void ScrollbarAnimationController::StopAnimation() {
delayed_scrollbar_animation_.Cancel(); delayed_scrollbar_animation_.Cancel();
need_trigger_scrollbar_fade_in_ = false; need_trigger_scrollbar_fade_in_ = false;
is_animating_ = false; is_animating_ = false;
animation_change_ = NONE; animation_change_ = AnimationChange::NONE;
} }
void ScrollbarAnimationController::PostDelayedAnimation( void ScrollbarAnimationController::PostDelayedAnimation(
...@@ -137,7 +137,7 @@ bool ScrollbarAnimationController::Animate(base::TimeTicks now) { ...@@ -137,7 +137,7 @@ bool ScrollbarAnimationController::Animate(base::TimeTicks now) {
} }
if (is_animating_) { if (is_animating_) {
DCHECK(animation_change_ != NONE); DCHECK(animation_change_ != AnimationChange::NONE);
if (last_awaken_time_.is_null()) if (last_awaken_time_.is_null())
last_awaken_time_ = now; last_awaken_time_ = now;
...@@ -166,8 +166,8 @@ float ScrollbarAnimationController::AnimationProgressAtTime( ...@@ -166,8 +166,8 @@ float ScrollbarAnimationController::AnimationProgressAtTime(
void ScrollbarAnimationController::RunAnimationFrame(float progress) { void ScrollbarAnimationController::RunAnimationFrame(float progress) {
float opacity; float opacity;
DCHECK(animation_change_ != NONE); DCHECK(animation_change_ != AnimationChange::NONE);
if (animation_change_ == FADE_IN) { if (animation_change_ == AnimationChange::FADE_IN) {
opacity = std::max(progress, opacity_); opacity = std::max(progress, opacity_);
} else { } else {
opacity = std::min(1.f - progress, opacity_); opacity = std::min(1.f - progress, opacity_);
...@@ -194,9 +194,9 @@ void ScrollbarAnimationController::UpdateScrollbarState() { ...@@ -194,9 +194,9 @@ void ScrollbarAnimationController::UpdateScrollbarState() {
// Overlay) and mouse is near or tickmarks show. // Overlay) and mouse is near or tickmarks show.
if (need_thinning_animation_) { if (need_thinning_animation_) {
if (!MouseIsNearAnyScrollbar() && !tickmarks_showing_) if (!MouseIsNearAnyScrollbar() && !tickmarks_showing_)
PostDelayedAnimation(FADE_OUT); PostDelayedAnimation(AnimationChange::FADE_OUT);
} else { } else {
PostDelayedAnimation(FADE_OUT); PostDelayedAnimation(AnimationChange::FADE_OUT);
} }
if (need_thinning_animation_) { if (need_thinning_animation_) {
...@@ -251,7 +251,7 @@ void ScrollbarAnimationController::DidMouseUp() { ...@@ -251,7 +251,7 @@ void ScrollbarAnimationController::DidMouseUp() {
if (!Captured()) { if (!Captured()) {
if (MouseIsNearAnyScrollbar() && ScrollbarsHidden()) { if (MouseIsNearAnyScrollbar() && ScrollbarsHidden()) {
PostDelayedAnimation(FADE_IN); PostDelayedAnimation(AnimationChange::FADE_IN);
need_trigger_scrollbar_fade_in_ = true; need_trigger_scrollbar_fade_in_ = true;
} }
return; return;
...@@ -261,7 +261,7 @@ void ScrollbarAnimationController::DidMouseUp() { ...@@ -261,7 +261,7 @@ void ScrollbarAnimationController::DidMouseUp() {
horizontal_controller_->DidMouseUp(); horizontal_controller_->DidMouseUp();
if (!MouseIsNearAnyScrollbar() && !ScrollbarsHidden() && !tickmarks_showing_) if (!MouseIsNearAnyScrollbar() && !ScrollbarsHidden() && !tickmarks_showing_)
PostDelayedAnimation(FADE_OUT); PostDelayedAnimation(AnimationChange::FADE_OUT);
} }
void ScrollbarAnimationController::DidMouseLeave() { void ScrollbarAnimationController::DidMouseLeave() {
...@@ -277,7 +277,7 @@ void ScrollbarAnimationController::DidMouseLeave() { ...@@ -277,7 +277,7 @@ void ScrollbarAnimationController::DidMouseLeave() {
if (ScrollbarsHidden() || Captured() || tickmarks_showing_) if (ScrollbarsHidden() || Captured() || tickmarks_showing_)
return; return;
PostDelayedAnimation(FADE_OUT); PostDelayedAnimation(AnimationChange::FADE_OUT);
} }
void ScrollbarAnimationController::DidMouseMove( void ScrollbarAnimationController::DidMouseMove(
...@@ -304,7 +304,7 @@ void ScrollbarAnimationController::DidMouseMove( ...@@ -304,7 +304,7 @@ void ScrollbarAnimationController::DidMouseMove(
if (need_trigger_scrollbar_fade_in_before != if (need_trigger_scrollbar_fade_in_before !=
need_trigger_scrollbar_fade_in_) { need_trigger_scrollbar_fade_in_) {
if (need_trigger_scrollbar_fade_in_) { if (need_trigger_scrollbar_fade_in_) {
PostDelayedAnimation(FADE_IN); PostDelayedAnimation(AnimationChange::FADE_IN);
} else { } else {
delayed_scrollbar_animation_.Cancel(); delayed_scrollbar_animation_.Cancel();
} }
...@@ -314,7 +314,7 @@ void ScrollbarAnimationController::DidMouseMove( ...@@ -314,7 +314,7 @@ void ScrollbarAnimationController::DidMouseMove(
Show(); Show();
StopAnimation(); StopAnimation();
} else if (!is_animating_) { } else if (!is_animating_) {
PostDelayedAnimation(FADE_OUT); PostDelayedAnimation(AnimationChange::FADE_OUT);
} }
} }
} }
......
...@@ -95,7 +95,7 @@ class CC_EXPORT ScrollbarAnimationController { ...@@ -95,7 +95,7 @@ class CC_EXPORT ScrollbarAnimationController {
private: private:
// Describes whether the current animation should FadeIn or FadeOut. // 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, ScrollbarAnimationController(ElementId scroll_element_id,
ScrollbarAnimationControllerClient* client, ScrollbarAnimationControllerClient* client,
......
...@@ -152,7 +152,7 @@ class CC_EXPORT ScrollbarController { ...@@ -152,7 +152,7 @@ class CC_EXPORT ScrollbarController {
// "Autoscroll" here means the continuous scrolling that occurs when the // "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 // pointer is held down on a hit-testable area of the scrollbar such as an
// arrows of the track itself. // arrows of the track itself.
enum AutoScrollDirection { AUTOSCROLL_FORWARD, AUTOSCROLL_BACKWARD }; enum class AutoScrollDirection { AUTOSCROLL_FORWARD, AUTOSCROLL_BACKWARD };
struct CC_EXPORT AutoScrollState { struct CC_EXPORT AutoScrollState {
// Can only be either AUTOSCROLL_FORWARD or AUTOSCROLL_BACKWARD. // Can only be either AUTOSCROLL_FORWARD or AUTOSCROLL_BACKWARD.
......
...@@ -61,7 +61,7 @@ SingleScrollbarAnimationControllerThinning:: ...@@ -61,7 +61,7 @@ SingleScrollbarAnimationControllerThinning::
mouse_is_over_scrollbar_thumb_(false), mouse_is_over_scrollbar_thumb_(false),
mouse_is_near_scrollbar_thumb_(false), mouse_is_near_scrollbar_thumb_(false),
mouse_is_near_scrollbar_track_(false), mouse_is_near_scrollbar_track_(false),
thickness_change_(NONE), thickness_change_(AnimationChange::NONE),
thinning_duration_(thinning_duration) { thinning_duration_(thinning_duration) {
ApplyThumbThicknessScale(kIdleThicknessScale); ApplyThumbThicknessScale(kIdleThicknessScale);
} }
...@@ -112,7 +112,7 @@ void SingleScrollbarAnimationControllerThinning::RunAnimationFrame( ...@@ -112,7 +112,7 @@ void SingleScrollbarAnimationControllerThinning::RunAnimationFrame(
client_->SetNeedsRedrawForScrollbarAnimation(); client_->SetNeedsRedrawForScrollbarAnimation();
if (progress == 1.f) { if (progress == 1.f) {
StopAnimation(); StopAnimation();
thickness_change_ = NONE; thickness_change_ = AnimationChange::NONE;
} }
} }
...@@ -143,10 +143,10 @@ void SingleScrollbarAnimationControllerThinning::DidMouseUp() { ...@@ -143,10 +143,10 @@ void SingleScrollbarAnimationControllerThinning::DidMouseUp() {
StopAnimation(); StopAnimation();
if (!mouse_is_near_scrollbar_thumb_) { if (!mouse_is_near_scrollbar_thumb_) {
thickness_change_ = DECREASE; thickness_change_ = AnimationChange::DECREASE;
StartAnimation(); StartAnimation();
} else { } else {
thickness_change_ = NONE; thickness_change_ = AnimationChange::NONE;
} }
} }
...@@ -161,7 +161,7 @@ void SingleScrollbarAnimationControllerThinning::DidMouseLeave() { ...@@ -161,7 +161,7 @@ void SingleScrollbarAnimationControllerThinning::DidMouseLeave() {
if (captured_) if (captured_)
return; return;
thickness_change_ = DECREASE; thickness_change_ = AnimationChange::DECREASE;
StartAnimation(); StartAnimation();
} }
...@@ -188,7 +188,9 @@ void SingleScrollbarAnimationControllerThinning::DidMouseMove( ...@@ -188,7 +188,9 @@ void SingleScrollbarAnimationControllerThinning::DidMouseMove(
if (!captured_ && if (!captured_ &&
mouse_is_near_scrollbar_thumb != mouse_is_near_scrollbar_thumb_) { 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(); StartAnimation();
} }
mouse_is_near_scrollbar_thumb_ = mouse_is_near_scrollbar_thumb; mouse_is_near_scrollbar_thumb_ = mouse_is_near_scrollbar_thumb;
...@@ -197,9 +199,11 @@ void SingleScrollbarAnimationControllerThinning::DidMouseMove( ...@@ -197,9 +199,11 @@ void SingleScrollbarAnimationControllerThinning::DidMouseMove(
float SingleScrollbarAnimationControllerThinning::ThumbThicknessScaleAt( float SingleScrollbarAnimationControllerThinning::ThumbThicknessScaleAt(
float progress) { float progress) {
if (thickness_change_ == NONE) if (thickness_change_ == AnimationChange::NONE)
return mouse_is_near_scrollbar_thumb_ ? 1.f : kIdleThicknessScale; 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; return ((1.f - kIdleThicknessScale) * factor) + kIdleThicknessScale;
} }
...@@ -210,9 +214,11 @@ float SingleScrollbarAnimationControllerThinning::AdjustScale( ...@@ -210,9 +214,11 @@ float SingleScrollbarAnimationControllerThinning::AdjustScale(
float min_value, float min_value,
float max_value) { float max_value) {
float result; float result;
if (animation_change == INCREASE && current_value > new_value) if (animation_change == AnimationChange::INCREASE &&
current_value > new_value)
result = current_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; result = current_value;
else else
result = new_value; result = new_value;
......
...@@ -73,7 +73,7 @@ class CC_EXPORT SingleScrollbarAnimationControllerThinning { ...@@ -73,7 +73,7 @@ class CC_EXPORT SingleScrollbarAnimationControllerThinning {
// Describes whether the current animation should INCREASE (thicken) // Describes whether the current animation should INCREASE (thicken)
// a bar or DECREASE it (thin). // a bar or DECREASE it (thin).
enum AnimationChange { NONE, INCREASE, DECREASE }; enum class AnimationChange { NONE, INCREASE, DECREASE };
float ThumbThicknessScaleAt(float progress); float ThumbThicknessScaleAt(float progress);
float AdjustScale(float new_value, 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