summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-20 18:28:00 +0000
committerpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-20 18:28:00 +0000
commit68da8f78cd06ba70144c9e3fb2e1bae724208e6a (patch)
tree695907a99af87ad2c9ff646893e11588a447e41d /chrome
parent6658ca866d0e28950179a65179c1a4d6e8e3f8df (diff)
downloadchromium_src-68da8f78cd06ba70144c9e3fb2e1bae724208e6a.zip
chromium_src-68da8f78cd06ba70144c9e3fb2e1bae724208e6a.tar.gz
chromium_src-68da8f78cd06ba70144c9e3fb2e1bae724208e6a.tar.bz2
Elide the EV bubble when it's extremely long. This limits it to half the location bar width, unless eliding to that would result in a width of less than 150 px.
BUG=42856 TEST=Visit https://www.barbican.org.uk/eticketing/index.asp and make the window smaller. The EV bubble should shrink, eliding in middle, until it hits a minimum size. Review URL: http://codereview.chromium.org/2084012 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@47819 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/autocomplete/autocomplete_popup_view_mac.mm2
-rw-r--r--chrome/browser/autocomplete/autocomplete_popup_view_mac_unittest.mm6
-rw-r--r--chrome/browser/cocoa/bookmark_menu_cocoa_controller.mm5
-rw-r--r--chrome/browser/cocoa/download_item_cell.mm5
-rw-r--r--chrome/browser/views/autocomplete/autocomplete_popup_contents_view.cc2
-rw-r--r--chrome/browser/views/bookmark_bar_view.cc7
-rw-r--r--chrome/browser/views/location_bar/ev_bubble_view.cc1
-rw-r--r--chrome/browser/views/location_bar/icon_label_bubble_view.cc17
-rw-r--r--chrome/browser/views/location_bar/icon_label_bubble_view.h3
-rw-r--r--chrome/browser/views/location_bar/location_bar_view.cc9
10 files changed, 39 insertions, 18 deletions
diff --git a/chrome/browser/autocomplete/autocomplete_popup_view_mac.mm b/chrome/browser/autocomplete/autocomplete_popup_view_mac.mm
index fd2b20e..c0e4f93 100644
--- a/chrome/browser/autocomplete/autocomplete_popup_view_mac.mm
+++ b/chrome/browser/autocomplete/autocomplete_popup_view_mac.mm
@@ -145,7 +145,7 @@ NSMutableAttributedString* AutocompletePopupViewMac::ElideString(
}
// If ElideText() decides to do nothing, nothing to be done.
- const std::wstring elided(ElideText(originalString, font, width));
+ const std::wstring elided(ElideText(originalString, font, width, false));
if (0 == elided.compare(originalString)) {
return aString;
}
diff --git a/chrome/browser/autocomplete/autocomplete_popup_view_mac_unittest.mm b/chrome/browser/autocomplete/autocomplete_popup_view_mac_unittest.mm
index aff63db..56856dd 100644
--- a/chrome/browser/autocomplete/autocomplete_popup_view_mac_unittest.mm
+++ b/chrome/browser/autocomplete/autocomplete_popup_view_mac_unittest.mm
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -441,14 +441,14 @@ TEST_F(AutocompletePopupViewMacTest, ElideString) {
// When elided, result is the same as ElideText().
ret = AutocompletePopupViewMac::ElideString(as, wideContents, font_, kNarrow);
- std::wstring elided(ElideText(wideContents, font_, kNarrow));
+ std::wstring elided(ElideText(wideContents, font_, kNarrow, false));
EXPECT_TRUE(ret == as);
EXPECT_FALSE([[as string] isEqualToString:contents]);
EXPECT_TRUE([[as string] isEqualToString:base::SysWideToNSString(elided)]);
// When elided, result is the same as ElideText().
ret = AutocompletePopupViewMac::ElideString(as, wideContents, font_, 0.0);
- elided = ElideText(wideContents, font_, 0.0);
+ elided = ElideText(wideContents, font_, 0.0, false);
EXPECT_TRUE(ret == as);
EXPECT_FALSE([[as string] isEqualToString:contents]);
EXPECT_TRUE([[as string] isEqualToString:base::SysWideToNSString(elided)]);
diff --git a/chrome/browser/cocoa/bookmark_menu_cocoa_controller.mm b/chrome/browser/cocoa/bookmark_menu_cocoa_controller.mm
index 26eced6..dc5b6e2 100644
--- a/chrome/browser/cocoa/bookmark_menu_cocoa_controller.mm
+++ b/chrome/browser/cocoa/bookmark_menu_cocoa_controller.mm
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -31,7 +31,8 @@ const NSUInteger kMaximumMenuPixelsWide = 300;
(int)[nsfont pointSize]);
std::wstring title = gfx::ElideText(node->GetTitle(),
font,
- kMaximumMenuPixelsWide);
+ kMaximumMenuPixelsWide,
+ false);
return base::SysWideToNSString(title);
}
diff --git a/chrome/browser/cocoa/download_item_cell.mm b/chrome/browser/cocoa/download_item_cell.mm
index dd661c7..cabde16 100644
--- a/chrome/browser/cocoa/download_item_cell.mm
+++ b/chrome/browser/cocoa/download_item_cell.mm
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -402,7 +402,8 @@ NSGradient* BackgroundTheme::GetNSGradient(int id) const {
return base::SysWideToNSString(ElideText(
base::SysNSStringToWide([self secondaryTitle]),
font_chr,
- availableWidth));
+ availableWidth,
+ false));
}
- (ThemeProvider*)backgroundThemeWrappingProvider:(ThemeProvider*)provider {
diff --git a/chrome/browser/views/autocomplete/autocomplete_popup_contents_view.cc b/chrome/browser/views/autocomplete/autocomplete_popup_contents_view.cc
index 8fc11b4..6560daf 100644
--- a/chrome/browser/views/autocomplete/autocomplete_popup_contents_view.cc
+++ b/chrome/browser/views/autocomplete/autocomplete_popup_contents_view.cc
@@ -530,7 +530,7 @@ void AutocompleteResultView::Elide(Runs* runs, int remaining_width) const {
// Can we fit at least an ellipsis?
std::wstring elided_text(
- gfx::ElideText(j->text, *j->font, remaining_width));
+ gfx::ElideText(j->text, *j->font, remaining_width, false));
Classifications::reverse_iterator prior_classification(j);
++prior_classification;
const bool on_first_classification =
diff --git a/chrome/browser/views/bookmark_bar_view.cc b/chrome/browser/views/bookmark_bar_view.cc
index 0aeb940..8dd76b1 100644
--- a/chrome/browser/views/bookmark_bar_view.cc
+++ b/chrome/browser/views/bookmark_bar_view.cc
@@ -143,10 +143,9 @@ static std::wstring CreateToolTipForURLAndTitle(const gfx::Point& screen_loc,
// First the title.
if (!title.empty()) {
std::wstring localized_title;
- if (base::i18n::AdjustStringForLocaleDirection(title, &localized_title))
- result.append(gfx::ElideText(localized_title, tt_font, max_width));
- else
- result.append(gfx::ElideText(title, tt_font, max_width));
+ result.append(gfx::ElideText(
+ base::i18n::AdjustStringForLocaleDirection(title, &localized_title) ?
+ localized_title : title, tt_font, max_width, false));
}
// Only show the URL if the url and title differ.
diff --git a/chrome/browser/views/location_bar/ev_bubble_view.cc b/chrome/browser/views/location_bar/ev_bubble_view.cc
index 882bfd0..215ad51 100644
--- a/chrome/browser/views/location_bar/ev_bubble_view.cc
+++ b/chrome/browser/views/location_bar/ev_bubble_view.cc
@@ -10,6 +10,7 @@ EVBubbleView::EVBubbleView(const int background_images[],
const LocationBarView* location_bar)
: IconLabelBubbleView(background_images, contained_image, color),
ALLOW_THIS_IN_INITIALIZER_LIST(click_handler_(this, location_bar)) {
+ SetElideInMiddle(true);
}
EVBubbleView::~EVBubbleView() {
diff --git a/chrome/browser/views/location_bar/icon_label_bubble_view.cc b/chrome/browser/views/location_bar/icon_label_bubble_view.cc
index c40acff..729c9a1 100644
--- a/chrome/browser/views/location_bar/icon_label_bubble_view.cc
+++ b/chrome/browser/views/location_bar/icon_label_bubble_view.cc
@@ -59,14 +59,21 @@ gfx::Size IconLabelBubbleView::GetPreferredSize() {
void IconLabelBubbleView::Layout() {
image_->SetBounds(kImageOffset, 0, image_->GetPreferredSize().width(),
height());
- gfx::Size label_size(label_->GetPreferredSize());
+ const int label_height = label_->GetPreferredSize().height();
label_->SetBounds(image_->x() + image_->width() + kLabelOffset,
- (height() - label_size.height()) / 2, label_size.width(),
- label_size.height());
+ (height() - label_height) / 2, width() - GetNonLabelWidth(),
+ label_height);
+}
+
+void IconLabelBubbleView::SetElideInMiddle(bool elide_in_middle) {
+ label_->SetElideInMiddle(elide_in_middle);
}
gfx::Size IconLabelBubbleView::GetNonLabelSize() {
- return gfx::Size(kImageOffset + image_->GetPreferredSize().width() +
- kLabelOffset + kLabelPadding, background_painter_.height());
+ return gfx::Size(GetNonLabelWidth(), background_painter_.height());
}
+int IconLabelBubbleView::GetNonLabelWidth() {
+ return kImageOffset + image_->GetPreferredSize().width() + kLabelOffset +
+ kLabelPadding;
+}
diff --git a/chrome/browser/views/location_bar/icon_label_bubble_view.h b/chrome/browser/views/location_bar/icon_label_bubble_view.h
index b8b9485..53b0b33 100644
--- a/chrome/browser/views/location_bar/icon_label_bubble_view.h
+++ b/chrome/browser/views/location_bar/icon_label_bubble_view.h
@@ -38,9 +38,12 @@ class IconLabelBubbleView : public views::View {
virtual void Layout();
protected:
+ void SetElideInMiddle(bool elide_in_middle);
gfx::Size GetNonLabelSize();
private:
+ int GetNonLabelWidth();
+
// For painting the background.
views::HorizontalPainter background_painter_;
diff --git a/chrome/browser/views/location_bar/location_bar_view.cc b/chrome/browser/views/location_bar/location_bar_view.cc
index 7f9cde9..10e561d 100644
--- a/chrome/browser/views/location_bar/location_bar_view.cc
+++ b/chrome/browser/views/location_bar/location_bar_view.cc
@@ -377,6 +377,15 @@ void LocationBarView::Layout() {
ev_bubble_view_->SetVisible(true);
ev_bubble_view_->SetLabel(model_->GetEVCertName());
ev_bubble_width = ev_bubble_view_->GetPreferredSize().width();
+
+ // Try to elide the bubble to be no larger than half the total available
+ // space, but never elide it any smaller than 150 px.
+ static const int kMinElidedBubbleWidth = 150;
+ static const double kMaxBubbleFraction = 0.5;
+ ev_bubble_width = std::min(ev_bubble_width, std::max(kMinElidedBubbleWidth,
+ static_cast<int>((entry_width - kBubblePadding - kViewPadding) *
+ kMaxBubbleFraction)));
+
entry_width -= kBubblePadding + ev_bubble_width + kViewPadding;
} else {
location_icon_view_->SetVisible(true);