Commit 42ca473d authored by Caroline Rising's avatar Caroline Rising Committed by Commit Bot

Fix bug where tab hover card image is seen red in color.

While a tab hover card is animating between tabs the hover cards anchor view is in transition and the tab hover card's data is updated before the anchor is moved. Because of this, GetThemeProvider() was not using the correct tab, this cl gets the theme provider from the correct tab that the hover card is moving to.

Bug: 968055, 910739, 928954
Change-Id: Ide4f109ea66c206da1c6fb9c8c785282694ccadb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1635857
Commit-Queue: Caroline Rising <corising@chromium.org>
Reviewed-by: default avatarDana Fried <dfried@chromium.org>
Cr-Commit-Position: refs/heads/master@{#664479}
parent 6447103a
...@@ -383,7 +383,7 @@ void TabHoverCardBubbleView::UpdateAndShow(Tab* tab) { ...@@ -383,7 +383,7 @@ void TabHoverCardBubbleView::UpdateAndShow(Tab* tab) {
if (preview_image_) if (preview_image_)
preview_image_->SetVisible(!tab->IsActive()); preview_image_->SetVisible(!tab->IsActive());
UpdateCardContent(tab->data()); 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 &&
...@@ -474,11 +474,11 @@ void TabHoverCardBubbleView::FadeInToShow() { ...@@ -474,11 +474,11 @@ void TabHoverCardBubbleView::FadeInToShow() {
fade_animation_delegate_->FadeIn(); fade_animation_delegate_->FadeIn();
} }
void TabHoverCardBubbleView::UpdateCardContent(TabRendererData data) { void TabHoverCardBubbleView::UpdateCardContent(const Tab* tab) {
title_label_->SetText(data.title); title_label_->SetText(tab->data().title);
base::string16 domain = url_formatter::FormatUrl( base::string16 domain = url_formatter::FormatUrl(
data.last_committed_url, tab->data().last_committed_url,
url_formatter::kFormatUrlOmitDefaults | url_formatter::kFormatUrlOmitDefaults |
url_formatter::kFormatUrlOmitHTTPS | url_formatter::kFormatUrlOmitHTTPS |
url_formatter::kFormatUrlOmitTrivialSubdomains | url_formatter::kFormatUrlOmitTrivialSubdomains |
...@@ -490,12 +490,12 @@ void TabHoverCardBubbleView::UpdateCardContent(TabRendererData data) { ...@@ -490,12 +490,12 @@ void TabHoverCardBubbleView::UpdateCardContent(TabRendererData data) {
if (preview_image_ && preview_image_->GetVisible()) { if (preview_image_ && preview_image_->GetVisible()) {
// If there is no valid thumbnail data, blank out the preview, else wait for // If there is no valid thumbnail data, blank out the preview, else wait for
// the image data to be decoded and update momentarily. // the image data to be decoded and update momentarily.
if (!data.thumbnail.AsImageSkiaAsync( if (!tab->data().thumbnail.AsImageSkiaAsync(
base::BindOnce(&TabHoverCardBubbleView::UpdatePreviewImage, base::BindOnce(&TabHoverCardBubbleView::UpdatePreviewImage,
weak_factory_.GetWeakPtr()))) { weak_factory_.GetWeakPtr()))) {
// Check the no-preview color and size to see if it needs to be // Check the no-preview color and size to see if it needs to be
// regenerated. DPI or theme change can cause a regeneration. // regenerated. DPI or theme change can cause a regeneration.
const SkColor foreground_color = GetThemeProvider()->GetColor( const SkColor foreground_color = tab->GetThemeProvider()->GetColor(
ThemeProperties::COLOR_HOVER_CARD_NO_PREVIEW_FOREGROUND); ThemeProperties::COLOR_HOVER_CARD_NO_PREVIEW_FOREGROUND);
// Set the no-preview placeholder image. All sizes are in DIPs. // Set the no-preview placeholder image. All sizes are in DIPs.
...@@ -510,7 +510,7 @@ void TabHoverCardBubbleView::UpdateCardContent(TabRendererData data) { ...@@ -510,7 +510,7 @@ void TabHoverCardBubbleView::UpdateCardContent(TabRendererData data) {
preview_image_->SetPreferredSize(GetTabHoverCardPreviewImageSize()); preview_image_->SetPreferredSize(GetTabHoverCardPreviewImageSize());
// Also possibly regenerate the background if it has changed. // Also possibly regenerate the background if it has changed.
const SkColor background_color = GetThemeProvider()->GetColor( const SkColor background_color = tab->GetThemeProvider()->GetColor(
ThemeProperties::COLOR_HOVER_CARD_NO_PREVIEW_BACKGROUND); ThemeProperties::COLOR_HOVER_CARD_NO_PREVIEW_BACKGROUND);
if (!preview_image_->background() || if (!preview_image_->background() ||
preview_image_->background()->get_color() != background_color) { preview_image_->background()->get_color() != background_color) {
......
...@@ -23,7 +23,6 @@ class Widget; ...@@ -23,7 +23,6 @@ class Widget;
} // namespace views } // namespace views
class Tab; class Tab;
struct TabRendererData;
// Dialog that displays an informational hover card containing page information. // Dialog that displays an informational hover card containing page information.
class TabHoverCardBubbleView : public views::BubbleDialogDelegateView { class TabHoverCardBubbleView : public views::BubbleDialogDelegateView {
...@@ -55,8 +54,8 @@ class TabHoverCardBubbleView : public views::BubbleDialogDelegateView { ...@@ -55,8 +54,8 @@ class TabHoverCardBubbleView : public views::BubbleDialogDelegateView {
void FadeInToShow(); void FadeInToShow();
// Updates and formats title and domain with given data. // Updates and formats title, domain, and preview image.
void UpdateCardContent(TabRendererData data); void UpdateCardContent(const Tab* tab);
void UpdatePreviewImage(gfx::ImageSkia preview_image); void UpdatePreviewImage(gfx::ImageSkia preview_image);
......
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