Bug 1565767 part 4. Remove some unnecesary refcounting at Document::GetBaseURI callsites. r=peterv

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Boris Zbarsky 2019-07-15 18:28:43 +00:00
parent ba4e7d1c8e
commit 75aa8f554d
7 changed files with 12 additions and 18 deletions

View File

@ -4663,7 +4663,7 @@ nsDocShell::Reload(uint32_t aReloadFlags) {
// Do not inherit owner from document
uint32_t flags = INTERNAL_LOAD_FLAGS_NONE;
nsAutoString srcdoc;
nsCOMPtr<nsIURI> baseURI;
nsIURI* baseURI = nullptr;
nsCOMPtr<nsIURI> originalURI;
nsCOMPtr<nsIURI> resultPrincipalURI;
bool loadReplace = false;

View File

@ -84,9 +84,9 @@ already_AddRefed<nsIURI> ParseURLFromDocument(Document* aDocument,
MOZ_ASSERT(aDocument);
MOZ_ASSERT(NS_IsMainThread());
nsCOMPtr<nsIURI> baseURI = aDocument->GetBaseURI();
nsCOMPtr<nsIURI> resolvedURI;
aRv = NS_NewURI(getter_AddRefs(resolvedURI), aInput, nullptr, baseURI);
aRv = NS_NewURI(getter_AddRefs(resolvedURI), aInput, nullptr,
aDocument->GetBaseURI());
if (NS_WARN_IF(aRv.Failed())) {
aRv.ThrowTypeError<MSG_INVALID_URL>(aInput);
}

View File

@ -96,7 +96,7 @@ already_AddRefed<Response> Response::Redirect(const GlobalObject& aGlobal,
nsAutoString parsedURL;
if (NS_IsMainThread()) {
nsCOMPtr<nsIURI> baseURI;
nsIURI* baseURI = nullptr;
nsCOMPtr<nsPIDOMWindowInner> inner(
do_QueryInterface(aGlobal.GetAsSupports()));
Document* doc = inner ? inner->GetExtantDoc() : nullptr;

View File

@ -1675,7 +1675,7 @@ nsresult Notification::ResolveIconAndSoundURL(nsString& iconUrl,
AssertIsOnMainThread();
nsresult rv = NS_OK;
nsCOMPtr<nsIURI> baseUri;
nsIURI* baseUri = nullptr;
// XXXnsm If I understand correctly, the character encoding for resolving
// URIs in new specs is dictated by the URL spec, which states that unless

View File

@ -94,10 +94,9 @@ class WorkletFetchHandler final : public PromiseNativeHandler,
return promise.forget();
}
nsCOMPtr<nsIURI> baseURI = doc->GetBaseURI();
nsCOMPtr<nsIURI> resolvedURI;
nsresult rv =
NS_NewURI(getter_AddRefs(resolvedURI), aModuleURL, nullptr, baseURI);
nsresult rv = NS_NewURI(getter_AddRefs(resolvedURI), aModuleURL, nullptr,
doc->GetBaseURI());
if (NS_WARN_IF(NS_FAILED(rv))) {
promise->MaybeReject(rv);
return promise.forget();

View File

@ -1372,7 +1372,7 @@ nsresult XMLHttpRequestMainThread::Open(const nsACString& aMethod,
}
// Steps 5-6
nsCOMPtr<nsIURI> baseURI;
nsIURI* baseURI = nullptr;
if (mBaseURI) {
baseURI = mBaseURI;
} else if (responsibleDocument) {

View File

@ -592,17 +592,11 @@ nsresult TX_CompileStylesheet(nsINode* aNode,
// If we move GetBaseURI to nsINode this can be simplified.
nsCOMPtr<Document> doc = aNode->OwnerDoc();
nsCOMPtr<nsIURI> uri;
if (aNode->IsContent()) {
uri = aNode->AsContent()->GetBaseURI();
} else {
NS_ASSERTION(aNode->IsDocument(), "not a doc");
uri = aNode->AsDocument()->GetBaseURI();
}
NS_ENSURE_TRUE(uri, NS_ERROR_FAILURE);
nsIURI* nodeBaseURI = aNode->GetBaseURI();
NS_ENSURE_TRUE(nodeBaseURI, NS_ERROR_FAILURE);
nsAutoCString spec;
uri->GetSpec(spec);
nodeBaseURI->GetSpec(spec);
NS_ConvertUTF8toUTF16 baseURI(spec);
nsIURI* docUri = doc->GetDocumentURI();
@ -610,6 +604,7 @@ nsresult TX_CompileStylesheet(nsINode* aNode,
// We need to remove the ref, a URI with a ref would mean that we have an
// embedded stylesheet.
nsCOMPtr<nsIURI> uri;
NS_GetURIWithoutRef(docUri, getter_AddRefs(uri));
NS_ENSURE_TRUE(uri, NS_ERROR_FAILURE);