| 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/metrics/field_trial_params.h" |
| 21 #include "base/strings/string_number_conversions.h" | 22 #include "base/strings/string_number_conversions.h" |
| 22 #include "base/strings/string_util.h" | 23 #include "base/strings/string_util.h" |
| 23 #include "chrome/browser/ui/layout_constants.h" | 24 #include "chrome/browser/ui/layout_constants.h" |
| 24 #include "chrome/browser/ui/views/location_bar/background_with_1_px_border.h" | 25 #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" | 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" |
| 28 #include "components/grit/components_scaled_resources.h" | 29 #include "components/grit/components_scaled_resources.h" |
| 30 #include "components/omnibox/browser/omnibox_field_trial.h" |
| 29 #include "components/omnibox/browser/omnibox_popup_model.h" | 31 #include "components/omnibox/browser/omnibox_popup_model.h" |
| 30 #include "components/omnibox/browser/vector_icons.h" | 32 #include "components/omnibox/browser/vector_icons.h" |
| 31 #include "third_party/skia/include/core/SkColor.h" | 33 #include "third_party/skia/include/core/SkColor.h" |
| 32 #include "ui/accessibility/ax_node_data.h" | 34 #include "ui/accessibility/ax_node_data.h" |
| 33 #include "ui/base/l10n/l10n_util.h" | 35 #include "ui/base/l10n/l10n_util.h" |
| 34 #include "ui/base/material_design/material_design_controller.h" | 36 #include "ui/base/material_design/material_design_controller.h" |
| 35 #include "ui/base/resource/resource_bundle.h" | 37 #include "ui/base/resource/resource_bundle.h" |
| 36 #include "ui/base/theme_provider.h" | 38 #include "ui/base/theme_provider.h" |
| 37 #include "ui/gfx/canvas.h" | 39 #include "ui/gfx/canvas.h" |
| 38 #include "ui/gfx/color_palette.h" | 40 #include "ui/gfx/color_palette.h" |
| (...skipping 678 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 717 description_rendertext_->SetDisplayRect(gfx::Rect(text_bounds_.width(), 0)); | 719 description_rendertext_->SetDisplayRect(gfx::Rect(text_bounds_.width(), 0)); |
| 718 description_rendertext_->GetStringSize(); | 720 description_rendertext_->GetStringSize(); |
| 719 return GetAnswerFont().GetHeight() * description_rendertext_->GetNumLines(); | 721 return GetAnswerFont().GetHeight() * description_rendertext_->GetNumLines(); |
| 720 } | 722 } |
| 721 | 723 |
| 722 int OmniboxResultView::GetVerticalMargin() const { | 724 int OmniboxResultView::GetVerticalMargin() const { |
| 723 // Regardless of the text size, we ensure a minimum size for the content line | 725 // Regardless of the text size, we ensure a minimum size for the content line |
| 724 // here. This minimum is larger for hybrid mouse/touch devices to ensure an | 726 // here. This minimum is larger for hybrid mouse/touch devices to ensure an |
| 725 // adequately sized touch target. | 727 // adequately sized touch target. |
| 726 using Md = ui::MaterialDesignController; | 728 using Md = ui::MaterialDesignController; |
| 727 const int kIconVerticalPad = Md::GetMode() == Md::MATERIAL_HYBRID ? 8 : 4; | 729 const int kIconVerticalPad = base::GetFieldTrialParamByFeatureAsInt( |
| 730 omnibox::kUIExperiments, |
| 731 OmniboxFieldTrial::kUIExperimentsVerticalMarginParam, |
| 732 Md::GetMode() == Md::MATERIAL_HYBRID ? 8 : 4); |
| 728 const int min_height = LocationBarView::kIconWidth + 2 * kIconVerticalPad; | 733 const int min_height = LocationBarView::kIconWidth + 2 * kIconVerticalPad; |
| 729 | 734 |
| 730 return std::max(kVerticalPadding, (min_height - GetTextHeight()) / 2); | 735 return std::max(kVerticalPadding, (min_height - GetTextHeight()) / 2); |
| 731 } | 736 } |
| 732 | 737 |
| 733 std::unique_ptr<gfx::RenderText> OmniboxResultView::CreateAnswerText( | 738 std::unique_ptr<gfx::RenderText> OmniboxResultView::CreateAnswerText( |
| 734 const SuggestionAnswer::ImageLine& line, | 739 const SuggestionAnswer::ImageLine& line, |
| 735 const gfx::FontList& font_list) const { | 740 const gfx::FontList& font_list) const { |
| 736 std::unique_ptr<gfx::RenderText> destination = | 741 std::unique_ptr<gfx::RenderText> destination = |
| 737 CreateRenderText(base::string16()); | 742 CreateRenderText(base::string16()); |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 802 destination->AppendText(text); | 807 destination->AppendText(text); |
| 803 const TextStyle& text_style = GetTextStyle(text_type); | 808 const TextStyle& text_style = GetTextStyle(text_type); |
| 804 // TODO(dschuyler): follow up on the problem of different font sizes within | 809 // TODO(dschuyler): follow up on the problem of different font sizes within |
| 805 // one RenderText. Maybe with destination->SetFontList(...). | 810 // one RenderText. Maybe with destination->SetFontList(...). |
| 806 destination->ApplyWeight( | 811 destination->ApplyWeight( |
| 807 is_bold ? gfx::Font::Weight::BOLD : gfx::Font::Weight::NORMAL, range); | 812 is_bold ? gfx::Font::Weight::BOLD : gfx::Font::Weight::NORMAL, range); |
| 808 destination->ApplyColor( | 813 destination->ApplyColor( |
| 809 GetNativeTheme()->GetSystemColor(text_style.colors[GetState()]), range); | 814 GetNativeTheme()->GetSystemColor(text_style.colors[GetState()]), range); |
| 810 destination->ApplyBaselineStyle(text_style.baseline, range); | 815 destination->ApplyBaselineStyle(text_style.baseline, range); |
| 811 } | 816 } |
| OLD | NEW |