| Index: chrome/browser/ui/views/location_bar/keyword_hint_view.cc
|
| diff --git a/chrome/browser/ui/views/location_bar/keyword_hint_view.cc b/chrome/browser/ui/views/location_bar/keyword_hint_view.cc
|
| index 2c0db47e9c027d48e0686b733789a504bca20eb5..1e6ef680a772cad36908767d93fcb1e139226ada 100644
|
| --- a/chrome/browser/ui/views/location_bar/keyword_hint_view.cc
|
| +++ b/chrome/browser/ui/views/location_bar/keyword_hint_view.cc
|
| @@ -20,6 +20,7 @@
|
| #include "ui/strings/grit/ui_strings.h"
|
| #include "ui/views/border.h"
|
| #include "ui/views/controls/label.h"
|
| +#include "ui/views/layout/fill_layout.h"
|
|
|
| #if defined(USE_AURA)
|
| #include "ui/keyboard/keyboard_util.h"
|
| @@ -27,19 +28,6 @@
|
|
|
| namespace {
|
|
|
| -// This view looks somewhat like a keyboard key.
|
| -class KeyboardKeyView : public views::Label {
|
| - public:
|
| - explicit KeyboardKeyView(const gfx::FontList& font_list);
|
| - ~KeyboardKeyView() override;
|
| -
|
| - private:
|
| - // views::Label:
|
| - gfx::Size GetPreferredSize() const override;
|
| -
|
| - DISALLOW_COPY_AND_ASSIGN(KeyboardKeyView);
|
| -};
|
| -
|
| bool IsVirtualKeyboardVisible() {
|
| #if defined(USE_AURA)
|
| return keyboard::IsKeyboardVisible();
|
| @@ -48,48 +36,42 @@ bool IsVirtualKeyboardVisible() {
|
| #endif
|
| }
|
|
|
| -KeyboardKeyView::KeyboardKeyView(const gfx::FontList& font_list)
|
| - : views::Label(base::string16(), {font_list}) {
|
| - SetBorder(views::CreateEmptyBorder(
|
| - gfx::Insets(LocationBarView::kBubbleVerticalPadding, 0)));
|
| -}
|
| -
|
| -KeyboardKeyView::~KeyboardKeyView() {}
|
| -
|
| -gfx::Size KeyboardKeyView::GetPreferredSize() const {
|
| - gfx::Size size = views::Label::GetPreferredSize();
|
| - constexpr int kPaddingInsideBorder = 5;
|
| - // Even though the border is 1 px thick visibly, it takes 1 DIP logically.
|
| - size.Enlarge(2 * (kPaddingInsideBorder + 1), 0);
|
| - return size;
|
| -}
|
| -
|
| } // namespace
|
|
|
| KeywordHintView::KeywordHintView(views::ButtonListener* listener,
|
| Profile* profile,
|
| const gfx::FontList& font_list,
|
| const gfx::FontList& bubble_font_list,
|
| - int chip_height,
|
| SkColor text_color,
|
| SkColor background_color)
|
| : CustomButton(listener),
|
| profile_(profile),
|
| leading_label_(nullptr),
|
| - chip_view_(new KeyboardKeyView(bubble_font_list)),
|
| - trailing_label_(nullptr),
|
| - chip_view_height_(chip_height) {
|
| + chip_container_(new views::View()),
|
| + chip_label_(new views::Label(base::string16(), {bubble_font_list})),
|
| + trailing_label_(nullptr) {
|
| leading_label_ =
|
| CreateLabel(font_list, text_color, background_color);
|
| - chip_view_->SetEnabledColor(text_color);
|
| +
|
| + constexpr int kPaddingInsideBorder = 5;
|
| + // Even though the border is 1 px thick visibly, it takes 1 DIP logically.
|
| + chip_label_->SetBorder(
|
| + views::CreateEmptyBorder(gfx::Insets(0, kPaddingInsideBorder + 1)));
|
| + chip_label_->SetEnabledColor(text_color);
|
| bool inverted = color_utils::IsDark(background_color);
|
| SkColor tab_bg_color =
|
| inverted ? SK_ColorWHITE : SkColorSetA(text_color, 0x13);
|
| SkColor tab_border_color = inverted ? SK_ColorWHITE : text_color;
|
| - chip_view_->SetBackgroundColor(tab_bg_color);
|
| - chip_view_->set_background(
|
| + chip_label_->SetBackgroundColor(tab_bg_color);
|
| +
|
| + chip_container_->SetBorder(views::CreateEmptyBorder(
|
| + gfx::Insets(LocationBarView::kBubbleVerticalPadding, 0)));
|
| + chip_container_->set_background(
|
| new BackgroundWith1PxBorder(tab_bg_color, tab_border_color));
|
| - AddChildView(chip_view_);
|
| + chip_container_->AddChildView(chip_label_);
|
| + chip_container_->SetLayoutManager(new views::FillLayout());
|
| + AddChildView(chip_container_);
|
| +
|
| trailing_label_ =
|
| CreateLabel(font_list, text_color, background_color);
|
| }
|
| @@ -114,12 +96,12 @@ void KeywordHintView::SetKeyword(const base::string16& keyword) {
|
| int message_id = is_extension_keyword
|
| ? IDS_OMNIBOX_EXTENSION_KEYWORD_HINT_TOUCH
|
| : IDS_OMNIBOX_KEYWORD_HINT_TOUCH;
|
| - chip_view_->SetText(l10n_util::GetStringFUTF16(message_id, short_name));
|
| + chip_label_->SetText(l10n_util::GetStringFUTF16(message_id, short_name));
|
|
|
| leading_label_->SetText(base::string16());
|
| trailing_label_->SetText(base::string16());
|
| } else {
|
| - chip_view_->SetText(l10n_util::GetStringUTF16(IDS_APP_TAB_KEY));
|
| + chip_label_->SetText(l10n_util::GetStringUTF16(IDS_APP_TAB_KEY));
|
|
|
| std::vector<size_t> content_param_offsets;
|
| int message_id = is_extension_keyword ? IDS_OMNIBOX_EXTENSION_KEYWORD_HINT
|
| @@ -137,7 +119,7 @@ void KeywordHintView::SetKeyword(const base::string16& keyword) {
|
| gfx::Size KeywordHintView::GetPreferredSize() const {
|
| // Height will be ignored by the LocationBarView.
|
| return gfx::Size(leading_label_->GetPreferredSize().width() +
|
| - chip_view_->GetPreferredSize().width() +
|
| + chip_container_->GetPreferredSize().width() +
|
| trailing_label_->GetPreferredSize().width() +
|
| LocationBarView::kIconInteriorPadding,
|
| 0);
|
| @@ -145,20 +127,19 @@ gfx::Size KeywordHintView::GetPreferredSize() const {
|
|
|
| gfx::Size KeywordHintView::GetMinimumSize() const {
|
| // Height will be ignored by the LocationBarView.
|
| - return chip_view_->GetPreferredSize();
|
| + return chip_container_->GetPreferredSize();
|
| }
|
|
|
| void KeywordHintView::Layout() {
|
| - int chip_width = chip_view_->GetPreferredSize().width();
|
| + int chip_width = chip_container_->GetPreferredSize().width();
|
| bool show_labels = (width() != chip_width);
|
| gfx::Size leading_size(leading_label_->GetPreferredSize());
|
| leading_label_->SetBounds(0, 0, show_labels ? leading_size.width() : 0,
|
| height());
|
| - chip_view_->SetBounds(leading_label_->bounds().right(),
|
| - (height() - chip_view_height_) / 2, chip_width,
|
| - chip_view_height_);
|
| + chip_container_->SetBounds(leading_label_->bounds().right(), 0, chip_width,
|
| + height());
|
| gfx::Size trailing_size(trailing_label_->GetPreferredSize());
|
| - trailing_label_->SetBounds(chip_view_->bounds().right(), 0,
|
| + trailing_label_->SetBounds(chip_container_->bounds().right(), 0,
|
| show_labels ? trailing_size.width() : 0, height());
|
| }
|
|
|
|
|