| 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/layout_constants.h" |
| 24 #include "chrome/browser/ui/views/location_bar/icon_label_bubble_view.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/omnibox/browser/omnibox_popup_model.h" | 28 #include "components/omnibox/browser/omnibox_popup_model.h" |
| 28 #include "grit/components_scaled_resources.h" | 29 #include "grit/components_scaled_resources.h" |
| 29 #include "grit/theme_resources.h" | 30 #include "grit/theme_resources.h" |
| 30 #include "third_party/skia/include/core/SkColor.h" | 31 #include "third_party/skia/include/core/SkColor.h" |
| 31 #include "ui/accessibility/ax_view_state.h" | 32 #include "ui/accessibility/ax_view_state.h" |
| 32 #include "ui/base/l10n/l10n_util.h" | 33 #include "ui/base/l10n/l10n_util.h" |
| 33 #include "ui/base/material_design/material_design_controller.h" | 34 #include "ui/base/material_design/material_design_controller.h" |
| (...skipping 613 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 647 // Pre-MD, normal icons are 19 px wide, while extension icons are 16 px wide. | 648 // Pre-MD, normal icons are 19 px wide, while extension icons are 16 px wide. |
| 648 // The code in IconLabelBubbleView::Layout() positions these icons in the | 649 // The code in IconLabelBubbleView::Layout() positions these icons in the |
| 649 // omnibox using ICON_LABEL_VIEW_TRAILING_PADDING, so we use that here as well | 650 // omnibox using ICON_LABEL_VIEW_TRAILING_PADDING, so we use that here as well |
| 650 // so the icons will line up. | 651 // so the icons will line up. |
| 651 // | 652 // |
| 652 // Technically we don't need the IsModeMaterial() check here, but it will make | 653 // Technically we don't need the IsModeMaterial() check here, but it will make |
| 653 // it easier to see that all this code is dead once we switch to MD. | 654 // it easier to see that all this code is dead once we switch to MD. |
| 654 int icon_x = start_x; | 655 int icon_x = start_x; |
| 655 if (!ui::MaterialDesignController::IsModeMaterial() && | 656 if (!ui::MaterialDesignController::IsModeMaterial() && |
| 656 (icon.width() != default_icon_size_)) | 657 (icon.width() != default_icon_size_)) |
| 657 icon_x += GetLayoutConstant(ICON_LABEL_VIEW_TRAILING_PADDING); | 658 icon_x += IconLabelBubbleView::kTrailingPaddingPreMd; |
| 658 icon_bounds_.SetRect(icon_x, (GetContentLineHeight() - icon.height()) / 2, | 659 icon_bounds_.SetRect(icon_x, (GetContentLineHeight() - icon.height()) / 2, |
| 659 icon.width(), icon.height()); | 660 icon.width(), icon.height()); |
| 660 | 661 |
| 661 const int text_x = start_x + default_icon_size_ + horizontal_padding; | 662 const int text_x = start_x + default_icon_size_ + horizontal_padding; |
| 662 int text_width = end_x - text_x; | 663 int text_width = end_x - text_x; |
| 663 | 664 |
| 664 if (match_.associated_keyword.get()) { | 665 if (match_.associated_keyword.get()) { |
| 665 const int max_kw_x = end_x - keyword_icon_->width(); | 666 const int max_kw_x = end_x - keyword_icon_->width(); |
| 666 const int kw_x = animation_->CurrentValueBetween(max_kw_x, start_x); | 667 const int kw_x = animation_->CurrentValueBetween(max_kw_x, start_x); |
| 667 const int kw_text_x = kw_x + keyword_icon_->width() + horizontal_padding; | 668 const int kw_text_x = kw_x + keyword_icon_->width() + horizontal_padding; |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 832 | 833 |
| 833 int OmniboxResultView::StartMargin() const { | 834 int OmniboxResultView::StartMargin() const { |
| 834 return ui::MaterialDesignController::IsModeMaterial() ? | 835 return ui::MaterialDesignController::IsModeMaterial() ? |
| 835 model_->start_margin() : 0; | 836 model_->start_margin() : 0; |
| 836 } | 837 } |
| 837 | 838 |
| 838 int OmniboxResultView::EndMargin() const { | 839 int OmniboxResultView::EndMargin() const { |
| 839 return ui::MaterialDesignController::IsModeMaterial() ? | 840 return ui::MaterialDesignController::IsModeMaterial() ? |
| 840 model_->end_margin() : 0; | 841 model_->end_margin() : 0; |
| 841 } | 842 } |
| OLD | NEW |