| 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 522 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 533 void FillFormField(const FormFieldData& data, | 533 void FillFormField(const FormFieldData& data, |
| 534 bool is_initiating_node, | 534 bool is_initiating_node, |
| 535 blink::WebFormControlElement* field) { | 535 blink::WebFormControlElement* field) { |
| 536 // Nothing to fill. | 536 // Nothing to fill. |
| 537 if (data.value.empty()) | 537 if (data.value.empty()) |
| 538 return; | 538 return; |
| 539 | 539 |
| 540 if (!data.is_autofilled) | 540 if (!data.is_autofilled) |
| 541 return; | 541 return; |
| 542 | 542 |
| 543 field->setAutofilled(true); | |
| 544 | |
| 545 WebInputElement* input_element = toWebInputElement(field); | 543 WebInputElement* input_element = toWebInputElement(field); |
| 546 if (IsCheckableElement(input_element)) { | 544 if (IsCheckableElement(input_element)) { |
| 547 input_element->setChecked(data.is_checked, true); | 545 input_element->setChecked(data.is_checked, true); |
| 548 } else { | 546 } else { |
| 549 base::string16 value = data.value; | 547 base::string16 value = data.value; |
| 550 if (IsTextInput(input_element) || IsMonthInput(input_element)) { | 548 if (IsTextInput(input_element) || IsMonthInput(input_element)) { |
| 551 // If the maxlength attribute contains a negative value, maxLength() | 549 // If the maxlength attribute contains a negative value, maxLength() |
| 552 // returns the default maxlength value. | 550 // returns the default maxlength value. |
| 553 value = value.substr(0, input_element->maxLength()); | 551 value = value.substr(0, input_element->maxLength()); |
| 554 } | 552 } |
| 555 field->setValue(value, true); | 553 field->setValue(value, true); |
| 556 } | 554 } |
| 557 | 555 |
| 556 field->setAutofilled(true); |
| 557 |
| 558 if (is_initiating_node && | 558 if (is_initiating_node && |
| 559 ((IsTextInput(input_element) || IsMonthInput(input_element)) || | 559 ((IsTextInput(input_element) || IsMonthInput(input_element)) || |
| 560 IsTextAreaElement(*field))) { | 560 IsTextAreaElement(*field))) { |
| 561 int length = field->value().length(); | 561 int length = field->value().length(); |
| 562 field->setSelectionRange(length, length); | 562 field->setSelectionRange(length, length); |
| 563 // Clear the current IME composition (the underline), if there is one. | 563 // Clear the current IME composition (the underline), if there is one. |
| 564 field->document().frame()->unmarkText(); | 564 field->document().frame()->unmarkText(); |
| 565 } | 565 } |
| 566 } | 566 } |
| 567 | 567 |
| (...skipping 613 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1181 | 1181 |
| 1182 gfx::RectF GetScaledBoundingBox(float scale, WebFormControlElement* element) { | 1182 gfx::RectF GetScaledBoundingBox(float scale, WebFormControlElement* element) { |
| 1183 gfx::Rect bounding_box(element->boundsInViewportSpace()); | 1183 gfx::Rect bounding_box(element->boundsInViewportSpace()); |
| 1184 return gfx::RectF(bounding_box.x() * scale, | 1184 return gfx::RectF(bounding_box.x() * scale, |
| 1185 bounding_box.y() * scale, | 1185 bounding_box.y() * scale, |
| 1186 bounding_box.width() * scale, | 1186 bounding_box.width() * scale, |
| 1187 bounding_box.height() * scale); | 1187 bounding_box.height() * scale); |
| 1188 } | 1188 } |
| 1189 | 1189 |
| 1190 } // namespace autofill | 1190 } // namespace autofill |
| OLD | NEW |