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 563 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
574 // Preview input, textarea and select fields. For input fields, excludes | 574 // Preview input, textarea and select fields. For input fields, excludes |
575 // checkboxes and radio buttons, as there is no provision for | 575 // checkboxes and radio buttons, as there is no provision for |
576 // setSuggestedCheckedValue in WebInputElement. | 576 // setSuggestedCheckedValue in WebInputElement. |
577 WebInputElement* input_element = toWebInputElement(field); | 577 WebInputElement* input_element = toWebInputElement(field); |
578 if (IsTextInput(input_element) || IsMonthInput(input_element)) { | 578 if (IsTextInput(input_element) || IsMonthInput(input_element)) { |
579 // If the maxlength attribute contains a negative value, maxLength() | 579 // If the maxlength attribute contains a negative value, maxLength() |
580 // returns the default maxlength value. | 580 // returns the default maxlength value. |
581 input_element->setSuggestedValue( | 581 input_element->setSuggestedValue( |
582 data.value.substr(0, input_element->maxLength())); | 582 data.value.substr(0, input_element->maxLength())); |
583 input_element->setAutofilled(true); | 583 input_element->setAutofilled(true); |
584 } else if (IsTextAreaElement(*field) || IsSelectElement(*field)) { | 584 } else if (IsTextAreaElement(*field)) { |
585 field->setSuggestedValue(data.value); | 585 field->setSuggestedValue(data.value); |
586 field->setAutofilled(true); | 586 field->setAutofilled(true); |
587 } else { | |
588 DCHECK(IsSelectElement(*field)); | |
589 field->setSuggestedValue(data.value); | |
Ilya Sherman
2014/06/02 23:51:00
We should only set the suggested value if the fiel
| |
590 if (data.is_autofilled) | |
591 field->setAutofilled(true); | |
587 } | 592 } |
588 | 593 |
589 if (is_initiating_node && | 594 if (is_initiating_node && |
590 (IsTextInput(input_element) || IsTextAreaElement(*field))) { | 595 (IsTextInput(input_element) || IsTextAreaElement(*field))) { |
591 // Select the part of the text that the user didn't type. | 596 // Select the part of the text that the user didn't type. |
592 int start = field->value().length(); | 597 int start = field->value().length(); |
593 int end = field->suggestedValue().length(); | 598 int end = field->suggestedValue().length(); |
594 field->setSelectionRange(start, end); | 599 field->setSelectionRange(start, end); |
595 } | 600 } |
596 } | 601 } |
(...skipping 581 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1178 | 1183 |
1179 gfx::RectF GetScaledBoundingBox(float scale, WebFormControlElement* element) { | 1184 gfx::RectF GetScaledBoundingBox(float scale, WebFormControlElement* element) { |
1180 gfx::Rect bounding_box(element->boundsInViewportSpace()); | 1185 gfx::Rect bounding_box(element->boundsInViewportSpace()); |
1181 return gfx::RectF(bounding_box.x() * scale, | 1186 return gfx::RectF(bounding_box.x() * scale, |
1182 bounding_box.y() * scale, | 1187 bounding_box.y() * scale, |
1183 bounding_box.width() * scale, | 1188 bounding_box.width() * scale, |
1184 bounding_box.height() * scale); | 1189 bounding_box.height() * scale); |
1185 } | 1190 } |
1186 | 1191 |
1187 } // namespace autofill | 1192 } // namespace autofill |
OLD | NEW |