Bug 1497301 part 1. Remove the JSContext arg of Location::GetSourceBaseURL. r=farre

It's unused.  Also, this function never fails, so there's no reason to have the
nsresult return type.
This commit is contained in:
Boris Zbarsky 2018-10-12 11:07:17 -04:00
Родитель ab84ab73c0
Коммит a074d0da17
2 изменённых файлов: 8 добавлений и 14 удалений

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

@ -460,14 +460,8 @@ nsresult
Location::SetHrefWithContext(JSContext* cx, const nsAString& aHref, Location::SetHrefWithContext(JSContext* cx, const nsAString& aHref,
bool aReplace) bool aReplace)
{ {
nsCOMPtr<nsIURI> base;
// Get the source of the caller // Get the source of the caller
nsresult result = GetSourceBaseURL(cx, getter_AddRefs(base)); nsCOMPtr<nsIURI> base = GetSourceBaseURL();
if (NS_FAILED(result)) {
return result;
}
return SetHrefWithBase(aHref, base, aReplace); return SetHrefWithBase(aHref, base, aReplace);
} }
@ -939,10 +933,9 @@ Location::Assign(const nsAString& aUrl,
} }
} }
nsresult already_AddRefed<nsIURI>
Location::GetSourceBaseURL(JSContext* cx, nsIURI** sourceURL) Location::GetSourceBaseURL()
{ {
*sourceURL = nullptr;
nsIDocument* doc = GetEntryDocument(); nsIDocument* doc = GetEntryDocument();
// If there's no entry document, we either have no Script Entry Point or one // If there's no entry document, we either have no Script Entry Point or one
// that isn't a DOM Window. This doesn't generally happen with the DOM, but // that isn't a DOM Window. This doesn't generally happen with the DOM, but
@ -958,9 +951,8 @@ Location::GetSourceBaseURL(JSContext* cx, nsIURI** sourceURL)
doc = docShellWin->GetDoc(); doc = docShellWin->GetDoc();
} }
} }
NS_ENSURE_TRUE(doc, NS_OK); NS_ENSURE_TRUE(doc, nullptr);
*sourceURL = doc->GetBaseURI().take(); return doc->GetBaseURI();
return NS_OK;
} }
bool bool

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

@ -172,7 +172,9 @@ protected:
nsresult SetHrefWithContext(JSContext* cx, const nsAString& aHref, nsresult SetHrefWithContext(JSContext* cx, const nsAString& aHref,
bool aReplace); bool aReplace);
nsresult GetSourceBaseURL(JSContext* cx, nsIURI** sourceURL); // Get the base URL we should be using for our relative URL
// resolution for SetHref/Assign/Replace.
already_AddRefed<nsIURI> GetSourceBaseURL();
nsresult CheckURL(nsIURI *url, nsDocShellLoadInfo** aLoadInfo); nsresult CheckURL(nsIURI *url, nsDocShellLoadInfo** aLoadInfo);
bool CallerSubsumes(nsIPrincipal* aSubjectPrincipal); bool CallerSubsumes(nsIPrincipal* aSubjectPrincipal);