Commit 2663ba7f authored by Caroline Rising's avatar Caroline Rising Committed by Commit Bot

Fix tab hover cards causing crashing when trying to get bubble bounds.

The crashing is caused by trying to get or set the anchor view which is gone. To fix this we get the bubble's bounds when the anchor view is set.

Bug: 965642
Change-Id: I0b2a788d09f04e09f51c5db1d723484b88f0bcd4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1625487
Commit-Queue: Caroline Rising <corising@chromium.org>
Reviewed-by: default avatarDana Fried <dfried@chromium.org>
Cr-Commit-Position: refs/heads/master@{#662916}
parent 2bc512d7
...@@ -211,16 +211,12 @@ class TabHoverCardBubbleView::WidgetSlideAnimationDelegate ...@@ -211,16 +211,12 @@ class TabHoverCardBubbleView::WidgetSlideAnimationDelegate
~WidgetSlideAnimationDelegate() override {} ~WidgetSlideAnimationDelegate() override {}
void AnimateToAnchorView(views::View* desired_anchor_view) { void AnimateToAnchorView(views::View* desired_anchor_view) {
DCHECK(!current_bubble_bounds_.IsEmpty());
desired_anchor_view_ = desired_anchor_view; desired_anchor_view_ = desired_anchor_view;
gfx::Rect anchor_bounds = desired_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 starting_bubble_bounds_ = current_bubble_bounds_;
// from where the previous left off.
if (slide_animation_->is_animating() && !current_bubble_bounds_.IsEmpty())
starting_bubble_bounds_ = current_bubble_bounds_;
else
starting_bubble_bounds_ = bubble_delegate_->GetBubbleBounds();
slide_animation_->Reset(0); slide_animation_->Reset(0);
...@@ -235,6 +231,10 @@ class TabHoverCardBubbleView::WidgetSlideAnimationDelegate ...@@ -235,6 +231,10 @@ class TabHoverCardBubbleView::WidgetSlideAnimationDelegate
void StopAnimation() { AnimationCanceled(slide_animation_.get()); } void StopAnimation() { AnimationCanceled(slide_animation_.get()); }
void SetBounds() {
current_bubble_bounds_ = bubble_delegate_->GetBubbleBounds();
}
bool IsAnimating() { return slide_animation_->is_animating(); } bool IsAnimating() { return slide_animation_->is_animating(); }
private: private:
...@@ -378,10 +378,15 @@ void TabHoverCardBubbleView::UpdateAndShow(Tab* tab) { ...@@ -378,10 +378,15 @@ void TabHoverCardBubbleView::UpdateAndShow(Tab* tab) {
return; return;
} }
if (widget_->IsVisible() && !disable_animations_for_testing_) if (widget_->IsVisible() && !disable_animations_for_testing_) {
slide_animation_delegate_->AnimateToAnchorView(tab); slide_animation_delegate_->AnimateToAnchorView(tab);
else } else {
SetAnchorView(tab); SetAnchorView(tab);
// Store the current bubble bounds now to be used when animating to a new
// view. We do this now since the anchor view is needed to get bubble
// bounds and could be deleting later when using the bounds to animate.
slide_animation_delegate_->SetBounds();
}
if (!widget_->IsVisible()) { if (!widget_->IsVisible()) {
if (disable_animations_for_testing_ || show_immediately || if (disable_animations_for_testing_ || show_immediately ||
......
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