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