Chromium Code Reviews| Index: chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc |
| diff --git a/chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc b/chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc |
| index ec0a26ef567b0f0cc84466e80de9c5f478619ddc..00d6af6b1d9707229d6cae8fdcc187fd21520f75 100644 |
| --- a/chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc |
| +++ b/chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc |
| @@ -260,18 +260,33 @@ class BookmarkButton : public BookmarkButtonBase { |
| const base::string16& title) |
| : BookmarkButtonBase(listener, title), url_(url) {} |
| + // views::View: |
| bool GetTooltipText(const gfx::Point& p, |
| base::string16* tooltip) const override { |
| + const views::TooltipManager* tooltip_manager = |
| + GetWidget()->GetTooltipManager(); |
| gfx::Point location(p); |
| ConvertPointToScreen(this, &location); |
| - *tooltip = BookmarkBarView::CreateToolTipForURLAndTitle( |
| - GetWidget(), location, url_, GetText()); |
| + int max_width = tooltip_manager->GetMaxWidth(location); |
|
sky
2016/11/17 01:08:28
Please add a comment as to why this is being done.
oshima
2016/11/17 14:02:32
Done.
|
| + if (!tooltip_.size() || max_width != max_width_) { |
|
sky
2016/11/17 01:08:28
!size() -> empty()
oshima
2016/11/17 14:02:33
Done.
|
| + max_width_ = max_width; |
| + tooltip_ = BookmarkBarView::CreateToolTipForURLAndTitle( |
| + max_width_, tooltip_manager->GetFontList(), url_, GetText()); |
| + } |
| + *tooltip = tooltip_; |
| return !tooltip->empty(); |
| } |
| + void SetText(const base::string16& text) override { |
| + BookmarkButtonBase::SetText(text); |
| + tooltip_.empty(); |
| + } |
| + |
| const char* GetClassName() const override { return kViewClassName; } |
| private: |
| + mutable int max_width_ = 0; |
|
sky
2016/11/17 01:08:28
max_width_ by itself isn't clear, especially with
oshima
2016/11/17 14:02:33
Done.
|
| + mutable base::string16 tooltip_; |
| const GURL& url_; |
| DISALLOW_COPY_AND_ASSIGN(BookmarkButton); |
| @@ -714,13 +729,10 @@ void BookmarkBarView::StopThrobbing(bool immediate) { |
| // static |
| base::string16 BookmarkBarView::CreateToolTipForURLAndTitle( |
| - const views::Widget* widget, |
| - const gfx::Point& screen_loc, |
| + int max_width, |
| + const gfx::FontList& tt_fonts, |
| const GURL& url, |
| const base::string16& title) { |
| - const views::TooltipManager* tooltip_manager = widget->GetTooltipManager(); |
| - int max_width = tooltip_manager->GetMaxWidth(screen_loc); |
| - const gfx::FontList tt_fonts = tooltip_manager->GetFontList(); |
| base::string16 result; |
| // First the title. |