Chromium Code Reviews| Index: chrome/browser/ui/views/omnibox/omnibox_result_view.cc |
| diff --git a/chrome/browser/ui/views/omnibox/omnibox_result_view.cc b/chrome/browser/ui/views/omnibox/omnibox_result_view.cc |
| index 911c26a55a8830909ee01af95c301f1be2a05462..a0ae799312631567a5bb3406c0252d878f72db78 100644 |
| --- a/chrome/browser/ui/views/omnibox/omnibox_result_view.cc |
| +++ b/chrome/browser/ui/views/omnibox/omnibox_result_view.cc |
| @@ -197,8 +197,8 @@ struct TextStyle { |
| gfx::NORMAL_BASELINE}, |
| }; |
| -const TextStyle& GetTextStyle(size_t type) { |
| - if (type > arraysize(kTextStyles)) |
| +const TextStyle& GetTextStyle(int type) { |
| + if (type < 1 || type > static_cast<int>(arraysize(kTextStyles))) |
|
Peter Kasting
2015/03/24 02:28:11
Super nitpicky nit: Better to static_cast<size_t>(
dschuyler
2015/03/24 20:54:42
Correct on all counts :)
Done.
|
| type = 1; |
| // Subtract one because the types are one based (not zero based). |
| return kTextStyles[type - 1]; |
| @@ -699,13 +699,19 @@ void OmniboxResultView::OnPaint(gfx::Canvas* canvas) { |
| if (match_.answer) { |
| base::string16 text; |
| description_rendertext_ = CreateRenderText(text); |
| - for (const SuggestionAnswer::TextField& textfield : |
| + for (const SuggestionAnswer::TextField& text_field : |
| match_.answer->second_line().text_fields()) |
| - AppendAnswerText(textfield); |
| - if (match_.answer->second_line().additional_text()) |
| - AppendAnswerText(*match_.answer->second_line().additional_text()); |
| - if (match_.answer->second_line().status_text()) |
| - AppendAnswerText(*match_.answer->second_line().status_text()); |
| + AppendAnswerText(text_field.text(), text_field.type()); |
| + const base::char16 space(' '); |
| + if (match_.answer->second_line().additional_text()) { |
| + const auto* text_field = |
|
Peter Kasting
2015/03/24 02:28:11
Why did you move these temps inside the conditiona
dschuyler
2015/03/24 20:54:42
I didn't copy paste the example given. I.e. it wa
|
| + match_.answer->second_line().additional_text(); |
| + AppendAnswerText(space + text_field->text(), text_field->type()); |
| + } |
| + if (match_.answer->second_line().status_text()) { |
| + const auto* text_field = match_.answer->second_line().status_text(); |
| + AppendAnswerText(space + text_field->text(), text_field->type()); |
| + } |
| } else if (!match_.description.empty()) { |
| description_rendertext_ = CreateClassifiedRenderText( |
| match_.description, match_.description_class, true); |
| @@ -755,12 +761,12 @@ int OmniboxResultView::GetContentLineHeight() const { |
| GetTextHeight() + (kMinimumTextVerticalPadding * 2)); |
| } |
| -void OmniboxResultView::AppendAnswerText( |
| - const SuggestionAnswer::TextField& text_field) { |
| +void OmniboxResultView::AppendAnswerText(const base::string16& text, |
| + int text_type) { |
| int offset = description_rendertext_->text().length(); |
| - gfx::Range range(offset, offset + text_field.text().length()); |
| - description_rendertext_->AppendText(text_field.text()); |
| - const TextStyle& text_style = GetTextStyle(text_field.type()); |
| + gfx::Range range(offset, offset + text.length()); |
| + description_rendertext_->AppendText(text); |
| + const TextStyle& text_style = GetTextStyle(text_type); |
| // TODO(dschuyler): follow up on the problem of different font sizes within |
| // one RenderText. |
| description_rendertext_->SetFontList( |