Back out bb4938013af5 and 9bee7d808f97 (bug 827976) for marionette bustage

CLOSED TREE
This commit is contained in:
Phil Ringnalda 2013-02-20 15:26:59 -08:00
Родитель 66b90e22d5
Коммит e50d83b80b
5 изменённых файлов: 71 добавлений и 41 удалений

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

@ -359,16 +359,12 @@ nsCCUncollectableMarker::Observe(nsISupports* aSubject, const char* aTopic,
do_GetService(NS_APPSHELLSERVICE_CONTRACTID);
if (appShell) {
nsCOMPtr<nsIXULWindow> hw;
bool hasHiddenWindow = false;
appShell->GetHasHiddenWindow(&hasHiddenWindow);
if (hasHiddenWindow) {
appShell->GetHiddenWindow(getter_AddRefs(hw));
if (hw) {
nsCOMPtr<nsIDocShell> shell;
hw->GetDocShell(getter_AddRefs(shell));
nsCOMPtr<nsIDocShellTreeNode> shellTreeNode = do_QueryInterface(shell);
MarkDocShell(shellTreeNode, cleanupJS, prepareForCC);
}
appShell->GetHiddenWindow(getter_AddRefs(hw));
if (hw) {
nsCOMPtr<nsIDocShell> shell;
hw->GetDocShell(getter_AddRefs(shell));
nsCOMPtr<nsIDocShellTreeNode> shellTreeNode = do_QueryInterface(shell);
MarkDocShell(shellTreeNode, cleanupJS, prepareForCC);
}
bool hasHiddenPrivateWindow = false;
appShell->GetHasHiddenPrivateWindow(&hasHiddenPrivateWindow);

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

@ -3803,12 +3803,8 @@ XREMain::XRE_mainRun()
SaveToEnv("XRE_BINARY_PATH=");
if (!mShuttingDown) {
#ifdef XP_MACOSX
// The hidden window is always needed on Mac to provide the menu bar
// when no other windows are open.
rv = appStartup->CreateHiddenWindow();
NS_ENSURE_SUCCESS(rv, NS_ERROR_FAILURE);
#endif
#if defined(HAVE_DESKTOP_STARTUP_ID) && defined(MOZ_WIDGET_GTK)
nsGTKToolkit* toolkit = nsGTKToolkit::GetToolkit();

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

@ -16,7 +16,7 @@ interface nsIAppShell;
struct JSContext;
%}
[scriptable, uuid(1a15727f-ab2e-46cd-ac7f-39f12f30eef5)]
[scriptable, uuid(5c19ab54-67bf-46d0-ac5b-21abd9050c3b)]
interface nsIAppShellService : nsISupports
{
/**
@ -82,6 +82,17 @@ interface nsIAppShellService : nsISupports
*/
readonly attribute nsIDOMWindow hiddenPrivateDOMWindow;
/**
* Return the (singleton) application hidden window as an nsIDOMWindow,
* and, the corresponding JavaScript context pointer. This is useful
* if you'd like to subsequently call OpenDialog on the hidden window.
* @aHiddenDOMWindow the hidden window QI'd to type nsIDOMWindow
* @aJSContext the corresponding JavaScript context
*/
[noscript]
void getHiddenWindowAndJSContext(out nsIDOMWindow aHiddenDOMWindow,
out JSContext aJSContext);
/**
* Return true if the application hidden window was provided by the
* application. If it wasn't, the default hidden window was used. This will
@ -107,12 +118,6 @@ interface nsIAppShellService : nsISupports
*/
void unregisterTopLevelWindow(in nsIXULWindow aWindow);
/**
* Whether the hidden non-private window has been lazily created.
*/
[noscript]
readonly attribute boolean hasHiddenWindow;
/**
* Whether the hidden private window has been lazily created.
*/

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

@ -29,6 +29,11 @@
#include "nsWidgetsCID.h"
#include "nsIRequestObserver.h"
/* For implementing GetHiddenWindowAndJSContext */
#include "nsIScriptGlobalObject.h"
#include "nsIScriptContext.h"
#include "jsapi.h"
#include "nsAppShellService.h"
#include "nsISupportsPrimitives.h"
#include "nsIPlatformCharset.h"
@ -81,12 +86,6 @@ nsAppShellService::CreateHiddenWindow()
return CreateHiddenWindowHelper(false);
}
void
nsAppShellService::EnsureHiddenWindow()
{
CreateHiddenWindow();
}
void
nsAppShellService::EnsurePrivateHiddenWindow()
{
@ -438,8 +437,6 @@ nsAppShellService::GetHiddenWindow(nsIXULWindow **aWindow)
{
NS_ENSURE_ARG_POINTER(aWindow);
EnsureHiddenWindow();
*aWindow = mHiddenWindow;
NS_IF_ADDREF(*aWindow);
return *aWindow ? NS_OK : NS_ERROR_FAILURE;
@ -448,8 +445,6 @@ nsAppShellService::GetHiddenWindow(nsIXULWindow **aWindow)
NS_IMETHODIMP
nsAppShellService::GetHiddenDOMWindow(nsIDOMWindow **aWindow)
{
EnsureHiddenWindow();
nsresult rv;
nsCOMPtr<nsIDocShell> docShell;
NS_ENSURE_TRUE(mHiddenWindow, NS_ERROR_FAILURE);
@ -477,15 +472,6 @@ nsAppShellService::GetHiddenPrivateWindow(nsIXULWindow **aWindow)
return *aWindow ? NS_OK : NS_ERROR_FAILURE;
}
NS_IMETHODIMP
nsAppShellService::GetHasHiddenWindow(bool* aHasHiddenWindow)
{
NS_ENSURE_ARG_POINTER(aHasHiddenWindow);
*aHasHiddenWindow = !!mHiddenWindow;
return NS_OK;
}
NS_IMETHODIMP
nsAppShellService::GetHiddenPrivateDOMWindow(nsIDOMWindow **aWindow)
{
@ -515,6 +501,54 @@ nsAppShellService::GetHasHiddenPrivateWindow(bool* aHasPrivateWindow)
return NS_OK;
}
NS_IMETHODIMP
nsAppShellService::GetHiddenWindowAndJSContext(nsIDOMWindow **aWindow,
JSContext **aJSContext)
{
nsresult rv = NS_OK;
if ( aWindow && aJSContext ) {
*aWindow = nullptr;
*aJSContext = nullptr;
if ( mHiddenWindow ) {
// Convert hidden window to nsIDOMWindow and extract its JSContext.
do {
// 1. Get doc for hidden window.
nsCOMPtr<nsIDocShell> docShell;
rv = mHiddenWindow->GetDocShell(getter_AddRefs(docShell));
if (NS_FAILED(rv)) break;
// 2. Convert that to an nsIDOMWindow.
nsCOMPtr<nsIDOMWindow> hiddenDOMWindow(do_GetInterface(docShell));
if(!hiddenDOMWindow) break;
// 3. Get script global object for the window.
nsCOMPtr<nsIScriptGlobalObject> sgo;
sgo = do_QueryInterface( hiddenDOMWindow );
if (!sgo) { rv = NS_ERROR_FAILURE; break; }
// 4. Get script context from that.
nsIScriptContext *scriptContext = sgo->GetContext();
if (!scriptContext) { rv = NS_ERROR_FAILURE; break; }
// 5. Get JSContext from the script context.
JSContext *jsContext = scriptContext->GetNativeContext();
if (!jsContext) { rv = NS_ERROR_FAILURE; break; }
// Now, give results to caller.
*aWindow = hiddenDOMWindow.get();
NS_IF_ADDREF( *aWindow );
*aJSContext = jsContext;
} while (0);
} else {
rv = NS_ERROR_FAILURE;
}
} else {
rv = NS_ERROR_NULL_POINTER;
}
return rv;
}
NS_IMETHODIMP
nsAppShellService::GetApplicationProvidedHiddenWindow(bool* aAPHW)
{

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

@ -33,7 +33,6 @@ protected:
~nsAppShellService();
nsresult CreateHiddenWindowHelper(bool aIsPrivate);
void EnsureHiddenWindow();
void EnsurePrivateHiddenWindow();
nsresult JustCreateTopWindow(nsIXULWindow *aParent,