Commit b5456110 authored by Dana Fried's avatar Dana Fried Committed by Commit Bot

Update bounds of hover card when hover card is updated or shown.

Prevents the wrong height hover card for the current window title from
being displayed. Previously, there were cases where the size of the
hover card was not correctly updated.

Note: probably still needs browsertests :/

Bug: 984963, 995980
Change-Id: I61c1ee3a9b8cf4c8315860c619f151e772cca04c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1763637Reviewed-by: default avatarCaroline Rising <corising@chromium.org>
Commit-Queue: Dana Fried <dfried@chromium.org>
Cr-Commit-Position: refs/heads/master@{#689544}
parent 147926d2
...@@ -222,30 +222,31 @@ class TabHoverCardBubbleView::WidgetSlideAnimationDelegate ...@@ -222,30 +222,31 @@ class TabHoverCardBubbleView::WidgetSlideAnimationDelegate
void AnimateToAnchorView(views::View* desired_anchor_view) { void AnimateToAnchorView(views::View* desired_anchor_view) {
DCHECK(!current_bubble_bounds_.IsEmpty()); 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();
anchor_bounds.Inset(bubble_delegate_->anchor_view_insets());
starting_bubble_bounds_ = current_bubble_bounds_; starting_bubble_bounds_ = current_bubble_bounds_;
target_bubble_bounds_ = CalculateTargetBounds(desired_anchor_view);
slide_animation_->Reset(0); slide_animation_->Reset(0);
target_bubble_bounds_ =
bubble_delegate_->GetBubbleFrameView()->GetUpdatedWindowBounds(
anchor_bounds, bubble_delegate_->arrow(),
bubble_delegate_->GetWidget()->client_view()->GetPreferredSize(),
true);
slide_animation_->Show(); slide_animation_->Show();
} }
void StopAnimation() { AnimationCanceled(slide_animation_.get()); } void StopAnimation() { AnimationCanceled(slide_animation_.get()); }
void SetBounds() { // Stores 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.
void SetCurrentBounds() {
current_bubble_bounds_ = bubble_delegate_->GetBubbleBounds(); current_bubble_bounds_ = bubble_delegate_->GetBubbleBounds();
} }
bool IsAnimating() { return slide_animation_->is_animating(); } bool IsAnimating() { return slide_animation_->is_animating(); }
gfx::Rect CalculateTargetBounds(views::View* desired_anchor_view) const {
gfx::Rect anchor_bounds = desired_anchor_view->GetAnchorBoundsInScreen();
anchor_bounds.Inset(bubble_delegate_->anchor_view_insets());
return bubble_delegate_->GetBubbleFrameView()->GetUpdatedWindowBounds(
anchor_bounds, bubble_delegate_->arrow(),
bubble_delegate_->GetWidget()->client_view()->GetPreferredSize(), true);
}
private: private:
void AnimationProgressed(const gfx::Animation* animation) override { void AnimationProgressed(const gfx::Animation* animation) override {
double value = gfx::Tween::CalculateValue( double value = gfx::Tween::CalculateValue(
...@@ -406,10 +407,13 @@ void TabHoverCardBubbleView::UpdateAndShow(Tab* tab) { ...@@ -406,10 +407,13 @@ void TabHoverCardBubbleView::UpdateAndShow(Tab* tab) {
} }
UpdateCardContent(tab); UpdateCardContent(tab);
// If widget is already visible and anchored to the correct tab we should not // If widget is already visible and anchored to the correct tab we should not
// try to reset the anchor view or reshow. // try to reset the anchor view or reshow.
if (widget_->IsVisible() && GetAnchorView() == tab && if (widget_->IsVisible() && GetAnchorView() == tab &&
!slide_animation_delegate_->IsAnimating()) { !slide_animation_delegate_->IsAnimating()) {
widget_->SetBounds(slide_animation_delegate_->CalculateTargetBounds(tab));
slide_animation_delegate_->SetCurrentBounds();
return; return;
} }
...@@ -421,10 +425,8 @@ void TabHoverCardBubbleView::UpdateAndShow(Tab* tab) { ...@@ -421,10 +425,8 @@ void TabHoverCardBubbleView::UpdateAndShow(Tab* tab) {
} else { } else {
if (!anchor_view_set) if (!anchor_view_set)
SetAnchorView(tab); SetAnchorView(tab);
// Store the current bubble bounds now to be used when animating to a new widget_->SetBounds(slide_animation_delegate_->CalculateTargetBounds(tab));
// view. We do this now since the anchor view is needed to get bubble slide_animation_delegate_->SetCurrentBounds();
// bounds and could be deleting later when using the bounds to animate.
slide_animation_delegate_->SetBounds();
} }
if (!widget_->IsVisible()) { if (!widget_->IsVisible()) {
......
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