summaryrefslogtreecommitdiffstats
path: root/toolkit/components/formautofill/shared
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-15 03:34:42 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-15 03:34:42 +0000
commitda4c7e7ed675c3bf405668739c3012d140856109 (patch)
treecdd868dba063fecba609a1d819de271f0d51b23e /toolkit/components/formautofill/shared
parentAdding upstream version 125.0.3. (diff)
downloadfirefox-da4c7e7ed675c3bf405668739c3012d140856109.tar.xz
firefox-da4c7e7ed675c3bf405668739c3012d140856109.zip
Adding upstream version 126.0.upstream/126.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'toolkit/components/formautofill/shared')
-rw-r--r--toolkit/components/formautofill/shared/AddressComponent.sys.mjs3
-rw-r--r--toolkit/components/formautofill/shared/FormAutofillSection.sys.mjs6
-rw-r--r--toolkit/components/formautofill/shared/FormAutofillUtils.sys.mjs42
3 files changed, 46 insertions, 5 deletions
diff --git a/toolkit/components/formautofill/shared/AddressComponent.sys.mjs b/toolkit/components/formautofill/shared/AddressComponent.sys.mjs
index 40e00b66a0..e83cd22251 100644
--- a/toolkit/components/formautofill/shared/AddressComponent.sys.mjs
+++ b/toolkit/components/formautofill/shared/AddressComponent.sys.mjs
@@ -412,7 +412,6 @@ class State extends AddressField {
const options = {
merge_whitespace: true,
- remove_punctuation: true,
};
this.#state = lazy.FormAutofillUtils.getAbbreviatedSubregionName(
this.normalizeUserValue(options),
@@ -991,7 +990,7 @@ export class AddressComparison {
* country, postal code, etc. The class provides a compare methods
* to compare another AddressComponent against the current instance.
*
- * Note. This class assumes records that pass to it have already been normalized.
+ * Note: This class assumes records that pass to it have already been normalized.
*/
export class AddressComponent {
/**
diff --git a/toolkit/components/formautofill/shared/FormAutofillSection.sys.mjs b/toolkit/components/formautofill/shared/FormAutofillSection.sys.mjs
index 7bda4c167b..1a5b3014c9 100644
--- a/toolkit/components/formautofill/shared/FormAutofillSection.sys.mjs
+++ b/toolkit/components/formautofill/shared/FormAutofillSection.sys.mjs
@@ -136,15 +136,15 @@ export class FormAutofillSection {
* specific case. Return the original value in the default case.
* @param {String} value
* The original field value.
- * @param {Object} fieldDetail
+ * @param {Object} _fieldName
* A fieldDetail of the related element.
- * @param {HTMLElement} element
+ * @param {HTMLElement} _element
* A element for checking converting value.
*
* @returns {String}
* A string of the converted value.
*/
- computeFillingValue(value, fieldName, element) {
+ computeFillingValue(value, _fieldName, _element) {
return value;
}
diff --git a/toolkit/components/formautofill/shared/FormAutofillUtils.sys.mjs b/toolkit/components/formautofill/shared/FormAutofillUtils.sys.mjs
index e86f14975c..c2b48a53a3 100644
--- a/toolkit/components/formautofill/shared/FormAutofillUtils.sys.mjs
+++ b/toolkit/components/formautofill/shared/FormAutofillUtils.sys.mjs
@@ -176,6 +176,12 @@ FormAutofillUtils = {
return Array.from(categories);
},
+ getCollectionNameFromFieldName(fieldName) {
+ return this.isCreditCardField(fieldName)
+ ? CREDITCARDS_COLLECTION_NAME
+ : ADDRESSES_COLLECTION_NAME;
+ },
+
getAddressSeparator() {
// The separator should be based on the L10N address format, and using a
// white space is a temporary solution.
@@ -799,6 +805,42 @@ FormAutofillUtils = {
return null;
},
+ /**
+ * Find the option element from xul menu popups, as used in address capture
+ * doorhanger.
+ *
+ * This is a proxy to `findAddressSelectOption`, which expects HTML select
+ * DOM nodes and operates on options instead of xul menuitems.
+ *
+ * NOTE: This is a temporary solution until Bug 1886949 is landed. This
+ * method will then be removed `findAddressSelectOption` will be used
+ * directly.
+ *
+ * @param {XULPopupElement} menupopup
+ * @param {object} address
+ * @param {string} fieldName
+ * @returns {XULElement}
+ */
+ findAddressSelectOptionWithMenuPopup(menupopup, address, fieldName) {
+ class MenuitemProxy {
+ constructor(menuitem) {
+ this.menuitem = menuitem;
+ }
+ get text() {
+ return this.menuitem.label;
+ }
+ get value() {
+ return this.menuitem.value;
+ }
+ }
+ const selectEl = {
+ options: Array.from(menupopup.childNodes).map(
+ menuitem => new MenuitemProxy(menuitem)
+ ),
+ };
+ return this.findAddressSelectOption(selectEl, address, fieldName)?.menuitem;
+ },
+
findCreditCardSelectOption(selectEl, creditCard, fieldName) {
let oneDigitMonth = creditCard["cc-exp-month"]
? creditCard["cc-exp-month"].toString()