Bug 932309 - Don't null out mDoc in nsGlobalWindow::FreeInnerObjects. r=smaug.

--HG--
extra : rebase_source : 098d932b2bb70575aa007788588b0fe51e71f838
This commit is contained in:
Peter Van der Beken 2013-10-16 18:11:24 +02:00
parent d0d07c21e8
commit ea7c9c2153
3 changed files with 24 additions and 11 deletions

View File

@ -1509,7 +1509,6 @@ nsGlobalWindow::FreeInnerObjects()
}
// Remove our reference to the document and the document principal.
mDoc = nullptr;
mFocusedNode = nullptr;
if (mApplicationCache) {
@ -8911,6 +8910,9 @@ NS_IMPL_REMOVE_SYSTEM_EVENT_LISTENER(nsGlobalWindow)
NS_IMETHODIMP
nsGlobalWindow::DispatchEvent(nsIDOMEvent* aEvent, bool* aRetVal)
{
MOZ_ASSERT(!IsInnerWindow() || IsCurrentInnerWindow(),
"We should only fire events on the current inner window.");
FORWARD_TO_INNER(DispatchEvent, (aEvent, aRetVal), NS_OK);
if (!mDoc) {
@ -9040,10 +9042,7 @@ nsIScriptContext*
nsGlobalWindow::GetContextForEventHandlers(nsresult* aRv)
{
*aRv = NS_ERROR_UNEXPECTED;
if (IsInnerWindow()) {
nsPIDOMWindow* outer = GetOuterWindow();
NS_ENSURE_TRUE(outer && outer->GetCurrentInnerWindow() == this, nullptr);
}
NS_ENSURE_TRUE(!IsInnerWindow() || IsCurrentInnerWindow(), nullptr);
nsIScriptContext* scx;
if ((scx = GetContext())) {
@ -10699,7 +10698,7 @@ nsGlobalWindow::Observe(nsISupports* aSubject, const char* aTopic,
// need to fire only one idle event while the window is frozen.
mNotifyIdleObserversIdleOnThaw = true;
mNotifyIdleObserversActiveOnThaw = false;
} else if (mOuterWindow && mOuterWindow->GetCurrentInnerWindow() == this) {
} else if (IsCurrentInnerWindow()) {
HandleIdleActiveEvent();
}
return NS_OK;
@ -10710,13 +10709,17 @@ nsGlobalWindow::Observe(nsISupports* aSubject, const char* aTopic,
if (IsFrozen()) {
mNotifyIdleObserversActiveOnThaw = true;
mNotifyIdleObserversIdleOnThaw = false;
} else if (mOuterWindow && mOuterWindow->GetCurrentInnerWindow() == this) {
} else if (IsCurrentInnerWindow()) {
ScheduleActiveTimerCallback();
}
return NS_OK;
}
if (IsInnerWindow() && !nsCRT::strcmp(aTopic, "dom-storage2-changed")) {
if (!nsCRT::strcmp(aTopic, "dom-storage2-changed")) {
if (!IsInnerWindow() || !IsCurrentInnerWindow()) {
return NS_OK;
}
nsIPrincipal *principal;
nsresult rv;

View File

@ -327,6 +327,15 @@ public:
return mIsInnerWindow;
}
// Returns true if this object has an outer window and it is the current inner
// window of that outer. Only call this on inner windows.
bool IsCurrentInnerWindow() const
{
MOZ_ASSERT(IsInnerWindow(),
"It doesn't make sense to call this on outer windows.");
return mOuterWindow && mOuterWindow->GetCurrentInnerWindow() == this;
}
bool IsOuterWindow() const
{
return !IsInnerWindow();

View File

@ -209,7 +209,7 @@ GamepadService::NewButtonEvent(uint32_t aIndex, uint32_t aButton, bool aPressed,
--i;
// Only send events to non-background windows
if (!listeners[i]->GetOuterWindow() ||
if (!listeners[i]->IsCurrentInnerWindow() ||
listeners[i]->GetOuterWindow()->IsBackground()) {
continue;
}
@ -274,7 +274,7 @@ GamepadService::NewAxisMoveEvent(uint32_t aIndex, uint32_t aAxis, double aValue)
--i;
// Only send events to non-background windows
if (!listeners[i]->GetOuterWindow() ||
if (!listeners[i]->IsCurrentInnerWindow() ||
listeners[i]->GetOuterWindow()->IsBackground()) {
continue;
}
@ -340,7 +340,7 @@ GamepadService::NewConnectionEvent(uint32_t aIndex, bool aConnected)
--i;
// Only send events to non-background windows
if (!listeners[i]->GetOuterWindow() ||
if (!listeners[i]->IsCurrentInnerWindow() ||
listeners[i]->GetOuterWindow()->IsBackground()) {
continue;
}
@ -525,6 +525,7 @@ GamepadServiceTest::CreateService()
GamepadServiceTest::GamepadServiceTest()
{
/* member initializers and constructor code */
nsRefPtr<GamepadService> service = GamepadService::GetService();
}
/* uint32_t addGamepad (in string id, in unsigned long mapping, in unsigned long numButtons, in unsigned long numAxes); */