Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(952)

Unified Diff: chrome/browser/ui/views/tabs/tab.cc

Issue 2441863002: Remove some more !IsModeMaterial code. (Closed)
Patch Set: pull more shades Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« chrome/browser/ui/views/tabs/tab.h ('K') | « chrome/browser/ui/views/tabs/tab.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..a94ac04a772b0c3f25bf929388da1f9c49144fac 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,24 @@ 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.
Peter Kasting 2016/10/21 21:07:50 Nit: This comment is slightly confusing now that y
Evan Stade 2016/10/21 22:11:12 actually, there would be a need for ..., has_c
Peter Kasting 2016/10/22 00:14:44 Ah, you're right. Man, I thought through this lik
Evan Stade 2016/10/24 13:01:20 incidentally, already done in latest patchset
- 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 +1253,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 +1281,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 +1297,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 != 0) {
Peter Kasting 2016/10/21 21:07:51 Nit: To avoid the else reading like a double-negat
Evan Stade 2016/10/21 22:11:12 Done.
gfx::ScopedCanvas scale_scoper(fill_canvas);
fill_canvas->sk_canvas()->scale(scale, scale);
fill_canvas->TileImageInt(*tp->GetImageSkiaNamed(fill_id),
« chrome/browser/ui/views/tabs/tab.h ('K') | « chrome/browser/ui/views/tabs/tab.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698