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 527 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
538 // If the maxlength attribute contains a negative value, maxLength() | 538 // If the maxlength attribute contains a negative value, maxLength() |
539 // returns the default maxlength value. | 539 // returns the default maxlength value. |
540 input_element->setValue( | 540 input_element->setValue( |
541 data.value.substr(0, input_element->maxLength()), true); | 541 data.value.substr(0, input_element->maxLength()), true); |
542 if (is_initiating_node) { | 542 if (is_initiating_node) { |
543 int length = input_element->value().length(); | 543 int length = input_element->value().length(); |
544 input_element->setSelectionRange(length, length); | 544 input_element->setSelectionRange(length, length); |
545 // Clear the current IME composition (the underline), if there is one. | 545 // Clear the current IME composition (the underline), if there is one. |
546 input_element->document().frame()->unmarkText(); | 546 input_element->document().frame()->unmarkText(); |
547 } | 547 } |
548 } else if (IsTextAreaElement(*field)) { | 548 } else if (IsTextAreaElement(*field) || IsSelectElement(*field)) { |
549 WebTextAreaElement text_area = field->to<WebTextAreaElement>(); | 549 field->setValue(data.value, true); |
Ilya Sherman
2014/03/28 21:12:44
Your repo is out of date. Please sync and rebase.
Dan Beam
2014/03/28 23:03:57
Done.
| |
550 if (text_area.value() != data.value) { | |
551 text_area.setValue(data.value); | |
552 text_area.dispatchFormControlChangeEvent(); | |
553 } | |
554 } else if (IsSelectElement(*field)) { | |
555 WebSelectElement select_element = field->to<WebSelectElement>(); | |
556 if (select_element.value() != data.value) { | |
557 select_element.setValue(data.value); | |
558 select_element.dispatchFormControlChangeEvent(); | |
559 } | |
560 } else { | 550 } else { |
561 DCHECK(IsCheckableElement(input_element)); | 551 DCHECK(IsCheckableElement(input_element)); |
562 input_element->setChecked(data.is_checked, true); | 552 input_element->setChecked(data.is_checked, true); |
563 } | 553 } |
564 } | 554 } |
565 | 555 |
566 // Sets the |field|'s "suggested" (non JS visible) value to the value in |data|. | 556 // Sets the |field|'s "suggested" (non JS visible) value to the value in |data|. |
567 // Also sets the "autofilled" attribute, causing the background to be yellow. | 557 // Also sets the "autofilled" attribute, causing the background to be yellow. |
568 void PreviewFormField(const FormFieldData& data, | 558 void PreviewFormField(const FormFieldData& data, |
569 bool is_initiating_node, | 559 bool is_initiating_node, |
(...skipping 616 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1186 | 1176 |
1187 gfx::RectF GetScaledBoundingBox(float scale, WebInputElement* element) { | 1177 gfx::RectF GetScaledBoundingBox(float scale, WebInputElement* element) { |
1188 gfx::Rect bounding_box(element->boundsInViewportSpace()); | 1178 gfx::Rect bounding_box(element->boundsInViewportSpace()); |
1189 return gfx::RectF(bounding_box.x() * scale, | 1179 return gfx::RectF(bounding_box.x() * scale, |
1190 bounding_box.y() * scale, | 1180 bounding_box.y() * scale, |
1191 bounding_box.width() * scale, | 1181 bounding_box.width() * scale, |
1192 bounding_box.height() * scale); | 1182 bounding_box.height() * scale); |
1193 } | 1183 } |
1194 | 1184 |
1195 } // namespace autofill | 1185 } // namespace autofill |
OLD | NEW |