Commit 3cce6d5d authored by Tommy C. Li's avatar Tommy C. Li Committed by Commit Bot

[omnibox] Fix ZeroSuggest Entity text color switching between dark mode

Before this CL, Entity suggestions from ZeroSuggest would have their
text color messed when switching back and forth between dark mode.

This CL fixes it, and adds a TODO explaining some technical debt we
have.

This CL also makes a similar fix to Answers, which doesn't seem to
happen in practice, since Answers don't show up in ZeroSuggest, but
this is the more correct thing to do.

Bug: 1095205
Change-Id: I2364bb578bbfe47705c594bfe423da694df6aad2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2264853
Commit-Queue: Tommy Li <tommycli@chromium.org>
Reviewed-by: default avatarJustin Donnelly <jdonnelly@chromium.org>
Cr-Commit-Position: refs/heads/master@{#782055}
parent 6cbf85b9
...@@ -188,13 +188,22 @@ void OmniboxResultView::ApplyThemeAndRefreshIcons(bool force_reapply_styles) { ...@@ -188,13 +188,22 @@ void OmniboxResultView::ApplyThemeAndRefreshIcons(bool force_reapply_styles) {
omnibox::kKeywordSearchIcon, GetLayoutConstant(LOCATION_BAR_ICON_SIZE), omnibox::kKeywordSearchIcon, GetLayoutConstant(LOCATION_BAR_ICON_SIZE),
GetColor(OmniboxPart::RESULTS_ICON))); GetColor(OmniboxPart::RESULTS_ICON)));
// We must reapply colors for all the text fields here. If we don't, we can
// break theme changes for ZeroSuggest. See https://crbug.com/1095205.
//
// TODO(tommycli): We should finish migrating this logic to live entirely
// within OmniboxTextView, which should keep track of its own OmniboxPart.
bool high_contrast = bool high_contrast =
GetNativeTheme() && GetNativeTheme()->UsesHighContrastColors(); GetNativeTheme() && GetNativeTheme()->UsesHighContrastColors();
if (match_.answer) { if (match_.answer) {
suggestion_view_->content()->ApplyTextColor( suggestion_view_->content()->ApplyTextColor(
OmniboxPart::RESULTS_TEXT_DEFAULT); OmniboxPart::RESULTS_TEXT_DEFAULT);
suggestion_view_->description()->ApplyTextColor(
OmniboxPart::RESULTS_TEXT_DEFAULT);
} else if (match_.type == AutocompleteMatchType::SEARCH_SUGGEST_ENTITY || } else if (match_.type == AutocompleteMatchType::SEARCH_SUGGEST_ENTITY ||
match_.type == AutocompleteMatchType::PEDAL) { match_.type == AutocompleteMatchType::PEDAL) {
suggestion_view_->content()->ApplyTextColor(
OmniboxPart::RESULTS_TEXT_DEFAULT);
suggestion_view_->description()->ApplyTextColor( suggestion_view_->description()->ApplyTextColor(
OmniboxPart::RESULTS_TEXT_DIMMED); OmniboxPart::RESULTS_TEXT_DIMMED);
} else if (high_contrast || force_reapply_styles) { } else if (high_contrast || force_reapply_styles) {
......
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