Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(399)

Unified Diff: chrome/browser/ui/autofill/autofill_popup_controller_impl.cc

Issue 44543002: Enable touch for autofill popup view (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed Gtk and Cocoa compile errors Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 a9102669a7741d2f74193e127f9a3f0648a29efd..867fa34948702283105dcfb380a378a8d4f0507c 100644
--- a/chrome/browser/ui/autofill/autofill_popup_controller_impl.cc
+++ b/chrome/browser/ui/autofill/autofill_popup_controller_impl.cc
@@ -27,8 +27,8 @@ using WebKit::WebAutofillClient;
namespace autofill {
namespace {
-// Used to indicate that no line is currently selected by the user.
-const int kNoSelection = -1;
+// Used to indicate that no line is currently preselected by the user.
+const int kNoPreselection = -1;
// The vertical height of each row in pixels.
const size_t kRowHeight = 24;
@@ -248,31 +248,31 @@ bool AutofillPopupControllerImpl::HandleKeyPressEvent(
const content::NativeWebKeyboardEvent& event) {
switch (event.windowsKeyCode) {
case ui::VKEY_UP:
- SelectPreviousLine();
+ PreselectPreviousLine();
return true;
case ui::VKEY_DOWN:
- SelectNextLine();
+ PreselectNextLine();
return true;
case ui::VKEY_PRIOR: // Page up.
- SetSelectedLine(0);
+ SetPreselectedLine(0);
return true;
case ui::VKEY_NEXT: // Page down.
- SetSelectedLine(names().size() - 1);
+ SetPreselectedLine(names().size() - 1);
return true;
case ui::VKEY_ESCAPE:
Hide();
return true;
case ui::VKEY_DELETE:
return (event.modifiers & content::NativeWebKeyboardEvent::ShiftKey) &&
- RemoveSelectedLine();
+ RemovePreselectedLine();
case ui::VKEY_TAB:
- // A tab press should cause the highlighted line to be selected, but still
+ // A tab press should cause the preselected line to be selected, but still
// return false so the tab key press propagates and changes the cursor
// location.
- AcceptSelectedLine();
+ AcceptPreselectedLine();
return false;
case ui::VKEY_RETURN:
- return AcceptSelectedLine();
+ return AcceptPreselectedLine();
default:
return false;
}
@@ -290,17 +290,17 @@ void AutofillPopupControllerImpl::UpdateBoundsAndRedrawPopup() {
view_->UpdateBoundsAndRedrawPopup();
}
-void AutofillPopupControllerImpl::MouseHovered(int x, int y) {
- SetSelectedLine(LineFromY(y));
+void AutofillPopupControllerImpl::PointPreselected(int x, int y) {
+ SetPreselectedLine(LineFromY(y));
}
-void AutofillPopupControllerImpl::MouseClicked(int x, int y) {
- MouseHovered(x, y);
- AcceptSelectedLine();
+void AutofillPopupControllerImpl::PointSelected(int x, int y) {
+ PointPreselected(x, y);
+ AcceptPreselectedLine();
}
-void AutofillPopupControllerImpl::MouseExitedPopup() {
- SetSelectedLine(kNoSelection);
+void AutofillPopupControllerImpl::PreselectionCleared() {
+ SetPreselectedLine(kNoPreselection);
}
bool AutofillPopupControllerImpl::ShouldRepostEvent(
@@ -403,8 +403,8 @@ const gfx::Font& AutofillPopupControllerImpl::subtext_font() const {
}
#endif
-int AutofillPopupControllerImpl::selected_line() const {
- return selected_line_;
+int AutofillPopupControllerImpl::preselected_line() const {
+ return preselected_line_;
}
void AutofillPopupControllerImpl::set_hide_on_outside_click(
@@ -412,90 +412,90 @@ void AutofillPopupControllerImpl::set_hide_on_outside_click(
hide_on_outside_click_ = hide_on_outside_click;
}
-void AutofillPopupControllerImpl::SetSelectedLine(int selected_line) {
- if (selected_line_ == selected_line)
+void AutofillPopupControllerImpl::SetPreselectedLine(int preselected_line) {
+ if (preselected_line_ == preselected_line)
return;
- if (selected_line_ != kNoSelection &&
- static_cast<size_t>(selected_line_) < identifiers_.size())
- InvalidateRow(selected_line_);
+ if (preselected_line_ != kNoPreselection &&
+ static_cast<size_t>(preselected_line_) < identifiers_.size())
+ InvalidateRow(preselected_line_);
- if (selected_line != kNoSelection)
- InvalidateRow(selected_line);
+ if (preselected_line != kNoPreselection)
+ InvalidateRow(preselected_line);
- selected_line_ = selected_line;
+ preselected_line_ = preselected_line;
- if (selected_line_ != kNoSelection)
- delegate_->DidSelectSuggestion(identifiers_[selected_line_]);
+ if (preselected_line_ != kNoPreselection)
+ delegate_->DidPreselectSuggestion(identifiers_[preselected_line_]);
else
delegate_->ClearPreviewedForm();
}
-void AutofillPopupControllerImpl::SelectNextLine() {
- int new_selected_line = selected_line_ + 1;
+void AutofillPopupControllerImpl::PreselectNextLine() {
+ int new_preselected_line = preselected_line_ + 1;
// Skip over any lines that can't be selected.
- while (static_cast<size_t>(new_selected_line) < names_.size() &&
- !CanAccept(identifiers()[new_selected_line])) {
- ++new_selected_line;
+ while (static_cast<size_t>(new_preselected_line) < names_.size() &&
+ !CanAccept(identifiers()[new_preselected_line])) {
+ ++new_preselected_line;
}
- if (new_selected_line >= static_cast<int>(names_.size()))
- new_selected_line = 0;
+ if (new_preselected_line >= static_cast<int>(names_.size()))
+ new_preselected_line = 0;
- SetSelectedLine(new_selected_line);
+ SetPreselectedLine(new_preselected_line);
}
-void AutofillPopupControllerImpl::SelectPreviousLine() {
- int new_selected_line = selected_line_ - 1;
+void AutofillPopupControllerImpl::PreselectPreviousLine() {
+ int new_preselected_line = preselected_line_ - 1;
// Skip over any lines that can't be selected.
- while (new_selected_line > kNoSelection &&
- !CanAccept(identifiers()[new_selected_line])) {
- --new_selected_line;
+ while (new_preselected_line > kNoPreselection &&
+ !CanAccept(identifiers()[new_preselected_line])) {
+ --new_preselected_line;
}
- if (new_selected_line <= kNoSelection)
- new_selected_line = names_.size() - 1;
+ if (new_preselected_line <= kNoPreselection)
+ new_preselected_line = names_.size() - 1;
- SetSelectedLine(new_selected_line);
+ SetPreselectedLine(new_preselected_line);
}
-bool AutofillPopupControllerImpl::AcceptSelectedLine() {
- if (selected_line_ == kNoSelection)
+bool AutofillPopupControllerImpl::AcceptPreselectedLine() {
+ if (preselected_line_ == kNoPreselection)
return false;
- DCHECK_GE(selected_line_, 0);
- DCHECK_LT(selected_line_, static_cast<int>(names_.size()));
+ DCHECK_GE(preselected_line_, 0);
+ DCHECK_LT(preselected_line_, static_cast<int>(names_.size()));
- if (!CanAccept(identifiers_[selected_line_]))
+ if (!CanAccept(identifiers_[preselected_line_]))
return false;
- AcceptSuggestion(selected_line_);
+ AcceptSuggestion(preselected_line_);
return true;
}
-bool AutofillPopupControllerImpl::RemoveSelectedLine() {
- if (selected_line_ == kNoSelection)
+bool AutofillPopupControllerImpl::RemovePreselectedLine() {
+ if (preselected_line_ == kNoPreselection)
return false;
- DCHECK_GE(selected_line_, 0);
- DCHECK_LT(selected_line_, static_cast<int>(names_.size()));
+ DCHECK_GE(preselected_line_, 0);
+ DCHECK_LT(preselected_line_, static_cast<int>(names_.size()));
- if (!CanDelete(selected_line_))
+ if (!CanDelete(preselected_line_))
return false;
- delegate_->RemoveSuggestion(full_names_[selected_line_],
- identifiers_[selected_line_]);
+ delegate_->RemoveSuggestion(full_names_[preselected_line_],
+ identifiers_[preselected_line_]);
// Remove the deleted element.
- names_.erase(names_.begin() + selected_line_);
- full_names_.erase(full_names_.begin() + selected_line_);
- subtexts_.erase(subtexts_.begin() + selected_line_);
- icons_.erase(icons_.begin() + selected_line_);
- identifiers_.erase(identifiers_.begin() + selected_line_);
+ names_.erase(names_.begin() + preselected_line_);
+ full_names_.erase(full_names_.begin() + preselected_line_);
+ subtexts_.erase(subtexts_.begin() + preselected_line_);
+ icons_.erase(icons_.begin() + preselected_line_);
+ identifiers_.erase(identifiers_.begin() + preselected_line_);
- SetSelectedLine(kNoSelection);
+ SetPreselectedLine(kNoPreselection);
if (HasSuggestions()) {
delegate_->ClearPreviewedForm();
@@ -517,7 +517,8 @@ int AutofillPopupControllerImpl::LineFromY(int y) {
return i;
}
- // The y value goes beyond the popup so stop the selection at the last line.
+ // The y value goes beyond the popup so stop the preselection at the last
+ // line.
return identifiers().size() - 1;
}
@@ -664,7 +665,7 @@ void AutofillPopupControllerImpl::ClearState() {
identifiers_.clear();
full_names_.clear();
- selected_line_ = kNoSelection;
+ preselected_line_ = kNoPreselection;
}
const gfx::Rect AutofillPopupControllerImpl::RoundedElementBounds() const {

Powered by Google App Engine
This is Rietveld 408576698