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

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: Renamed some results table vars; cl format 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_ResultsTableNormalText,
127 NativeTheme::kColorId_ResultsTableSelectedText,
128 gfx::NORMAL_BASELINE},
129 // 2 HEADLINE_TEXT
130 {ui::ResourceBundle::LargeFont,
131 NativeTheme::kColorId_ResultsTableNormalDimmedText,
132 NativeTheme::kColorId_ResultsTableSelectedDimmedText,
133 gfx::NORMAL_BASELINE},
134 // 3 TOP_ALIGNED_TEXT
135 {ui::ResourceBundle::LargeFont,
136 NativeTheme::kColorId_ResultsTableNormalDimmedText,
137 NativeTheme::kColorId_ResultsTableSelectedDimmedText,
138 gfx::SUPERIOR},
139 // 4 DESCRIPTION_TEXT
140 {ui::ResourceBundle::BaseFont,
141 NativeTheme::kColorId_ResultsTableNormalDimmedText,
142 NativeTheme::kColorId_ResultsTableSelectedDimmedText,
143 gfx::NORMAL_BASELINE},
144 // 5 DESCRIPTION_TEXT_NEGATIVE
145 {ui::ResourceBundle::LargeFont,
146 NativeTheme::kColorId_ResultsTableNegativeText,
Peter Kasting 2015/03/14 02:12:25 Your original CL used a dimmer shade of red/green
dschuyler 2015/03/16 21:49:09 That may come up again. Like the comment about th
147 NativeTheme::kColorId_ResultsTableNegativeSelectedText,
148 gfx::INFERIOR},
149 // 6 DESCRIPTION_TEXT_POSITIVE
150 {ui::ResourceBundle::LargeFont,
151 NativeTheme::kColorId_ResultsTablePositiveText,
152 NativeTheme::kColorId_ResultsTablePositiveSelectedText,
153 gfx::INFERIOR},
154 // 7 MORE_INFO_TEXT
155 {ui::ResourceBundle::SmallFont,
156 NativeTheme::kColorId_ResultsTableNormalDimmedText,
157 NativeTheme::kColorId_ResultsTableSelectedDimmedText,
158 gfx::NORMAL_BASELINE},
159 // 8 SUGGESTION_TEXT
160 {ui::ResourceBundle::BaseFont,
161 NativeTheme::kColorId_ResultsTableNormalText,
162 NativeTheme::kColorId_ResultsTableSelectedText,
163 gfx::NORMAL_BASELINE},
164 // 9 SUGGESTION_TEXT_POSITIVE
165 {ui::ResourceBundle::BaseFont,
166 NativeTheme::kColorId_ResultsTablePositiveText,
167 NativeTheme::kColorId_ResultsTablePositiveSelectedText,
168 gfx::NORMAL_BASELINE},
169 // 10 SUGGESTION_TEXT_NEGATIVE
170 {ui::ResourceBundle::BaseFont,
171 NativeTheme::kColorId_ResultsTableNegativeText,
172 NativeTheme::kColorId_ResultsTableNegativeSelectedText,
173 gfx::NORMAL_BASELINE},
174 // 11 SUGGESTION_LINK_COLOR
175 {ui::ResourceBundle::BaseFont,
176 NativeTheme::kColorId_ResultsTableNormalUrl,
177 NativeTheme::kColorId_ResultsTableSelectedUrl,
178 gfx::NORMAL_BASELINE},
179 // 12 STATUS_TEXT
180 {ui::ResourceBundle::LargeFont,
181 NativeTheme::kColorId_ResultsTableNormalDimmedText,
182 NativeTheme::kColorId_ResultsTableSelectedDimmedText,
183 gfx::INFERIOR},
184 // 13 PERSONALIZED_SUGGESTION_TEXT
185 {ui::ResourceBundle::BaseFont,
186 NativeTheme::kColorId_ResultsTableNormalDimmedText,
Peter Kasting 2015/03/14 02:12:25 I think you want to use the same colors as SUGGEST
dschuyler 2015/03/16 21:49:09 I changed it to be the same color as suggestion te
187 NativeTheme::kColorId_ResultsTableSelectedDimmedText,
188 gfx::NORMAL_BASELINE},
189 };
190
191 const TextStyles& GetTextStyle(int type) {
192 if (type > (int)arraysize(kTextStyles))
Peter Kasting 2015/03/14 01:54:14 No C-style casts. If you're going to take ints he
dschuyler 2015/03/16 21:49:09 Done.
193 type = 1;
194 // Subtract one because the types are one based (not zero based).
195 return kTextStyles[(type - 1)];
Peter Kasting 2015/03/14 01:54:14 Nit: No {}
dschuyler 2015/03/16 21:49:09 I'm reading that as No () Done.
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() + GetAnswerLineHeight());
256 } 340 }
257 341
258 //////////////////////////////////////////////////////////////////////////////// 342 ////////////////////////////////////////////////////////////////////////////////
259 // OmniboxResultView, protected: 343 // OmniboxResultView, protected:
260 344
261 OmniboxResultView::ResultViewState OmniboxResultView::GetState() const { 345 OmniboxResultView::ResultViewState OmniboxResultView::GetState() const {
262 if (model_->IsSelectedIndex(model_index_)) 346 if (model_->IsSelectedIndex(model_index_))
263 return SELECTED; 347 return SELECTED;
264 return model_->IsHoveredIndex(model_index_) ? HOVERED : NORMAL; 348 return model_->IsHoveredIndex(model_index_) ? HOVERED : NORMAL;
265 } 349 }
(...skipping 20 matching lines...) Expand all
286 int contents_max_width, description_max_width; 370 int contents_max_width, description_max_width;
287 OmniboxPopupModel::ComputeMatchMaxWidths( 371 OmniboxPopupModel::ComputeMatchMaxWidths(
288 contents->GetContentWidth(), 372 contents->GetContentWidth(),
289 separator_width_, 373 separator_width_,
290 description ? description->GetContentWidth() : 0, 374 description ? description->GetContentWidth() : 0,
291 mirroring_context_->remaining_width(x), 375 mirroring_context_->remaining_width(x),
292 !AutocompleteMatch::IsSearchType(match.type), 376 !AutocompleteMatch::IsSearchType(match.type),
293 &contents_max_width, 377 &contents_max_width,
294 &description_max_width); 378 &description_max_width);
295 379
296 x = DrawRenderText(match, contents, true, canvas, x, y, contents_max_width); 380 int after_contents_x =
381 DrawRenderText(match, contents, true, canvas, x, y, contents_max_width);
297 382
298 if (description_max_width != 0) { 383 if (description_max_width != 0) {
299 x = DrawRenderText(match, separator_rendertext_.get(), false, canvas, x, y, 384 if (match.answer) {
300 separator_width_); 385 y += GetContentLineHeight();
301 386 if (!answer_image_.isNull()) {
302 if (!answer_image_.isNull()) { 387 // Add one to draw all the way on to the bottom and left pixels.
303 canvas->DrawImageInt(answer_image_, 388 // i.e. make the destination rect <= rather than strictly less than.
304 // Source x, y, w, h. 389 int answer_icon_size = 1 + GetAnswerLineHeight();
Peter Kasting 2015/03/14 01:54:14 This seems wrong. If the answer line height is, f
dschuyler 2015/03/16 21:49:09 After some internal reflection, I think I simply f
305 0, 0, answer_image_.width(), answer_image_.height(), 390 canvas->DrawImageInt(
306 // Destination x, y, w, h. 391 answer_image_,
307 GetMirroredXInView(x), 392 // Source x, y, w, h.
308 y + kMinimumIconVerticalPadding, default_icon_size_, 393 0, 0, answer_image_.width(), answer_image_.height(),
309 default_icon_size_, true); 394 // Destination x, y, w, h.
310 x += default_icon_size_ + LocationBarView::kIconInternalPadding; 395 GetMirroredXInView(x), y, answer_icon_size, answer_icon_size, true);
396 x += answer_icon_size + LocationBarView::kIconInternalPadding;
397 }
398 } else {
399 x = DrawRenderText(match, separator_rendertext_.get(), false, canvas,
400 after_contents_x, y, separator_width_);
311 } 401 }
312 402
313 DrawRenderText(match, description, false, canvas, x, y, 403 DrawRenderText(match, description, false, canvas, x, y,
314 description_max_width); 404 description_max_width);
315 } 405 }
316 } 406 }
317 407
318 int OmniboxResultView::DrawRenderText( 408 int OmniboxResultView::DrawRenderText(
319 const AutocompleteMatch& match, 409 const AutocompleteMatch& match,
320 gfx::RenderText* render_text, 410 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, 461 const int start_offset = std::max(prefix_width,
372 std::min(remaining_width - max_match_contents_width, offset)); 462 std::min(remaining_width - max_match_contents_width, offset));
373 right_x = x + std::min(remaining_width, start_offset + max_width); 463 right_x = x + std::min(remaining_width, start_offset + max_width);
374 x += start_offset; 464 x += start_offset;
375 prefix_x = x - prefix_width; 465 prefix_x = x - prefix_width;
376 } 466 }
377 prefix_render_text->SetDirectionalityMode(is_match_contents_rtl ? 467 prefix_render_text->SetDirectionalityMode(is_match_contents_rtl ?
378 gfx::DIRECTIONALITY_FORCE_RTL : gfx::DIRECTIONALITY_FORCE_LTR); 468 gfx::DIRECTIONALITY_FORCE_RTL : gfx::DIRECTIONALITY_FORCE_LTR);
379 prefix_render_text->SetHorizontalAlignment( 469 prefix_render_text->SetHorizontalAlignment(
380 is_match_contents_rtl ? gfx::ALIGN_RIGHT : gfx::ALIGN_LEFT); 470 is_match_contents_rtl ? gfx::ALIGN_RIGHT : gfx::ALIGN_LEFT);
381 prefix_render_text->SetDisplayRect(gfx::Rect( 471 prefix_render_text->SetDisplayRect(
382 mirroring_context_->mirrored_left_coord( 472 gfx::Rect(mirroring_context_->mirrored_left_coord(
383 prefix_x, prefix_x + prefix_width), y, 473 prefix_x, prefix_x + prefix_width),
384 prefix_width, height())); 474 y, prefix_width, GetContentLineHeight()));
385 prefix_render_text->Draw(canvas); 475 prefix_render_text->Draw(canvas);
386 } 476 }
387 477
388 // Set the display rect to trigger eliding. 478 // Set the display rect to trigger eliding.
389 render_text->SetDisplayRect(gfx::Rect( 479 render_text->SetDisplayRect(
390 mirroring_context_->mirrored_left_coord(x, right_x), y, 480 gfx::Rect(mirroring_context_->mirrored_left_coord(x, right_x), y,
391 right_x - x, height())); 481 right_x - x, GetContentLineHeight()));
392 render_text->Draw(canvas); 482 render_text->Draw(canvas);
393 return right_x; 483 return right_x;
394 } 484 }
395 485
396 scoped_ptr<gfx::RenderText> OmniboxResultView::CreateRenderText( 486 scoped_ptr<gfx::RenderText> OmniboxResultView::CreateRenderText(
397 const base::string16& text) const { 487 const base::string16& text) const {
398 scoped_ptr<gfx::RenderText> render_text(gfx::RenderText::CreateInstance()); 488 scoped_ptr<gfx::RenderText> render_text(gfx::RenderText::CreateInstance());
399 render_text->SetDisplayRect(gfx::Rect(gfx::Size(INT_MAX, 0))); 489 render_text->SetDisplayRect(gfx::Rect(gfx::Size(INT_MAX, 0)));
400 render_text->SetCursorEnabled(false); 490 render_text->SetCursorEnabled(false);
401 render_text->SetElideBehavior(gfx::ELIDE_TAIL); 491 render_text->SetElideBehavior(gfx::ELIDE_TAIL);
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
547 if (!contents_rendertext_) { 637 if (!contents_rendertext_) {
548 contents_rendertext_.reset( 638 contents_rendertext_.reset(
549 CreateClassifiedRenderText( 639 CreateClassifiedRenderText(
550 match_.contents, match_.contents_class, false).release()); 640 match_.contents, match_.contents_class, false).release());
551 } 641 }
552 } 642 }
553 643
554 void OmniboxResultView::Layout() { 644 void OmniboxResultView::Layout() {
555 const gfx::ImageSkia icon = GetIcon(); 645 const gfx::ImageSkia icon = GetIcon();
556 646
557 icon_bounds_.SetRect(edge_item_padding_ + 647 icon_bounds_.SetRect(
558 ((icon.width() == default_icon_size_) ? 648 edge_item_padding_ + ((icon.width() == default_icon_size_)
559 0 : LocationBarView::kIconInternalPadding), 649 ? 0
560 (height() - icon.height()) / 2, icon.width(), icon.height()); 650 : LocationBarView::kIconInternalPadding),
651 (GetContentLineHeight() - icon.height()) / 2, icon.width(),
652 icon.height());
561 653
562 int text_x = edge_item_padding_ + default_icon_size_ + item_padding_; 654 int text_x = edge_item_padding_ + default_icon_size_ + item_padding_;
563 int text_width = width() - text_x - edge_item_padding_; 655 int text_width = width() - text_x - edge_item_padding_;
564 656
565 if (match_.associated_keyword.get()) { 657 if (match_.associated_keyword.get()) {
566 const int kw_collapsed_size = 658 const int kw_collapsed_size =
567 keyword_icon_->width() + edge_item_padding_; 659 keyword_icon_->width() + edge_item_padding_;
568 const int max_kw_x = width() - kw_collapsed_size; 660 const int max_kw_x = width() - kw_collapsed_size;
569 const int kw_x = 661 const int kw_x =
570 animation_->CurrentValueBetween(max_kw_x, edge_item_padding_); 662 animation_->CurrentValueBetween(max_kw_x, edge_item_padding_);
(...skipping 24 matching lines...) Expand all
595 if (!ShowOnlyKeywordMatch()) { 687 if (!ShowOnlyKeywordMatch()) {
596 canvas->DrawImageInt(GetIcon(), GetMirroredXForRect(icon_bounds_), 688 canvas->DrawImageInt(GetIcon(), GetMirroredXForRect(icon_bounds_),
597 icon_bounds_.y()); 689 icon_bounds_.y());
598 int x = GetMirroredXForRect(text_bounds_); 690 int x = GetMirroredXForRect(text_bounds_);
599 mirroring_context_->Initialize(x, text_bounds_.width()); 691 mirroring_context_->Initialize(x, text_bounds_.width());
600 InitContentsRenderTextIfNecessary(); 692 InitContentsRenderTextIfNecessary();
601 693
602 if (!description_rendertext_) { 694 if (!description_rendertext_) {
603 if (match_.answer) { 695 if (match_.answer) {
604 base::string16 text; 696 base::string16 text;
697 const base::string16 spacer(base::UTF8ToUTF16(" "));
605 for (const auto& textfield : match_.answer->second_line().text_fields()) 698 for (const auto& textfield : match_.answer->second_line().text_fields())
606 text += textfield.text(); 699 text += textfield.text();
700 if (match_.answer->second_line().additional_text()) {
701 text += spacer;
702 text += match_.answer->second_line().additional_text()->text();
703 }
704 if (match_.answer->second_line().status_text())
705 text += match_.answer->second_line().status_text()->text();
607 description_rendertext_ = CreateRenderText(text); 706 description_rendertext_ = CreateRenderText(text);
707 int text_offset = 0;
708 for (const auto& textfield :
709 match_.answer->second_line().text_fields()) {
710 text_offset = StyleAnswerText(description_rendertext_.get(),
711 text_offset, textfield);
712 }
713 if (match_.answer->second_line().additional_text())
714 text_offset = StyleAnswerText(
715 description_rendertext_.get(), text_offset + spacer.length(),
716 *match_.answer->second_line().additional_text());
717 if (match_.answer->second_line().status_text())
718 text_offset =
719 StyleAnswerText(description_rendertext_.get(), text_offset,
720 *match_.answer->second_line().status_text());
608 } else if (!match_.description.empty()) { 721 } else if (!match_.description.empty()) {
609 description_rendertext_ = CreateClassifiedRenderText( 722 description_rendertext_ = CreateClassifiedRenderText(
610 match_.description, match_.description_class, true); 723 match_.description, match_.description_class, true);
611 } 724 }
612 } 725 }
613 PaintMatch(match_, contents_rendertext_.get(), 726 PaintMatch(match_, contents_rendertext_.get(),
614 description_rendertext_.get(), canvas, x); 727 description_rendertext_.get(), canvas, x);
615 } 728 }
616 729
617 AutocompleteMatch* keyword_match = match_.associated_keyword.get(); 730 AutocompleteMatch* keyword_match = match_.associated_keyword.get();
(...skipping 15 matching lines...) Expand all
633 } 746 }
634 PaintMatch(*keyword_match, keyword_contents_rendertext_.get(), 747 PaintMatch(*keyword_match, keyword_contents_rendertext_.get(),
635 keyword_description_rendertext_.get(), canvas, x); 748 keyword_description_rendertext_.get(), canvas, x);
636 } 749 }
637 } 750 }
638 751
639 void OmniboxResultView::AnimationProgressed(const gfx::Animation* animation) { 752 void OmniboxResultView::AnimationProgressed(const gfx::Animation* animation) {
640 Layout(); 753 Layout();
641 SchedulePaint(); 754 SchedulePaint();
642 } 755 }
756
757 int OmniboxResultView::StyleAnswerText(
758 gfx::RenderText* render_text,
759 int offset,
760 const SuggestionAnswer::TextField& text_field) const {
761 int length = text_field.text().length();
762 gfx::Range range(offset, offset + length);
763 const TextStyles& text_style = GetTextStyle(text_field.type());
764 render_text->SetFontList(
765 ui::ResourceBundle::GetSharedInstance().GetFontList(text_style.font));
766 render_text->ApplyColor(
767 GetState() == SELECTED
Peter Kasting 2015/03/14 01:54:14 Don't you want to deal with HOVERED here too? Aft
dschuyler 2015/03/16 21:49:09 I wasn't sure why the existing code sometimes igno
768 ? GetNativeTheme()->GetSystemColor(text_style.color_selected)
769 : GetNativeTheme()->GetSystemColor(text_style.color),
770 range);
771 render_text->ApplyBaselineStyle(text_style.baseline, range);
772 return offset + length;
773 }
774
775 int OmniboxResultView::GetAnswerLineHeight() const {
776 // GetTextStyle(1) is (one of) the largest fonts used, so it's a good
777 // reference for line height.
Peter Kasting 2015/03/14 01:54:14 Isn't it more that (1) is used in basically every
dschuyler 2015/03/16 21:49:09 That sounds correct. I think that's saying someth
778 return ui::ResourceBundle::GetSharedInstance()
779 .GetFontList(GetTextStyle(1).font)
780 .GetHeight();
781 }
782
783 int OmniboxResultView::GetContentLineHeight() const {
784 return std::max(default_icon_size_ + (kMinimumIconVerticalPadding * 2),
785 GetTextHeight() + (minimum_text_vertical_padding_ * 2));
786 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698