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_strip.h" | 5 #include "chrome/browser/ui/views/tabs/tab_strip.h" |
6 | 6 |
7 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
8 #include <windowsx.h> | 8 #include <windowsx.h> |
9 #endif | 9 #endif |
10 | 10 |
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
413 int height = mask->height(); | 413 int height = mask->height(); |
414 int width = mask->width(); | 414 int width = mask->width(); |
415 gfx::Canvas canvas(gfx::Size(width, height), scale_factor, false); | 415 gfx::Canvas canvas(gfx::Size(width, height), scale_factor, false); |
416 | 416 |
417 // For custom images the background starts at the top of the tab strip. | 417 // For custom images the background starts at the top of the tab strip. |
418 // Otherwise the background starts at the top of the frame. | 418 // Otherwise the background starts at the top of the frame. |
419 gfx::ImageSkia* background = | 419 gfx::ImageSkia* background = |
420 GetThemeProvider()->GetImageSkiaNamed(background_id); | 420 GetThemeProvider()->GetImageSkiaNamed(background_id); |
421 int offset_y = GetThemeProvider()->HasCustomImage(background_id) ? | 421 int offset_y = GetThemeProvider()->HasCustomImage(background_id) ? |
422 0 : background_offset_.y(); | 422 0 : background_offset_.y(); |
423 canvas.TileImageInt(*background, GetMirroredX() + background_offset_.x(), | 423 |
424 newtab_button_v_offset() + offset_y, 0, 0, width, height); | 424 // The new tab background is mirrored in RTL mode, but the theme background |
| 425 // should never be mirrored. Mirror it here to compensate. |
| 426 float x_scale = 1.0f; |
| 427 int x = GetMirroredX() + background_offset_.x(); |
| 428 if (base::i18n::IsRTL()) { |
| 429 x_scale = -1.0f; |
| 430 // Offset by |width| such that the same region is painted as if there was no |
| 431 // flip. |
| 432 x += width; |
| 433 } |
| 434 canvas.TileImageInt(*background, x, newtab_button_v_offset() + offset_y, |
| 435 x_scale, 1.0f, 0, 0, width, height); |
425 | 436 |
426 if (alpha != 255) { | 437 if (alpha != 255) { |
427 SkPaint paint; | 438 SkPaint paint; |
428 paint.setColor(SkColorSetARGB(alpha, 255, 255, 255)); | 439 paint.setColor(SkColorSetARGB(alpha, 255, 255, 255)); |
429 paint.setXfermodeMode(SkXfermode::kDstIn_Mode); | 440 paint.setXfermodeMode(SkXfermode::kDstIn_Mode); |
430 paint.setStyle(SkPaint::kFill_Style); | 441 paint.setStyle(SkPaint::kFill_Style); |
431 canvas.DrawRect(gfx::Rect(0, 0, width, height), paint); | 442 canvas.DrawRect(gfx::Rect(0, 0, width, height), paint); |
432 } | 443 } |
433 | 444 |
434 // White highlight on hover. | 445 // White highlight on hover. |
(...skipping 1906 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2341 | 2352 |
2342 int mini_tab_count = GetMiniTabCount(); | 2353 int mini_tab_count = GetMiniTabCount(); |
2343 int normal_count = tab_count() - mini_tab_count; | 2354 int normal_count = tab_count() - mini_tab_count; |
2344 if (normal_count == 0 || normal_count == mini_tab_count) | 2355 if (normal_count == 0 || normal_count == mini_tab_count) |
2345 return false; | 2356 return false; |
2346 int x = GetStartXForNormalTabs(); | 2357 int x = GetStartXForNormalTabs(); |
2347 int available_width = width() - x - new_tab_button_width(); | 2358 int available_width = width() - x - new_tab_button_width(); |
2348 return (Tab::GetTouchWidth() * normal_count + | 2359 return (Tab::GetTouchWidth() * normal_count + |
2349 tab_h_offset() * (normal_count - 1)) > available_width; | 2360 tab_h_offset() * (normal_count - 1)) > available_width; |
2350 } | 2361 } |
OLD | NEW |