Commit c366435f authored by Orin Jaworski's avatar Orin Jaworski Committed by Commit Bot

[omnibox] Call result view OnSelectionStateChanged more and check state

This CL takes another step toward having selection change logic consider
full selection instead of updating line and state separately with
assumed NORMAL state default. The API is preserved for now but behavior
changes slightly in a way that should, long term, be more efficient
than doing event handling in duplicate. In particular, the goal is to
have result views only update on selection change once instead of once
on line change and then again on state change.

Bug: 1046523
Change-Id: I6c94db73d4997241275e4a1b62b75272611c166a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2134917Reviewed-by: default avatarTommy Li <tommycli@chromium.org>
Commit-Queue: Tommy Li <tommycli@chromium.org>
Auto-Submit: Orin Jaworski <orinj@chromium.org>
Cr-Commit-Position: refs/heads/master@{#756433}
parent 85b19c42
......@@ -223,11 +223,7 @@ void OmniboxPopupContentsView::InvalidateLine(size_t line) {
webui_view_->GetWebUIHandler()->InvalidateLine(line);
return;
}
OmniboxResultView* result = result_view_at(line);
result->ApplyThemeAndRefreshIcons();
result->ShowKeyword(IsSelectedIndex(line) && model_->selected_line_state() ==
OmniboxPopupModel::KEYWORD);
result_view_at(line)->OnSelectionStateChanged();
}
void OmniboxPopupContentsView::OnSelectionChanged(
......@@ -239,11 +235,13 @@ void OmniboxPopupContentsView::OnSelectionChanged(
return;
}
if (old_selection.line != OmniboxPopupModel::kNoMatch)
result_view_at(old_selection.line)->OnSelectionStateChanged();
if (old_selection.line != OmniboxPopupModel::kNoMatch) {
InvalidateLine(old_selection.line);
}
if (new_selection.line != OmniboxPopupModel::kNoMatch)
result_view_at(new_selection.line)->OnSelectionStateChanged();
if (new_selection.line != OmniboxPopupModel::kNoMatch) {
InvalidateLine(new_selection.line);
}
}
void OmniboxPopupContentsView::UpdatePopupAppearance() {
......
......@@ -249,10 +249,15 @@ void OmniboxResultView::OnSelectionStateChanged() {
// but this selection event allows the screen reader to get more details
// about the list and the user's position within it.
NotifyAccessibilityEvent(ax::mojom::Event::kSelection, true);
}
// TODO(orinj): Eventually the deep digging in this class should get
// replaced with a single local point of access to all selection state.
ShowKeyword(popup_contents_view_->model()->selection().state ==
OmniboxPopupModel::KEYWORD);
} else {
ShowKeyword(false);
}
ApplyThemeAndRefreshIcons();
ShowKeyword(false);
}
bool OmniboxResultView::IsSelected() const {
......
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