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

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

Issue 795933009: [AiS] for desktop, two lines and font sytles (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Increase vertical spacing in suggestions Created 5 years, 9 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
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 #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
11 11
12 #include "chrome/browser/ui/views/omnibox/omnibox_result_view.h" 12 #include "chrome/browser/ui/views/omnibox/omnibox_result_view.h"
13 13
14 #include <algorithm> // NOLINT 14 #include <algorithm> // NOLINT
15 15
16 #include "base/i18n/bidi_line_iterator.h" 16 #include "base/i18n/bidi_line_iterator.h"
17 #include "base/memory/scoped_vector.h" 17 #include "base/memory/scoped_vector.h"
18 #include "base/strings/string_number_conversions.h" 18 #include "base/strings/string_number_conversions.h"
19 #include "base/strings/string_util.h" 19 #include "base/strings/string_util.h"
20 #include "chrome/browser/bitmap_fetcher/bitmap_fetcher_service_factory.h" 20 #include "chrome/browser/bitmap_fetcher/bitmap_fetcher_service_factory.h"
21 #include "chrome/browser/profiles/profile.h" 21 #include "chrome/browser/profiles/profile.h"
22 #include "chrome/browser/ui/omnibox/omnibox_popup_model.h" 22 #include "chrome/browser/ui/omnibox/omnibox_popup_model.h"
23 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" 23 #include "chrome/browser/ui/views/location_bar/location_bar_view.h"
24 #include "chrome/browser/ui/views/omnibox/omnibox_popup_contents_view.h" 24 #include "chrome/browser/ui/views/omnibox/omnibox_popup_contents_view.h"
25 #include "chrome/grit/generated_resources.h" 25 #include "chrome/grit/generated_resources.h"
26 #include "components/omnibox/omnibox_field_trial.h"
26 #include "components/omnibox/suggestion_answer.h" 27 #include "components/omnibox/suggestion_answer.h"
27 #include "grit/components_scaled_resources.h" 28 #include "grit/components_scaled_resources.h"
28 #include "grit/theme_resources.h" 29 #include "grit/theme_resources.h"
30 #include "third_party/skia/include/core/SkColor.h"
29 #include "ui/base/l10n/l10n_util.h" 31 #include "ui/base/l10n/l10n_util.h"
32 #include "ui/base/resource/resource_bundle.h"
30 #include "ui/base/theme_provider.h" 33 #include "ui/base/theme_provider.h"
31 #include "ui/gfx/canvas.h" 34 #include "ui/gfx/canvas.h"
32 #include "ui/gfx/color_utils.h" 35 #include "ui/gfx/color_utils.h"
33 #include "ui/gfx/image/image.h" 36 #include "ui/gfx/image/image.h"
34 #include "ui/gfx/range/range.h" 37 #include "ui/gfx/range/range.h"
35 #include "ui/gfx/render_text.h" 38 #include "ui/gfx/render_text.h"
36 #include "ui/gfx/text_utils.h" 39 #include "ui/gfx/text_utils.h"
37 #include "ui/native_theme/native_theme.h" 40 #include "ui/native_theme/native_theme.h"
38 41
39 using ui::NativeTheme; 42 using ui::NativeTheme;
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 { NativeTheme::kColorId_ResultsTableSelectedUrl, 108 { NativeTheme::kColorId_ResultsTableSelectedUrl,
106 OmniboxResultView::SELECTED, OmniboxResultView::URL }, 109 OmniboxResultView::SELECTED, OmniboxResultView::URL },
107 { NativeTheme::kColorId_ResultsTableNormalDivider, 110 { NativeTheme::kColorId_ResultsTableNormalDivider,
108 OmniboxResultView::NORMAL, OmniboxResultView::DIVIDER }, 111 OmniboxResultView::NORMAL, OmniboxResultView::DIVIDER },
109 { NativeTheme::kColorId_ResultsTableHoveredDivider, 112 { NativeTheme::kColorId_ResultsTableHoveredDivider,
110 OmniboxResultView::HOVERED, OmniboxResultView::DIVIDER }, 113 OmniboxResultView::HOVERED, OmniboxResultView::DIVIDER },
111 { NativeTheme::kColorId_ResultsTableSelectedDivider, 114 { NativeTheme::kColorId_ResultsTableSelectedDivider,
112 OmniboxResultView::SELECTED, OmniboxResultView::DIVIDER }, 115 OmniboxResultView::SELECTED, OmniboxResultView::DIVIDER },
113 }; 116 };
114 117
118 struct TextStyles {
119 ui::ResourceBundle::FontStyle font;
120 NativeTheme::ColorId color;
121 NativeTheme::ColorId color_selected;
122 gfx::BaselineStyle baseline;
123 } const kTextStyles[] = {
124 // 1 ANSWER_TEXT
125 {ui::ResourceBundle::LargeFont,
126 NativeTheme::kColorId_AnswerNormalText,
Justin Donnelly 2015/03/13 21:08:33 You've pushed some knowledge of the Answers spec i
dschuyler 2015/03/13 21:48:23 Seems reasonable.
127 NativeTheme::kColorId_AnswerNormalTextSelected,
128 gfx::NORMAL_BASELINE},
129 // 2 HEADLINE_TEXT
130 {ui::ResourceBundle::LargeFont,
131 NativeTheme::kColorId_AnswerInfoText,
132 NativeTheme::kColorId_AnswerInfoTextSelected,
133 gfx::NORMAL_BASELINE},
134 // 3 TOP_ALIGNED_TEXT
135 {ui::ResourceBundle::LargeFont,
136 NativeTheme::kColorId_AnswerInfoText,
137 NativeTheme::kColorId_AnswerInfoTextSelected,
138 gfx::SUPERIOR},
139 // 4 DESCRIPTION_TEXT
140 {ui::ResourceBundle::BaseFont,
141 NativeTheme::kColorId_AnswerInfoText,
142 NativeTheme::kColorId_AnswerInfoTextSelected,
143 gfx::NORMAL_BASELINE},
144 // 5 DESCRIPTION_TEXT_NEGATIVE
145 {ui::ResourceBundle::LargeFont,
146 NativeTheme::kColorId_AnswerNegativeText,
147 NativeTheme::kColorId_AnswerNegativeTextSelected,
148 gfx::INFERIOR},
149 // 6 DESCRIPTION_TEXT_POSITIVE
150 {ui::ResourceBundle::LargeFont,
151 NativeTheme::kColorId_AnswerPositiveText,
152 NativeTheme::kColorId_AnswerPositiveTextSelected,
153 gfx::INFERIOR},
154 // 7 MORE_INFO_TEXT
155 {ui::ResourceBundle::SmallFont,
156 NativeTheme::kColorId_AnswerInfoText,
157 NativeTheme::kColorId_AnswerInfoTextSelected,
158 gfx::NORMAL_BASELINE},
159 // 8 SUGGESTION_TEXT
160 {ui::ResourceBundle::BaseFont,
161 NativeTheme::kColorId_AnswerNormalText,
162 NativeTheme::kColorId_AnswerNormalTextSelected,
163 gfx::NORMAL_BASELINE},
164 // 9 SUGGESTION_TEXT_POSITIVE
165 {ui::ResourceBundle::BaseFont,
166 NativeTheme::kColorId_AnswerPositiveText,
167 NativeTheme::kColorId_AnswerPositiveTextSelected,
168 gfx::NORMAL_BASELINE},
169 // 10 SUGGESTION_TEXT_NEGATIVE
170 {ui::ResourceBundle::BaseFont,
171 NativeTheme::kColorId_AnswerNegativeText,
172 NativeTheme::kColorId_AnswerNegativeTextSelected,
173 gfx::NORMAL_BASELINE},
174 // 11 SUGGESTION_LINK_COLOR
175 {ui::ResourceBundle::BaseFont,
176 NativeTheme::kColorId_AnswerLinkText,
177 NativeTheme::kColorId_AnswerLinkTextSelected,
178 gfx::NORMAL_BASELINE},
179 // 12 STATUS_TEXT
180 {ui::ResourceBundle::LargeFont,
181 NativeTheme::kColorId_AnswerInfoText,
182 NativeTheme::kColorId_AnswerInfoTextSelected,
183 gfx::INFERIOR},
184 // 13 PERSONALIZED_SUGGESTION_TEXT
185 {ui::ResourceBundle::BaseFont,
186 NativeTheme::kColorId_AnswerInfoText,
187 NativeTheme::kColorId_AnswerInfoTextSelected,
188 gfx::NORMAL_BASELINE},
189 };
190
191 const TextStyles& GetTextStyle(int type) {
192 if (type > (int)arraysize(kTextStyles))
193 type = 1;
194 // Subtract one because the types are one based (not zero based).
195 return kTextStyles[(type - 1)];
196 }
197
115 } // namespace 198 } // namespace
116 199
117 //////////////////////////////////////////////////////////////////////////////// 200 ////////////////////////////////////////////////////////////////////////////////
118 // OmniboxResultView, public: 201 // OmniboxResultView, public:
119 202
120 // This class is a utility class for calculations affected by whether the result 203 // This class is a utility class for calculations affected by whether the result
121 // view is horizontally mirrored. The drawing functions can be written as if 204 // view is horizontally mirrored. The drawing functions can be written as if
122 // all drawing occurs left-to-right, and then use this class to get the actual 205 // all drawing occurs left-to-right, and then use this class to get the actual
123 // coordinates to begin drawing onscreen. 206 // coordinates to begin drawing onscreen.
124 class OmniboxResultView::MirroringContext { 207 class OmniboxResultView::MirroringContext {
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 void OmniboxResultView::Invalidate() { 326 void OmniboxResultView::Invalidate() {
244 keyword_icon_->SetImage(GetKeywordIcon()); 327 keyword_icon_->SetImage(GetKeywordIcon());
245 // While the text in the RenderTexts may not have changed, the styling 328 // While the text in the RenderTexts may not have changed, the styling
246 // (color/bold) may need to change. So we reset them to cause them to be 329 // (color/bold) may need to change. So we reset them to cause them to be
247 // recomputed in OnPaint(). 330 // recomputed in OnPaint().
248 ResetRenderTexts(); 331 ResetRenderTexts();
249 SchedulePaint(); 332 SchedulePaint();
250 } 333 }
251 334
252 gfx::Size OmniboxResultView::GetPreferredSize() const { 335 gfx::Size OmniboxResultView::GetPreferredSize() const {
253 return gfx::Size(0, std::max( 336 if (!match_.answer)
254 default_icon_size_ + (kMinimumIconVerticalPadding * 2), 337 return gfx::Size(0, GetContentLineHeight());
255 GetTextHeight() + (minimum_text_vertical_padding_ * 2))); 338 // An answer implies a match and a description in a large font.
339 return gfx::Size(0, GetContentLineHeight() +
340 ui::ResourceBundle::GetSharedInstance()
341 .GetFontList(GetTextStyle(1).font)
Justin Donnelly 2015/03/13 21:08:33 An explanation of why 1 would be helpful.
dschuyler 2015/03/13 21:48:23 Done.
342 .GetHeight());
256 } 343 }
257 344
258 //////////////////////////////////////////////////////////////////////////////// 345 ////////////////////////////////////////////////////////////////////////////////
259 // OmniboxResultView, protected: 346 // OmniboxResultView, protected:
260 347
261 OmniboxResultView::ResultViewState OmniboxResultView::GetState() const { 348 OmniboxResultView::ResultViewState OmniboxResultView::GetState() const {
262 if (model_->IsSelectedIndex(model_index_)) 349 if (model_->IsSelectedIndex(model_index_))
263 return SELECTED; 350 return SELECTED;
264 return model_->IsHoveredIndex(model_index_) ? HOVERED : NORMAL; 351 return model_->IsHoveredIndex(model_index_) ? HOVERED : NORMAL;
265 } 352 }
(...skipping 20 matching lines...) Expand all
286 int contents_max_width, description_max_width; 373 int contents_max_width, description_max_width;
287 OmniboxPopupModel::ComputeMatchMaxWidths( 374 OmniboxPopupModel::ComputeMatchMaxWidths(
288 contents->GetContentWidth(), 375 contents->GetContentWidth(),
289 separator_width_, 376 separator_width_,
290 description ? description->GetContentWidth() : 0, 377 description ? description->GetContentWidth() : 0,
291 mirroring_context_->remaining_width(x), 378 mirroring_context_->remaining_width(x),
292 !AutocompleteMatch::IsSearchType(match.type), 379 !AutocompleteMatch::IsSearchType(match.type),
293 &contents_max_width, 380 &contents_max_width,
294 &description_max_width); 381 &description_max_width);
295 382
296 x = DrawRenderText(match, contents, true, canvas, x, y, contents_max_width); 383 int after_contents_x =
384 DrawRenderText(match, contents, true, canvas, x, y, contents_max_width);
297 385
298 if (description_max_width != 0) { 386 if (description_max_width != 0) {
299 x = DrawRenderText(match, separator_rendertext_.get(), false, canvas, x, y, 387 if (match.answer) {
300 separator_width_); 388 y += GetContentLineHeight();
301 389 if (!answer_image_.isNull()) {
302 if (!answer_image_.isNull()) { 390 // Add one to draw all the way on to the bottom and left pixels.
303 canvas->DrawImageInt(answer_image_, 391 // i.e. make the destination rect <= rather than strictly less than.
304 // Source x, y, w, h. 392 int answer_icon_size = 1 +
305 0, 0, answer_image_.width(), answer_image_.height(), 393 ui::ResourceBundle::GetSharedInstance()
306 // Destination x, y, w, h. 394 .GetFontList(GetTextStyle(1).font)
Justin Donnelly 2015/03/13 21:08:33 This is used in a couple places. How about GetAnsw
dschuyler 2015/03/13 21:48:23 Done.
307 GetMirroredXInView(x), 395 .GetBaseline();
308 y + kMinimumIconVerticalPadding, default_icon_size_, 396 canvas->DrawImageInt(
309 default_icon_size_, true); 397 answer_image_,
310 x += default_icon_size_ + LocationBarView::kIconInternalPadding; 398 // Source x, y, w, h.
399 0, 0, answer_image_.width(), answer_image_.height(),
400 // Destination x, y, w, h.
401 GetMirroredXInView(x), y, answer_icon_size, answer_icon_size, true);
402 x += answer_icon_size + LocationBarView::kIconInternalPadding;
403 }
404 } else {
405 x = DrawRenderText(match, separator_rendertext_.get(), false, canvas,
406 after_contents_x, y, separator_width_);
311 } 407 }
312 408
313 DrawRenderText(match, description, false, canvas, x, y, 409 DrawRenderText(match, description, false, canvas, x, y,
314 description_max_width); 410 description_max_width);
315 } 411 }
316 } 412 }
317 413
318 int OmniboxResultView::DrawRenderText( 414 int OmniboxResultView::DrawRenderText(
319 const AutocompleteMatch& match, 415 const AutocompleteMatch& match,
320 gfx::RenderText* render_text, 416 gfx::RenderText* render_text,
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 const int start_offset = std::max(prefix_width, 467 const int start_offset = std::max(prefix_width,
372 std::min(remaining_width - max_match_contents_width, offset)); 468 std::min(remaining_width - max_match_contents_width, offset));
373 right_x = x + std::min(remaining_width, start_offset + max_width); 469 right_x = x + std::min(remaining_width, start_offset + max_width);
374 x += start_offset; 470 x += start_offset;
375 prefix_x = x - prefix_width; 471 prefix_x = x - prefix_width;
376 } 472 }
377 prefix_render_text->SetDirectionalityMode(is_match_contents_rtl ? 473 prefix_render_text->SetDirectionalityMode(is_match_contents_rtl ?
378 gfx::DIRECTIONALITY_FORCE_RTL : gfx::DIRECTIONALITY_FORCE_LTR); 474 gfx::DIRECTIONALITY_FORCE_RTL : gfx::DIRECTIONALITY_FORCE_LTR);
379 prefix_render_text->SetHorizontalAlignment( 475 prefix_render_text->SetHorizontalAlignment(
380 is_match_contents_rtl ? gfx::ALIGN_RIGHT : gfx::ALIGN_LEFT); 476 is_match_contents_rtl ? gfx::ALIGN_RIGHT : gfx::ALIGN_LEFT);
381 prefix_render_text->SetDisplayRect(gfx::Rect( 477 prefix_render_text->SetDisplayRect(
382 mirroring_context_->mirrored_left_coord( 478 gfx::Rect(mirroring_context_->mirrored_left_coord(
383 prefix_x, prefix_x + prefix_width), y, 479 prefix_x, prefix_x + prefix_width),
384 prefix_width, height())); 480 y, prefix_width, GetContentLineHeight()));
385 prefix_render_text->Draw(canvas); 481 prefix_render_text->Draw(canvas);
386 } 482 }
387 483
388 // Set the display rect to trigger eliding. 484 // Set the display rect to trigger eliding.
389 render_text->SetDisplayRect(gfx::Rect( 485 render_text->SetDisplayRect(
390 mirroring_context_->mirrored_left_coord(x, right_x), y, 486 gfx::Rect(mirroring_context_->mirrored_left_coord(x, right_x), y,
391 right_x - x, height())); 487 right_x - x, GetContentLineHeight()));
392 render_text->Draw(canvas); 488 render_text->Draw(canvas);
393 return right_x; 489 return right_x;
394 } 490 }
395 491
396 scoped_ptr<gfx::RenderText> OmniboxResultView::CreateRenderText( 492 scoped_ptr<gfx::RenderText> OmniboxResultView::CreateRenderText(
397 const base::string16& text) const { 493 const base::string16& text) const {
398 scoped_ptr<gfx::RenderText> render_text(gfx::RenderText::CreateInstance()); 494 scoped_ptr<gfx::RenderText> render_text(gfx::RenderText::CreateInstance());
399 render_text->SetDisplayRect(gfx::Rect(gfx::Size(INT_MAX, 0))); 495 render_text->SetDisplayRect(gfx::Rect(gfx::Size(INT_MAX, 0)));
400 render_text->SetCursorEnabled(false); 496 render_text->SetCursorEnabled(false);
401 render_text->SetElideBehavior(gfx::ELIDE_TAIL); 497 render_text->SetElideBehavior(gfx::ELIDE_TAIL);
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
547 if (!contents_rendertext_) { 643 if (!contents_rendertext_) {
548 contents_rendertext_.reset( 644 contents_rendertext_.reset(
549 CreateClassifiedRenderText( 645 CreateClassifiedRenderText(
550 match_.contents, match_.contents_class, false).release()); 646 match_.contents, match_.contents_class, false).release());
551 } 647 }
552 } 648 }
553 649
554 void OmniboxResultView::Layout() { 650 void OmniboxResultView::Layout() {
555 const gfx::ImageSkia icon = GetIcon(); 651 const gfx::ImageSkia icon = GetIcon();
556 652
557 icon_bounds_.SetRect(edge_item_padding_ + 653 icon_bounds_.SetRect(
558 ((icon.width() == default_icon_size_) ? 654 edge_item_padding_ + ((icon.width() == default_icon_size_)
559 0 : LocationBarView::kIconInternalPadding), 655 ? 0
560 (height() - icon.height()) / 2, icon.width(), icon.height()); 656 : LocationBarView::kIconInternalPadding),
657 (GetContentLineHeight() - icon.height()) / 2, icon.width(),
658 icon.height());
561 659
562 int text_x = edge_item_padding_ + default_icon_size_ + item_padding_; 660 int text_x = edge_item_padding_ + default_icon_size_ + item_padding_;
563 int text_width = width() - text_x - edge_item_padding_; 661 int text_width = width() - text_x - edge_item_padding_;
564 662
565 if (match_.associated_keyword.get()) { 663 if (match_.associated_keyword.get()) {
566 const int kw_collapsed_size = 664 const int kw_collapsed_size =
567 keyword_icon_->width() + edge_item_padding_; 665 keyword_icon_->width() + edge_item_padding_;
568 const int max_kw_x = width() - kw_collapsed_size; 666 const int max_kw_x = width() - kw_collapsed_size;
569 const int kw_x = 667 const int kw_x =
570 animation_->CurrentValueBetween(max_kw_x, edge_item_padding_); 668 animation_->CurrentValueBetween(max_kw_x, edge_item_padding_);
(...skipping 24 matching lines...) Expand all
595 if (!ShowOnlyKeywordMatch()) { 693 if (!ShowOnlyKeywordMatch()) {
596 canvas->DrawImageInt(GetIcon(), GetMirroredXForRect(icon_bounds_), 694 canvas->DrawImageInt(GetIcon(), GetMirroredXForRect(icon_bounds_),
597 icon_bounds_.y()); 695 icon_bounds_.y());
598 int x = GetMirroredXForRect(text_bounds_); 696 int x = GetMirroredXForRect(text_bounds_);
599 mirroring_context_->Initialize(x, text_bounds_.width()); 697 mirroring_context_->Initialize(x, text_bounds_.width());
600 InitContentsRenderTextIfNecessary(); 698 InitContentsRenderTextIfNecessary();
601 699
602 if (!description_rendertext_) { 700 if (!description_rendertext_) {
603 if (match_.answer) { 701 if (match_.answer) {
604 base::string16 text; 702 base::string16 text;
703 const base::string16 spacer(base::UTF8ToUTF16(" "));
605 for (const auto& textfield : match_.answer->second_line().text_fields()) 704 for (const auto& textfield : match_.answer->second_line().text_fields())
606 text += textfield.text(); 705 text += textfield.text();
706 if (match_.answer->second_line().additional_text()) {
707 text += spacer;
708 text += match_.answer->second_line().additional_text()->text();
709 }
710 if (match_.answer->second_line().status_text())
711 text += match_.answer->second_line().status_text()->text();
607 description_rendertext_ = CreateRenderText(text); 712 description_rendertext_ = CreateRenderText(text);
713 int text_offset = 0;
714 for (const auto& textfield :
715 match_.answer->second_line().text_fields()) {
716 text_offset = StyleAnswerText(description_rendertext_.get(),
717 text_offset, textfield);
718 }
719 if (match_.answer->second_line().additional_text())
720 text_offset = StyleAnswerText(
721 description_rendertext_.get(), text_offset + spacer.length(),
722 *match_.answer->second_line().additional_text());
723 if (match_.answer->second_line().status_text())
724 text_offset =
725 StyleAnswerText(description_rendertext_.get(), text_offset,
726 *match_.answer->second_line().status_text());
608 } else if (!match_.description.empty()) { 727 } else if (!match_.description.empty()) {
609 description_rendertext_ = CreateClassifiedRenderText( 728 description_rendertext_ = CreateClassifiedRenderText(
610 match_.description, match_.description_class, true); 729 match_.description, match_.description_class, true);
611 } 730 }
612 } 731 }
613 PaintMatch(match_, contents_rendertext_.get(), 732 PaintMatch(match_, contents_rendertext_.get(),
614 description_rendertext_.get(), canvas, x); 733 description_rendertext_.get(), canvas, x);
615 } 734 }
616 735
617 AutocompleteMatch* keyword_match = match_.associated_keyword.get(); 736 AutocompleteMatch* keyword_match = match_.associated_keyword.get();
(...skipping 15 matching lines...) Expand all
633 } 752 }
634 PaintMatch(*keyword_match, keyword_contents_rendertext_.get(), 753 PaintMatch(*keyword_match, keyword_contents_rendertext_.get(),
635 keyword_description_rendertext_.get(), canvas, x); 754 keyword_description_rendertext_.get(), canvas, x);
636 } 755 }
637 } 756 }
638 757
639 void OmniboxResultView::AnimationProgressed(const gfx::Animation* animation) { 758 void OmniboxResultView::AnimationProgressed(const gfx::Animation* animation) {
640 Layout(); 759 Layout();
641 SchedulePaint(); 760 SchedulePaint();
642 } 761 }
762
763 int OmniboxResultView::StyleAnswerText(
764 gfx::RenderText* render_text,
765 int offset,
766 const SuggestionAnswer::TextField& text_field) const {
767 int length = text_field.text().length();
768 gfx::Range range(offset, offset + length);
769 const TextStyles& text_style = GetTextStyle(text_field.type());
770 render_text->SetFontList(
771 ui::ResourceBundle::GetSharedInstance().GetFontList(text_style.font));
772 render_text->ApplyColor(
773 GetState() == SELECTED
774 ? GetNativeTheme()->GetSystemColor(text_style.color_selected)
775 : GetNativeTheme()->GetSystemColor(text_style.color),
776 range);
777 render_text->ApplyBaselineStyle(text_style.baseline, range);
778 return offset + length;
779 }
780
781 int OmniboxResultView::GetContentLineHeight() const {
782 return std::max(default_icon_size_ + (kMinimumIconVerticalPadding * 2),
783 GetTextHeight() + (minimum_text_vertical_padding_ * 2));
784 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698