From 477b6576b706982fc9b6b44a2a7dd349bff5fe36 Mon Sep 17 00:00:00 2001 From: Marco Bonardo Date: Mon, 11 Jul 2011 10:27:58 -0700 Subject: [PATCH] Backout changesets 9e4ab3907b29, 3abc0dbbf710 due to m-oth permaorange --- browser/base/content/tabbrowser.xml | 11 +----- browser/base/content/test/Makefile.in | 1 - browser/base/content/test/browser_minimize.js | 9 ----- dom/base/nsGlobalWindow.h | 3 +- dom/base/nsPIDOMWindow.h | 10 ++---- .../src/nsAutoWindowStateHelper.cpp | 35 ++++++++++++++++--- xpfe/appshell/src/nsWebShellWindow.cpp | 15 ++++---- 7 files changed, 42 insertions(+), 42 deletions(-) delete mode 100644 browser/base/content/test/browser_minimize.js diff --git a/browser/base/content/tabbrowser.xml b/browser/base/content/tabbrowser.xml index 89500c50e60..9d36c2b5f30 100644 --- a/browser/base/content/tabbrowser.xml +++ b/browser/base/content/tabbrowser.xml @@ -867,8 +867,7 @@ updatePageReport = true; newBrowser.setAttribute("type", "content-primary"); - newBrowser.docShellIsActive = - (window.windowState != window.STATE_MINIMIZED); + newBrowser.docShellIsActive = true; this.mCurrentBrowser = newBrowser; this.mCurrentTab = this.selectedTab; this.showTab(this.mCurrentTab); @@ -2464,12 +2463,6 @@ case "keypress": this._handleKeyEvent(aEvent); break; - case "sizemodechange": - if (aEvent.target == window) { - this.mCurrentBrowser.docShellIsActive = - (window.windowState != window.STATE_MINIMIZED); - } - break; } ]]> @@ -2479,7 +2472,6 @@ this.mCurrentBrowser = this.mPanelContainer.childNodes[0].firstChild.firstChild; this.mCurrentTab = this.tabContainer.firstChild; document.addEventListener("keypress", this, false); - window.addEventListener("sizemodechange", this, false); var uniqueId = "panel" + Date.now(); this.mPanelContainer.childNodes[0].id = uniqueId; @@ -2542,7 +2534,6 @@ this.mTabListeners[i] = null; } document.removeEventListener("keypress", this, false); - window.removeEventListener("sizemodechange", this, false); ]]> diff --git a/browser/base/content/test/Makefile.in b/browser/base/content/test/Makefile.in index d1284543fbc..3c1eb8f9ff8 100644 --- a/browser/base/content/test/Makefile.in +++ b/browser/base/content/test/Makefile.in @@ -256,7 +256,6 @@ _BROWSER_FILES = \ browser_addon_bar_shortcut.js \ browser_addon_bar_aomlistener.js \ test_bug628179.html \ - browser_minimize.js \ $(NULL) ifneq (cocoa,$(MOZ_WIDGET_TOOLKIT)) diff --git a/browser/base/content/test/browser_minimize.js b/browser/base/content/test/browser_minimize.js deleted file mode 100644 index ef921e4158e..00000000000 --- a/browser/base/content/test/browser_minimize.js +++ /dev/null @@ -1,9 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ */ -function test() { - is(gBrowser.docShellIsActive, true, "Docshell should be active"); - window.minimize(); - is(gBrowser.docShellIsActive, false, "Docshell should be inactive"); - window.restore(); - is(gBrowser.docShellIsActive, true, "Docshell should be active again"); -} diff --git a/dom/base/nsGlobalWindow.h b/dom/base/nsGlobalWindow.h index e4e681530d2..4892e780a0b 100644 --- a/dom/base/nsGlobalWindow.h +++ b/dom/base/nsGlobalWindow.h @@ -383,7 +383,6 @@ public: virtual NS_HIDDEN_(void) SetHasOrientationEventListener(); virtual NS_HIDDEN_(void) MaybeUpdateTouchState(); virtual NS_HIDDEN_(void) UpdateTouchState(); - virtual NS_HIDDEN_(PRBool) DispatchCustomEvent(const char *aEventName); // nsIDOMStorageWindow NS_DECL_NSIDOMSTORAGEWINDOW @@ -730,6 +729,8 @@ protected: return GetParentInternal() != nsnull; } + PRBool DispatchCustomEvent(const char *aEventName); + // If aLookForCallerOnJSStack is true, this method will look at the JS stack // to determine who the caller is. If it's false, it'll use |this| as the // caller. diff --git a/dom/base/nsPIDOMWindow.h b/dom/base/nsPIDOMWindow.h index a5f362715af..f25c629e4cd 100644 --- a/dom/base/nsPIDOMWindow.h +++ b/dom/base/nsPIDOMWindow.h @@ -80,8 +80,8 @@ class nsIArray; class nsPIWindowRoot; #define NS_PIDOMWINDOW_IID \ -{ 0xa595249b, 0x1e74, 0x467e, \ - { 0x92, 0x56, 0x58, 0xff, 0x07, 0x1b, 0xc2, 0x96 } } +{ 0x6c05ae9d, 0x4ad1, 0x4e92, \ + { 0x9c, 0x95, 0xd3, 0x54, 0xea, 0x0f, 0xb9, 0x48 } } class nsPIDOMWindow : public nsIDOMWindowInternal { @@ -579,12 +579,6 @@ public: */ PRUint64 WindowID() const { return mWindowID; } - /** - * Dispatch a custom event with name aEventName targeted at this window. - * Returns whether the default action should be performed. - */ - virtual PRBool DispatchCustomEvent(const char *aEventName) = 0; - protected: // The nsPIDOMWindow constructor. The aOuterWindow argument should // be null if and only if the created window itself is an outer diff --git a/embedding/components/windowwatcher/src/nsAutoWindowStateHelper.cpp b/embedding/components/windowwatcher/src/nsAutoWindowStateHelper.cpp index f7a0e669334..d44166eb763 100644 --- a/embedding/components/windowwatcher/src/nsAutoWindowStateHelper.cpp +++ b/embedding/components/windowwatcher/src/nsAutoWindowStateHelper.cpp @@ -1,4 +1,4 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -75,11 +75,38 @@ nsAutoWindowStateHelper::~nsAutoWindowStateHelper() PRBool nsAutoWindowStateHelper::DispatchCustomEvent(const char *aEventName) { - nsCOMPtr window = do_QueryInterface(mWindow); - if (!window) { + if (!mWindow) { return PR_TRUE; } - return window->DispatchCustomEvent(aEventName); +#ifdef DEBUG + { + nsCOMPtr window(do_QueryInterface(mWindow)); + } +#endif + + nsCOMPtr domdoc; + mWindow->GetDocument(getter_AddRefs(domdoc)); + + nsCOMPtr event; + + PRBool defaultActionEnabled = PR_TRUE; + + if (domdoc) { + domdoc->CreateEvent(NS_LITERAL_STRING("Events"), getter_AddRefs(event)); + + nsCOMPtr privateEvent(do_QueryInterface(event)); + if (privateEvent) { + event->InitEvent(NS_ConvertASCIItoUTF16(aEventName), PR_TRUE, PR_TRUE); + + privateEvent->SetTrusted(PR_TRUE); + + nsCOMPtr target(do_QueryInterface(mWindow)); + + target->DispatchEvent(event, &defaultActionEnabled); + } + } + + return defaultActionEnabled; } diff --git a/xpfe/appshell/src/nsWebShellWindow.cpp b/xpfe/appshell/src/nsWebShellWindow.cpp index 203a99c53a6..c8fa8dcd2ae 100644 --- a/xpfe/appshell/src/nsWebShellWindow.cpp +++ b/xpfe/appshell/src/nsWebShellWindow.cpp @@ -381,16 +381,13 @@ nsWebShellWindow::HandleEvent(nsGUIEvent *aEvent) eventWindow->SetPersistenceTimer(PAD_MISC); result = nsEventStatus_eConsumeDoDefault; - nsCOMPtr ourWindow = do_GetInterface(docShell); - if (ourWindow) { - // Let the application know if it's in fullscreen mode so it - // can update its UI. - if (modeEvent->mSizeMode == nsSizeMode_Fullscreen) { + // min, max, and normal are all the same to apps, but for + // fullscreen we need to let them know so they can update + // their ui. + if (modeEvent->mSizeMode == nsSizeMode_Fullscreen) { + nsCOMPtr ourWindow = do_GetInterface(docShell); + if (ourWindow) ourWindow->SetFullScreen(PR_TRUE); - } - - // And always fire a user-defined sizemodechange event on the window - ourWindow->DispatchCustomEvent("sizemodechange"); } // Note the current implementation of SetSizeMode just stores