| 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 761 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 772 void Tab::Layout() { | 772 void Tab::Layout() { |
| 773 gfx::Rect lb = GetContentsBounds(); | 773 gfx::Rect lb = GetContentsBounds(); |
| 774 if (lb.IsEmpty()) | 774 if (lb.IsEmpty()) |
| 775 return; | 775 return; |
| 776 lb.Inset( | 776 lb.Inset( |
| 777 left_padding(), top_padding(), right_padding(), bottom_padding()); | 777 left_padding(), top_padding(), right_padding(), bottom_padding()); |
| 778 | 778 |
| 779 // The height of the content of the Tab is the largest of the favicon, | 779 // The height of the content of the Tab is the largest of the favicon, |
| 780 // the title text and the close button graphic. | 780 // the title text and the close button graphic. |
| 781 int content_height = std::max(tab_icon_size(), font_height_); | 781 int content_height = std::max(tab_icon_size(), font_height_); |
| 782 close_button_->set_border(NULL); | 782 close_button_->ClearBorder(); |
| 783 gfx::Size close_button_size(close_button_->GetPreferredSize()); | 783 gfx::Size close_button_size(close_button_->GetPreferredSize()); |
| 784 content_height = std::max(content_height, close_button_size.height()); | 784 content_height = std::max(content_height, close_button_size.height()); |
| 785 | 785 |
| 786 // Size the Favicon. | 786 // Size the Favicon. |
| 787 showing_icon_ = ShouldShowIcon(); | 787 showing_icon_ = ShouldShowIcon(); |
| 788 if (showing_icon_) { | 788 if (showing_icon_) { |
| 789 // Use the size of the favicon as apps use a bigger favicon size. | 789 // Use the size of the favicon as apps use a bigger favicon size. |
| 790 int favicon_top = top_padding() + content_height / 2 - tab_icon_size() / 2; | 790 int favicon_top = top_padding() + content_height / 2 - tab_icon_size() / 2; |
| 791 int favicon_left = lb.x(); | 791 int favicon_left = lb.x(); |
| 792 favicon_bounds_.SetRect(favicon_left, favicon_top, | 792 favicon_bounds_.SetRect(favicon_left, favicon_top, |
| (...skipping 18 matching lines...) Expand all Loading... |
| 811 // edges of the tab. However, the larger hit-target should be active only | 811 // edges of the tab. However, the larger hit-target should be active only |
| 812 // for mouse events, and the close-image should show up in the right place. | 812 // for mouse events, and the close-image should show up in the right place. |
| 813 // So a border is added to the button with necessary padding. The close | 813 // So a border is added to the button with necessary padding. The close |
| 814 // button (BaseTab::TabCloseButton) makes sure the padding is a hit-target | 814 // button (BaseTab::TabCloseButton) makes sure the padding is a hit-target |
| 815 // only for touch events. | 815 // only for touch events. |
| 816 int top_border = close_button_top; | 816 int top_border = close_button_top; |
| 817 int bottom_border = height() - (close_button_size.height() + top_border); | 817 int bottom_border = height() - (close_button_size.height() + top_border); |
| 818 int left_border = kCloseButtonHorzFuzz; | 818 int left_border = kCloseButtonHorzFuzz; |
| 819 int right_border = width() - (lb.width() + close_button_size.width() + | 819 int right_border = width() - (lb.width() + close_button_size.width() + |
| 820 left_border); | 820 left_border); |
| 821 close_button_->set_border(views::Border::CreateEmptyBorder(top_border, | 821 close_button_->SetBorder(views::Border::CreateEmptyBorder(top_border, |
| 822 left_border, bottom_border, right_border)); | 822 left_border, bottom_border, right_border)); |
| 823 close_button_->SetPosition(gfx::Point(lb.width(), 0)); | 823 close_button_->SetPosition(gfx::Point(lb.width(), 0)); |
| 824 close_button_->SizeToPreferredSize(); | 824 close_button_->SizeToPreferredSize(); |
| 825 close_button_->SetVisible(true); | 825 close_button_->SetVisible(true); |
| 826 } else { | 826 } else { |
| 827 close_button_->SetBounds(0, 0, 0, 0); | 827 close_button_->SetBounds(0, 0, 0, 0); |
| 828 close_button_->SetVisible(false); | 828 close_button_->SetVisible(false); |
| 829 } | 829 } |
| 830 | 830 |
| 831 showing_media_indicator_ = ShouldShowMediaIndicator(); | 831 showing_media_indicator_ = ShouldShowMediaIndicator(); |
| (...skipping 932 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1764 const gfx::ImageSkia& image) { | 1764 const gfx::ImageSkia& image) { |
| 1765 DCHECK_NE(scale_factor, ui::SCALE_FACTOR_NONE); | 1765 DCHECK_NE(scale_factor, ui::SCALE_FACTOR_NONE); |
| 1766 ImageCacheEntry entry; | 1766 ImageCacheEntry entry; |
| 1767 entry.resource_id = resource_id; | 1767 entry.resource_id = resource_id; |
| 1768 entry.scale_factor = scale_factor; | 1768 entry.scale_factor = scale_factor; |
| 1769 entry.image = image; | 1769 entry.image = image; |
| 1770 image_cache_->push_front(entry); | 1770 image_cache_->push_front(entry); |
| 1771 if (image_cache_->size() > kMaxImageCacheSize) | 1771 if (image_cache_->size() > kMaxImageCacheSize) |
| 1772 image_cache_->pop_back(); | 1772 image_cache_->pop_back(); |
| 1773 } | 1773 } |
| OLD | NEW |