Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(42)

Side by Side Diff: components/autofill/content/renderer/form_autofill_util.cc

Issue 152133004: Update WebNode::getElementsByTagName() callers to use a WebNodeCollection (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « android_webview/renderer/aw_render_view_ext.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 10 matching lines...) Expand all
21 #include "third_party/WebKit/public/platform/WebVector.h" 21 #include "third_party/WebKit/public/platform/WebVector.h"
22 #include "third_party/WebKit/public/web/WebDocument.h" 22 #include "third_party/WebKit/public/web/WebDocument.h"
23 #include "third_party/WebKit/public/web/WebElement.h" 23 #include "third_party/WebKit/public/web/WebElement.h"
24 #include "third_party/WebKit/public/web/WebExceptionCode.h" 24 #include "third_party/WebKit/public/web/WebExceptionCode.h"
25 #include "third_party/WebKit/public/web/WebFormControlElement.h" 25 #include "third_party/WebKit/public/web/WebFormControlElement.h"
26 #include "third_party/WebKit/public/web/WebFormElement.h" 26 #include "third_party/WebKit/public/web/WebFormElement.h"
27 #include "third_party/WebKit/public/web/WebFrame.h" 27 #include "third_party/WebKit/public/web/WebFrame.h"
28 #include "third_party/WebKit/public/web/WebInputElement.h" 28 #include "third_party/WebKit/public/web/WebInputElement.h"
29 #include "third_party/WebKit/public/web/WebLabelElement.h" 29 #include "third_party/WebKit/public/web/WebLabelElement.h"
30 #include "third_party/WebKit/public/web/WebNode.h" 30 #include "third_party/WebKit/public/web/WebNode.h"
31 #include "third_party/WebKit/public/web/WebNodeCollection.h"
31 #include "third_party/WebKit/public/web/WebNodeList.h" 32 #include "third_party/WebKit/public/web/WebNodeList.h"
32 #include "third_party/WebKit/public/web/WebOptionElement.h" 33 #include "third_party/WebKit/public/web/WebOptionElement.h"
33 #include "third_party/WebKit/public/web/WebSelectElement.h" 34 #include "third_party/WebKit/public/web/WebSelectElement.h"
34 #include "third_party/WebKit/public/web/WebTextAreaElement.h" 35 #include "third_party/WebKit/public/web/WebTextAreaElement.h"
35 36
36 using blink::WebDocument; 37 using blink::WebDocument;
37 using blink::WebElement; 38 using blink::WebElement;
38 using blink::WebExceptionCode; 39 using blink::WebExceptionCode;
39 using blink::WebFormControlElement; 40 using blink::WebFormControlElement;
40 using blink::WebFormElement; 41 using blink::WebFormElement;
41 using blink::WebFrame; 42 using blink::WebFrame;
42 using blink::WebInputElement; 43 using blink::WebInputElement;
43 using blink::WebLabelElement; 44 using blink::WebLabelElement;
44 using blink::WebNode; 45 using blink::WebNode;
46 using blink::WebNodeCollection;
45 using blink::WebNodeList; 47 using blink::WebNodeList;
46 using blink::WebOptionElement; 48 using blink::WebOptionElement;
47 using blink::WebSelectElement; 49 using blink::WebSelectElement;
48 using blink::WebTextAreaElement; 50 using blink::WebTextAreaElement;
49 using blink::WebString; 51 using blink::WebString;
50 using blink::WebVector; 52 using blink::WebVector;
51 53
52 namespace autofill { 54 namespace autofill {
53 namespace { 55 namespace {
54 56
(...skipping 843 matching lines...) Expand 10 before | Expand all | Expand 10 after
898 // If we failed to extract any fields, give up. Also, to avoid overly 900 // If we failed to extract any fields, give up. Also, to avoid overly
899 // expensive computation, we impose a maximum number of allowable fields. 901 // expensive computation, we impose a maximum number of allowable fields.
900 if (form_fields.empty() || form_fields.size() > kMaxParseableFields) 902 if (form_fields.empty() || form_fields.size() > kMaxParseableFields)
901 return false; 903 return false;
902 904
903 // Loop through the label elements inside the form element. For each label 905 // Loop through the label elements inside the form element. For each label
904 // element, get the corresponding form control element, use the form control 906 // element, get the corresponding form control element, use the form control
905 // element's name as a key into the <name, FormFieldData> map to find the 907 // element's name as a key into the <name, FormFieldData> map to find the
906 // previously created FormFieldData and set the FormFieldData's label to the 908 // previously created FormFieldData and set the FormFieldData's label to the
907 // label.firstChild().nodeValue() of the label element. 909 // label.firstChild().nodeValue() of the label element.
908 WebNodeList labels = form_element.getElementsByTagName(kLabel); 910 WebNodeCollection labels = form_element.getElementsByTagName(kLabel);
909 for (unsigned i = 0; i < labels.length(); ++i) { 911 DCHECK(!labels.isNull());
910 WebLabelElement label = labels.item(i).to<WebLabelElement>(); 912 for (WebNode item = labels.firstItem(); !item.isNull();
913 item = labels.nextItem()) {
914 WebLabelElement label = item.to<WebLabelElement>();
911 WebFormControlElement field_element = 915 WebFormControlElement field_element =
912 label.correspondingControl().to<WebFormControlElement>(); 916 label.correspondingControl().to<WebFormControlElement>();
913 917
914 base::string16 element_name; 918 base::string16 element_name;
915 if (field_element.isNull()) { 919 if (field_element.isNull()) {
916 // Sometimes site authors will incorrectly specify the corresponding 920 // Sometimes site authors will incorrectly specify the corresponding
917 // field element's name rather than its id, so we compensate here. 921 // field element's name rather than its id, so we compensate here.
918 element_name = label.getAttribute(kFor); 922 element_name = label.getAttribute(kFor);
919 } else if ( 923 } else if (
920 !field_element.isFormControlElement() || 924 !field_element.isFormControlElement() ||
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
1177 1181
1178 gfx::RectF GetScaledBoundingBox(float scale, WebInputElement* element) { 1182 gfx::RectF GetScaledBoundingBox(float scale, WebInputElement* element) {
1179 gfx::Rect bounding_box(element->boundsInViewportSpace()); 1183 gfx::Rect bounding_box(element->boundsInViewportSpace());
1180 return gfx::RectF(bounding_box.x() * scale, 1184 return gfx::RectF(bounding_box.x() * scale,
1181 bounding_box.y() * scale, 1185 bounding_box.y() * scale,
1182 bounding_box.width() * scale, 1186 bounding_box.width() * scale,
1183 bounding_box.height() * scale); 1187 bounding_box.height() * scale);
1184 } 1188 }
1185 1189
1186 } // namespace autofill 1190 } // namespace autofill
OLDNEW
« no previous file with comments | « android_webview/renderer/aw_render_view_ext.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698