Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "components/autofill/content/renderer/form_autofill_util.h" | 5 #include "components/autofill/content/renderer/form_autofill_util.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 526 void FillFormField(const FormFieldData& data, | 526 void FillFormField(const FormFieldData& data, |
| 527 bool is_initiating_node, | 527 bool is_initiating_node, |
| 528 blink::WebFormControlElement* field) { | 528 blink::WebFormControlElement* field) { |
| 529 // Nothing to fill. | 529 // Nothing to fill. |
| 530 if (data.value.empty()) | 530 if (data.value.empty()) |
| 531 return; | 531 return; |
| 532 | 532 |
| 533 field->setAutofilled(true); | 533 field->setAutofilled(true); |
| 534 | 534 |
| 535 WebInputElement* input_element = toWebInputElement(field); | 535 WebInputElement* input_element = toWebInputElement(field); |
| 536 base::string16 value = data.value; | |
| 536 if (IsTextInput(input_element) || IsMonthInput(input_element)) { | 537 if (IsTextInput(input_element) || IsMonthInput(input_element)) { |
| 537 // If the maxlength attribute contains a negative value, maxLength() | 538 // If the maxlength attribute contains a negative value, maxLength() |
| 538 // returns the default maxlength value. | 539 // returns the default maxlength value. |
| 539 input_element->setValue( | 540 value = value.substr(0, input_element->maxLength()); |
| 540 data.value.substr(0, input_element->maxLength()), true); | 541 } |
| 541 } else if (IsTextAreaElement(*field) || IsSelectElement(*field)) { | 542 |
| 542 if (field->value() != data.value) { | 543 if (IsCheckableElement(input_element)) |
| 543 field->setValue(data.value); | |
| 544 field->dispatchFormControlChangeEvent(); | |
| 545 } | |
| 546 } else { | |
| 547 DCHECK(IsCheckableElement(input_element)); | |
| 548 input_element->setChecked(data.is_checked, true); | 544 input_element->setChecked(data.is_checked, true); |
| 549 } | 545 else |
| 546 field->setValue(data.value, true); | |
|
Ilya Sherman
2014/03/29 00:07:07
I noticed that you've removed the check "if (field
Dan Beam
2014/03/29 00:51:14
yes
| |
| 550 | 547 |
| 551 if (is_initiating_node && | 548 if (is_initiating_node && |
| 552 ((IsTextInput(input_element) || IsMonthInput(input_element)) || | 549 ((IsTextInput(input_element) || IsMonthInput(input_element)) || |
| 553 IsTextAreaElement(*field))) { | 550 IsTextAreaElement(*field))) { |
| 554 int length = field->value().length(); | 551 int length = field->value().length(); |
| 555 field->setSelectionRange(length, length); | 552 field->setSelectionRange(length, length); |
| 556 // Clear the current IME composition (the underline), if there is one. | 553 // Clear the current IME composition (the underline), if there is one. |
| 557 field->document().frame()->unmarkText(); | 554 field->document().frame()->unmarkText(); |
| 558 } | 555 } |
| 559 } | 556 } |
| (...skipping 614 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1174 | 1171 |
| 1175 gfx::RectF GetScaledBoundingBox(float scale, WebFormControlElement* element) { | 1172 gfx::RectF GetScaledBoundingBox(float scale, WebFormControlElement* element) { |
| 1176 gfx::Rect bounding_box(element->boundsInViewportSpace()); | 1173 gfx::Rect bounding_box(element->boundsInViewportSpace()); |
| 1177 return gfx::RectF(bounding_box.x() * scale, | 1174 return gfx::RectF(bounding_box.x() * scale, |
| 1178 bounding_box.y() * scale, | 1175 bounding_box.y() * scale, |
| 1179 bounding_box.width() * scale, | 1176 bounding_box.width() * scale, |
| 1180 bounding_box.height() * scale); | 1177 bounding_box.height() * scale); |
| 1181 } | 1178 } |
| 1182 | 1179 |
| 1183 } // namespace autofill | 1180 } // namespace autofill |
| OLD | NEW |