Commit fb0b87c1 authored by Tommy Li's avatar Tommy Li Committed by Commit Bot

[omnibox] Cleanups: Rename OmniboxResultView method and simplify a call

This CL is just a cleanup CL that renames OmniboxResultView::Invalidate
to a more specific ApplyThemeAndRefreshIcons().

This is in preparation to refactor some of the OmniboxPopupView API
to be more friendly for a WebUI implementation.

Bug: 1046561
Change-Id: Ic082932f02d28b69e82fb35afc3d94f4e23427f0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2071914Reviewed-by: default avatarOrin Jaworski <orinj@chromium.org>
Commit-Queue: Tommy Li <tommycli@chromium.org>
Cr-Commit-Position: refs/heads/master@{#744683}
parent 5d6c8f71
...@@ -217,13 +217,9 @@ void OmniboxPopupContentsView::InvalidateLine(size_t line) { ...@@ -217,13 +217,9 @@ void OmniboxPopupContentsView::InvalidateLine(size_t line) {
} }
OmniboxResultView* result = result_view_at(line); OmniboxResultView* result = result_view_at(line);
result->Invalidate(); result->ApplyThemeAndRefreshIcons();
result->ShowKeyword(IsSelectedIndex(line) && model_->selected_line_state() ==
if (HasMatchAt(line) && GetMatchAtIndex(line).associated_keyword.get()) { OmniboxPopupModel::KEYWORD);
result->ShowKeyword(IsSelectedIndex(line) &&
model_->selected_line_state() ==
OmniboxPopupModel::KEYWORD);
}
} }
void OmniboxPopupContentsView::OnSelectionStateChanged(size_t line) { void OmniboxPopupContentsView::OnSelectionStateChanged(size_t line) {
......
...@@ -173,7 +173,7 @@ void OmniboxResultView::SetMatch(const AutocompleteMatch& match) { ...@@ -173,7 +173,7 @@ void OmniboxResultView::SetMatch(const AutocompleteMatch& match) {
} }
} }
Invalidate(); ApplyThemeAndRefreshIcons();
InvalidateLayout(); InvalidateLayout();
} }
...@@ -184,7 +184,7 @@ void OmniboxResultView::ShowKeyword(bool show_keyword) { ...@@ -184,7 +184,7 @@ void OmniboxResultView::ShowKeyword(bool show_keyword) {
animation_->Hide(); animation_->Hide();
} }
void OmniboxResultView::Invalidate(bool force_reapply_styles) { void OmniboxResultView::ApplyThemeAndRefreshIcons(bool force_reapply_styles) {
bool high_contrast = bool high_contrast =
GetNativeTheme() && GetNativeTheme()->UsesHighContrastColors(); GetNativeTheme() && GetNativeTheme()->UsesHighContrastColors();
// TODO(tapted): Consider using background()->SetNativeControlColor() and // TODO(tapted): Consider using background()->SetNativeControlColor() and
...@@ -324,8 +324,8 @@ OmniboxPartState OmniboxResultView::GetThemeState() const { ...@@ -324,8 +324,8 @@ OmniboxPartState OmniboxResultView::GetThemeState() const {
} }
void OmniboxResultView::OnMatchIconUpdated() { void OmniboxResultView::OnMatchIconUpdated() {
// The new icon will be fetched during Invalidate(). // The new icon will be fetched during ApplyThemeAndRefreshIcons().
Invalidate(); ApplyThemeAndRefreshIcons();
} }
void OmniboxResultView::SetRichSuggestionImage(const gfx::ImageSkia& image) { void OmniboxResultView::SetRichSuggestionImage(const gfx::ImageSkia& image) {
...@@ -591,7 +591,7 @@ void OmniboxResultView::OnThemeChanged() { ...@@ -591,7 +591,7 @@ void OmniboxResultView::OnThemeChanged() {
vector_icons::kCloseRoundedIcon, vector_icons::kCloseRoundedIcon,
GetLayoutConstant(LOCATION_BAR_ICON_SIZE), GetLayoutConstant(LOCATION_BAR_ICON_SIZE),
GetColor(OmniboxPart::RESULTS_ICON)); GetColor(OmniboxPart::RESULTS_ICON));
Invalidate(true); ApplyThemeAndRefreshIcons(true);
} }
void OmniboxResultView::ProvideButtonFocusHint() { void OmniboxResultView::ProvideButtonFocusHint() {
...@@ -637,7 +637,7 @@ gfx::Image OmniboxResultView::GetIcon() const { ...@@ -637,7 +637,7 @@ gfx::Image OmniboxResultView::GetIcon() const {
void OmniboxResultView::UpdateHoverState() { void OmniboxResultView::UpdateHoverState() {
UpdateRemoveSuggestionVisibility(); UpdateRemoveSuggestionVisibility();
Invalidate(); ApplyThemeAndRefreshIcons();
} }
void OmniboxResultView::OpenMatch(WindowOpenDisposition disposition, void OmniboxResultView::OpenMatch(WindowOpenDisposition disposition,
......
...@@ -58,7 +58,9 @@ class OmniboxResultView : public views::View, ...@@ -58,7 +58,9 @@ class OmniboxResultView : public views::View,
void ShowKeyword(bool show_keyword); void ShowKeyword(bool show_keyword);
void Invalidate(bool force_reapply_styles = false); // Applies the current theme to the current text and widget colors.
// Also refreshes the icons which may need to be re-colored as well.
void ApplyThemeAndRefreshIcons(bool force_reapply_styles = false);
// Invoked when this result view has been selected or unselected. // Invoked when this result view has been selected or unselected.
void OnSelectionStateChanged(); void OnSelectionStateChanged();
......
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