diff options
author | vabr <vabr@chromium.org> | 2015-02-13 07:14:35 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-02-13 15:15:33 +0000 |
commit | ae130ef602aef780ed69597eb875dca2d904d473 (patch) | |
tree | 399e1701478cc64746d45fed0ed6dc5a18c3339f | |
parent | 7ec5114efa5eada853c2ece5d6edb0fa4ce5611a (diff) | |
download | chromium_src-ae130ef602aef780ed69597eb875dca2d904d473.zip chromium_src-ae130ef602aef780ed69597eb875dca2d904d473.tar.gz chromium_src-ae130ef602aef780ed69597eb875dca2d904d473.tar.bz2 |
PasswordAutofillAgent: only check visibility if needed
PasswordAutofillAgent::SendPasswordForms is called twice during page load:
On DidFinishDocumentLoad, when it is interested in parsed HTML forms,
and on DidFinishLoad, when it is interested in those forms, which are also visible.
Currently, the method does the visibility check all the times, and throuws out the result in the first situation.
This is not only wasting computational resources, but possibly causing crashes due to not finished rendering computations.
This CL fixes that, and only does the visibility check if needed.
BUG=457243
Review URL: https://codereview.chromium.org/925983002
Cr-Commit-Position: refs/heads/master@{#316218}
-rw-r--r-- | components/autofill/content/renderer/password_autofill_agent.cc | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/components/autofill/content/renderer/password_autofill_agent.cc b/components/autofill/content/renderer/password_autofill_agent.cc index db5d26d..0f64220 100644 --- a/components/autofill/content/renderer/password_autofill_agent.cc +++ b/components/autofill/content/renderer/password_autofill_agent.cc @@ -893,16 +893,18 @@ void PasswordAutofillAgent::SendPasswordForms(bool only_visible) { std::vector<PasswordForm> password_forms; for (size_t i = 0; i < forms.size(); ++i) { const blink::WebFormElement& form = forms[i]; - bool is_form_visible = IsWebNodeVisible(form); - if (logger) { - LogHTMLForm(logger.get(), Logger::STRING_FORM_FOUND_ON_PAGE, form); - logger->LogBoolean(Logger::STRING_FORM_IS_VISIBLE, is_form_visible); - } + if (only_visible) { + bool is_form_visible = IsWebNodeVisible(form); + if (logger) { + LogHTMLForm(logger.get(), Logger::STRING_FORM_FOUND_ON_PAGE, form); + logger->LogBoolean(Logger::STRING_FORM_IS_VISIBLE, is_form_visible); + } - // If requested, ignore non-rendered forms, e.g. those styled with - // display:none. - if (only_visible && !is_form_visible) - continue; + // If requested, ignore non-rendered forms, e.g., those styled with + // display:none. + if (!is_form_visible) + continue; + } scoped_ptr<PasswordForm> password_form(CreatePasswordForm(form, nullptr)); if (password_form.get()) { |