Bug 968804 - Part m: Add outer window assertions to DispatchCustomEvent; r=khuey

This commit is contained in:
Ms2ger 2014-06-29 17:31:13 +02:00
parent 00a3b7c101
commit 71fc09547a
5 changed files with 16 additions and 11 deletions

View File

@ -5818,12 +5818,12 @@ nsGlobalWindow::GetChildWindow(const nsAString& aName)
}
bool
nsGlobalWindow::DispatchCustomEvent(const char *aEventName)
nsGlobalWindow::DispatchCustomEvent(const nsAString& aEventName)
{
MOZ_ASSERT(IsOuterWindow());
bool defaultActionEnabled = true;
nsContentUtils::DispatchTrustedEvent(mDoc,
GetOuterWindow(),
NS_ConvertASCIItoUTF16(aEventName),
nsContentUtils::DispatchTrustedEvent(mDoc, ToSupports(this), aEventName,
true, true, &defaultActionEnabled);
return defaultActionEnabled;
@ -5999,7 +5999,7 @@ nsGlobalWindow::SetFullScreenInternal(bool aFullScreen, bool aRequireTrust)
// dispatch a "fullscreen" DOM event so that XUL apps can
// respond visually if we are kicked into full screen mode
if (!DispatchCustomEvent("fullscreen")) {
if (!DispatchCustomEvent(NS_LITERAL_STRING("fullscreen"))) {
return NS_OK;
}
@ -8435,7 +8435,7 @@ nsGlobalWindow::Close(ErrorResult& aError)
bool wasInClose = mInClose;
mInClose = true;
if (!DispatchCustomEvent("DOMWindowClose")) {
if (!DispatchCustomEvent(NS_LITERAL_STRING("DOMWindowClose"))) {
// Someone chose to prevent the default action for this event, if
// so, let's not close this window after all...
@ -8474,7 +8474,7 @@ nsGlobalWindow::ForceClose()
mInClose = true;
DispatchCustomEvent("DOMWindowClose");
DispatchCustomEvent(NS_LITERAL_STRING("DOMWindowClose"));
FinalClose();
}

View File

@ -487,9 +487,9 @@ public:
virtual void MaybeUpdateTouchState();
virtual void UpdateTouchState();
virtual bool DispatchCustomEvent(const char *aEventName);
// Outer windows only.
virtual bool DispatchCustomEvent(const nsAString& aEventName);
bool DispatchResizeEvent(const mozilla::CSSIntSize& aSize);
virtual void RefreshCompartmentPrincipal();

View File

@ -677,8 +677,10 @@ public:
/**
* Dispatch a custom event with name aEventName targeted at this window.
* Returns whether the default action should be performed.
*
* Outer windows only.
*/
virtual bool DispatchCustomEvent(const char *aEventName) = 0;
virtual bool DispatchCustomEvent(const nsAString& aEventName) = 0;
/**
* Notify the active inner window that the document principal may have changed

View File

@ -152,7 +152,8 @@ nsXULAlerts::CloseAlert(const nsAString& aAlertName)
nsIDOMWindow* alert = mNamedWindows.GetWeak(aAlertName);
nsCOMPtr<nsPIDOMWindow> domWindow = do_QueryInterface(alert);
if (domWindow) {
domWindow->DispatchCustomEvent("XULAlertClose");
MOZ_ASSERT(domWindow->IsOuterWindow());
domWindow->DispatchCustomEvent(NS_LITERAL_STRING("XULAlertClose"));
}
return NS_OK;
}

View File

@ -330,6 +330,8 @@ nsWebShellWindow::SizeModeChanged(nsSizeMode sizeMode)
nsCOMPtr<nsPIDOMWindow> ourWindow =
mDocShell ? mDocShell->GetWindow() : nullptr;
if (ourWindow) {
MOZ_ASSERT(ourWindow->IsOuterWindow());
// Let the application know if it's in fullscreen mode so it
// can update its UI.
if (sizeMode == nsSizeMode_Fullscreen) {
@ -340,7 +342,7 @@ nsWebShellWindow::SizeModeChanged(nsSizeMode sizeMode)
}
// And always fire a user-defined sizemodechange event on the window
ourWindow->DispatchCustomEvent("sizemodechange");
ourWindow->DispatchCustomEvent(NS_LITERAL_STRING("sizemodechange"));
}
// Note the current implementation of SetSizeMode just stores