Bug 1635094 - Cleanup the ReferrerInfo code. r=ckerschb

The cast in InitWithNode is wrong. AsElement() asserts instead of
checking the flag, so we always pass an element (and if we didn't we'd
have type confusion problems). I audited the callers and we're fine.

Anyhow, always require an element, and add two convenience constructors
for C++ code.

Differential Revision: https://phabricator.services.mozilla.com/D73636
This commit is contained in:
Emilio Cobos Álvarez
2020-05-04 16:26:51 +00:00
parent d740104e0f
commit 41fba10f7f
27 changed files with 113 additions and 157 deletions

View File

@@ -152,9 +152,7 @@ nsMacShellService::SetDesktopBackground(Element* aElement, int32_t aPosition,
loadContext = do_QueryInterface(docShell);
}
nsCOMPtr<nsIReferrerInfo> referrerInfo = new mozilla::dom::ReferrerInfo();
referrerInfo->InitWithNode(aElement);
auto referrerInfo = MakeRefPtr<mozilla::dom::ReferrerInfo>(*aElement);
return wbp->SaveURI(imageURI, aElement->NodePrincipal(), 0, referrerInfo,
nullptr, nullptr, mBackgroundFile,
nsIContentPolicy::TYPE_IMAGE, loadContext);