Bug 1525101 - adjust nsIFormFillController to make custom elements popup working, r=peterv
authorAlexander Surkov <surkov.alexander@gmail.com>
Mon, 25 Feb 2019 20:02:35 +0000
changeset 461010 fcf3d5468b1f1838504b2b75f856f2beff73fab7
parent 461009 bea571f9708b466869f9032e2faedac64e62f05b
child 461011 86948cd899191e4f6afbd374e40431663ede4b12
push id112146
push usernerli@mozilla.com
push dateTue, 26 Feb 2019 04:26:08 +0000
treeherdermozilla-inbound@c4ce50209f19 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspeterv
bugs1525101
milestone67.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 1525101 - adjust nsIFormFillController to make custom elements popup working, r=peterv Differential Revision: https://phabricator.services.mozilla.com/D20505
testing/specialpowers/content/specialpowersAPI.js
toolkit/components/satchel/nsFormFillController.cpp
toolkit/components/satchel/nsIFormFillController.idl
--- a/testing/specialpowers/content/specialpowersAPI.js
+++ b/testing/specialpowers/content/specialpowersAPI.js
@@ -1438,18 +1438,18 @@ SpecialPowersAPI.prototype = {
     return wrapPrivileged(tmp.FormHistory);
   },
   getFormFillController(window) {
     return Cc["@mozilla.org/satchel/form-fill-controller;1"]
              .getService(Ci.nsIFormFillController);
   },
   attachFormFillControllerTo(window) {
     this.getFormFillController()
-        .attachToBrowser(this._getDocShell(window),
-                         this._getAutoCompletePopup(window));
+        .attachPopupElementToBrowser(this._getDocShell(window),
+                                     this._getAutoCompletePopup(window));
   },
   detachFormFillControllerFrom(window) {
     this.getFormFillController().detachFromBrowser(this._getDocShell(window));
   },
   isBackButtonEnabled(window) {
     return !this._getTopChromeWindow(window).document
                                       .getElementById("Browser:Back")
                                       .hasAttribute("disabled");
--- a/toolkit/components/satchel/nsFormFillController.cpp
+++ b/toolkit/components/satchel/nsFormFillController.cpp
@@ -222,16 +222,30 @@ nsFormFillController::AttachToBrowser(ns
   // Listen for focus events on the domWindow of the docShell
   nsCOMPtr<nsPIDOMWindowOuter> window = GetWindowForDocShell(aDocShell);
   AddWindowListeners(window);
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
+nsFormFillController::AttachPopupElementToBrowser(nsIDocShell* aDocShell,
+                                                  dom::Element* aPopupEl) {
+  MOZ_LOG(sLogger, LogLevel::Debug,
+          ("AttachPopupElementToBrowser for docShell %p with popup %p",
+           aDocShell, aPopupEl));
+  NS_ENSURE_TRUE(aDocShell && aPopupEl, NS_ERROR_ILLEGAL_VALUE);
+
+  nsCOMPtr<nsIAutoCompletePopup> popup = aPopupEl->AsAutoCompletePopup();
+  NS_ENSURE_STATE(popup);
+
+  return AttachToBrowser(aDocShell, popup);
+}
+
+NS_IMETHODIMP
 nsFormFillController::DetachFromBrowser(nsIDocShell* aDocShell) {
   int32_t index = GetIndexOfDocShell(aDocShell);
   NS_ENSURE_TRUE(index >= 0, NS_ERROR_FAILURE);
 
   // Stop listening for focus events on the domWindow of the docShell
   nsCOMPtr<nsPIDOMWindowOuter> window =
       GetWindowForDocShell(mDocShells.SafeElementAt(index));
   RemoveWindowListeners(window);
--- a/toolkit/components/satchel/nsIFormFillController.idl
+++ b/toolkit/components/satchel/nsIFormFillController.idl
@@ -1,16 +1,17 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsISupports.idl"
 
 interface nsIDocShell;
 interface nsIAutoCompletePopup;
+webidl Element;
 
 webidl HTMLInputElement;
 
 /*
  * nsIFormFillController is an interface for controlling form fill behavior
  * on HTML documents.  Any number of docShells can be controller concurrently.
  * While a docShell is attached, all HTML documents that are loaded within it
  * will have a focus listener attached that will listen for when a text input
@@ -28,16 +29,17 @@ interface nsIFormFillController : nsISup
 
   /*
    * 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);
+  void attachPopupElementToBrowser(in nsIDocShell docShell, in Element popup);
 
   /*
    * Stop controlling form fill behavior for the given browser
    *
    * @param docShell - The docShell to detach from
    */
   void detachFromBrowser(in nsIDocShell docShell);