Bug 516747 part 3. Make TabChild and TabParent cooperate on window opening at least to the extent of doing all window opens in new tabs. r=bsmedberg

This commit is contained in:
Boris Zbarsky 2009-12-31 20:35:55 -05:00
Родитель 626a16fef3
Коммит 35066793ab
8 изменённых файлов: 83 добавлений и 5 удалений

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

@ -98,6 +98,8 @@
#include "nsIContentViewer.h"
#include "nsIView.h"
#include "nsIDOMChromeWindow.h"
#ifdef MOZ_WIDGET_GTK2
#include "mozcontainer.h"
@ -1456,6 +1458,16 @@ nsFrameLoader::TryNewProcess()
if (mChildProcess) {
nsCOMPtr<nsIDOMElement> element = do_QueryInterface(mOwnerContent);
mChildProcess->SetOwnerElement(element);
nsCOMPtr<nsIDocShellTreeItem> rootItem;
parentAsItem->GetRootTreeItem(getter_AddRefs(rootItem));
nsCOMPtr<nsIDOMWindow> rootWin = do_GetInterface(rootItem);
nsCOMPtr<nsIDOMChromeWindow> rootChromeWin = do_QueryInterface(rootWin);
NS_ABORT_IF_FALSE(rootChromeWin, "How did we not get a chrome window here?");
nsCOMPtr<nsIBrowserDOMWindow> browserDOMWin;
rootChromeWin->GetBrowserDOMWindow(getter_AddRefs(browserDOMWin));
mChildProcess->SetBrowserDOMWindow(browserDOMWin);
}
return true;
}

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

@ -74,4 +74,8 @@ include $(topsrcdir)/config/config.mk
include $(topsrcdir)/ipc/chromium/chromium-config.mk
include $(topsrcdir)/config/rules.mk
LOCAL_INCLUDES += \
-I$(srcdir)/../../content/base/src \
$(NULL)
DEFINES += -DBIN_SUFFIX='"$(BIN_SUFFIX)"'

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

@ -45,7 +45,7 @@ include "mozilla/TabTypes.h";
namespace mozilla {
namespace dom {
sync protocol PContentProcess
rpc protocol PContentProcess
{
manages PIFrameEmbedding;
manages PTestShell;

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

@ -49,7 +49,7 @@ using RemoteDOMEvent;
namespace mozilla {
namespace dom {
async protocol PIFrameEmbedding
rpc protocol PIFrameEmbedding
{
manager PContentProcess;
manages PDocumentRenderer;
@ -65,6 +65,8 @@ parent:
moveFocus(bool forward);
sendEvent(RemoteDOMEvent aEvent);
rpc createWindow() returns (PIFrameEmbedding window);
child:
createWidget(MagicWindowHandle parentWidget);

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

@ -102,9 +102,10 @@ TabChild::Init()
return NS_OK;
}
NS_IMPL_ISUPPORTS6(TabChild, nsIWebBrowserChrome, nsIWebBrowserChrome2,
NS_IMPL_ISUPPORTS7(TabChild, nsIWebBrowserChrome, nsIWebBrowserChrome2,
nsIEmbeddingSiteWindow, nsIEmbeddingSiteWindow2,
nsIWebBrowserChromeFocus, nsIInterfaceRequestor)
nsIWebBrowserChromeFocus, nsIInterfaceRequestor,
nsIWindowProvider)
NS_IMETHODIMP
TabChild::SetStatus(PRUint32 aStatusType, const PRUnichar* aStatus)
@ -254,6 +255,26 @@ TabChild::GetInterface(const nsIID & aIID, void **aSink)
return QueryInterface(aIID, aSink);
}
NS_IMETHODIMP
TabChild::ProvideWindow(nsIDOMWindow* aParent, PRUint32 aChromeFlags,
PRBool aPositionSpecified, PRBool aSizeSpecified,
nsIURI* aURI, const nsAString& aName,
const nsACString& aFeatures, PRBool* aWindowIsNew,
nsIDOMWindow** aReturn)
{
*aReturn = nsnull;
PIFrameEmbeddingChild* newChild;
if (!CallcreateWindow(&newChild)) {
return NS_ERROR_NOT_AVAILABLE;
}
nsCOMPtr<nsIDOMWindow> win =
do_GetInterface(static_cast<TabChild*>(newChild)->mWebNav);
win.forget(aReturn);
return NS_OK;
}
bool
TabChild::RecvcreateWidget(const MagicWindowHandle& parentWidget)
{

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

@ -49,6 +49,7 @@
#include "nsIDOMEventListener.h"
#include "nsIDOMEventTarget.h"
#include "nsIInterfaceRequestor.h"
#include "nsIWindowProvider.h"
namespace mozilla {
namespace dom {
@ -69,7 +70,8 @@ class TabChild : public PIFrameEmbeddingChild,
public nsIWebBrowserChrome2,
public nsIEmbeddingSiteWindow2,
public nsIWebBrowserChromeFocus,
public nsIInterfaceRequestor
public nsIInterfaceRequestor,
public nsIWindowProvider
{
public:
TabChild();
@ -84,6 +86,7 @@ public:
NS_DECL_NSIEMBEDDINGSITEWINDOW2
NS_DECL_NSIWEBBROWSERCHROMEFOCUS
NS_DECL_NSIINTERFACEREQUESTOR
NS_DECL_NSIWINDOWPROVIDER
virtual bool RecvcreateWidget(const MagicWindowHandle& parentWidget);
virtual bool RecvloadURL(const nsCString& uri);

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

@ -50,6 +50,7 @@
#include "nsIDOMEventTarget.h"
#include "nsIDOMEvent.h"
#include "nsIPrivateDOMEvent.h"
#include "nsFrameLoader.h"
using mozilla::ipc::BrowserProcessSubThread;
using mozilla::ipc::DocumentRendererParent;
@ -93,6 +94,33 @@ TabParent::RecvsendEvent(const RemoteDOMEvent& aEvent)
return true;
}
bool
TabParent::AnswercreateWindow(PIFrameEmbeddingParent** retval)
{
if (!mBrowserDOMWindow) {
return false;
}
// Get a new rendering area from the browserDOMWin. We don't want
// to be starting any loads here, so get it with a null URI.
nsCOMPtr<nsIFrameLoaderOwner> frameLoaderOwner;
mBrowserDOMWindow->OpenURIInFrame(nsnull, nsnull,
nsIBrowserDOMWindow::OPEN_NEWTAB,
nsIBrowserDOMWindow::OPEN_NEW,
getter_AddRefs(frameLoaderOwner));
if (!frameLoaderOwner) {
return false;
}
nsRefPtr<nsFrameLoader> frameLoader = frameLoaderOwner->GetFrameLoader();
if (!frameLoader) {
return false;
}
*retval = frameLoader->GetChildProcess();
return true;
}
void
TabParent::LoadURL(nsIURI* aURI)
{

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

@ -43,6 +43,9 @@
#include "mozilla/ipc/GeckoChildProcessHost.h"
#include "nsCOMPtr.h"
#include "nsIBrowserDOMWindow.h"
class nsIURI;
class nsIDOMElement;
@ -55,9 +58,13 @@ public:
TabParent();
virtual ~TabParent();
void SetOwnerElement(nsIDOMElement* aElement) { mFrameElement = aElement; }
void SetBrowserDOMWindow(nsIBrowserDOMWindow* aBrowserDOMWindow) {
mBrowserDOMWindow = aBrowserDOMWindow;
}
virtual bool RecvmoveFocus(const bool& aForward);
virtual bool RecvsendEvent(const RemoteDOMEvent& aEvent);
virtual bool AnswercreateWindow(PIFrameEmbeddingParent** retval);
void LoadURL(nsIURI* aURI);
void Move(PRUint32 x, PRUint32 y, PRUint32 width, PRUint32 height);
@ -77,6 +84,7 @@ public:
virtual bool DeallocPDocumentRenderer(PDocumentRendererParent* actor);
protected:
nsIDOMElement* mFrameElement;
nsCOMPtr<nsIBrowserDOMWindow> mBrowserDOMWindow;
};
} // namespace dom