Commit c0cf6f4e authored by Angela Yoeurng's avatar Angela Yoeurng Committed by Commit Bot

[omnibox] Change background color of suggestion hover/selected

This CL updates the background color of a hovered/selected suggestion if
the refined-focus-state flag is enabled. It also made the focus bar
visible only if the search suggestion is selected vs. if the aux buttons
are selected as well.

Bug: 1129612
Change-Id: Iba4287937a345123c5465cea2522e7462be1f93e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2459632
Commit-Queue: Angela Yoeurng <yoangela@chromium.org>
Reviewed-by: default avatarPeter Kasting <pkasting@chromium.org>
Reviewed-by: default avatarTommy Li <tommycli@chromium.org>
Cr-Commit-Position: refs/heads/master@{#815330}
parent 4e420bdc
......@@ -11,6 +11,7 @@
#include "chrome/browser/ui/ui_features.h"
#include "chrome/grit/theme_resources.h"
#include "components/grit/components_scaled_resources.h"
#include "components/omnibox/browser/omnibox_field_trial.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/gfx/color_palette.h"
#include "ui/gfx/color_utils.h"
......@@ -613,7 +614,9 @@ base::Optional<ThemeHelper::OmniboxColor> ThemeHelper::GetOmniboxColorImpl(
return blend_toward_max_contrast(bg, 0x0A);
};
const auto results_bg_hovered_color = [&]() {
return blend_toward_max_contrast(results_bg_color(), 0x1A);
return blend_toward_max_contrast(
results_bg_color(),
OmniboxFieldTrial::IsRefinedFocusStateEnabled() ? 0x0A : 0x1A);
};
const auto url_color = [&](OmniboxColor bg) {
return blend_for_min_contrast(
......@@ -621,7 +624,9 @@ base::Optional<ThemeHelper::OmniboxColor> ThemeHelper::GetOmniboxColorImpl(
{{dark ? gfx::kGoogleBlue050 : gfx::kGoogleBlue900, false}});
};
const auto results_bg_selected_color = [&]() {
return blend_toward_max_contrast(results_bg_color(), 0x29);
return blend_toward_max_contrast(
results_bg_color(),
OmniboxFieldTrial::IsRefinedFocusStateEnabled() ? 0x0A : 0x29);
};
const auto blend_with_clamped_contrast = [&](OmniboxColor bg) {
return blend_for_min_contrast(fg, fg, blend_for_min_contrast(bg, bg));
......
......@@ -207,7 +207,11 @@ gfx::Image OmniboxPopupContentsView::GetMatchIcon(
void OmniboxPopupContentsView::SetSelectedLineForMouseOrTouch(size_t index) {
DCHECK(HasMatchAt(index));
// We do this to prevent de-focusing auxiliary buttons due to drag.
if (index == model_->selected_line())
// With refined-focus-state enabled, there's more visual differences for
// having the actual suggestion focused vs. an aux button, so we cannot skip
// setting the selection.
if (!OmniboxFieldTrial::IsRefinedFocusStateEnabled() &&
index == model_->selected_line())
return;
OmniboxPopupModel::LineState line_state = OmniboxPopupModel::NORMAL;
......
......@@ -319,7 +319,12 @@ void OmniboxResultView::ApplyThemeAndRefreshIcons(bool force_reapply_styles) {
}
if (OmniboxFieldTrial::IsRefinedFocusStateEnabled()) {
focus_bar_->SetVisible(IsMatchSelected());
// The focus bar indicates when the suggestion is focused. Do not show the
// focus bar if an auxiliary button is selected.
focus_bar_->SetVisible(
IsMatchSelected() &&
popup_contents_view_->model()->selected_line_state() ==
OmniboxPopupModel::NORMAL);
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment