Commit 27c9c76c authored by suzhe@google.com's avatar suzhe@google.com

Fix a CHECK failure in AutocompletePopupModel::InfoForCurrentSelection().

BUG=70344
TEST=See bug report.

Review URL: http://codereview.chromium.org/6380012

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@72417 0039d316-1c4b-4281-b951-d872f2087c98
parent 15972e04
......@@ -479,12 +479,6 @@ void AutocompleteEditModel::OnKillFocus() {
has_focus_ = false;
control_key_state_ = UP;
paste_state_ = NONE;
// Like typing, killing focus "accepts" the temporary text as the user
// text, because it makes little sense to have temporary text when the
// popup is closed.
InternalSetUserText(UserTextFromDisplayText(view_->GetText()));
has_temporary_text_ = false;
}
bool AutocompleteEditModel::OnEscapeKeyPressed() {
......@@ -680,6 +674,14 @@ void AutocompleteEditModel::PopupBoundsChangedTo(const gfx::Rect& bounds) {
controller_->OnPopupBoundsChanged(bounds);
}
void AutocompleteEditModel::OnPopupClosed() {
// Accepts the temporary text as the user text, because it makes little
// sense to have temporary text when the popup is closed.
InternalSetUserText(UserTextFromDisplayText(view_->GetText()));
has_temporary_text_ = false;
PopupBoundsChangedTo(gfx::Rect());
}
// Return true if the suggestion type warrants a TCP/IP preconnection.
// i.e., it is now highly likely that the user will select the related domain.
static bool IsPreconnectable(AutocompleteMatch::Type type) {
......
......@@ -319,6 +319,9 @@ class AutocompleteEditModel : public NotificationObserver {
// Invoked when the popup is going to change its bounds to |bounds|.
void PopupBoundsChangedTo(const gfx::Rect& bounds);
// Called when the popup is closed.
void OnPopupClosed();
private:
enum PasteState {
NONE, // Most recent edit was not a paste.
......
......@@ -317,8 +317,12 @@ void AutocompletePopupModel::Observe(NotificationType type,
if ((hovered_line_ != kNoMatch) && (result->size() <= hovered_line_))
SetHoveredLine(kNoMatch);
const bool was_open = view_->IsOpen();
view_->UpdatePopupAppearance();
edit_model_->PopupBoundsChangedTo(view_->GetTargetBounds());
if (view_->IsOpen())
edit_model_->PopupBoundsChangedTo(view_->GetTargetBounds());
else if (was_open)
edit_model_->OnPopupClosed();
}
const SkBitmap* AutocompletePopupModel::GetSpecialIconForMatch(
......
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