diff --git a/content/base/src/EventSource.cpp b/content/base/src/EventSource.cpp index a94ac100db8..660cacff58b 100644 --- a/content/base/src/EventSource.cpp +++ b/content/base/src/EventSource.cpp @@ -1238,7 +1238,7 @@ EventSource::DispatchAllMessageEvents() } AutoJSAPI jsapi; - if (NS_WARN_IF(!jsapi.InitUsingWin(GetOwner()))) { + if (NS_WARN_IF(!jsapi.Init(GetOwner()))) { return; } JSContext* cx = jsapi.cx(); diff --git a/content/base/src/WebSocket.cpp b/content/base/src/WebSocket.cpp index 1a126d01000..b2bf682a493 100644 --- a/content/base/src/WebSocket.cpp +++ b/content/base/src/WebSocket.cpp @@ -866,7 +866,7 @@ WebSocket::CreateAndDispatchMessageEvent(const nsACString& aData, return NS_OK; AutoJSAPI jsapi; - if (NS_WARN_IF(!jsapi.InitUsingWin(GetOwner()))) { + if (NS_WARN_IF(!jsapi.Init(GetOwner()))) { return NS_ERROR_FAILURE; } JSContext* cx = jsapi.cx(); diff --git a/content/base/src/nsContentUtils.cpp b/content/base/src/nsContentUtils.cpp index 05ee0bfc222..e92417f6960 100644 --- a/content/base/src/nsContentUtils.cpp +++ b/content/base/src/nsContentUtils.cpp @@ -6323,7 +6323,7 @@ nsContentUtils::IsPatternMatching(nsAString& aValue, nsAString& aPattern, NS_ASSERTION(aDocument, "aDocument should be a valid pointer (not null)"); AutoJSAPI jsapi; - if (NS_WARN_IF(!jsapi.InitUsingWin(aDocument->GetWindow()))) { + if (NS_WARN_IF(!jsapi.Init(aDocument->GetWindow()))) { return true; } JSContext* cx = jsapi.cx(); diff --git a/content/base/src/nsDOMDataChannel.cpp b/content/base/src/nsDOMDataChannel.cpp index 8d250ab706b..a6ac0ca80a7 100644 --- a/content/base/src/nsDOMDataChannel.cpp +++ b/content/base/src/nsDOMDataChannel.cpp @@ -384,7 +384,7 @@ nsDOMDataChannel::DoOnMessageAvailable(const nsACString& aData, } AutoJSAPI jsapi; - if (NS_WARN_IF(!jsapi.InitUsingWin(GetOwner()))) { + if (NS_WARN_IF(!jsapi.Init(GetOwner()))) { return NS_ERROR_FAILURE; } JSContext* cx = jsapi.cx(); diff --git a/content/media/webaudio/AudioDestinationNode.cpp b/content/media/webaudio/AudioDestinationNode.cpp index 5ea1d057486..80075df6506 100644 --- a/content/media/webaudio/AudioDestinationNode.cpp +++ b/content/media/webaudio/AudioDestinationNode.cpp @@ -127,7 +127,7 @@ public: // AudioDestinationNode::FireOfflineCompletionEvent. AutoJSAPI jsapi; - if (NS_WARN_IF(!jsapi.InitUsingWin(aNode->GetOwner()))) { + if (NS_WARN_IF(!jsapi.Init(aNode->GetOwner()))) { return; } JSContext* cx = jsapi.cx(); diff --git a/content/media/webaudio/AudioProcessingEvent.cpp b/content/media/webaudio/AudioProcessingEvent.cpp index 1901b7e4802..979e510f869 100644 --- a/content/media/webaudio/AudioProcessingEvent.cpp +++ b/content/media/webaudio/AudioProcessingEvent.cpp @@ -42,7 +42,7 @@ AudioProcessingEvent::LazilyCreateBuffer(uint32_t aNumberOfChannels, ErrorResult& aRv) { AutoJSAPI jsapi; - if (NS_WARN_IF(!jsapi.InitUsingWin(mNode->GetOwner()))) { + if (NS_WARN_IF(!jsapi.Init(mNode->GetOwner()))) { aRv.Throw(NS_ERROR_UNEXPECTED); return nullptr; } diff --git a/content/media/webaudio/MediaBufferDecoder.cpp b/content/media/webaudio/MediaBufferDecoder.cpp index 340b8a82ff9..b7585921010 100644 --- a/content/media/webaudio/MediaBufferDecoder.cpp +++ b/content/media/webaudio/MediaBufferDecoder.cpp @@ -414,7 +414,7 @@ WebAudioDecodeJob::AllocateBuffer() MOZ_ASSERT(NS_IsMainThread()); AutoJSAPI jsapi; - if (NS_WARN_IF(!jsapi.InitUsingWin(mContext->GetOwner()))) { + if (NS_WARN_IF(!jsapi.Init(mContext->GetOwner()))) { return false; } JSContext* cx = jsapi.cx(); diff --git a/content/media/webaudio/ScriptProcessorNode.cpp b/content/media/webaudio/ScriptProcessorNode.cpp index d3e90837849..89f5b59f662 100644 --- a/content/media/webaudio/ScriptProcessorNode.cpp +++ b/content/media/webaudio/ScriptProcessorNode.cpp @@ -403,7 +403,7 @@ private: } AutoJSAPI jsapi; - if (NS_WARN_IF(!jsapi.InitUsingWin(node->GetOwner()))) { + if (NS_WARN_IF(!jsapi.Init(node->GetOwner()))) { return NS_OK; } JSContext* cx = jsapi.cx(); diff --git a/dom/archivereader/ArchiveRequest.cpp b/dom/archivereader/ArchiveRequest.cpp index 6065e8a03eb..9047110abe9 100644 --- a/dom/archivereader/ArchiveRequest.cpp +++ b/dom/archivereader/ArchiveRequest.cpp @@ -132,7 +132,7 @@ ArchiveRequest::ReaderReady(nsTArray >& aFileList, nsresult rv; AutoJSAPI jsapi; - if (NS_WARN_IF(!jsapi.InitUsingWin(GetOwner()))) { + if (NS_WARN_IF(!jsapi.Init(GetOwner()))) { return NS_ERROR_UNEXPECTED; } JSContext* cx = jsapi.cx(); diff --git a/dom/base/ScriptSettings.cpp b/dom/base/ScriptSettings.cpp index ece2c83ffb0..2a42cb150ae 100644 --- a/dom/base/ScriptSettings.cpp +++ b/dom/base/ScriptSettings.cpp @@ -294,23 +294,41 @@ AutoJSAPI::InitWithLegacyErrorReporting(nsIGlobalObject* aGlobalObject) } bool -AutoJSAPI::InitUsingWin(nsPIDOMWindow* aWindow, JSContext* aCx) +AutoJSAPI::Init(nsPIDOMWindow* aWindow, JSContext* aCx) { return Init(static_cast(aWindow), aCx); } bool -AutoJSAPI::InitUsingWin(nsPIDOMWindow* aWindow) +AutoJSAPI::Init(nsPIDOMWindow* aWindow) { return Init(static_cast(aWindow)); } bool -AutoJSAPI::InitWithLegacyErrorReportingUsingWin(nsPIDOMWindow* aWindow) +AutoJSAPI::Init(nsGlobalWindow* aWindow, JSContext* aCx) +{ + return Init(static_cast(aWindow), aCx); +} + +bool +AutoJSAPI::Init(nsGlobalWindow* aWindow) +{ + return Init(static_cast(aWindow)); +} + +bool +AutoJSAPI::InitWithLegacyErrorReporting(nsPIDOMWindow* aWindow) { return InitWithLegacyErrorReporting(static_cast(aWindow)); } +bool +AutoJSAPI::InitWithLegacyErrorReporting(nsGlobalWindow* aWindow) +{ + return InitWithLegacyErrorReporting(static_cast(aWindow)); +} + AutoEntryScript::AutoEntryScript(nsIGlobalObject* aGlobalObject, bool aIsMainThread, JSContext* aCx) diff --git a/dom/base/ScriptSettings.h b/dom/base/ScriptSettings.h index ac48af2807a..40f7b0afea2 100644 --- a/dom/base/ScriptSettings.h +++ b/dom/base/ScriptSettings.h @@ -17,6 +17,7 @@ #include "mozilla/Maybe.h" class nsPIDOMWindow; +class nsGlobalWindow; namespace mozilla { namespace dom { @@ -154,11 +155,16 @@ public: // false and use of cx() will cause an assertion. bool InitWithLegacyErrorReporting(nsIGlobalObject* aGlobalObject); - // Convenience functions to take an nsPIDOMWindow*, when it is more easily - // available than an nsIGlobalObject. - bool InitUsingWin(nsPIDOMWindow* aWindow); - bool InitUsingWin(nsPIDOMWindow* aWindow, JSContext* aCx); - bool InitWithLegacyErrorReportingUsingWin(nsPIDOMWindow* aWindow); + // Convenience functions to take an nsPIDOMWindow* or nsGlobalWindow*, + // when it is more easily available than an nsIGlobalObject. + bool Init(nsPIDOMWindow* aWindow); + bool Init(nsPIDOMWindow* aWindow, JSContext* aCx); + + bool Init(nsGlobalWindow* aWindow); + bool Init(nsGlobalWindow* aWindow, JSContext* aCx); + + bool InitWithLegacyErrorReporting(nsPIDOMWindow* aWindow); + bool InitWithLegacyErrorReporting(nsGlobalWindow* aWindow); JSContext* cx() const { MOZ_ASSERT(mCx, "Must call Init before using an AutoJSAPI"); diff --git a/dom/bluetooth/BluetoothAdapter.cpp b/dom/bluetooth/BluetoothAdapter.cpp index 1f1fbb31ad4..de91ced82fa 100644 --- a/dom/bluetooth/BluetoothAdapter.cpp +++ b/dom/bluetooth/BluetoothAdapter.cpp @@ -96,7 +96,7 @@ public: } AutoJSAPI jsapi; - if (!jsapi.InitUsingWin(mAdapterPtr->GetOwner())) { + if (!jsapi.Init(mAdapterPtr->GetOwner())) { BT_WARNING("Failed to initialise AutoJSAPI!"); SetError(NS_LITERAL_STRING("BluetoothAutoJSAPIInitError")); return false; @@ -252,7 +252,7 @@ BluetoothAdapter::SetPropertyByValue(const BluetoothNamedValue& aValue) mUuids = value.get_ArrayOfnsString(); AutoJSAPI jsapi; - if (!jsapi.InitUsingWin(GetOwner())) { + if (!jsapi.Init(GetOwner())) { BT_WARNING("Failed to initialise AutoJSAPI!"); return; } @@ -268,7 +268,7 @@ BluetoothAdapter::SetPropertyByValue(const BluetoothNamedValue& aValue) mDeviceAddresses = value.get_ArrayOfnsString(); AutoJSAPI jsapi; - if (!jsapi.InitUsingWin(GetOwner())) { + if (!jsapi.Init(GetOwner())) { BT_WARNING("Failed to initialise AutoJSAPI!"); return; } diff --git a/dom/bluetooth/BluetoothDevice.cpp b/dom/bluetooth/BluetoothDevice.cpp index 12260567264..07ade8bb49f 100644 --- a/dom/bluetooth/BluetoothDevice.cpp +++ b/dom/bluetooth/BluetoothDevice.cpp @@ -132,7 +132,7 @@ BluetoothDevice::SetPropertyByValue(const BluetoothNamedValue& aValue) mUuids = value.get_ArrayOfnsString(); AutoJSAPI jsapi; - if (!jsapi.InitUsingWin(GetOwner())) { + if (!jsapi.Init(GetOwner())) { BT_WARNING("Failed to initialise AutoJSAPI!"); return; } @@ -148,7 +148,7 @@ BluetoothDevice::SetPropertyByValue(const BluetoothNamedValue& aValue) mServices = value.get_ArrayOfnsString(); AutoJSAPI jsapi; - if (!jsapi.InitUsingWin(GetOwner())) { + if (!jsapi.Init(GetOwner())) { BT_WARNING("Failed to initialise AutoJSAPI!"); return; } diff --git a/dom/bluetooth/BluetoothManager.cpp b/dom/bluetooth/BluetoothManager.cpp index 552c9a7686c..e6f0b0dd60e 100644 --- a/dom/bluetooth/BluetoothManager.cpp +++ b/dom/bluetooth/BluetoothManager.cpp @@ -69,7 +69,7 @@ public: BluetoothAdapter::Create(mManagerPtr->GetOwner(), values); dom::AutoJSAPI jsapi; - if (!jsapi.InitUsingWin(mManagerPtr->GetOwner())) { + if (!jsapi.Init(mManagerPtr->GetOwner())) { BT_WARNING("Failed to initialise AutoJSAPI!"); SetError(NS_LITERAL_STRING("BluetoothAutoJSAPIInitError")); return false; diff --git a/dom/bluetooth2/BluetoothAdapter.cpp b/dom/bluetooth2/BluetoothAdapter.cpp index 6b4958f6765..008f8d8a85c 100644 --- a/dom/bluetooth2/BluetoothAdapter.cpp +++ b/dom/bluetooth2/BluetoothAdapter.cpp @@ -95,7 +95,7 @@ public: } AutoJSAPI jsapi; - if (!jsapi.InitUsingWin(mAdapterPtr->GetOwner())) { + if (!jsapi.Init(mAdapterPtr->GetOwner())) { BT_WARNING("Failed to initialise AutoJSAPI!"); SetError(NS_LITERAL_STRING("BluetoothAutoJSAPIInitError")); return false; @@ -254,7 +254,7 @@ BluetoothAdapter::SetPropertyByValue(const BluetoothNamedValue& aValue) mUuids = value.get_ArrayOfnsString(); AutoJSAPI jsapi; - if (!jsapi.InitUsingWin(GetOwner())) { + if (!jsapi.Init(GetOwner())) { BT_WARNING("Failed to initialise AutoJSAPI!"); return; } @@ -270,7 +270,7 @@ BluetoothAdapter::SetPropertyByValue(const BluetoothNamedValue& aValue) mDeviceAddresses = value.get_ArrayOfnsString(); AutoJSAPI jsapi; - if (!jsapi.InitUsingWin(GetOwner())) { + if (!jsapi.Init(GetOwner())) { BT_WARNING("Failed to initialise AutoJSAPI!"); return; } diff --git a/dom/bluetooth2/BluetoothDevice.cpp b/dom/bluetooth2/BluetoothDevice.cpp index 01c76204b23..a068c3d1176 100644 --- a/dom/bluetooth2/BluetoothDevice.cpp +++ b/dom/bluetooth2/BluetoothDevice.cpp @@ -126,7 +126,7 @@ BluetoothDevice::SetPropertyByValue(const BluetoothNamedValue& aValue) mUuids = value.get_ArrayOfnsString(); AutoJSAPI jsapi; - if (!jsapi.InitUsingWin(GetOwner())) { + if (!jsapi.Init(GetOwner())) { BT_WARNING("Failed to initialise AutoJSAPI!"); return; } @@ -142,7 +142,7 @@ BluetoothDevice::SetPropertyByValue(const BluetoothNamedValue& aValue) mServices = value.get_ArrayOfnsString(); AutoJSAPI jsapi; - if (!jsapi.InitUsingWin(GetOwner())) { + if (!jsapi.Init(GetOwner())) { BT_WARNING("Failed to initialise AutoJSAPI!"); return; } diff --git a/dom/devicestorage/nsDeviceStorage.cpp b/dom/devicestorage/nsDeviceStorage.cpp index 55b4f6baf84..08ca6bce93c 100644 --- a/dom/devicestorage/nsDeviceStorage.cpp +++ b/dom/devicestorage/nsDeviceStorage.cpp @@ -1726,7 +1726,7 @@ JS::Value StringToJsval(nsPIDOMWindow* aWindow, nsAString& aString) MOZ_ASSERT(aWindow); AutoJSAPI jsapi; - if (NS_WARN_IF(!jsapi.InitUsingWin(aWindow))) { + if (NS_WARN_IF(!jsapi.Init(aWindow))) { return JSVAL_NULL; } JSContext* cx = jsapi.cx(); diff --git a/dom/icc/src/Icc.cpp b/dom/icc/src/Icc.cpp index d4b1eaca0a7..d99bc7948fd 100644 --- a/dom/icc/src/Icc.cpp +++ b/dom/icc/src/Icc.cpp @@ -49,7 +49,7 @@ nsresult Icc::NotifyStkEvent(const nsAString& aName, const nsAString& aMessage) { AutoJSAPI jsapi; - if (NS_WARN_IF(!jsapi.InitWithLegacyErrorReportingUsingWin(GetOwner()))) { + if (NS_WARN_IF(!jsapi.InitWithLegacyErrorReporting(GetOwner()))) { return NS_ERROR_UNEXPECTED; } JSContext* cx = jsapi.cx(); diff --git a/dom/workers/WorkerPrivate.cpp b/dom/workers/WorkerPrivate.cpp index 4b99bb69f76..5f12ef4032f 100644 --- a/dom/workers/WorkerPrivate.cpp +++ b/dom/workers/WorkerPrivate.cpp @@ -3138,7 +3138,7 @@ WorkerPrivateParent::BroadcastErrorToSharedWorkers( size_t actionsIndex = windowActions.LastIndexOf(WindowAction(window)); AutoJSAPI jsapi; - if (NS_WARN_IF(!jsapi.InitWithLegacyErrorReportingUsingWin(sharedWorker->GetOwner()))) { + if (NS_WARN_IF(!jsapi.InitWithLegacyErrorReporting(sharedWorker->GetOwner()))) { continue; } JSContext* cx = jsapi.cx();