summaryrefslogtreecommitdiffstats
path: root/toolkit/components/formautofill/shared/FormAutofillUtils.sys.mjs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:14:29 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:14:29 +0000
commitfbaf0bb26397aa498eb9156f06d5a6fe34dd7dd8 (patch)
tree4c1ccaf5486d4f2009f9a338a98a83e886e29c97 /toolkit/components/formautofill/shared/FormAutofillUtils.sys.mjs
parentReleasing progress-linux version 124.0.1-1~progress7.99u1. (diff)
downloadfirefox-fbaf0bb26397aa498eb9156f06d5a6fe34dd7dd8.tar.xz
firefox-fbaf0bb26397aa498eb9156f06d5a6fe34dd7dd8.zip
Merging upstream version 125.0.1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'toolkit/components/formautofill/shared/FormAutofillUtils.sys.mjs')
-rw-r--r--toolkit/components/formautofill/shared/FormAutofillUtils.sys.mjs39
1 files changed, 27 insertions, 12 deletions
diff --git a/toolkit/components/formautofill/shared/FormAutofillUtils.sys.mjs b/toolkit/components/formautofill/shared/FormAutofillUtils.sys.mjs
index ce10c71ce1..e86f14975c 100644
--- a/toolkit/components/formautofill/shared/FormAutofillUtils.sys.mjs
+++ b/toolkit/components/formautofill/shared/FormAutofillUtils.sys.mjs
@@ -192,7 +192,7 @@ FormAutofillUtils = {
getAddressLabel(address) {
// TODO: Implement a smarter way for deciding what to display
// as option text. Possibly improve the algorithm in
- // ProfileAutoCompleteResult.jsm and reuse it here.
+ // ProfileAutoCompleteResult.sys.mjs and reuse it here.
let fieldOrder = [
"name",
"-moz-street-address-one-line", // Street address
@@ -302,20 +302,27 @@ FormAutofillUtils = {
},
/**
- * Determines if an element is focusable
- * and accessible via keyboard navigation or not.
+ * Determines if an element is visually hidden or not.
*
* @param {HTMLElement} element
- *
- * @returns {bool} true if the element is focusable and accessible
+ * @param {boolean} visibilityCheck true to run visiblity check against
+ * element.checkVisibility API. Otherwise, test by only checking
+ * `hidden` and `display` attributes
+ * @returns {boolean} true if the element is visible
*/
- isFieldFocusable(element) {
- return (
- // The Services.focus.elementIsFocusable API considers elements with
- // tabIndex="-1" set as focusable. But since they are not accessible
- // via keyboard navigation we treat them as non-interactive
- Services.focus.elementIsFocusable(element, 0) && element.tabIndex != "-1"
- );
+ isFieldVisible(element, visibilityCheck = true) {
+ if (
+ visibilityCheck &&
+ element.checkVisibility &&
+ !FormAutofillUtils.ignoreVisibilityCheck
+ ) {
+ return element.checkVisibility({
+ checkOpacity: true,
+ checkVisibilityCSS: true,
+ });
+ }
+
+ return !element.hidden && element.style.display != "none";
},
/**
@@ -1127,3 +1134,11 @@ XPCOMUtils.defineLazyPreferenceGetter(
"extensions.formautofill.focusOnAutofill",
true
);
+
+// This is only used for testing
+XPCOMUtils.defineLazyPreferenceGetter(
+ FormAutofillUtils,
+ "ignoreVisibilityCheck",
+ "extensions.formautofill.test.ignoreVisibilityCheck",
+ false
+);