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

[omnibox] Change popup handler API to pass Selection instead of line only

This CL starts preparing popup handlers for changes to either line
index or line state, instead of only considering line and assuming
the NORMAL state. The interface is changed, but not behavior.

Bug: 1046523
Change-Id: I1cdf5e288b6be2c488795be2bfba0b276327326e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2132769Reviewed-by: default avatarTommy Li <tommycli@chromium.org>
Reviewed-by: default avatarJustin Donnelly <jdonnelly@chromium.org>
Auto-Submit: Orin Jaworski <orinj@chromium.org>
Commit-Queue: Orin Jaworski <orinj@chromium.org>
Commit-Queue: Justin Donnelly <jdonnelly@chromium.org>
Cr-Commit-Position: refs/heads/master@{#756122}
parent 7066ac32
......@@ -230,19 +230,20 @@ void OmniboxPopupContentsView::InvalidateLine(size_t line) {
OmniboxPopupModel::KEYWORD);
}
void OmniboxPopupContentsView::OnSelectedLineChanged(size_t old_selected_line,
size_t new_selected_line) {
void OmniboxPopupContentsView::OnSelectionChanged(
OmniboxPopupModel::Selection old_selection,
OmniboxPopupModel::Selection new_selection) {
if (base::FeatureList::IsEnabled(omnibox::kWebUIOmniboxPopup)) {
webui_view_->GetWebUIHandler()->OnSelectedLineChanged(old_selected_line,
new_selected_line);
webui_view_->GetWebUIHandler()->OnSelectedLineChanged(old_selection.line,
new_selection.line);
return;
}
if (old_selected_line != OmniboxPopupModel::kNoMatch)
result_view_at(old_selected_line)->OnSelectionStateChanged();
if (old_selection.line != OmniboxPopupModel::kNoMatch)
result_view_at(old_selection.line)->OnSelectionStateChanged();
if (new_selected_line != OmniboxPopupModel::kNoMatch)
result_view_at(new_selected_line)->OnSelectionStateChanged();
if (new_selection.line != OmniboxPopupModel::kNoMatch)
result_view_at(new_selection.line)->OnSelectionStateChanged();
}
void OmniboxPopupContentsView::UpdatePopupAppearance() {
......
......@@ -73,8 +73,8 @@ class OmniboxPopupContentsView : public views::View,
// OmniboxPopupView:
bool IsOpen() const override;
void InvalidateLine(size_t line) override;
void OnSelectedLineChanged(size_t old_selected_line,
size_t new_selected_line) override;
void OnSelectionChanged(OmniboxPopupModel::Selection old_selection,
OmniboxPopupModel::Selection new_selection) override;
void UpdatePopupAppearance() override;
void ProvideButtonFocusHint(size_t line) override;
void OnMatchIconUpdated(size_t match_index) override;
......
......@@ -186,13 +186,13 @@ void OmniboxPopupModel::SetSelectedLine(size_t line,
return; // Nothing else to do.
// We need to update selection before calling InvalidateLine(), since it will
// check them to determine how to draw. We also need to update
// use selection to determine how to draw. We also need to update
// |selection_.line| before calling OnPopupDataChanged(), so that when the
// edit notifies its controller that something has changed, the controller
// can get the correct updated data.
const size_t prev_selected_line = selected_line();
const Selection old_selection = selection_;
selection_ = Selection(line, NORMAL);
view_->OnSelectedLineChanged(prev_selected_line, selected_line());
view_->OnSelectionChanged(old_selection, selection_);
if (line == kNoMatch)
return;
......
......@@ -25,12 +25,10 @@ class OmniboxPopupView {
// Invalidates one line of the autocomplete popup.
virtual void InvalidateLine(size_t line) = 0;
// Invoked when the selected line changes. Either |old_selected_line| or
// |new_selected_line| can be OmniboxPopupModel::kNoMatch. This method is
// invoked by the model, and when it is, the view should consider the
// LineState to have been reset to NORMAL.
virtual void OnSelectedLineChanged(size_t old_selected_line,
size_t new_selected_line) {}
// Invoked when the selection changes. The |line| field in either selection
// may be OmniboxPopupModel::kNoMatch. This method is invoked by the model.
virtual void OnSelectionChanged(OmniboxPopupModel::Selection old_selection,
OmniboxPopupModel::Selection new_selection) {}
// Redraws the popup window to match any changes in the result set; this may
// mean opening or closing the window.
......
......@@ -10,13 +10,13 @@
#include <memory>
#include "base/strings/string16.h"
#include "components/omnibox/browser/omnibox_popup_model.h"
#include "components/omnibox/browser/omnibox_popup_view.h"
#import "ios/chrome/browser/ui/omnibox/popup/omnibox_popup_mediator.h"
#include "ios/chrome/browser/ui/omnibox/popup/omnibox_popup_provider.h"
class OmniboxEditModel;
@class OmniboxPopupMediator;
class OmniboxPopupModel;
class OmniboxPopupViewSuggestionsDelegate;
struct AutocompleteMatch;
......
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