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

Side by Side Diff: ios/web/web_state/js/resources/common.js

Issue 2454863002: Fix iOS autofill JavaScript compiler warnings. (Closed)
Patch Set: Created 4 years, 1 month 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
« no previous file with comments | « components/autofill/ios/browser/resources/autofill_controller.js ('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 // This file provides common methods that can be shared by other JavaScripts. 5 // This file provides common methods that can be shared by other JavaScripts.
6 6
7 goog.provide('__crWeb.common'); 7 goog.provide('__crWeb.common');
8 8
9 goog.require('__crWeb.base'); 9 goog.require('__crWeb.base');
10 10
11 11
12 /** @typedef {HTMLInputElement|HTMLTextAreaElement|HTMLSelectElement} */
13 var FormControlElement;
14
12 /** 15 /**
13 * Namespace for this file. It depends on |__gCrWeb| having already been 16 * Namespace for this file. It depends on |__gCrWeb| having already been
14 * injected. String 'common' is used in |__gCrWeb['common']| as it needs to be 17 * injected. String 'common' is used in |__gCrWeb['common']| as it needs to be
15 * accessed in Objective-C code. 18 * accessed in Objective-C code.
16 */ 19 */
17 __gCrWeb['common'] = {}; 20 __gCrWeb['common'] = {};
18 21
19 /* Beginning of anonymous object. */ 22 /* Beginning of anonymous object. */
20 (function() { 23 (function() {
21 /** 24 /**
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 * Returns an array of control elements in a form. 85 * Returns an array of control elements in a form.
83 * 86 *
84 * This method is based on the logic in method 87 * This method is based on the logic in method
85 * void WebFormElement::getFormControlElements( 88 * void WebFormElement::getFormControlElements(
86 * WebVector<WebFormControlElement>&) const 89 * WebVector<WebFormControlElement>&) const
87 * in chromium/src/third_party/WebKit/Source/WebKit/chromium/src/ 90 * in chromium/src/third_party/WebKit/Source/WebKit/chromium/src/
88 * WebFormElement.cpp. 91 * WebFormElement.cpp.
89 * 92 *
90 * @param {Element} form A form element for which the control elements are 93 * @param {Element} form A form element for which the control elements are
91 * returned. 94 * returned.
92 * @return {Array<Element>} 95 * @return {Array<FormControlElement>}
93 */ 96 */
94 __gCrWeb.common.getFormControlElements = function(form) { 97 __gCrWeb.common.getFormControlElements = function(form) {
95 if (!form) { 98 if (!form) {
96 return []; 99 return [];
97 } 100 }
98 var results = []; 101 var results = [];
99 // Get input and select elements from form.elements. 102 // Get input and select elements from form.elements.
100 // TODO(chenyu): according to 103 // TODO(chenyu): according to
101 // http://www.w3.org/TR/2011/WD-html5-20110525/forms.html, form.elements are 104 // http://www.w3.org/TR/2011/WD-html5-20110525/forms.html, form.elements are
102 // the "listed elements whose form owner is the form element, with the 105 // the "listed elements whose form owner is the form element, with the
103 // exception of input elements whose type attribute is in the Image Button 106 // exception of input elements whose type attribute is in the Image Button
104 // state, which must, for historical reasons, be excluded from this 107 // state, which must, for historical reasons, be excluded from this
105 // particular collection." In WebFormElement.cpp, this method is implemented 108 // particular collection." In WebFormElement.cpp, this method is implemented
106 // by returning elements in form's associated elements that have tag 'INPUT' 109 // by returning elements in form's associated elements that have tag 'INPUT'
107 // or 'SELECT'. Check if input Image Buttons are excluded in that 110 // or 'SELECT'. Check if input Image Buttons are excluded in that
108 // implementation. Note for Autofill, as input Image Button is not 111 // implementation. Note for Autofill, as input Image Button is not
109 // considered as autofillable elements, there is no impact on Autofill 112 // considered as autofillable elements, there is no impact on Autofill
110 // feature. 113 // feature.
111 var elements = form.elements; 114 var elements = form.elements;
112 for (var i = 0; i < elements.length; i++) { 115 for (var i = 0; i < elements.length; i++) {
113 if (__gCrWeb.common.isFormControlElement(elements[i])) { 116 if (__gCrWeb.common.isFormControlElement(elements[i])) {
114 results.push(elements[i]); 117 results.push(/** @type {FormControlElement} */ (elements[i]));
115 } 118 }
116 } 119 }
117 return results; 120 return results;
118 }; 121 };
119 122
120 /** 123 /**
121 * Returns true if an element can be autocompleted. 124 * Returns true if an element can be autocompleted.
122 * 125 *
123 * This method aims to provide the same logic as method 126 * This method aims to provide the same logic as method
124 * bool autoComplete() const 127 * bool autoComplete() const
(...skipping 550 matching lines...) Expand 10 before | Expand all | Expand 10 after
675 var plugins = findPluginNodesWithoutFallback_(); 678 var plugins = findPluginNodesWithoutFallback_();
676 if (plugins.length > 0) { 679 if (plugins.length > 0) {
677 // Store the list of plugins in a known place for the replacement script 680 // Store the list of plugins in a known place for the replacement script
678 // to use, then trigger it. 681 // to use, then trigger it.
679 __gCrWeb['placeholderTargetPlugins'] = plugins; 682 __gCrWeb['placeholderTargetPlugins'] = plugins;
680 return true; 683 return true;
681 } 684 }
682 return false; 685 return false;
683 }; 686 };
684 }()); // End of anonymous object 687 }()); // End of anonymous object
OLDNEW
« no previous file with comments | « components/autofill/ios/browser/resources/autofill_controller.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698