Bug 1550930 part 3. Stop using [array] for nsIDroppedLinkHandler.dropLinks. r=NeilDeakin

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Boris Zbarsky 2019-05-15 20:58:08 +00:00
Родитель d49981ee72
Коммит e679d377e4
5 изменённых файлов: 17 добавлений и 32 удалений

Просмотреть файл

@ -873,11 +873,9 @@ nsDocShellTreeOwner::HandleEvent(Event* aEvent) {
} else if (eventType.EqualsLiteral("drop")) {
nsIWebNavigation* webnav = static_cast<nsIWebNavigation*>(mWebBrowser);
uint32_t linksCount;
nsIDroppedLinkItem** links;
if (webnav && NS_SUCCEEDED(handler->DropLinks(dragEvent, true, &linksCount,
&links))) {
if (linksCount >= 1) {
nsTArray<RefPtr<nsIDroppedLinkItem>> links;
if (webnav && NS_SUCCEEDED(handler->DropLinks(dragEvent, true, links))) {
if (links.Length() >= 1) {
nsCOMPtr<nsIPrincipal> triggeringPrincipal;
handler->GetTriggeringPrincipal(dragEvent,
getter_AddRefs(triggeringPrincipal));
@ -888,11 +886,7 @@ nsDocShellTreeOwner::HandleEvent(Event* aEvent) {
nsCOMPtr<nsIBrowserChild> browserChild =
do_QueryInterface(webBrowserChrome);
if (browserChild) {
nsresult rv = browserChild->RemoteDropLinks(linksCount, links);
for (uint32_t i = 0; i < linksCount; i++) {
NS_RELEASE(links[i]);
}
free(links);
nsresult rv = browserChild->RemoteDropLinks(links);
return rv;
}
}
@ -912,11 +906,6 @@ nsDocShellTreeOwner::HandleEvent(Event* aEvent) {
webnav->LoadURI(url, loadURIOptions);
}
}
for (uint32_t i = 0; i < linksCount; i++) {
NS_RELEASE(links[i]);
}
free(links);
}
}
} else {

Просмотреть файл

@ -276,7 +276,7 @@ ContentAreaDropListener.prototype =
return url;
},
dropLinks: function(aEvent, aDisallowInherit, aCount)
dropLinks: function(aEvent, aDisallowInherit)
{
if (aEvent && this._eventTargetIsDisabled(aEvent))
return [];
@ -297,8 +297,6 @@ ContentAreaDropListener.prototype =
throw ex;
}
}
if (aCount)
aCount.value = links.length;
return links;
},

Просмотреть файл

@ -65,7 +65,7 @@ interface nsIDroppedLinkHandler : nsISupports
/**
* Given a drop event aEvent, determines links being dragged and returns
* them. If links are returned the caller can, for instance, load them. If
* the count of links is 0, there is no valid link to be dropped.
* the returned array is empty, there is no valid link to be dropped.
*
* A NS_ERROR_DOM_SECURITY_ERR error will be thrown and the event cancelled if
* the receiving target should not load the uri for security reasons. This
@ -76,10 +76,8 @@ interface nsIDroppedLinkHandler : nsISupports
* - aDisallowInherit is true, and the URI being dropped would inherit the
* current document's security context (URI_INHERITS_SECURITY_CONTEXT).
*/
void dropLinks(in DragEvent aEvent,
[optional] in boolean aDisallowInherit,
[optional] out unsigned long aCount,
[retval, array, size_is(aCount)] out nsIDroppedLinkItem aLinks);
Array<nsIDroppedLinkItem> dropLinks(in DragEvent aEvent,
[optional] in boolean aDisallowInherit);
/**
* Given a drop event aEvent, validate the extra URIs for the event,

Просмотреть файл

@ -29,8 +29,7 @@ interface nsIBrowserChild : nsISupports
[noscript] void remoteSizeShellTo(in int32_t width, in int32_t height,
in int32_t shellItemWidth, in int32_t shellItemHeight);
[noscript] void remoteDropLinks(in unsigned long linksCount,
[array, size_is(linksCount)] in nsIDroppedLinkItem links);
void remoteDropLinks(in Array<nsIDroppedLinkItem> links);
readonly attribute uint64_t tabId;

Просмотреть файл

@ -735,25 +735,25 @@ BrowserChild::RemoteSizeShellTo(int32_t aWidth, int32_t aHeight,
}
NS_IMETHODIMP
BrowserChild::RemoteDropLinks(uint32_t aLinksCount,
nsIDroppedLinkItem** aLinks) {
BrowserChild::RemoteDropLinks(
const nsTArray<RefPtr<nsIDroppedLinkItem>>& aLinks) {
nsTArray<nsString> linksArray;
nsresult rv = NS_OK;
for (uint32_t i = 0; i < aLinksCount; i++) {
for (nsIDroppedLinkItem* link : aLinks) {
nsString tmp;
rv = aLinks[i]->GetUrl(tmp);
rv = link->GetUrl(tmp);
if (NS_FAILED(rv)) {
return rv;
}
linksArray.AppendElement(tmp);
rv = aLinks[i]->GetName(tmp);
rv = link->GetName(tmp);
if (NS_FAILED(rv)) {
return rv;
}
linksArray.AppendElement(tmp);
rv = aLinks[i]->GetType(tmp);
rv = link->GetType(tmp);
if (NS_FAILED(rv)) {
return rv;
}
@ -1816,7 +1816,8 @@ mozilla::ipc::IPCResult BrowserChild::RecvRealTouchEvent(
}
UniquePtr<DisplayportSetListener> postLayerization =
APZCCallbackHelper::SendSetTargetAPZCNotification(
mPuppetWidget, document, localEvent, aGuid.mLayersId, aInputBlockId);
mPuppetWidget, document, localEvent, aGuid.mLayersId,
aInputBlockId);
if (postLayerization && postLayerization->Register()) {
Unused << postLayerization.release();
}