2009-06-30 13:39:22 -07:00
|
|
|
/* -*- Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 8; -*- */
|
2009-08-18 12:05:15 -07:00
|
|
|
/* vim: set sw=4 ts=8 et tw=80 : */
|
2009-09-09 15:00:14 -07:00
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
|
|
|
*
|
|
|
|
* The contents of this file are subject to the Mozilla Public License Version
|
|
|
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
|
|
|
* the License. You may obtain a copy of the License at
|
|
|
|
* http://www.mozilla.org/MPL/
|
|
|
|
*
|
|
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* License.
|
|
|
|
*
|
|
|
|
* The Original Code is Mozilla Content App.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is
|
|
|
|
* The Mozilla Foundation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 2009
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
|
|
|
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
|
|
|
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
2009-06-30 13:39:22 -07:00
|
|
|
|
2010-08-20 16:24:41 -07:00
|
|
|
#ifndef mozilla_dom_TabChild_h
|
|
|
|
#define mozilla_dom_TabChild_h
|
2009-06-30 13:39:22 -07:00
|
|
|
|
2010-02-20 09:05:20 -08:00
|
|
|
#ifndef _IMPL_NS_LAYOUT
|
2010-07-19 11:33:33 -07:00
|
|
|
#include "mozilla/dom/PBrowserChild.h"
|
2010-02-20 09:05:20 -08:00
|
|
|
#endif
|
2009-06-30 13:39:22 -07:00
|
|
|
#include "nsIWebNavigation.h"
|
|
|
|
#include "nsCOMPtr.h"
|
2009-11-05 10:14:22 -08:00
|
|
|
#include "nsAutoPtr.h"
|
|
|
|
#include "nsIWebBrowserChrome2.h"
|
|
|
|
#include "nsIEmbeddingSiteWindow2.h"
|
|
|
|
#include "nsIWebBrowserChromeFocus.h"
|
2010-08-20 16:24:40 -07:00
|
|
|
#include "nsIWidget.h"
|
2009-11-17 06:22:23 -08:00
|
|
|
#include "nsIDOMEventListener.h"
|
|
|
|
#include "nsIDOMEventTarget.h"
|
2009-12-31 17:34:06 -08:00
|
|
|
#include "nsIInterfaceRequestor.h"
|
2009-12-31 17:35:55 -08:00
|
|
|
#include "nsIWindowProvider.h"
|
2010-02-20 09:05:20 -08:00
|
|
|
#include "nsIXPCScriptable.h"
|
|
|
|
#include "nsIClassInfo.h"
|
|
|
|
#include "jsapi.h"
|
|
|
|
#include "nsIXPConnect.h"
|
|
|
|
#include "nsIDOMWindow.h"
|
2010-03-03 12:30:25 -08:00
|
|
|
#include "nsIDocShell.h"
|
2010-08-05 15:11:23 -07:00
|
|
|
#include "nsIDocShellTreeItem.h"
|
|
|
|
#include "nsIDocShellTreeOwner.h"
|
|
|
|
#include "nsIDocument.h"
|
2010-02-20 09:05:20 -08:00
|
|
|
#include "nsNetUtil.h"
|
|
|
|
#include "nsFrameMessageManager.h"
|
|
|
|
#include "nsIScriptContext.h"
|
|
|
|
#include "nsDOMEventTargetHelper.h"
|
2010-05-17 04:25:22 -07:00
|
|
|
#include "nsIDialogCreator.h"
|
|
|
|
#include "nsIDialogParamBlock.h"
|
2010-08-05 15:11:23 -07:00
|
|
|
#include "nsIPresShell.h"
|
2010-02-20 09:05:20 -08:00
|
|
|
#include "nsIPrincipal.h"
|
|
|
|
#include "nsIScriptObjectPrincipal.h"
|
|
|
|
#include "nsIScriptContext.h"
|
2010-03-26 11:39:39 -07:00
|
|
|
#include "nsWeakReference.h"
|
2010-05-13 10:44:51 -07:00
|
|
|
#include "nsITabChild.h"
|
2009-06-30 13:39:22 -07:00
|
|
|
|
2010-07-16 23:59:36 -07:00
|
|
|
struct gfxMatrix;
|
2010-03-24 03:47:18 -07:00
|
|
|
|
2009-06-30 13:39:22 -07:00
|
|
|
namespace mozilla {
|
2010-08-20 16:24:41 -07:00
|
|
|
namespace layout {
|
|
|
|
class RenderFrameChild;
|
|
|
|
}
|
|
|
|
|
2009-08-12 09:18:08 -07:00
|
|
|
namespace dom {
|
2009-06-30 13:39:22 -07:00
|
|
|
|
2009-11-17 06:22:23 -08:00
|
|
|
class TabChild;
|
2010-05-17 04:25:22 -07:00
|
|
|
class PContentDialogChild;
|
2009-11-17 06:22:23 -08:00
|
|
|
|
2010-02-20 09:05:20 -08:00
|
|
|
class TabChildGlobal : public nsDOMEventTargetHelper,
|
|
|
|
public nsIContentFrameMessageManager,
|
|
|
|
public nsIScriptObjectPrincipal,
|
|
|
|
public nsIScriptContextPrincipal
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
TabChildGlobal(TabChild* aTabChild);
|
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(TabChildGlobal, nsDOMEventTargetHelper)
|
|
|
|
NS_FORWARD_SAFE_NSIFRAMEMESSAGEMANAGER(mMessageManager)
|
|
|
|
NS_IMETHOD SendSyncMessage()
|
|
|
|
{
|
|
|
|
return mMessageManager ? mMessageManager->SendSyncMessage()
|
|
|
|
: NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
|
|
|
NS_IMETHOD GetContent(nsIDOMWindow** aContent);
|
2010-03-03 12:30:25 -08:00
|
|
|
NS_IMETHOD GetDocShell(nsIDocShell** aDocShell);
|
2010-02-20 09:05:20 -08:00
|
|
|
NS_IMETHOD Dump(const nsAString& aStr)
|
|
|
|
{
|
|
|
|
return mMessageManager ? mMessageManager->Dump(aStr) : NS_OK;
|
|
|
|
}
|
2010-11-24 05:58:21 -08:00
|
|
|
NS_IMETHOD PrivateNoteIntentionalCrash();
|
2010-02-20 09:05:20 -08:00
|
|
|
|
|
|
|
NS_IMETHOD AddEventListener(const nsAString& aType,
|
|
|
|
nsIDOMEventListener* aListener,
|
|
|
|
PRBool aUseCapture)
|
|
|
|
{
|
|
|
|
// By default add listeners only for trusted events!
|
|
|
|
return nsDOMEventTargetHelper::AddEventListener(aType, aListener,
|
|
|
|
aUseCapture, PR_FALSE, 1);
|
|
|
|
}
|
|
|
|
NS_IMETHOD AddEventListener(const nsAString& aType,
|
|
|
|
nsIDOMEventListener* aListener,
|
|
|
|
PRBool aUseCapture, PRBool aWantsUntrusted,
|
|
|
|
PRUint8 optional_argc)
|
|
|
|
{
|
|
|
|
return nsDOMEventTargetHelper::AddEventListener(aType, aListener,
|
|
|
|
aUseCapture,
|
|
|
|
aWantsUntrusted,
|
|
|
|
optional_argc);
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual nsIScriptObjectPrincipal* GetObjectPrincipal() { return this; }
|
|
|
|
virtual JSContext* GetJSContextForEventHandlers();
|
|
|
|
virtual nsIPrincipal* GetPrincipal();
|
|
|
|
|
|
|
|
nsCOMPtr<nsIContentFrameMessageManager> mMessageManager;
|
|
|
|
TabChild* mTabChild;
|
|
|
|
};
|
|
|
|
|
2009-11-17 06:22:23 -08:00
|
|
|
class ContentListener : public nsIDOMEventListener
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
ContentListener(TabChild* aTabChild) : mTabChild(aTabChild) {}
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
NS_DECL_NSIDOMEVENTLISTENER
|
|
|
|
protected:
|
|
|
|
TabChild* mTabChild;
|
|
|
|
};
|
|
|
|
|
2010-07-19 11:33:33 -07:00
|
|
|
class TabChild : public PBrowserChild,
|
2010-08-18 03:02:49 -07:00
|
|
|
public nsFrameScriptExecutor,
|
2009-11-05 10:14:22 -08:00
|
|
|
public nsIWebBrowserChrome2,
|
|
|
|
public nsIEmbeddingSiteWindow2,
|
2009-12-31 17:34:06 -08:00
|
|
|
public nsIWebBrowserChromeFocus,
|
2009-12-31 17:35:55 -08:00
|
|
|
public nsIInterfaceRequestor,
|
2010-03-26 11:39:39 -07:00
|
|
|
public nsIWindowProvider,
|
2010-05-13 10:44:51 -07:00
|
|
|
public nsSupportsWeakReference,
|
2010-05-17 04:25:22 -07:00
|
|
|
public nsIDialogCreator,
|
2010-05-13 10:44:51 -07:00
|
|
|
public nsITabChild
|
2009-06-30 13:39:22 -07:00
|
|
|
{
|
2010-08-20 16:24:41 -07:00
|
|
|
typedef mozilla::layout::RenderFrameChild RenderFrameChild;
|
|
|
|
|
2009-06-30 13:39:22 -07:00
|
|
|
public:
|
2010-07-19 11:33:33 -07:00
|
|
|
TabChild(PRUint32 aChromeFlags);
|
2009-06-30 13:39:22 -07:00
|
|
|
virtual ~TabChild();
|
2009-11-05 10:14:22 -08:00
|
|
|
nsresult Init();
|
|
|
|
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
NS_DECL_NSIWEBBROWSERCHROME
|
|
|
|
NS_DECL_NSIWEBBROWSERCHROME2
|
|
|
|
NS_DECL_NSIEMBEDDINGSITEWINDOW
|
|
|
|
NS_DECL_NSIEMBEDDINGSITEWINDOW2
|
|
|
|
NS_DECL_NSIWEBBROWSERCHROMEFOCUS
|
2009-12-31 17:34:06 -08:00
|
|
|
NS_DECL_NSIINTERFACEREQUESTOR
|
2009-12-31 17:35:55 -08:00
|
|
|
NS_DECL_NSIWINDOWPROVIDER
|
2010-05-17 04:25:22 -07:00
|
|
|
NS_DECL_NSIDIALOGCREATOR
|
2009-06-30 13:39:22 -07:00
|
|
|
|
2010-07-19 11:33:33 -07:00
|
|
|
virtual bool RecvLoadURL(const nsCString& uri);
|
2010-08-20 16:24:40 -07:00
|
|
|
virtual bool RecvShow(const nsIntSize& size);
|
|
|
|
virtual bool RecvMove(const nsIntSize& size);
|
2010-07-19 11:33:33 -07:00
|
|
|
virtual bool RecvActivate();
|
|
|
|
virtual bool RecvMouseEvent(const nsString& aType,
|
|
|
|
const float& aX,
|
|
|
|
const float& aY,
|
|
|
|
const PRInt32& aButton,
|
|
|
|
const PRInt32& aClickCount,
|
|
|
|
const PRInt32& aModifiers,
|
|
|
|
const bool& aIgnoreRootScrollFrame);
|
|
|
|
virtual bool RecvKeyEvent(const nsString& aType,
|
|
|
|
const PRInt32& aKeyCode,
|
|
|
|
const PRInt32& aCharCode,
|
|
|
|
const PRInt32& aModifiers,
|
|
|
|
const bool& aPreventDefault);
|
2010-08-17 01:07:42 -07:00
|
|
|
virtual bool RecvCompositionEvent(const nsCompositionEvent& event);
|
|
|
|
virtual bool RecvTextEvent(const nsTextEvent& event);
|
|
|
|
virtual bool RecvSelectionEvent(const nsSelectionEvent& event);
|
2010-07-19 11:33:33 -07:00
|
|
|
virtual bool RecvActivateFrameEvent(const nsString& aType, const bool& capture);
|
|
|
|
virtual bool RecvLoadRemoteScript(const nsString& aURL);
|
|
|
|
virtual bool RecvAsyncMessage(const nsString& aMessage,
|
|
|
|
const nsString& aJSON);
|
2010-10-26 15:20:53 -07:00
|
|
|
|
|
|
|
virtual PDocumentRendererChild*
|
2010-10-26 15:20:53 -07:00
|
|
|
AllocPDocumentRenderer(const nsRect& documentRect, const gfxMatrix& transform,
|
|
|
|
const nsString& bgcolor,
|
2010-10-26 15:20:53 -07:00
|
|
|
const PRUint32& renderFlags, const bool& flushLayout,
|
|
|
|
const nsIntSize& renderSize);
|
2009-12-03 00:16:14 -08:00
|
|
|
virtual bool DeallocPDocumentRenderer(PDocumentRendererChild* actor);
|
2010-10-26 15:20:53 -07:00
|
|
|
virtual bool RecvPDocumentRendererConstructor(PDocumentRendererChild* actor,
|
|
|
|
const nsRect& documentRect,
|
2010-10-26 15:20:53 -07:00
|
|
|
const gfxMatrix& transform,
|
2010-10-26 15:20:53 -07:00
|
|
|
const nsString& bgcolor,
|
|
|
|
const PRUint32& renderFlags,
|
2010-10-26 15:20:53 -07:00
|
|
|
const bool& flushLayout,
|
|
|
|
const nsIntSize& renderSize);
|
2010-10-26 15:20:53 -07:00
|
|
|
|
2010-05-17 04:25:22 -07:00
|
|
|
virtual PContentDialogChild* AllocPContentDialog(const PRUint32&,
|
|
|
|
const nsCString&,
|
|
|
|
const nsCString&,
|
2010-11-08 18:49:00 -08:00
|
|
|
const InfallibleTArray<int>&,
|
|
|
|
const InfallibleTArray<nsString>&);
|
2010-05-17 04:25:22 -07:00
|
|
|
virtual bool DeallocPContentDialog(PContentDialogChild* aDialog);
|
|
|
|
static void ParamsToArrays(nsIDialogParamBlock* aParams,
|
2010-11-08 18:49:00 -08:00
|
|
|
InfallibleTArray<int>& aIntParams,
|
|
|
|
InfallibleTArray<nsString>& aStringParams);
|
|
|
|
static void ArraysToParams(const InfallibleTArray<int>& aIntParams,
|
|
|
|
const InfallibleTArray<nsString>& aStringParams,
|
2010-05-17 04:25:22 -07:00
|
|
|
nsIDialogParamBlock* aParams);
|
2009-06-30 13:39:22 -07:00
|
|
|
|
2010-09-09 22:00:08 -07:00
|
|
|
virtual PContentPermissionRequestChild* AllocPContentPermissionRequest(const nsCString& aType, const IPC::URI& uri);
|
|
|
|
virtual bool DeallocPContentPermissionRequest(PContentPermissionRequestChild* actor);
|
2010-05-13 10:44:51 -07:00
|
|
|
|
2010-10-20 10:12:32 -07:00
|
|
|
virtual POfflineCacheUpdateChild* AllocPOfflineCacheUpdate(const URI& manifestURI,
|
|
|
|
const URI& documentURI,
|
|
|
|
const nsCString& clientID,
|
|
|
|
const bool& stickDocument);
|
|
|
|
virtual bool DeallocPOfflineCacheUpdate(POfflineCacheUpdateChild* offlineCacheUpdate);
|
|
|
|
|
2010-02-20 09:05:20 -08:00
|
|
|
nsIWebNavigation* WebNavigation() { return mWebNav; }
|
|
|
|
|
|
|
|
JSContext* GetJSContext() { return mCx; }
|
|
|
|
|
|
|
|
nsIPrincipal* GetPrincipal() { return mPrincipal; }
|
2009-11-06 12:43:39 -08:00
|
|
|
|
2010-08-05 15:11:23 -07:00
|
|
|
protected:
|
2010-08-20 16:24:41 -07:00
|
|
|
NS_OVERRIDE
|
|
|
|
virtual PRenderFrameChild* AllocPRenderFrame();
|
|
|
|
NS_OVERRIDE
|
|
|
|
virtual bool DeallocPRenderFrame(PRenderFrameChild* aFrame);
|
2010-08-05 15:11:23 -07:00
|
|
|
NS_OVERRIDE
|
|
|
|
virtual bool RecvDestroy();
|
|
|
|
|
2010-08-17 01:07:42 -07:00
|
|
|
bool DispatchWidgetEvent(nsGUIEvent& event);
|
|
|
|
|
2009-06-30 13:39:22 -07:00
|
|
|
private:
|
2010-07-21 16:23:03 -07:00
|
|
|
void ActorDestroy(ActorDestroyReason why);
|
|
|
|
|
2010-02-20 09:05:20 -08:00
|
|
|
bool InitTabChildGlobal();
|
2010-08-20 16:24:41 -07:00
|
|
|
bool InitWidget(const nsIntSize& size);
|
2010-08-20 16:24:40 -07:00
|
|
|
void DestroyWindow();
|
2010-02-20 09:05:20 -08:00
|
|
|
|
2009-06-30 13:39:22 -07:00
|
|
|
nsCOMPtr<nsIWebNavigation> mWebNav;
|
2010-08-20 16:24:40 -07:00
|
|
|
nsCOMPtr<nsIWidget> mWidget;
|
2010-08-20 16:24:41 -07:00
|
|
|
RenderFrameChild* mRemoteFrame;
|
2010-08-23 01:44:43 -07:00
|
|
|
nsRefPtr<TabChildGlobal> mTabChildGlobal;
|
2010-07-19 11:33:33 -07:00
|
|
|
PRUint32 mChromeFlags;
|
2010-02-20 09:05:20 -08:00
|
|
|
|
2009-06-30 13:39:22 -07:00
|
|
|
DISALLOW_EVIL_CONSTRUCTORS(TabChild);
|
|
|
|
};
|
|
|
|
|
2010-08-05 15:11:23 -07:00
|
|
|
inline TabChild*
|
|
|
|
GetTabChildFrom(nsIDocShell* aDocShell)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsITabChild> tc = do_GetInterface(aDocShell);
|
|
|
|
return static_cast<TabChild*>(tc.get());
|
|
|
|
}
|
|
|
|
|
|
|
|
inline TabChild*
|
|
|
|
GetTabChildFrom(nsIPresShell* aPresShell)
|
|
|
|
{
|
|
|
|
nsIDocument* doc = aPresShell->GetDocument();
|
|
|
|
if (!doc) {
|
|
|
|
return nsnull;
|
|
|
|
}
|
|
|
|
nsCOMPtr<nsISupports> container = doc->GetContainer();
|
|
|
|
nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(container));
|
|
|
|
return GetTabChildFrom(docShell);
|
|
|
|
}
|
|
|
|
|
2009-06-30 13:39:22 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-08-20 16:24:41 -07:00
|
|
|
#endif // mozilla_dom_TabChild_h
|