| 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 // 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 /** | 7 /** |
| 8 * Namespace for this file. It depends on |__gCrWeb| having already been | 8 * Namespace for this file. It depends on |__gCrWeb| having already been |
| 9 * injected. String 'common' is used in |__gCrWeb['common']| as it needs to be | 9 * injected. String 'common' is used in |__gCrWeb['common']| as it needs to be |
| 10 * accessed in Objective-C code. | 10 * accessed in Objective-C code. |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 * Returns an array of control elements in a form. | 83 * Returns an array of control elements in a form. |
| 84 * | 84 * |
| 85 * This method is based on the logic in method | 85 * This method is based on the logic in method |
| 86 * void WebFormElement::getFormControlElements( | 86 * void WebFormElement::getFormControlElements( |
| 87 * WebVector<WebFormControlElement>&) const | 87 * WebVector<WebFormControlElement>&) const |
| 88 * in chromium/src/third_party/WebKit/Source/WebKit/chromium/src/ | 88 * in chromium/src/third_party/WebKit/Source/WebKit/chromium/src/ |
| 89 * WebFormElement.cpp. | 89 * WebFormElement.cpp. |
| 90 * | 90 * |
| 91 * @param {Element} form A form element for which the control elements are | 91 * @param {Element} form A form element for which the control elements are |
| 92 * returned. | 92 * returned. |
| 93 * @return {Array.<Element>} | 93 * @return {Array<Element>} |
| 94 */ | 94 */ |
| 95 __gCrWeb.common.getFormControlElements = function(form) { | 95 __gCrWeb.common.getFormControlElements = function(form) { |
| 96 if (!form) { | 96 if (!form) { |
| 97 return []; | 97 return []; |
| 98 } | 98 } |
| 99 var results = []; | 99 var results = []; |
| 100 // Get input and select elements from form.elements. | 100 // Get input and select elements from form.elements. |
| 101 // TODO(chenyu): according to | 101 // TODO(chenyu): according to |
| 102 // http://www.w3.org/TR/2011/WD-html5-20110525/forms.html, form.elements are | 102 // http://www.w3.org/TR/2011/WD-html5-20110525/forms.html, form.elements are |
| 103 // the "listed elements whose form owner is the form element, with the | 103 // the "listed elements whose form owner is the form element, with the |
| (...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 570 element, type, bubbles, cancelable) { | 570 element, type, bubbles, cancelable) { |
| 571 var changeEvent = element.ownerDocument.createEvent('HTMLEvents'); | 571 var changeEvent = element.ownerDocument.createEvent('HTMLEvents'); |
| 572 changeEvent.initEvent(type, bubbles, cancelable); | 572 changeEvent.initEvent(type, bubbles, cancelable); |
| 573 | 573 |
| 574 // A timer is used to avoid reentering JavaScript evaluation. | 574 // A timer is used to avoid reentering JavaScript evaluation. |
| 575 window.setTimeout(function() { | 575 window.setTimeout(function() { |
| 576 element.dispatchEvent(changeEvent); | 576 element.dispatchEvent(changeEvent); |
| 577 }, 0); | 577 }, 0); |
| 578 }; | 578 }; |
| 579 } // End of anonymous object | 579 } // End of anonymous object |
| OLD | NEW |