Commit 48c85889 authored by estade's avatar estade Committed by Commit bot

Fix a couple of autofill popup issues

1. The popup needs to hide when the renderer resizes (akin to hiding on scroll or orientation change).
2. There was a race condition where the renderer could say Show() then Hide(), but the Hide() would fall on deaf ears because the popup was still waiting for webdata.

The linked bug occurred when the render view was auto-resized /after/ an orientation change. After the orientation change we'd get a text field changed event which would trigger the popup to reshow. The fix is to make the renderer resizing close the popup, but (2) and (3) above were necessary for this to actually work.

BUG=401752

Review URL: https://codereview.chromium.org/482643004

Cr-Commit-Position: refs/heads/master@{#291720}
parent 8df98f36
...@@ -246,6 +246,10 @@ void AutofillAgent::OrientationChangeEvent() { ...@@ -246,6 +246,10 @@ void AutofillAgent::OrientationChangeEvent() {
HidePopup(); HidePopup();
} }
void AutofillAgent::Resized() {
HidePopup();
}
void AutofillAgent::DidChangeScrollOffset(WebLocalFrame*) { void AutofillAgent::DidChangeScrollOffset(WebLocalFrame*) {
HidePopup(); HidePopup();
} }
......
...@@ -68,6 +68,7 @@ class AutofillAgent : public content::RenderViewObserver, ...@@ -68,6 +68,7 @@ class AutofillAgent : public content::RenderViewObserver,
virtual void DidChangeScrollOffset(blink::WebLocalFrame* frame) OVERRIDE; virtual void DidChangeScrollOffset(blink::WebLocalFrame* frame) OVERRIDE;
virtual void FocusedNodeChanged(const blink::WebNode& node) OVERRIDE; virtual void FocusedNodeChanged(const blink::WebNode& node) OVERRIDE;
virtual void OrientationChangeEvent() OVERRIDE; virtual void OrientationChangeEvent() OVERRIDE;
virtual void Resized() OVERRIDE;
// PageClickListener: // PageClickListener:
virtual void FormControlElementClicked( virtual void FormControlElementClicked(
......
...@@ -46,6 +46,9 @@ class AutocompleteHistoryManager : public WebDataServiceConsumer { ...@@ -46,6 +46,9 @@ class AutocompleteHistoryManager : public WebDataServiceConsumer {
const std::vector<int>& autofill_unique_ids); const std::vector<int>& autofill_unique_ids);
virtual void OnFormSubmitted(const FormData& form); virtual void OnFormSubmitted(const FormData& form);
// Cancels the currently pending WebDataService query, if there is one.
void CancelPendingQuery();
// Must be public for the external delegate to use. // Must be public for the external delegate to use.
void OnRemoveAutocompleteEntry(const base::string16& name, void OnRemoveAutocompleteEntry(const base::string16& name,
const base::string16& value); const base::string16& value);
...@@ -60,9 +63,6 @@ class AutocompleteHistoryManager : public WebDataServiceConsumer { ...@@ -60,9 +63,6 @@ class AutocompleteHistoryManager : public WebDataServiceConsumer {
void SendSuggestions(const std::vector<base::string16>* suggestions); void SendSuggestions(const std::vector<base::string16>* suggestions);
private: private:
// Cancels the currently pending WebDataService query, if there is one.
void CancelPendingQuery();
// Provides driver-level context. Must outlive this object. // Provides driver-level context. Must outlive this object.
AutofillDriver* driver_; AutofillDriver* driver_;
scoped_refptr<AutofillWebDataService> database_; scoped_refptr<AutofillWebDataService> database_;
......
...@@ -693,6 +693,7 @@ void AutofillManager::OnHidePopup() { ...@@ -693,6 +693,7 @@ void AutofillManager::OnHidePopup() {
if (!IsAutofillEnabled()) if (!IsAutofillEnabled())
return; return;
autocomplete_history_manager_->CancelPendingQuery();
client_->HideAutofillPopup(); client_->HideAutofillPopup();
} }
......
...@@ -93,6 +93,7 @@ class CONTENT_EXPORT RenderViewObserver : public IPC::Listener, ...@@ -93,6 +93,7 @@ class CONTENT_EXPORT RenderViewObserver : public IPC::Listener,
virtual void Navigate(const GURL& url) {} virtual void Navigate(const GURL& url) {}
virtual void ClosePage() {} virtual void ClosePage() {}
virtual void OrientationChangeEvent() {} virtual void OrientationChangeEvent() {}
virtual void Resized() {}
virtual void OnStop() {} virtual void OnStop() {}
......
...@@ -3290,6 +3290,10 @@ void RenderViewImpl::OnResize(const ViewMsg_Resize_Params& params) { ...@@ -3290,6 +3290,10 @@ void RenderViewImpl::OnResize(const ViewMsg_Resize_Params& params) {
if (old_visible_viewport_size != visible_viewport_size_) if (old_visible_viewport_size != visible_viewport_size_)
has_scrolled_focused_editable_node_into_rect_ = false; has_scrolled_focused_editable_node_into_rect_ = false;
FOR_EACH_OBSERVER(RenderViewObserver,
observers_,
Resized());
} }
void RenderViewImpl::DidInitiatePaint() { void RenderViewImpl::DidInitiatePaint() {
......
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