| Index: chrome/browser/ui/views/tabs/tab.cc
|
| diff --git a/chrome/browser/ui/views/tabs/tab.cc b/chrome/browser/ui/views/tabs/tab.cc
|
| index ba7f628ea4eb6b8b5ee1a183928544c7910245e5..b5891907aa2dccea5d5d4d1a839266d545c5034e 100644
|
| --- a/chrome/browser/ui/views/tabs/tab.cc
|
| +++ b/chrome/browser/ui/views/tabs/tab.cc
|
| @@ -1143,13 +1143,13 @@ void Tab::DataChanged(const TabRendererData& old) {
|
| }
|
|
|
| void Tab::PaintTab(gfx::Canvas* canvas, const gfx::Path& clip) {
|
| - const int kActiveTabFillId = IDR_THEME_TOOLBAR;
|
| - const bool has_custom_image =
|
| - GetThemeProvider()->HasCustomImage(kActiveTabFillId);
|
| + const int kActiveTabFillId =
|
| + GetThemeProvider()->HasCustomImage(IDR_THEME_TOOLBAR) ? IDR_THEME_TOOLBAR
|
| + : 0;
|
| const int y_offset = -GetLayoutInsets(TAB).top();
|
| if (IsActive()) {
|
| PaintTabBackgroundUsingFillId(canvas, canvas, true, kActiveTabFillId,
|
| - has_custom_image, y_offset);
|
| + y_offset);
|
| } else {
|
| PaintInactiveTabBackground(canvas, clip);
|
|
|
| @@ -1158,7 +1158,7 @@ void Tab::PaintTab(gfx::Canvas* canvas, const gfx::Path& clip) {
|
| canvas->SaveLayerAlpha(gfx::ToRoundedInt(throb_value * 0xff),
|
| GetLocalBounds());
|
| PaintTabBackgroundUsingFillId(canvas, canvas, true, kActiveTabFillId,
|
| - has_custom_image, y_offset);
|
| + y_offset);
|
| canvas->Restore();
|
| }
|
| }
|
| @@ -1215,20 +1215,23 @@ void Tab::PaintInactiveTabBackground(gfx::Canvas* canvas,
|
| const gfx::Path& clip) {
|
| bool has_custom_image;
|
| int fill_id = controller_->GetBackgroundResourceId(&has_custom_image);
|
| -
|
| - // If the theme is providing a custom background image, then its top edge
|
| - // should be at the top of the tab. Otherwise, we assume that the background
|
| - // image is a composited foreground + frame image. Note that if the theme is
|
| - // only providing a custom frame image, |has_custom_image| will be true, but
|
| - // we should use the |background_offset_| here.
|
| const ui::ThemeProvider* tp = GetThemeProvider();
|
| - const int y_offset = tp->HasCustomImage(fill_id) ? 0 : background_offset_.y();
|
|
|
| // We only cache the image when it's the default image and we're not hovered,
|
| // to avoid caching a background image that isn't the same for all tabs.
|
| - if (has_custom_image || hover_controller_.ShouldDraw()) {
|
| - PaintTabBackgroundUsingFillId(canvas, canvas, false, fill_id,
|
| - has_custom_image, y_offset);
|
| + if (has_custom_image) {
|
| + // If the theme is providing a custom background image, then its top edge
|
| + // should be at the top of the tab. Otherwise, we assume that the background
|
| + // image is a composited foreground + frame image. Note that if the theme
|
| + // is only providing a custom frame image, |has_custom_image| will be true,
|
| + // but we should use the |background_offset_| here.
|
| + const int y_offset =
|
| + tp->HasCustomImage(fill_id) ? 0 : background_offset_.y();
|
| + PaintTabBackgroundUsingFillId(canvas, canvas, false, fill_id, y_offset);
|
| + return;
|
| + }
|
| + if (hover_controller_.ShouldDraw()) {
|
| + PaintTabBackgroundUsingFillId(canvas, canvas, false, 0, 0);
|
| return;
|
| }
|
|
|
| @@ -1249,14 +1252,12 @@ void Tab::PaintInactiveTabBackground(gfx::Canvas* canvas,
|
| gfx::Canvas tmp_canvas(size(), canvas->image_scale(), false);
|
| if (use_fill_and_stroke_images) {
|
| gfx::Canvas tmp_fill_canvas(size(), canvas->image_scale(), false);
|
| - PaintTabBackgroundUsingFillId(&tmp_fill_canvas, &tmp_canvas, false,
|
| - fill_id, false, y_offset);
|
| + PaintTabBackgroundUsingFillId(&tmp_fill_canvas, &tmp_canvas, false, 0, 0);
|
| g_image_cache->emplace_front(
|
| metadata, gfx::ImageSkia(tmp_fill_canvas.ExtractImageRep()),
|
| gfx::ImageSkia(tmp_canvas.ExtractImageRep()));
|
| } else {
|
| - PaintTabBackgroundUsingFillId(&tmp_canvas, &tmp_canvas, false, fill_id,
|
| - false, y_offset);
|
| + PaintTabBackgroundUsingFillId(&tmp_canvas, &tmp_canvas, false, 0, 0);
|
| g_image_cache->emplace_front(
|
| metadata, gfx::ImageSkia(),
|
| gfx::ImageSkia(tmp_canvas.ExtractImageRep()));
|
| @@ -1279,7 +1280,6 @@ void Tab::PaintTabBackgroundUsingFillId(gfx::Canvas* fill_canvas,
|
| gfx::Canvas* stroke_canvas,
|
| bool is_active,
|
| int fill_id,
|
| - bool has_custom_image,
|
| int y_offset) {
|
| gfx::Path fill;
|
| SkPaint paint;
|
| @@ -1296,7 +1296,7 @@ void Tab::PaintTabBackgroundUsingFillId(gfx::Canvas* fill_canvas,
|
| {
|
| gfx::ScopedCanvas clip_scoper(fill_canvas);
|
| fill_canvas->ClipPath(fill, true);
|
| - if (has_custom_image) {
|
| + if (fill_id) {
|
| gfx::ScopedCanvas scale_scoper(fill_canvas);
|
| fill_canvas->sk_canvas()->scale(scale, scale);
|
| fill_canvas->TileImageInt(*tp->GetImageSkiaNamed(fill_id),
|
|
|