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 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 165 } else { | 165 } else { |
| 166 UpdateBoundsAndRedrawPopup(); | 166 UpdateBoundsAndRedrawPopup(); |
| 167 } | 167 } |
| 168 | 168 |
| 169 delegate_->OnPopupShown(this); | 169 delegate_->OnPopupShown(this); |
| 170 } | 170 } |
| 171 | 171 |
| 172 void AutofillPopupControllerImpl::Hide() { | 172 void AutofillPopupControllerImpl::Hide() { |
| 173 if (is_hiding_) | 173 if (is_hiding_) |
| 174 return; | 174 return; |
| 175 is_hiding_ = true; | 175 is_hiding_ = true; |
|
Ilya Sherman
2013/02/26 01:02:32
Since deletion now happens synchronously within th
csharp
2013/02/26 18:33:31
True, fixed.
| |
| 176 | 176 |
| 177 SetSelectedLine(kNoSelection); | 177 SetSelectedLine(kNoSelection); |
| 178 | 178 |
| 179 delegate_->OnPopupHidden(this); | 179 delegate_->OnPopupHidden(this); |
| 180 | 180 |
| 181 if (view_) | 181 if (view_) |
| 182 view_->Hide(); | 182 view_->Hide(); |
| 183 else | 183 |
| 184 delete this; | 184 delete this; |
| 185 } | 185 } |
| 186 | 186 |
| 187 bool AutofillPopupControllerImpl::HandleKeyPressEvent( | 187 bool AutofillPopupControllerImpl::HandleKeyPressEvent( |
| 188 const content::NativeWebKeyboardEvent& event) { | 188 const content::NativeWebKeyboardEvent& event) { |
| 189 switch (event.windowsKeyCode) { | 189 switch (event.windowsKeyCode) { |
| 190 case ui::VKEY_UP: | 190 case ui::VKEY_UP: |
| 191 SelectPreviousLine(); | 191 SelectPreviousLine(); |
| 192 return true; | 192 return true; |
| 193 case ui::VKEY_DOWN: | 193 case ui::VKEY_DOWN: |
| 194 SelectNextLine(); | 194 SelectNextLine(); |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 205 case ui::VKEY_DELETE: | 205 case ui::VKEY_DELETE: |
| 206 return (event.modifiers & content::NativeWebKeyboardEvent::ShiftKey) && | 206 return (event.modifiers & content::NativeWebKeyboardEvent::ShiftKey) && |
| 207 RemoveSelectedLine(); | 207 RemoveSelectedLine(); |
| 208 case ui::VKEY_RETURN: | 208 case ui::VKEY_RETURN: |
| 209 return AcceptSelectedLine(); | 209 return AcceptSelectedLine(); |
| 210 default: | 210 default: |
| 211 return false; | 211 return false; |
| 212 } | 212 } |
| 213 } | 213 } |
| 214 | 214 |
| 215 void AutofillPopupControllerImpl::ViewDestroyed() { | |
| 216 delete this; | |
| 217 } | |
| 218 | |
| 219 void AutofillPopupControllerImpl::UpdateBoundsAndRedrawPopup() { | 215 void AutofillPopupControllerImpl::UpdateBoundsAndRedrawPopup() { |
| 220 #if !defined(OS_ANDROID) | 216 #if !defined(OS_ANDROID) |
| 221 // TODO(csharp): Since UpdatePopupBounds can change the position of the popup, | 217 // TODO(csharp): Since UpdatePopupBounds can change the position of the popup, |
| 222 // the popup could end up jumping from above the element to below it. | 218 // the popup could end up jumping from above the element to below it. |
| 223 // It is unclear if it is better to keep the popup where it was, or if it | 219 // It is unclear if it is better to keep the popup where it was, or if it |
| 224 // should try and move to its desired position. | 220 // should try and move to its desired position. |
| 225 UpdatePopupBounds(); | 221 UpdatePopupBounds(); |
| 226 #endif | 222 #endif |
| 227 | 223 |
| 228 view_->UpdateBoundsAndRedrawPopup(); | 224 view_->UpdateBoundsAndRedrawPopup(); |
| (...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 654 if (bottom_available >= popup_required_height || | 650 if (bottom_available >= popup_required_height || |
| 655 bottom_available >= top_available) { | 651 bottom_available >= top_available) { |
| 656 // The popup can appear below the field. | 652 // The popup can appear below the field. |
| 657 return std::make_pair(bottom_growth_start, popup_required_height); | 653 return std::make_pair(bottom_growth_start, popup_required_height); |
| 658 } else { | 654 } else { |
| 659 // The popup must appear above the field. | 655 // The popup must appear above the field. |
| 660 return std::make_pair(top_growth_end - popup_required_height, | 656 return std::make_pair(top_growth_end - popup_required_height, |
| 661 popup_required_height); | 657 popup_required_height); |
| 662 } | 658 } |
| 663 } | 659 } |
| OLD | NEW |