| 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" |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 | 56 |
| 57 // Padding around the "content" of a tab, occupied by the tab border graphics. | 57 // Padding around the "content" of a tab, occupied by the tab border graphics. |
| 58 const int kLeftPadding = 22; | 58 const int kLeftPadding = 22; |
| 59 const int kTopPadding = 7; | 59 const int kTopPadding = 7; |
| 60 const int kRightPadding = 17; | 60 const int kRightPadding = 17; |
| 61 const int kBottomPadding = 5; | 61 const int kBottomPadding = 5; |
| 62 | 62 |
| 63 // Height of the shadow at the top of the tab image assets. | 63 // Height of the shadow at the top of the tab image assets. |
| 64 const int kDropShadowHeight = 4; | 64 const int kDropShadowHeight = 4; |
| 65 | 65 |
| 66 // Size of icon used for throbber and favicon next to tab title. | |
| 67 const int kTabIconSize = gfx::kFaviconSize; | |
| 68 | |
| 69 // How long the pulse throb takes. | 66 // How long the pulse throb takes. |
| 70 const int kPulseDurationMs = 200; | 67 const int kPulseDurationMs = 200; |
| 71 | 68 |
| 72 // Width of touch tabs. | 69 // Width of touch tabs. |
| 73 static const int kTouchWidth = 120; | 70 static const int kTouchWidth = 120; |
| 74 | 71 |
| 75 static const int kToolbarOverlap = 1; | 72 static const int kToolbarOverlap = 1; |
| 76 static const int kFaviconTitleSpacing = 4; | 73 static const int kFaviconTitleSpacing = 4; |
| 77 // Additional vertical offset for title text relative to top of tab. | 74 // Additional vertical offset for title text relative to top of tab. |
| 78 // Ash text rendering may be different than Windows. | 75 // Ash text rendering may be different than Windows. |
| (...skipping 602 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 681 } | 678 } |
| 682 | 679 |
| 683 void Tab::Layout() { | 680 void Tab::Layout() { |
| 684 gfx::Rect lb = GetContentsBounds(); | 681 gfx::Rect lb = GetContentsBounds(); |
| 685 if (lb.IsEmpty()) | 682 if (lb.IsEmpty()) |
| 686 return; | 683 return; |
| 687 lb.Inset(kLeftPadding, kTopPadding, kRightPadding, kBottomPadding); | 684 lb.Inset(kLeftPadding, kTopPadding, kRightPadding, kBottomPadding); |
| 688 | 685 |
| 689 // The height of the content of the Tab is the largest of the favicon, | 686 // The height of the content of the Tab is the largest of the favicon, |
| 690 // the title text and the close button graphic. | 687 // the title text and the close button graphic. |
| 688 const int kTabIconSize = gfx::kFaviconSize; |
| 691 int content_height = std::max(kTabIconSize, font_height_); | 689 int content_height = std::max(kTabIconSize, font_height_); |
| 692 close_button_->SetBorder(views::Border::NullBorder()); | 690 close_button_->SetBorder(views::Border::NullBorder()); |
| 693 gfx::Size close_button_size(close_button_->GetPreferredSize()); | 691 gfx::Size close_button_size(close_button_->GetPreferredSize()); |
| 694 content_height = std::max(content_height, close_button_size.height()); | 692 content_height = std::max(content_height, close_button_size.height()); |
| 695 | 693 |
| 696 // Size the Favicon. | 694 // Size the Favicon. |
| 697 showing_icon_ = ShouldShowIcon(); | 695 showing_icon_ = ShouldShowIcon(); |
| 698 if (showing_icon_) { | 696 if (showing_icon_) { |
| 699 // Use the size of the favicon as apps use a bigger favicon size. | 697 // Use the size of the favicon as apps use a bigger favicon size. |
| 700 int favicon_top = kTopPadding + content_height / 2 - kTabIconSize / 2; | 698 int favicon_top = kTopPadding + content_height / 2 - kTabIconSize / 2; |
| (...skipping 762 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1463 SchedulePaintInRect(GetImmersiveBarRect()); | 1461 SchedulePaintInRect(GetImmersiveBarRect()); |
| 1464 else | 1462 else |
| 1465 ScheduleIconPaint(); | 1463 ScheduleIconPaint(); |
| 1466 } | 1464 } |
| 1467 | 1465 |
| 1468 int Tab::IconCapacity() const { | 1466 int Tab::IconCapacity() const { |
| 1469 if (height() < GetMinimumUnselectedSize().height()) | 1467 if (height() < GetMinimumUnselectedSize().height()) |
| 1470 return 0; | 1468 return 0; |
| 1471 const int available_width = | 1469 const int available_width = |
| 1472 std::max(0, width() - kLeftPadding - kRightPadding); | 1470 std::max(0, width() - kLeftPadding - kRightPadding); |
| 1473 const int width_per_icon = kTabIconSize; | 1471 const int width_per_icon = gfx::kFaviconSize; |
| 1474 const int kPaddingBetweenIcons = 2; | 1472 const int kPaddingBetweenIcons = 2; |
| 1475 if (available_width >= width_per_icon && | 1473 if (available_width >= width_per_icon && |
| 1476 available_width < (width_per_icon + kPaddingBetweenIcons)) { | 1474 available_width < (width_per_icon + kPaddingBetweenIcons)) { |
| 1477 return 1; | 1475 return 1; |
| 1478 } | 1476 } |
| 1479 return available_width / (width_per_icon + kPaddingBetweenIcons); | 1477 return available_width / (width_per_icon + kPaddingBetweenIcons); |
| 1480 } | 1478 } |
| 1481 | 1479 |
| 1482 bool Tab::ShouldShowIcon() const { | 1480 bool Tab::ShouldShowIcon() const { |
| 1483 return chrome::ShouldTabShowFavicon( | 1481 return chrome::ShouldTabShowFavicon( |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1649 const gfx::ImageSkia& image) { | 1647 const gfx::ImageSkia& image) { |
| 1650 DCHECK_NE(scale_factor, ui::SCALE_FACTOR_NONE); | 1648 DCHECK_NE(scale_factor, ui::SCALE_FACTOR_NONE); |
| 1651 ImageCacheEntry entry; | 1649 ImageCacheEntry entry; |
| 1652 entry.resource_id = resource_id; | 1650 entry.resource_id = resource_id; |
| 1653 entry.scale_factor = scale_factor; | 1651 entry.scale_factor = scale_factor; |
| 1654 entry.image = image; | 1652 entry.image = image; |
| 1655 image_cache_->push_front(entry); | 1653 image_cache_->push_front(entry); |
| 1656 if (image_cache_->size() > kMaxImageCacheSize) | 1654 if (image_cache_->size() > kMaxImageCacheSize) |
| 1657 image_cache_->pop_back(); | 1655 image_cache_->pop_back(); |
| 1658 } | 1656 } |
| OLD | NEW |