Bug 1534267 - Make BrowserBridgeParent* available via TabParent. r=rhunt

Differential Revision: https://phabricator.services.mozilla.com/D22972

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Henri Sivonen 2019-03-11 18:47:20 +00:00
Родитель a24b99a70f
Коммит 69686abca6
3 изменённых файлов: 27 добавлений и 4 удалений

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

@ -17,7 +17,11 @@ namespace dom {
BrowserBridgeParent::BrowserBridgeParent() : mIPCOpen(false) {} BrowserBridgeParent::BrowserBridgeParent() : mIPCOpen(false) {}
BrowserBridgeParent::~BrowserBridgeParent() {} BrowserBridgeParent::~BrowserBridgeParent() {
if (mTabParent) {
mTabParent->mBrowserBridgeParent = nullptr;
}
}
nsresult BrowserBridgeParent::Init(const nsString& aPresentationURL, nsresult BrowserBridgeParent::Init(const nsString& aPresentationURL,
const nsString& aRemoteType) { const nsString& aRemoteType) {
@ -53,7 +57,7 @@ nsresult BrowserBridgeParent::Init(const nsString& aPresentationURL,
// Construct the TabParent object for our subframe. // Construct the TabParent object for our subframe.
uint32_t chromeFlags = 0; uint32_t chromeFlags = 0;
RefPtr<TabParent> tabParent( RefPtr<TabParent> tabParent(
new TabParent(constructorSender, tabId, tabContext, chromeFlags)); new TabParent(constructorSender, tabId, tabContext, chromeFlags, this));
PBrowserParent* browser = constructorSender->SendPBrowserConstructor( PBrowserParent* browser = constructorSender->SendPBrowserConstructor(
// DeallocPBrowserParent() releases this ref. // DeallocPBrowserParent() releases this ref.

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

@ -144,7 +144,8 @@ NS_IMPL_ISUPPORTS(TabParent, nsITabParent, nsIAuthPromptProvider,
nsISupportsWeakReference) nsISupportsWeakReference)
TabParent::TabParent(ContentParent* aManager, const TabId& aTabId, TabParent::TabParent(ContentParent* aManager, const TabId& aTabId,
const TabContext& aContext, uint32_t aChromeFlags) const TabContext& aContext, uint32_t aChromeFlags,
BrowserBridgeParent* aBrowserBridgeParent)
: TabContext(aContext), : TabContext(aContext),
mFrameElement(nullptr), mFrameElement(nullptr),
mContentCache(*this), mContentCache(*this),
@ -162,6 +163,7 @@ TabParent::TabParent(ContentParent* aManager, const TabId& aTabId,
mIsDestroyed(false), mIsDestroyed(false),
mChromeFlags(aChromeFlags), mChromeFlags(aChromeFlags),
mDragValid(false), mDragValid(false),
mBrowserBridgeParent(aBrowserBridgeParent),
mTabId(aTabId), mTabId(aTabId),
mCreatingWindow(false), mCreatingWindow(false),
mCursor(eCursorInvalid), mCursor(eCursorInvalid),
@ -2320,6 +2322,10 @@ RenderFrame* TabParent::GetRenderFrame() {
return &mRenderFrame; return &mRenderFrame;
} }
BrowserBridgeParent* TabParent::GetBrowserBridgeParent() const {
return mBrowserBridgeParent;
}
mozilla::ipc::IPCResult TabParent::RecvRequestIMEToCommitComposition( mozilla::ipc::IPCResult TabParent::RecvRequestIMEToCommitComposition(
const bool& aCancel, bool* aIsCommitted, nsString* aCommittedString) { const bool& aCancel, bool* aIsCommitted, nsString* aCommittedString) {
nsCOMPtr<nsIWidget> widget = GetWidget(); nsCOMPtr<nsIWidget> widget = GetWidget();

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

@ -72,6 +72,7 @@ class ClonedMessageData;
class ContentParent; class ContentParent;
class Element; class Element;
class DataTransfer; class DataTransfer;
class BrowserBridgeParent;
namespace ipc { namespace ipc {
class StructuredCloneData; class StructuredCloneData;
@ -88,6 +89,7 @@ class TabParent final : public PBrowserParent,
typedef mozilla::dom::ClonedMessageData ClonedMessageData; typedef mozilla::dom::ClonedMessageData ClonedMessageData;
friend class PBrowserParent; friend class PBrowserParent;
friend class BrowserBridgeParent; // for clearing mBrowserBridgeParent
virtual ~TabParent(); virtual ~TabParent();
@ -101,7 +103,8 @@ class TabParent final : public PBrowserParent,
NS_DECL_NSIDOMEVENTLISTENER NS_DECL_NSIDOMEVENTLISTENER
TabParent(ContentParent* aManager, const TabId& aTabId, TabParent(ContentParent* aManager, const TabId& aTabId,
const TabContext& aContext, uint32_t aChromeFlags); const TabContext& aContext, uint32_t aChromeFlags,
BrowserBridgeParent* aBrowserBridgeParent = nullptr);
Element* GetOwnerElement() const { return mFrameElement; } Element* GetOwnerElement() const { return mFrameElement; }
already_AddRefed<nsPIDOMWindowOuter> GetParentWindowOuter(); already_AddRefed<nsPIDOMWindowOuter> GetParentWindowOuter();
@ -570,6 +573,10 @@ class TabParent final : public PBrowserParent,
layout::RenderFrame* GetRenderFrame(); layout::RenderFrame* GetRenderFrame();
// Returns the BrowserBridgeParent if this TabParent is for an out-of-process
// iframe and nullptr otherwise.
BrowserBridgeParent* GetBrowserBridgeParent() const;
mozilla::ipc::IPCResult RecvEnsureLayersConnected( mozilla::ipc::IPCResult RecvEnsureLayersConnected(
CompositorOptions* aCompositorOptions); CompositorOptions* aCompositorOptions);
@ -704,6 +711,12 @@ class TabParent final : public PBrowserParent,
// The root browsing context loaded in this TabParent. // The root browsing context loaded in this TabParent.
RefPtr<CanonicalBrowsingContext> mBrowsingContext; RefPtr<CanonicalBrowsingContext> mBrowsingContext;
// Pointer back to BrowserBridgeParent if there is one associated with
// this TabParent. This is non-owning to avoid cycles and is managed
// by the BrowserBridgeParent instance, which has the strong reference
// to this TabParent.
BrowserBridgeParent* mBrowserBridgeParent;
TabId mTabId; TabId mTabId;
// When loading a new tab or window via window.open, the child is // When loading a new tab or window via window.open, the child is