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

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

Issue 2365263006: Delete pre-MD code from OmniboxResultView (Closed)
Patch Set: update references to constant (merge resolution) Created 4 years, 2 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 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
11 #endif 11 #endif
12 12
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "chrome/browser/ui/views/omnibox/omnibox_result_view.h" 14 #include "chrome/browser/ui/views/omnibox/omnibox_result_view.h"
15 15
16 #include <limits.h> 16 #include <limits.h>
17 17
18 #include <algorithm> // NOLINT 18 #include <algorithm> // NOLINT
19 19
20 #include "base/i18n/bidi_line_iterator.h" 20 #include "base/i18n/bidi_line_iterator.h"
21 #include "base/strings/string_number_conversions.h" 21 #include "base/strings/string_number_conversions.h"
22 #include "base/strings/string_util.h" 22 #include "base/strings/string_util.h"
23 #include "chrome/browser/ui/layout_constants.h" 23 #include "chrome/browser/ui/layout_constants.h"
24 #include "chrome/browser/ui/views/location_bar/background_with_1_px_border.h" 24 #include "chrome/browser/ui/views/location_bar/background_with_1_px_border.h"
25 #include "chrome/browser/ui/views/location_bar/icon_label_bubble_view.h"
26 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" 25 #include "chrome/browser/ui/views/location_bar/location_bar_view.h"
27 #include "chrome/browser/ui/views/omnibox/omnibox_popup_contents_view.h" 26 #include "chrome/browser/ui/views/omnibox/omnibox_popup_contents_view.h"
28 #include "chrome/grit/generated_resources.h" 27 #include "chrome/grit/generated_resources.h"
29 #include "chrome/grit/theme_resources.h"
30 #include "components/grit/components_scaled_resources.h" 28 #include "components/grit/components_scaled_resources.h"
31 #include "components/omnibox/browser/omnibox_popup_model.h" 29 #include "components/omnibox/browser/omnibox_popup_model.h"
32 #include "third_party/skia/include/core/SkColor.h" 30 #include "third_party/skia/include/core/SkColor.h"
33 #include "ui/accessibility/ax_view_state.h" 31 #include "ui/accessibility/ax_view_state.h"
34 #include "ui/base/l10n/l10n_util.h" 32 #include "ui/base/l10n/l10n_util.h"
35 #include "ui/base/material_design/material_design_controller.h"
36 #include "ui/base/resource/resource_bundle.h" 33 #include "ui/base/resource/resource_bundle.h"
37 #include "ui/base/theme_provider.h" 34 #include "ui/base/theme_provider.h"
38 #include "ui/gfx/canvas.h" 35 #include "ui/gfx/canvas.h"
39 #include "ui/gfx/color_palette.h" 36 #include "ui/gfx/color_palette.h"
40 #include "ui/gfx/color_utils.h" 37 #include "ui/gfx/color_utils.h"
41 #include "ui/gfx/image/image.h" 38 #include "ui/gfx/image/image.h"
42 #include "ui/gfx/paint_vector_icon.h" 39 #include "ui/gfx/paint_vector_icon.h"
43 #include "ui/gfx/range/range.h" 40 #include "ui/gfx/range/range.h"
44 #include "ui/gfx/render_text.h" 41 #include "ui/gfx/render_text.h"
45 #include "ui/gfx/scoped_canvas.h"
46 #include "ui/gfx/text_utils.h" 42 #include "ui/gfx/text_utils.h"
47 #include "ui/gfx/vector_icons_public.h" 43 #include "ui/gfx/vector_icons_public.h"
48 #include "ui/native_theme/native_theme.h" 44 #include "ui/native_theme/native_theme.h"
49 45
50 using ui::NativeTheme; 46 using ui::NativeTheme;
51 47
52 namespace { 48 namespace {
53 49
54 // A mapping from OmniboxResultView's ResultViewState/ColorKind types to 50 // A mapping from OmniboxResultView's ResultViewState/ColorKind types to
55 // NativeTheme colors. 51 // NativeTheme colors.
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 177
182 private: 178 private:
183 int center_; 179 int center_;
184 int right_; 180 int right_;
185 181
186 DISALLOW_COPY_AND_ASSIGN(MirroringContext); 182 DISALLOW_COPY_AND_ASSIGN(MirroringContext);
187 }; 183 };
188 184
189 OmniboxResultView::OmniboxResultView(OmniboxPopupContentsView* model, 185 OmniboxResultView::OmniboxResultView(OmniboxPopupContentsView* model,
190 int model_index, 186 int model_index,
191 LocationBarView* location_bar_view,
192 const gfx::FontList& font_list) 187 const gfx::FontList& font_list)
193 : model_(model), 188 : model_(model),
194 model_index_(model_index), 189 model_index_(model_index),
195 location_bar_view_(location_bar_view),
196 font_list_(font_list), 190 font_list_(font_list),
197 font_height_(std::max( 191 font_height_(std::max(
198 font_list.GetHeight(), 192 font_list.GetHeight(),
199 font_list.DeriveWithWeight(gfx::Font::Weight::BOLD).GetHeight())), 193 font_list.DeriveWithWeight(gfx::Font::Weight::BOLD).GetHeight())),
200 mirroring_context_(new MirroringContext()), 194 mirroring_context_(new MirroringContext()),
201 keyword_icon_(new views::ImageView()), 195 keyword_icon_(new views::ImageView()),
202 animation_(new gfx::SlideAnimation(this)) { 196 animation_(new gfx::SlideAnimation(this)) {
203 CHECK_GE(model_index, 0); 197 CHECK_GE(model_index, 0);
204 if (default_icon_size_ == 0)
205 default_icon_size_ = LocationBarView::kIconWidth;
206 keyword_icon_->set_owned_by_client(); 198 keyword_icon_->set_owned_by_client();
207 keyword_icon_->EnableCanvasFlippingForRTLUI(true); 199 keyword_icon_->EnableCanvasFlippingForRTLUI(true);
208 keyword_icon_->SetImage(GetKeywordIcon()); 200 keyword_icon_->SetImage(
201 GetVectorIcon(gfx::VectorIconId::OMNIBOX_KEYWORD_SEARCH));
209 keyword_icon_->SizeToPreferredSize(); 202 keyword_icon_->SizeToPreferredSize();
210 } 203 }
211 204
212 OmniboxResultView::~OmniboxResultView() { 205 OmniboxResultView::~OmniboxResultView() {
213 } 206 }
214 207
215 SkColor OmniboxResultView::GetColor( 208 SkColor OmniboxResultView::GetColor(
216 ResultViewState state, 209 ResultViewState state,
217 ColorKind kind) const { 210 ColorKind kind) const {
218 for (size_t i = 0; i < arraysize(kTranslationTable); ++i) { 211 for (size_t i = 0; i < arraysize(kTranslationTable); ++i) {
(...skipping 27 matching lines...) Expand all
246 } 239 }
247 240
248 void OmniboxResultView::ShowKeyword(bool show_keyword) { 241 void OmniboxResultView::ShowKeyword(bool show_keyword) {
249 if (show_keyword) 242 if (show_keyword)
250 animation_->Show(); 243 animation_->Show();
251 else 244 else
252 animation_->Hide(); 245 animation_->Hide();
253 } 246 }
254 247
255 void OmniboxResultView::Invalidate() { 248 void OmniboxResultView::Invalidate() {
256 if (ui::MaterialDesignController::IsModeMaterial()) { 249 const ResultViewState state = GetState();
257 const ResultViewState state = GetState(); 250 if (state == NORMAL) {
258 if (state == NORMAL) { 251 set_background(nullptr);
259 set_background(nullptr); 252 } else {
260 } else { 253 const SkColor bg_color = GetColor(state, BACKGROUND);
261 const SkColor bg_color = GetColor(state, BACKGROUND); 254 set_background(new BackgroundWith1PxBorder(bg_color, bg_color));
262 set_background(new BackgroundWith1PxBorder(bg_color, bg_color));
263 }
264 } 255 }
265 256
266 keyword_icon_->SetImage(GetKeywordIcon());
267
268 // While the text in the RenderTexts may not have changed, the styling 257 // While the text in the RenderTexts may not have changed, the styling
269 // (color/bold) may need to change. So we reset them to cause them to be 258 // (color/bold) may need to change. So we reset them to cause them to be
270 // recomputed in OnPaint(). 259 // recomputed in OnPaint().
271 contents_rendertext_.reset(); 260 contents_rendertext_.reset();
272 description_rendertext_.reset(); 261 description_rendertext_.reset();
273 separator_rendertext_.reset(); 262 separator_rendertext_.reset();
274 keyword_contents_rendertext_.reset(); 263 keyword_contents_rendertext_.reset();
275 keyword_description_rendertext_.reset(); 264 keyword_description_rendertext_.reset();
276 } 265 }
277 266
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
496 text_length; 485 text_length;
497 const gfx::Range current_range(text_start, text_end); 486 const gfx::Range current_range(text_start, text_end);
498 487
499 // Calculate style-related data. 488 // Calculate style-related data.
500 if (classifications[i].style & ACMatchClassification::MATCH) 489 if (classifications[i].style & ACMatchClassification::MATCH)
501 render_text->ApplyWeight(gfx::Font::Weight::BOLD, current_range); 490 render_text->ApplyWeight(gfx::Font::Weight::BOLD, current_range);
502 491
503 ColorKind color_kind = TEXT; 492 ColorKind color_kind = TEXT;
504 if (classifications[i].style & ACMatchClassification::URL) { 493 if (classifications[i].style & ACMatchClassification::URL) {
505 color_kind = URL; 494 color_kind = URL;
506 // Consider logical string for domain "ABC.com×™/hello" where ABC are 495 // Consider logical string for domain "ABC.com/hello" where ABC are
507 // Hebrew (RTL) characters. This string should ideally show as 496 // Hebrew (RTL) characters. This string should ideally show as
508 // "CBA.com/hello". If we do not force LTR on URL, it will appear as 497 // "CBA.com/hello". If we do not force LTR on URL, it will appear as
509 // "com/hello.CBA". 498 // "com/hello.CBA".
510 // With IDN and RTL TLDs, it might be okay to allow RTL rendering of URLs, 499 // With IDN and RTL TLDs, it might be okay to allow RTL rendering of URLs,
511 // but it still has some pitfalls like : 500 // but it still has some pitfalls like :
512 // ABC.COM/abc-pqr/xyz/FGH will appear as HGF/abc-pqr/xyz/MOC.CBA which 501 // ABC.COM/abc-pqr/xyz/FGH will appear as HGF/abc-pqr/xyz/MOC.CBA which
513 // really confuses the path hierarchy of the URL. 502 // really confuses the path hierarchy of the URL.
514 // Also, if the URL supports https, the appearance will change into LTR 503 // Also, if the URL supports https, the appearance will change into LTR
515 // directionality. 504 // directionality.
516 // In conclusion, LTR rendering of URL is probably the safest bet. 505 // In conclusion, LTR rendering of URL is probably the safest bet.
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
555 const gfx::Range& glyph_bounds = 544 const gfx::Range& glyph_bounds =
556 input_render_text->GetGlyphBounds(contents_start_index); 545 input_render_text->GetGlyphBounds(contents_start_index);
557 const int start_padding = is_match_contents_rtl ? 546 const int start_padding = is_match_contents_rtl ?
558 std::max(glyph_bounds.start(), glyph_bounds.end()) : 547 std::max(glyph_bounds.start(), glyph_bounds.end()) :
559 std::min(glyph_bounds.start(), glyph_bounds.end()); 548 std::min(glyph_bounds.start(), glyph_bounds.end());
560 549
561 return is_ui_rtl ? 550 return is_ui_rtl ?
562 (input_render_text->GetContentWidth() - start_padding) : start_padding; 551 (input_render_text->GetContentWidth() - start_padding) : start_padding;
563 } 552 }
564 553
565 // static
566 int OmniboxResultView::default_icon_size_ = 0;
567
568 const char* OmniboxResultView::GetClassName() const { 554 const char* OmniboxResultView::GetClassName() const {
569 return "OmniboxResultView"; 555 return "OmniboxResultView";
570 } 556 }
571 557
572 gfx::ImageSkia OmniboxResultView::GetIcon() const { 558 gfx::ImageSkia OmniboxResultView::GetIcon() const {
573 const gfx::Image image = model_->GetIconIfExtensionMatch(model_index_); 559 const gfx::Image image = model_->GetIconIfExtensionMatch(model_index_);
574 if (!image.IsEmpty()) 560 if (!image.IsEmpty())
575 return image.AsImageSkia(); 561 return image.AsImageSkia();
576 562
577 if (ui::MaterialDesignController::IsModeMaterial()) { 563 return GetVectorIcon(
578 return GetVectorIcon( 564 model_->IsStarredMatch(match_)
579 model_->IsStarredMatch(match_) 565 ? gfx::VectorIconId::OMNIBOX_STAR
580 ? gfx::VectorIconId::OMNIBOX_STAR 566 : AutocompleteMatch::TypeToVectorIcon(match_.type));
581 : AutocompleteMatch::TypeToVectorIcon(match_.type));
582 }
583
584 int icon = model_->IsStarredMatch(match_) ?
585 IDR_OMNIBOX_STAR : AutocompleteMatch::TypeToIcon(match_.type);
586 if (GetState() == SELECTED) {
587 switch (icon) {
588 case IDR_OMNIBOX_CALCULATOR:
589 icon = IDR_OMNIBOX_CALCULATOR_SELECTED;
590 break;
591 case IDR_OMNIBOX_EXTENSION_APP:
592 icon = IDR_OMNIBOX_EXTENSION_APP_SELECTED;
593 break;
594 case IDR_OMNIBOX_HTTP:
595 icon = IDR_OMNIBOX_HTTP_SELECTED;
596 break;
597 case IDR_OMNIBOX_SEARCH:
598 icon = IDR_OMNIBOX_SEARCH_SELECTED;
599 break;
600 case IDR_OMNIBOX_STAR:
601 icon = IDR_OMNIBOX_STAR_SELECTED;
602 break;
603 default:
604 NOTREACHED();
605 break;
606 }
607 }
608 return *location_bar_view_->GetThemeProvider()->GetImageSkiaNamed(icon);
609 }
610
611 gfx::ImageSkia OmniboxResultView::GetKeywordIcon() const {
612 if (ui::MaterialDesignController::IsModeMaterial())
613 return GetVectorIcon(gfx::VectorIconId::OMNIBOX_KEYWORD_SEARCH);
614
615 // NOTE: If we ever begin returning icons of varying size, then callers need
616 // to ensure that |keyword_icon_| is resized each time its image is reset.
617 int icon = IDR_OMNIBOX_TTS;
618 if (GetState() == SELECTED)
619 icon = IDR_OMNIBOX_TTS_SELECTED;
620
621 return *location_bar_view_->GetThemeProvider()->GetImageSkiaNamed(icon);
622 } 567 }
623 568
624 gfx::ImageSkia OmniboxResultView::GetVectorIcon( 569 gfx::ImageSkia OmniboxResultView::GetVectorIcon(
625 gfx::VectorIconId icon_id) const { 570 gfx::VectorIconId icon_id) const {
626 // For selected rows, paint the icon the same color as the text. 571 // For selected rows, paint the icon the same color as the text.
627 SkColor color = GetColor(GetState(), TEXT); 572 SkColor color = GetColor(GetState(), TEXT);
628 if (GetState() != SELECTED) 573 if (GetState() != SELECTED)
629 color = color_utils::DeriveDefaultIconColor(color); 574 color = color_utils::DeriveDefaultIconColor(color);
630 return gfx::CreateVectorIcon(icon_id, 16, color); 575 return gfx::CreateVectorIcon(icon_id, 16, color);
631 } 576 }
632 577
633 bool OmniboxResultView::ShowOnlyKeywordMatch() const { 578 bool OmniboxResultView::ShowOnlyKeywordMatch() const {
634 return match_.associated_keyword && 579 return match_.associated_keyword &&
635 (keyword_icon_->x() <= icon_bounds_.right()); 580 (keyword_icon_->x() <= icon_bounds_.right());
636 } 581 }
637 582
638 void OmniboxResultView::InitContentsRenderTextIfNecessary() const { 583 void OmniboxResultView::InitContentsRenderTextIfNecessary() const {
639 if (!contents_rendertext_) { 584 if (!contents_rendertext_) {
640 contents_rendertext_.reset( 585 contents_rendertext_.reset(
641 CreateClassifiedRenderText( 586 CreateClassifiedRenderText(
642 match_.contents, match_.contents_class, false).release()); 587 match_.contents, match_.contents_class, false).release());
643 } 588 }
644 } 589 }
645 590
646 void OmniboxResultView::Layout() { 591 void OmniboxResultView::Layout() {
647 int horizontal_padding = 592 int horizontal_padding =
648 GetLayoutConstant(LOCATION_BAR_HORIZONTAL_PADDING); 593 GetLayoutConstant(LOCATION_BAR_HORIZONTAL_PADDING);
649 // In non-material, the horizontal bounds we're given are indented inside the 594 // The horizontal bounds we're given are the outside bounds, so we can match
650 // omnibox border. In material, we're given the outside bounds, so we can 595 // the omnibox border outline shape exactly in OnPaint(). We have to inset
651 // match the omnibox border outline shape exactly in OnPaint(). So we have to 596 // here to keep the icons lined up.
652 // inset here to keep the icons lined up. 597 const int start_x =
653 const int border_padding = ui::MaterialDesignController::IsModeMaterial() ? 598 GetLayoutConstant(LOCATION_BAR_BORDER_THICKNESS) + horizontal_padding;
654 GetLayoutConstant(LOCATION_BAR_BORDER_THICKNESS) : 0; 599 const int end_x = width() - start_x;
655 const int start_x = border_padding + horizontal_padding;
656 const int end_x = width() - border_padding - horizontal_padding;
657 600
658 const gfx::ImageSkia icon = GetIcon(); 601 const gfx::ImageSkia icon = GetIcon();
659 // Pre-MD, normal icons are 19 px wide, while extension icons are 16 px wide. 602 icon_bounds_.SetRect(start_x, (GetContentLineHeight() - icon.height()) / 2,
660 // The code in IconLabelBubbleView::Layout() positions these icons in the
661 // omnibox using ICON_LABEL_VIEW_TRAILING_PADDING, so we use that here as well
662 // so the icons will line up.
663 //
664 // Technically we don't need the IsModeMaterial() check here, but it will make
665 // it easier to see that all this code is dead once we switch to MD.
666 int icon_x = start_x;
667 if (!ui::MaterialDesignController::IsModeMaterial() &&
668 (icon.width() != default_icon_size_))
669 icon_x += IconLabelBubbleView::kTrailingPaddingPreMd;
670 icon_bounds_.SetRect(icon_x, (GetContentLineHeight() - icon.height()) / 2,
671 icon.width(), icon.height()); 603 icon.width(), icon.height());
672 604
673 const int text_x = start_x + default_icon_size_ + horizontal_padding; 605 const int text_x = start_x + LocationBarView::kIconWidth + horizontal_padding;
674 int text_width = end_x - text_x; 606 int text_width = end_x - text_x;
675 607
676 if (match_.associated_keyword.get()) { 608 if (match_.associated_keyword.get()) {
677 const int max_kw_x = end_x - keyword_icon_->width(); 609 const int max_kw_x = end_x - keyword_icon_->width();
678 const int kw_x = animation_->CurrentValueBetween(max_kw_x, start_x); 610 const int kw_x = animation_->CurrentValueBetween(max_kw_x, start_x);
679 const int kw_text_x = kw_x + keyword_icon_->width() + horizontal_padding; 611 const int kw_text_x = kw_x + keyword_icon_->width() + horizontal_padding;
680 612
681 text_width = kw_x - text_x - horizontal_padding; 613 text_width = kw_x - text_x - horizontal_padding;
682 keyword_text_bounds_.SetRect( 614 keyword_text_bounds_.SetRect(
683 kw_text_x, 0, std::max(end_x - kw_text_x, 0), height()); 615 kw_text_x, 0, std::max(end_x - kw_text_x, 0), height());
684 keyword_icon_->SetPosition( 616 keyword_icon_->SetPosition(
685 gfx::Point(kw_x, (height() - keyword_icon_->height()) / 2)); 617 gfx::Point(kw_x, (height() - keyword_icon_->height()) / 2));
686 } 618 }
687 619
688 text_bounds_.SetRect(text_x, 0, std::max(text_width, 0), height()); 620 text_bounds_.SetRect(text_x, 0, std::max(text_width, 0), height());
689 } 621 }
690 622
691 void OmniboxResultView::OnBoundsChanged(const gfx::Rect& previous_bounds) { 623 void OmniboxResultView::OnBoundsChanged(const gfx::Rect& previous_bounds) {
692 animation_->SetSlideDuration(width() / 4); 624 animation_->SetSlideDuration(width() / 4);
693 } 625 }
694 626
695 void OmniboxResultView::OnPaint(gfx::Canvas* canvas) { 627 void OmniboxResultView::OnPaint(gfx::Canvas* canvas) {
696 if (ui::MaterialDesignController::IsModeMaterial()) { 628 View::OnPaint(canvas);
697 View::OnPaint(canvas);
698 } else {
699 const ResultViewState state = GetState();
700 if (state != NORMAL)
701 canvas->DrawColor(GetColor(state, BACKGROUND));
702 }
703 629
704 // NOTE: While animating the keyword match, both matches may be visible. 630 // NOTE: While animating the keyword match, both matches may be visible.
705 631
706 if (!ShowOnlyKeywordMatch()) { 632 if (!ShowOnlyKeywordMatch()) {
707 canvas->DrawImageInt(GetIcon(), GetMirroredXForRect(icon_bounds_), 633 canvas->DrawImageInt(GetIcon(), GetMirroredXForRect(icon_bounds_),
708 icon_bounds_.y()); 634 icon_bounds_.y());
709 int x = GetMirroredXForRect(text_bounds_); 635 int x = GetMirroredXForRect(text_bounds_);
710 mirroring_context_->Initialize(x, text_bounds_.width()); 636 mirroring_context_->Initialize(x, text_bounds_.width());
711 InitContentsRenderTextIfNecessary(); 637 InitContentsRenderTextIfNecessary();
712 638
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
755 int OmniboxResultView::GetAnswerLineHeight() const { 681 int OmniboxResultView::GetAnswerLineHeight() const {
756 // ANSWER_TEXT_LARGE is the largest font used and so defines the boundary that 682 // ANSWER_TEXT_LARGE is the largest font used and so defines the boundary that
757 // all the other answer styles fit within. 683 // all the other answer styles fit within.
758 return ui::ResourceBundle::GetSharedInstance() 684 return ui::ResourceBundle::GetSharedInstance()
759 .GetFontList(GetTextStyle(SuggestionAnswer::ANSWER_TEXT_LARGE).font) 685 .GetFontList(GetTextStyle(SuggestionAnswer::ANSWER_TEXT_LARGE).font)
760 .GetHeight(); 686 .GetHeight();
761 } 687 }
762 688
763 int OmniboxResultView::GetContentLineHeight() const { 689 int OmniboxResultView::GetContentLineHeight() const {
764 return std::max( 690 return std::max(
765 default_icon_size_ + GetLayoutInsets(OMNIBOX_DROPDOWN_ICON).height(), 691 LocationBarView::kIconWidth +
692 GetLayoutInsets(OMNIBOX_DROPDOWN_ICON).height(),
766 GetTextHeight() + GetLayoutInsets(OMNIBOX_DROPDOWN_TEXT).height()); 693 GetTextHeight() + GetLayoutInsets(OMNIBOX_DROPDOWN_TEXT).height());
767 } 694 }
768 695
769 std::unique_ptr<gfx::RenderText> OmniboxResultView::CreateAnswerLine( 696 std::unique_ptr<gfx::RenderText> OmniboxResultView::CreateAnswerLine(
770 const SuggestionAnswer::ImageLine& line, 697 const SuggestionAnswer::ImageLine& line,
771 gfx::FontList font_list) const { 698 gfx::FontList font_list) const {
772 std::unique_ptr<gfx::RenderText> destination = 699 std::unique_ptr<gfx::RenderText> destination =
773 CreateRenderText(base::string16()); 700 CreateRenderText(base::string16());
774 destination->SetFontList(font_list); 701 destination->SetFontList(font_list);
775 702
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
838 destination->AppendText(text); 765 destination->AppendText(text);
839 const TextStyle& text_style = GetTextStyle(text_type); 766 const TextStyle& text_style = GetTextStyle(text_type);
840 // TODO(dschuyler): follow up on the problem of different font sizes within 767 // TODO(dschuyler): follow up on the problem of different font sizes within
841 // one RenderText. Maybe with destination->SetFontList(...). 768 // one RenderText. Maybe with destination->SetFontList(...).
842 destination->ApplyWeight( 769 destination->ApplyWeight(
843 is_bold ? gfx::Font::Weight::BOLD : gfx::Font::Weight::NORMAL, range); 770 is_bold ? gfx::Font::Weight::BOLD : gfx::Font::Weight::NORMAL, range);
844 destination->ApplyColor( 771 destination->ApplyColor(
845 GetNativeTheme()->GetSystemColor(text_style.colors[GetState()]), range); 772 GetNativeTheme()->GetSystemColor(text_style.colors[GetState()]), range);
846 destination->ApplyBaselineStyle(text_style.baseline, range); 773 destination->ApplyBaselineStyle(text_style.baseline, range);
847 } 774 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698