| 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 goog.provide('__crWeb.common'); | 7 goog.provide('__crWeb.common'); |
| 8 | 8 |
| 9 goog.require('__crWeb.base'); | 9 goog.require('__crWeb.base'); |
| 10 | 10 |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 * @return {boolean} true if the |element| is a form control element. | 72 * @return {boolean} true if the |element| is a form control element. |
| 73 */ | 73 */ |
| 74 __gCrWeb.common.isFormControlElement = function(element) { | 74 __gCrWeb.common.isFormControlElement = function(element) { |
| 75 var tagName = element.tagName; | 75 var tagName = element.tagName; |
| 76 return (tagName === 'INPUT' || | 76 return (tagName === 'INPUT' || |
| 77 tagName === 'SELECT' || | 77 tagName === 'SELECT' || |
| 78 tagName === 'TEXTAREA'); | 78 tagName === 'TEXTAREA'); |
| 79 }; | 79 }; |
| 80 | 80 |
| 81 /** | 81 /** |
| 82 * Detects focusable elements. | |
| 83 * @param {Element} element A DOM element. | |
| 84 * @return {boolean} true if the |element| is focusable. | |
| 85 */ | |
| 86 __gCrWeb.common.isFocusable = function(element) { | |
| 87 // When the disabled or hidden attributes are present, controls do not | |
| 88 // receive focus. | |
| 89 if (element.hasAttribute('disabled') || element.hasAttribute('hidden')) | |
| 90 return false; | |
| 91 return __gCrWeb.common.isFormControlElement(element); | |
| 92 }; | |
| 93 | |
| 94 /** | |
| 95 * Returns an array of control elements in a form. | 82 * Returns an array of control elements in a form. |
| 96 * | 83 * |
| 97 * This method is based on the logic in method | 84 * This method is based on the logic in method |
| 98 * void WebFormElement::getFormControlElements( | 85 * void WebFormElement::getFormControlElements( |
| 99 * WebVector<WebFormControlElement>&) const | 86 * WebVector<WebFormControlElement>&) const |
| 100 * in chromium/src/third_party/WebKit/Source/WebKit/chromium/src/ | 87 * in chromium/src/third_party/WebKit/Source/WebKit/chromium/src/ |
| 101 * WebFormElement.cpp. | 88 * WebFormElement.cpp. |
| 102 * | 89 * |
| 103 * @param {Element} form A form element for which the control elements are | 90 * @param {Element} form A form element for which the control elements are |
| 104 * returned. | 91 * returned. |
| (...skipping 582 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 687 var plugins = findPluginNodesWithoutFallback_(); | 674 var plugins = findPluginNodesWithoutFallback_(); |
| 688 if (plugins.length > 0) { | 675 if (plugins.length > 0) { |
| 689 // Store the list of plugins in a known place for the replacement script | 676 // Store the list of plugins in a known place for the replacement script |
| 690 // to use, then trigger it. | 677 // to use, then trigger it. |
| 691 __gCrWeb['placeholderTargetPlugins'] = plugins; | 678 __gCrWeb['placeholderTargetPlugins'] = plugins; |
| 692 return true; | 679 return true; |
| 693 } | 680 } |
| 694 return false; | 681 return false; |
| 695 }; | 682 }; |
| 696 }()); // End of anonymous object | 683 }()); // End of anonymous object |
| OLD | NEW |