Bug 1550934. Stop using [array] in nsIBrowser. r=NeilDeakin

Differential Revision: https://phabricator.services.mozilla.com/D30771

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Boris Zbarsky 2019-05-15 21:12:44 +00:00
parent 705a74ebd7
commit 33f3c7c417
4 changed files with 17 additions and 46 deletions

View File

@ -25,14 +25,12 @@ interface nsIBrowser : nsISupports
* 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
@ -73,16 +71,12 @@ interface nsIBrowser : nsISupports
* 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;

View File

@ -809,15 +809,12 @@ mozilla::ipc::IPCResult BrowserParent::RecvDropLinks(
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;
@ -826,7 +823,7 @@ mozilla::ipc::IPCResult BrowserParent::RecvDropLinks(
} else {
triggeringPrincipal = NullPrincipal::CreateWithoutOriginAttributes();
}
browser->DropLinks(aLinks.Length(), links.get(), triggeringPrincipal);
browser->DropLinks(aLinks, triggeringPrincipal);
}
return IPC_OK();
}
@ -2163,25 +2160,8 @@ mozilla::ipc::IPCResult BrowserParent::RecvEnableDisableCommands(
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();

View File

@ -1348,11 +1348,10 @@ class MozBrowser extends MozElements.MozElementMixin(XULFrameElement) {
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);
}
}
@ -1832,12 +1831,12 @@ class MozBrowser extends MozElements.MozElementMixin(XULFrameElement) {
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],

View File

@ -67,18 +67,16 @@ RemoteController.prototype = {
// 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