From 68b57502ccfeff8a355a2b5a913345ef5743d10f Mon Sep 17 00:00:00 2001 From: Alexander Surkov Date: Mon, 25 Feb 2019 20:02:35 +0000 Subject: [PATCH] Bug 1525101 - adjust nsIFormFillController to make custom elements popup working, r=peterv Differential Revision: https://phabricator.services.mozilla.com/D20505 --HG-- extra : moz-landing-system : lando --- testing/specialpowers/content/specialpowersAPI.js | 4 ++-- .../components/satchel/nsFormFillController.cpp | 14 ++++++++++++++ .../components/satchel/nsIFormFillController.idl | 2 ++ 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/testing/specialpowers/content/specialpowersAPI.js b/testing/specialpowers/content/specialpowersAPI.js index 750af80899df..90c278f90a07 100644 --- a/testing/specialpowers/content/specialpowersAPI.js +++ b/testing/specialpowers/content/specialpowersAPI.js @@ -1443,8 +1443,8 @@ SpecialPowersAPI.prototype = { }, 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)); diff --git a/toolkit/components/satchel/nsFormFillController.cpp b/toolkit/components/satchel/nsFormFillController.cpp index a16e74c5bfd1..ff1e884da0a2 100644 --- a/toolkit/components/satchel/nsFormFillController.cpp +++ b/toolkit/components/satchel/nsFormFillController.cpp @@ -226,6 +226,20 @@ nsFormFillController::AttachToBrowser(nsIDocShell* aDocShell, 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 popup = aPopupEl->AsAutoCompletePopup(); + NS_ENSURE_STATE(popup); + + return AttachToBrowser(aDocShell, popup); +} + NS_IMETHODIMP nsFormFillController::DetachFromBrowser(nsIDocShell* aDocShell) { int32_t index = GetIndexOfDocShell(aDocShell); diff --git a/toolkit/components/satchel/nsIFormFillController.idl b/toolkit/components/satchel/nsIFormFillController.idl index 9194bdd3bee1..4bf897e2f273 100644 --- a/toolkit/components/satchel/nsIFormFillController.idl +++ b/toolkit/components/satchel/nsIFormFillController.idl @@ -6,6 +6,7 @@ interface nsIDocShell; interface nsIAutoCompletePopup; +webidl Element; webidl HTMLInputElement; @@ -33,6 +34,7 @@ interface nsIFormFillController : nsISupports * @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