2011-10-01 20:14:36 +04:00
|
|
|
/* -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 2; -*- */
|
2009-08-18 23:05:15 +04:00
|
|
|
/* vim: set sw=4 ts=8 et tw=80 : */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
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"
|
2012-06-10 02:15:12 +04:00
|
|
|
#include "nsIEmbeddingSiteWindow.h"
|
2009-11-05 21:14:22 +03:00
|
|
|
#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"
|
2012-02-08 06:53:33 +04:00
|
|
|
#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"
|
2012-06-15 06:31:55 +04:00
|
|
|
#include "mozilla/Attributes.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
|
|
|
|
2012-02-08 06:53:33 +04:00
|
|
|
class TabChildGlobal : public nsDOMEventTargetHelper,
|
2010-02-20 20:05:20 +03:00
|
|
|
public nsIContentFrameMessageManager,
|
|
|
|
public nsIScriptObjectPrincipal,
|
|
|
|
public nsIScriptContextPrincipal
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
TabChildGlobal(TabChild* aTabChild);
|
2012-04-27 00:56:46 +04:00
|
|
|
void Init();
|
2010-02-20 20:05:20 +03:00
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
2012-02-08 06:53:33 +04:00
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(TabChildGlobal, nsDOMEventTargetHelper)
|
2010-02-20 20:05:20 +03:00
|
|
|
NS_FORWARD_SAFE_NSIFRAMEMESSAGEMANAGER(mMessageManager)
|
2011-10-01 20:14:36 +04:00
|
|
|
NS_IMETHOD SendSyncMessage(const nsAString& aMessageName,
|
|
|
|
const jsval& aObject,
|
|
|
|
JSContext* aCx,
|
|
|
|
PRUint8 aArgc,
|
|
|
|
jsval* aRetval)
|
2010-02-20 20:05:20 +03:00
|
|
|
{
|
2011-10-01 20:14:36 +04:00
|
|
|
return mMessageManager
|
|
|
|
? mMessageManager->SendSyncMessage(aMessageName, aObject, aCx, aArgc, aRetval)
|
|
|
|
: NS_ERROR_NULL_POINTER;
|
2010-02-20 20:05:20 +03:00
|
|
|
}
|
|
|
|
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;
|
|
|
|
}
|
2010-11-24 16:58:21 +03:00
|
|
|
NS_IMETHOD PrivateNoteIntentionalCrash();
|
2011-06-25 13:52:00 +04:00
|
|
|
NS_IMETHOD Btoa(const nsAString& aBinaryData,
|
|
|
|
nsAString& aAsciiBase64String);
|
|
|
|
NS_IMETHOD Atob(const nsAString& aAsciiString,
|
|
|
|
nsAString& aBinaryData);
|
2010-02-20 20:05:20 +03:00
|
|
|
|
|
|
|
NS_IMETHOD AddEventListener(const nsAString& aType,
|
|
|
|
nsIDOMEventListener* aListener,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool aUseCapture)
|
2010-02-20 20:05:20 +03:00
|
|
|
{
|
|
|
|
// By default add listeners only for trusted events!
|
|
|
|
return nsDOMEventTargetHelper::AddEventListener(aType, aListener,
|
2011-10-17 18:59:28 +04:00
|
|
|
aUseCapture, false, 2);
|
2010-02-20 20:05:20 +03:00
|
|
|
}
|
|
|
|
NS_IMETHOD AddEventListener(const nsAString& aType,
|
|
|
|
nsIDOMEventListener* aListener,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool aUseCapture, bool aWantsUntrusted,
|
2010-02-20 20:05:20 +03:00
|
|
|
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;
|
|
|
|
};
|
|
|
|
|
2012-06-15 06:31:55 +04:00
|
|
|
class ContentListener MOZ_FINAL : public nsIDOMEventListener
|
2009-11-17 17:22:23 +03:00
|
|
|
{
|
|
|
|
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,
|
2012-06-10 02:15:12 +04:00
|
|
|
public nsIEmbeddingSiteWindow,
|
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_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
|
2012-05-28 13:27:25 +04:00
|
|
|
NS_DECL_NSITABCHILD
|
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);
|
2011-07-16 01:46:56 +04:00
|
|
|
virtual bool RecvUpdateDimensions(const nsRect& rect, const nsIntSize& size);
|
2010-07-19 22:33:33 +04:00
|
|
|
virtual bool RecvActivate();
|
2011-06-18 04:08:32 +04:00
|
|
|
virtual bool RecvDeactivate();
|
2010-07-19 22:33:33 +04:00
|
|
|
virtual bool RecvMouseEvent(const nsString& aType,
|
|
|
|
const float& aX,
|
|
|
|
const float& aY,
|
|
|
|
const PRInt32& aButton,
|
|
|
|
const PRInt32& aClickCount,
|
|
|
|
const PRInt32& aModifiers,
|
|
|
|
const bool& aIgnoreRootScrollFrame);
|
2011-06-22 04:32:43 +04:00
|
|
|
virtual bool RecvRealMouseEvent(const nsMouseEvent& event);
|
|
|
|
virtual bool RecvRealKeyEvent(const nsKeyEvent& event);
|
|
|
|
virtual bool RecvMouseScrollEvent(const nsMouseScrollEvent& event);
|
2010-07-19 22:33:33 +04:00
|
|
|
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,
|
|
|
|
const nsIntSize& renderSize);
|
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,
|
2010-10-27 02:20:53 +04:00
|
|
|
const bool& flushLayout,
|
|
|
|
const nsIntSize& renderSize);
|
2010-10-27 02:20:53 +04:00
|
|
|
|
2010-05-17 15:25:22 +04:00
|
|
|
virtual PContentDialogChild* AllocPContentDialog(const PRUint32&,
|
|
|
|
const nsCString&,
|
|
|
|
const nsCString&,
|
2010-11-09 05:49:00 +03:00
|
|
|
const InfallibleTArray<int>&,
|
|
|
|
const InfallibleTArray<nsString>&);
|
2010-05-17 15:25:22 +04:00
|
|
|
virtual bool DeallocPContentDialog(PContentDialogChild* aDialog);
|
|
|
|
static void ParamsToArrays(nsIDialogParamBlock* aParams,
|
2010-11-09 05:49:00 +03:00
|
|
|
InfallibleTArray<int>& aIntParams,
|
|
|
|
InfallibleTArray<nsString>& aStringParams);
|
|
|
|
static void ArraysToParams(const InfallibleTArray<int>& aIntParams,
|
|
|
|
const InfallibleTArray<nsString>& aStringParams,
|
2010-05-17 15:25:22 +04:00
|
|
|
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
|
|
|
|
2011-10-21 02:17:09 +04:00
|
|
|
void SetBackgroundColor(const nscolor& aColor);
|
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);
|
|
|
|
|
2012-06-01 21:21:12 +04:00
|
|
|
virtual PIndexedDBChild* AllocPIndexedDB(const nsCString& aASCIIOrigin,
|
|
|
|
bool* /* aAllowed */);
|
|
|
|
|
|
|
|
virtual bool DeallocPIndexedDB(PIndexedDBChild* actor);
|
|
|
|
|
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
|
|
|
|
2012-06-13 02:01:25 +04:00
|
|
|
// Call RecvShow(nsIntSize(0, 0)) and block future calls to RecvShow().
|
|
|
|
void DoFakeShow();
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
BrowserFrameProvideWindow(nsIDOMWindow* aOpener,
|
|
|
|
nsIURI* aURI,
|
|
|
|
const nsAString& aName,
|
|
|
|
const nsACString& aFeatures,
|
|
|
|
bool* aWindowIsNew,
|
|
|
|
nsIDOMWindow** aReturn);
|
|
|
|
|
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;
|
2011-07-16 01:46:56 +04:00
|
|
|
nsIntRect mOuterRect;
|
2011-10-21 02:17:09 +04:00
|
|
|
nscolor mLastBackgroundColor;
|
2012-06-13 02:01:25 +04:00
|
|
|
bool mDidFakeShow;
|
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);
|
|
|
|
}
|
|
|
|
|
2011-09-30 11:00:48 +04:00
|
|
|
inline TabChild*
|
|
|
|
GetTabChildFrom(nsIDOMWindow* aWindow)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIWebNavigation> webNav = do_GetInterface(aWindow);
|
|
|
|
nsCOMPtr<nsIDocShell> docShell = do_QueryInterface(webNav);
|
|
|
|
return GetTabChildFrom(docShell);
|
|
|
|
}
|
|
|
|
|
2009-07-01 00:39:22 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-08-21 03:24:41 +04:00
|
|
|
#endif // mozilla_dom_TabChild_h
|