| 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 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 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/location_bar_view.h" | 25 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" |
| 26 #include "chrome/browser/ui/views/omnibox/omnibox_popup_contents_view.h" | 26 #include "chrome/browser/ui/views/omnibox/omnibox_popup_contents_view.h" |
| 27 #include "chrome/grit/generated_resources.h" | 27 #include "chrome/grit/generated_resources.h" |
| 28 #include "components/grit/components_scaled_resources.h" | 28 #include "components/grit/components_scaled_resources.h" |
| 29 #include "components/omnibox/browser/omnibox_popup_model.h" | 29 #include "components/omnibox/browser/omnibox_popup_model.h" |
| 30 #include "third_party/skia/include/core/SkColor.h" | 30 #include "third_party/skia/include/core/SkColor.h" |
| 31 #include "ui/accessibility/ax_node_data.h" | 31 #include "ui/accessibility/ax_node_data.h" |
| 32 #include "ui/base/l10n/l10n_util.h" | 32 #include "ui/base/l10n/l10n_util.h" |
| 33 #include "ui/base/material_design/material_design_controller.h" |
| 33 #include "ui/base/resource/resource_bundle.h" | 34 #include "ui/base/resource/resource_bundle.h" |
| 34 #include "ui/base/theme_provider.h" | 35 #include "ui/base/theme_provider.h" |
| 35 #include "ui/gfx/canvas.h" | 36 #include "ui/gfx/canvas.h" |
| 36 #include "ui/gfx/color_palette.h" | 37 #include "ui/gfx/color_palette.h" |
| 37 #include "ui/gfx/color_utils.h" | 38 #include "ui/gfx/color_utils.h" |
| 38 #include "ui/gfx/image/image.h" | 39 #include "ui/gfx/image/image.h" |
| 39 #include "ui/gfx/paint_vector_icon.h" | 40 #include "ui/gfx/paint_vector_icon.h" |
| 40 #include "ui/gfx/range/range.h" | 41 #include "ui/gfx/range/range.h" |
| 41 #include "ui/gfx/render_text.h" | 42 #include "ui/gfx/render_text.h" |
| 42 #include "ui/gfx/text_utils.h" | 43 #include "ui/gfx/text_utils.h" |
| (...skipping 637 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 680 | 681 |
| 681 int OmniboxResultView::GetAnswerLineHeight() const { | 682 int OmniboxResultView::GetAnswerLineHeight() const { |
| 682 // ANSWER_TEXT_LARGE is the largest font used and so defines the boundary that | 683 // ANSWER_TEXT_LARGE is the largest font used and so defines the boundary that |
| 683 // all the other answer styles fit within. | 684 // all the other answer styles fit within. |
| 684 return ui::ResourceBundle::GetSharedInstance() | 685 return ui::ResourceBundle::GetSharedInstance() |
| 685 .GetFontList(GetTextStyle(SuggestionAnswer::ANSWER_TEXT_LARGE).font) | 686 .GetFontList(GetTextStyle(SuggestionAnswer::ANSWER_TEXT_LARGE).font) |
| 686 .GetHeight(); | 687 .GetHeight(); |
| 687 } | 688 } |
| 688 | 689 |
| 689 int OmniboxResultView::GetContentLineHeight() const { | 690 int OmniboxResultView::GetContentLineHeight() const { |
| 691 using Md = ui::MaterialDesignController; |
| 692 const int kIconVerticalPad = Md::GetMode() == Md::MATERIAL_HYBRID ? 8 : 4; |
| 693 const int kTextVerticalPad = 3; |
| 690 return std::max( | 694 return std::max( |
| 691 LocationBarView::kIconWidth + | 695 LocationBarView::kIconWidth + 2 * kIconVerticalPad, |
| 692 GetLayoutInsets(OMNIBOX_DROPDOWN_ICON).height(), | 696 GetTextHeight() + 2 * kTextVerticalPad); |
| 693 GetTextHeight() + GetLayoutInsets(OMNIBOX_DROPDOWN_TEXT).height()); | |
| 694 } | 697 } |
| 695 | 698 |
| 696 std::unique_ptr<gfx::RenderText> OmniboxResultView::CreateAnswerLine( | 699 std::unique_ptr<gfx::RenderText> OmniboxResultView::CreateAnswerLine( |
| 697 const SuggestionAnswer::ImageLine& line, | 700 const SuggestionAnswer::ImageLine& line, |
| 698 gfx::FontList font_list) const { | 701 gfx::FontList font_list) const { |
| 699 std::unique_ptr<gfx::RenderText> destination = | 702 std::unique_ptr<gfx::RenderText> destination = |
| 700 CreateRenderText(base::string16()); | 703 CreateRenderText(base::string16()); |
| 701 destination->SetFontList(font_list); | 704 destination->SetFontList(font_list); |
| 702 | 705 |
| 703 for (const SuggestionAnswer::TextField& text_field : line.text_fields()) | 706 for (const SuggestionAnswer::TextField& text_field : line.text_fields()) |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 765 destination->AppendText(text); | 768 destination->AppendText(text); |
| 766 const TextStyle& text_style = GetTextStyle(text_type); | 769 const TextStyle& text_style = GetTextStyle(text_type); |
| 767 // TODO(dschuyler): follow up on the problem of different font sizes within | 770 // TODO(dschuyler): follow up on the problem of different font sizes within |
| 768 // one RenderText. Maybe with destination->SetFontList(...). | 771 // one RenderText. Maybe with destination->SetFontList(...). |
| 769 destination->ApplyWeight( | 772 destination->ApplyWeight( |
| 770 is_bold ? gfx::Font::Weight::BOLD : gfx::Font::Weight::NORMAL, range); | 773 is_bold ? gfx::Font::Weight::BOLD : gfx::Font::Weight::NORMAL, range); |
| 771 destination->ApplyColor( | 774 destination->ApplyColor( |
| 772 GetNativeTheme()->GetSystemColor(text_style.colors[GetState()]), range); | 775 GetNativeTheme()->GetSystemColor(text_style.colors[GetState()]), range); |
| 773 destination->ApplyBaselineStyle(text_style.baseline, range); | 776 destination->ApplyBaselineStyle(text_style.baseline, range); |
| 774 } | 777 } |
| OLD | NEW |