Bug 1302987 - Rename nsLocation to mozilla::dom::Location, r=smaug
authorAndrea Marchesini <amarchesini@mozilla.com>
Fri, 16 Sep 2016 09:18:18 +0200
changeset 314237 0079d29d4ce323d812817b4a607eb91f63f680ea
parent 314236 6d372e532876e0a5a5f9ad4171b3ac936ea2a806
child 314238 88570c6adbe21830848a2e3f2f88cb1557e0dd29
push idunknown
push userunknown
push dateunknown
reviewerssmaug
bugs1302987
milestone51.0a1
Bug 1302987 - Rename nsLocation to mozilla::dom::Location, r=smaug
dom/base/Location.cpp
dom/base/Location.h
dom/base/moz.build
dom/base/nsDocument.cpp
dom/base/nsGlobalWindow.cpp
dom/base/nsGlobalWindow.h
dom/base/nsIDocument.h
dom/base/nsLocation.cpp
dom/base/nsLocation.h
dom/bindings/Bindings.conf
dom/html/nsHTMLDocument.h
dom/html/test/test_hash_encoded.html
modules/libpref/init/all.js
rename from dom/base/nsLocation.cpp
rename to dom/base/Location.cpp
--- a/dom/base/nsLocation.cpp
+++ b/dom/base/Location.cpp
@@ -1,15 +1,15 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-#include "nsLocation.h"
+#include "Location.h"
 #include "nsIScriptSecurityManager.h"
 #include "nsIScriptObjectPrincipal.h"
 #include "nsIScriptContext.h"
 #include "nsIDocShell.h"
 #include "nsIDocShellLoadInfo.h"
 #include "nsIWebNavigation.h"
 #include "nsCDefaultURIFixup.h"
 #include "nsIURIFixup.h"
@@ -30,83 +30,83 @@
 #include "nsContentUtils.h"
 #include "nsGlobalWindow.h"
 #include "mozilla/Likely.h"
 #include "nsCycleCollectionParticipant.h"
 #include "nsNullPrincipal.h"
 #include "ScriptSettings.h"
 #include "mozilla/dom/LocationBinding.h"
 
-using namespace mozilla;
-using namespace mozilla::dom;
+namespace mozilla {
+namespace dom {
 
 static nsresult
 GetDocumentCharacterSetForURI(const nsAString& aHref, nsACString& aCharset)
 {
   aCharset.Truncate();
 
   if (nsIDocument* doc = GetEntryDocument()) {
     aCharset = doc->GetDocumentCharacterSet();
   }
 
   return NS_OK;
 }
 
-nsLocation::nsLocation(nsPIDOMWindowInner* aWindow, nsIDocShell *aDocShell)
+Location::Location(nsPIDOMWindowInner* aWindow, nsIDocShell *aDocShell)
   : mInnerWindow(aWindow)
 {
   MOZ_ASSERT(aDocShell);
   MOZ_ASSERT(mInnerWindow->IsInnerWindow());
 
   mDocShell = do_GetWeakReference(aDocShell);
 }
 
-nsLocation::~nsLocation()
+Location::~Location()
 {
 }
 
-// QueryInterface implementation for nsLocation
-NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsLocation)
+// QueryInterface implementation for Location
+NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(Location)
   NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
   NS_INTERFACE_MAP_ENTRY(nsIDOMLocation)
   NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDOMLocation)
 NS_INTERFACE_MAP_END
 
-NS_IMPL_CYCLE_COLLECTION_CLASS(nsLocation)
+NS_IMPL_CYCLE_COLLECTION_CLASS(Location)
 
-NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsLocation)
+NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(Location)
   NS_IMPL_CYCLE_COLLECTION_UNLINK(mInnerWindow);
   NS_IMPL_CYCLE_COLLECTION_UNLINK_PRESERVED_WRAPPER
 NS_IMPL_CYCLE_COLLECTION_UNLINK_END
 
-NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsLocation)
+NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(Location)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mInnerWindow)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
 
-NS_IMPL_CYCLE_COLLECTION_TRACE_WRAPPERCACHE(nsLocation)
+NS_IMPL_CYCLE_COLLECTION_TRACE_WRAPPERCACHE(Location)
 
-NS_IMPL_CYCLE_COLLECTING_ADDREF(nsLocation)
-NS_IMPL_CYCLE_COLLECTING_RELEASE(nsLocation)
+NS_IMPL_CYCLE_COLLECTING_ADDREF(Location)
+NS_IMPL_CYCLE_COLLECTING_RELEASE(Location)
 
 void
-nsLocation::SetDocShell(nsIDocShell *aDocShell)
+Location::SetDocShell(nsIDocShell *aDocShell)
 {
    mDocShell = do_GetWeakReference(aDocShell);
 }
 
 nsIDocShell *
-nsLocation::GetDocShell()
+Location::GetDocShell()
 {
   nsCOMPtr<nsIDocShell> docshell(do_QueryReferent(mDocShell));
   return docshell;
 }
 
 nsresult
-nsLocation::CheckURL(nsIURI* aURI, nsIDocShellLoadInfo** aLoadInfo)
+Location::CheckURL(nsIURI* aURI, nsIDocShellLoadInfo** aLoadInfo)
 {
   *aLoadInfo = nullptr;
 
   nsCOMPtr<nsIDocShell> docShell(do_QueryReferent(mDocShell));
   NS_ENSURE_TRUE(docShell, NS_ERROR_NOT_AVAILABLE);
 
   nsCOMPtr<nsIPrincipal> triggeringPrincipal;
   nsCOMPtr<nsIURI> sourceURI;
@@ -159,20 +159,21 @@ nsLocation::CheckURL(nsIURI* aURI, nsIDo
       bool urisEqual = false;
       if (docOriginalURI && docCurrentURI && principalURI) {
         principalURI->Equals(docOriginalURI, &urisEqual);
       }
       if (urisEqual) {
         sourceURI = docCurrentURI;
       }
       else {
-        // Use principalURI as long as it is not an nsNullPrincipalURI.
-        // We could add a method such as GetReferrerURI to principals to make this
-        // cleaner, but given that we need to start using Source Browsing Context
-        // for referrer (see Bug 960639) this may be wasted effort at this stage.
+        // Use principalURI as long as it is not an nsNullPrincipalURI.  We
+        // could add a method such as GetReferrerURI to principals to make this
+        // cleaner, but given that we need to start using Source Browsing
+        // Context for referrer (see Bug 960639) this may be wasted effort at
+        // this stage.
         if (principalURI) {
           bool isNullPrincipalScheme;
           rv = principalURI->SchemeIs(NS_NULLPRINCIPAL_SCHEME,
                                      &isNullPrincipalScheme);
           if (NS_SUCCEEDED(rv) && !isNullPrincipalScheme) {
             sourceURI = principalURI;
           }
         }
@@ -200,17 +201,17 @@ nsLocation::CheckURL(nsIURI* aURI, nsIDo
   }
 
   loadInfo.swap(*aLoadInfo);
 
   return NS_OK;
 }
 
 nsresult
-nsLocation::GetURI(nsIURI** aURI, bool aGetInnermostURI)
+Location::GetURI(nsIURI** aURI, bool aGetInnermostURI)
 {
   *aURI = nullptr;
 
   nsresult rv;
   nsCOMPtr<nsIDocShell> docShell(do_QueryReferent(mDocShell));
   nsCOMPtr<nsIWebNavigation> webNav(do_QueryInterface(docShell, &rv));
   if (NS_FAILED(rv)) {
     return rv;
@@ -238,17 +239,17 @@ nsLocation::GetURI(nsIURI** aURI, bool a
 
   nsCOMPtr<nsIURIFixup> urifixup(do_GetService(NS_URIFIXUP_CONTRACTID, &rv));
   NS_ENSURE_SUCCESS(rv, rv);
 
   return urifixup->CreateExposableURI(uri, aURI);
 }
 
 nsresult
-nsLocation::GetWritableURI(nsIURI** aURI, const nsACString* aNewRef)
+Location::GetWritableURI(nsIURI** aURI, const nsACString* aNewRef)
 {
   *aURI = nullptr;
 
   nsCOMPtr<nsIURI> uri;
 
   nsresult rv = GetURI(getter_AddRefs(uri));
   if (NS_FAILED(rv) || !uri) {
     return rv;
@@ -257,17 +258,17 @@ nsLocation::GetWritableURI(nsIURI** aURI
   if (!aNewRef) {
     return uri->Clone(aURI);
   }
 
   return uri->CloneWithNewRef(*aNewRef, aURI);
 }
 
 nsresult
-nsLocation::SetURI(nsIURI* aURI, bool aReplace)
+Location::SetURI(nsIURI* aURI, bool aReplace)
 {
   nsCOMPtr<nsIDocShell> docShell(do_QueryReferent(mDocShell));
   if (docShell) {
     nsCOMPtr<nsIDocShellLoadInfo> loadInfo;
 
     if(NS_FAILED(CheckURL(aURI, getter_AddRefs(loadInfo))))
       return NS_ERROR_FAILURE;
 
@@ -287,17 +288,17 @@ nsLocation::SetURI(nsIURI* aURI, bool aR
     return docShell->LoadURI(aURI, loadInfo,
                              nsIWebNavigation::LOAD_FLAGS_NONE, true);
   }
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsLocation::GetHash(nsAString& aHash)
+Location::GetHash(nsAString& aHash)
 {
   aHash.SetLength(0);
 
   nsCOMPtr<nsIURI> uri;
   nsresult rv = GetURI(getter_AddRefs(uri));
   if (NS_FAILED(rv) || !uri) {
     return rv;
   }
@@ -346,33 +347,33 @@ nsLocation::GetHash(nsAString& aHash)
   } else {
     mCachedHash = aHash;
   }
 
   return rv;
 }
 
 NS_IMETHODIMP
-nsLocation::SetHash(const nsAString& aHash)
+Location::SetHash(const nsAString& aHash)
 {
   NS_ConvertUTF16toUTF8 hash(aHash);
   if (hash.IsEmpty() || hash.First() != char16_t('#')) {
     hash.Insert(char16_t('#'), 0);
   }
   nsCOMPtr<nsIURI> uri;
   nsresult rv = GetWritableURI(getter_AddRefs(uri), &hash);
   if (NS_FAILED(rv) || !uri) {
     return rv;
   }
 
   return SetURI(uri);
 }
 
 NS_IMETHODIMP
-nsLocation::GetHost(nsAString& aHost)
+Location::GetHost(nsAString& aHost)
 {
   aHost.Truncate();
 
   nsCOMPtr<nsIURI> uri;
   nsresult result;
 
   result = GetURI(getter_AddRefs(uri), true);
 
@@ -385,65 +386,65 @@ nsLocation::GetHost(nsAString& aHost)
       AppendUTF8toUTF16(hostport, aHost);
     }
   }
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsLocation::SetHost(const nsAString& aHost)
+Location::SetHost(const nsAString& aHost)
 {
   nsCOMPtr<nsIURI> uri;
   nsresult rv = GetWritableURI(getter_AddRefs(uri));
   if (NS_WARN_IF(NS_FAILED(rv) || !uri)) {
     return rv;
   }
 
   rv = uri->SetHostPort(NS_ConvertUTF16toUTF8(aHost));
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
   return SetURI(uri);
 }
 
 NS_IMETHODIMP
-nsLocation::GetHostname(nsAString& aHostname)
+Location::GetHostname(nsAString& aHostname)
 {
   aHostname.Truncate();
 
   nsCOMPtr<nsIURI> uri;
   GetURI(getter_AddRefs(uri), true);
   if (uri) {
     nsContentUtils::GetHostOrIPv6WithBrackets(uri, aHostname);
   }
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsLocation::SetHostname(const nsAString& aHostname)
+Location::SetHostname(const nsAString& aHostname)
 {
   nsCOMPtr<nsIURI> uri;
   nsresult rv = GetWritableURI(getter_AddRefs(uri));
   if (NS_WARN_IF(NS_FAILED(rv) || !uri)) {
     return rv;
   }
 
   rv = uri->SetHost(NS_ConvertUTF16toUTF8(aHostname));
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
   return SetURI(uri);
 }
 
 NS_IMETHODIMP
-nsLocation::GetHref(nsAString& aHref)
+Location::GetHref(nsAString& aHref)
 {
   aHref.Truncate();
 
   nsCOMPtr<nsIURI> uri;
   nsresult result;
 
   result = GetURI(getter_AddRefs(uri));
 
@@ -456,17 +457,17 @@ nsLocation::GetHref(nsAString& aHref)
       AppendUTF8toUTF16(uriString, aHref);
     }
   }
 
   return result;
 }
 
 NS_IMETHODIMP
-nsLocation::SetHref(const nsAString& aHref)
+Location::SetHref(const nsAString& aHref)
 {
   nsAutoString oldHref;
   nsresult rv = NS_OK;
 
   JSContext *cx = nsContentUtils::GetCurrentJSContext();
   if (cx) {
     rv = SetHrefWithContext(cx, aHref, false);
   } else {
@@ -482,33 +483,33 @@ nsLocation::SetHref(const nsAString& aHr
       }
     }
   }
 
   return rv;
 }
 
 nsresult
-nsLocation::SetHrefWithContext(JSContext* cx, const nsAString& aHref,
+Location::SetHrefWithContext(JSContext* cx, const nsAString& aHref,
                                bool aReplace)
 {
   nsCOMPtr<nsIURI> base;
 
   // Get the source of the caller
   nsresult result = GetSourceBaseURL(cx, getter_AddRefs(base));
 
   if (NS_FAILED(result)) {
     return result;
   }
 
   return SetHrefWithBase(aHref, base, aReplace);
 }
 
 nsresult
-nsLocation::SetHrefWithBase(const nsAString& aHref, nsIURI* aBase,
+Location::SetHrefWithBase(const nsAString& aHref, nsIURI* aBase,
                             bool aReplace)
 {
   nsresult result;
   nsCOMPtr<nsIURI> newUri;
 
   nsCOMPtr<nsIDocShell> docShell(do_QueryReferent(mDocShell));
 
   nsAutoCString docCharset;
@@ -548,17 +549,17 @@ nsLocation::SetHrefWithBase(const nsAStr
 
     return SetURI(newUri, aReplace || inScriptTag);
   }
 
   return result;
 }
 
 NS_IMETHODIMP
-nsLocation::GetOrigin(nsAString& aOrigin)
+Location::GetOrigin(nsAString& aOrigin)
 {
   aOrigin.Truncate();
 
   nsCOMPtr<nsIURI> uri;
   nsresult rv = GetURI(getter_AddRefs(uri), true);
   NS_ENSURE_SUCCESS(rv, rv);
   NS_ENSURE_TRUE(uri, NS_OK);
 
@@ -566,17 +567,17 @@ nsLocation::GetOrigin(nsAString& aOrigin
   rv = nsContentUtils::GetUTFOrigin(uri, origin);
   NS_ENSURE_SUCCESS(rv, rv);
 
   aOrigin = origin;
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsLocation::GetPathname(nsAString& aPathname)
+Location::GetPathname(nsAString& aPathname)
 {
   aPathname.Truncate();
 
   nsCOMPtr<nsIURI> uri;
   nsresult result = NS_OK;
 
   result = GetURI(getter_AddRefs(uri));
 
@@ -590,34 +591,34 @@ nsLocation::GetPathname(nsAString& aPath
       AppendUTF8toUTF16(file, aPathname);
     }
   }
 
   return result;
 }
 
 NS_IMETHODIMP
-nsLocation::SetPathname(const nsAString& aPathname)
+Location::SetPathname(const nsAString& aPathname)
 {
   nsCOMPtr<nsIURI> uri;
   nsresult rv = GetWritableURI(getter_AddRefs(uri));
   if (NS_WARN_IF(NS_FAILED(rv) || !uri)) {
     return rv;
   }
 
   rv = uri->SetPath(NS_ConvertUTF16toUTF8(aPathname));
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
   return SetURI(uri);
 }
 
 NS_IMETHODIMP
-nsLocation::GetPort(nsAString& aPort)
+Location::GetPort(nsAString& aPort)
 {
   aPort.SetLength(0);
 
   nsCOMPtr<nsIURI> uri;
   nsresult result = NS_OK;
 
   result = GetURI(getter_AddRefs(uri), true);
 
@@ -634,17 +635,17 @@ nsLocation::GetPort(nsAString& aPort)
     // Don't propagate this exception to caller
     result = NS_OK;
   }
 
   return result;
 }
 
 NS_IMETHODIMP
-nsLocation::SetPort(const nsAString& aPort)
+Location::SetPort(const nsAString& aPort)
 {
   nsCOMPtr<nsIURI> uri;
   nsresult rv = GetWritableURI(getter_AddRefs(uri));
   if (NS_WARN_IF(NS_FAILED(rv) || !uri)) {
     return rv;
   }
 
   // perhaps use nsReadingIterators at some point?
@@ -665,17 +666,17 @@ nsLocation::SetPort(const nsAString& aPo
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
   return SetURI(uri);
 }
 
 NS_IMETHODIMP
-nsLocation::GetProtocol(nsAString& aProtocol)
+Location::GetProtocol(nsAString& aProtocol)
 {
   aProtocol.SetLength(0);
 
   nsCOMPtr<nsIURI> uri;
   nsresult result = NS_OK;
 
   result = GetURI(getter_AddRefs(uri));
 
@@ -689,17 +690,17 @@ nsLocation::GetProtocol(nsAString& aProt
       aProtocol.Append(char16_t(':'));
     }
   }
 
   return result;
 }
 
 NS_IMETHODIMP
-nsLocation::SetProtocol(const nsAString& aProtocol)
+Location::SetProtocol(const nsAString& aProtocol)
 {
   nsCOMPtr<nsIURI> uri;
   nsresult rv = GetWritableURI(getter_AddRefs(uri));
   if (NS_WARN_IF(NS_FAILED(rv) || !uri)) {
     return rv;
   }
 
   rv = uri->SetScheme(NS_ConvertUTF16toUTF8(aProtocol));
@@ -716,34 +717,34 @@ nsLocation::SetProtocol(const nsAString&
   if (NS_FAILED(rv)) {
     return rv;
   }
 
   return SetURI(uri);
 }
 
 void
-nsLocation::GetUsername(nsAString& aUsername, ErrorResult& aError)
+Location::GetUsername(nsAString& aUsername, ErrorResult& aError)
 {
   THROW_AND_RETURN_IF_CALLER_DOESNT_SUBSUME();
 
   aUsername.Truncate();
   nsCOMPtr<nsIURI> uri;
   nsresult result = GetURI(getter_AddRefs(uri));
   if (uri) {
     nsAutoCString username;
     result = uri->GetUsername(username);
     if (NS_SUCCEEDED(result)) {
       CopyUTF8toUTF16(username, aUsername);
     }
   }
 }
 
 void
-nsLocation::SetUsername(const nsAString& aUsername, ErrorResult& aError)
+Location::SetUsername(const nsAString& aUsername, ErrorResult& aError)
 {
   THROW_AND_RETURN_IF_CALLER_DOESNT_SUBSUME();
 
   nsCOMPtr<nsIURI> uri;
   nsresult rv = GetWritableURI(getter_AddRefs(uri));
   if (NS_WARN_IF(NS_FAILED(rv))) {
     aError.Throw(rv);
     return;
@@ -758,34 +759,34 @@ nsLocation::SetUsername(const nsAString&
     aError.Throw(rv);
     return;
   }
 
   rv = SetURI(uri);
 }
 
 void
-nsLocation::GetPassword(nsAString& aPassword, ErrorResult& aError)
+Location::GetPassword(nsAString& aPassword, ErrorResult& aError)
 {
   THROW_AND_RETURN_IF_CALLER_DOESNT_SUBSUME();
 
   aPassword.Truncate();
   nsCOMPtr<nsIURI> uri;
   nsresult result = GetURI(getter_AddRefs(uri));
   if (uri) {
     nsAutoCString password;
     result = uri->GetPassword(password);
     if (NS_SUCCEEDED(result)) {
       CopyUTF8toUTF16(password, aPassword);
     }
   }
 }
 
 void
-nsLocation::SetPassword(const nsAString& aPassword, ErrorResult& aError)
+Location::SetPassword(const nsAString& aPassword, ErrorResult& aError)
 {
   THROW_AND_RETURN_IF_CALLER_DOESNT_SUBSUME();
 
   nsCOMPtr<nsIURI> uri;
   nsresult rv = GetWritableURI(getter_AddRefs(uri));
   if (NS_WARN_IF(NS_FAILED(rv))) {
     aError.Throw(rv);
     return;
@@ -800,17 +801,17 @@ nsLocation::SetPassword(const nsAString&
     aError.Throw(rv);
     return;
   }
 
   rv = SetURI(uri);
 }
 
 NS_IMETHODIMP
-nsLocation::GetSearch(nsAString& aSearch)
+Location::GetSearch(nsAString& aSearch)
 {
   aSearch.SetLength(0);
 
   nsCOMPtr<nsIURI> uri;
   nsresult result = NS_OK;
 
   result = GetURI(getter_AddRefs(uri));
 
@@ -826,28 +827,28 @@ nsLocation::GetSearch(nsAString& aSearch
       AppendUTF8toUTF16(search, aSearch);
     }
   }
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsLocation::SetSearch(const nsAString& aSearch)
+Location::SetSearch(const nsAString& aSearch)
 {
   nsresult rv = SetSearchInternal(aSearch);
   if (NS_FAILED(rv)) {
     return rv;
   }
 
   return NS_OK;
 }
 
 nsresult
-nsLocation::SetSearchInternal(const nsAString& aSearch)
+Location::SetSearchInternal(const nsAString& aSearch)
 {
   nsCOMPtr<nsIURI> uri;
   nsresult rv = GetWritableURI(getter_AddRefs(uri));
 
   nsCOMPtr<nsIURL> url(do_QueryInterface(uri));
   if (NS_WARN_IF(NS_FAILED(rv) || !url)) {
     return rv;
   }
@@ -856,22 +857,23 @@ nsLocation::SetSearchInternal(const nsAS
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
   return SetURI(uri);
 }
 
 NS_IMETHODIMP
-nsLocation::Reload(bool aForceget)
+Location::Reload(bool aForceget)
 {
   nsresult rv;
   nsCOMPtr<nsIDocShell> docShell(do_QueryReferent(mDocShell));
   nsCOMPtr<nsIWebNavigation> webNav(do_QueryInterface(docShell));
-  nsCOMPtr<nsPIDOMWindowOuter> window = docShell ? docShell->GetWindow() : nullptr;
+  nsCOMPtr<nsPIDOMWindowOuter> window = docShell ? docShell->GetWindow()
+                                                 : nullptr;
 
   if (window && window->IsHandlingResizeEvent()) {
     // location.reload() was called on a window that is handling a
     // resize event. Sites do this since Netscape 4.x needed it, but
     // we don't, and it's a horrible experience for nothing. In stead
     // of reloading the page, just clear style data and reflow the
     // page since some sites may use this trick to work around gecko
     // reflow bugs, and this should have the same effect.
@@ -904,17 +906,17 @@ nsLocation::Reload(bool aForceget)
   } else {
     rv = NS_ERROR_FAILURE;
   }
 
   return rv;
 }
 
 NS_IMETHODIMP
-nsLocation::Replace(const nsAString& aUrl)
+Location::Replace(const nsAString& aUrl)
 {
   nsresult rv = NS_OK;
   if (JSContext *cx = nsContentUtils::GetCurrentJSContext()) {
     return SetHrefWithContext(cx, aUrl, true);
   }
 
   nsAutoString oldHref;
 
@@ -925,17 +927,17 @@ nsLocation::Replace(const nsAString& aUr
 
   rv = NS_NewURI(getter_AddRefs(oldUri), oldHref);
   NS_ENSURE_SUCCESS(rv, rv);
 
   return SetHrefWithBase(aUrl, oldUri, true);
 }
 
 NS_IMETHODIMP
-nsLocation::Assign(const nsAString& aUrl)
+Location::Assign(const nsAString& aUrl)
 {
   if (JSContext *cx = nsContentUtils::GetCurrentJSContext()) {
     return SetHrefWithContext(cx, aUrl, false);
   }
 
   nsAutoString oldHref;
   nsresult result = NS_OK;
 
@@ -950,66 +952,71 @@ nsLocation::Assign(const nsAString& aUrl
       result = SetHrefWithBase(aUrl, oldUri, false);
     }
   }
 
   return result;
 }
 
 NS_IMETHODIMP
-nsLocation::ToString(nsAString& aReturn)
+Location::ToString(nsAString& aReturn)
 {
   return GetHref(aReturn);
 }
 
 NS_IMETHODIMP
-nsLocation::ValueOf(nsIDOMLocation** aReturn)
+Location::ValueOf(nsIDOMLocation** aReturn)
 {
   nsCOMPtr<nsIDOMLocation> loc(this);
   loc.forget(aReturn);
   return NS_OK;
 }
 
 nsresult
-nsLocation::GetSourceBaseURL(JSContext* cx, nsIURI** sourceURL)
+Location::GetSourceBaseURL(JSContext* cx, nsIURI** sourceURL)
 {
   *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 can sometimes happen with extension code in certain IPC configurations.
-  // If this happens, try falling back on the current document associated with
-  // the docshell. If that fails, just return null and hope that the caller passed
+  // that isn't a DOM Window.  This doesn't generally happen with the DOM, but
+  // can sometimes happen with extension code in certain IPC configurations.  If
+  // this happens, try falling back on the current document associated with the
+  // docshell. If that fails, just return null and hope that the caller passed
   // an absolute URI.
   if (!doc && GetDocShell()) {
-    nsCOMPtr<nsPIDOMWindowOuter> docShellWin = do_QueryInterface(GetDocShell()->GetScriptGlobalObject());
+    nsCOMPtr<nsPIDOMWindowOuter> docShellWin =
+      do_QueryInterface(GetDocShell()->GetScriptGlobalObject());
     if (docShellWin) {
       doc = docShellWin->GetDoc();
     }
   }
   NS_ENSURE_TRUE(doc, NS_OK);
   *sourceURL = doc->GetBaseURI().take();
   return NS_OK;
 }
 
 bool
-nsLocation::CallerSubsumes()
+Location::CallerSubsumes()
 {
   // Get the principal associated with the location object.  Note that this is
   // the principal of the page which will actually be navigated, not the
   // principal of the Location object itself.  This is why we need this check
   // even though we only allow limited cross-origin access to Location objects
   // in general.
   nsCOMPtr<nsPIDOMWindowOuter> outer = mInnerWindow->GetOuterWindow();
   if (MOZ_UNLIKELY(!outer))
     return false;
   nsCOMPtr<nsIScriptObjectPrincipal> sop = do_QueryInterface(outer);
   bool subsumes = false;
-  nsresult rv = nsContentUtils::SubjectPrincipal()->SubsumesConsideringDomain(sop->GetPrincipal(), &subsumes);
+  nsresult rv =
+    nsContentUtils::SubjectPrincipal()->SubsumesConsideringDomain(sop->GetPrincipal(), &subsumes);
   NS_ENSURE_SUCCESS(rv, false);
   return subsumes;
 }
 
 JSObject*
-nsLocation::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
+Location::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
 {
   return LocationBinding::Wrap(aCx, this, aGivenProto);
 }
+
+} // dom namespace
+} // mozilla namespace
rename from dom/base/nsLocation.h
rename to dom/base/Location.h
--- a/dom/base/nsLocation.h
+++ b/dom/base/Location.h
@@ -1,44 +1,45 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-#ifndef nsLocation_h__
-#define nsLocation_h__
+#ifndef mozilla_dom_Location_h
+#define mozilla_dom_Location_h
 
-#include "nsIDOMLocation.h"
-#include "nsString.h"
-#include "nsIWeakReferenceUtils.h"
-#include "nsWrapperCache.h"
-#include "nsCycleCollectionParticipant.h"
 #include "js/TypeDecls.h"
 #include "mozilla/ErrorResult.h"
+#include "nsCycleCollectionParticipant.h"
+#include "nsIDOMLocation.h"
+#include "nsIWeakReferenceUtils.h"
 #include "nsPIDOMWindow.h"
+#include "nsString.h"
+#include "nsWrapperCache.h"
 
-class nsIURI;
 class nsIDocShell;
 class nsIDocShellLoadInfo;
+class nsIURI;
+
+namespace mozilla {
+namespace dom {
 
 //*****************************************************************************
-// nsLocation: Script "location" object
+// Location: Script "location" object
 //*****************************************************************************
 
-class nsLocation final : public nsIDOMLocation
-                       , public nsWrapperCache
+class Location final : public nsIDOMLocation
+                     , public nsWrapperCache
 {
-  typedef mozilla::ErrorResult ErrorResult;
-
 public:
-  nsLocation(nsPIDOMWindowInner* aWindow, nsIDocShell *aDocShell);
+  Location(nsPIDOMWindowInner* aWindow, nsIDocShell *aDocShell);
 
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
-  NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_AMBIGUOUS(nsLocation,
+  NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_AMBIGUOUS(Location,
                                                          nsIDOMLocation)
 
   void SetDocShell(nsIDocShell *aDocShell);
   nsIDocShell *GetDocShell();
 
   // nsIDOMLocation
   NS_DECL_NSIDOMLOCATION
 
@@ -159,20 +160,22 @@ public:
   {
     // GetHref checks CallerSubsumes.
     GetHref(aRetval, aError);
   }
   nsPIDOMWindowInner* GetParentObject() const
   {
     return mInnerWindow;
   }
-  virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
+
+  virtual JSObject* WrapObject(JSContext* aCx,
+                               JS::Handle<JSObject*> aGivenProto) override;
 
 protected:
-  virtual ~nsLocation();
+  virtual ~Location();
 
   nsresult SetSearchInternal(const nsAString& aSearch);
 
   // In the case of jar: uris, we sometimes want the place the jar was
   // fetched from as the URI instead of the jar: uri itself.  Pass in
   // true for aGetInnermostURI when that's the case.
   nsresult GetURI(nsIURI** aURL, bool aGetInnermostURI = false);
   nsresult GetWritableURI(nsIURI** aURL,
@@ -188,9 +191,12 @@ protected:
   nsresult CheckURL(nsIURI *url, nsIDocShellLoadInfo** aLoadInfo);
   bool CallerSubsumes();
 
   nsString mCachedHash;
   nsCOMPtr<nsPIDOMWindowInner> mInnerWindow;
   nsWeakPtr mDocShell;
 };
 
-#endif // nsLocation_h__
+} // dom namespace
+} // mozilla namespace
+
+#endif // mozilla_dom_Location_h
--- a/dom/base/moz.build
+++ b/dom/base/moz.build
@@ -180,16 +180,17 @@ EXPORTS.mozilla.dom += [
     'FileList.h',
     'FileReader.h',
     'FormData.h',
     'FragmentOrElement.h',
     'FromParser.h',
     'ImageEncoder.h',
     'ImportManager.h',
     'Link.h',
+    'Location.h',
     'NameSpaceConstants.h',
     'Navigator.h',
     'NodeInfo.h',
     'NodeInfoInlines.h',
     'NodeIterator.h',
     'ProcessGlobal.h',
     'ResponsiveImageSelector.h',
     'SameProcessMessageQueue.h',
@@ -239,16 +240,17 @@ UNIFIED_SOURCES += [
     'File.cpp',
     'FileList.cpp',
     'FileReader.cpp',
     'FormData.cpp',
     'FragmentOrElement.cpp',
     'ImageEncoder.cpp',
     'ImportManager.cpp',
     'Link.cpp',
+    'Location.cpp',
     'MultipartBlobImpl.cpp',
     'Navigator.cpp',
     'NodeInfo.cpp',
     'NodeIterator.cpp',
     'nsAtomListUtils.cpp',
     'nsAttrAndChildArray.cpp',
     'nsAttrValue.cpp',
     'nsAttrValueOrString.cpp',
@@ -283,17 +285,16 @@ UNIFIED_SOURCES += [
     'nsHTMLContentSerializer.cpp',
     'nsIGlobalObject.cpp',
     'nsINode.cpp',
     'nsInProcessTabChildGlobal.cpp',
     'nsJSEnvironment.cpp',
     'nsJSTimeoutHandler.cpp',
     'nsJSUtils.cpp',
     'nsLineBreaker.cpp',
-    'nsLocation.cpp',
     'nsMappedAttributeElement.cpp',
     'nsMappedAttributes.cpp',
     'nsMimeTypeArray.cpp',
     'nsNameSpaceManager.cpp',
     'nsNoDataProtocolContentPolicy.cpp',
     'nsNodeInfoManager.cpp',
     'nsNodeUtils.cpp',
     'nsOpenURIInFrameParams.cpp',
--- a/dom/base/nsDocument.cpp
+++ b/dom/base/nsDocument.cpp
@@ -238,17 +238,17 @@
 #include "mozilla/dom/XPathNSResolverBinding.h"
 #include "mozilla/dom/XPathResult.h"
 #include "nsIDocumentEncoder.h"
 #include "nsIDocumentActivity.h"
 #include "nsIStructuredCloneContainer.h"
 #include "nsIMutableArray.h"
 #include "mozilla/dom/DOMStringList.h"
 #include "nsWindowMemoryReporter.h"
-#include "nsLocation.h"
+#include "mozilla/dom/Location.h"
 #include "mozilla/dom/FontFaceSet.h"
 #include "mozilla/dom/BoxObject.h"
 #include "gfxPrefs.h"
 #include "nsISupportsPrimitives.h"
 #include "mozilla/StyleSetHandle.h"
 #include "mozilla/StyleSetHandleInlines.h"
 #include "mozilla/StyleSheetHandle.h"
 #include "mozilla/StyleSheetHandleInlines.h"
@@ -6513,28 +6513,28 @@ nsDocument::GetDefaultView(mozIDOMWindow
 
 NS_IMETHODIMP
 nsDocument::GetLocation(nsIDOMLocation **_retval)
 {
   *_retval = nsIDocument::GetLocation().take();
   return NS_OK;
 }
 
-already_AddRefed<nsLocation>
+already_AddRefed<Location>
 nsIDocument::GetLocation() const
 {
   nsCOMPtr<nsPIDOMWindowInner> w = do_QueryInterface(mScriptGlobalObject);
 
   if (!w) {
     return nullptr;
   }
 
   nsGlobalWindow* window = nsGlobalWindow::Cast(w);
   ErrorResult dummy;
-  RefPtr<nsLocation> loc = window->GetLocation(dummy);
+  RefPtr<Location> loc = window->GetLocation(dummy);
   dummy.SuppressException();
   return loc.forget();
 }
 
 Element*
 nsIDocument::GetHtmlElement() const
 {
   Element* rootElement = GetRootElement();
--- a/dom/base/nsGlobalWindow.cpp
+++ b/dom/base/nsGlobalWindow.cpp
@@ -198,17 +198,17 @@
 
 #include "nsRefreshDriver.h"
 #include "Layers.h"
 
 #include "mozilla/AddonPathService.h"
 #include "mozilla/BasePrincipal.h"
 #include "mozilla/Services.h"
 #include "mozilla/Telemetry.h"
-#include "nsLocation.h"
+#include "mozilla/dom/Location.h"
 #include "nsHTMLDocument.h"
 #include "nsWrapperCacheInlines.h"
 #include "mozilla/DOMEventTargetHelper.h"
 #include "prrng.h"
 #include "nsSandboxFlags.h"
 #include "TimeChangeObserver.h"
 #include "mozilla/dom/AudioContext.h"
 #include "mozilla/dom/BrowserElementDictionariesBinding.h"
@@ -9749,24 +9749,24 @@ nsGlobalWindow::GetPrivateRoot()
         top = parent->GetTop();
       }
     }
   }
 
   return top;
 }
 
-nsLocation*
+Location*
 nsGlobalWindow::GetLocation(ErrorResult& aError)
 {
   MOZ_RELEASE_ASSERT(IsInnerWindow());
 
   nsIDocShell *docShell = GetDocShell();
   if (!mLocation && docShell) {
-    mLocation = new nsLocation(AsInner(), docShell);
+    mLocation = new Location(AsInner(), docShell);
   }
   return mLocation;
 }
 
 nsIDOMLocation*
 nsGlobalWindow::GetLocation()
 {
   FORWARD_TO_INNER(GetLocation, (), nullptr);
--- a/dom/base/nsGlobalWindow.h
+++ b/dom/base/nsGlobalWindow.h
@@ -83,17 +83,16 @@ class nsIDOMOfflineResourceList;
 class nsIScrollableFrame;
 class nsIControllers;
 class nsIJSID;
 class nsIScriptContext;
 class nsIScriptTimeoutHandler;
 class nsIWebBrowserChrome;
 
 class nsDOMWindowList;
-class nsLocation;
 class nsScreen;
 class nsHistory;
 class nsGlobalWindowObserver;
 class nsGlobalWindow;
 class nsDOMWindowUtils;
 class nsIIdleService;
 struct nsRect;
 
@@ -106,16 +105,17 @@ class BarProp;
 struct ChannelPixelLayout;
 class Console;
 class Crypto;
 class CustomElementsRegistry;
 class External;
 class Function;
 class Gamepad;
 enum class ImageBitmapFormat : uint32_t;
+class Location;
 class MediaQueryList;
 class MozSelfSupport;
 class Navigator;
 class OwningExternalOrWindowProxy;
 class Promise;
 class PostMessageEvent;
 struct RequestInit;
 class RequestOrUSVString;
@@ -875,17 +875,17 @@ public:
   nsIDocument* GetDocument()
   {
     return GetDoc();
   }
   void GetNameOuter(nsAString& aName);
   void GetName(nsAString& aName, mozilla::ErrorResult& aError);
   void SetNameOuter(const nsAString& aName, mozilla::ErrorResult& aError);
   void SetName(const nsAString& aName, mozilla::ErrorResult& aError);
-  nsLocation* GetLocation(mozilla::ErrorResult& aError);
+  mozilla::dom::Location* GetLocation(mozilla::ErrorResult& aError);
   nsIDOMLocation* GetLocation() override;
   nsHistory* GetHistory(mozilla::ErrorResult& aError);
   mozilla::dom::CustomElementsRegistry* CustomElements() override;
   mozilla::dom::BarProp* GetLocationbar(mozilla::ErrorResult& aError);
   mozilla::dom::BarProp* GetMenubar(mozilla::ErrorResult& aError);
   mozilla::dom::BarProp* GetPersonalbar(mozilla::ErrorResult& aError);
   mozilla::dom::BarProp* GetScrollbars(mozilla::ErrorResult& aError);
   mozilla::dom::BarProp* GetStatusbar(mozilla::ErrorResult& aError);
@@ -1845,17 +1845,17 @@ protected:
   // that come after it.
   mozilla::LinkedList<nsTimeout> mTimeouts;
   // If mTimeoutInsertionPoint is non-null, insertions should happen after it.
   // This is a dummy timeout at the moment; if that ever changes, the logic in
   // ResetTimersForNonBackgroundWindow needs to change.
   nsTimeout*                    mTimeoutInsertionPoint;
   uint32_t                      mTimeoutPublicIdCounter;
   uint32_t                      mTimeoutFiringDepth;
-  RefPtr<nsLocation>          mLocation;
+  RefPtr<mozilla::dom::Location> mLocation;
   RefPtr<nsHistory>           mHistory;
   RefPtr<mozilla::dom::CustomElementsRegistry> mCustomElements;
 
   // These member variables are used on both inner and the outer windows.
   nsCOMPtr<nsIPrincipal> mDocumentPrincipal;
 
   typedef nsTArray<RefPtr<mozilla::dom::StorageEvent>> nsDOMStorageEventArray;
   nsDOMStorageEventArray mPendingStorageEvents;
--- a/dom/base/nsIDocument.h
+++ b/dom/base/nsIDocument.h
@@ -80,17 +80,16 @@ class nsIObserver;
 class nsIPresShell;
 class nsIPrincipal;
 class nsIRequest;
 class nsIRunnable;
 class nsIStreamListener;
 class nsIStructuredCloneContainer;
 class nsIURI;
 class nsIVariant;
-class nsLocation;
 class nsViewManager;
 class nsPresContext;
 class nsRange;
 class nsScriptLoader;
 class nsSMILAnimationController;
 class nsTextNode;
 class nsWindowSizes;
 class nsDOMCaretPosition;
@@ -133,16 +132,17 @@ class Event;
 class EventTarget;
 class FontFaceSet;
 class FrameRequestCallback;
 struct FullscreenRequest;
 class ImportManager;
 class HTMLBodyElement;
 struct LifecycleCallbackArgs;
 class Link;
+class Location;
 class MediaQueryList;
 class GlobalObject;
 class NodeFilter;
 class NodeIterator;
 enum class OrientationType : uint32_t;
 class ProcessingInstruction;
 class Promise;
 class StyleSheetList;
@@ -2556,17 +2556,17 @@ public:
     CreateCDATASection(const nsAString& aData, mozilla::ErrorResult& rv);
   already_AddRefed<mozilla::dom::Attr>
     CreateAttribute(const nsAString& aName, mozilla::ErrorResult& rv);
   already_AddRefed<mozilla::dom::Attr>
     CreateAttributeNS(const nsAString& aNamespaceURI,
                       const nsAString& aQualifiedName,
                       mozilla::ErrorResult& rv);
   void GetInputEncoding(nsAString& aInputEncoding) const;
-  already_AddRefed<nsLocation> GetLocation() const;
+  already_AddRefed<mozilla::dom::Location> GetLocation() const;
   void GetReferrer(nsAString& aReferrer) const;
   void GetLastModified(nsAString& aLastModified) const;
   void GetReadyState(nsAString& aReadyState) const;
   // Not const because otherwise the compiler can't figure out whether to call
   // this GetTitle or the nsAString version from non-const methods, since
   // neither is an exact match.
   virtual void GetTitle(nsString& aTitle) = 0;
   virtual void SetTitle(const nsAString& aTitle, mozilla::ErrorResult& rv) = 0;
--- a/dom/bindings/Bindings.conf
+++ b/dom/bindings/Bindings.conf
@@ -633,20 +633,16 @@ DOMInterfaces = {
     'wrapperCache': False,
 },
 
 'LocalMediaStream': {
     'headerFile': 'DOMMediaStream.h',
     'nativeType': 'mozilla::DOMLocalMediaStream'
 },
 
-'Location': {
-    'nativeType': 'nsLocation',
-},
-
 'MediaList': {
     'nativeType': 'nsMediaList',
     'headerFile': 'nsIMediaList.h',
 },
 
 'MediaKeys' : {
     'implicitJSContext': [ 'createSession']
 },
--- a/dom/html/nsHTMLDocument.h
+++ b/dom/html/nsHTMLDocument.h
@@ -232,17 +232,18 @@ public:
   void Clear() const
   {
     // Deprecated
   }
   mozilla::dom::Selection* GetSelection(mozilla::ErrorResult& aRv);
   // The XPCOM CaptureEvents works fine for us.
   // The XPCOM ReleaseEvents works fine for us.
   // We're picking up GetLocation from Document
-  already_AddRefed<nsLocation> GetLocation() const {
+  already_AddRefed<mozilla::dom::Location> GetLocation() const
+  {
     return nsIDocument::GetLocation();
   }
 
   virtual nsHTMLDocument* AsHTMLDocument() override { return this; }
 
 protected:
   ~nsHTMLDocument();
 
--- a/dom/html/test/test_hash_encoded.html
+++ b/dom/html/test/test_hash_encoded.html
@@ -90,17 +90,17 @@ function doTestEncoded() {
   is(parsed.b.key, 'value', 'JSON not parsed correctly');
 
   url = new URL("http://www.example.com/test/");
   url.hash = '#{"a":[13, 42], "b":{"key":"value"}}';
   is(target.hash, '#{"a":[13, 42], "b":{"key":"value"}}', 'Unexpected url hash');
   parsed = JSON.parse(target.hash.substring(1));
   is(parsed.b.key, 'value', 'JSON not parsed correctly');
 
-  // Tests nsLocation::GetHash
+  // Tests Location::GetHash
 
   window.history.pushState(1, document.title, '#q=♥â¥#hello');
   is(location.hash,'#q=♥â¥#hello', 'Unexpected location hash');
 
   window.history.pushState(1, document.title, '#q=%E2%99%A5%C3%A2%C2%A5');
   is(location.hash,'#q=%E2%99%A5%C3%A2%C2%A5', 'Unexpected location hash');
 
   window.history.pushState(1, document.title, '#/search/%23important');
--- a/modules/libpref/init/all.js
+++ b/modules/libpref/init/all.js
@@ -200,17 +200,17 @@ pref("dom.keyboardevent.code.enabled", t
 // If this is true, TextEventDispatcher dispatches keydown and keyup events
 // even during composition (keypress events are never fired during composition
 // even if this is true).
 pref("dom.keyboardevent.dispatch_during_composition", false);
 
 // Whether the UndoManager API is enabled
 pref("dom.undo_manager.enabled", false);
 
-// Whether URL,nsLocation,Link::GetHash should be percent encoded
+// Whether URL,Location,Link::GetHash should be percent encoded
 // in setter and percent decoded in getter (old behaviour = true)
 pref("dom.url.encode_decode_hash", true);
 // Whether ::GetHash should do percent decoding (old behaviour = true)
 pref("dom.url.getters_decode_hash", false);
 
 // Whether to run add-on code in different compartments from browser code. This
 // causes a separate compartment for each (addon, global) combination, which may
 // significantly increase the number of compartments in the system.