OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/ui/views/tabs/tab.h" | 5 #include "chrome/browser/ui/views/tabs/tab.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/debug/alias.h" | 10 #include "base/debug/alias.h" |
11 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
12 #include "chrome/browser/defaults.h" | 12 #include "chrome/browser/defaults.h" |
13 #include "chrome/browser/themes/theme_properties.h" | 13 #include "chrome/browser/themes/theme_properties.h" |
14 #include "chrome/browser/ui/browser.h" | 14 #include "chrome/browser/ui/browser.h" |
15 #include "chrome/browser/ui/tab_contents/core_tab_helper.h" | 15 #include "chrome/browser/ui/tab_contents/core_tab_helper.h" |
16 #include "chrome/browser/ui/tabs/tab_resources.h" | 16 #include "chrome/browser/ui/tabs/tab_resources.h" |
17 #include "chrome/browser/ui/view_ids.h" | 17 #include "chrome/browser/ui/view_ids.h" |
18 #include "chrome/browser/ui/views/tabs/tab_controller.h" | 18 #include "chrome/browser/ui/views/tabs/tab_controller.h" |
| 19 #include "chrome/browser/ui/views/tabs/tab_paint_util.h" |
19 #include "chrome/browser/ui/views/theme_image_mapper.h" | 20 #include "chrome/browser/ui/views/theme_image_mapper.h" |
20 #include "chrome/browser/ui/views/touch_uma/touch_uma.h" | 21 #include "chrome/browser/ui/views/touch_uma/touch_uma.h" |
21 #include "chrome/common/chrome_switches.h" | 22 #include "chrome/common/chrome_switches.h" |
22 #include "grit/generated_resources.h" | 23 #include "grit/generated_resources.h" |
23 #include "grit/theme_resources.h" | 24 #include "grit/theme_resources.h" |
24 #include "grit/ui_resources.h" | 25 #include "grit/ui_resources.h" |
25 #include "third_party/skia/include/effects/SkGradientShader.h" | 26 #include "third_party/skia/include/effects/SkGradientShader.h" |
26 #include "ui/base/accessibility/accessible_view_state.h" | 27 #include "ui/base/accessibility/accessible_view_state.h" |
27 #include "ui/base/animation/animation_container.h" | 28 #include "ui/base/animation/animation_container.h" |
28 #include "ui/base/animation/multi_animation.h" | 29 #include "ui/base/animation/multi_animation.h" |
(...skipping 1204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1233 // And then the gradient on top of that. | 1234 // And then the gradient on top of that. |
1234 if (animation->current_part_index() == 2) { | 1235 if (animation->current_part_index() == 2) { |
1235 uint8 alpha = animation->CurrentValueBetween(255, 0); | 1236 uint8 alpha = animation->CurrentValueBetween(255, 0); |
1236 canvas->DrawImageInt(hover_image, 0, 0, alpha); | 1237 canvas->DrawImageInt(hover_image, 0, 0, alpha); |
1237 } else { | 1238 } else { |
1238 canvas->DrawImageInt(hover_image, 0, 0); | 1239 canvas->DrawImageInt(hover_image, 0, 0); |
1239 } | 1240 } |
1240 } | 1241 } |
1241 | 1242 |
1242 void Tab::PaintInactiveTabBackground(gfx::Canvas* canvas) { | 1243 void Tab::PaintInactiveTabBackground(gfx::Canvas* canvas) { |
1243 int tab_id; | 1244 int background_id; |
1244 int frame_id; | 1245 int background_overlay_id; |
1245 views::Widget* widget = GetWidget(); | 1246 views::Widget* widget = GetWidget(); |
1246 GetTabIdAndFrameId(widget, &tab_id, &frame_id); | 1247 GetInactiveBackgroundIdAndOverlayId(widget, &background_id, |
| 1248 &background_overlay_id); |
1247 | 1249 |
1248 // Explicitly map the id so we cache correctly. | 1250 // Explicitly map the id so we cache correctly. |
1249 const chrome::HostDesktopType host_desktop_type = GetHostDesktopType(this); | 1251 const chrome::HostDesktopType host_desktop_type = GetHostDesktopType(this); |
1250 tab_id = chrome::MapThemeImage(host_desktop_type, tab_id); | 1252 background_id = chrome::MapThemeImage(host_desktop_type, background_id); |
1251 | 1253 |
1252 // HasCustomImage() is only true if the theme provides the image. However, | 1254 // HasCustomImage() is only true if the theme provides the image. However, |
1253 // even if the theme does not provide a tab background, the theme machinery | 1255 // even if the theme does not provide a tab background, the theme machinery |
1254 // will make one if given a frame image. | 1256 // will make one if given a frame image. |
1255 ui::ThemeProvider* theme_provider = GetThemeProvider(); | 1257 ui::ThemeProvider* theme_provider = GetThemeProvider(); |
1256 const bool theme_provided_image = theme_provider->HasCustomImage(tab_id) || | 1258 const bool theme_provided_image = |
1257 (frame_id != 0 && theme_provider->HasCustomImage(frame_id)); | 1259 theme_provider->HasCustomImage(IDR_THEME_FRAME) || |
| 1260 theme_provider->HasCustomImage(background_id) || |
| 1261 theme_provider->HasCustomImage(background_overlay_id); |
1258 | 1262 |
1259 const bool can_cache = !theme_provided_image && | 1263 const bool can_cache = !theme_provided_image && |
1260 !hover_controller_.ShouldDraw(); | 1264 !hover_controller_.ShouldDraw(); |
1261 | 1265 |
1262 if (can_cache) { | 1266 if (can_cache) { |
| 1267 // The default theme does not provide background overlay images. |
1263 gfx::ImageSkia cached_image( | 1268 gfx::ImageSkia cached_image( |
1264 GetCachedImage(tab_id, size(), canvas->scale_factor())); | 1269 GetCachedImage(background_id, size(), canvas->scale_factor())); |
1265 if (cached_image.width() == 0) { | 1270 if (cached_image.width() == 0) { |
1266 gfx::Canvas tmp_canvas(size(), canvas->scale_factor(), false); | 1271 gfx::Canvas tmp_canvas(size(), canvas->scale_factor(), false); |
1267 PaintInactiveTabBackgroundUsingResourceId(&tmp_canvas, tab_id); | 1272 PaintInactiveTabBackgroundUsingResourceIds(&tmp_canvas, background_id, |
| 1273 background_overlay_id); |
1268 cached_image = gfx::ImageSkia(tmp_canvas.ExtractImageRep()); | 1274 cached_image = gfx::ImageSkia(tmp_canvas.ExtractImageRep()); |
1269 SetCachedImage(tab_id, canvas->scale_factor(), cached_image); | 1275 SetCachedImage(background_id, canvas->scale_factor(), cached_image); |
1270 } | 1276 } |
1271 canvas->DrawImageInt(cached_image, 0, 0); | 1277 canvas->DrawImageInt(cached_image, 0, 0); |
1272 } else { | 1278 } else { |
1273 PaintInactiveTabBackgroundUsingResourceId(canvas, tab_id); | 1279 PaintInactiveTabBackgroundUsingResourceIds(canvas, background_id, |
| 1280 background_overlay_id); |
1274 } | 1281 } |
1275 } | 1282 } |
1276 | 1283 |
1277 void Tab::PaintInactiveTabBackgroundUsingResourceId(gfx::Canvas* canvas, | 1284 void Tab::PaintInactiveTabBackgroundUsingResourceIds( |
1278 int tab_id) { | 1285 gfx::Canvas* canvas, |
| 1286 int background_id, |
| 1287 int background_overlay_id) { |
1279 // WARNING: the inactive tab background may be cached. If you change what it | 1288 // WARNING: the inactive tab background may be cached. If you change what it |
1280 // is drawn from you may need to update whether it can be cached. | 1289 // is drawn from you may need to update whether it can be cached. |
1281 | 1290 |
1282 // The tab image needs to be lined up with the background image | 1291 // The tab image needs to be lined up with the background image |
1283 // so that it feels partially transparent. These offsets represent the tab | 1292 // so that it feels partially transparent. This offset represents the tab |
1284 // position within the frame background image. | 1293 // position within the frame background image. |
1285 int offset = GetMirroredX() + background_offset_.x(); | 1294 int offset = GetMirroredX() + background_offset_.x(); |
1286 | 1295 |
1287 gfx::ImageSkia* tab_bg = GetThemeProvider()->GetImageSkiaNamed(tab_id); | 1296 ui::ThemeProvider* tp = GetThemeProvider(); |
1288 | |
1289 TabImage* tab_image = &tab_active_; | 1297 TabImage* tab_image = &tab_active_; |
1290 TabImage* tab_inactive_image = &tab_inactive_; | 1298 TabImage* tab_inactive_image = &tab_inactive_; |
1291 TabImage* alpha = &tab_alpha_; | 1299 TabImage* alpha = &tab_alpha_; |
1292 | 1300 |
1293 // If the theme is providing a custom background image, then its top edge | |
1294 // should be at the top of the tab. Otherwise, we assume that the background | |
1295 // image is a composited foreground + frame image. | |
1296 int bg_offset_y = GetThemeProvider()->HasCustomImage(tab_id) ? | |
1297 0 : background_offset_.y(); | |
1298 | |
1299 // We need a gfx::Canvas object to be able to extract the image from. | 1301 // We need a gfx::Canvas object to be able to extract the image from. |
1300 // We draw everything to this canvas and then output it to the canvas | 1302 // We draw everything to this canvas and then output it to the canvas |
1301 // parameter in addition to using it to mask the hover glow if needed. | 1303 // parameter in addition to using it to mask the hover glow if needed. |
1302 gfx::Canvas background_canvas(size(), canvas->scale_factor(), false); | 1304 gfx::Canvas background_canvas(size(), canvas->scale_factor(), false); |
1303 | 1305 |
1304 // Draw left edge. Don't draw over the toolbar, as we're not the foreground | 1306 // Draw left edge. Don't draw over the toolbar, as we're not the foreground |
1305 // tab. | 1307 // tab. |
1306 gfx::ImageSkia tab_l = gfx::ImageSkiaOperations::CreateTiledImage( | 1308 gfx::ImageSkia tab_l = TabPaintUtil::CreateTiledInactiveBackground(tp, |
1307 *tab_bg, offset, bg_offset_y, tab_image->l_width, height()); | 1309 background_id, background_overlay_id, background_offset_.y(), offset, 0, |
| 1310 tab_image->l_width, height()); |
1308 gfx::ImageSkia theme_l = | 1311 gfx::ImageSkia theme_l = |
1309 gfx::ImageSkiaOperations::CreateMaskedImage(tab_l, *alpha->image_l); | 1312 gfx::ImageSkiaOperations::CreateMaskedImage(tab_l, *alpha->image_l); |
1310 background_canvas.DrawImageInt(theme_l, | 1313 background_canvas.DrawImageInt(theme_l, |
1311 0, 0, theme_l.width(), theme_l.height() - kToolbarOverlap, | 1314 0, 0, theme_l.width(), theme_l.height() - kToolbarOverlap, |
1312 0, 0, theme_l.width(), theme_l.height() - kToolbarOverlap, | 1315 0, 0, theme_l.width(), theme_l.height() - kToolbarOverlap, |
1313 false); | 1316 false); |
1314 | 1317 |
1315 // Draw right edge. Again, don't draw over the toolbar. | 1318 // Draw right edge. Again, don't draw over the toolbar. |
1316 gfx::ImageSkia tab_r = gfx::ImageSkiaOperations::CreateTiledImage(*tab_bg, | 1319 gfx::ImageSkia tab_r = TabPaintUtil::CreateTiledInactiveBackground(tp, |
1317 offset + width() - tab_image->r_width, bg_offset_y, | 1320 background_id, background_overlay_id, background_offset_.y(), |
1318 tab_image->r_width, height()); | 1321 offset + width() - tab_image->r_width, 0, tab_image->r_width, height()); |
1319 gfx::ImageSkia theme_r = | 1322 gfx::ImageSkia theme_r = |
1320 gfx::ImageSkiaOperations::CreateMaskedImage(tab_r, *alpha->image_r); | 1323 gfx::ImageSkiaOperations::CreateMaskedImage(tab_r, *alpha->image_r); |
1321 background_canvas.DrawImageInt(theme_r, | 1324 background_canvas.DrawImageInt(theme_r, |
1322 0, 0, theme_r.width(), theme_r.height() - kToolbarOverlap, | 1325 0, 0, theme_r.width(), theme_r.height() - kToolbarOverlap, |
1323 width() - theme_r.width(), 0, theme_r.width(), | 1326 width() - theme_r.width(), 0, theme_r.width(), |
1324 theme_r.height() - kToolbarOverlap, false); | 1327 theme_r.height() - kToolbarOverlap, false); |
1325 | 1328 |
1326 // Draw center. Instead of masking out the top portion we simply skip over | 1329 // Draw center. Instead of masking out the top portion we simply skip over |
1327 // it by incrementing by GetDropShadowHeight(), since it's a simple | 1330 // it by incrementing by drop_shadow_height(), since it's a simple |
1328 // rectangle. And again, don't draw over the toolbar. | 1331 // rectangle. And again, don't draw over the toolbar. |
1329 background_canvas.TileImageInt(*tab_bg, | 1332 gfx::ImageSkia tab_c = TabPaintUtil::CreateTiledInactiveBackground(tp, |
1330 offset + tab_image->l_width, | 1333 background_id, |
1331 bg_offset_y + drop_shadow_height(), | 1334 background_overlay_id, |
1332 tab_image->l_width, | 1335 background_offset_.y(), |
1333 drop_shadow_height(), | 1336 offset + tab_image->l_width, |
1334 width() - tab_image->l_width - tab_image->r_width, | 1337 drop_shadow_height(), |
1335 height() - drop_shadow_height() - kToolbarOverlap); | 1338 width() - tab_image->l_width - tab_image->r_width, |
| 1339 height() - drop_shadow_height() - kToolbarOverlap); |
| 1340 background_canvas.DrawImageInt(tab_c, tab_image->l_width, |
| 1341 drop_shadow_height()); |
1336 | 1342 |
1337 canvas->DrawImageInt( | 1343 canvas->DrawImageInt( |
1338 gfx::ImageSkia(background_canvas.ExtractImageRep()), 0, 0); | 1344 gfx::ImageSkia(background_canvas.ExtractImageRep()), 0, 0); |
1339 | 1345 |
1340 if (!GetThemeProvider()->HasCustomImage(tab_id) && | 1346 if (!tp->HasCustomImage(background_overlay_id) && |
1341 hover_controller_.ShouldDraw()) { | 1347 hover_controller_.ShouldDraw()) { |
1342 hover_controller_.Draw(canvas, gfx::ImageSkia( | 1348 hover_controller_.Draw(canvas, gfx::ImageSkia( |
1343 background_canvas.ExtractImageRep())); | 1349 background_canvas.ExtractImageRep())); |
1344 } | 1350 } |
1345 | 1351 |
1346 // Now draw the highlights/shadows around the tab edge. | 1352 // Now draw the highlights/shadows around the tab edge. |
1347 canvas->DrawImageInt(*tab_inactive_image->image_l, 0, 0); | 1353 canvas->DrawImageInt(*tab_inactive_image->image_l, 0, 0); |
1348 canvas->TileImageInt(*tab_inactive_image->image_c, | 1354 canvas->TileImageInt(*tab_inactive_image->image_c, |
1349 tab_inactive_image->l_width, 0, | 1355 tab_inactive_image->l_width, 0, |
1350 width() - tab_inactive_image->l_width - | 1356 width() - tab_inactive_image->l_width - |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1497 gfx::ImageSkia projection_glow( | 1503 gfx::ImageSkia projection_glow( |
1498 *tp->GetImageSkiaNamed(IDR_TAB_CAPTURE_GLOW)); | 1504 *tp->GetImageSkiaNamed(IDR_TAB_CAPTURE_GLOW)); |
1499 DrawIconCenter(canvas, projection_glow, 0, projection_glow.width(), | 1505 DrawIconCenter(canvas, projection_glow, 0, projection_glow.width(), |
1500 projection_glow.height(), glow_bounds, false, paint); | 1506 projection_glow.height(), glow_bounds, false, paint); |
1501 } else if (data().capture_state == TabRendererData::CAPTURE_STATE_RECORDING) { | 1507 } else if (data().capture_state == TabRendererData::CAPTURE_STATE_RECORDING) { |
1502 // If recording, fade the recording icon on top of the favicon with a mask | 1508 // If recording, fade the recording icon on top of the favicon with a mask |
1503 // around/behind it. | 1509 // around/behind it. |
1504 gfx::ImageSkia recording_dot(*tp->GetImageSkiaNamed(IDR_TAB_RECORDING)); | 1510 gfx::ImageSkia recording_dot(*tp->GetImageSkiaNamed(IDR_TAB_RECORDING)); |
1505 gfx::ImageSkia recording_dot_mask( | 1511 gfx::ImageSkia recording_dot_mask( |
1506 *tp->GetImageSkiaNamed(IDR_TAB_RECORDING_MASK)); | 1512 *tp->GetImageSkiaNamed(IDR_TAB_RECORDING_MASK)); |
1507 gfx::ImageSkia tab_background; | |
1508 if (IsActive()) { | |
1509 tab_background = *tp->GetImageSkiaNamed(IDR_THEME_TOOLBAR); | |
1510 } else { | |
1511 int tab_id; | |
1512 int frame_id_dummy; | |
1513 views::Widget* widget = GetWidget(); | |
1514 GetTabIdAndFrameId(widget, &tab_id, &frame_id_dummy); | |
1515 tab_background = *tp->GetImageSkiaNamed(tab_id); | |
1516 } | |
1517 | 1513 |
1518 // This is the offset from the favicon bottom right corner for the mask, | 1514 // This is the offset from the favicon bottom right corner for the mask, |
1519 // given that the recording dot is drawn in the bottom right corner. | 1515 // given that the recording dot is drawn in the bottom right corner. |
1520 int mask_offset_from_right = recording_dot.width() + | 1516 int mask_offset_from_right = recording_dot.width() + |
1521 (recording_dot_mask.width() - recording_dot.width()) / 2; | 1517 (recording_dot_mask.width() - recording_dot.width()) / 2; |
1522 int mask_offset_from_bottom = recording_dot.height() + | 1518 int mask_offset_from_bottom = recording_dot.height() + |
1523 (recording_dot_mask.height() - recording_dot.height()) / 2; | 1519 (recording_dot_mask.height() - recording_dot.height()) / 2; |
1524 | 1520 |
1525 int mask_dst_x = bounds.x() + bounds.width() - mask_offset_from_right; | 1521 int mask_dst_x = bounds.x() + bounds.width() - mask_offset_from_right; |
1526 int mask_dst_y = bounds.y() + bounds.height() - mask_offset_from_bottom; | 1522 int mask_dst_y = bounds.y() + bounds.height() - mask_offset_from_bottom; |
1527 | 1523 |
1528 // Crop the background image at the correct position and create a mask | 1524 // Crop the background image at the correct position and create a mask |
1529 // from the background. | 1525 // from the background. |
1530 int offset_x = GetMirroredX() + background_offset_.x() + mask_dst_x; | 1526 int offset_x = GetMirroredX() + background_offset_.x() + mask_dst_x; |
1531 int offset_y = mask_dst_y; | 1527 int offset_y = mask_dst_y; |
1532 gfx::ImageSkia tab_background_cropped = | 1528 gfx::ImageSkia tab_background_cropped; |
1533 gfx::ImageSkiaOperations::CreateTiledImage( | 1529 if (IsActive()) { |
1534 tab_background, offset_x, offset_y, | 1530 gfx::ImageSkia tab_background = *tp->GetImageSkiaNamed(IDR_THEME_TOOLBAR); |
1535 recording_dot_mask.width(), recording_dot_mask.height()); | 1531 tab_background_cropped = gfx::ImageSkiaOperations::CreateTiledImage( |
| 1532 tab_background, offset_x, offset_y, |
| 1533 recording_dot_mask.width(), recording_dot_mask.height()); |
| 1534 } else { |
| 1535 int background_id; |
| 1536 int background_overlay_id; |
| 1537 views::Widget* widget = GetWidget(); |
| 1538 GetInactiveBackgroundIdAndOverlayId(widget, &background_id, |
| 1539 &background_overlay_id); |
| 1540 |
| 1541 tab_background_cropped = TabPaintUtil::CreateTiledInactiveBackground(tp, |
| 1542 background_id, background_overlay_id, background_offset_.y(), |
| 1543 offset_x, offset_y, recording_dot_mask.width(), |
| 1544 recording_dot_mask.height()); |
| 1545 } |
1536 gfx::ImageSkia recording_dot_mask_with_bg = | 1546 gfx::ImageSkia recording_dot_mask_with_bg = |
1537 gfx::ImageSkiaOperations::CreateMaskedImage(tab_background_cropped, | 1547 gfx::ImageSkiaOperations::CreateMaskedImage(tab_background_cropped, |
1538 recording_dot_mask); | 1548 recording_dot_mask); |
1539 | 1549 |
1540 // Draw the mask. | 1550 // Draw the mask. |
1541 DrawIconAtLocation(canvas, recording_dot_mask_with_bg, 0, | 1551 DrawIconAtLocation(canvas, recording_dot_mask_with_bg, 0, |
1542 mask_dst_x, mask_dst_y, | 1552 mask_dst_x, mask_dst_y, |
1543 recording_dot_mask.width(), | 1553 recording_dot_mask.width(), |
1544 recording_dot_mask.height(), | 1554 recording_dot_mask.height(), |
1545 false, SkPaint()); | 1555 false, SkPaint()); |
1546 | 1556 |
1547 // Potentially draw an alpha of the active bg image. | 1557 // Potentially draw an alpha of the active bg image. |
1548 double throb_value = GetThrobValue(); | 1558 double throb_value = GetThrobValue(); |
1549 if (!IsActive() && throb_value > 0) { | 1559 if (!IsActive() && throb_value > 0) { |
1550 tab_background = *tp->GetImageSkiaNamed(IDR_THEME_TOOLBAR); | 1560 gfx::ImageSkia tab_background = |
| 1561 *tp->GetImageSkiaNamed(IDR_THEME_TOOLBAR); |
1551 tab_background_cropped = gfx::ImageSkiaOperations::CreateTiledImage( | 1562 tab_background_cropped = gfx::ImageSkiaOperations::CreateTiledImage( |
1552 tab_background, offset_x, offset_y, | 1563 tab_background, offset_x, offset_y, |
1553 recording_dot_mask.width(), recording_dot_mask.height()); | 1564 recording_dot_mask.width(), recording_dot_mask.height()); |
1554 recording_dot_mask_with_bg = gfx::ImageSkiaOperations::CreateMaskedImage( | 1565 recording_dot_mask_with_bg = gfx::ImageSkiaOperations::CreateMaskedImage( |
1555 tab_background_cropped, recording_dot_mask); | 1566 tab_background_cropped, recording_dot_mask); |
1556 | 1567 |
1557 canvas->SaveLayerAlpha(static_cast<int>(throb_value * 0xff), | 1568 canvas->SaveLayerAlpha(static_cast<int>(throb_value * 0xff), |
1558 GetLocalBounds()); | 1569 GetLocalBounds()); |
1559 DrawIconAtLocation(canvas, recording_dot_mask_with_bg, 0, | 1570 DrawIconAtLocation(canvas, recording_dot_mask_with_bg, 0, |
1560 mask_dst_x, mask_dst_y, | 1571 mask_dst_x, mask_dst_y, |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1745 // The main bar is as wide as the normal tab's horizontal top line. | 1756 // The main bar is as wide as the normal tab's horizontal top line. |
1746 // This top line of the tab extends a few pixels left and right of the | 1757 // This top line of the tab extends a few pixels left and right of the |
1747 // center image due to pixels in the rounded corner images. | 1758 // center image due to pixels in the rounded corner images. |
1748 const int kBarPadding = 1; | 1759 const int kBarPadding = 1; |
1749 int main_bar_left = tab_active_.l_width - kBarPadding; | 1760 int main_bar_left = tab_active_.l_width - kBarPadding; |
1750 int main_bar_right = width() - tab_active_.r_width + kBarPadding; | 1761 int main_bar_right = width() - tab_active_.r_width + kBarPadding; |
1751 return gfx::Rect( | 1762 return gfx::Rect( |
1752 main_bar_left, 0, main_bar_right - main_bar_left, kImmersiveBarHeight); | 1763 main_bar_left, 0, main_bar_right - main_bar_left, kImmersiveBarHeight); |
1753 } | 1764 } |
1754 | 1765 |
1755 void Tab::GetTabIdAndFrameId(views::Widget* widget, | 1766 void Tab::GetInactiveBackgroundIdAndOverlayId( |
1756 int* tab_id, | 1767 views::Widget* widget, |
1757 int* frame_id) const { | 1768 int* background_id, |
| 1769 int* background_overlay_id) const { |
1758 if (widget && widget->GetTopLevelWidget()->ShouldUseNativeFrame()) { | 1770 if (widget && widget->GetTopLevelWidget()->ShouldUseNativeFrame()) { |
1759 *tab_id = IDR_THEME_TAB_BACKGROUND_V; | 1771 *background_id = IDR_THEME_TAB_BACKGROUND_V; |
1760 *frame_id = 0; | 1772 *background_overlay_id = IDR_THEME_TAB_BACKGROUND_V_OVERLAY; |
1761 } else if (data().incognito) { | 1773 } else if (data().incognito) { |
1762 *tab_id = IDR_THEME_TAB_BACKGROUND_INCOGNITO; | 1774 *background_id = IDR_THEME_TAB_BACKGROUND_INCOGNITO; |
1763 *frame_id = IDR_THEME_FRAME_INCOGNITO; | 1775 *background_overlay_id = IDR_THEME_TAB_BACKGROUND_INCOGNITO_OVERLAY; |
1764 #if defined(OS_WIN) | 1776 #if defined(OS_WIN) |
1765 } else if (win8::IsSingleWindowMetroMode()) { | 1777 } else if (win8::IsSingleWindowMetroMode()) { |
1766 *tab_id = IDR_THEME_TAB_BACKGROUND_V; | 1778 *background_id = IDR_THEME_TAB_BACKGROUND_V; |
1767 *frame_id = 0; | 1779 *background_overlay_id = IDR_THEME_TAB_BACKGROUND_V_OVERLAY; |
1768 #endif | 1780 #endif |
1769 } else { | 1781 } else { |
1770 *tab_id = IDR_THEME_TAB_BACKGROUND; | 1782 *background_id = IDR_THEME_TAB_BACKGROUND; |
1771 *frame_id = IDR_THEME_FRAME; | 1783 *background_overlay_id = IDR_THEME_TAB_BACKGROUND_OVERLAY; |
1772 } | 1784 } |
1773 } | 1785 } |
1774 | 1786 |
1775 //////////////////////////////////////////////////////////////////////////////// | 1787 //////////////////////////////////////////////////////////////////////////////// |
1776 // Tab, private static: | 1788 // Tab, private static: |
1777 | 1789 |
1778 // static | 1790 // static |
1779 void Tab::InitTabResources() { | 1791 void Tab::InitTabResources() { |
1780 static bool initialized = false; | 1792 static bool initialized = false; |
1781 if (initialized) | 1793 if (initialized) |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1834 const gfx::ImageSkia& image) { | 1846 const gfx::ImageSkia& image) { |
1835 DCHECK_NE(scale_factor, ui::SCALE_FACTOR_NONE); | 1847 DCHECK_NE(scale_factor, ui::SCALE_FACTOR_NONE); |
1836 ImageCacheEntry entry; | 1848 ImageCacheEntry entry; |
1837 entry.resource_id = resource_id; | 1849 entry.resource_id = resource_id; |
1838 entry.scale_factor = scale_factor; | 1850 entry.scale_factor = scale_factor; |
1839 entry.image = image; | 1851 entry.image = image; |
1840 image_cache_->push_front(entry); | 1852 image_cache_->push_front(entry); |
1841 if (image_cache_->size() > kMaxImageCacheSize) | 1853 if (image_cache_->size() > kMaxImageCacheSize) |
1842 image_cache_->pop_back(); | 1854 image_cache_->pop_back(); |
1843 } | 1855 } |
OLD | NEW |