2009-07-01 00:39:22 +04:00
|
|
|
/* -*- Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 8; -*- */
|
2009-08-18 23:05:15 +04:00
|
|
|
/* vim: set sw=4 ts=8 et tw=80 : */
|
2009-09-10 02:00:14 +04: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-07-01 00:39:22 +04:00
|
|
|
|
2010-08-21 03:24:41 +04:00
|
|
|
#ifndef mozilla_dom_TabChild_h
|
|
|
|
#define mozilla_dom_TabChild_h
|
2009-07-01 00:39:22 +04:00
|
|
|
|
2010-02-20 20:05:20 +03:00
|
|
|
#ifndef _IMPL_NS_LAYOUT
|
2010-07-19 22:33:33 +04:00
|
|
|
#include "mozilla/dom/PBrowserChild.h"
|
2010-02-20 20:05:20 +03:00
|
|
|
#endif
|
2009-07-01 00:39:22 +04:00
|
|
|
#include "nsIWebNavigation.h"
|
|
|
|
#include "nsCOMPtr.h"
|
2009-11-05 21:14:22 +03:00
|
|
|
#include "nsAutoPtr.h"
|
|
|
|
#include "nsIWebBrowserChrome2.h"
|
|
|
|
#include "nsIEmbeddingSiteWindow2.h"
|
|
|
|
#include "nsIWebBrowserChromeFocus.h"
|
2010-08-21 03:24:40 +04:00
|
|
|
#include "nsIWidget.h"
|
2009-11-17 17:22:23 +03:00
|
|
|
#include "nsIDOMEventListener.h"
|
|
|
|
#include "nsIDOMEventTarget.h"
|
2010-01-01 04:34:06 +03:00
|
|
|
#include "nsIInterfaceRequestor.h"
|
2010-01-01 04:35:55 +03:00
|
|
|
#include "nsIWindowProvider.h"
|
2010-02-20 20:05:20 +03:00
|
|
|
#include "nsIXPCScriptable.h"
|
|
|
|
#include "nsIClassInfo.h"
|
|
|
|
#include "jsapi.h"
|
|
|
|
#include "nsIXPConnect.h"
|
|
|
|
#include "nsIDOMWindow.h"
|
2010-03-03 23:30:25 +03:00
|
|
|
#include "nsIDocShell.h"
|
2010-08-06 02:11:23 +04:00
|
|
|
#include "nsIDocShellTreeItem.h"
|
|
|
|
#include "nsIDocShellTreeOwner.h"
|
|
|
|
#include "nsIDocument.h"
|
2010-02-20 20:05:20 +03:00
|
|
|
#include "nsNetUtil.h"
|
|
|
|
#include "nsFrameMessageManager.h"
|
|
|
|
#include "nsIScriptContext.h"
|
|
|
|
#include "nsDOMEventTargetHelper.h"
|
2010-05-17 15:25:22 +04:00
|
|
|
#include "nsIDialogCreator.h"
|
|
|
|
#include "nsIDialogParamBlock.h"
|
2010-08-06 02:11:23 +04:00
|
|
|
#include "nsIPresShell.h"
|
2010-02-20 20:05:20 +03:00
|
|
|
#include "nsIPrincipal.h"
|
|
|
|
#include "nsIScriptObjectPrincipal.h"
|
|
|
|
#include "nsIScriptContext.h"
|
2010-03-26 21:39:39 +03:00
|
|
|
#include "nsWeakReference.h"
|
2010-05-13 21:44:51 +04:00
|
|
|
#include "nsITabChild.h"
|
2009-07-01 00:39:22 +04:00
|
|
|
|
2010-07-17 10:59:36 +04:00
|
|
|
struct gfxMatrix;
|
2010-03-24 13:47:18 +03:00
|
|
|
|
2009-07-01 00:39:22 +04:00
|
|
|
namespace mozilla {
|
2010-08-21 03:24:41 +04:00
|
|
|
namespace layout {
|
|
|
|
class RenderFrameChild;
|
|
|
|
}
|
|
|
|
|
2009-08-12 20:18:08 +04:00
|
|
|
namespace dom {
|
2009-07-01 00:39:22 +04:00
|
|
|
|
2009-11-17 17:22:23 +03:00
|
|
|
class TabChild;
|
2010-05-17 15:25:22 +04:00
|
|
|
class PContentDialogChild;
|
2009-11-17 17:22:23 +03:00
|
|
|
|
2010-02-20 20:05:20 +03: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 23:30:25 +03:00
|
|
|
NS_IMETHOD GetDocShell(nsIDocShell** aDocShell);
|
2010-02-20 20:05:20 +03:00
|
|
|
NS_IMETHOD Dump(const nsAString& aStr)
|
|
|
|
{
|
|
|
|
return mMessageManager ? mMessageManager->Dump(aStr) : NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
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 17:22:23 +03:00
|
|
|
class ContentListener : public nsIDOMEventListener
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
ContentListener(TabChild* aTabChild) : mTabChild(aTabChild) {}
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
NS_DECL_NSIDOMEVENTLISTENER
|
|
|
|
protected:
|
|
|
|
TabChild* mTabChild;
|
|
|
|
};
|
|
|
|
|
2010-07-19 22:33:33 +04:00
|
|
|
class TabChild : public PBrowserChild,
|
2010-08-18 14:02:49 +04:00
|
|
|
public nsFrameScriptExecutor,
|
2009-11-05 21:14:22 +03:00
|
|
|
public nsIWebBrowserChrome2,
|
|
|
|
public nsIEmbeddingSiteWindow2,
|
2010-01-01 04:34:06 +03:00
|
|
|
public nsIWebBrowserChromeFocus,
|
2010-01-01 04:35:55 +03:00
|
|
|
public nsIInterfaceRequestor,
|
2010-03-26 21:39:39 +03:00
|
|
|
public nsIWindowProvider,
|
2010-05-13 21:44:51 +04:00
|
|
|
public nsSupportsWeakReference,
|
2010-05-17 15:25:22 +04:00
|
|
|
public nsIDialogCreator,
|
2010-05-13 21:44:51 +04:00
|
|
|
public nsITabChild
|
2009-07-01 00:39:22 +04:00
|
|
|
{
|
2010-08-21 03:24:41 +04:00
|
|
|
typedef mozilla::layout::RenderFrameChild RenderFrameChild;
|
|
|
|
|
2009-07-01 00:39:22 +04:00
|
|
|
public:
|
2010-07-19 22:33:33 +04:00
|
|
|
TabChild(PRUint32 aChromeFlags);
|
2009-07-01 00:39:22 +04:00
|
|
|
virtual ~TabChild();
|
2009-11-05 21:14:22 +03:00
|
|
|
nsresult Init();
|
|
|
|
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
NS_DECL_NSIWEBBROWSERCHROME
|
|
|
|
NS_DECL_NSIWEBBROWSERCHROME2
|
|
|
|
NS_DECL_NSIEMBEDDINGSITEWINDOW
|
|
|
|
NS_DECL_NSIEMBEDDINGSITEWINDOW2
|
|
|
|
NS_DECL_NSIWEBBROWSERCHROMEFOCUS
|
2010-01-01 04:34:06 +03:00
|
|
|
NS_DECL_NSIINTERFACEREQUESTOR
|
2010-01-01 04:35:55 +03:00
|
|
|
NS_DECL_NSIWINDOWPROVIDER
|
2010-05-17 15:25:22 +04:00
|
|
|
NS_DECL_NSIDIALOGCREATOR
|
2009-07-01 00:39:22 +04:00
|
|
|
|
2010-07-19 22:33:33 +04:00
|
|
|
virtual bool RecvLoadURL(const nsCString& uri);
|
2010-08-21 03:24:40 +04:00
|
|
|
virtual bool RecvShow(const nsIntSize& size);
|
|
|
|
virtual bool RecvMove(const nsIntSize& size);
|
2010-07-19 22:33:33 +04: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 12:07:42 +04:00
|
|
|
virtual bool RecvCompositionEvent(const nsCompositionEvent& event);
|
|
|
|
virtual bool RecvTextEvent(const nsTextEvent& event);
|
|
|
|
virtual bool RecvSelectionEvent(const nsSelectionEvent& event);
|
2010-07-19 22:33:33 +04: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-27 02:20:53 +04:00
|
|
|
|
|
|
|
virtual PDocumentRendererChild*
|
2010-10-27 02:20:53 +04:00
|
|
|
AllocPDocumentRenderer(const nsRect& documentRect, const gfxMatrix& transform,
|
|
|
|
const nsString& bgcolor,
|
2010-10-27 02:20:53 +04:00
|
|
|
const PRUint32& renderFlags, const bool& flushLayout);
|
2009-12-03 11:16:14 +03:00
|
|
|
virtual bool DeallocPDocumentRenderer(PDocumentRendererChild* actor);
|
2010-10-27 02:20:53 +04:00
|
|
|
virtual bool RecvPDocumentRendererConstructor(PDocumentRendererChild* actor,
|
|
|
|
const nsRect& documentRect,
|
2010-10-27 02:20:53 +04:00
|
|
|
const gfxMatrix& transform,
|
2010-10-27 02:20:53 +04:00
|
|
|
const nsString& bgcolor,
|
|
|
|
const PRUint32& renderFlags,
|
|
|
|
const bool& flushLayout);
|
|
|
|
|
2010-05-17 15:25:22 +04:00
|
|
|
virtual PContentDialogChild* AllocPContentDialog(const PRUint32&,
|
|
|
|
const nsCString&,
|
|
|
|
const nsCString&,
|
|
|
|
const nsTArray<int>&,
|
|
|
|
const nsTArray<nsString>&);
|
|
|
|
virtual bool DeallocPContentDialog(PContentDialogChild* aDialog);
|
|
|
|
static void ParamsToArrays(nsIDialogParamBlock* aParams,
|
|
|
|
nsTArray<int>& aIntParams,
|
|
|
|
nsTArray<nsString>& aStringParams);
|
|
|
|
static void ArraysToParams(const nsTArray<int>& aIntParams,
|
|
|
|
const nsTArray<nsString>& aStringParams,
|
|
|
|
nsIDialogParamBlock* aParams);
|
2009-07-01 00:39:22 +04:00
|
|
|
|
2010-09-10 09:00:08 +04:00
|
|
|
virtual PContentPermissionRequestChild* AllocPContentPermissionRequest(const nsCString& aType, const IPC::URI& uri);
|
|
|
|
virtual bool DeallocPContentPermissionRequest(PContentPermissionRequestChild* actor);
|
2010-05-13 21:44:51 +04:00
|
|
|
|
2010-10-20 21:12:32 +04:00
|
|
|
virtual POfflineCacheUpdateChild* AllocPOfflineCacheUpdate(const URI& manifestURI,
|
|
|
|
const URI& documentURI,
|
|
|
|
const nsCString& clientID,
|
|
|
|
const bool& stickDocument);
|
|
|
|
virtual bool DeallocPOfflineCacheUpdate(POfflineCacheUpdateChild* offlineCacheUpdate);
|
|
|
|
|
2010-02-20 20:05:20 +03:00
|
|
|
nsIWebNavigation* WebNavigation() { return mWebNav; }
|
|
|
|
|
|
|
|
JSContext* GetJSContext() { return mCx; }
|
|
|
|
|
|
|
|
nsIPrincipal* GetPrincipal() { return mPrincipal; }
|
2009-11-06 23:43:39 +03:00
|
|
|
|
2010-08-06 02:11:23 +04:00
|
|
|
protected:
|
2010-08-21 03:24:41 +04:00
|
|
|
NS_OVERRIDE
|
|
|
|
virtual PRenderFrameChild* AllocPRenderFrame();
|
|
|
|
NS_OVERRIDE
|
|
|
|
virtual bool DeallocPRenderFrame(PRenderFrameChild* aFrame);
|
2010-08-06 02:11:23 +04:00
|
|
|
NS_OVERRIDE
|
|
|
|
virtual bool RecvDestroy();
|
|
|
|
|
2010-08-17 12:07:42 +04:00
|
|
|
bool DispatchWidgetEvent(nsGUIEvent& event);
|
|
|
|
|
2009-07-01 00:39:22 +04:00
|
|
|
private:
|
2010-07-22 03:23:03 +04:00
|
|
|
void ActorDestroy(ActorDestroyReason why);
|
|
|
|
|
2010-02-20 20:05:20 +03:00
|
|
|
bool InitTabChildGlobal();
|
2010-08-21 03:24:41 +04:00
|
|
|
bool InitWidget(const nsIntSize& size);
|
2010-08-21 03:24:40 +04:00
|
|
|
void DestroyWindow();
|
2010-02-20 20:05:20 +03:00
|
|
|
|
2009-07-01 00:39:22 +04:00
|
|
|
nsCOMPtr<nsIWebNavigation> mWebNav;
|
2010-08-21 03:24:40 +04:00
|
|
|
nsCOMPtr<nsIWidget> mWidget;
|
2010-08-21 03:24:41 +04:00
|
|
|
RenderFrameChild* mRemoteFrame;
|
2010-08-23 12:44:43 +04:00
|
|
|
nsRefPtr<TabChildGlobal> mTabChildGlobal;
|
2010-07-19 22:33:33 +04:00
|
|
|
PRUint32 mChromeFlags;
|
2010-02-20 20:05:20 +03:00
|
|
|
|
2009-07-01 00:39:22 +04:00
|
|
|
DISALLOW_EVIL_CONSTRUCTORS(TabChild);
|
|
|
|
};
|
|
|
|
|
2010-08-06 02:11:23 +04: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-07-01 00:39:22 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-08-21 03:24:41 +04:00
|
|
|
#endif // mozilla_dom_TabChild_h
|