Chromium Code Reviews| 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 const int kIconVerticalPad = | |
| 692 ui::MaterialDesignController::GetMode() == | |
| 693 ui::MaterialDesignController::MATERIAL_HYBRID | |
| 694 ? 8 | |
| 695 : 4; | |
|
Peter Kasting
2016/11/22 22:12:08
Nit: Shorter:
using MD = ui::MaterialDesignCont
Evan Stade
2016/11/29 03:01:45
done (with slight adjustments)
| |
| 696 const int kTextVerticalPad = 3; | |
| 690 return std::max( | 697 return std::max( |
| 691 LocationBarView::kIconWidth + | 698 LocationBarView::kIconWidth + 2 * kIconVerticalPad, |
| 692 GetLayoutInsets(OMNIBOX_DROPDOWN_ICON).height(), | 699 GetTextHeight() + 2 * kTextVerticalPad); |
| 693 GetTextHeight() + GetLayoutInsets(OMNIBOX_DROPDOWN_TEXT).height()); | |
| 694 } | 700 } |
| 695 | 701 |
| 696 std::unique_ptr<gfx::RenderText> OmniboxResultView::CreateAnswerLine( | 702 std::unique_ptr<gfx::RenderText> OmniboxResultView::CreateAnswerLine( |
| 697 const SuggestionAnswer::ImageLine& line, | 703 const SuggestionAnswer::ImageLine& line, |
| 698 gfx::FontList font_list) const { | 704 gfx::FontList font_list) const { |
| 699 std::unique_ptr<gfx::RenderText> destination = | 705 std::unique_ptr<gfx::RenderText> destination = |
| 700 CreateRenderText(base::string16()); | 706 CreateRenderText(base::string16()); |
| 701 destination->SetFontList(font_list); | 707 destination->SetFontList(font_list); |
| 702 | 708 |
| 703 for (const SuggestionAnswer::TextField& text_field : line.text_fields()) | 709 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); | 771 destination->AppendText(text); |
| 766 const TextStyle& text_style = GetTextStyle(text_type); | 772 const TextStyle& text_style = GetTextStyle(text_type); |
| 767 // TODO(dschuyler): follow up on the problem of different font sizes within | 773 // TODO(dschuyler): follow up on the problem of different font sizes within |
| 768 // one RenderText. Maybe with destination->SetFontList(...). | 774 // one RenderText. Maybe with destination->SetFontList(...). |
| 769 destination->ApplyWeight( | 775 destination->ApplyWeight( |
| 770 is_bold ? gfx::Font::Weight::BOLD : gfx::Font::Weight::NORMAL, range); | 776 is_bold ? gfx::Font::Weight::BOLD : gfx::Font::Weight::NORMAL, range); |
| 771 destination->ApplyColor( | 777 destination->ApplyColor( |
| 772 GetNativeTheme()->GetSystemColor(text_style.colors[GetState()]), range); | 778 GetNativeTheme()->GetSystemColor(text_style.colors[GetState()]), range); |
| 773 destination->ApplyBaselineStyle(text_style.baseline, range); | 779 destination->ApplyBaselineStyle(text_style.baseline, range); |
| 774 } | 780 } |
| OLD | NEW |