From 794b785d59a67ea6cba7772a8b981e079ac6de9a Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Mon, 19 Jul 2010 13:33:33 -0500 Subject: [PATCH] Bug 559534: Forward nsIXULWindow.chromeFlags to remote tabs. sr=bsmedberg --- content/base/src/nsFrameLoader.cpp | 17 ++++++++++++++++- dom/ipc/ContentChild.cpp | 4 ++-- dom/ipc/ContentChild.h | 2 +- dom/ipc/ContentParent.cpp | 6 +++--- dom/ipc/ContentParent.h | 4 ++-- dom/ipc/PContent.ipdl | 2 +- dom/ipc/TabChild.cpp | 10 +++++++--- dom/ipc/TabChild.h | 3 ++- xpfe/appshell/public/nsIXULWindow.idl | 9 ++++++++- xpfe/appshell/src/nsXULWindow.cpp | 10 ++++++++++ xpfe/appshell/src/nsXULWindow.h | 1 + 11 files changed, 53 insertions(+), 15 deletions(-) diff --git a/content/base/src/nsFrameLoader.cpp b/content/base/src/nsFrameLoader.cpp index f4e3e9cdabf..654c50a92a3 100644 --- a/content/base/src/nsFrameLoader.cpp +++ b/content/base/src/nsFrameLoader.cpp @@ -91,6 +91,7 @@ #include "nsISHistory.h" #include "nsISHistoryInternal.h" #include "nsIDOMNSHTMLDocument.h" +#include "nsIXULWindow.h" #include "nsLayoutUtils.h" #include "nsIView.h" @@ -1651,9 +1652,23 @@ nsFrameLoader::TryNewProcess() return false; } + PRUint32 chromeFlags = 0; + nsCOMPtr parentOwner; + if (NS_FAILED(parentAsItem->GetTreeOwner(getter_AddRefs(parentOwner))) || + !parentOwner) { + return false; + } + nsCOMPtr window(do_GetInterface(parentOwner)); + if (!window) { + return false; + } + if (NS_FAILED(window->GetChromeFlags(&chromeFlags))) { + return false; + } + ContentParent* parent = ContentParent::GetSingleton(); NS_ASSERTION(parent->IsAlive(), "Process parent should be alive; something is very wrong!"); - mRemoteBrowser = parent->CreateTab(); + mRemoteBrowser = parent->CreateTab(chromeFlags); if (mRemoteBrowser) { nsCOMPtr element = do_QueryInterface(mOwnerContent); mRemoteBrowser->SetOwnerElement(element); diff --git a/dom/ipc/ContentChild.cpp b/dom/ipc/ContentChild.cpp index bba0b89fd25..b301c20391a 100644 --- a/dom/ipc/ContentChild.cpp +++ b/dom/ipc/ContentChild.cpp @@ -83,9 +83,9 @@ ContentChild::Init(MessageLoop* aIOLoop, } PBrowserChild* -ContentChild::AllocPBrowser() +ContentChild::AllocPBrowser(const PRUint32& aChromeFlags) { - nsRefPtr iframe = new TabChild(); + nsRefPtr iframe = new TabChild(aChromeFlags); return NS_SUCCEEDED(iframe->Init()) ? iframe.forget().get() : NULL; } diff --git a/dom/ipc/ContentChild.h b/dom/ipc/ContentChild.h index fa6bd89712a..06250f01ef2 100644 --- a/dom/ipc/ContentChild.h +++ b/dom/ipc/ContentChild.h @@ -133,7 +133,7 @@ public: /* if you remove this, please talk to cjones or dougt */ virtual bool RecvDummy(Shmem& foo) { return true; } - virtual PBrowserChild* AllocPBrowser(); + virtual PBrowserChild* AllocPBrowser(const PRUint32& aChromeFlags); virtual bool DeallocPBrowser(PBrowserChild*); virtual PTestShellChild* AllocPTestShell(); diff --git a/dom/ipc/ContentParent.cpp b/dom/ipc/ContentParent.cpp index 2bb50c4bd58..72ef2a34687 100644 --- a/dom/ipc/ContentParent.cpp +++ b/dom/ipc/ContentParent.cpp @@ -119,9 +119,9 @@ ContentParent::ActorDestroy(ActorDestroyReason why) } TabParent* -ContentParent::CreateTab() +ContentParent::CreateTab(PRUint32 aChromeFlags) { - return static_cast(SendPBrowserConstructor()); + return static_cast(SendPBrowserConstructor(aChromeFlags)); } TestShellParent* @@ -361,7 +361,7 @@ ContentParent::Observe(nsISupports* aSubject, } PBrowserParent* -ContentParent::AllocPBrowser() +ContentParent::AllocPBrowser(const PRUint32& aChromeFlags) { TabParent* parent = new TabParent(); if (parent){ diff --git a/dom/ipc/ContentParent.h b/dom/ipc/ContentParent.h index 5796bfab2c9..cd46534817a 100644 --- a/dom/ipc/ContentParent.h +++ b/dom/ipc/ContentParent.h @@ -80,7 +80,7 @@ public: NS_DECL_NSIOBSERVER NS_DECL_NSITHREADOBSERVER - TabParent* CreateTab(); + TabParent* CreateTab(PRUint32 aChromeFlags); TestShellParent* CreateTestShell(); bool DestroyTestShell(TestShellParent* aTestShell); @@ -104,7 +104,7 @@ private: ContentParent(); virtual ~ContentParent(); - virtual PBrowserParent* AllocPBrowser(); + virtual PBrowserParent* AllocPBrowser(const PRUint32& aChromeFlags); virtual bool DeallocPBrowser(PBrowserParent* frame); virtual PTestShellParent* AllocPTestShell(); diff --git a/dom/ipc/PContent.ipdl b/dom/ipc/PContent.ipdl index 9fca1afd5cc..fd205f40cfb 100644 --- a/dom/ipc/PContent.ipdl +++ b/dom/ipc/PContent.ipdl @@ -59,7 +59,7 @@ rpc protocol PContent manages PNecko; child: - PBrowser(); + PBrowser(PRUint32 chromeFlags); PTestShell(); diff --git a/dom/ipc/TabChild.cpp b/dom/ipc/TabChild.cpp index 0d7ba49ff96..feaf86baa24 100644 --- a/dom/ipc/TabChild.cpp +++ b/dom/ipc/TabChild.cpp @@ -110,8 +110,10 @@ public: }; -TabChild::TabChild() -: mCx(nsnull), mTabChildGlobal(nsnull) +TabChild::TabChild(PRUint32 aChromeFlags) + : mCx(nsnull) + , mTabChildGlobal(nsnull) + , mChromeFlags(aChromeFlags) { printf("creating %d!\n", NS_IsMainThread()); } @@ -182,12 +184,14 @@ TabChild::SetWebBrowser(nsIWebBrowser* aWebBrowser) NS_IMETHODIMP TabChild::GetChromeFlags(PRUint32* aChromeFlags) { - return NS_ERROR_NOT_IMPLEMENTED; + *aChromeFlags = mChromeFlags; + return NS_OK; } NS_IMETHODIMP TabChild::SetChromeFlags(PRUint32 aChromeFlags) { + NS_ERROR("trying to SetChromeFlags from content process?"); return NS_ERROR_NOT_IMPLEMENTED; } diff --git a/dom/ipc/TabChild.h b/dom/ipc/TabChild.h index 7525f2c2223..da66f2126bc 100644 --- a/dom/ipc/TabChild.h +++ b/dom/ipc/TabChild.h @@ -151,7 +151,7 @@ class TabChild : public PBrowserChild, public nsITabChild { public: - TabChild(); + TabChild(PRUint32 aChromeFlags); virtual ~TabChild(); bool DestroyWidget(); nsresult Init(); @@ -286,6 +286,7 @@ private: nsCOMPtr mChannel; TabChildGlobal* mTabChildGlobal; nsCOMPtr mPrincipal; + PRUint32 mChromeFlags; DISALLOW_EVIL_CONSTRUCTORS(TabChild); }; diff --git a/xpfe/appshell/public/nsIXULWindow.idl b/xpfe/appshell/public/nsIXULWindow.idl index be27b505a77..812e1219c6d 100644 --- a/xpfe/appshell/public/nsIXULWindow.idl +++ b/xpfe/appshell/public/nsIXULWindow.idl @@ -51,7 +51,7 @@ interface nsIDocShellTreeItem; interface nsIAppShell; interface nsIXULBrowserWindow; -[scriptable, uuid(c175a596-ee13-420a-aa74-13ad3a14deb1)] +[scriptable, uuid(5869c5e5-743d-473c-bb71-41752146d373)] interface nsIXULWindow : nsISupports { /** @@ -132,6 +132,13 @@ interface nsIXULWindow : nsISupports attribute PRUint32 contextFlags; attribute PRUint32 chromeFlags; + + /** + * Begin assuming |chromeFlags| don't change hereafter, and assert + * if they do change. The state change is one-way and idempotent. + */ + void assumeChromeFlagsAreFrozen(); + /** * Create a new window. * @param aChromeFlags see nsIWebBrowserChrome diff --git a/xpfe/appshell/src/nsXULWindow.cpp b/xpfe/appshell/src/nsXULWindow.cpp index 8ba379ff8e6..fb648f039e3 100644 --- a/xpfe/appshell/src/nsXULWindow.cpp +++ b/xpfe/appshell/src/nsXULWindow.cpp @@ -148,6 +148,7 @@ nsXULWindow::nsXULWindow(PRUint32 aChromeFlags) mLockedUntilChromeLoad(PR_FALSE), mIgnoreXULSize(PR_FALSE), mIgnoreXULPosition(PR_FALSE), + mChromeFlagsFrozen(PR_FALSE), mContextFlags(0), mBlurSuppressionLevel(0), mPersistentAttributesDirty(0), @@ -332,12 +333,21 @@ NS_IMETHODIMP nsXULWindow::GetChromeFlags(PRUint32 *aChromeFlags) NS_IMETHODIMP nsXULWindow::SetChromeFlags(PRUint32 aChromeFlags) { + NS_ASSERTION(!mChromeFlagsFrozen, + "SetChromeFlags() after AssumeChromeFlagsAreFrozen()!"); + mChromeFlags = aChromeFlags; if (mChromeLoaded) NS_ENSURE_SUCCESS(ApplyChromeFlags(), NS_ERROR_FAILURE); return NS_OK; } +NS_IMETHODIMP nsXULWindow::AssumeChromeFlagsAreFrozen() +{ + mChromeFlagsFrozen = PR_TRUE; + return NS_OK; +} + NS_IMETHODIMP nsXULWindow::SetIntrinsicallySized(PRBool aIntrinsicallySized) { mIntrinsicallySized = aIntrinsicallySized; diff --git a/xpfe/appshell/src/nsXULWindow.h b/xpfe/appshell/src/nsXULWindow.h index 126df3f4cad..8084aadd847 100644 --- a/xpfe/appshell/src/nsXULWindow.h +++ b/xpfe/appshell/src/nsXULWindow.h @@ -171,6 +171,7 @@ protected: PRPackedBool mLockedUntilChromeLoad; PRPackedBool mIgnoreXULSize; PRPackedBool mIgnoreXULPosition; + PRPackedBool mChromeFlagsFrozen; PRUint32 mContextFlags; PRUint32 mBlurSuppressionLevel; PRUint32 mPersistentAttributesDirty; // persistentAttributes