Chromium Code Reviews| Index: chrome/browser/ui/views/autocomplete/autocomplete_result_view.cc |
| diff --git a/chrome/browser/ui/views/autocomplete/autocomplete_result_view.cc b/chrome/browser/ui/views/autocomplete/autocomplete_result_view.cc |
| index df52555fbc84d4ecf46d28dc96918fe371bb6fda..59fb04245d329cf735de9340dd5ac4eb6d585b46 100644 |
| --- a/chrome/browser/ui/views/autocomplete/autocomplete_result_view.cc |
| +++ b/chrome/browser/ui/views/autocomplete/autocomplete_result_view.cc |
| @@ -33,7 +33,7 @@ const char16 kEllipsis[] = { 0x2026, 0x0 }; |
| // The minimum distance between the top and bottom of the {icon|text} and the |
| // top or bottom of the row. |
| const int kMinimumIconVerticalPadding = 2; |
| -const int kMinimumTextVerticalPadding = 3; |
| +const int kMinimumTextVerticalPadding = 3; // Default value, may be overridden. |
|
Peter Kasting
2012/05/07 21:03:12
Nit: Comment unnecessary given your comments on th
Jói
2012/05/10 18:33:07
Done.
|
| } // namespace |
| @@ -103,7 +103,10 @@ AutocompleteResultView::AutocompleteResultView( |
| int model_index, |
| const gfx::Font& font, |
| const gfx::Font& bold_font) |
| - : model_(model), |
| + : edge_item_padding_(LocationBarView::kEdgeItemPadding), |
| + item_padding_(LocationBarView::kItemPadding), |
| + minimum_text_vertical_padding_(kMinimumTextVerticalPadding), |
| + model_(model), |
| model_index_(model_index), |
| normal_font_(font), |
| bold_font_(bold_font), |
| @@ -208,12 +211,19 @@ void AutocompleteResultView::Invalidate() { |
| gfx::Size AutocompleteResultView::GetPreferredSize() { |
| return gfx::Size(0, std::max( |
| default_icon_size_ + (kMinimumIconVerticalPadding * 2), |
| - GetTextHeight() + (kMinimumTextVerticalPadding * 2))); |
| + GetTextHeight() + (minimum_text_vertical_padding_ * 2))); |
| } |
| //////////////////////////////////////////////////////////////////////////////// |
| // AutocompleteResultView, protected: |
| +AutocompleteResultView::ResultViewState |
| + AutocompleteResultView::GetState() const { |
| + if (model_->IsSelectedIndex(model_index_)) |
| + return SELECTED; |
| + return model_->IsHoveredIndex(model_index_) ? HOVERED : NORMAL; |
| +} |
| + |
| void AutocompleteResultView::PaintMatch(gfx::Canvas* canvas, |
| const AutocompleteMatch& match, |
| int x) { |
| @@ -244,6 +254,10 @@ int AutocompleteResultView::GetTextHeight() const { |
| return std::max(normal_font_.GetHeight(), bold_font_.GetHeight()); |
| } |
| +void AutocompleteResultView::AdjustIconBounds(const AutocompleteMatch& match, |
| + gfx::Rect* bounds) { |
| +} |
| + |
| // static |
| bool AutocompleteResultView::SortRunsLogically(const RunData& lhs, |
| const RunData& rhs) { |
| @@ -259,13 +273,6 @@ bool AutocompleteResultView::SortRunsVisually(const RunData& lhs, |
| // static |
| int AutocompleteResultView::default_icon_size_ = 0; |
| -AutocompleteResultView::ResultViewState |
| - AutocompleteResultView::GetState() const { |
| - if (model_->IsSelectedIndex(model_index_)) |
| - return SELECTED; |
| - return model_->IsHoveredIndex(model_index_) ? HOVERED : NORMAL; |
| -} |
| - |
| const SkBitmap* AutocompleteResultView::GetIcon() const { |
| const SkBitmap* bitmap = model_->GetIconIfExtensionMatch(model_index_); |
| if (bitmap) |
| @@ -538,33 +545,31 @@ void AutocompleteResultView::Elide(Runs* runs, int remaining_width) const { |
| void AutocompleteResultView::Layout() { |
| const SkBitmap* icon = GetIcon(); |
| - icon_bounds_.SetRect(LocationBarView::kEdgeItemPadding + |
| - ((icon->width() == default_icon_size_) ? |
| - 0 : LocationBarView::kIconInternalPadding), |
| + icon_bounds_.SetRect( |
| + edge_item_padding_ + ((icon->width() == default_icon_size_) ? 0 : |
|
Peter Kasting
2012/05/07 21:03:12
Nit: Wrap these lines as they were before (maintai
Jói
2012/05/10 18:33:07
Went one step further and separated it out as a te
|
| + LocationBarView::kIconInternalPadding), |
| (height() - icon->height()) / 2, icon->width(), icon->height()); |
| - int text_x = LocationBarView::kEdgeItemPadding + default_icon_size_ + |
| - LocationBarView::kItemPadding; |
| + int text_x = edge_item_padding_ + default_icon_size_ + item_padding_; |
| int text_height = GetTextHeight(); |
| int text_width; |
| if (match_.associated_keyword.get()) { |
| const int kw_collapsed_size = keyword_icon_->width() + |
| - LocationBarView::kEdgeItemPadding; |
| + edge_item_padding_; |
| const int max_kw_x = width() - kw_collapsed_size; |
| const int kw_x = animation_->CurrentValueBetween(max_kw_x, |
| - LocationBarView::kEdgeItemPadding); |
| - const int kw_text_x = kw_x + keyword_icon_->width() + |
| - LocationBarView::kItemPadding; |
| + edge_item_padding_); |
| + const int kw_text_x = kw_x + keyword_icon_->width() + item_padding_; |
| - text_width = kw_x - text_x - LocationBarView::kItemPadding; |
| + text_width = kw_x - text_x - item_padding_; |
| keyword_text_bounds_.SetRect(kw_text_x, 0, std::max( |
| - width() - kw_text_x - LocationBarView::kEdgeItemPadding, 0), |
| + width() - kw_text_x - edge_item_padding_, 0), |
| text_height); |
| keyword_icon_->SetPosition(gfx::Point(kw_x, |
| (height() - keyword_icon_->height()) / 2)); |
| } else { |
| - text_width = width() - text_x - LocationBarView::kEdgeItemPadding; |
| + text_width = width() - text_x - edge_item_padding_; |
| } |
| text_bounds_.SetRect(text_x, std::max(0, (height() - text_height) / 2), |
| @@ -584,8 +589,9 @@ void AutocompleteResultView::OnPaint(gfx::Canvas* canvas) { |
| if (!match_.associated_keyword.get() || |
| keyword_icon_->x() > icon_bounds_.right()) { |
| // Paint the icon. |
| - canvas->DrawBitmapInt(*GetIcon(), GetMirroredXForRect(icon_bounds_), |
| - icon_bounds_.y()); |
| + AdjustIconBounds(match_, &icon_bounds_); |
| + canvas->DrawBitmapInt( |
|
Peter Kasting
2012/05/07 21:03:12
Nit: Better than either old or new wrapping would
Jói
2012/05/10 18:33:07
Done.
|
| + *GetIcon(), GetMirroredXForRect(icon_bounds_), icon_bounds_.y()); |
| // Paint the text. |
| int x = GetMirroredXForRect(text_bounds_); |