Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(287)

Side by Side Diff: chrome/browser/ui/views/omnibox/omnibox_result_view.cc

Issue 2943533002: Use the result view font list for the base answers font. (Closed)
Patch Set: Respond to comment Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // For WinDDK ATL compatibility, these ATL headers must come first. 5 // For WinDDK ATL compatibility, these ATL headers must come first.
6 #include "build/build_config.h" 6 #include "build/build_config.h"
7 7
8 #if defined(OS_WIN) 8 #if defined(OS_WIN)
9 #include <atlbase.h> // NOLINT 9 #include <atlbase.h> // NOLINT
10 #include <atlwin.h> // NOLINT 10 #include <atlwin.h> // NOLINT
(...skipping 728 matching lines...) Expand 10 before | Expand all | Expand 10 after
739 739
740 const gfx::FontList& OmniboxResultView::GetAnswerFont() const { 740 const gfx::FontList& OmniboxResultView::GetAnswerFont() const {
741 // This assumes that the first text type in the second answer line can be used 741 // This assumes that the first text type in the second answer line can be used
742 // to specify the font for all the text fields in the line. For now this works 742 // to specify the font for all the text fields in the line. For now this works
743 // but eventually it will be necessary to get RenderText to support multiple 743 // but eventually it will be necessary to get RenderText to support multiple
744 // font sizes or use multiple RenderTexts. 744 // font sizes or use multiple RenderTexts.
745 int text_type = 745 int text_type =
746 match_.answer && !match_.answer->second_line().text_fields().empty() 746 match_.answer && !match_.answer->second_line().text_fields().empty()
747 ? match_.answer->second_line().text_fields()[0].type() 747 ? match_.answer->second_line().text_fields()[0].type()
748 : SuggestionAnswer::SUGGESTION; 748 : SuggestionAnswer::SUGGESTION;
749 return ui::ResourceBundle::GetSharedInstance().GetFontList( 749
750 GetTextStyle(text_type).font); 750 // When BaseFont is specified, reuse font_list_, which may have had size
751 // adjustments from BaseFont before it was provided to this class. Otherwise,
752 // get the standard font list for the specified style.
753 ui::ResourceBundle::FontStyle font_style = GetTextStyle(text_type).font;
754 return (font_style == ui::ResourceBundle::BaseFont)
755 ? font_list_
756 : ui::ResourceBundle::GetSharedInstance().GetFontList(font_style);
751 } 757 }
752 758
753 int OmniboxResultView::GetAnswerHeight() const { 759 int OmniboxResultView::GetAnswerHeight() const {
754 // If the answer specifies a maximum of 1 line we can simply return the answer 760 // If the answer specifies a maximum of 1 line we can simply return the answer
755 // font height. 761 // font height.
756 if (match_.answer->second_line().num_text_lines() == 1) 762 if (match_.answer->second_line().num_text_lines() == 1)
757 return GetAnswerFont().GetHeight() + kVerticalPadding; 763 return GetAnswerFont().GetHeight() + kVerticalPadding;
758 764
759 // Multi-line answers require layout in order to determine the number of lines 765 // Multi-line answers require layout in order to determine the number of lines
760 // the RenderText will use. 766 // the RenderText will use.
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
855 destination->AppendText(text); 861 destination->AppendText(text);
856 const TextStyle& text_style = GetTextStyle(text_type); 862 const TextStyle& text_style = GetTextStyle(text_type);
857 // TODO(dschuyler): follow up on the problem of different font sizes within 863 // TODO(dschuyler): follow up on the problem of different font sizes within
858 // one RenderText. Maybe with destination->SetFontList(...). 864 // one RenderText. Maybe with destination->SetFontList(...).
859 destination->ApplyWeight( 865 destination->ApplyWeight(
860 is_bold ? gfx::Font::Weight::BOLD : gfx::Font::Weight::NORMAL, range); 866 is_bold ? gfx::Font::Weight::BOLD : gfx::Font::Weight::NORMAL, range);
861 destination->ApplyColor( 867 destination->ApplyColor(
862 GetNativeTheme()->GetSystemColor(text_style.colors[GetState()]), range); 868 GetNativeTheme()->GetSystemColor(text_style.colors[GetState()]), range);
863 destination->ApplyBaselineStyle(text_style.baseline, range); 869 destination->ApplyBaselineStyle(text_style.baseline, range);
864 } 870 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698