Bug 1904442 - Rename GlobalTeardownObserver::GetOwner to GetOwnerWindow. r=smaug,media-playback-reviewers,dom-storage-reviewers,aosmond,padenot,asuth

Also HasOrHasHadOwner to HasOrHasHadOwnerWindow.

Differential Revision: https://phabricator.services.mozilla.com/D214772
This commit is contained in:
Emilio Cobos Álvarez 2024-07-01 11:49:59 +00:00
Родитель 3f954d7c88
Коммит 4ffa6418bb
84 изменённых файлов: 381 добавлений и 433 удалений

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

@ -11,6 +11,7 @@
#include "nsRefreshDriver.h"
#include "nsCSSProps.h"
#include "mozilla/dom/AnimationEffect.h"
#include "nsGlobalWindowInner.h"
using namespace mozilla;
@ -185,8 +186,8 @@ void AnimationEventInfo::MaybeAddMarker() const {
DOM,
MarkerOptions(
MarkerTiming::Interval(startTime, mScheduledEventTimeStamp),
mAnimation->GetOwner()
? MarkerInnerWindowId(mAnimation->GetOwner()->WindowID())
mAnimation->GetOwnerWindow()
? MarkerInnerWindowId(mAnimation->GetOwnerWindow()->WindowID())
: MarkerInnerWindowId::NoId()),
CSSAnimationMarker, name, NS_ConvertUTF16toUTF8(target), properties,
oncompositor);
@ -226,8 +227,8 @@ void AnimationEventInfo::MaybeAddMarker() const {
mScheduledEventTimeStamp -
TimeDuration::FromSeconds(data.mElapsedTime),
mScheduledEventTimeStamp),
mAnimation->GetOwner()
? MarkerInnerWindowId(mAnimation->GetOwner()->WindowID())
mAnimation->GetOwnerWindow()
? MarkerInnerWindowId(mAnimation->GetOwnerWindow()->WindowID())
: MarkerInnerWindowId::NoId()),
CSSTransitionMarker, NS_ConvertUTF16toUTF8(target), property,
onCompositor, message == eTransitionCancel);

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

@ -678,8 +678,8 @@ EventSourceImpl::Observe(nsISupports* aSubject, const char* aTopic,
MOZ_ASSERT(mIsMainThread);
{
auto lock = mSharedData.Lock();
if (!lock->mEventSource->GetOwner() ||
window != lock->mEventSource->GetOwner()) {
if (!lock->mEventSource->GetOwnerWindow() ||
window != lock->mEventSource->GetOwnerWindow()) {
return NS_OK;
}
}
@ -961,8 +961,8 @@ EventSourceImpl::GetInterface(const nsIID& aIID, void** aResult) {
rv = lock->mEventSource->CheckCurrentGlobalCorrectness();
NS_ENSURE_SUCCESS(rv, NS_ERROR_UNEXPECTED);
if (lock->mEventSource->GetOwner()) {
window = lock->mEventSource->GetOwner()->GetOuterWindow();
if (nsGlobalWindowInner* win = lock->mEventSource->GetOwnerWindow()) {
window = win->GetOuterWindow();
}
}

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

@ -5,7 +5,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "GlobalTeardownObserver.h"
#include "mozilla/Sprintf.h"
#include "nsGlobalWindowInner.h"
#include "mozilla/dom/Document.h"
namespace mozilla {
@ -29,41 +29,36 @@ void GlobalTeardownObserver::BindToOwner(nsIGlobalObject* aOwner) {
if (aOwner) {
mParentObject = aOwner;
aOwner->AddGlobalTeardownObserver(this);
// Let's cache the result of this QI for fast access and off main thread
// usage
mOwnerWindow =
nsCOMPtr<nsPIDOMWindowInner>(do_QueryInterface(aOwner)).get();
if (mOwnerWindow) {
mHasOrHasHadOwnerWindow = true;
}
const bool isWindow = !!aOwner->GetAsInnerWindow();
MOZ_ASSERT_IF(!isWindow, !mHasOrHasHadOwnerWindow);
mHasOrHasHadOwnerWindow = isWindow;
}
}
void GlobalTeardownObserver::DisconnectFromOwner() {
if (mParentObject) {
mParentObject->RemoveGlobalTeardownObserver(this);
}
mOwnerWindow = nullptr;
mParentObject = nullptr;
}
}
nsresult GlobalTeardownObserver::CheckCurrentGlobalCorrectness() const {
NS_ENSURE_STATE(!mHasOrHasHadOwnerWindow || mOwnerWindow);
// Main-thread.
if (mOwnerWindow && !mOwnerWindow->IsCurrentInnerWindow()) {
return NS_ERROR_FAILURE;
}
if (NS_IsMainThread()) {
if (!mParentObject) {
if (NS_IsMainThread() && !HasOrHasHadOwnerWindow()) {
return NS_OK;
}
if (!mParentObject) {
return NS_ERROR_FAILURE;
}
if (mParentObject->IsDying()) {
// Main-thread.
if (mHasOrHasHadOwnerWindow) {
auto* ownerWin = static_cast<nsGlobalWindowInner*>(mParentObject);
if (!ownerWin->IsCurrentInnerWindow()) {
return NS_ERROR_FAILURE;
}
}
if (mParentObject->IsDying() && !NS_IsMainThread()) {
return NS_ERROR_FAILURE;
}

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

@ -8,15 +8,12 @@
#define DOM_BASE_GLOBALTEARDOWNOBSERVER_H_
#include "mozilla/Attributes.h"
#include "mozilla/dom/EventTarget.h"
#include "mozilla/RefPtr.h"
#include "nsCycleCollectionParticipant.h"
#include "nsID.h"
#include "nsIGlobalObject.h"
#include "nsIScriptGlobalObject.h"
#include "nsISupports.h"
#include "nsISupportsUtils.h"
#include "nsPIDOMWindow.h"
#define NS_GLOBALTEARDOWNOBSERVER_IID \
{ \
@ -37,9 +34,9 @@ class GlobalTeardownObserver
explicit GlobalTeardownObserver(nsIGlobalObject* aGlobalObject,
bool aHasOrHasHadOwnerWindow = false);
nsPIDOMWindowInner* GetOwner() const { return mOwnerWindow; }
nsGlobalWindowInner* GetOwnerWindow() const { return mOwnerWindow; }
nsIGlobalObject* GetOwnerGlobal() const { return mParentObject; }
bool HasOrHasHadOwner() { return mHasOrHasHadOwnerWindow; }
bool HasOrHasHadOwnerWindow() const { return mHasOrHasHadOwnerWindow; }
void GetParentObject(nsIScriptGlobalObject** aParentObject) {
if (mParentObject) {
@ -75,7 +72,7 @@ class GlobalTeardownObserver
// mParentObject pre QI-ed and cached (inner window)
// (it is needed for off main thread access)
// It is obtained in BindToOwner and reset in DisconnectFromOwner.
nsPIDOMWindowInner* MOZ_NON_OWNING_REF mOwnerWindow = nullptr;
nsGlobalWindowInner* MOZ_NON_OWNING_REF mOwnerWindow = nullptr;
bool mHasOrHasHadOwnerWindow = false;
};

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

@ -168,7 +168,7 @@ ScreenOrientation::LockOrientationTask::Run() {
return NS_OK;
}
nsCOMPtr<nsPIDOMWindowInner> owner = mScreenOrientation->GetOwner();
nsCOMPtr<nsPIDOMWindowInner> owner = mScreenOrientation->GetOwnerWindow();
if (!owner || !owner->IsFullyActive()) {
mPromise->MaybeRejectWithAbortError("The document is not fully active.");
return NS_OK;
@ -441,7 +441,7 @@ already_AddRefed<Promise> ScreenOrientation::LockInternal(
// If document is not fully active, return a promise rejected with an
// "InvalidStateError" DOMException.
nsCOMPtr<nsPIDOMWindowInner> owner = GetOwner();
nsCOMPtr<nsPIDOMWindowInner> owner = GetOwnerWindow();
if (NS_WARN_IF(!owner)) {
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
return nullptr;
@ -560,12 +560,12 @@ already_AddRefed<Promise> ScreenOrientation::LockInternal(
RefPtr<GenericNonExclusivePromise> ScreenOrientation::LockDeviceOrientation(
hal::ScreenOrientation aOrientation, bool aIsFullscreen) {
if (!GetOwner()) {
if (!GetOwnerWindow()) {
return GenericNonExclusivePromise::CreateAndReject(NS_ERROR_DOM_ABORT_ERR,
__func__);
}
nsCOMPtr<EventTarget> target = GetOwner()->GetDoc();
nsCOMPtr<EventTarget> target = GetOwnerWindow()->GetDoc();
// We need to register a listener so we learn when we leave fullscreen
// and when we will have to unlock the screen.
// This needs to be done before LockScreenOrientation call to make sure
@ -608,13 +608,13 @@ void ScreenOrientation::UnlockDeviceOrientation() {
}
void ScreenOrientation::CleanupFullscreenListener() {
if (!mFullscreenListener || !GetOwner()) {
if (!mFullscreenListener || !GetOwnerWindow()) {
mFullscreenListener = nullptr;
return;
}
// Remove event listener in case of fullscreen lock.
if (nsCOMPtr<EventTarget> target = GetOwner()->GetDoc()) {
if (nsCOMPtr<EventTarget> target = GetOwnerWindow()->GetDoc()) {
target->RemoveSystemEventListener(u"fullscreenchange"_ns,
mFullscreenListener,
/* useCapture */ true);
@ -675,7 +675,7 @@ uint16_t ScreenOrientation::GetAngle(CallerType aCallerType,
ScreenOrientation::LockPermission
ScreenOrientation::GetLockOrientationPermission(bool aCheckSandbox) const {
nsCOMPtr<nsPIDOMWindowInner> owner = GetOwner();
nsCOMPtr<nsPIDOMWindowInner> owner = GetOwnerWindow();
if (!owner) {
return LOCK_DENIED;
}
@ -707,7 +707,7 @@ ScreenOrientation::GetLockOrientationPermission(bool aCheckSandbox) const {
}
Document* ScreenOrientation::GetResponsibleDocument() const {
nsCOMPtr<nsPIDOMWindowInner> owner = GetOwner();
nsCOMPtr<nsPIDOMWindowInner> owner = GetOwnerWindow();
if (!owner) {
return nullptr;
}

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

@ -11,6 +11,7 @@
#include "mozilla/ScrollContainerFrame.h"
#include "mozilla/ToString.h"
#include "nsIDocShell.h"
#include "nsGlobalWindowInner.h"
#include "nsPresContext.h"
#include "nsRefreshDriver.h"
#include "DocumentInlines.h"
@ -49,7 +50,7 @@ void VisualViewport::GetEventTargetParent(EventChainPreVisitor& aVisitor) {
// Only our special internal events are allowed to escape the
// Visual Viewport and be dispatched further up the DOM tree.
if (msg == eMozVisualScroll || msg == eMozVisualResize) {
if (nsPIDOMWindowInner* win = GetOwner()) {
if (nsPIDOMWindowInner* win = GetOwnerWindow()) {
if (Document* doc = win->GetExtantDoc()) {
parentTarget = doc;
}
@ -136,7 +137,7 @@ double VisualViewport::OffsetTop() const {
}
Document* VisualViewport::GetDocument() const {
nsCOMPtr<nsPIDOMWindowInner> window = GetOwner();
nsCOMPtr<nsPIDOMWindowInner> window = GetOwnerWindow();
if (!window) {
return nullptr;
}

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

@ -9925,11 +9925,9 @@ nsIDocShell* nsContentUtils::GetDocShellForEventTarget(EventTarget* aTarget) {
do_QueryInterface(node->OwnerDoc()->GetScriptHandlingObject(ignore));
} else if ((innerWindow = nsPIDOMWindowInner::FromEventTarget(aTarget))) {
// Nothing else to do
} else {
nsCOMPtr<DOMEventTargetHelper> helper = do_QueryInterface(aTarget);
if (helper) {
innerWindow = helper->GetOwner();
}
} else if (nsCOMPtr<DOMEventTargetHelper> helper =
do_QueryInterface(aTarget)) {
innerWindow = helper->GetOwnerWindow();
}
if (innerWindow) {

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

@ -284,7 +284,7 @@ nsresult nsDOMDataChannel::DoOnMessageAvailable(const nsACString& aData,
}
AutoJSAPI jsapi;
if (NS_WARN_IF(!jsapi.Init(GetOwner()))) {
if (NS_WARN_IF(!jsapi.Init(GetOwnerWindow()))) {
return NS_ERROR_FAILURE;
}
JSContext* cx = jsapi.cx();

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

@ -36,14 +36,13 @@ class nsDOMDataChannel final : public mozilla::DOMEventTargetHelper,
// EventTarget
using EventTarget::EventListenerAdded;
virtual void EventListenerAdded(nsAtom* aType) override;
void EventListenerAdded(nsAtom* aType) override;
using EventTarget::EventListenerRemoved;
virtual void EventListenerRemoved(nsAtom* aType) override;
void EventListenerRemoved(nsAtom* aType) override;
virtual JSObject* WrapObject(JSContext* aCx,
JS::Handle<JSObject*> aGivenProto) override;
nsPIDOMWindowInner* GetParentObject() const { return GetOwner(); }
JSObject* WrapObject(JSContext*, JS::Handle<JSObject*> aGivenProto) override;
nsIGlobalObject* GetParentObject() const { return GetOwnerGlobal(); }
// WebIDL
void GetLabel(nsAString& aLabel);

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

@ -98,6 +98,7 @@
#include "mozilla/dom/BindingUtils.h"
#include "mozilla/dom/BrowserChild.h"
#include "mozilla/dom/BrowsingContext.h"
#include "mozilla/dom/Credential.h"
#include "mozilla/dom/CSPEvalChecker.h"
#include "mozilla/dom/CallbackDebuggerNotification.h"
#include "mozilla/dom/ChromeMessageBroadcaster.h"

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

@ -31,7 +31,6 @@
#include "prclist.h"
#include "mozilla/dom/BindingDeclarations.h"
#include "mozilla/dom/ChromeMessageBroadcaster.h"
#include "mozilla/dom/Credential.h"
#include "mozilla/dom/DebuggerNotificationManager.h"
#include "mozilla/dom/GamepadHandle.h"
#include "mozilla/dom/Location.h"
@ -102,6 +101,7 @@ namespace dom {
class BarProp;
class BrowsingContext;
struct ChannelPixelLayout;
class Credential;
class ClientSource;
class Console;
class Crypto;

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

@ -49,7 +49,7 @@ int32_t nsScreen::PixelDepth() {
}
nsPIDOMWindowOuter* nsScreen::GetOuter() const {
if (nsPIDOMWindowInner* inner = GetOwner()) {
if (nsPIDOMWindowInner* inner = GetOwnerWindow()) {
return inner->GetOuterWindow();
}
return nullptr;
@ -67,7 +67,7 @@ CSSIntRect nsScreen::GetRect() {
// Here we manipulate the value of aRect to represent the screen size,
// if in RDM.
if (nsPIDOMWindowInner* owner = GetOwner()) {
if (nsPIDOMWindowInner* owner = GetOwnerWindow()) {
if (Document* doc = owner->GetExtantDoc()) {
Maybe<CSSIntSize> deviceSize =
nsGlobalWindowOuter::GetRDMDeviceSize(*doc);
@ -96,7 +96,7 @@ CSSIntRect nsScreen::GetAvailRect() {
// Here we manipulate the value of aRect to represent the screen size,
// if in RDM.
if (nsPIDOMWindowInner* owner = GetOwner()) {
if (nsPIDOMWindowInner* owner = GetOwnerWindow()) {
if (Document* doc = owner->GetExtantDoc()) {
Maybe<CSSIntSize> deviceSize =
nsGlobalWindowOuter::GetRDMDeviceSize(*doc);
@ -166,7 +166,7 @@ JSObject* nsScreen::WrapObject(JSContext* aCx,
}
CSSIntRect nsScreen::GetWindowInnerRect() {
nsCOMPtr<nsPIDOMWindowInner> win = GetOwner();
nsCOMPtr<nsPIDOMWindowInner> win = GetOwnerWindow();
if (!win) {
return {};
}
@ -180,7 +180,6 @@ CSSIntRect nsScreen::GetWindowInnerRect() {
}
bool nsScreen::ShouldResistFingerprinting(RFPTarget aTarget) const {
nsCOMPtr<nsPIDOMWindowInner> owner = GetOwner();
return owner &&
nsGlobalWindowInner::Cast(owner)->ShouldResistFingerprinting(aTarget);
nsGlobalWindowInner* owner = GetOwnerWindow();
return owner && owner->ShouldResistFingerprinting(aTarget);
}

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

@ -28,7 +28,7 @@ class nsScreen : public mozilla::DOMEventTargetHelper {
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsScreen,
mozilla::DOMEventTargetHelper)
nsPIDOMWindowInner* GetParentObject() const { return GetOwner(); }
nsIGlobalObject* GetParentObject() const { return GetOwnerGlobal(); }
nsPIDOMWindowOuter* GetOuter() const;

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

@ -13,6 +13,7 @@
#include "mozilla/dom/BatteryManagerBinding.h"
#include "mozilla/Preferences.h"
#include "nsContentUtils.h"
#include "nsGlobalWindowInner.h"
#include "mozilla/dom/Document.h"
/**
@ -113,7 +114,7 @@ void BatteryManager::UpdateFromBatteryInfo(
mLevel = aBatteryInfo.level();
// Round to the nearest ten percent for non-chrome.
Document* doc = GetOwner() ? GetOwner()->GetDoc() : nullptr;
Document* doc = GetOwnerWindow() ? GetOwnerWindow()->GetDoc() : nullptr;
mCharging = aBatteryInfo.charging();
mRemainingTime = aBatteryInfo.remainingTime();

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

@ -18,7 +18,7 @@ class BatteryInformation;
namespace dom::battery {
class BatteryManager : public DOMEventTargetHelper,
class BatteryManager final : public DOMEventTargetHelper,
public hal::BatteryObserver {
public:
explicit BatteryManager(nsPIDOMWindowInner* aWindow);
@ -33,10 +33,9 @@ class BatteryManager : public DOMEventTargetHelper,
* WebIDL Interface
*/
nsPIDOMWindowInner* GetParentObject() const { return GetOwner(); }
nsIGlobalObject* GetParentObject() const { return GetOwnerGlobal(); }
virtual JSObject* WrapObject(JSContext* aCx,
JS::Handle<JSObject*> aGivenProto) override;
JSObject* WrapObject(JSContext*, JS::Handle<JSObject*> aGivenProto) override;
bool Charging() const;

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

@ -353,7 +353,7 @@ void BroadcastChannel::RemoveDocFromBFCache() {
return;
}
if (nsPIDOMWindowInner* window = GetOwner()) {
if (nsPIDOMWindowInner* window = GetOwnerWindow()) {
window->RemoveFromBFCacheSync();
}
}

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

@ -330,22 +330,17 @@ already_AddRefed<Promise> Clipboard::ReadHelper(nsIPrincipal& aSubjectPrincipal,
ReadRequestType aType,
ErrorResult& aRv) {
// Create a new promise
RefPtr<Promise> p = dom::Promise::Create(GetOwnerGlobal(), aRv);
if (aRv.Failed() || !p) {
nsGlobalWindowInner* owner = GetOwnerWindow();
RefPtr<Promise> p = dom::Promise::Create(owner, aRv);
if (aRv.Failed()) {
return nullptr;
}
nsPIDOMWindowInner* owner = GetOwner();
if (!owner) {
p->MaybeRejectWithUndefined();
return p.forget();
}
// If a "paste" clipboard event is actively being processed, we're
// intentionally skipping permission/user-activation checks and giving the
// webpage access to the clipboard.
if (RefPtr<DataTransfer> dataTransfer =
nsGlobalWindowInner::Cast(owner)->GetCurrentPasteDataTransfer()) {
owner->GetCurrentPasteDataTransfer()) {
// If there is valid nsIClipboardDataSnapshot, use it directly.
if (nsCOMPtr<nsIClipboardDataSnapshot> clipboardDataSnapshot =
dataTransfer->GetClipboardDataSnapshot()) {
@ -685,13 +680,13 @@ already_AddRefed<Promise> Clipboard::Write(
const Sequence<OwningNonNull<ClipboardItem>>& aData,
nsIPrincipal& aSubjectPrincipal, ErrorResult& aRv) {
// Create a promise
RefPtr<Promise> p = dom::Promise::Create(GetOwnerGlobal(), aRv);
RefPtr<nsGlobalWindowInner> owner = GetOwnerWindow();
RefPtr<Promise> p = dom::Promise::Create(owner, aRv);
if (aRv.Failed()) {
return nullptr;
}
RefPtr<nsPIDOMWindowInner> owner = GetOwner();
Document* doc = owner ? owner->GetDoc() : nullptr;
Document* doc = owner->GetDoc();
if (!doc) {
p->MaybeRejectWithUndefined();
return p.forget();
@ -751,7 +746,7 @@ already_AddRefed<Promise> Clipboard::Write(
[owner, request, context, principal = RefPtr{&aSubjectPrincipal}](
const nsTArray<NativeEntry>& aEntries) {
RefPtr<DataTransfer> dataTransfer =
new DataTransfer(owner, eCopy,
new DataTransfer(ToSupports(owner), eCopy,
/* is external */ true,
/* clipboard type */ -1);
@ -800,7 +795,8 @@ already_AddRefed<Promise> Clipboard::WriteText(const nsAString& aData,
nsTArray<OwningNonNull<ClipboardItem>> sequence;
RefPtr<ClipboardItem> item = MakeRefPtr<ClipboardItem>(
GetOwner(), PresentationStyle::Unspecified, std::move(items));
ToSupports(GetOwnerWindow()), PresentationStyle::Unspecified,
std::move(items));
sequence.AppendElement(*item);
return Write(std::move(sequence), aSubjectPrincipal, aRv);

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

@ -12,6 +12,7 @@
#include "mozilla/EventDispatcher.h"
#include "mozilla/EventListenerManager.h"
#include "mozilla/Likely.h"
#include "nsGlobalWindowInner.h"
#include "MainThreadUtils.h"
namespace mozilla {
@ -24,8 +25,8 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INTERNAL(DOMEventTargetHelper)
if (MOZ_UNLIKELY(cb.WantDebugInfo())) {
char name[512];
nsAutoString uri;
if (tmp->GetOwner() && tmp->GetOwner()->GetExtantDoc()) {
Unused << tmp->GetOwner()->GetExtantDoc()->GetDocumentURI(uri);
if (tmp->GetOwnerWindow() && tmp->GetOwnerWindow()->GetExtantDoc()) {
Unused << tmp->GetOwnerWindow()->GetExtantDoc()->GetDocumentURI(uri);
}
nsXPCOMCycleCollectionParticipant* participant = nullptr;
@ -93,8 +94,9 @@ DOMEventTargetHelper::DOMEventTargetHelper(nsIGlobalObject* aGlobalObject)
: GlobalTeardownObserver(aGlobalObject) {}
DOMEventTargetHelper::DOMEventTargetHelper(DOMEventTargetHelper* aOther)
: GlobalTeardownObserver(aOther ? aOther->GetParentObject() : nullptr,
aOther ? aOther->HasOrHasHadOwner() : false) {}
: GlobalTeardownObserver(
aOther ? aOther->GetParentObject() : nullptr,
aOther ? aOther->HasOrHasHadOwnerWindow() : false) {}
DOMEventTargetHelper::~DOMEventTargetHelper() {
if (mListenerManager) {
@ -115,12 +117,15 @@ void DOMEventTargetHelper::DisconnectFromOwner() {
MaybeDontKeepAlive();
}
nsPIDOMWindowOuter* DOMEventTargetHelper::GetOwnerGlobalForBindingsInternal() {
return nsPIDOMWindowOuter::GetFromCurrentInner(GetOwnerWindow());
}
nsPIDOMWindowInner* DOMEventTargetHelper::GetWindowIfCurrent() const {
if (NS_FAILED(CheckCurrentGlobalCorrectness())) {
return nullptr;
}
return GetOwner();
return GetOwnerWindow();
}
Document* DOMEventTargetHelper::GetDocumentIfCurrent() const {

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

@ -10,7 +10,6 @@
#include "mozilla/Attributes.h"
#include "mozilla/dom/EventTarget.h"
#include "mozilla/GlobalTeardownObserver.h"
#include "mozilla/LinkedList.h"
#include "mozilla/RefPtr.h"
#include "nsAtom.h"
#include "nsCOMPtr.h"
@ -19,9 +18,7 @@
#include "nsGkAtoms.h"
#include "nsID.h"
#include "nsIGlobalObject.h"
#include "nsIScriptGlobalObject.h"
#include "nsISupports.h"
#include "nsISupportsUtils.h"
#include "nsPIDOMWindow.h"
#include "nsStringFwd.h"
#include "nsTArray.h"
@ -61,8 +58,8 @@ class DOMEventTargetHelper : public dom::EventTarget,
NS_DECL_CYCLE_COLLECTION_SKIPPABLE_WRAPPERCACHE_CLASS_AMBIGUOUS(
DOMEventTargetHelper, dom::EventTarget)
virtual EventListenerManager* GetExistingListenerManager() const override;
virtual EventListenerManager* GetOrCreateListenerManager() override;
EventListenerManager* GetExistingListenerManager() const override;
EventListenerManager* GetOrCreateListenerManager() override;
bool ComputeDefaultWantsUntrusted(ErrorResult& aRv) override;
@ -102,9 +99,7 @@ class DOMEventTargetHelper : public dom::EventTarget,
bool HasListenersFor(nsAtom* aTypeWithOn) const;
virtual nsPIDOMWindowOuter* GetOwnerGlobalForBindingsInternal() override {
return nsPIDOMWindowOuter::GetFromCurrentInner(GetOwner());
}
nsPIDOMWindowOuter* GetOwnerGlobalForBindingsInternal() override;
// Like GetOwner, but only returns non-null if the window being returned is
// current (in the "current document" sense of the HTML spec).
@ -116,9 +111,9 @@ class DOMEventTargetHelper : public dom::EventTarget,
void DisconnectFromOwner() override;
using EventTarget::GetParentObject;
virtual void EventListenerAdded(nsAtom* aType) override;
void EventListenerAdded(nsAtom* aType) override;
virtual void EventListenerRemoved(nsAtom* aType) override;
void EventListenerRemoved(nsAtom* aType) override;
// Dispatch a trusted, non-cancellable and non-bubbling event to |this|.
nsresult DispatchTrustedEvent(const nsAString& aEventName);

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

@ -670,7 +670,7 @@ void EventListenerManager::ProcessApzAwareEventListenerAdd() {
}
if (!doc) {
if (nsCOMPtr<DOMEventTargetHelper> helper = do_QueryInterface(mTarget)) {
if (nsPIDOMWindowInner* window = helper->GetOwner()) {
if (nsPIDOMWindowInner* window = helper->GetOwnerWindow()) {
doc = window->GetExtantDoc();
}
}

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

@ -103,6 +103,7 @@
#include "nsError.h"
#include "nsGenericHTMLElement.h"
#include "nsGkAtoms.h"
#include "nsGlobalWindowInner.h"
#include "nsIAsyncVerifyRedirectCallback.h"
#include "nsICachingChannel.h"
#include "nsIClassOfService.h"
@ -3670,11 +3671,11 @@ void HTMLMediaElement::AddOutputTrackSourceToOutputStream(
RefPtr<MediaStreamTrack> domTrack;
if (aSource->Track()->mType == MediaSegment::AUDIO) {
domTrack = new AudioStreamTrack(
aOutputStream.mStream->GetOwner(), aSource->Track(), aSource,
aOutputStream.mStream->GetOwnerWindow(), aSource->Track(), aSource,
MediaStreamTrackState::Live, aSource->Muted());
} else {
domTrack = new VideoStreamTrack(
aOutputStream.mStream->GetOwner(), aSource->Track(), aSource,
aOutputStream.mStream->GetOwnerWindow(), aSource->Track(), aSource,
MediaStreamTrackState::Live, aSource->Muted());
}

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

@ -1242,7 +1242,7 @@ mozilla::ipc::IPCResult BackgroundDatabaseChild::RecvVersionChange(
RefPtr<IDBDatabase> kungFuDeathGrip = mDatabase;
// Handle bfcache'd windows.
if (nsPIDOMWindowInner* owner = kungFuDeathGrip->GetOwner()) {
if (nsPIDOMWindowInner* owner = kungFuDeathGrip->GetOwnerWindow()) {
// The database must be closed if the window is already frozen.
bool shouldAbortAndClose = owner->IsFrozen();

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

@ -50,6 +50,7 @@
#include "ProfilerHelpers.h"
#include "ReportInternalError.h"
#include "ScriptErrorHelper.h"
#include "nsGlobalWindowInner.h"
#include "nsQueryObject.h"
// Include this last to avoid path problems on Windows.
@ -187,9 +188,8 @@ RefPtr<IDBDatabase> IDBDatabase::Create(IDBOpenDBRequest* aRequest,
RefPtr<IDBDatabase> db =
new IDBDatabase(aRequest, aFactory.clonePtr(), aActor, std::move(aSpec));
if (NS_IsMainThread()) {
nsCOMPtr<nsPIDOMWindowInner> window = aFactory->GetOwner();
if (window) {
if (nsCOMPtr<nsPIDOMWindowInner> window = aFactory->GetOwnerWindow()) {
MOZ_ASSERT(NS_IsMainThread());
uint64_t windowId = window->WindowID();
RefPtr<Observer> observer = new Observer(db, windowId);
@ -209,7 +209,6 @@ RefPtr<IDBDatabase> IDBDatabase::Create(IDBOpenDBRequest* aRequest,
db->mObserver = std::move(observer);
}
}
db->IncreaseActiveDatabaseCount();
@ -342,7 +341,7 @@ RefPtr<DOMStringList> IDBDatabase::ObjectStoreNames() const {
}
RefPtr<Document> IDBDatabase::GetOwnerDocument() const {
if (nsPIDOMWindowInner* window = GetOwner()) {
if (nsPIDOMWindowInner* window = GetOwnerWindow()) {
return window->GetExtantDoc();
}
return nullptr;

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

@ -403,8 +403,8 @@ void IDBFactory::UpdateActiveDatabaseCount(int32_t aDelta) {
(mActiveDatabaseCount + aDelta) < mActiveDatabaseCount);
mActiveDatabaseCount += aDelta;
if (GetOwner()) {
GetOwner()->UpdateActiveIndexedDBDatabaseCount(aDelta);
if (nsGlobalWindowInner* win = GetOwnerWindow()) {
win->UpdateActiveIndexedDBDatabaseCount(aDelta);
}
}

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

@ -10,11 +10,10 @@
#include "MediaTrackGraph.h"
#include "Tracing.h"
#include "VideoSegment.h"
#include "gfxPlatform.h"
#include "mozilla/Atomics.h"
#include "mozilla/dom/CanvasCaptureMediaStreamBinding.h"
#include "mozilla/gfx/2D.h"
#include "nsContentUtils.h"
#include "nsGlobalWindowInner.h"
using namespace mozilla::layers;
using namespace mozilla::gfx;
@ -172,7 +171,7 @@ void CanvasCaptureMediaStream::RequestFrame() {
nsresult CanvasCaptureMediaStream::Init(const dom::Optional<double>& aFPS,
nsIPrincipal* aPrincipal) {
MediaTrackGraph* graph = MediaTrackGraph::GetInstance(
MediaTrackGraph::SYSTEM_THREAD_DRIVER, GetOwner(),
MediaTrackGraph::SYSTEM_THREAD_DRIVER, GetOwnerWindow(),
MediaTrackGraph::REQUEST_DEFAULT_SAMPLE_RATE,
MediaTrackGraph::DEFAULT_OUTPUT_DEVICE);
SourceMediaTrack* source = graph->CreateSourceTrack(MediaSegment::VIDEO);

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

@ -366,7 +366,7 @@ void DOMMediaStream::RemoveTrack(MediaStreamTrack& aTrack) {
}
already_AddRefed<DOMMediaStream> DOMMediaStream::Clone() {
auto newStream = MakeRefPtr<DOMMediaStream>(GetOwner());
auto newStream = MakeRefPtr<DOMMediaStream>(GetOwnerWindow());
LOG(LogLevel::Info,
("DOMMediaStream %p created clone %p", this, newStream.get()));
@ -418,11 +418,11 @@ void DOMMediaStream::RemoveTrackInternal(MediaStreamTrack* aTrack) {
}
already_AddRefed<nsIPrincipal> DOMMediaStream::GetPrincipal() {
if (!GetOwner()) {
nsGlobalWindowInner* win = GetOwnerWindow();
if (!win) {
return nullptr;
}
nsCOMPtr<nsIPrincipal> principal =
nsGlobalWindowInner::Cast(GetOwner())->GetPrincipal();
nsCOMPtr<nsIPrincipal> principal = win->GetPrincipal();
for (const auto& t : mTracks) {
if (t->Ended()) {
continue;

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

@ -48,7 +48,8 @@ already_AddRefed<Promise> MediaDevices::GetUserMedia(
ErrorResult& aRv) {
MOZ_ASSERT(NS_IsMainThread());
// Get the relevant global for the promise from the wrapper cache because
// DOMEventTargetHelper::GetOwner() returns null if the document is unloaded.
// DOMEventTargetHelper::GetOwnerWindow() returns null if the document is
// unloaded.
// We know the wrapper exists because it is being used for |this| from JS.
// See https://github.com/heycam/webidl/issues/932 for why the relevant
// global is used instead of the current global.
@ -185,7 +186,7 @@ void MediaDevices::MaybeResumeDeviceExposure() {
!mHaveUnprocessedDeviceListChange) {
return;
}
nsPIDOMWindowInner* window = GetOwner();
nsPIDOMWindowInner* window = GetOwnerWindow();
if (!window || !window->IsFullyActive()) {
return;
}
@ -229,7 +230,7 @@ void MediaDevices::MaybeResumeDeviceExposure() {
RefPtr<MediaDeviceSetRefCnt> MediaDevices::FilterExposedDevices(
const MediaDeviceSet& aDevices) const {
nsPIDOMWindowInner* window = GetOwner();
nsPIDOMWindowInner* window = GetOwnerWindow();
RefPtr exposed = new MediaDeviceSetRefCnt();
if (!window) {
return exposed; // Promises will be left pending
@ -394,7 +395,7 @@ bool MediaDevices::ShouldQueueDeviceChange(
void MediaDevices::ResumeEnumerateDevices(
nsTArray<RefPtr<Promise>>&& aPromises,
RefPtr<const MediaDeviceSetRefCnt> aExposedDevices) const {
nsCOMPtr<nsPIDOMWindowInner> window = GetOwner();
nsCOMPtr<nsPIDOMWindowInner> window = GetOwnerWindow();
if (!window) {
return; // Leave Promise pending after navigation by design.
}
@ -421,7 +422,7 @@ void MediaDevices::ResumeEnumerateDevices(
void MediaDevices::ResolveEnumerateDevicesPromise(
Promise* aPromise, const LocalMediaDeviceSet& aDevices) const {
nsCOMPtr<nsPIDOMWindowInner> window = GetOwner();
nsCOMPtr<nsPIDOMWindowInner> window = GetOwnerWindow();
auto windowId = window->WindowID();
nsTArray<RefPtr<MediaDeviceInfo>> infos;
bool legacy = StaticPrefs::media_devices_enumerate_legacy_enabled();
@ -659,7 +660,7 @@ RefPtr<MediaDevices::SinkInfoPromise> MediaDevices::GetSinkDevice(
GetCurrentSerialEventTarget(), __func__,
[self = RefPtr(this), this,
aDeviceId](RefPtr<const MediaDeviceSetRefCnt> aRawDevices) {
nsCOMPtr<nsPIDOMWindowInner> window = GetOwner();
nsCOMPtr<nsPIDOMWindowInner> window = GetOwnerWindow();
if (!window) {
return LocalDeviceSetPromise::CreateAndReject(
new MediaMgrError(MediaMgrError::Name::AbortError), __func__);
@ -728,7 +729,7 @@ void MediaDevices::OnDeviceChange() {
if (nsContentUtils::ShouldResistFingerprinting(
"Guarding the more expensive RFP check with a simple one",
RFPTarget::MediaDevices)) {
nsCOMPtr<nsPIDOMWindowInner> window = GetOwner();
nsCOMPtr<nsPIDOMWindowInner> window = GetOwnerWindow();
auto* wrapper = GetWrapper();
if (!window && wrapper) {
nsCOMPtr<nsIGlobalObject> global = xpc::NativeGlobal(wrapper);
@ -757,7 +758,7 @@ void MediaDevices::SetupDeviceChangeListener() {
return;
}
nsPIDOMWindowInner* window = GetOwner();
nsPIDOMWindowInner* window = GetOwnerWindow();
if (!window) {
return;
}

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

@ -34,6 +34,7 @@
#include "nsIScriptError.h"
#include "nsMimeTypes.h"
#include "nsProxyRelease.h"
#include "nsGlobalWindowInner.h"
#include "nsServiceManagerUtils.h"
#include "nsTArray.h"
@ -166,10 +167,10 @@ NS_IMPL_RELEASE_INHERITED(MediaRecorder, DOMEventTargetHelper)
namespace {
bool PrincipalSubsumes(MediaRecorder* aRecorder, nsIPrincipal* aPrincipal) {
if (!aRecorder->GetOwner()) {
if (!aRecorder->GetOwnerWindow()) {
return false;
}
nsCOMPtr<Document> doc = aRecorder->GetOwner()->GetExtantDoc();
nsCOMPtr<Document> doc = aRecorder->GetOwnerWindow()->GetExtantDoc();
if (!doc) {
return false;
}
@ -197,8 +198,9 @@ bool MediaStreamTracksPrincipalSubsumes(
bool AudioNodePrincipalSubsumes(MediaRecorder* aRecorder,
AudioNode* aAudioNode) {
MOZ_ASSERT(aAudioNode);
Document* doc =
aAudioNode->GetOwner() ? aAudioNode->GetOwner()->GetExtantDoc() : nullptr;
Document* doc = aAudioNode->GetOwnerWindow()
? aAudioNode->GetOwnerWindow()->GetExtantDoc()
: nullptr;
nsCOMPtr<nsIPrincipal> principal = doc ? doc->NodePrincipal() : nullptr;
return PrincipalSubsumes(aRecorder, principal);
}
@ -1192,7 +1194,7 @@ MediaRecorder::MediaRecorder(nsPIDOMWindowInner* aOwnerWindow)
}
void MediaRecorder::RegisterActivityObserver() {
if (nsPIDOMWindowInner* window = GetOwner()) {
if (nsPIDOMWindowInner* window = GetOwnerWindow()) {
mDocument = window->GetExtantDoc();
if (mDocument) {
mDocument->RegisterActivityObserver(
@ -1823,7 +1825,7 @@ void MediaRecorder::RemoveSession(Session* aSession) {
}
void MediaRecorder::NotifyOwnerDocumentActivityChanged() {
nsPIDOMWindowInner* window = GetOwner();
nsPIDOMWindowInner* window = GetOwnerWindow();
NS_ENSURE_TRUE_VOID(window);
Document* doc = window->GetExtantDoc();
NS_ENSURE_TRUE_VOID(doc);

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

@ -151,7 +151,7 @@ static bool IsMediaElementInaudible(const HTMLMediaElement& aElement) {
static bool IsAudioContextAllowedToPlay(const AudioContext& aContext) {
// Offline context won't directly output sound to audio devices.
return aContext.IsOffline() ||
IsWindowAllowedToPlayOverall(aContext.GetParentObject());
IsWindowAllowedToPlayOverall(aContext.GetOwnerWindow());
}
static bool IsEnableBlockingWebAudioByUserGesturePolicy() {
@ -297,7 +297,7 @@ bool AutoplayPolicy::IsAllowedToPlay(const AudioContext& aContext) {
return true;
}
nsPIDOMWindowInner* window = aContext.GetParentObject();
nsPIDOMWindowInner* window = aContext.GetOwnerWindow();
uint32_t sitePermission = SiteAutoplayPerm(window);
if (sitePermission == nsIPermissionManager::ALLOW_ACTION) {

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

@ -16,6 +16,7 @@
#include "mozilla/dom/Document.h"
#include "CaptureTask.h"
#include "MediaEngineSource.h"
#include "nsGlobalWindowInner.h"
namespace mozilla {
@ -189,23 +190,12 @@ nsresult ImageCapture::PostErrorEvent(uint16_t aErrorCode, nsresult aReason) {
bool ImageCapture::CheckPrincipal() {
MOZ_ASSERT(NS_IsMainThread());
nsCOMPtr<nsIPrincipal> principal = mTrack->GetPrincipal();
if (!GetOwner()) {
if (!GetOwnerWindow()) {
return false;
}
nsCOMPtr<Document> doc = GetOwner()->GetExtantDoc();
if (!doc || !principal) {
return false;
}
bool subsumes;
if (NS_FAILED(doc->NodePrincipal()->Subsumes(principal, &subsumes))) {
return false;
}
return subsumes;
nsCOMPtr<Document> doc = GetOwnerWindow()->GetExtantDoc();
return doc && principal && doc->NodePrincipal()->Subsumes(principal);
}
} // namespace dom

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

@ -60,7 +60,7 @@ class ImageCapture final : public DOMEventTargetHelper {
}
// ImageCapture class members
nsPIDOMWindowInner* GetParentObject() { return GetOwner(); }
nsIGlobalObject* GetParentObject() const { return GetOwnerGlobal(); }
static already_AddRefed<ImageCapture> Constructor(const GlobalObject& aGlobal,
MediaStreamTrack& aTrack,

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

@ -14,13 +14,11 @@
#include "MediaContainerType.h"
#include "MediaResult.h"
#include "MediaSourceDemuxer.h"
#include "MediaSourceUtils.h"
#include "SourceBuffer.h"
#include "SourceBufferList.h"
#include "mozilla/ErrorResult.h"
#include "mozilla/FloatingPoint.h"
#include "mozilla/Logging.h"
#include "mozilla/Sprintf.h"
#include "mozilla/StaticPrefs_media.h"
#include "mozilla/dom/BindingDeclarations.h"
#include "mozilla/dom/HTMLMediaElement.h"
@ -32,7 +30,7 @@
#include "nsIScriptObjectPrincipal.h"
#include "nsMimeTypes.h"
#include "nsPIDOMWindow.h"
#include "nsServiceManagerUtils.h"
#include "nsGlobalWindowInner.h"
#include "nsString.h"
#include "nsThreadUtils.h"
@ -282,11 +280,11 @@ already_AddRefed<SourceBuffer> MediaSource::AddSourceBuffer(
MOZ_ASSERT(NS_IsMainThread());
DecoderDoctorDiagnostics diagnostics;
IsTypeSupported(aType, &diagnostics, aRv);
RecordTypeForTelemetry(aType, GetOwner());
RecordTypeForTelemetry(aType, GetOwnerWindow());
bool supported = !aRv.Failed();
diagnostics.StoreFormatDiagnostics(
GetOwner() ? GetOwner()->GetExtantDoc() : nullptr, aType, supported,
__func__);
GetOwnerWindow() ? GetOwnerWindow()->GetExtantDoc() : nullptr, aType,
supported, __func__);
MSE_API("AddSourceBuffer(aType=%s)%s", NS_ConvertUTF16toUTF8(aType).get(),
supported ? "" : " [not supported]");
if (!supported) {
@ -653,12 +651,12 @@ void MediaSource::DurationChange(double aNewDuration, ErrorResult& aRv) {
already_AddRefed<Promise> MediaSource::MozDebugReaderData(ErrorResult& aRv) {
// Creating a JS promise
nsPIDOMWindowInner* win = GetOwner();
nsGlobalWindowInner* win = GetOwnerWindow();
if (!win) {
aRv.Throw(NS_ERROR_UNEXPECTED);
return nullptr;
}
RefPtr<Promise> domPromise = Promise::Create(win->AsGlobal(), aRv);
RefPtr<Promise> domPromise = Promise::Create(win, aRv);
if (NS_WARN_IF(aRv.Failed())) {
return nullptr;
}
@ -677,7 +675,9 @@ already_AddRefed<Promise> MediaSource::MozDebugReaderData(ErrorResult& aRv) {
return domPromise.forget();
}
nsPIDOMWindowInner* MediaSource::GetParentObject() const { return GetOwner(); }
nsPIDOMWindowInner* MediaSource::GetParentObject() const {
return GetOwnerWindow();
}
JSObject* MediaSource::WrapObject(JSContext* aCx,
JS::Handle<JSObject*> aGivenProto) {

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

@ -12,12 +12,12 @@
#include "MediaSourceUtils.h"
#include "mozilla/ErrorResult.h"
#include "mozilla/FloatingPoint.h"
#include "mozilla/Preferences.h"
#include "mozilla/dom/MediaSourceBinding.h"
#include "mozilla/dom/TimeRanges.h"
#include "mozilla/dom/TypedArray.h"
#include "nsError.h"
#include "nsIRunnable.h"
#include "nsGlobalWindowInner.h"
#include "nsThreadUtils.h"
#include "mozilla/Logging.h"
#include <time.h>
@ -389,7 +389,8 @@ void SourceBuffer::ChangeType(const nsAString& aType, ErrorResult& aRv) {
MediaSource::IsTypeSupported(aType, &diagnostics, aRv);
bool supported = !aRv.Failed();
diagnostics.StoreFormatDiagnostics(
mMediaSource->GetOwner() ? mMediaSource->GetOwner()->GetExtantDoc()
mMediaSource->GetOwnerWindow()
? mMediaSource->GetOwnerWindow()->GetExtantDoc()
: nullptr,
aType, supported, __func__);
MSE_API("ChangeType(aType=%s)%s", NS_ConvertUTF16toUTF8(aType).get(),

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

@ -233,8 +233,7 @@ void AudioContext::StartBlockedAudioContextIfAllowed() {
void AudioContext::DisconnectFromWindow() {
MaybeClearPageAwakeRequest();
nsPIDOMWindowInner* window = GetOwner();
if (window) {
if (nsGlobalWindowInner* window = GetOwnerWindow()) {
window->RemoveAudioContext(this);
}
}
@ -249,9 +248,8 @@ JSObject* AudioContext::WrapObject(JSContext* aCx,
JS::Handle<JSObject*> aGivenProto) {
if (mIsOffline) {
return OfflineAudioContext_Binding::Wrap(aCx, this, aGivenProto);
} else {
return AudioContext_Binding::Wrap(aCx, this, aGivenProto);
}
return AudioContext_Binding::Wrap(aCx, this, aGivenProto);
}
static bool CheckFullyActive(nsPIDOMWindowInner* aWindow, ErrorResult& aRv) {
@ -374,7 +372,7 @@ already_AddRefed<AudioBuffer> AudioContext::CreateBuffer(
return nullptr;
}
return AudioBuffer::Create(GetOwner(), aNumberOfChannels, aLength,
return AudioBuffer::Create(GetOwnerWindow(), aNumberOfChannels, aLength,
aSampleRate, aRv);
}
@ -591,8 +589,8 @@ void AudioContext::GetOutputTimestamp(AudioTimestamp& aTimeStamp) {
// output latency. The resolution of CurrentTime() is already reduced.
aTimeStamp.mContextTime.Construct(
std::max(0.0, CurrentTime() - OutputLatency()));
nsPIDOMWindowInner* parent = GetParentObject();
Performance* perf = parent ? parent->GetPerformance() : nullptr;
nsGlobalWindowInner* win = GetOwnerWindow();
Performance* perf = win ? win->GetPerformance() : nullptr;
if (perf) {
// perf->Now() already has reduced resolution here, no need to do it again.
aTimeStamp.mPerformanceTime.Construct(
@ -615,7 +613,8 @@ bool AudioContext::IsRunning() const {
already_AddRefed<Promise> AudioContext::CreatePromise(ErrorResult& aRv) {
// Get the relevant global for the promise from the wrapper cache because
// DOMEventTargetHelper::GetOwner() returns null if the document is unloaded.
// DOMEventTargetHelper::GetOwnerWindow() returns null if the document is
// unloaded.
// We know the wrapper exists because it is being used for |this| from JS.
// See https://github.com/heycam/webidl/issues/932 for why the relevant
// global is used instead of the current global.
@ -765,8 +764,8 @@ double AudioContext::CurrentTime() {
}
nsISerialEventTarget* AudioContext::GetMainThread() const {
if (nsPIDOMWindowInner* window = GetParentObject()) {
return window->AsGlobal()->SerialEventTarget();
if (nsIGlobalObject* global = GetOwnerGlobal()) {
return global->SerialEventTarget();
}
return GetCurrentSerialEventTarget();
}
@ -830,12 +829,12 @@ class OnStateChangeTask final : public Runnable {
NS_IMETHODIMP
Run() override {
nsPIDOMWindowInner* parent = mAudioContext->GetParentObject();
if (!parent) {
nsGlobalWindowInner* win = mAudioContext->GetOwnerWindow();
if (!win) {
return NS_ERROR_FAILURE;
}
Document* doc = parent->GetExtantDoc();
Document* doc = win->GetExtantDoc();
if (!doc) {
return NS_ERROR_FAILURE;
}
@ -903,7 +902,7 @@ void AudioContext::OnStateChanged(void* aPromise, AudioContextState aNewState) {
}
BrowsingContext* AudioContext::GetTopLevelBrowsingContext() {
nsCOMPtr<nsPIDOMWindowInner> window = GetParentObject();
nsGlobalWindowInner* window = GetOwnerWindow();
if (!window) {
return nullptr;
}
@ -1173,15 +1172,14 @@ void AudioContext::ReportBlocked() {
return;
}
RefPtr<AudioContext> self = this;
RefPtr<nsIRunnable> r =
NS_NewRunnableFunction("AudioContext::AutoplayBlocked", [self]() {
nsPIDOMWindowInner* parent = self->GetParentObject();
if (!parent) {
RefPtr<nsIRunnable> r = NS_NewRunnableFunction(
"AudioContext::AutoplayBlocked", [self = RefPtr{this}]() {
nsGlobalWindowInner* win = self->GetOwnerWindow();
if (!win) {
return;
}
Document* doc = parent->GetExtantDoc();
Document* doc = win->GetExtantDoc();
if (!doc) {
return;
}
@ -1365,8 +1363,7 @@ BasicWaveFormCache* AudioContext::GetBasicWaveFormCache() {
void AudioContext::ReportToConsole(uint32_t aErrorFlags,
const char* aMsg) const {
MOZ_ASSERT(aMsg);
Document* doc =
GetParentObject() ? GetParentObject()->GetExtantDoc() : nullptr;
Document* doc = GetOwnerWindow() ? GetOwnerWindow()->GetExtantDoc() : nullptr;
nsContentUtils::ReportToConsole(aErrorFlags, "Media"_ns, doc,
nsContentUtils::eDOM_PROPERTIES, aMsg);
}

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

@ -147,11 +147,11 @@ class AudioContext final : public DOMEventTargetHelper,
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(AudioContext, DOMEventTargetHelper)
MOZ_DEFINE_MALLOC_SIZE_OF(MallocSizeOf)
nsPIDOMWindowInner* GetParentObject() const { return GetOwner(); }
nsIGlobalObject* GetParentObject() const { return GetOwnerGlobal(); }
nsISerialEventTarget* GetMainThread() const;
virtual void DisconnectFromOwner() override;
void DisconnectFromOwner() override;
void OnWindowDestroy(); // idempotent

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

@ -8,7 +8,6 @@
#include "AlignmentUtils.h"
#include "AudibilityMonitor.h"
#include "AudioChannelService.h"
#include "AudioContext.h"
#include "AudioNodeEngine.h"
#include "AudioNodeTrack.h"
@ -25,9 +24,7 @@
#include "mozilla/Telemetry.h"
#include "mozilla/TelemetryHistogramEnums.h"
#include "nsContentUtils.h"
#include "nsIInterfaceRequestorUtils.h"
#include "nsIScriptObjectPrincipal.h"
#include "nsServiceManagerUtils.h"
#include "nsGlobalWindowInner.h"
#include "Tracing.h"
extern mozilla::LazyLogModule gAudioChannelLog;
@ -152,8 +149,8 @@ class OfflineDestinationNodeEngine final : public AudioNodeEngine {
// Create the input buffer
ErrorResult rv;
RefPtr<AudioBuffer> renderedBuffer =
AudioBuffer::Create(aContext->GetOwner(), mNumberOfChannels, mLength,
mSampleRate, mBuffer.forget(), rv);
AudioBuffer::Create(aContext->GetOwnerWindow(), mNumberOfChannels,
mLength, mSampleRate, mBuffer.forget(), rv);
if (rv.Failed()) {
rv.SuppressException();
return nullptr;
@ -308,7 +305,7 @@ AudioDestinationNode::AudioDestinationNode(AudioContext* aContext,
// GetParentObject can return nullptr here. This will end up creating another
// MediaTrackGraph
MediaTrackGraph* graph = MediaTrackGraph::GetInstance(
MediaTrackGraph::AUDIO_THREAD_DRIVER, aContext->GetParentObject(),
MediaTrackGraph::AUDIO_THREAD_DRIVER, aContext->GetOwnerWindow(),
aContext->SampleRate(), MediaTrackGraph::DEFAULT_OUTPUT_DEVICE);
AudioNodeEngine* engine = new DestinationNodeEngine(this);
@ -339,7 +336,7 @@ void AudioDestinationNode::CreateAndStartAudioChannelAgent() {
MOZ_ASSERT(!mAudioChannelAgent);
AudioChannelAgent* agent = new AudioChannelAgent();
nsresult rv = agent->InitWithWeakCallback(GetOwner(), this);
nsresult rv = agent->InitWithWeakCallback(GetOwnerWindow(), this);
if (NS_WARN_IF(NS_FAILED(rv))) {
AUDIO_CHANNEL_LOG("Failed to init audio channel agent");
return;
@ -567,8 +564,7 @@ AudioDestinationNode::WindowAudioCaptureChanged(bool aCapture) {
return NS_OK;
}
nsCOMPtr<nsPIDOMWindowInner> ownerWindow = GetOwner();
if (!ownerWindow) {
if (!GetOwnerWindow()) {
return NS_OK;
}
@ -591,7 +587,7 @@ bool AudioDestinationNode::IsCapturingAudio() const {
void AudioDestinationNode::StartAudioCapturingTrack() {
MOZ_ASSERT(!IsCapturingAudio());
nsCOMPtr<nsPIDOMWindowInner> window = Context()->GetParentObject();
nsGlobalWindowInner* window = Context()->GetOwnerWindow();
uint64_t id = window->WindowID();
mCaptureTrackPort = mTrack->Graph()->ConnectToCaptureTrack(id, mTrack);
}
@ -609,7 +605,8 @@ void AudioDestinationNode::CreateAudioWakeLockIfNeeded() {
NS_ENSURE_TRUE_VOID(pmService);
ErrorResult rv;
mWakeLock = pmService->NewWakeLock(u"audio-playing"_ns, GetOwner(), rv);
mWakeLock =
pmService->NewWakeLock(u"audio-playing"_ns, GetOwnerWindow(), rv);
}
}

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

@ -8,6 +8,7 @@
#include "mozilla/dom/AudioProcessingEventBinding.h"
#include "mozilla/dom/ScriptSettings.h"
#include "AudioContext.h"
#include "nsGlobalWindowInner.h"
namespace mozilla::dom {
@ -35,8 +36,8 @@ JSObject* AudioProcessingEvent::WrapObjectInternal(
already_AddRefed<AudioBuffer> AudioProcessingEvent::LazilyCreateBuffer(
uint32_t aNumberOfChannels, ErrorResult& aRv) {
RefPtr<AudioBuffer> buffer = AudioBuffer::Create(
mNode->Context()->GetOwner(), aNumberOfChannels, mNode->BufferSize(),
mNode->Context()->SampleRate(), aRv);
mNode->Context()->GetOwnerWindow(), aNumberOfChannels,
mNode->BufferSize(), mNode->Context()->SampleRate(), aRv);
MOZ_ASSERT(buffer || aRv.ErrorCodeIs(NS_ERROR_OUT_OF_MEMORY));
return buffer.forget();
}

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

@ -21,13 +21,12 @@ namespace mozilla {
dom::AudioContext* aContext, ErrorResult& aRv) {
MOZ_ASSERT(NS_IsMainThread());
nsCOMPtr<nsPIDOMWindowInner> window = aContext->GetOwner();
nsGlobalWindowInner* window = aContext->GetOwnerWindow();
if (NS_WARN_IF(!window)) {
aRv.Throw(NS_ERROR_FAILURE);
return nullptr;
}
nsCOMPtr<nsIPrincipal> principal =
nsGlobalWindowInner::Cast(window)->GetPrincipal();
nsIPrincipal* principal = window->GetPrincipal();
if (NS_WARN_IF(!principal)) {
aRv.Throw(NS_ERROR_FAILURE);
return nullptr;

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

@ -17,6 +17,7 @@
#include "mozilla/ErrorResult.h"
#include "AudioParamTimeline.h"
#include "Tracing.h"
#include "nsGlobalWindowInner.h"
namespace mozilla::dom {
@ -235,8 +236,8 @@ BiquadFilterNode::BiquadFilterNode(AudioContext* aContext)
mGain = CreateAudioParam(BiquadFilterNodeEngine::GAIN, u"gain"_ns, 0.f);
uint64_t windowID = 0;
if (aContext->GetParentObject()) {
windowID = aContext->GetParentObject()->WindowID();
if (nsGlobalWindowInner* win = aContext->GetOwnerWindow()) {
windowID = win->WindowID();
}
BiquadFilterNodeEngine* engine =
new BiquadFilterNodeEngine(this, aContext->Destination(), windowID);

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

@ -11,8 +11,8 @@
#include "PlayingRefChangeHandler.h"
#include "AlignmentUtils.h"
#include "nsPrintfCString.h"
#include "nsGlobalWindowInner.h"
#include "nsGkAtoms.h"
#include "Tracing.h"
namespace mozilla::dom {
@ -151,8 +151,8 @@ IIRFilterNode::IIRFilterNode(AudioContext* aContext,
elements[0] = 1.0;
uint64_t windowID = 0;
if (aContext->GetParentObject()) {
windowID = aContext->GetParentObject()->WindowID();
if (nsGlobalWindowInner* win = aContext->GetOwnerWindow()) {
windowID = win->WindowID();
}
IIRFilterNodeEngine* engine = new IIRFilterNodeEngine(
this, aContext->Destination(), mFeedforward, mFeedback, windowID);

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

@ -24,19 +24,13 @@
#include "mozilla/AbstractThread.h"
#include "mozilla/Logging.h"
#include "mozilla/StaticPrefs_media.h"
#include "mozilla/Telemetry.h"
#include "mozilla/dom/AudioContextBinding.h"
#include "mozilla/dom/BaseAudioContextBinding.h"
#include "mozilla/dom/DOMException.h"
#include "mozilla/dom/Promise.h"
#include "mozilla/dom/ScriptSettings.h"
#include "nsComponentManagerUtils.h"
#include "nsContentUtils.h"
#include "nsIScriptError.h"
#include "nsIScriptObjectPrincipal.h"
#include "nsGlobalWindowInner.h"
#include "nsMimeTypes.h"
#include "nsPrintfCString.h"
#include "nsXPCOMCIDInternal.h"
namespace mozilla {
@ -626,8 +620,8 @@ bool WebAudioDecodeJob::AllocateBuffer() {
MOZ_ASSERT(NS_IsMainThread());
// Now create the AudioBuffer
mOutput = AudioBuffer::Create(mContext->GetOwner(), mContext->SampleRate(),
std::move(mBuffer));
mOutput = AudioBuffer::Create(mContext->GetOwnerWindow(),
mContext->SampleRate(), std::move(mBuffer));
return mOutput != nullptr;
}

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

@ -12,6 +12,7 @@
#include "AudioStreamTrack.h"
#include "DOMMediaStream.h"
#include "ForwardedInputTrack.h"
#include "nsGlobalWindowInner.h"
namespace mozilla::dom {
@ -83,15 +84,15 @@ MediaStreamAudioDestinationNode::MediaStreamAudioDestinationNode(
AudioContext* aContext)
: AudioNode(aContext, 2, ChannelCountMode::Explicit,
ChannelInterpretation::Speakers),
mDOMStream(MakeAndAddRef<DOMMediaStream>(GetOwner())) {
mDOMStream(MakeAndAddRef<DOMMediaStream>(GetOwnerWindow())) {
// Ensure an audio track with the correct ID is exposed to JS. If we can't get
// a principal here because the document is not available, pass in a null
// principal. This happens in edge cases when the document is being unloaded
// and it does not matter too much to have something working as long as it's
// not dangerous.
nsCOMPtr<nsIPrincipal> principal = nullptr;
if (aContext->GetParentObject()) {
Document* doc = aContext->GetParentObject()->GetExtantDoc();
if (nsGlobalWindowInner* win = aContext->GetOwnerWindow()) {
Document* doc = win->GetExtantDoc();
principal = doc->NodePrincipal();
}
mTrack = AudioNodeTrack::Create(aContext, new AudioNodeEngine(this),
@ -101,7 +102,8 @@ MediaStreamAudioDestinationNode::MediaStreamAudioDestinationNode(
this, mTrack,
aContext->Graph()->CreateForwardedInputTrack(MediaSegment::AUDIO),
principal);
auto track = MakeRefPtr<AudioStreamTrack>(GetOwner(), source->mTrack, source);
auto track =
MakeRefPtr<AudioStreamTrack>(GetOwnerWindow(), source->mTrack, source);
mDOMStream->AddTrackInternal(track);
}

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

@ -13,6 +13,7 @@
#include "nsContentUtils.h"
#include "nsIScriptError.h"
#include "nsID.h"
#include "nsGlobalWindowInner.h"
#include "Tracing.h"
namespace mozilla::dom {
@ -102,7 +103,7 @@ void MediaStreamAudioSourceNode::AttachToTrack(
}
if (NS_WARN_IF(Context()->Graph() != aTrack->Graph())) {
nsCOMPtr<nsPIDOMWindowInner> pWindow = Context()->GetParentObject();
nsGlobalWindowInner* pWindow = Context()->GetOwnerWindow();
Document* document = pWindow ? pWindow->GetExtantDoc() : nullptr;
nsContentUtils::ReportToConsole(nsIScriptError::warningFlag, "Web Audio"_ns,
document, nsContentUtils::eDOM_PROPERTIES,
@ -228,7 +229,7 @@ void MediaStreamAudioSourceNode::PrincipalChanged(
bool subsumes = false;
Document* doc = nullptr;
if (nsPIDOMWindowInner* parent = Context()->GetParentObject()) {
if (nsGlobalWindowInner* parent = Context()->GetOwnerWindow()) {
doc = parent->GetExtantDoc();
if (doc) {
nsIPrincipal* docPrincipal = doc->NodePrincipal();

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

@ -12,6 +12,7 @@
#include "mozilla/dom/Document.h"
#include "nsContentUtils.h"
#include "nsIScriptError.h"
#include "nsGlobalWindowInner.h"
namespace mozilla::dom {
@ -50,7 +51,7 @@ MediaStreamTrackAudioSourceNode::Create(
if (!aOptions.mMediaStreamTrack->Ended() &&
aAudioContext.Graph() != aOptions.mMediaStreamTrack->Graph()) {
nsCOMPtr<nsPIDOMWindowInner> pWindow = aAudioContext.GetParentObject();
nsGlobalWindowInner* pWindow = aAudioContext.GetOwnerWindow();
Document* document = pWindow ? pWindow->GetExtantDoc() : nullptr;
nsContentUtils::ReportToConsole(nsIScriptError::warningFlag, "Web Audio"_ns,
document, nsContentUtils::eDOM_PROPERTIES,
@ -146,8 +147,8 @@ void MediaStreamTrackAudioSourceNode::PrincipalChanged(
bool subsumes = false;
Document* doc = nullptr;
if (nsPIDOMWindowInner* parent = Context()->GetParentObject()) {
doc = parent->GetExtantDoc();
if (nsGlobalWindowInner* win = Context()->GetOwnerWindow()) {
doc = win->GetExtantDoc();
if (doc) {
nsIPrincipal* docPrincipal = doc->NodePrincipal();
nsIPrincipal* trackPrincipal = aMediaStreamTrack->GetPrincipal();

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

@ -11,10 +11,10 @@
#include "AudioNodeEngine.h"
#include "AudioNodeTrack.h"
#include "AudioProcessingEvent.h"
#include "WebAudioUtils.h"
#include "mozilla/dom/ScriptSettings.h"
#include "mozilla/Mutex.h"
#include "mozilla/PodOperations.h"
#include "nsGlobalWindowInner.h"
#include <deque>
#include "Tracing.h"
@ -400,7 +400,7 @@ class ScriptProcessorNodeEngine final : public AudioNodeEngine {
}
AutoJSAPI jsapi;
if (NS_WARN_IF(!jsapi.Init(aNode->GetOwner()))) {
if (NS_WARN_IF(!jsapi.Init(aNode->GetOwnerWindow()))) {
return;
}
JSContext* cx = jsapi.cx();
@ -411,7 +411,7 @@ class ScriptProcessorNodeEngine final : public AudioNodeEngine {
if (mInputBuffer) {
ErrorResult rv;
inputBuffer = AudioBuffer::Create(
context->GetOwner(), inputChannelCount, aNode->BufferSize(),
context->GetOwnerWindow(), inputChannelCount, aNode->BufferSize(),
context->SampleRate(), mInputBuffer.forget(), rv);
if (rv.Failed()) {
rv.SuppressException();

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

@ -5,22 +5,15 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsThreadUtils.h"
#include "nsXPCOMCIDInternal.h"
#include "OnlineSpeechRecognitionService.h"
#include "nsIFile.h"
#include "SpeechGrammar.h"
#include "SpeechRecognition.h"
#include "SpeechRecognitionAlternative.h"
#include "SpeechRecognitionResult.h"
#include "SpeechRecognitionResultList.h"
#include "nsIObserverService.h"
#include "mozilla/dom/Document.h"
#include "mozilla/Preferences.h"
#include "mozilla/ScopeExit.h"
#include "mozilla/StaticPrefs_media.h"
#include "mozilla/Services.h"
#include "nsDirectoryServiceDefs.h"
#include "nsDirectoryServiceUtils.h"
#include "nsNetUtil.h"
#include "nsContentUtils.h"
#include "nsIChannel.h"
@ -28,10 +21,9 @@
#include "nsIPrincipal.h"
#include "nsIStreamListener.h"
#include "nsIUploadChannel2.h"
#include "mozilla/dom/ClientIPCTypes.h"
#include "nsStringStream.h"
#include "nsIOutputStream.h"
#include "nsStreamUtils.h"
#include "nsGlobalWindowInner.h"
#include "OpusTrackEncoder.h"
#include "OggWriter.h"
#include "nsIClassOfService.h"
@ -316,7 +308,7 @@ void OnlineSpeechRecognitionService::DoSTT() {
nsIRequest::LOAD_NORMAL | nsIChannel::LOAD_BYPASS_SERVICE_WORKER;
nsContentPolicyType contentPolicy = nsIContentPolicy::TYPE_OTHER;
nsPIDOMWindowInner* window = mRecognition->GetOwner();
nsGlobalWindowInner* window = mRecognition->GetOwnerWindow();
if (NS_WARN_IF(!window)) {
mRecognition->DispatchError(
SpeechRecognition::EVENT_RECOGNITIONSERVICE_ERROR,

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

@ -38,6 +38,7 @@
#include "nsPIDOMWindow.h"
#include "nsServiceManagerUtils.h"
#include "nsQueryObject.h"
#include "nsGlobalWindowInner.h"
#include "SpeechTrackListener.h"
#include <algorithm>
@ -160,7 +161,7 @@ SpeechRecognition::SpeechRecognition(nsPIDOMWindowInner* aOwnerWindow)
mEndpointer(kSAMPLE_RATE),
mAudioSamplesPerChunk(mEndpointer.FrameSize()),
mSpeechDetectionTimer(NS_NewTimer()),
mSpeechGrammarList(new SpeechGrammarList(GetOwner())),
mSpeechGrammarList(new SpeechGrammarList(GetOwnerGlobal())),
mContinuous(false),
mInterimResults(false),
mMaxAlternatives(1) {
@ -830,7 +831,7 @@ void SpeechRecognition::Start(const Optional<NonNull<DOMMediaStream>>& aStream,
}
} else {
mTrackIsOwned = true;
nsPIDOMWindowInner* win = GetOwner();
nsPIDOMWindowInner* win = GetOwnerWindow();
if (!win || !win->IsFullyActive()) {
aRv.ThrowInvalidStateError("The document is not fully active.");
return;
@ -885,7 +886,7 @@ void SpeechRecognition::Start(const Optional<NonNull<DOMMediaStream>>& aStream,
}
bool SpeechRecognition::SetRecognitionService(ErrorResult& aRv) {
if (!GetOwner()) {
if (!GetOwnerWindow()) {
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
return false;
}
@ -896,7 +897,7 @@ bool SpeechRecognition::SetRecognitionService(ErrorResult& aRv) {
if (!mLang.IsEmpty()) {
lang = mLang;
} else {
nsCOMPtr<Document> document = GetOwner()->GetExtantDoc();
nsCOMPtr<Document> document = GetOwnerWindow()->GetExtantDoc();
if (!document) {
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
return false;
@ -911,7 +912,7 @@ bool SpeechRecognition::SetRecognitionService(ErrorResult& aRv) {
element->GetLang(lang);
}
auto result = CreateSpeechRecognitionService(GetOwner(), this, lang);
auto result = CreateSpeechRecognitionService(GetOwnerWindow(), this, lang);
if (result.isErr()) {
switch (result.unwrapErr()) {

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

@ -17,6 +17,7 @@
#include "nsSynthVoiceRegistry.h"
#include "mozilla/dom/Document.h"
#include "nsIDocShell.h"
#include "nsGlobalWindowInner.h"
#undef LOG
mozilla::LogModule* GetSpeechSynthLog() {
@ -146,7 +147,7 @@ void SpeechSynthesis::AdvanceQueue() {
RefPtr<SpeechSynthesisUtterance> utterance = mSpeechQueue.ElementAt(0);
nsAutoString docLang;
nsCOMPtr<nsPIDOMWindowInner> window = GetOwner();
nsCOMPtr<nsPIDOMWindowInner> window = GetOwnerWindow();
if (Document* doc = window ? window->GetExtantDoc() : nullptr) {
if (Element* elm = doc->GetHtmlElement()) {
elm->GetLang(docLang);
@ -223,7 +224,7 @@ void SpeechSynthesis::GetVoices(
nsTArray<RefPtr<SpeechSynthesisVoice> >& aResult) {
aResult.Clear();
uint32_t voiceCount = 0;
nsCOMPtr<nsPIDOMWindowInner> window = GetOwner();
nsCOMPtr<nsPIDOMWindowInner> window = GetOwnerWindow();
nsCOMPtr<nsIDocShell> docShell = window ? window->GetDocShell() : nullptr;
if (nsContentUtils::ShouldResistFingerprinting(docShell,
@ -297,7 +298,7 @@ SpeechSynthesis::Observe(nsISupports* aSubject, const char* aTopic,
}
} else if (strcmp(aTopic, "synth-voices-changed") == 0) {
LOG(LogLevel::Debug, ("SpeechSynthesis::onvoiceschanged"));
nsCOMPtr<nsPIDOMWindowInner> window = GetOwner();
nsCOMPtr<nsPIDOMWindowInner> window = GetOwnerWindow();
nsCOMPtr<nsIDocShell> docShell = window ? window->GetDocShell() : nullptr;
if (!nsContentUtils::ShouldResistFingerprinting(
@ -311,7 +312,7 @@ SpeechSynthesis::Observe(nsISupports* aSubject, const char* aTopic,
} else if (strcmp(aTopic, "synth-voices-error") == 0) {
NS_WARNING("SpeechSynthesis::Observe: synth-voices-error");
LOG(LogLevel::Debug, ("SpeechSynthesis::onvoiceserror"));
nsCOMPtr<nsPIDOMWindowInner> window = GetOwner();
nsCOMPtr<nsPIDOMWindowInner> window = GetOwnerWindow();
nsCOMPtr<nsIObserverService> obs = services::GetObserverService();
if (obs) {

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

@ -46,7 +46,7 @@ JSObject* SpeechSynthesisUtterance::WrapObject(
}
nsISupports* SpeechSynthesisUtterance::GetParentObject() const {
return GetOwner();
return GetOwnerGlobal();
}
already_AddRefed<SpeechSynthesisUtterance>

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

@ -11,6 +11,7 @@
#include "nsXULAppAPI.h"
#include "SharedBuffer.h"
#include "SpeechSynthesis.h"
#include "nsGlobalWindowInner.h"
#undef LOG
extern mozilla::LogModule* GetSpeechSynthLog();
@ -335,7 +336,7 @@ void nsSpeechTask::CreateAudioChannelAgent() {
}
mAudioChannelAgent = new AudioChannelAgent();
mAudioChannelAgent->InitWithWeakCallback(mUtterance->GetOwner(), this);
mAudioChannelAgent->InitWithWeakCallback(mUtterance->GetOwnerWindow(), this);
nsresult rv = mAudioChannelAgent->NotifyStartedPlaying(
AudioChannelService::AudibleState::eAudible);

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

@ -640,7 +640,7 @@ already_AddRefed<nsSpeechTask> nsSynthVoiceRegistry::SpeakUtterance(
float volume = aUtterance.Volume();
RefPtr<AudioChannelService> service = AudioChannelService::GetOrCreate();
if (service) {
if (nsCOMPtr<nsPIDOMWindowInner> topWindow = aUtterance.GetOwner()) {
if (nsCOMPtr<nsPIDOMWindowInner> topWindow = aUtterance.GetOwnerWindow()) {
// TODO : use audio channel agent, open new bug to fix it.
AudioPlaybackConfig config =
service->GetMediaConfig(topWindow->GetOuterWindow());

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

@ -81,7 +81,7 @@ TextTrack::TextTrack(nsPIDOMWindowInner* aOwnerWindow,
TextTrack::~TextTrack() = default;
void TextTrack::SetDefaultSettings() {
nsPIDOMWindowInner* ownerWindow = GetOwner();
nsPIDOMWindowInner* ownerWindow = GetOwnerWindow();
mCueList = new TextTrackCueList(ownerWindow);
mActiveCueList = new TextTrackCueList(ownerWindow);
mCuePos = 0;
@ -246,14 +246,15 @@ void TextTrack::GetLanguage(nsAString& aLanguage) const {
}
void TextTrack::DispatchAsyncTrustedEvent(const nsString& aEventName) {
nsPIDOMWindowInner* win = GetOwner();
nsGlobalWindowInner* win = GetOwnerWindow();
if (!win) {
return;
}
RefPtr<TextTrack> self = this;
nsGlobalWindowInner::Cast(win)->Dispatch(NS_NewRunnableFunction(
"dom::TextTrack::DispatchAsyncTrustedEvent",
[self, aEventName]() { self->DispatchTrustedEvent(aEventName); }));
win->Dispatch(
NS_NewRunnableFunction("dom::TextTrack::DispatchAsyncTrustedEvent",
[self = RefPtr{this}, aEventName]() {
self->DispatchTrustedEvent(aEventName);
}));
}
bool TextTrack::IsLoaded() {

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

@ -12,6 +12,7 @@
#include "nsComponentManagerUtils.h"
#include "mozilla/ClearOnShutdown.h"
#include "mozilla/intl/Bidi.h"
#include "nsGlobalWindowInner.h"
extern mozilla::LazyLogModule gTextTrackLog;
@ -94,7 +95,7 @@ TextTrackCue::~TextTrackCue() = default;
* keep getting it from our window.
*/
nsresult TextTrackCue::StashDocument() {
nsPIDOMWindowInner* window = GetOwner();
nsPIDOMWindowInner* window = GetOwnerWindow();
if (!window) {
return NS_ERROR_NO_INTERFACE;
}

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

@ -69,7 +69,7 @@ already_AddRefed<TextTrack> TextTrackList::AddTextTrack(
TextTrackMode aMode, TextTrackReadyState aReadyState,
TextTrackSource aTextTrackSource, const CompareTextTracks& aCompareTT) {
RefPtr<TextTrack> track =
new TextTrack(GetOwner(), this, aKind, aLabel, aLanguage, aMode,
new TextTrack(GetOwnerWindow(), this, aKind, aLabel, aLanguage, aMode,
aReadyState, aTextTrackSource);
AddTextTrack(track, aCompareTT);
return track.forget();
@ -121,7 +121,7 @@ nsresult TextTrackList::DispatchTrackEvent(Event* aEvent) {
void TextTrackList::CreateAndDispatchChangeEvent() {
MOZ_ASSERT(NS_IsMainThread());
nsPIDOMWindowInner* win = GetOwner();
nsPIDOMWindowInner* win = GetOwnerWindow();
if (!win) {
return;
}

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

@ -119,10 +119,8 @@ class PostMessageRunnable final : public CancelableRunnable {
}
// Create the event
nsCOMPtr<mozilla::dom::EventTarget> eventTarget =
do_QueryInterface(mPort->GetOwner());
RefPtr<MessageEvent> event =
new MessageEvent(eventTarget, nullptr, nullptr);
new MessageEvent(mPort->GetOwnerWindow(), nullptr, nullptr);
Sequence<OwningNonNull<MessagePort>> ports;
if (!mData->TakeTransferredPortsAsSequence(ports)) {
@ -813,7 +811,7 @@ void MessagePort::RemoveDocFromBFCache() {
return;
}
if (nsPIDOMWindowInner* window = GetOwner()) {
if (nsPIDOMWindowInner* window = GetOwnerWindow()) {
window->RemoveFromBFCacheSync();
}
}

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

@ -21,6 +21,7 @@
#include "mozilla/dom/PContent.h"
#include "mozilla/dom/Document.h"
#include "nsPIDOMWindow.h"
#include "nsGlobalWindowInner.h"
#include "nsContentPermissionHelper.h"
#include "nsISupportsImpl.h" // for MOZ_COUNT_CTOR, MOZ_COUNT_DTOR
#include "ipc/IPCMessageUtils.h"
@ -150,7 +151,7 @@ void MIDIAccess::MaybeCreateMIDIPort(const MIDIPortInfo& aInfo,
// We already have the port in our map.
return;
}
port = MIDIInput::Create(GetOwner(), this, aInfo, mSysexEnabled);
port = MIDIInput::Create(GetOwnerWindow(), this, aInfo, mSysexEnabled);
if (NS_WARN_IF(!port)) {
LOG("Couldn't create input port");
aRv.Throw(NS_ERROR_FAILURE);
@ -169,7 +170,7 @@ void MIDIAccess::MaybeCreateMIDIPort(const MIDIPortInfo& aInfo,
// We already have the port in our map.
return;
}
port = MIDIOutput::Create(GetOwner(), this, aInfo, mSysexEnabled);
port = MIDIOutput::Create(GetOwnerWindow(), this, aInfo, mSysexEnabled);
if (NS_WARN_IF(!port)) {
LOG("Couldn't create output port");
aRv.Throw(NS_ERROR_FAILURE);
@ -205,7 +206,7 @@ void MIDIAccess::MaybeCreateMIDIPort(const MIDIPortInfo& aInfo,
// request removal from MIDIAccess's maps.
void MIDIAccess::Notify(const MIDIPortList& aEvent) {
LOG("MIDIAcess::Notify");
if (!GetOwner()) {
if (!GetOwnerWindow()) {
// Do nothing if we've already been disconnected from the document.
return;
}

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

@ -10,6 +10,7 @@
#include "mozilla/dom/MIDIInputBinding.h"
#include "mozilla/dom/MIDIMessageEvent.h"
#include "mozilla/dom/MIDIMessageEventBinding.h"
#include "nsGlobalWindowInner.h"
#include "MIDILog.h"
@ -38,11 +39,11 @@ JSObject* MIDIInput::WrapObject(JSContext* aCx,
}
void MIDIInput::Receive(const nsTArray<MIDIMessage>& aMsgs) {
if (!GetOwner()) {
if (!GetOwnerWindow()) {
return; // Ignore messages once we've been disconnected from the owner
}
nsCOMPtr<Document> doc = GetOwner()->GetDoc();
nsCOMPtr<Document> doc = GetOwnerWindow()->GetDoc();
if (!doc) {
NS_WARNING("No document available to send MIDIMessageEvent to!");
return;

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

@ -14,9 +14,9 @@
#include "mozilla/TimeStamp.h"
#include "mozilla/dom/Document.h"
#include "mozilla/dom/Performance.h"
#include "nsGlobalWindowInner.h"
using namespace mozilla;
using namespace mozilla::dom;
namespace mozilla::dom {
MIDIOutput::MIDIOutput(nsPIDOMWindowInner* aWindow) : MIDIPort(aWindow) {}
@ -54,13 +54,13 @@ void MIDIOutput::Send(const Sequence<uint8_t>& aData,
// message ASAP.
TimeStamp timestamp;
if (aTimestamp.WasPassed() && aTimestamp.Value() != 0) {
nsCOMPtr<Document> doc = GetOwner()->GetDoc();
nsCOMPtr<Document> doc = GetOwnerWindow()->GetDoc();
if (!doc) {
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
return;
}
TimeDuration ts_diff = TimeDuration::FromMilliseconds(aTimestamp.Value());
timestamp = GetOwner()
timestamp = GetOwnerWindow()
->GetPerformance()
->GetDOMTiming()
->GetNavigationStartTimeStamp() +
@ -100,3 +100,5 @@ void MIDIOutput::Clear() {
}
Port()->SendClear();
}
} // namespace mozilla::dom

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

@ -41,8 +41,7 @@ MIDIPort::MIDIPort(nsPIDOMWindowInner* aWindow)
mKeepAlive(false) {
MOZ_ASSERT(aWindow);
Document* aDoc = GetOwner()->GetExtantDoc();
if (aDoc) {
if (Document* aDoc = aWindow->GetExtantDoc()) {
aDoc->DisallowBFCaching();
}
}
@ -158,13 +157,10 @@ bool MIDIPort::SysexEnabled() const {
already_AddRefed<Promise> MIDIPort::Open(ErrorResult& aError) {
LOG("MIDIPort::Open");
MOZ_ASSERT(Port());
RefPtr<Promise> p;
if (mOpeningPromise) {
p = mOpeningPromise;
return p.forget();
return do_AddRef(mOpeningPromise);
}
nsCOMPtr<nsIGlobalObject> go = do_QueryInterface(GetOwner());
p = Promise::Create(go, aError);
RefPtr<Promise> p = Promise::Create(GetOwnerGlobal(), aError);
if (aError.Failed()) {
return nullptr;
}
@ -176,13 +172,10 @@ already_AddRefed<Promise> MIDIPort::Open(ErrorResult& aError) {
already_AddRefed<Promise> MIDIPort::Close(ErrorResult& aError) {
LOG("MIDIPort::Close");
MOZ_ASSERT(Port());
RefPtr<Promise> p;
if (mClosingPromise) {
p = mClosingPromise;
return p.forget();
return do_AddRef(mClosingPromise);
}
nsCOMPtr<nsIGlobalObject> go = do_QueryInterface(GetOwner());
p = Promise::Create(go, aError);
RefPtr<Promise> p = Promise::Create(GetOwnerGlobal(), aError);
if (aError.Failed()) {
return nullptr;
}
@ -199,7 +192,7 @@ void MIDIPort::Notify(const void_t& aVoid) {
}
void MIDIPort::FireStateChangeEvent() {
if (!GetOwner()) {
if (!GetOwnerWindow()) {
return; // Ignore changes once we've been disconnected from the owner
}

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

@ -41,7 +41,7 @@ class MIDIPort : public DOMEventTargetHelper,
virtual ~MIDIPort();
public:
nsPIDOMWindowInner* GetParentObject() const { return GetOwner(); }
nsIGlobalObject* GetParentObject() const { return GetOwnerGlobal(); }
// Getters
void GetId(nsString& aRetVal) const;

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

@ -14,6 +14,8 @@
#include "TCPServerSocket.h"
#include "TCPSocket.h"
#include "nsComponentManagerUtils.h"
#include "nsGlobalWindowInner.h"
using namespace mozilla::dom;
@ -139,7 +141,7 @@ TCPServerSocket::OnSocketAccepted(nsIServerSocket* aServer,
NS_IMETHODIMP
TCPServerSocket::OnStopListening(nsIServerSocket* aServer, nsresult aStatus) {
if (aStatus != NS_BINDING_ABORTED) {
RefPtr<Event> event = new Event(GetOwner());
RefPtr<Event> event = new Event(GetOwnerWindow());
event->InitEvent(u"error"_ns, false, false);
event->SetTrusted(true);
DispatchEvent(*event);

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

@ -32,10 +32,8 @@ class TCPServerSocket final : public DOMEventTargetHelper,
DOMEventTargetHelper)
NS_DECL_NSISERVERSOCKETLISTENER
nsPIDOMWindowInner* GetParentObject() const { return GetOwner(); }
virtual JSObject* WrapObject(JSContext* aCx,
JS::Handle<JSObject*> aGivenProto) override;
nsIGlobalObject* GetParentObject() const { return GetOwnerGlobal(); }
JSObject* WrapObject(JSContext*, JS::Handle<JSObject*> aGivenProto) override;
nsresult Init();

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

@ -374,16 +374,15 @@ bool UDPSocket::Send(const StringOrBlobOrArrayBufferOrArrayBufferView& aData,
nsresult UDPSocket::InitLocal(const nsAString& aLocalAddress,
const uint16_t& aLocalPort) {
nsresult rv;
nsCOMPtr<nsIUDPSocket> sock =
do_CreateInstance("@mozilla.org/network/udp-socket;1", &rv);
if (NS_FAILED(rv)) {
return rv;
}
nsCOMPtr<nsIGlobalObject> global = do_QueryInterface(GetOwner(), &rv);
if (NS_FAILED(rv)) {
return rv;
nsCOMPtr<nsIGlobalObject> global = GetOwnerGlobal();
if (!global) {
return NS_ERROR_FAILURE;
}
nsCOMPtr<nsIPrincipal> principal = global->PrincipalOrNull();
@ -458,23 +457,21 @@ nsresult UDPSocket::InitLocal(const nsAString& aLocalAddress,
nsresult UDPSocket::InitRemote(const nsAString& aLocalAddress,
const uint16_t& aLocalPort) {
nsresult rv;
RefPtr<UDPSocketChild> sock = new UDPSocketChild();
mListenerProxy = new ListenerProxy(this);
nsCOMPtr<nsIGlobalObject> obj = do_QueryInterface(GetOwner(), &rv);
if (NS_FAILED(rv)) {
return rv;
nsCOMPtr<nsIGlobalObject> global = GetOwnerGlobal();
if (!global) {
return NS_ERROR_FAILURE;
}
nsCOMPtr<nsIPrincipal> principal = obj->PrincipalOrNull();
nsCOMPtr<nsIPrincipal> principal = global->PrincipalOrNull();
if (!principal) {
return NS_ERROR_FAILURE;
}
rv = sock->Bind(mListenerProxy, principal,
nsresult rv = sock->Bind(mListenerProxy, principal,
NS_ConvertUTF16toUTF8(aLocalAddress), aLocalPort,
mAddressReuse, mLoopback, 0, 0);
@ -497,9 +494,9 @@ nsresult UDPSocket::Init(const nsString& aLocalAddress,
mAddressReuse = aAddressReuse;
mLoopback = aLoopback;
ErrorResult rv;
nsCOMPtr<nsIGlobalObject> global = do_QueryInterface(GetOwner());
nsCOMPtr<nsIGlobalObject> global = GetOwnerGlobal();
ErrorResult rv;
mOpened = Promise::Create(global, rv);
if (NS_WARN_IF(rv.Failed())) {
return rv.StealNSResult();
@ -571,7 +568,7 @@ nsresult UDPSocket::DispatchReceivedData(const nsACString& aRemoteAddress,
const nsTArray<uint8_t>& aData) {
AutoJSAPI jsapi;
if (NS_WARN_IF(!jsapi.Init(GetOwner()))) {
if (NS_WARN_IF(!jsapi.Init(GetOwnerWindow()))) {
return NS_ERROR_FAILURE;
}

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

@ -49,7 +49,7 @@ class UDPSocket final : public DOMEventTargetHelper,
NS_DECL_NSIUDPSOCKETINTERNAL
public:
nsPIDOMWindowInner* GetParentObject() const { return GetOwner(); }
nsIGlobalObject* GetParentObject() const { return GetOwnerGlobal(); }
virtual JSObject* WrapObject(JSContext* aCx,
JS::Handle<JSObject*> aGivenProto) override;

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

@ -984,11 +984,10 @@ nsIPrincipal* Notification::GetPrincipal() {
AssertIsOnMainThread();
if (mWorkerPrivate) {
return mWorkerPrivate->GetPrincipal();
} else {
nsCOMPtr<nsIScriptObjectPrincipal> sop = do_QueryInterface(GetOwner());
NS_ENSURE_TRUE(sop, nullptr);
return sop->GetPrincipal();
}
nsGlobalWindowInner* win = GetOwnerWindow();
NS_ENSURE_TRUE(win, nullptr);
return win->GetPrincipal();
}
class WorkerNotificationObserver final : public MainThreadNotificationObserver {
@ -1163,7 +1162,7 @@ MainThreadNotificationObserver::Observe(nsISupports* aSubject,
Notification* notification = mNotificationRef->GetNotification();
MOZ_ASSERT(notification);
if (!strcmp("alertclickcallback", aTopic)) {
nsCOMPtr<nsPIDOMWindowInner> window = notification->GetOwner();
nsCOMPtr<nsPIDOMWindowInner> window = notification->GetOwnerWindow();
if (NS_WARN_IF(!window || !window->IsCurrentInnerWindow())) {
// Window has been closed, this observer is not valid anymore
return NS_ERROR_FAILURE;
@ -1320,8 +1319,8 @@ bool Notification::IsInPrivateBrowsing() {
if (mWorkerPrivate) {
doc = mWorkerPrivate->GetDocument();
} else if (GetOwner()) {
doc = GetOwner()->GetExtantDoc();
} else if (nsGlobalWindowInner* win = GetOwnerWindow()) {
doc = win->GetExtantDoc();
}
if (doc) {
@ -1374,7 +1373,7 @@ void Notification::ShowInternal() {
if (mWorkerPrivate) {
permission = GetPermissionInternal(mWorkerPrivate->GetPrincipal(), result);
} else {
permission = GetPermissionInternal(GetOwner(), result);
permission = GetPermissionInternal(GetOwnerWindow(), result);
}
// We rely on GetPermissionInternal returning Denied on all failure codepaths.
MOZ_ASSERT_IF(result.Failed(), permission == NotificationPermission::Denied);
@ -2344,11 +2343,8 @@ Notification::Observe(nsISupports* aSubject, const char* aTopic,
if (!strcmp(aTopic, DOM_WINDOW_DESTROYED_TOPIC) ||
!strcmp(aTopic, DOM_WINDOW_FROZEN_TOPIC)) {
nsCOMPtr<nsPIDOMWindowInner> window = GetOwner();
if (SameCOMIdentity(aSubject, window)) {
nsCOMPtr<nsIObserverService> obs =
mozilla::services::GetObserverService();
if (obs) {
if (SameCOMIdentity(aSubject, ToSupports(GetOwnerWindow()))) {
if (nsCOMPtr<nsIObserverService> obs = services::GetObserverService()) {
obs->RemoveObserver(this, DOM_WINDOW_DESTROYED_TOPIC);
obs->RemoveObserver(this, DOM_WINDOW_FROZEN_TOPIC);
}

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

@ -177,10 +177,9 @@ class Notification : public DOMEventTargetHelper,
void Close();
nsPIDOMWindowInner* GetParentObject() { return GetOwner(); }
nsIGlobalObject* GetParentObject() const { return GetOwnerGlobal(); }
virtual JSObject* WrapObject(JSContext* aCx,
JS::Handle<JSObject*> aGivenProto) override;
JSObject* WrapObject(JSContext*, JS::Handle<JSObject*> aGivenProto) override;
bool RequireInteraction() const;

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

@ -26,6 +26,7 @@
#include "nsIURLParser.h"
#include "nsNetCID.h"
#include "nsServiceManagerUtils.h"
#include "nsGlobalWindowInner.h"
#include "mozilla/dom/MerchantValidationEvent.h"
#include "PaymentResponse.h"
@ -808,8 +809,8 @@ void PaymentRequest::RespondShowPayment(const nsAString& aMethodName,
aDetails, aPayerName, aPayerEmail, aPayerPhone);
} else if (mAcceptPromise) {
RefPtr<PaymentResponse> paymentResponse = new PaymentResponse(
GetOwner(), this, mId, aMethodName, mShippingOption, mShippingAddress,
aDetails, aPayerName, aPayerEmail, aPayerPhone);
GetOwnerWindow(), this, mId, aMethodName, mShippingOption,
mShippingAddress, aDetails, aPayerName, aPayerEmail, aPayerPhone);
mResponse = paymentResponse;
mAcceptPromise->MaybeResolve(paymentResponse);
} else {
@ -1063,10 +1064,10 @@ nsresult PaymentRequest::UpdateShippingAddress(
const nsAString& aPhone) {
nsTArray<nsString> emptyArray;
mShippingAddress = new PaymentAddress(
GetOwner(), aCountry, emptyArray, aRegion, aRegionCode, aCity,
GetOwnerWindow(), aCountry, emptyArray, aRegion, aRegionCode, aCity,
aDependentLocality, aPostalCode, aSortingCode, u""_ns, u""_ns, u""_ns);
mFullShippingAddress =
new PaymentAddress(GetOwner(), aCountry, aAddressLine, aRegion,
new PaymentAddress(GetOwnerWindow(), aCountry, aAddressLine, aRegion,
aRegionCode, aCity, aDependentLocality, aPostalCode,
aSortingCode, aOrganization, aRecipient, aPhone);
// Fire shippingaddresschange event
@ -1190,7 +1191,7 @@ bool PaymentRequest::InFullyActiveDocument() {
}
void PaymentRequest::RegisterActivityObserver() {
if (nsPIDOMWindowInner* window = GetOwner()) {
if (nsPIDOMWindowInner* window = GetOwnerWindow()) {
mDocument = window->GetExtantDoc();
if (mDocument) {
mDocument->RegisterActivityObserver(
@ -1207,7 +1208,7 @@ void PaymentRequest::UnregisterActivityObserver() {
}
void PaymentRequest::NotifyOwnerDocumentActivityChanged() {
nsPIDOMWindowInner* window = GetOwner();
nsPIDOMWindowInner* window = GetOwnerWindow();
NS_ENSURE_TRUE_VOID(window);
Document* doc = window->GetExtantDoc();
NS_ENSURE_TRUE_VOID(doc);

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

@ -351,7 +351,7 @@ PaymentRequestChild* PaymentRequestManager::GetPaymentChild(
return child;
}
nsPIDOMWindowInner* win = aRequest->GetOwner();
nsPIDOMWindowInner* win = aRequest->GetOwnerWindow();
NS_ENSURE_TRUE(win, nullptr);
BrowserChild* browserChild = BrowserChild::GetFrom(win->GetDocShell());
NS_ENSURE_TRUE(browserChild, nullptr);

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

@ -13,6 +13,7 @@
#include "PaymentRequest.h"
#include "PaymentRequestManager.h"
#include "PaymentRequestUtils.h"
#include "nsGlobalWindowInner.h"
#include "mozilla/EventStateManager.h"
namespace mozilla::dom {
@ -122,7 +123,7 @@ void PaymentResponse::GetDetails(JSContext* aCx,
!rawData.billingAddress.recipient.IsEmpty() ||
!rawData.billingAddress.phone.IsEmpty()) {
basicCardResponse.mBillingAddress = new PaymentAddress(
GetOwner(), rawData.billingAddress.country,
GetOwnerWindow(), rawData.billingAddress.country,
rawData.billingAddress.addressLine, rawData.billingAddress.region,
rawData.billingAddress.regionCode, rawData.billingAddress.city,
rawData.billingAddress.dependentLocality,
@ -198,13 +199,7 @@ already_AddRefed<Promise> PaymentResponse::Complete(PaymentComplete result,
return nullptr;
}
if (NS_WARN_IF(!GetOwner())) {
aRv.ThrowAbortError("Global object should exist");
return nullptr;
}
nsIGlobalObject* global = GetOwner()->AsGlobal();
RefPtr<Promise> promise = Promise::Create(global, aRv);
RefPtr<Promise> promise = Promise::Create(GetOwnerGlobal(), aRv);
if (aRv.Failed()) {
return nullptr;
}
@ -229,8 +224,7 @@ already_AddRefed<Promise> PaymentResponse::Retry(
return nullptr;
}
nsIGlobalObject* global = GetOwner()->AsGlobal();
RefPtr<Promise> promise = Promise::Create(global, aRv);
RefPtr<Promise> promise = Promise::Create(GetOwnerGlobal(), aRv);
if (aRv.Failed()) {
return nullptr;
}
@ -292,7 +286,7 @@ void PaymentResponse::RespondRetry(const nsAString& aMethodName,
mPayerEmail = aPayerEmail;
mPayerPhone = aPayerPhone;
if (NS_WARN_IF(!GetOwner())) {
if (NS_WARN_IF(!GetOwnerGlobal())) {
return;
}

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

@ -346,8 +346,8 @@ already_AddRefed<PerformanceMark> Performance::Mark(
if (profiler_thread_is_being_profiled_for_markers()) {
Maybe<uint64_t> innerWindowId;
if (GetOwner()) {
innerWindowId = Some(GetOwner()->WindowID());
if (nsGlobalWindowInner* owner = GetOwnerWindow()) {
innerWindowId = Some(owner->WindowID());
}
TimeStamp startTimeStamp =
CreationTimeStamp() +
@ -800,8 +800,8 @@ already_AddRefed<PerformanceMeasure> Performance::Measure(
}
Maybe<uint64_t> innerWindowId;
if (GetOwner()) {
innerWindowId = Some(GetOwner()->WindowID());
if (nsGlobalWindowInner* owner = GetOwnerWindow()) {
innerWindowId = Some(owner->WindowID());
}
profiler_add_marker("UserTiming", geckoprofiler::category::DOM,
{MarkerTiming::Interval(startTimeStamp, endTimeStamp),
@ -842,10 +842,8 @@ void Performance::TimingNotification(PerformanceEntry* aEntry,
RefPtr<PerformanceEntryEvent> perfEntryEvent =
PerformanceEntryEvent::Constructor(this, u"performanceentry"_ns, init);
nsCOMPtr<EventTarget> et = do_QueryInterface(GetOwner());
if (et) {
et->DispatchEvent(*perfEntryEvent);
if (RefPtr<nsGlobalWindowInner> owner = GetOwnerWindow()) {
owner->DispatchEvent(*perfEntryEvent);
}
}

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

@ -21,12 +21,11 @@
#include "mozilla/dom/PerformanceResourceTiming.h"
#include "mozilla/dom/PerformanceTiming.h"
#include "mozilla/StaticPrefs_dom.h"
#include "mozilla/StaticPrefs_privacy.h"
#include "mozilla/PresShell.h"
#include "nsIChannel.h"
#include "nsIHttpChannel.h"
#include "nsIDocShell.h"
#include "nsTextFrame.h"
#include "nsGlobalWindowInner.h"
#include "nsContainerFrame.h"
namespace mozilla::dom {
@ -110,7 +109,7 @@ PerformanceMainThread::PerformanceMainThread(nsPIDOMWindowInner* aWindow,
CreateNavigationTimingEntry();
if (StaticPrefs::dom_enable_largest_contentful_paint()) {
nsCOMPtr<nsPIDOMWindowInner> owner = GetOwner();
nsGlobalWindowInner* owner = GetOwnerWindow();
MarkerInnerWindowId innerWindowID =
owner ? MarkerInnerWindowId(owner->WindowID())
: MarkerInnerWindowId::NoId();
@ -418,7 +417,7 @@ void PerformanceMainThread::InsertUserEntry(PerformanceEntry* aEntry) {
if (StaticPrefs::dom_performance_enable_user_timing_logging() ||
StaticPrefs::dom_performance_enable_notify_performance_timing()) {
nsresult rv = NS_ERROR_FAILURE;
nsCOMPtr<nsPIDOMWindowInner> owner = GetOwner();
nsGlobalWindowInner* owner = GetOwnerWindow();
if (owner && owner->GetDocumentURI()) {
rv = owner->GetDocumentURI()->GetHost(uri);
}

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

@ -13,6 +13,7 @@
#include "nsIPermissionManager.h"
#include "PermissionObserver.h"
#include "PermissionUtils.h"
#include "nsGlobalWindowInner.h"
namespace mozilla::dom {
@ -70,7 +71,7 @@ RefPtr<PermissionStatus::SimplePromise> PermissionStatus::UpdateState() {
// does not exactly match what the spec has. (Not passing "permission key" for
// example)
nsCOMPtr<nsPIDOMWindowInner> window = GetOwner();
RefPtr<nsGlobalWindowInner> window = GetOwnerWindow();
if (NS_WARN_IF(!window)) {
return SimplePromise::CreateAndReject(NS_ERROR_FAILURE, __func__);
}
@ -100,7 +101,7 @@ RefPtr<PermissionStatus::SimplePromise> PermissionStatus::UpdateState() {
bool PermissionStatus::MaybeUpdatedBy(nsIPermission* aPermission) const {
NS_ENSURE_TRUE(aPermission, false);
nsCOMPtr<nsPIDOMWindowInner> window = GetOwner();
RefPtr<nsGlobalWindowInner> window = GetOwnerWindow();
if (NS_WARN_IF(!window)) {
return false;
}

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

@ -12,6 +12,7 @@
#include "mozilla/dom/FeaturePolicyUtils.h"
#include "mozilla/dom/PermissionStatus.h"
#include "mozilla/dom/PermissionStatusBinding.h"
#include "nsGlobalWindowInner.h"
#include "nsIPermissionManager.h"
namespace mozilla::dom {
@ -22,7 +23,7 @@ StorageAccessPermissionStatus::StorageAccessPermissionStatus(
RefPtr<PermissionStatus::SimplePromise>
StorageAccessPermissionStatus::UpdateState() {
nsCOMPtr<nsPIDOMWindowInner> window = GetOwner();
nsGlobalWindowInner* window = GetOwnerWindow();
if (NS_WARN_IF(!window)) {
return SimplePromise::CreateAndReject(NS_ERROR_FAILURE, __func__);
}
@ -63,7 +64,7 @@ bool StorageAccessPermissionStatus::MaybeUpdatedBy(
bool StorageAccessPermissionStatus::MaybeUpdatedByNotifyOnly(
nsPIDOMWindowInner* aInnerWindow) const {
nsPIDOMWindowInner* owner = GetOwner();
nsPIDOMWindowInner* owner = GetOwnerWindow();
NS_ENSURE_TRUE(owner, false);
NS_ENSURE_TRUE(aInnerWindow, false);
return owner->WindowID() == aInnerWindow->WindowID();

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

@ -181,7 +181,7 @@ void ServiceWorker::PostMessage(JSContext* aCx, JS::Handle<JS::Value> aMessage,
return;
}
nsPIDOMWindowInner* window = GetOwner();
nsPIDOMWindowInner* window = GetOwnerWindow();
if (NS_WARN_IF(!window || !window->GetExtantDoc())) {
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
return;

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

@ -16,9 +16,9 @@
#include "nsNetUtil.h"
#include "nsPIDOMWindow.h"
#include "mozilla/Components.h"
#include "mozilla/StaticPrefs_dom.h"
#include "nsCycleCollectionParticipant.h"
#include "nsGlobalWindowInner.h"
#include "nsServiceManagerUtils.h"
#include "mozilla/LoadInfo.h"
#include "mozilla/SchedulerGroup.h"
@ -678,7 +678,7 @@ void ServiceWorkerContainer::GetScopeForUrl(const nsAString& aUrl,
return;
}
nsCOMPtr<nsPIDOMWindowInner> window = GetOwner();
nsCOMPtr<nsPIDOMWindowInner> window = GetOwnerWindow();
if (NS_WARN_IF(!window)) {
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
return;
@ -707,7 +707,7 @@ nsIGlobalObject* ServiceWorkerContainer::GetGlobalIfValid(
// not exposed on worker globals yet. The main thing we need
// to fix here to support that is the storage access check via
// the nsIGlobalObject.
nsPIDOMWindowInner* window = GetOwner();
nsGlobalWindowInner* window = GetOwnerWindow();
if (NS_WARN_IF(!window)) {
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
return nullptr;
@ -753,10 +753,7 @@ void ServiceWorkerContainer::EnqueueReceivedMessageDispatch(
template <typename F>
void ServiceWorkerContainer::RunWithJSContext(F&& aCallable) {
nsCOMPtr<nsIGlobalObject> globalObject;
if (nsPIDOMWindowInner* const window = GetOwner()) {
globalObject = do_QueryInterface(window);
}
nsCOMPtr<nsIGlobalObject> globalObject = GetOwnerGlobal();
// If AutoJSAPI::Init() fails then either global is nullptr or not
// in a usable state.

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

@ -25,8 +25,8 @@
#include "VRManagerChild.h"
#include "VRDisplayPresentation.h"
#include "nsIObserverService.h"
#include "nsIFrame.h"
#include "nsISupportsPrimitives.h"
#include "nsGlobalWindowInner.h"
using namespace mozilla::gfx;
@ -507,7 +507,7 @@ VRDisplay::Observe(nsISupports* aSubject, const char* aTopic,
nsresult rv = wrapper->GetData(&innerID);
NS_ENSURE_SUCCESS(rv, rv);
if (!GetOwner() || GetOwner()->WindowID() == innerID) {
if (!GetOwnerWindow() || GetOwnerWindow()->WindowID() == innerID) {
Shutdown();
}

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

@ -38,7 +38,7 @@ bool ReadFloat32Array(T& aDestination, const Float32Array& aSource,
}; // anonymous namespace
VRMockDisplay::VRMockDisplay(VRServiceTest* aVRServiceTest)
: DOMEventTargetHelper(aVRServiceTest->GetOwner()),
: DOMEventTargetHelper(aVRServiceTest->GetOwnerGlobal()),
mVRServiceTest(aVRServiceTest) {}
JSObject* VRMockDisplay::WrapObject(JSContext* aCx,
@ -339,7 +339,7 @@ NS_IMPL_ISUPPORTS_CYCLE_COLLECTION_INHERITED_0(VRMockController,
VRMockController::VRMockController(VRServiceTest* aVRServiceTest,
uint32_t aControllerIdx)
: DOMEventTargetHelper(aVRServiceTest->GetOwner()),
: DOMEventTargetHelper(aVRServiceTest->GetOwnerGlobal()),
mVRServiceTest(aVRServiceTest),
mControllerIdx(aControllerIdx) {
MOZ_ASSERT(aControllerIdx < kVRControllerMaxCount);

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

@ -299,9 +299,8 @@ void XRSession::WillRefresh(mozilla::TimeStamp aTime) {
// Inline sessions are driven by nsRefreshDriver directly,
// unlike immersive sessions, which are driven VRDisplayClient.
if (!IsImmersive() && !mXRSystem->HasActiveImmersiveSession()) {
nsGlobalWindowInner* win = nsGlobalWindowInner::Cast(GetOwner());
if (win) {
if (JSObject* obj = win->AsGlobal()->GetGlobalJSObject()) {
if (nsIGlobalObject* global = GetOwnerGlobal()) {
if (JSObject* obj = global->GetGlobalJSObject()) {
js::NotifyAnimationActivity(obj);
}
}

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

@ -272,7 +272,7 @@ void XRSystem::OnXRPermissionRequestCancel() {
}
bool XRSystem::FeaturePolicyBlocked() const {
nsGlobalWindowInner* win = nsGlobalWindowInner::Cast(GetOwner());
nsGlobalWindowInner* win = GetOwnerWindow();
if (!win) {
return true;
}
@ -332,11 +332,11 @@ void XRSystem::ResolveSessionRequests(
if (request->ResolveSupport(display, enabledReferenceSpaceTypes)) {
if (request->IsImmersive()) {
session = XRSession::CreateImmersiveSession(
GetOwner(), this, display, request->GetPresentationGroup(),
GetOwnerWindow(), this, display, request->GetPresentationGroup(),
enabledReferenceSpaceTypes);
mActiveImmersiveSession = session;
} else {
session = XRSession::CreateInlineSession(GetOwner(), this,
session = XRSession::CreateInlineSession(GetOwnerWindow(), this,
enabledReferenceSpaceTypes);
mInlineSessions.AppendElement(session);
}
@ -445,8 +445,7 @@ void XRSystem::ProcessSessionRequestsWaitingForRuntimeDetection() {
* allowing xr-spatial-tracking for inline sessions do not
* present a modal XR permission UI. (eg. Android Firefox Reality)
*/
nsGlobalWindowInner* win = nsGlobalWindowInner::Cast(GetOwner());
win->RequestXRPermission();
GetOwnerWindow()->RequestXRPermission();
}
}

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

@ -638,8 +638,8 @@ void WebSocketImpl::Disconnect(const RefPtr<WebSocketImpl>& aProofOfRef) {
// If we haven't called WebSocket::DisconnectFromOwner yet, update
// web socket count here.
if (mWebSocket->GetOwner()) {
mWebSocket->GetOwner()->UpdateWebSocketCount(-1);
if (nsGlobalWindowInner* win = mWebSocket->GetOwnerWindow()) {
win->UpdateWebSocketCount(-1);
}
} else {
RefPtr<DisconnectInternalRunnable> runnable =
@ -1373,8 +1373,8 @@ already_AddRefed<WebSocket> WebSocket::ConstructorCommon(
if (NS_IsMainThread()) {
// We're keeping track of all main thread web sockets to be able to
// avoid throttling timeouts when we have active web sockets.
if (webSocket->GetOwner()) {
webSocket->GetOwner()->UpdateWebSocketCount(1);
if (nsGlobalWindowInner* win = webSocket->GetOwnerWindow()) {
win->UpdateWebSocketCount(1);
}
bool isSecure = principal->SchemeIs("https");
@ -1582,8 +1582,8 @@ void WebSocket::DisconnectFromOwner() {
// If we haven't called WebSocketImpl::Disconnect yet, update web
// socket count here.
if (NS_IsMainThread() && mImpl && !mImpl->mDisconnectingOrDisconnected &&
GetOwner()) {
GetOwner()->UpdateWebSocketCount(-1);
GetOwnerWindow()) {
GetOwnerWindow()->UpdateWebSocketCount(-1);
}
DOMEventTargetHelper::DisconnectFromOwner();
@ -1674,7 +1674,7 @@ nsresult WebSocketImpl::Init(JSContext* aCx, bool aIsSecure,
// inner-windowID. This can happen in sharedWorkers and ServiceWorkers or in
// DedicateWorkers created by JSM.
if (aCx) {
if (nsPIDOMWindowInner* ownerWindow = mWebSocket->GetOwner()) {
if (nsPIDOMWindowInner* ownerWindow = mWebSocket->GetOwnerWindow()) {
mInnerWindowID = ownerWindow->WindowID();
}
}
@ -2596,17 +2596,17 @@ WebSocketImpl::Observe(nsISupports* aSubject, const char* aTopic,
AssertIsOnMainThread();
int64_t readyState = mWebSocket->ReadyState();
if ((readyState == WebSocket::CLOSING) || (readyState == WebSocket::CLOSED)) {
if (readyState == WebSocket::CLOSING || readyState == WebSocket::CLOSED) {
return NS_OK;
}
nsCOMPtr<nsPIDOMWindowInner> window = do_QueryInterface(aSubject);
if (!mWebSocket->GetOwner() || window != mWebSocket->GetOwner()) {
if (!mWebSocket->GetOwnerWindow() || window != mWebSocket->GetOwnerWindow()) {
return NS_OK;
}
if ((strcmp(aTopic, DOM_WINDOW_FROZEN_TOPIC) == 0) ||
(strcmp(aTopic, DOM_WINDOW_DESTROYED_TOPIC) == 0)) {
if (!strcmp(aTopic, DOM_WINDOW_FROZEN_TOPIC) ||
!strcmp(aTopic, DOM_WINDOW_DESTROYED_TOPIC)) {
RefPtr<WebSocketImpl> self(this);
CloseConnection(self, nsIWebSocketChannel::CLOSE_GOING_AWAY);
}

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

@ -17,6 +17,7 @@
#include "mozilla/dom/WindowGlobalChild.h"
#include "mozilla/dom/WorkerError.h"
#include "mozilla/dom/locks/LockManagerChild.h"
#include "nsGlobalWindowInner.h"
namespace mozilla {
@ -74,7 +75,7 @@ IPCResult SharedWorkerChild::RecvError(const ErrorValue& aValue) {
return IPC_OK();
}
nsPIDOMWindowInner* window = mParent->GetOwner();
nsPIDOMWindowInner* window = mParent->GetOwnerWindow();
uint64_t innerWindowId = window ? window->WindowID() : 0;
if (aValue.type() == ErrorValue::TCSPViolation) {
@ -153,7 +154,7 @@ IPCResult SharedWorkerChild::RecvNotifyLock(bool aCreated) {
return IPC_OK();
}
locks::LockManagerChild::NotifyBFCacheOnMainThread(mParent->GetOwner(),
locks::LockManagerChild::NotifyBFCacheOnMainThread(mParent->GetOwnerWindow(),
aCreated);
return IPC_OK();
@ -164,7 +165,7 @@ IPCResult SharedWorkerChild::RecvNotifyWebTransport(bool aCreated) {
return IPC_OK();
}
WebTransport::NotifyBFCacheOnMainThread(mParent->GetOwner(), aCreated);
WebTransport::NotifyBFCacheOnMainThread(mParent->GetOwnerWindow(), aCreated);
return IPC_OK();
}

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

@ -37,9 +37,8 @@ class XMLHttpRequestEventTarget : public DOMEventTargetHelper {
IMPL_EVENT_HANDLER(timeout)
IMPL_EVENT_HANDLER(loadend)
nsISupports* GetParentObject() const { return GetOwner(); }
virtual void DisconnectFromOwner() override;
nsISupports* GetParentObject() const { return GetOwnerGlobal(); }
void DisconnectFromOwner() override;
};
} // namespace mozilla::dom

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

@ -53,6 +53,7 @@
#include "nsIBaseChannel.h"
#include "nsIJARChannel.h"
#include "nsIJARURI.h"
#include "nsGlobalWindowInner.h"
#include "nsReadableUtils.h"
#include "nsSandboxFlags.h"
@ -525,7 +526,7 @@ Document* XMLHttpRequestMainThread::GetResponseXML(ErrorResult& aRv) {
}
if (mWarnAboutSyncHtml) {
mWarnAboutSyncHtml = false;
LogMessage("HTMLSyncXHRWarning", GetOwner());
LogMessage("HTMLSyncXHRWarning", GetOwnerWindow());
}
if (mState != XMLHttpRequest_Binding::DONE) {
return nullptr;
@ -559,7 +560,7 @@ nsresult XMLHttpRequestMainThread::DetectCharset() {
if (mResponseType == XMLHttpRequestResponseType::Json &&
encoding != UTF_8_ENCODING) {
// The XHR spec says only UTF-8 is supported for responseType == "json"
LogMessage("JSONCharsetWarning", GetOwner());
LogMessage("JSONCharsetWarning", GetOwnerWindow());
encoding = UTF_8_ENCODING;
}
@ -726,9 +727,9 @@ void XMLHttpRequestMainThread::SetResponseType(
}
// sync request is not allowed setting responseType in window context
if (HasOrHasHadOwner() && mState != XMLHttpRequest_Binding::UNSENT &&
if (HasOrHasHadOwnerWindow() && mState != XMLHttpRequest_Binding::UNSENT &&
mFlagSynchronous) {
LogMessage("ResponseTypeSyncXHRWarning", GetOwner());
LogMessage("ResponseTypeSyncXHRWarning", GetOwnerWindow());
aRv.ThrowInvalidAccessError(
"synchronous XMLHttpRequests do not support timeout and responseType");
return;
@ -1542,9 +1543,9 @@ void XMLHttpRequestMainThread::Open(const nsACString& aMethod,
NOT_CALLABLE_IN_SYNC_SEND_RV
// Gecko-specific
if (!aAsync && !DontWarnAboutSyncXHR() && GetOwner() &&
GetOwner()->GetExtantDoc()) {
GetOwner()->GetExtantDoc()->WarnOnceAbout(
if (!aAsync && !DontWarnAboutSyncXHR() && GetOwnerWindow() &&
GetOwnerWindow()->GetExtantDoc()) {
GetOwnerWindow()->GetExtantDoc()->WarnOnceAbout(
DeprecatedOperations::eSyncXMLHttpRequestDeprecated);
}
@ -1572,7 +1573,7 @@ void XMLHttpRequestMainThread::Open(const nsACString& aMethod,
}
// Gecko-specific
if (!aAsync && responsibleDocument && GetOwner()) {
if (!aAsync && responsibleDocument && GetOwnerWindow()) {
// We have no extant document during unload, so the above general
// syncXHR warning will not display. But we do want to display a
// recommendation to use sendBeacon instead of syncXHR during unload.
@ -1581,7 +1582,8 @@ void XMLHttpRequestMainThread::Open(const nsACString& aMethod,
bool inUnload = false;
shell->GetIsInUnload(&inUnload);
if (inUnload) {
LogMessage("UseSendBeaconDuringUnloadAndPagehideWarning", GetOwner());
LogMessage("UseSendBeaconDuringUnloadAndPagehideWarning",
GetOwnerWindow());
}
}
}
@ -1640,14 +1642,14 @@ void XMLHttpRequestMainThread::Open(const nsACString& aMethod,
}
// Step 9
if (!aAsync && HasOrHasHadOwner() &&
if (!aAsync && HasOrHasHadOwnerWindow() &&
(mTimeoutMilliseconds ||
mResponseType != XMLHttpRequestResponseType::_empty)) {
if (mTimeoutMilliseconds) {
LogMessage("TimeoutSyncXHRWarning", GetOwner());
LogMessage("TimeoutSyncXHRWarning", GetOwnerWindow());
}
if (mResponseType != XMLHttpRequestResponseType::_empty) {
LogMessage("ResponseTypeSyncXHRWarning", GetOwner());
LogMessage("ResponseTypeSyncXHRWarning", GetOwnerWindow());
}
aRv.ThrowInvalidAccessError(
"synchronous XMLHttpRequests do not support timeout and responseType");
@ -2492,7 +2494,7 @@ void XMLHttpRequestMainThread::ChangeStateToDone(bool aWasSync) {
nsLoadFlags loadFlags = 0;
mChannel->GetLoadFlags(&loadFlags);
if (loadFlags & nsIRequest::LOAD_BACKGROUND) {
nsPIDOMWindowInner* owner = GetOwner();
nsPIDOMWindowInner* owner = GetOwnerWindow();
BrowsingContext* bc = owner ? owner->GetBrowsingContext() : nullptr;
bc = bc ? bc->Top() : nullptr;
if (bc && bc->IsLoading()) {
@ -2746,7 +2748,7 @@ nsresult XMLHttpRequestMainThread::InitiateFetch(
mAuthorRequestHeaders.ApplyToChannel(httpChannel, false, false);
if (!IsSystemXHR()) {
nsCOMPtr<nsPIDOMWindowInner> owner = GetOwner();
nsCOMPtr<nsPIDOMWindowInner> owner = GetOwnerWindow();
nsCOMPtr<Document> doc = owner ? owner->GetExtantDoc() : nullptr;
nsCOMPtr<nsIReferrerInfo> referrerInfo =
ReferrerInfo::CreateForFetch(mPrincipal, doc);
@ -3246,9 +3248,9 @@ void XMLHttpRequestMainThread::SendInternal(const BodyExtractorBase* aBody,
mFlagSyncLooping = true;
if (GetOwner()) {
if (GetOwnerWindow()) {
if (nsCOMPtr<nsPIDOMWindowOuter> topWindow =
GetOwner()->GetOuterWindow()->GetInProcessTop()) {
GetOwnerWindow()->GetOuterWindow()->GetInProcessTop()) {
if (nsCOMPtr<nsPIDOMWindowInner> topInner =
topWindow->GetCurrentInnerWindow()) {
suspendedDoc = topWindow->GetExtantDoc();
@ -3341,7 +3343,7 @@ void XMLHttpRequestMainThread::SetRequestHeader(const nsACString& aName,
if (!isPrivilegedCaller && isForbiddenHeader) {
AutoTArray<nsString, 1> params;
CopyUTF8toUTF16(aName, *params.AppendElement());
LogMessage("ForbiddenHeaderWarning", GetOwner(), params);
LogMessage("ForbiddenHeaderWarning", GetOwnerWindow(), params);
return;
}
@ -3363,10 +3365,10 @@ void XMLHttpRequestMainThread::SetTimeout(uint32_t aTimeout, ErrorResult& aRv) {
NOT_CALLABLE_IN_SYNC_SEND_RV
if (mFlagSynchronous && mState != XMLHttpRequest_Binding::UNSENT &&
HasOrHasHadOwner()) {
HasOrHasHadOwnerWindow()) {
/* Timeout is not supported for synchronous requests with an owning window,
per XHR2 spec. */
LogMessage("TimeoutSyncXHRWarning", GetOwner());
LogMessage("TimeoutSyncXHRWarning", GetOwnerWindow());
aRv.ThrowInvalidAccessError(
"synchronous XMLHttpRequests do not support timeout and responseType");
return;
@ -3692,8 +3694,8 @@ XMLHttpRequestMainThread::GetInterface(const nsIID& aIID, void** aResult) {
// Get the an auth prompter for our window so that the parenting
// of the dialogs works as it should when using tabs.
nsCOMPtr<nsPIDOMWindowOuter> window;
if (GetOwner()) {
window = GetOwner()->GetOuterWindow();
if (nsGlobalWindowInner* inner = GetOwnerWindow()) {
window = inner->GetOuterWindow();
}
return wwatch->GetPrompt(window, aIID, reinterpret_cast<void**>(aResult));
}

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

@ -8,8 +8,8 @@
#include "mozilla/dom/nsMixedContentBlocker.h"
#include "mozilla/glean/GleanMetrics.h"
#include "mozilla/net/Cookie.h"
#include "mozilla/StaticPrefs_network.h"
#include "mozilla/Telemetry.h"
#include "nsIConsoleReportCollector.h"
#include "nsIScriptError.h"
#include "nsIURI.h"