Bug 1395173 - Part 1. Cache computed values in form handler instance instead of prototype. r=lchang draft
authorRay Lin <ralin@mozilla.com>
Thu, 31 Aug 2017 16:38:54 +0800
changeset 658394 13ce65bef09b9d3f8e627399efd1eff1241ec058
parent 658358 8e05298328da75f3056a9f1f9609938870d756a0
child 658395 c35cc8f121edbc90faa8ff3bdea70b30d64c2ed4
child 658401 6985f400cf6f0676986438d7ccb2463085c21764
push id77745
push userbmo:ralin@mozilla.com
push dateMon, 04 Sep 2017 02:50:42 +0000
reviewerslchang
bugs1395173
milestone57.0a1
Bug 1395173 - Part 1. Cache computed values in form handler instance instead of prototype. r=lchang MozReview-Commit-ID: Dwz6EmJ4VmN
browser/extensions/formautofill/FormAutofillHandler.jsm
--- a/browser/extensions/formautofill/FormAutofillHandler.jsm
+++ b/browser/extensions/formautofill/FormAutofillHandler.jsm
@@ -49,16 +49,22 @@ function FormAutofillHandler(form) {
      * Similar to the `fieldDetails` above but contains credit card fields only.
      */
     fieldDetails: [],
     /**
      * String of the filled creditCard's guid.
      */
     filledRecordGUID: null,
   };
+
+  this._cacheValue = {
+    allFieldNames: null,
+    oneLineStreetAddress: null,
+    matchingSelectOption: null,
+  };
 }
 
 FormAutofillHandler.prototype = {
   /**
    * DOM Form element to which this object is attached.
    */
   form: null,
 
@@ -164,22 +170,16 @@ FormAutofillHandler.prototype = {
       return this.address.fieldDetails;
     }
     if (FormAutofillUtils.isCreditCardField(fieldDetail.fieldName)) {
       return this.creditCard.fieldDetails;
     }
     return [];
   },
 
-  _cacheValue: {
-    allFieldNames: null,
-    oneLineStreetAddress: null,
-    matchingSelectOption: null,
-  },
-
   get allFieldNames() {
     if (!this._cacheValue.allFieldNames) {
       this._cacheValue.allFieldNames = this.fieldDetails.map(record => record.fieldName);
     }
     return this._cacheValue.allFieldNames;
   },
 
   _getOneLineStreetAddress(address) {