Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(806)

Side by Side Diff: chrome/browser/ui/views/tabs/tab.cc

Issue 120163005: Make tab tooltip behavior consistent across all desktop platforms. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/cocoa/tabs/tab_strip_controller.mm ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 909 matching lines...) Expand 10 before | Expand all | Expand 10 after
920 if (clip.size().GetArea()) { 920 if (clip.size().GetArea()) {
921 SkRect intersection(path->getBounds()); 921 SkRect intersection(path->getBounds());
922 intersection.intersect(RectToSkRect(clip)); 922 intersection.intersect(RectToSkRect(clip));
923 path->reset(); 923 path->reset();
924 path->addRect(intersection); 924 path->addRect(intersection);
925 } 925 }
926 } 926 }
927 } 927 }
928 928
929 bool Tab::GetTooltipText(const gfx::Point& p, base::string16* tooltip) const { 929 bool Tab::GetTooltipText(const gfx::Point& p, base::string16* tooltip) const {
930 // TODO(miu): Rectify inconsistent tooltip behavior. http://crbug.com/310947 930 // Note: Anything that affects the tooltip text should be accounted for when
931 931 // calling TooltipTextChanged() from Tab::DataChanged().
932 if (data_.media_state != TAB_MEDIA_STATE_NONE) { 932 *tooltip = chrome::AssembleTabTooltipText(data_.title, data_.media_state);
933 *tooltip = chrome::AssembleTabTooltipText(data_.title, data_.media_state); 933 return !tooltip->empty();
934 return true;
935 }
936
937 if (data_.title.empty())
938 return false;
939
940 // Only show the tooltip if the title is truncated.
941 if (font_->GetStringWidth(data_.title) > GetTitleBounds().width()) {
942 *tooltip = data_.title;
943 return true;
944 }
945 return false;
946 } 934 }
947 935
948 bool Tab::GetTooltipTextOrigin(const gfx::Point& p, gfx::Point* origin) const { 936 bool Tab::GetTooltipTextOrigin(const gfx::Point& p, gfx::Point* origin) const {
949 origin->set_x(title_bounds_.x() + 10); 937 origin->set_x(title_bounds_.x() + 10);
950 origin->set_y(-views::TooltipManager::GetTooltipHeight() - 4); 938 origin->set_y(-views::TooltipManager::GetTooltipHeight() - 4);
951 return true; 939 return true;
952 } 940 }
953 941
954 ui::ThemeProvider* Tab::GetThemeProvider() const { 942 ui::ThemeProvider* Tab::GetThemeProvider() const {
955 ui::ThemeProvider* tp = View::GetThemeProvider(); 943 ui::ThemeProvider* tp = View::GetThemeProvider();
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
1121 return; 1109 return;
1122 const int mini_delta = kMiniTabRendererAsNormalTabWidth - GetMiniWidth(); 1110 const int mini_delta = kMiniTabRendererAsNormalTabWidth - GetMiniWidth();
1123 const int ideal_delta = width() - GetMiniWidth(); 1111 const int ideal_delta = width() - GetMiniWidth();
1124 const int ideal_x = (GetMiniWidth() - bounds->width()) / 2; 1112 const int ideal_x = (GetMiniWidth() - bounds->width()) / 2;
1125 bounds->set_x(bounds->x() + static_cast<int>( 1113 bounds->set_x(bounds->x() + static_cast<int>(
1126 (1 - static_cast<float>(ideal_delta) / static_cast<float>(mini_delta)) * 1114 (1 - static_cast<float>(ideal_delta) / static_cast<float>(mini_delta)) *
1127 (ideal_x - bounds->x()))); 1115 (ideal_x - bounds->x())));
1128 } 1116 }
1129 1117
1130 void Tab::DataChanged(const TabRendererData& old) { 1118 void Tab::DataChanged(const TabRendererData& old) {
1119 if (data().media_state != old.media_state || data().title != old.title)
1120 TooltipTextChanged();
1121
1131 if (data().blocked == old.blocked) 1122 if (data().blocked == old.blocked)
1132 return; 1123 return;
1133 1124
1134 if (data().blocked) 1125 if (data().blocked)
1135 StartPulse(); 1126 StartPulse();
1136 else 1127 else
1137 StopPulse(); 1128 StopPulse();
1138 } 1129 }
1139 1130
1140 void Tab::PaintTab(gfx::Canvas* canvas) { 1131 void Tab::PaintTab(gfx::Canvas* canvas) {
(...skipping 632 matching lines...) Expand 10 before | Expand all | Expand 10 after
1773 const gfx::ImageSkia& image) { 1764 const gfx::ImageSkia& image) {
1774 DCHECK_NE(scale_factor, ui::SCALE_FACTOR_NONE); 1765 DCHECK_NE(scale_factor, ui::SCALE_FACTOR_NONE);
1775 ImageCacheEntry entry; 1766 ImageCacheEntry entry;
1776 entry.resource_id = resource_id; 1767 entry.resource_id = resource_id;
1777 entry.scale_factor = scale_factor; 1768 entry.scale_factor = scale_factor;
1778 entry.image = image; 1769 entry.image = image;
1779 image_cache_->push_front(entry); 1770 image_cache_->push_front(entry);
1780 if (image_cache_->size() > kMaxImageCacheSize) 1771 if (image_cache_->size() > kMaxImageCacheSize)
1781 image_cache_->pop_back(); 1772 image_cache_->pop_back();
1782 } 1773 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/tabs/tab_strip_controller.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698