mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-29 07:42:04 +00:00
Bug 968804 - Part a: Add inner window assertions to DETH and {Add,Remove}EventTargetObject; r=peterv
This commit is contained in:
parent
54bd037fd0
commit
d02b9c0ccb
@ -1344,12 +1344,14 @@ nsGlobalWindow::~nsGlobalWindow()
|
||||
void
|
||||
nsGlobalWindow::AddEventTargetObject(DOMEventTargetHelper* aObject)
|
||||
{
|
||||
MOZ_ASSERT(IsInnerWindow());
|
||||
mEventTargetObjects.PutEntry(aObject);
|
||||
}
|
||||
|
||||
void
|
||||
nsGlobalWindow::RemoveEventTargetObject(DOMEventTargetHelper* aObject)
|
||||
{
|
||||
MOZ_ASSERT(IsInnerWindow());
|
||||
mEventTargetObjects.RemoveEntry(aObject);
|
||||
}
|
||||
|
||||
|
@ -696,6 +696,7 @@ public:
|
||||
|
||||
void UnmarkGrayTimers();
|
||||
|
||||
// Inner windows only.
|
||||
void AddEventTargetObject(mozilla::DOMEventTargetHelper* aObject);
|
||||
void RemoveEventTargetObject(mozilla::DOMEventTargetHelper* aObject);
|
||||
|
||||
|
@ -91,7 +91,7 @@ DOMEventTargetHelper::~DOMEventTargetHelper()
|
||||
void
|
||||
DOMEventTargetHelper::BindToOwner(nsPIDOMWindow* aOwner)
|
||||
{
|
||||
MOZ_ASSERT(!aOwner || aOwner->IsInnerWindow());
|
||||
MOZ_ASSERT_IF(aOwner, aOwner->IsInnerWindow());
|
||||
nsCOMPtr<nsIGlobalObject> glob = do_QueryInterface(aOwner);
|
||||
BindToOwner(glob);
|
||||
}
|
||||
@ -112,6 +112,7 @@ DOMEventTargetHelper::BindToOwner(nsIGlobalObject* aOwner)
|
||||
// Let's cache the result of this QI for fast access and off main thread usage
|
||||
mOwnerWindow = nsCOMPtr<nsPIDOMWindow>(do_QueryInterface(aOwner)).get();
|
||||
if (mOwnerWindow) {
|
||||
MOZ_ASSERT(mOwnerWindow->IsInnerWindow());
|
||||
mHasOrHasHadOwnerWindow = true;
|
||||
static_cast<nsGlobalWindow*>(mOwnerWindow)->AddEventTargetObject(this);
|
||||
}
|
||||
@ -134,6 +135,7 @@ DOMEventTargetHelper::BindToOwner(DOMEventTargetHelper* aOther)
|
||||
// Let's cache the result of this QI for fast access and off main thread usage
|
||||
mOwnerWindow = nsCOMPtr<nsPIDOMWindow>(do_QueryInterface(mParentObject)).get();
|
||||
if (mOwnerWindow) {
|
||||
MOZ_ASSERT(mOwnerWindow->IsInnerWindow());
|
||||
mHasOrHasHadOwnerWindow = true;
|
||||
static_cast<nsGlobalWindow*>(mOwnerWindow)->AddEventTargetObject(this);
|
||||
}
|
||||
|
@ -120,12 +120,8 @@ public:
|
||||
nsresult CheckInnerWindowCorrectness()
|
||||
{
|
||||
NS_ENSURE_STATE(!mHasOrHasHadOwnerWindow || mOwnerWindow);
|
||||
if (mOwnerWindow) {
|
||||
NS_ASSERTION(mOwnerWindow->IsInnerWindow(), "Should have inner window here!\n");
|
||||
nsPIDOMWindow* outer = mOwnerWindow->GetOuterWindow();
|
||||
if (!outer || outer->GetCurrentInnerWindow() != mOwnerWindow) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
if (mOwnerWindow && !mOwnerWindow->IsCurrentInnerWindow()) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
@ -159,7 +155,7 @@ protected:
|
||||
private:
|
||||
// Inner window or sandbox.
|
||||
nsIGlobalObject* mParentObject;
|
||||
// mParentObject pre QI-ed and cached
|
||||
// mParentObject pre QI-ed and cached (inner window)
|
||||
// (it is needed for off main thread access)
|
||||
nsPIDOMWindow* mOwnerWindow;
|
||||
bool mHasOrHasHadOwnerWindow;
|
||||
|
Loading…
Reference in New Issue
Block a user