Commit 78c59b73 authored by Ian Kilpatrick's avatar Ian Kilpatrick Committed by Commit Bot

[cleanup] Remove LayoutTheme::AnimationDurationForProgressBar

and LayoutTheme::AnimationRepeatIntervalForProgressBar, and moves them
into LayoutProgress.

There should be no behaviour change.

Change-Id: I4e03085cd81810fde8f1a32f109af5a6b5861667
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2270862Reviewed-by: default avatarKent Tamura <tkent@chromium.org>
Reviewed-by: default avatarMason Freed <masonfreed@chromium.org>
Commit-Queue: Ian Kilpatrick <ikilpatrick@chromium.org>
Cr-Commit-Position: refs/heads/master@{#799635}
parent fab728a9
...@@ -27,6 +27,14 @@ ...@@ -27,6 +27,14 @@
namespace blink { namespace blink {
namespace {
constexpr base::TimeDelta kAnimationInterval =
base::TimeDelta::FromMilliseconds(125);
constexpr base::TimeDelta kAnimationDuration = kAnimationInterval * 20;
} // namespace
LayoutProgress::LayoutProgress(Element* element) LayoutProgress::LayoutProgress(Element* element)
: LayoutBlockFlow(element), : LayoutBlockFlow(element),
position_(HTMLProgressElement::kInvalidPosition), position_(HTMLProgressElement::kInvalidPosition),
...@@ -64,7 +72,7 @@ double LayoutProgress::AnimationProgress() const { ...@@ -64,7 +72,7 @@ double LayoutProgress::AnimationProgress() const {
return 0; return 0;
const base::TimeDelta elapsed = const base::TimeDelta elapsed =
base::TimeTicks::Now() - animation_start_time_; base::TimeTicks::Now() - animation_start_time_;
return (elapsed % animation_duration_) / animation_duration_; return (elapsed % kAnimationDuration) / kAnimationDuration;
} }
bool LayoutProgress::IsDeterminate() const { bool LayoutProgress::IsDeterminate() const {
...@@ -83,24 +91,18 @@ bool LayoutProgress::IsAnimating() const { ...@@ -83,24 +91,18 @@ bool LayoutProgress::IsAnimating() const {
void LayoutProgress::AnimationTimerFired(TimerBase*) { void LayoutProgress::AnimationTimerFired(TimerBase*) {
SetShouldDoFullPaintInvalidation(); SetShouldDoFullPaintInvalidation();
if (!animation_timer_.IsActive() && animating_) if (!animation_timer_.IsActive() && animating_)
animation_timer_.StartOneShot(animation_repeat_interval_, FROM_HERE); animation_timer_.StartOneShot(kAnimationInterval, FROM_HERE);
} }
void LayoutProgress::UpdateAnimationState() { void LayoutProgress::UpdateAnimationState() {
animation_duration_ = bool animating = !IsDeterminate() && StyleRef().HasEffectiveAppearance();
LayoutTheme::GetTheme().AnimationDurationForProgressBar();
animation_repeat_interval_ =
LayoutTheme::GetTheme().AnimationRepeatIntervalForProgressBar();
bool animating = !IsDeterminate() && StyleRef().HasEffectiveAppearance() &&
animation_duration_ > base::TimeDelta();
if (animating == animating_) if (animating == animating_)
return; return;
animating_ = animating; animating_ = animating;
if (animating_) { if (animating_) {
animation_start_time_ = base::TimeTicks::Now(); animation_start_time_ = base::TimeTicks::Now();
animation_timer_.StartOneShot(animation_repeat_interval_, FROM_HERE); animation_timer_.StartOneShot(kAnimationInterval, FROM_HERE);
} else { } else {
animation_timer_.Stop(); animation_timer_.Stop();
} }
......
...@@ -58,8 +58,6 @@ class CORE_EXPORT LayoutProgress : public LayoutBlockFlow { ...@@ -58,8 +58,6 @@ class CORE_EXPORT LayoutProgress : public LayoutBlockFlow {
double position_; double position_;
base::TimeTicks animation_start_time_; base::TimeTicks animation_start_time_;
base::TimeDelta animation_repeat_interval_;
base::TimeDelta animation_duration_;
bool animating_; bool animating_;
TaskRunnerTimer<LayoutProgress> animation_timer_; TaskRunnerTimer<LayoutProgress> animation_timer_;
......
...@@ -602,14 +602,6 @@ void LayoutTheme::AdjustMenuListStyle(ComputedStyle& style, Element*) const { ...@@ -602,14 +602,6 @@ void LayoutTheme::AdjustMenuListStyle(ComputedStyle& style, Element*) const {
style.SetOverflowY(EOverflow::kVisible); style.SetOverflowY(EOverflow::kVisible);
} }
base::TimeDelta LayoutTheme::AnimationRepeatIntervalForProgressBar() const {
return base::TimeDelta();
}
base::TimeDelta LayoutTheme::AnimationDurationForProgressBar() const {
return base::TimeDelta();
}
bool LayoutTheme::ShouldHaveSpinButton(HTMLInputElement* input_element) const { bool LayoutTheme::ShouldHaveSpinButton(HTMLInputElement* input_element) const {
return input_element->IsSteppable() && return input_element->IsSteppable() &&
input_element->type() != input_type_names::kRange; input_element->type() != input_type_names::kRange;
......
...@@ -195,11 +195,6 @@ class CORE_EXPORT LayoutTheme : public RefCounted<LayoutTheme> { ...@@ -195,11 +195,6 @@ class CORE_EXPORT LayoutTheme : public RefCounted<LayoutTheme> {
virtual void AdjustProgressBarBounds(ComputedStyle& style) const {} virtual void AdjustProgressBarBounds(ComputedStyle& style) const {}
// Returns the repeat interval of the animation for the progress bar.
virtual base::TimeDelta AnimationRepeatIntervalForProgressBar() const;
// Returns the duration of the animation for the progress bar.
virtual base::TimeDelta AnimationDurationForProgressBar() const;
// Returns size of one slider tick mark for a horizontal track. // Returns size of one slider tick mark for a horizontal track.
// For vertical tracks we rotate it and use it. i.e. Width is always length // For vertical tracks we rotate it and use it. i.e. Width is always length
// along the track. // along the track.
......
...@@ -388,21 +388,4 @@ int LayoutThemeDefault::MenuListInternalPadding(const ComputedStyle& style, ...@@ -388,21 +388,4 @@ int LayoutThemeDefault::MenuListInternalPadding(const ComputedStyle& style,
return padding * style.EffectiveZoom(); return padding * style.EffectiveZoom();
} }
//
// The following values come from the defaults of GTK+.
//
constexpr int kProgressAnimationFrames = 10;
constexpr base::TimeDelta kProgressAnimationInterval =
base::TimeDelta::FromMilliseconds(125);
base::TimeDelta LayoutThemeDefault::AnimationRepeatIntervalForProgressBar()
const {
return kProgressAnimationInterval;
}
base::TimeDelta LayoutThemeDefault::AnimationDurationForProgressBar() const {
return kProgressAnimationInterval * kProgressAnimationFrames *
2; // "2" for back and forth
}
} // namespace blink } // namespace blink
...@@ -118,9 +118,6 @@ class CORE_EXPORT LayoutThemeDefault : public LayoutTheme { ...@@ -118,9 +118,6 @@ class CORE_EXPORT LayoutThemeDefault : public LayoutTheme {
void AdjustMenuListStyle(ComputedStyle&, Element*) const override; void AdjustMenuListStyle(ComputedStyle&, Element*) const override;
void AdjustMenuListButtonStyle(ComputedStyle&, Element*) const override; void AdjustMenuListButtonStyle(ComputedStyle&, Element*) const override;
base::TimeDelta AnimationRepeatIntervalForProgressBar() const override;
base::TimeDelta AnimationDurationForProgressBar() const override;
// These methods define the padding for the MenuList's inner block. // These methods define the padding for the MenuList's inner block.
int PopupInternalPaddingStart(const ComputedStyle&) const override; int PopupInternalPaddingStart(const ComputedStyle&) const override;
int PopupInternalPaddingEnd(LocalFrame*, const ComputedStyle&) const override; int PopupInternalPaddingEnd(LocalFrame*, const ComputedStyle&) const override;
......
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