Skip to content

Commit

Permalink
Speculative fix for launcher assistant icon disappearing
Browse files Browse the repository at this point in the history
Add an OnAborted() callback to the icon fade animation. In theory if
the animation was aborted (instead of ended) the button visibility
could get out of sync. I'm not sure that this will fix the issue, since
I can't repro the problem, but adding OnAborted() won't hurt.

Bug: 1313138
Change-Id: I0f34c1f4401ac8847b1356c35d01819325abbaaa
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3630964
Reviewed-by: Matthew Mourgos <mmourgos@chromium.org>
Commit-Queue: James Cook <jamescook@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1000593}
  • Loading branch information
James Cook authored and Chromium LUCI CQ committed May 6, 2022
1 parent cb38de1 commit e652899
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions ash/search_box/search_box_view_base.cc
Original file line number Diff line number Diff line change
Expand Up @@ -586,30 +586,36 @@ void SearchBoxViewBase::MaybeFadeButtonIn(SearchBoxImageButton* button) {
if (!button->layer()->GetAnimator()->is_animating())
button->layer()->SetOpacity(0.0f);

button->SetVisible(true);
button->set_is_showing(true);
views::AnimationBuilder()
.SetPreemptionStrategy(
ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET)
.Once()
.At(kButtonFadeInDelay)
.SetDuration(kButtonFadeInDuration)
.SetOpacity(button->layer(), 1.0f, gfx::Tween::LINEAR);

// Set the button visible after scheduling the animation because scheduling
// the animation might abort a fade-out, which sets the button invisible.
button->SetVisible(true);
button->set_is_showing(true);
}

void SearchBoxViewBase::MaybeFadeButtonOut(SearchBoxImageButton* button) {
if (!button->GetVisible() || !button->is_showing())
return;

button->set_is_showing(false);
views::AnimationBuilder()
.SetPreemptionStrategy(
ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET)
.OnEnded(base::BindOnce(&SearchBoxViewBase::SetVisibilityHidden,
weak_factory_.GetWeakPtr(), button))
.OnAborted(base::BindOnce(&SearchBoxViewBase::SetVisibilityHidden,
weak_factory_.GetWeakPtr(), button))
.Once()
.SetDuration(kButtonFadeOutDuration)
.SetOpacity(button->layer(), 0.0f, gfx::Tween::LINEAR);

button->set_is_showing(false);
}

void SearchBoxViewBase::SetVisibilityHidden(SearchBoxImageButton* button) {
Expand Down

0 comments on commit e652899

Please sign in to comment.