Index: chrome/browser/ui/autofill/autofill_popup_controller_impl.cc |
diff --git a/chrome/browser/ui/autofill/autofill_popup_controller_impl.cc b/chrome/browser/ui/autofill/autofill_popup_controller_impl.cc |
index 487248fba6fdda38fb06cfa215aecb70cb0b4acf..f40432a6202a0560bb4bf2a95e5830ecfc50c554 100644 |
--- a/chrome/browser/ui/autofill/autofill_popup_controller_impl.cc |
+++ b/chrome/browser/ui/autofill/autofill_popup_controller_impl.cc |
@@ -27,8 +27,7 @@ using base::WeakPtr; |
namespace autofill { |
namespace { |
-// Used to indicate that no line is currently selected by the user. |
-const int kNoSelection = -1; |
+const auto& kNoSelection = AutofillPopupView::kNoSelection; |
groby-ooo-7-16
2017/03/20 20:42:55
Why define a new constant here? (And if we must, p
csashi
2017/03/20 21:41:51
I removed this a few patches ago. Can you please c
groby-ooo-7-16
2017/03/20 22:53:10
Acknowledged.
|
} // namespace |
@@ -114,9 +113,9 @@ void AutofillPopupControllerImpl::Show( |
#endif |
if (just_created) { |
- ShowView(); |
+ view_->Show(); |
} else { |
- UpdateBoundsAndRedrawPopup(); |
+ OnSuggestionsChanged(); |
} |
controller_common_->RegisterKeyPressCallback(); |
@@ -153,7 +152,7 @@ void AutofillPopupControllerImpl::UpdateDataListValues( |
// The popup contents have changed, so either update the bounds or hide it. |
if (HasSuggestions()) |
- UpdateBoundsAndRedrawPopup(); |
+ OnSuggestionsChanged(); |
else |
Hide(); |
@@ -185,7 +184,7 @@ void AutofillPopupControllerImpl::UpdateDataListValues( |
elided_labels_[i] = labels[i]; |
} |
- UpdateBoundsAndRedrawPopup(); |
+ OnSuggestionsChanged(); |
DCHECK_EQ(suggestions_.size(), elided_values_.size()); |
DCHECK_EQ(suggestions_.size(), elided_labels_.size()); |
} |
@@ -245,7 +244,7 @@ bool AutofillPopupControllerImpl::HandleKeyPressEvent( |
} |
} |
-void AutofillPopupControllerImpl::UpdateBoundsAndRedrawPopup() { |
+void AutofillPopupControllerImpl::OnSuggestionsChanged() { |
#if !defined(OS_ANDROID) |
// TODO(csharp): Since UpdatePopupBounds can change the position of the popup, |
// the popup could end up jumping from above the element to below it. |
@@ -255,7 +254,7 @@ void AutofillPopupControllerImpl::UpdateBoundsAndRedrawPopup() { |
#endif |
// Platform-specific draw call. |
- view_->UpdateBoundsAndRedrawPopup(); |
+ view_->OnSuggestionsChanged(); |
} |
void AutofillPopupControllerImpl::SetSelectionAtPoint(const gfx::Point& point) { |
@@ -366,7 +365,7 @@ bool AutofillPopupControllerImpl::RemoveSuggestion(int list_index) { |
if (HasSuggestions()) { |
delegate_->ClearPreviewedForm(); |
- UpdateBoundsAndRedrawPopup(); |
+ OnSuggestionsChanged(); |
} else { |
Hide(); |
} |
@@ -394,17 +393,15 @@ void AutofillPopupControllerImpl::SetSelectedLine(int selected_line) { |
if (selected_line_ == selected_line) |
return; |
- if (selected_line_ != kNoSelection && |
- static_cast<size_t>(selected_line_) < suggestions_.size()) |
- InvalidateRow(selected_line_); |
- |
if (selected_line != kNoSelection) { |
- InvalidateRow(selected_line); |
- |
+ DCHECK_GE(selected_line, 0); |
+ DCHECK_LT(static_cast<size_t>(selected_line), suggestions_.size()); |
if (!CanAccept(suggestions_[selected_line].frontend_id)) |
selected_line = kNoSelection; |
} |
+ view_->OnSelectedRowChanged(selected_line_, selected_line); |
+ |
selected_line_ = selected_line; |
if (selected_line_ != kNoSelection) { |
@@ -482,16 +479,6 @@ void AutofillPopupControllerImpl::SetValues( |
} |
} |
-void AutofillPopupControllerImpl::ShowView() { |
- view_->Show(); |
-} |
- |
-void AutofillPopupControllerImpl::InvalidateRow(size_t row) { |
- DCHECK(0 <= row); |
- DCHECK(row < suggestions_.size()); |
- view_->InvalidateRow(row); |
-} |
- |
WeakPtr<AutofillPopupControllerImpl> AutofillPopupControllerImpl::GetWeakPtr() { |
return weak_ptr_factory_.GetWeakPtr(); |
} |