Commit 35c8765c authored by Vaclav Brozek's avatar Vaclav Brozek Committed by Commit Bot

Move SyntheticForm into GetPasswordForm

A SyntheticForm is an object created specifically for the
GetPasswordForm function to consume. Yet, the function only takes a
const reference of a SyntheticForm. This prevents the function from
sparing some copies in moving data from a SyntheticForm to a
PasswordForm.

This CL changes the const reference to a plain value, moves the
SyntheticForm via std::move on the callsites, and ensures that
SyntheticForm has a move constructor.

Bug: 833838
Change-Id: Iaee54b092c7f12b91b2afd35f4882b9d451ce668
Reviewed-on: https://chromium-review.googlesource.com/1013983
Commit-Queue: Vaclav Brozek <vabr@chromium.org>
Reviewed-by: default avatarVadym Doroshenko <dvadym@chromium.org>
Cr-Commit-Position: refs/heads/master@{#551425}
parent 6d9e97dc
...@@ -65,6 +65,7 @@ enum class FieldFilteringLevel { ...@@ -65,6 +65,7 @@ enum class FieldFilteringLevel {
// view of the underlying data, regardless of its origin. // view of the underlying data, regardless of its origin.
struct SyntheticForm { struct SyntheticForm {
SyntheticForm(); SyntheticForm();
SyntheticForm(SyntheticForm&& other);
~SyntheticForm(); ~SyntheticForm();
std::vector<blink::WebElement> fieldsets; std::vector<blink::WebElement> fieldsets;
...@@ -78,8 +79,9 @@ struct SyntheticForm { ...@@ -78,8 +79,9 @@ struct SyntheticForm {
DISALLOW_COPY_AND_ASSIGN(SyntheticForm); DISALLOW_COPY_AND_ASSIGN(SyntheticForm);
}; };
SyntheticForm::SyntheticForm() {} SyntheticForm::SyntheticForm() = default;
SyntheticForm::~SyntheticForm() {} SyntheticForm::SyntheticForm(SyntheticForm&& other) = default;
SyntheticForm::~SyntheticForm() = default;
// Layout classification of password forms // Layout classification of password forms
// A layout sequence of a form is the sequence of it's non-password and password // A layout sequence of a form is the sequence of it's non-password and password
...@@ -460,7 +462,7 @@ bool ScriptModifiedUsernameAcceptable( ...@@ -460,7 +462,7 @@ bool ScriptModifiedUsernameAcceptable(
// associated string is used instead of the element's value to create // associated string is used instead of the element's value to create
// the PasswordForm. // the PasswordForm.
bool GetPasswordForm( bool GetPasswordForm(
const SyntheticForm& form, SyntheticForm form,
PasswordForm* password_form, PasswordForm* password_form,
const FieldValueAndPropertiesMaskMap* field_value_and_properties_map, const FieldValueAndPropertiesMaskMap* field_value_and_properties_map,
const FormsPredictionsMap* form_predictions, const FormsPredictionsMap* form_predictions,
...@@ -752,7 +754,7 @@ bool GetPasswordForm( ...@@ -752,7 +754,7 @@ bool GetPasswordForm(
password_form->username_value = username_value; password_form->username_value = username_value;
} }
password_form->origin = form.origin; password_form->origin = std::move(form.origin);
password_form->signon_realm = GetSignOnRealm(password_form->origin); password_form->signon_realm = GetSignOnRealm(password_form->origin);
// Convert |possible_usernames| to ValueElementVector. // Convert |possible_usernames| to ValueElementVector.
...@@ -902,7 +904,7 @@ std::unique_ptr<PasswordForm> CreatePasswordFormFromWebForm( ...@@ -902,7 +904,7 @@ std::unique_ptr<PasswordForm> CreatePasswordFormFromWebForm(
return std::unique_ptr<PasswordForm>(); return std::unique_ptr<PasswordForm>();
} }
if (!GetPasswordForm(synthetic_form, password_form.get(), if (!GetPasswordForm(std::move(synthetic_form), password_form.get(),
field_value_and_properties_map, form_predictions, field_value_and_properties_map, form_predictions,
username_detector_cache)) { username_detector_cache)) {
return std::unique_ptr<PasswordForm>(); return std::unique_ptr<PasswordForm>();
...@@ -932,7 +934,7 @@ std::unique_ptr<PasswordForm> CreatePasswordFormFromUnownedInputElements( ...@@ -932,7 +934,7 @@ std::unique_ptr<PasswordForm> CreatePasswordFormFromUnownedInputElements(
nullptr /* FormFieldData */)) { nullptr /* FormFieldData */)) {
return std::unique_ptr<PasswordForm>(); return std::unique_ptr<PasswordForm>();
} }
if (!GetPasswordForm(synthetic_form, password_form.get(), if (!GetPasswordForm(std::move(synthetic_form), password_form.get(),
field_value_and_properties_map, form_predictions, field_value_and_properties_map, form_predictions,
username_detector_cache)) { username_detector_cache)) {
return std::unique_ptr<PasswordForm>(); return std::unique_ptr<PasswordForm>();
......
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