Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/ui/autofill/autofill_popup_controller_impl.h" | 5 #include "chrome/browser/ui/autofill/autofill_popup_controller_impl.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 259 case ui::VKEY_NEXT: // Page down. | 259 case ui::VKEY_NEXT: // Page down. |
| 260 SetSelectedLine(names().size() - 1); | 260 SetSelectedLine(names().size() - 1); |
| 261 return true; | 261 return true; |
| 262 case ui::VKEY_ESCAPE: | 262 case ui::VKEY_ESCAPE: |
| 263 Hide(); | 263 Hide(); |
| 264 return true; | 264 return true; |
| 265 case ui::VKEY_DELETE: | 265 case ui::VKEY_DELETE: |
| 266 return (event.modifiers & content::NativeWebKeyboardEvent::ShiftKey) && | 266 return (event.modifiers & content::NativeWebKeyboardEvent::ShiftKey) && |
| 267 RemoveSelectedLine(); | 267 RemoveSelectedLine(); |
| 268 case ui::VKEY_TAB: | 268 case ui::VKEY_TAB: |
| 269 // A tab press should cause the highlighted line to be selected, but still | 269 // A tab press should cause the selected line to be accepted, but still |
|
Ilya Sherman
2013/11/05 18:39:45
Thanks for correcting this comment :)
| |
| 270 // return false so the tab key press propagates and changes the cursor | 270 // return false so the tab key press propagates and changes the cursor |
| 271 // location. | 271 // location. |
| 272 AcceptSelectedLine(); | 272 AcceptSelectedLine(); |
| 273 return false; | 273 return false; |
| 274 case ui::VKEY_RETURN: | 274 case ui::VKEY_RETURN: |
| 275 return AcceptSelectedLine(); | 275 return AcceptSelectedLine(); |
| 276 default: | 276 default: |
| 277 return false; | 277 return false; |
| 278 } | 278 } |
| 279 } | 279 } |
| 280 | 280 |
| 281 void AutofillPopupControllerImpl::UpdateBoundsAndRedrawPopup() { | 281 void AutofillPopupControllerImpl::UpdateBoundsAndRedrawPopup() { |
| 282 #if !defined(OS_ANDROID) | 282 #if !defined(OS_ANDROID) |
| 283 // TODO(csharp): Since UpdatePopupBounds can change the position of the popup, | 283 // TODO(csharp): Since UpdatePopupBounds can change the position of the popup, |
| 284 // the popup could end up jumping from above the element to below it. | 284 // the popup could end up jumping from above the element to below it. |
| 285 // It is unclear if it is better to keep the popup where it was, or if it | 285 // It is unclear if it is better to keep the popup where it was, or if it |
| 286 // should try and move to its desired position. | 286 // should try and move to its desired position. |
| 287 UpdatePopupBounds(); | 287 UpdatePopupBounds(); |
| 288 #endif | 288 #endif |
| 289 | 289 |
| 290 view_->UpdateBoundsAndRedrawPopup(); | 290 view_->UpdateBoundsAndRedrawPopup(); |
| 291 } | 291 } |
| 292 | 292 |
| 293 void AutofillPopupControllerImpl::MouseHovered(int x, int y) { | 293 void AutofillPopupControllerImpl::LineSelectedAtPoint(int x, int y) { |
| 294 SetSelectedLine(LineFromY(y)); | 294 SetSelectedLine(LineFromY(y)); |
| 295 } | 295 } |
| 296 | 296 |
| 297 void AutofillPopupControllerImpl::MouseClicked(int x, int y) { | 297 void AutofillPopupControllerImpl::LineAcceptedAtPoint(int x, int y) { |
| 298 MouseHovered(x, y); | 298 LineSelectedAtPoint(x, y); |
| 299 AcceptSelectedLine(); | 299 AcceptSelectedLine(); |
| 300 } | 300 } |
| 301 | 301 |
| 302 void AutofillPopupControllerImpl::MouseExitedPopup() { | 302 void AutofillPopupControllerImpl::SelectionCleared() { |
| 303 SetSelectedLine(kNoSelection); | 303 SetSelectedLine(kNoSelection); |
| 304 } | 304 } |
| 305 | 305 |
| 306 bool AutofillPopupControllerImpl::ShouldRepostEvent( | 306 bool AutofillPopupControllerImpl::ShouldRepostEvent( |
| 307 const ui::MouseEvent& event) { | 307 const ui::MouseEvent& event) { |
| 308 return delegate_->ShouldRepostEvent(event); | 308 return delegate_->ShouldRepostEvent(event); |
| 309 } | 309 } |
| 310 | 310 |
| 311 void AutofillPopupControllerImpl::AcceptSuggestion(size_t index) { | 311 void AutofillPopupControllerImpl::AcceptSuggestion(size_t index) { |
| 312 delegate_->DidAcceptSuggestion(full_names_[index], identifiers_[index]); | 312 delegate_->DidAcceptSuggestion(full_names_[index], identifiers_[index]); |
| (...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 733 // The popup can appear below the field. | 733 // The popup can appear below the field. |
| 734 return std::make_pair(bottom_growth_start, popup_required_height); | 734 return std::make_pair(bottom_growth_start, popup_required_height); |
| 735 } else { | 735 } else { |
| 736 // The popup must appear above the field. | 736 // The popup must appear above the field. |
| 737 return std::make_pair(top_growth_end - popup_required_height, | 737 return std::make_pair(top_growth_end - popup_required_height, |
| 738 popup_required_height); | 738 popup_required_height); |
| 739 } | 739 } |
| 740 } | 740 } |
| 741 | 741 |
| 742 } // namespace autofill | 742 } // namespace autofill |
| OLD | NEW |