Bug 1550934. Stop using [array] in nsIBrowser. r=NeilDeakin
authorBoris Zbarsky <bzbarsky@mit.edu>
Wed, 15 May 2019 21:12:44 +0000
changeset 532818 be2fb503011adec5a8d387f2bc531e13fab0fd8e
parent 532817 9dd4eba320e64aea32ba5e62b96c14c93768427f
child 532819 d9a6ddf122884cf34e3fc650d2b21a4ab5076124
push id11272
push userapavel@mozilla.com
push dateThu, 16 May 2019 15:28:22 +0000
treeherdermozilla-beta@2265bfc5920d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersNeilDeakin
bugs1550934
milestone68.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 1550934. Stop using [array] in nsIBrowser. r=NeilDeakin Differential Revision: https://phabricator.services.mozilla.com/D30771
dom/interfaces/base/nsIBrowser.idl
dom/ipc/BrowserParent.cpp
toolkit/content/widgets/browser-custom-element.js
toolkit/modules/RemoteController.js
--- a/dom/interfaces/base/nsIBrowser.idl
+++ b/dom/interfaces/base/nsIBrowser.idl
@@ -20,24 +20,22 @@ interface nsIBrowser : nsISupports
    * they are loaded in the same process as the content.
    */
   readonly attribute FrameLoader sameProcessAsFrameLoader;
 
   /*
    * Called by the child to inform the parent that links are dropped into
    * content area.
    *
-   * @param linksCount length of links
    * @param links a flat array of url, name, and type for each link
    * @param triggeringPrincipal a principal that initiated loading
    *                            of the dropped links
    */
-  void dropLinks(in unsigned long linksCount,
-                 [array, size_is(linksCount)] in wstring links,
-                 in nsIPrincipal aTriggeringPrincipal);
+  void dropLinks(in Array<AString> links,
+                 in nsIPrincipal triggeringPrincipal);
 
   /**
    * Swapping of frameloaders are usually initiated from a frameloader owner
    * or other components operating on frameloader owners. This is done by calling
    * swapFrameLoaders at MozFrameLoaderOwner webidl interface.
    *
    * This function aimed to provide the other way around -
    * if the swapping is initiated from frameloader itself or other platform level
@@ -68,22 +66,18 @@ interface nsIBrowser : nsISupports
    */
   readonly attribute nsIWebProgress remoteWebProgressManager;
 
   /**
    * Called by the child to inform the parent that a command update has occurred
    * and the supplied set of commands are now enabled and disabled.
    *
    * @param action command updater action
-   * @param enabledLength length of enabledCommands array
    * @param enabledCommands commands to enable
-   * @param disabledLength length of disabledCommands array
    * @param disabledCommand commands to disable
    */
   void enableDisableCommandsRemoteOnly(in AString action,
-                                       in unsigned long enabledLength,
-                                       [array, size_is(enabledLength)] in string enabledCommands,
-                                       in unsigned long disabledLength,
-                                       [array, size_is(disabledLength)] in string disabledCommands);
+                                       in Array<ACString> enabledCommands,
+                                       in Array<ACString> disabledCommands);
 
   readonly attribute nsIPrincipal contentPrincipal;
   readonly attribute nsIContentSecurityPolicy csp;
 };
--- a/dom/ipc/BrowserParent.cpp
+++ b/dom/ipc/BrowserParent.cpp
@@ -804,34 +804,31 @@ mozilla::ipc::IPCResult BrowserParent::R
     // Verify that links have not been modified by the child. If links have
     // not been modified then it's safe to load those links using the
     // SystemPrincipal. If they have been modified by web content, then
     // we use a NullPrincipal which still allows to load web links.
     bool loadUsingSystemPrincipal = true;
     if (aLinks.Length() != mVerifyDropLinks.Length()) {
       loadUsingSystemPrincipal = false;
     }
-    UniquePtr<const char16_t*[]> links;
-    links = MakeUnique<const char16_t*[]>(aLinks.Length());
     for (uint32_t i = 0; i < aLinks.Length(); i++) {
       if (loadUsingSystemPrincipal) {
         if (!aLinks[i].Equals(mVerifyDropLinks[i])) {
           loadUsingSystemPrincipal = false;
         }
       }
-      links[i] = aLinks[i].get();
     }
     mVerifyDropLinks.Clear();
     nsCOMPtr<nsIPrincipal> triggeringPrincipal;
     if (loadUsingSystemPrincipal) {
       triggeringPrincipal = nsContentUtils::GetSystemPrincipal();
     } else {
       triggeringPrincipal = NullPrincipal::CreateWithoutOriginAttributes();
     }
-    browser->DropLinks(aLinks.Length(), links.get(), triggeringPrincipal);
+    browser->DropLinks(aLinks, triggeringPrincipal);
   }
   return IPC_OK();
 }
 
 mozilla::ipc::IPCResult BrowserParent::RecvEvent(const RemoteDOMEvent& aEvent) {
   RefPtr<Event> event = aEvent.mEvent;
   NS_ENSURE_TRUE(event, IPC_OK());
 
@@ -2158,35 +2155,18 @@ mozilla::ipc::IPCResult BrowserParent::R
     nsTArray<nsCString>&& aDisabledCommands) {
   nsCOMPtr<nsIBrowser> browser =
       mFrameElement ? mFrameElement->AsBrowser() : nullptr;
   bool isRemoteBrowser = false;
   if (browser) {
     browser->GetIsRemoteBrowser(&isRemoteBrowser);
   }
   if (isRemoteBrowser) {
-    UniquePtr<const char*[]> enabledCommands, disabledCommands;
-
-    if (aEnabledCommands.Length()) {
-      enabledCommands = MakeUnique<const char*[]>(aEnabledCommands.Length());
-      for (uint32_t c = 0; c < aEnabledCommands.Length(); c++) {
-        enabledCommands[c] = aEnabledCommands[c].get();
-      }
-    }
-
-    if (aDisabledCommands.Length()) {
-      disabledCommands = MakeUnique<const char*[]>(aDisabledCommands.Length());
-      for (uint32_t c = 0; c < aDisabledCommands.Length(); c++) {
-        disabledCommands[c] = aDisabledCommands[c].get();
-      }
-    }
-
-    browser->EnableDisableCommandsRemoteOnly(
-        aAction, aEnabledCommands.Length(), enabledCommands.get(),
-        aDisabledCommands.Length(), disabledCommands.get());
+    browser->EnableDisableCommandsRemoteOnly(aAction, aEnabledCommands,
+                                             aDisabledCommands);
   }
 
   return IPC_OK();
 }
 
 LayoutDeviceIntPoint BrowserParent::TransformPoint(
     const LayoutDeviceIntPoint& aPoint,
     const LayoutDeviceToLayoutDeviceMatrix4x4& aMatrix) {
--- a/toolkit/content/widgets/browser-custom-element.js
+++ b/toolkit/content/widgets/browser-custom-element.js
@@ -1343,21 +1343,20 @@ class MozBrowser extends MozElements.Moz
         }
 
       default:
         return this._receiveMessage(aMessage);
     }
     return undefined;
   }
 
-  enableDisableCommandsRemoteOnly(aAction, aEnabledLength, aEnabledCommands, aDisabledLength, aDisabledCommands) {
+  enableDisableCommandsRemoteOnly(aAction, aEnabledCommands, aDisabledCommands) {
     if (this._controller) {
-      this._controller.enableDisableCommands(aAction,
-        aEnabledLength, aEnabledCommands,
-        aDisabledLength, aDisabledCommands);
+      this._controller.enableDisableCommands(aAction, aEnabledCommands,
+                                             aDisabledCommands);
     }
   }
 
   updateSecurityUIForContentBlockingEvent(aEvent) {
     if (this.isRemoteBrowser && this.messageManager) {
       // Invoking this getter triggers the generation of the underlying object,
       // which we need to access with ._securityUI, because .securityUI returns
       // a wrapper that makes _update inaccessible.
@@ -1827,22 +1826,22 @@ class MozBrowser extends MozElements.Moz
   drawSnapshot(x, y, w, h, scale, backgroundColor) {
     if (!this.frameLoader) {
       throw Components.Exception("No frame loader.",
         Cr.NS_ERROR_FAILURE);
     }
     return this.frameLoader.drawSnapshot(x, y, w, h, scale, backgroundColor);
   }
 
-  dropLinks(aLinksCount, aLinks, aTriggeringPrincipal) {
+  dropLinks(aLinks, aTriggeringPrincipal) {
     if (!this.droppedLinkHandler) {
       return false;
     }
     let links = [];
-    for (let i = 0; i < aLinksCount; i += 3) {
+    for (let i = 0; i < aLinks.length; i += 3) {
       links.push({
         url: aLinks[i],
         name: aLinks[i + 1],
         type: aLinks[i + 2],
       });
     }
     this.droppedLinkHandler(null, links, aTriggeringPrincipal);
     return true;
--- a/toolkit/modules/RemoteController.js
+++ b/toolkit/modules/RemoteController.js
@@ -62,28 +62,26 @@ RemoteController.prototype = {
   getSupportedCommands(aCount, aCommands) {
     throw Cr.NS_ERROR_NOT_IMPLEMENTED;
   },
 
   onEvent() {},
 
   // This is intended to be called from the browser binding to update
   // the enabled and disabled commands.
-  enableDisableCommands(aAction,
-                                  aEnabledLength, aEnabledCommands,
-                                  aDisabledLength, aDisabledCommands) {
+  enableDisableCommands(aAction, aEnabledCommands, aDisabledCommands) {
     // Clear the list first
     this._supportedCommands = { };
 
-    for (let c = 0; c < aEnabledLength; c++) {
-      this._supportedCommands[aEnabledCommands[c]] = true;
+    for (let command of aEnabledCommands) {
+      this._supportedCommands[command] = true;
     }
 
-    for (let c = 0; c < aDisabledLength; c++) {
-      this._supportedCommands[aDisabledCommands[c]] = false;
+    for (let command of aDisabledCommands) {
+      this._supportedCommands[command] = false;
     }
 
     // Don't update anything if we're not the active element
     if (this._browser != this._browser.ownerDocument.activeElement) {
       return;
     }
     this._browser.ownerGlobal.updateCommands(aAction);
   },