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