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

Unified Diff: chrome/browser/ui/views/location_bar/selected_keyword_view.cc

Issue 2731113002: Adjust elision of omnibox keyword search label. (Closed)
Patch Set: . Created 3 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/views/location_bar/selected_keyword_view.cc
diff --git a/chrome/browser/ui/views/location_bar/selected_keyword_view.cc b/chrome/browser/ui/views/location_bar/selected_keyword_view.cc
index 53c7ccadc2bcf319ebc710c1494847990cb843a3..1507587942634b6c1e38a990ae2f2f38c6cfd091 100644
--- a/chrome/browser/ui/views/location_bar/selected_keyword_view.cc
+++ b/chrome/browser/ui/views/location_bar/selected_keyword_view.cc
@@ -23,6 +23,7 @@
SelectedKeywordView::SelectedKeywordView(const gfx::FontList& font_list,
Profile* profile)
: IconLabelBubbleView(font_list, false), profile_(profile) {
+ set_can_process_events_within_subtree(false);
Peter Kasting 2017/03/07 02:28:45 Don't do this (it looks like an artifact of the "p
full_label_.SetFontList(font_list);
full_label_.SetVisible(false);
partial_label_.SetFontList(font_list);
@@ -49,14 +50,17 @@ gfx::Size SelectedKeywordView::GetPreferredSize() const {
return GetSizeForLabelWidth(full_label_.GetPreferredSize().width());
}
-gfx::Size SelectedKeywordView::GetMinimumSize() const {
Evan Stade 2017/03/07 18:04:44 I mis-spoke before, this actually is necessary and
- // Height will be ignored by the LocationBarView.
- return GetSizeForLabelWidth(partial_label_.GetMinimumSize().width());
-}
-
void SelectedKeywordView::Layout() {
- SetLabel(((width() == GetPreferredSize().width()) ?
- full_label_ : partial_label_).text());
+ // Keep showing the full label as long as there's more than enough width for
+ // the partial label. Otherwise there will be empty space displayed next to
+ // the partial label.
+ if (width() >
+ GetSizeForLabelWidth(partial_label_.GetPreferredSize().width()).width()) {
+ SetLabel(full_label_.text());
+ } else {
+ SetLabel(partial_label_.text());
+ }
Peter Kasting 2017/03/07 02:28:45 Nit: Shorter: const int partial_label_width = p
+
IconLabelBubbleView::Layout();
}
@@ -79,14 +83,7 @@ void SelectedKeywordView::SetKeyword(const base::string16& keyword) {
: l10n_util::GetStringFUTF16(IDS_OMNIBOX_KEYWORD_TEXT_MD, short_name);
full_label_.SetText(full_name);
- const base::string16 min_string(
- location_bar_util::CalculateMinString(short_name));
- const base::string16 partial_name =
- is_extension_keyword
- ? min_string
- : l10n_util::GetStringFUTF16(IDS_OMNIBOX_KEYWORD_TEXT_MD, min_string);
- partial_label_.SetText(min_string.empty() ?
- full_label_.text() : partial_name);
+ partial_label_.SetText(location_bar_util::CalculateMinString(short_name));
Peter Kasting 2017/03/07 02:28:45 This lost the protection the old code had against
Evan Stade 2017/03/07 18:04:44 hmmm, this is even better if I just remove Calcula
Peter Kasting 2017/03/08 03:13:12 Set the "minimum size" to the required width for s
// Update the label now so ShouldShowLabel() works correctly when the parent
// class is calculating the preferred size. It will be updated again in

Powered by Google App Engine
This is Rietveld 408576698