mattn's patch. draft
authorSean Lee <selee@mozilla.com>
Tue, 07 Feb 2017 16:43:15 +0800
changeset 479830 5c90730881cea96b6b843f65f87a41b3e32c61c5
parent 479651 af8a2573d0f1e9cc6f2ba0ab67d7a702a197f177
child 479831 4374e22cbf62892bf53a9db3f06450a895985677
child 479834 6265c7f6c780dd63e020a1bb491ff3846a116317
child 479983 13d7ca947d66f73f935489196394c38156410508
child 480432 30333dfccc687ec8bced9cbb00acfd1aa4938af4
push id44375
push userbmo:selee@mozilla.com
push dateTue, 07 Feb 2017 10:27:56 +0000
milestone54.0a1
mattn's patch. MozReview-Commit-ID: B4okC5l5y4J
browser/extensions/formautofill/content/FormAutofillContent.js
toolkit/components/satchel/nsFormFillController.cpp
toolkit/components/satchel/nsIFormFillController.idl
--- a/browser/extensions/formautofill/content/FormAutofillContent.js
+++ b/browser/extensions/formautofill/content/FormAutofillContent.js
@@ -286,28 +286,28 @@ AutofillProfileAutoCompleteSearch.protot
   /**
    * Get the input's information from FormAutofillContent's cache.
    *
    * @returns {Object}
    *          Target input's information that cached in FormAutofillContent.
    */
   getInputDetails() {
     // TODO: Maybe we'll need to wait for cache ready if detail is empty.
-    return FormAutofillContent.getInputDetails(formFillController.getFocusedInput());
+    return FormAutofillContent.getInputDetails(formFillController.focusedInput);
   },
 
   /**
    * Get the form's information from FormAutofillContent's cache.
    *
    * @returns {Array<Object>}
    *          Array of the inputs' information for the target form.
    */
   getFormDetails() {
     // TODO: Maybe we'll need to wait for cache ready if details is empty.
-    return FormAutofillContent.getFormDetails(formFillController.getFocusedInput());
+    return FormAutofillContent.getFormDetails(formFillController.focusedInput);
   },
 };
 
 this.NSGetFactory = XPCOMUtils.generateNSGetFactory([AutofillProfileAutoCompleteSearch]);
 
 let ProfileAutocomplete = {
   _registered: false,
   _factory: null,
--- a/toolkit/components/satchel/nsFormFillController.cpp
+++ b/toolkit/components/satchel/nsFormFillController.cpp
@@ -312,21 +312,19 @@ nsFormFillController::MarkAsAutofillFiel
   NS_ENSURE_STATE(node);
   mAutofillInputs.Put(node, true);
   node->AddMutationObserverUnlessExists(this);
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsFormFillController::GetFocusedInput(nsIDOMHTMLInputElement** aRetVal) {
-  if (!aRetVal) {
-    return NS_ERROR_INVALID_POINTER;
-  }
-  *aRetVal = mFocusedInput;
+nsFormFillController::GetFocusedInput(nsIDOMHTMLInputElement **aInput) {
+  *aInput = mFocusedInput;
+  NS_IF_ADDREF(*aInput);
   return NS_OK;
 }
 
 ////////////////////////////////////////////////////////////////////////
 //// nsIAutoCompleteInput
 
 NS_IMETHODIMP
 nsFormFillController::GetPopup(nsIAutoCompletePopup **aPopup)
--- a/toolkit/components/satchel/nsIFormFillController.idl
+++ b/toolkit/components/satchel/nsIFormFillController.idl
@@ -16,16 +16,21 @@ interface nsIDOMHTMLInputElement;
  * is focused.  When this happens, the input will be bound to the
  * global nsIAutoCompleteController service.
  */
 
 [scriptable, uuid(07f0a0dc-f6e9-4cdd-a55f-56d770523a4c)]
 interface nsIFormFillController : nsISupports
 {
   /*
+   * The input element the form fill controller is currently bound to.
+   */
+  readonly attribute nsIDOMHTMLInputElement focusedInput;
+
+  /*
    * Start controlling form fill behavior for the given browser
    *
    * @param docShell - The docShell to attach to
    * @param popup - The popup to show when autocomplete results are available
    */
   void attachToBrowser(in nsIDocShell docShell, in nsIAutoCompletePopup popup);
 
   /*
@@ -46,16 +51,9 @@ interface nsIFormFillController : nsISup
 
   /*
    * Mark the specified <input> element as being managed by a form autofill component.
    * Autocomplete requests will be handed off to the autofill component.
    *
    * @param aInput - The HTML <input> element to mark
    */
   void markAsAutofillField(in nsIDOMHTMLInputElement aInput);
-
-  /**
-   * Return the focused input which is cached in form fill controller.
-   *
-   * @returns The focused input.
-   */
-  nsIDOMHTMLInputElement getFocusedInput();
 };