From a67a0a31e8f0511ac9794788e4ea6110d6df885b Mon Sep 17 00:00:00 2001 From: Andrea Marchesini Date: Mon, 8 May 2017 15:49:31 +0200 Subject: [PATCH] Bug 1362003 - nsGlobalWindow::GetLocation doesn't need to receive an ErrorResult param, r=bz Renaming nsGlobalWindow::GetLocation() to Location(). --- chrome/nsChromeRegistry.cpp | 5 +++-- dom/base/nsDocument.cpp | 4 +--- dom/base/nsGlobalWindow.cpp | 15 ++------------- dom/base/nsGlobalWindow.h | 3 +-- dom/base/nsPIDOMWindow.h | 5 ++++- dom/interfaces/base/nsIDOMWindow.idl | 1 - dom/ipc/TelemetryScrollProbe.cpp | 1 - dom/webidl/Window.webidl | 2 +- .../src/peerconnection/PeerConnectionImpl.cpp | 4 ++-- toolkit/xre/nsNativeAppSupportWin.cpp | 4 ++-- 10 files changed, 16 insertions(+), 28 deletions(-) diff --git a/chrome/nsChromeRegistry.cpp b/chrome/nsChromeRegistry.cpp index 00e38c91af10..1a94191ed0f5 100644 --- a/chrome/nsChromeRegistry.cpp +++ b/chrome/nsChromeRegistry.cpp @@ -19,7 +19,6 @@ #include "nsIConsoleService.h" #include "nsIDocument.h" #include "nsIDOMDocument.h" -#include "nsIDOMLocation.h" #include "nsIDOMWindowCollection.h" #include "nsIDOMWindow.h" #include "nsIObserverService.h" @@ -31,6 +30,7 @@ #include "mozilla/Printf.h" #include "mozilla/StyleSheet.h" #include "mozilla/StyleSheetInlines.h" +#include "mozilla/dom/Location.h" #ifdef ENABLE_INTL_API #include "unicode/uloc.h" @@ -42,6 +42,7 @@ nsChromeRegistry* nsChromeRegistry::gChromeRegistry; // mozilla::TextRange and a TextRange in OSX headers. using mozilla::StyleSheet; using mozilla::dom::IsChromeURI; +using mozilla::dom::Location; //////////////////////////////////////////////////////////////////////////////// @@ -508,7 +509,7 @@ nsChromeRegistry::ReloadChrome() if (NS_SUCCEEDED(rv)) { nsCOMPtr domWindow = do_QueryInterface(protoWindow); if (domWindow) { - nsIDOMLocation* location = domWindow->GetLocation(); + Location* location = domWindow->Location(); if (location) { rv = location->Reload(false); if (NS_FAILED(rv)) return rv; diff --git a/dom/base/nsDocument.cpp b/dom/base/nsDocument.cpp index af9ea0adbdf5..dbbf749e3f4a 100644 --- a/dom/base/nsDocument.cpp +++ b/dom/base/nsDocument.cpp @@ -6877,9 +6877,7 @@ nsIDocument::GetLocation() const } nsGlobalWindow* window = nsGlobalWindow::Cast(w); - ErrorResult dummy; - RefPtr loc = window->GetLocation(dummy); - dummy.SuppressException(); + RefPtr loc = window->Location(); return loc.forget(); } diff --git a/dom/base/nsGlobalWindow.cpp b/dom/base/nsGlobalWindow.cpp index 9e6dac4fd9c2..ed163644f547 100644 --- a/dom/base/nsGlobalWindow.cpp +++ b/dom/base/nsGlobalWindow.cpp @@ -10438,28 +10438,17 @@ nsGlobalWindow::GetPrivateRoot() } Location* -nsGlobalWindow::GetLocation(ErrorResult& aError) +nsGlobalWindow::Location() { MOZ_RELEASE_ASSERT(IsInnerWindow()); if (!mLocation) { - mLocation = new Location(AsInner(), GetDocShell()); + mLocation = new dom::Location(AsInner(), GetDocShell()); } return mLocation; } -nsIDOMLocation* -nsGlobalWindow::GetLocation() -{ - FORWARD_TO_INNER(GetLocation, (), nullptr); - - ErrorResult dummy; - nsIDOMLocation* location = GetLocation(dummy); - dummy.SuppressException(); - return location; -} - void nsGlobalWindow::ActivateOrDeactivate(bool aActivate) { diff --git a/dom/base/nsGlobalWindow.h b/dom/base/nsGlobalWindow.h index a2886a173d1c..8601041d3749 100644 --- a/dom/base/nsGlobalWindow.h +++ b/dom/base/nsGlobalWindow.h @@ -855,8 +855,7 @@ public: void GetName(nsAString& aName, mozilla::ErrorResult& aError); void SetNameOuter(const nsAString& aName, mozilla::ErrorResult& aError); void SetName(const nsAString& aName, mozilla::ErrorResult& aError); - mozilla::dom::Location* GetLocation(mozilla::ErrorResult& aError); - nsIDOMLocation* GetLocation() override; + mozilla::dom::Location* Location() override; nsHistory* GetHistory(mozilla::ErrorResult& aError); mozilla::dom::CustomElementRegistry* CustomElements() override; mozilla::dom::BarProp* GetLocationbar(mozilla::ErrorResult& aError); diff --git a/dom/base/nsPIDOMWindow.h b/dom/base/nsPIDOMWindow.h index 5518a9270301..2ba183470243 100644 --- a/dom/base/nsPIDOMWindow.h +++ b/dom/base/nsPIDOMWindow.h @@ -91,6 +91,9 @@ enum class FullscreenReason namespace mozilla { namespace dom { + +class Location; + // The states in this enum represent the different possible outcomes which the // window could be experiencing of loading a document with the // Large-Allocation header. The NONE case represents the case where no @@ -570,7 +573,7 @@ public: virtual nsIDOMScreen* GetScreen() = 0; virtual nsIDOMNavigator* GetNavigator() = 0; - virtual nsIDOMLocation* GetLocation() = 0; + virtual mozilla::dom::Location* Location() = 0; virtual nsresult GetPrompter(nsIPrompt** aPrompt) = 0; virtual nsresult GetControllers(nsIControllers** aControllers) = 0; virtual already_AddRefed GetSelection() = 0; diff --git a/dom/interfaces/base/nsIDOMWindow.idl b/dom/interfaces/base/nsIDOMWindow.idl index b41458a1231d..ecb9ad4f5d1e 100644 --- a/dom/interfaces/base/nsIDOMWindow.idl +++ b/dom/interfaces/base/nsIDOMWindow.idl @@ -7,7 +7,6 @@ interface nsIControllers; interface nsIDOMBlob; -interface nsIDOMLocation; interface nsIDOMOfflineResourceList; interface nsIPrompt; interface nsISelection; diff --git a/dom/ipc/TelemetryScrollProbe.cpp b/dom/ipc/TelemetryScrollProbe.cpp index a3a97b4ce5ed..a7c9814265c5 100644 --- a/dom/ipc/TelemetryScrollProbe.cpp +++ b/dom/ipc/TelemetryScrollProbe.cpp @@ -8,7 +8,6 @@ #include "nsIDOMDocument.h" // for nsIDOMDocument #include "nsIDOMEvent.h" // for nsIDOMEvent -#include "nsIDOMLocation.h" // for nsIDOMLocation #include "nsIURI.h" // for nsIURI #include "TabChild.h" // for TabChildGlobal, TabChildBase #include "mozilla/Telemetry.h" // for mozilla::Telemetry diff --git a/dom/webidl/Window.webidl b/dom/webidl/Window.webidl index 96a3ed6f8af9..dbe5c0221abc 100644 --- a/dom/webidl/Window.webidl +++ b/dom/webidl/Window.webidl @@ -35,7 +35,7 @@ interface nsIDOMCrypto; CrossOriginReadable] readonly attribute Window self; [Unforgeable, StoreInSlot, Pure] readonly attribute Document? document; [Throws] attribute DOMString name; - [PutForwards=href, Unforgeable, Throws, + [PutForwards=href, Unforgeable, CrossOriginReadable, CrossOriginWritable] readonly attribute Location location; [Throws] readonly attribute History history; [Func="CustomElementRegistry::IsCustomElementEnabled"] diff --git a/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.cpp b/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.cpp index fbf263175551..ca62c420477d 100644 --- a/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.cpp +++ b/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.cpp @@ -60,6 +60,7 @@ #include "nsIDocument.h" #include "nsGlobalWindow.h" #include "nsDOMDataChannel.h" +#include "mozilla/dom/Location.h" #include "mozilla/dom/Performance.h" #include "mozilla/TimeStamp.h" #include "mozilla/Telemetry.h" @@ -74,7 +75,6 @@ #include "nsNetUtil.h" #include "nsIURLParser.h" #include "nsIDOMDataChannel.h" -#include "nsIDOMLocation.h" #include "NullPrincipal.h" #include "mozilla/PeerIdentity.h" #include "mozilla/dom/RTCCertificate.h" @@ -609,7 +609,7 @@ PeerConnectionImpl::Initialize(PeerConnectionObserver& aObserver, nsAutoCString locationCStr; - if (nsCOMPtr location = mWindow->GetLocation()) { + if (RefPtr location = mWindow->Location()) { nsAutoString locationAStr; location->ToString(locationAStr); diff --git a/toolkit/xre/nsNativeAppSupportWin.cpp b/toolkit/xre/nsNativeAppSupportWin.cpp index 8234b83e3aad..7d2a211d8fc8 100644 --- a/toolkit/xre/nsNativeAppSupportWin.cpp +++ b/toolkit/xre/nsNativeAppSupportWin.cpp @@ -35,11 +35,11 @@ #include "nsIFile.h" #include "nsIObserver.h" #include "nsIObserverService.h" -#include "nsIDOMLocation.h" #include "nsIWebNavigation.h" #include "nsIWindowMediator.h" #include "nsNativeCharsetUtils.h" #include "nsIAppStartup.h" +#include "mozilla/dom/Location.h" #include #include @@ -967,7 +967,7 @@ nsNativeAppSupportWin::HandleDDENotification( UINT uType, // transaction t break; } // Get location. - nsCOMPtr location = internalContent->GetLocation(); + RefPtr location = internalContent->Location(); if ( !location ) { break; }