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