Bug 868859 - Make chromeWindow.content work in e10s. r=bz

This commit is contained in:
Tom Schuster 2013-05-08 23:16:46 +02:00
parent 57fd2695a3
commit cb80974d17
12 changed files with 95 additions and 7 deletions

View File

@ -4433,6 +4433,10 @@ nsBrowserAccess.prototype = {
isTabContentWindow: function (aWindow) {
return gBrowser.browsers.some(function (browser) browser.contentWindow == aWindow);
},
get contentWindow() {
return gBrowser.contentWindow;
}
}

View File

@ -1205,6 +1205,10 @@ nsBrowserAccess.prototype = {
isTabContentWindow: function(aWindow) {
return Browser.browsers.some(function (browser) browser.contentWindow == aWindow);
},
get contentWindow() {
return Browser.selectedBrowser.contentWindow;
}
};

View File

@ -12,7 +12,7 @@
interface nsIDocShellTreeItem;
[scriptable, uuid(932f9f93-8e21-4728-a527-cafc64b4d831)]
[scriptable, uuid(6cd89e60-1060-491e-8c31-ce969435ec56)]
interface nsIDocShellTreeOwner : nsISupports
{
/*
@ -64,6 +64,9 @@ interface nsIDocShellTreeOwner : nsISupports
*/
readonly attribute nsIDocShellTreeItem primaryContentShell;
[implicit_jscontext]
readonly attribute jsval contentWindow;
/*
Tells the tree owner to size its window or parent window in such a way
that the shell passed along will be the size specified.

View File

@ -3618,6 +3618,28 @@ nsGlobalWindow::GetContent(nsIDOMWindow** aContent)
return NS_OK;
}
NS_IMETHODIMP
nsGlobalWindow::GetScriptableContent(JSContext* aCx, JS::Value* aVal)
{
nsCOMPtr<nsIDOMWindow> content;
nsresult rv = GetContent(getter_AddRefs(content));
NS_ENSURE_SUCCESS(rv, rv);
if (content || !nsContentUtils::IsCallerChrome() || !IsChromeWindow()) {
JS::Rooted<JSObject*> global(aCx, JS_GetGlobalForScopeChain(aCx));
if (content && global) {
nsCOMPtr<nsIXPConnectJSObjectHolder> wrapper;
return nsContentUtils::WrapNative(aCx, global, content, aVal,
getter_AddRefs(wrapper));
}
return NS_ERROR_FAILURE;
}
// Something tries to get .content on a ChromeWindow, try to fetch the CPOW.
nsCOMPtr<nsIDocShellTreeOwner> treeOwner = GetTreeOwner();
NS_ENSURE_TRUE(treeOwner, NS_ERROR_FAILURE);
return treeOwner->GetContentWindow(aCx, aVal);
}
NS_IMETHODIMP
nsGlobalWindow::GetPrompter(nsIPrompt** aPrompt)

View File

@ -9,7 +9,7 @@ interface nsIDOMWindow;
interface nsIURI;
interface nsIFrameLoaderOwner;
[scriptable, uuid(3ab89888-eb41-4dc8-b347-115555f47c80)]
[scriptable, uuid(e420bd32-b8c4-4b47-8cca-09e0bddbb0c3)]
/**
* The C++ source has access to the browser script source through
@ -92,5 +92,12 @@ interface nsIBrowserDOMWindow : nsISupports
* currently open tab in this toplevel browser window.
*/
boolean isTabContentWindow(in nsIDOMWindow aWindow);
/**
* The contentWindow property of the currently selected browser.
* This is used to implement .content in remote-Firefox.
*/
readonly attribute jsval contentWindow;
};

View File

@ -5,7 +5,7 @@
#include "domstubs.idl"
[scriptable, uuid(35b653f4-e679-4843-8391-89cb2f5a9ba4)]
[scriptable, uuid(f28c92a2-302a-4448-b589-46af599de352)]
interface nsIDOMJSWindow : nsISupports
{
void dump(in DOMString str);
@ -66,4 +66,7 @@ interface nsIDOMJSWindow : nsISupports
* This property is "replaceable" in JavaScript.
*/
readonly attribute nsIDOMWindow frames;
[implicit_jscontext, binaryname(ScriptableContent)]
readonly attribute jsval content;
};

View File

@ -25,7 +25,7 @@ interface nsIVariant;
* @see <http://www.whatwg.org/html/#window>
*/
[scriptable, uuid(be62660a-e3f6-409c-a4a9-378364a9526f)]
[scriptable, uuid(db8ea3c8-6997-460a-8715-0a1cbf20f15d)]
interface nsIDOMWindow : nsISupports
{
// the current browsing context
@ -360,7 +360,7 @@ interface nsIDOMWindow : nsISupports
void sizeToContent();
/* [replaceable] content */
readonly attribute nsIDOMWindow content;
[noscript] readonly attribute nsIDOMWindow content;
/* [replaceable] prompter */
[noscript] readonly attribute nsIPrompt prompter;

View File

@ -253,6 +253,9 @@
},
openDialog: function(aType, aName, aFeatures, aArguments, aFrameElement) {
alert(aType + ", " + aName + ", " + aFeatures + ", " + aArguments + ", " + aFrameElement);
},
get contentWindow() {
return null;
}
}

View File

@ -353,7 +353,7 @@ nsDocShellTreeOwner::GetPrimaryContentShell(nsIDocShellTreeItem** aShell)
{
NS_ENSURE_ARG_POINTER(aShell);
if(mTreeOwner)
if (mTreeOwner)
return mTreeOwner->GetPrimaryContentShell(aShell);
*aShell = (mPrimaryContentShell ? mPrimaryContentShell : mWebBrowser->mDocShell);
@ -362,6 +362,15 @@ nsDocShellTreeOwner::GetPrimaryContentShell(nsIDocShellTreeItem** aShell)
return NS_OK;
}
NS_IMETHODIMP
nsDocShellTreeOwner::GetContentWindow(JSContext* aCx, JS::Value* aVal)
{
if (mTreeOwner)
return mTreeOwner->GetContentWindow(aCx, aVal);
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsDocShellTreeOwner::SizeShellTo(nsIDocShellTreeItem* aShellItem,
int32_t aCX, int32_t aCY)

View File

@ -2492,6 +2492,10 @@ nsBrowserAccess.prototype = {
isTabContentWindow: function(aWindow) {
return BrowserApp.getBrowserForWindow(aWindow) != null;
},
get contentWindow() {
return BrowserApp.selectedBrowser.contentWindow;
}
};

View File

@ -24,6 +24,8 @@
#include "nsIDOMNodeList.h"
#include "nsIDOMXULElement.h"
#include "nsIXULBrowserWindow.h"
#include "nsIDOMChromeWindow.h"
#include "nsIBrowserDOMWindow.h"
// CIDs
static NS_DEFINE_CID(kWindowMediatorCID, NS_WINDOWMEDIATOR_CID);
@ -245,6 +247,25 @@ NS_IMETHODIMP nsChromeTreeOwner::GetPrimaryContentShell(nsIDocShellTreeItem** aS
return mXULWindow->GetPrimaryContentShell(aShell);
}
NS_IMETHODIMP
nsChromeTreeOwner::GetContentWindow(JSContext* aCx, JS::Value* aVal)
{
NS_ENSURE_STATE(mXULWindow);
nsCOMPtr<nsIDOMWindow> domWin;
mXULWindow->GetWindowDOMWindow(getter_AddRefs(domWin));
nsCOMPtr<nsIDOMChromeWindow> chromeWin = do_QueryInterface(domWin);
if (!chromeWin)
return NS_OK;
nsCOMPtr<nsIBrowserDOMWindow> browserDOMWin;
chromeWin->GetBrowserDOMWindow(getter_AddRefs(browserDOMWin));
if (!browserDOMWin)
return NS_OK;
return browserDOMWin->GetContentWindow(aVal);
}
NS_IMETHODIMP nsChromeTreeOwner::SizeShellTo(nsIDocShellTreeItem* aShellItem,
int32_t aCX, int32_t aCY)
{

View File

@ -292,12 +292,20 @@ nsContentTreeOwner::ContentShellRemoved(nsIDocShellTreeItem* aContentShell)
return mXULWindow->ContentShellRemoved(aContentShell);
}
NS_IMETHODIMP nsContentTreeOwner::GetPrimaryContentShell(nsIDocShellTreeItem** aShell)
NS_IMETHODIMP
nsContentTreeOwner::GetPrimaryContentShell(nsIDocShellTreeItem** aShell)
{
NS_ENSURE_STATE(mXULWindow);
return mXULWindow->GetPrimaryContentShell(aShell);
}
NS_IMETHODIMP
nsContentTreeOwner::GetContentWindow(JSContext* aCx, JS::Value* aVal)
{
NS_ENSURE_STATE(mXULWindow);
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsContentTreeOwner::SizeShellTo(nsIDocShellTreeItem* aShellItem,
int32_t aCX, int32_t aCY)
{