| 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" | |
| 24 #include "chrome/browser/ui/views/location_bar/background_with_1_px_border.h" | 23 #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" | 24 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" |
| 26 #include "chrome/browser/ui/views/omnibox/omnibox_popup_contents_view.h" | 25 #include "chrome/browser/ui/views/omnibox/omnibox_popup_contents_view.h" |
| 27 #include "chrome/grit/generated_resources.h" | 26 #include "chrome/grit/generated_resources.h" |
| 28 #include "components/grit/components_scaled_resources.h" | 27 #include "components/grit/components_scaled_resources.h" |
| 29 #include "components/omnibox/browser/omnibox_popup_model.h" | 28 #include "components/omnibox/browser/omnibox_popup_model.h" |
| 30 #include "third_party/skia/include/core/SkColor.h" | 29 #include "third_party/skia/include/core/SkColor.h" |
| 31 #include "ui/accessibility/ax_node_data.h" | 30 #include "ui/accessibility/ax_node_data.h" |
| 32 #include "ui/base/l10n/l10n_util.h" | 31 #include "ui/base/l10n/l10n_util.h" |
| 33 #include "ui/base/material_design/material_design_controller.h" | 32 #include "ui/base/material_design/material_design_controller.h" |
| (...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 583 | 582 |
| 584 void OmniboxResultView::InitContentsRenderTextIfNecessary() const { | 583 void OmniboxResultView::InitContentsRenderTextIfNecessary() const { |
| 585 if (!contents_rendertext_) { | 584 if (!contents_rendertext_) { |
| 586 contents_rendertext_.reset( | 585 contents_rendertext_.reset( |
| 587 CreateClassifiedRenderText( | 586 CreateClassifiedRenderText( |
| 588 match_.contents, match_.contents_class, false).release()); | 587 match_.contents, match_.contents_class, false).release()); |
| 589 } | 588 } |
| 590 } | 589 } |
| 591 | 590 |
| 592 void OmniboxResultView::Layout() { | 591 void OmniboxResultView::Layout() { |
| 593 int horizontal_padding = | 592 constexpr int horizontal_padding = LocationBarView::kHorizontalPadding; |
| 594 GetLayoutConstant(LOCATION_BAR_HORIZONTAL_PADDING); | |
| 595 // The horizontal bounds we're given are the outside bounds, so we can match | 593 // The horizontal bounds we're given are the outside bounds, so we can match |
| 596 // the omnibox border outline shape exactly in OnPaint(). We have to inset | 594 // the omnibox border outline shape exactly in OnPaint(). We have to inset |
| 597 // here to keep the icons lined up. | 595 // here to keep the icons lined up. |
| 598 const int start_x = | 596 constexpr int start_x = |
| 599 GetLayoutConstant(LOCATION_BAR_BORDER_THICKNESS) + horizontal_padding; | 597 BackgroundWith1PxBorder::kLocationBarBorderThicknessDip + |
| 598 horizontal_padding; |
| 600 const int end_x = width() - start_x; | 599 const int end_x = width() - start_x; |
| 601 | 600 |
| 602 const gfx::ImageSkia icon = GetIcon(); | 601 const gfx::ImageSkia icon = GetIcon(); |
| 603 icon_bounds_.SetRect(start_x, (GetContentLineHeight() - icon.height()) / 2, | 602 icon_bounds_.SetRect(start_x, (GetContentLineHeight() - icon.height()) / 2, |
| 604 icon.width(), icon.height()); | 603 icon.width(), icon.height()); |
| 605 | 604 |
| 606 const int text_x = start_x + LocationBarView::kIconWidth + horizontal_padding; | 605 constexpr int text_x = |
| 606 start_x + LocationBarView::kIconWidth + horizontal_padding; |
| 607 int text_width = end_x - text_x; | 607 int text_width = end_x - text_x; |
| 608 | 608 |
| 609 if (match_.associated_keyword.get()) { | 609 if (match_.associated_keyword.get()) { |
| 610 const int max_kw_x = end_x - keyword_icon_->width(); | 610 const int max_kw_x = end_x - keyword_icon_->width(); |
| 611 const int kw_x = animation_->CurrentValueBetween(max_kw_x, start_x); | 611 const int kw_x = animation_->CurrentValueBetween(max_kw_x, start_x); |
| 612 const int kw_text_x = kw_x + keyword_icon_->width() + horizontal_padding; | 612 const int kw_text_x = kw_x + keyword_icon_->width() + horizontal_padding; |
| 613 | 613 |
| 614 text_width = kw_x - text_x - horizontal_padding; | 614 text_width = kw_x - text_x - horizontal_padding; |
| 615 keyword_text_bounds_.SetRect( | 615 keyword_text_bounds_.SetRect( |
| 616 kw_text_x, 0, std::max(end_x - kw_text_x, 0), height()); | 616 kw_text_x, 0, std::max(end_x - kw_text_x, 0), height()); |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 768 destination->AppendText(text); | 768 destination->AppendText(text); |
| 769 const TextStyle& text_style = GetTextStyle(text_type); | 769 const TextStyle& text_style = GetTextStyle(text_type); |
| 770 // 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 |
| 771 // one RenderText. Maybe with destination->SetFontList(...). | 771 // one RenderText. Maybe with destination->SetFontList(...). |
| 772 destination->ApplyWeight( | 772 destination->ApplyWeight( |
| 773 is_bold ? gfx::Font::Weight::BOLD : gfx::Font::Weight::NORMAL, range); | 773 is_bold ? gfx::Font::Weight::BOLD : gfx::Font::Weight::NORMAL, range); |
| 774 destination->ApplyColor( | 774 destination->ApplyColor( |
| 775 GetNativeTheme()->GetSystemColor(text_style.colors[GetState()]), range); | 775 GetNativeTheme()->GetSystemColor(text_style.colors[GetState()]), range); |
| 776 destination->ApplyBaselineStyle(text_style.baseline, range); | 776 destination->ApplyBaselineStyle(text_style.baseline, range); |
| 777 } | 777 } |
| OLD | NEW |