diff --git a/dom/base/Location.cpp b/dom/base/Location.cpp index 25597ed073b6..a152d8b9f2cd 100644 --- a/dom/base/Location.cpp +++ b/dom/base/Location.cpp @@ -460,14 +460,8 @@ nsresult Location::SetHrefWithContext(JSContext* cx, const nsAString& aHref, bool aReplace) { - nsCOMPtr base; - // Get the source of the caller - nsresult result = GetSourceBaseURL(cx, getter_AddRefs(base)); - - if (NS_FAILED(result)) { - return result; - } + nsCOMPtr base = GetSourceBaseURL(); return SetHrefWithBase(aHref, base, aReplace); } @@ -939,10 +933,9 @@ Location::Assign(const nsAString& aUrl, } } -nsresult -Location::GetSourceBaseURL(JSContext* cx, nsIURI** sourceURL) +already_AddRefed +Location::GetSourceBaseURL() { - *sourceURL = nullptr; nsIDocument* doc = GetEntryDocument(); // 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 @@ -958,9 +951,8 @@ Location::GetSourceBaseURL(JSContext* cx, nsIURI** sourceURL) doc = docShellWin->GetDoc(); } } - NS_ENSURE_TRUE(doc, NS_OK); - *sourceURL = doc->GetBaseURI().take(); - return NS_OK; + NS_ENSURE_TRUE(doc, nullptr); + return doc->GetBaseURI(); } bool diff --git a/dom/base/Location.h b/dom/base/Location.h index 7c62041d7413..0389b9507e33 100644 --- a/dom/base/Location.h +++ b/dom/base/Location.h @@ -172,7 +172,9 @@ protected: nsresult SetHrefWithContext(JSContext* cx, const nsAString& aHref, 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 GetSourceBaseURL(); nsresult CheckURL(nsIURI *url, nsDocShellLoadInfo** aLoadInfo); bool CallerSubsumes(nsIPrincipal* aSubjectPrincipal);