OLD | NEW |
---|---|
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 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
8 #include <atlbase.h> // NOLINT | 8 #include <atlbase.h> // NOLINT |
9 #include <atlwin.h> // NOLINT | 9 #include <atlwin.h> // NOLINT |
10 #endif | 10 #endif |
(...skipping 681 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
692 canvas->DrawImageInt(GetIcon(), GetMirroredXForRect(icon_bounds_), | 692 canvas->DrawImageInt(GetIcon(), GetMirroredXForRect(icon_bounds_), |
693 icon_bounds_.y()); | 693 icon_bounds_.y()); |
694 int x = GetMirroredXForRect(text_bounds_); | 694 int x = GetMirroredXForRect(text_bounds_); |
695 mirroring_context_->Initialize(x, text_bounds_.width()); | 695 mirroring_context_->Initialize(x, text_bounds_.width()); |
696 InitContentsRenderTextIfNecessary(); | 696 InitContentsRenderTextIfNecessary(); |
697 | 697 |
698 if (!description_rendertext_) { | 698 if (!description_rendertext_) { |
699 if (match_.answer) { | 699 if (match_.answer) { |
700 base::string16 text; | 700 base::string16 text; |
701 description_rendertext_ = CreateRenderText(text); | 701 description_rendertext_ = CreateRenderText(text); |
702 for (const SuggestionAnswer::TextField& textfield : | 702 for (const SuggestionAnswer::TextField& text_field : |
703 match_.answer->second_line().text_fields()) | 703 match_.answer->second_line().text_fields()) |
704 AppendAnswerText(textfield); | 704 AppendAnswerText(text_field.text(), text_field.type()); |
705 if (match_.answer->second_line().additional_text()) | 705 if (match_.answer->second_line().additional_text()) { |
Peter Kasting
2015/03/24 01:05:35
Nit: Briefer, seems a bit more readable:
dschuyler
2015/03/24 01:26:47
Done.
| |
706 AppendAnswerText(*match_.answer->second_line().additional_text()); | 706 AppendAnswerText( |
707 if (match_.answer->second_line().status_text()) | 707 base::ASCIIToUTF16(" ") + |
708 AppendAnswerText(*match_.answer->second_line().status_text()); | 708 match_.answer->second_line().additional_text()->text(), |
709 match_.answer->second_line().additional_text()->type()); | |
710 } | |
711 if (match_.answer->second_line().status_text()) { | |
712 AppendAnswerText( | |
713 base::ASCIIToUTF16(" ") + | |
714 match_.answer->second_line().status_text()->text(), | |
715 match_.answer->second_line().status_text()->type()); | |
716 } | |
709 } else if (!match_.description.empty()) { | 717 } else if (!match_.description.empty()) { |
710 description_rendertext_ = CreateClassifiedRenderText( | 718 description_rendertext_ = CreateClassifiedRenderText( |
711 match_.description, match_.description_class, true); | 719 match_.description, match_.description_class, true); |
712 } | 720 } |
713 } | 721 } |
714 PaintMatch(match_, contents_rendertext_.get(), | 722 PaintMatch(match_, contents_rendertext_.get(), |
715 description_rendertext_.get(), canvas, x); | 723 description_rendertext_.get(), canvas, x); |
716 } | 724 } |
717 | 725 |
718 AutocompleteMatch* keyword_match = match_.associated_keyword.get(); | 726 AutocompleteMatch* keyword_match = match_.associated_keyword.get(); |
(...skipping 29 matching lines...) Expand all Loading... | |
748 return ui::ResourceBundle::GetSharedInstance() | 756 return ui::ResourceBundle::GetSharedInstance() |
749 .GetFontList(GetTextStyle(1).font) | 757 .GetFontList(GetTextStyle(1).font) |
750 .GetHeight(); | 758 .GetHeight(); |
751 } | 759 } |
752 | 760 |
753 int OmniboxResultView::GetContentLineHeight() const { | 761 int OmniboxResultView::GetContentLineHeight() const { |
754 return std::max(default_icon_size_ + (kMinimumIconVerticalPadding * 2), | 762 return std::max(default_icon_size_ + (kMinimumIconVerticalPadding * 2), |
755 GetTextHeight() + (kMinimumTextVerticalPadding * 2)); | 763 GetTextHeight() + (kMinimumTextVerticalPadding * 2)); |
756 } | 764 } |
757 | 765 |
758 void OmniboxResultView::AppendAnswerText( | 766 void OmniboxResultView::AppendAnswerText(const base::string16& text, |
759 const SuggestionAnswer::TextField& text_field) { | 767 int text_type) { |
760 int offset = description_rendertext_->text().length(); | 768 int offset = description_rendertext_->text().length(); |
761 gfx::Range range(offset, offset + text_field.text().length()); | 769 gfx::Range range(offset, offset + text.length()); |
762 description_rendertext_->AppendText(text_field.text()); | 770 description_rendertext_->AppendText(text); |
763 const TextStyle& text_style = GetTextStyle(text_field.type()); | 771 const TextStyle& text_style = GetTextStyle(text_type); |
764 // TODO(dschuyler): follow up on the problem of different font sizes within | 772 // TODO(dschuyler): follow up on the problem of different font sizes within |
765 // one RenderText. | 773 // one RenderText. |
766 description_rendertext_->SetFontList( | 774 description_rendertext_->SetFontList( |
767 ui::ResourceBundle::GetSharedInstance().GetFontList(text_style.font)); | 775 ui::ResourceBundle::GetSharedInstance().GetFontList(text_style.font)); |
768 description_rendertext_->ApplyColor( | 776 description_rendertext_->ApplyColor( |
769 GetNativeTheme()->GetSystemColor(text_style.colors[GetState()]), range); | 777 GetNativeTheme()->GetSystemColor(text_style.colors[GetState()]), range); |
770 description_rendertext_->ApplyBaselineStyle(text_style.baseline, range); | 778 description_rendertext_->ApplyBaselineStyle(text_style.baseline, range); |
771 } | 779 } |
OLD | NEW |