Bug 1330111 - Convert the getFocusedInput method on nsIFormFillController to an attribute. r=felipe
☠☠ backed out by e29f86bd5608 ☠ ☠
authorMatthew Noorenberghe <mozilla@noorenberghe.ca>
Tue, 31 Jan 2017 23:57:49 -0800
changeset 341052 dee4bf1753cd224cd6abb2bbd3592fd3464c778e
parent 341051 6b7069ed30e01c72e657b7aa8528351274eaa985
child 341053 e0f1b702887202ed0f388943d0598369ebb54b99
push id86621
push usermozilla@noorenberghe.ca
push dateTue, 07 Feb 2017 05:12:02 +0000
treeherdermozilla-inbound@d71bc4a09493 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfelipe
bugs1330111
milestone54.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1330111 - Convert the getFocusedInput method on nsIFormFillController to an attribute. r=felipe The convention is to use an attribute. This also fixes reference counting. MozReview-Commit-ID: B38ZVNt4Ugi
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
@@ -311,21 +311,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();
 };