| 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 0446be9feea894a152a00b251004a97204b51f20..8a8ae03ce892d1021cbab0b1f2517722ae6c5a2f 100644
|
| --- a/chrome/browser/ui/views/omnibox/omnibox_result_view.cc
|
| +++ b/chrome/browser/ui/views/omnibox/omnibox_result_view.cc
|
| @@ -87,6 +87,19 @@ struct TextStyle {
|
| gfx::BaselineStyle baseline;
|
| };
|
|
|
| +// Returns the styles that should be applied to the specified answer text type.
|
| +//
|
| +// Note that the font value is only consulted for the first text type that
|
| +// appears on an answer line, because RenderText does not yet support multiple
|
| +// font sizes. Subsequent text types on the same line will share the text size
|
| +// of the first type, while the color and baseline styles specified here will
|
| +// always apply. The gfx::INFERIOR baseline style is used as a workaround to
|
| +// produce smaller text on the same line. The way this is used in the current
|
| +// set of answers is that the small types (TOP_ALIGNED, DESCRIPTION_NEGATIVE,
|
| +// DESCRIPTION_POSITIVE and SUGGESTION_SECONDARY_TEXT_SMALL) only ever appear
|
| +// following LargeFont text, so for consistency they specify LargeFont for the
|
| +// first value even though this is not actually used (since they're not the
|
| +// first value).
|
| TextStyle GetTextStyle(int type) {
|
| switch (type) {
|
| case SuggestionAnswer::TOP_ALIGNED:
|
| @@ -125,7 +138,12 @@ TextStyle GetTextStyle(int type) {
|
| NativeTheme::kColorId_ResultsTableHoveredText,
|
| NativeTheme::kColorId_ResultsTableSelectedText},
|
| gfx::NORMAL_BASELINE};
|
| - case SuggestionAnswer::SUGGESTION_SECONDARY_TEXT_SMALL: // Fall through.
|
| + case SuggestionAnswer::SUGGESTION_SECONDARY_TEXT_SMALL:
|
| + return {ui::ResourceBundle::LargeFont,
|
| + {NativeTheme::kColorId_ResultsTableNormalDimmedText,
|
| + NativeTheme::kColorId_ResultsTableHoveredDimmedText,
|
| + NativeTheme::kColorId_ResultsTableSelectedDimmedText},
|
| + gfx::INFERIOR};
|
| case SuggestionAnswer::SUGGESTION_SECONDARY_TEXT_MEDIUM:
|
| return {ui::ResourceBundle::BaseFont,
|
| {NativeTheme::kColorId_ResultsTableNormalDimmedText,
|
| @@ -278,12 +296,11 @@ void OmniboxResultView::OnSelected() {
|
| gfx::Size OmniboxResultView::GetPreferredSize() const {
|
| if (!match_.answer)
|
| return gfx::Size(0, GetContentLineHeight());
|
| - // An answer implies a match and a description in a large font.
|
| if (match_.answer->second_line().num_text_lines() == 1)
|
| return gfx::Size(0, GetContentLineHeight() + GetAnswerLineHeight());
|
| if (!description_rendertext_) {
|
| description_rendertext_ =
|
| - CreateAnswerLine(match_.answer->second_line(), font_list_);
|
| + CreateAnswerLine(match_.answer->second_line(), GetAnswerLineFont());
|
| }
|
| description_rendertext_->SetDisplayRect(
|
| gfx::Rect(text_bounds_.width(), 0));
|
| @@ -648,7 +665,7 @@ void OmniboxResultView::OnPaint(gfx::Canvas* canvas) {
|
| if (!description_rendertext_) {
|
| if (match_.answer) {
|
| description_rendertext_ =
|
| - CreateAnswerLine(match_.answer->second_line(), font_list_);
|
| + CreateAnswerLine(match_.answer->second_line(), GetAnswerLineFont());
|
| } else if (!match_.description.empty()) {
|
| description_rendertext_ = CreateClassifiedRenderText(
|
| match_.description, match_.description_class, true);
|
| @@ -681,12 +698,21 @@ void OmniboxResultView::AnimationProgressed(const gfx::Animation* animation) {
|
| SchedulePaint();
|
| }
|
|
|
| +const gfx::FontList& OmniboxResultView::GetAnswerLineFont() const {
|
| + // This assumes that the first text type in the second answer line can be used
|
| + // to specify the font for all the text fields in the line. For now this works
|
| + // but eventually it will be necessary to get RenderText to support multiple
|
| + // font sizes or use multiple RenderTexts.
|
| + int text_type =
|
| + match_.answer && !match_.answer->second_line().text_fields().empty()
|
| + ? match_.answer->second_line().text_fields()[0].type()
|
| + : SuggestionAnswer::SUGGESTION;
|
| + return ui::ResourceBundle::GetSharedInstance().GetFontList(
|
| + GetTextStyle(text_type).font);
|
| +}
|
| +
|
| int OmniboxResultView::GetAnswerLineHeight() const {
|
| - // ANSWER_TEXT_LARGE is the largest font used and so defines the boundary that
|
| - // all the other answer styles fit within.
|
| - return ui::ResourceBundle::GetSharedInstance()
|
| - .GetFontList(GetTextStyle(SuggestionAnswer::ANSWER_TEXT_LARGE).font)
|
| - .GetHeight();
|
| + return GetAnswerLineFont().GetHeight();
|
| }
|
|
|
| int OmniboxResultView::GetContentLineHeight() const {
|
| @@ -700,7 +726,7 @@ int OmniboxResultView::GetContentLineHeight() const {
|
|
|
| std::unique_ptr<gfx::RenderText> OmniboxResultView::CreateAnswerLine(
|
| const SuggestionAnswer::ImageLine& line,
|
| - gfx::FontList font_list) const {
|
| + const gfx::FontList& font_list) const {
|
| std::unique_ptr<gfx::RenderText> destination =
|
| CreateRenderText(base::string16());
|
| destination->SetFontList(font_list);
|
|
|