Commit ad274080 authored by Caroline Rising's avatar Caroline Rising Committed by Commit Bot

Set tab hover cards anchor_view_ to null when animation has ended or been stopped.

This is a follow up to https://chromium-review.googlesource.com/c/chromium/src/+/1627654

Bug: 910739
Change-Id: Ie80bc128250fd4dde9763fd38ce5bcfc58669d31
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1627666
Commit-Queue: Caroline Rising <corising@chromium.org>
Reviewed-by: default avatarDana Fried <dfried@chromium.org>
Cr-Commit-Position: refs/heads/master@{#662868}
parent 7a0351e8
...@@ -209,9 +209,9 @@ class TabHoverCardBubbleView::WidgetSlideAnimationDelegate ...@@ -209,9 +209,9 @@ class TabHoverCardBubbleView::WidgetSlideAnimationDelegate
} }
~WidgetSlideAnimationDelegate() override {} ~WidgetSlideAnimationDelegate() override {}
void AnimateToAnchorView(views::View* anchor_view) { void AnimateToAnchorView(views::View* desired_anchor_view) {
anchor_view_ = anchor_view; desired_anchor_view_ = desired_anchor_view;
gfx::Rect anchor_bounds = anchor_view->GetAnchorBoundsInScreen(); gfx::Rect anchor_bounds = desired_anchor_view->GetAnchorBoundsInScreen();
anchor_bounds.Inset(bubble_delegate_->anchor_view_insets()); anchor_bounds.Inset(bubble_delegate_->anchor_view_insets());
// If an animation is currently running we should start the next animation // If an animation is currently running we should start the next animation
...@@ -232,10 +232,7 @@ class TabHoverCardBubbleView::WidgetSlideAnimationDelegate ...@@ -232,10 +232,7 @@ class TabHoverCardBubbleView::WidgetSlideAnimationDelegate
slide_animation_->Show(); slide_animation_->Show();
} }
void StopAnimation() { void StopAnimation() { AnimationCanceled(slide_animation_.get()); }
anchor_view_ = nullptr;
slide_animation_->Stop();
}
bool IsAnimating() { return slide_animation_->is_animating(); } bool IsAnimating() { return slide_animation_->is_animating(); }
...@@ -247,14 +244,24 @@ class TabHoverCardBubbleView::WidgetSlideAnimationDelegate ...@@ -247,14 +244,24 @@ class TabHoverCardBubbleView::WidgetSlideAnimationDelegate
value, starting_bubble_bounds_, target_bubble_bounds_); value, starting_bubble_bounds_, target_bubble_bounds_);
if (current_bubble_bounds_ == target_bubble_bounds_) { if (current_bubble_bounds_ == target_bubble_bounds_) {
bubble_delegate_->SetAnchorView(anchor_view_); bubble_delegate_->SetAnchorView(desired_anchor_view_);
AnimationEnded(animation);
} }
bubble_delegate_->GetWidget()->SetBounds(current_bubble_bounds_); bubble_delegate_->GetWidget()->SetBounds(current_bubble_bounds_);
} }
void AnimationEnded(const gfx::Animation* animation) override {
desired_anchor_view_ = nullptr;
}
void AnimationCanceled(const gfx::Animation* animation) override {
AnimationEnded(animation);
slide_animation_->Stop();
}
TabHoverCardBubbleView* const bubble_delegate_; TabHoverCardBubbleView* const bubble_delegate_;
std::unique_ptr<gfx::SlideAnimation> slide_animation_; std::unique_ptr<gfx::SlideAnimation> slide_animation_;
views::View* anchor_view_ = nullptr; views::View* desired_anchor_view_ = nullptr;
gfx::Rect starting_bubble_bounds_; gfx::Rect starting_bubble_bounds_;
gfx::Rect target_bubble_bounds_; gfx::Rect target_bubble_bounds_;
gfx::Rect current_bubble_bounds_; gfx::Rect current_bubble_bounds_;
......
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