mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-26 12:20:56 +00:00
Bug 1525720, part 10 - Link BrowserParent and BrowserHost on creation. r=nika
This commit adds a link from BrowserParent to it's owning BrowserHost if it is the root BrowserParent. Differential Revision: https://phabricator.services.mozilla.com/D31441 --HG-- extra : source : d3b2ac8d5ca4bd350603085c3cb9f6a51269e075
This commit is contained in:
parent
408ed3f4b5
commit
fd25ba1f84
@ -61,9 +61,9 @@ nsresult BrowserBridgeParent::Init(const nsString& aPresentationURL,
|
||||
constructorSender->ChildID());
|
||||
|
||||
// Construct the BrowserParent object for our subframe.
|
||||
RefPtr<BrowserParent> browserParent(
|
||||
new BrowserParent(constructorSender, tabId, tabContext, aBrowsingContext,
|
||||
aChromeFlags, this));
|
||||
RefPtr<BrowserParent> browserParent(new BrowserParent(
|
||||
constructorSender, tabId, tabContext, aBrowsingContext, aChromeFlags));
|
||||
browserParent->SetBrowserBridgeParent(this);
|
||||
|
||||
// Open a remote endpoint for our PBrowser actor. DeallocPBrowserParent
|
||||
// releases the ref taken.
|
||||
|
@ -12,7 +12,9 @@
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
BrowserHost::BrowserHost(BrowserParent* aParent) : mRoot(aParent) {}
|
||||
BrowserHost::BrowserHost(BrowserParent* aParent) : mRoot(aParent) {
|
||||
mRoot->SetBrowserHost(this);
|
||||
}
|
||||
|
||||
mozilla::layers::LayersId BrowserHost::GetLayersId() const {
|
||||
return mRoot->GetRenderFrame()->GetLayersId();
|
||||
|
@ -173,8 +173,7 @@ NS_IMPL_CYCLE_COLLECTING_RELEASE(BrowserParent)
|
||||
BrowserParent::BrowserParent(ContentParent* aManager, const TabId& aTabId,
|
||||
const TabContext& aContext,
|
||||
CanonicalBrowsingContext* aBrowsingContext,
|
||||
uint32_t aChromeFlags,
|
||||
BrowserBridgeParent* aBrowserBridgeParent)
|
||||
uint32_t aChromeFlags)
|
||||
: TabContext(aContext),
|
||||
mTabId(aTabId),
|
||||
mManager(aManager),
|
||||
@ -184,7 +183,8 @@ BrowserParent::BrowserParent(ContentParent* aManager, const TabId& aTabId,
|
||||
mBrowserDOMWindow(nullptr),
|
||||
mFrameLoader(nullptr),
|
||||
mChromeFlags(aChromeFlags),
|
||||
mBrowserBridgeParent(aBrowserBridgeParent),
|
||||
mBrowserBridgeParent(nullptr),
|
||||
mBrowserHost(nullptr),
|
||||
mContentCache(*this),
|
||||
mRenderFrame{},
|
||||
mLayerTreeEpoch{1},
|
||||
@ -442,6 +442,12 @@ RenderFrame* BrowserParent::GetRenderFrame() {
|
||||
return &mRenderFrame;
|
||||
}
|
||||
|
||||
BrowserBridgeParent* BrowserParent::GetBrowserBridgeParent() const {
|
||||
return mBrowserBridgeParent;
|
||||
}
|
||||
|
||||
BrowserHost* BrowserParent::GetBrowserHost() const { return mBrowserHost; }
|
||||
|
||||
ShowInfo BrowserParent::GetShowInfo() {
|
||||
TryCacheDPIAndScale();
|
||||
if (mFrameElement) {
|
||||
@ -3827,6 +3833,24 @@ void BrowserParent::LiveResizeStarted() { SuppressDisplayport(true); }
|
||||
|
||||
void BrowserParent::LiveResizeStopped() { SuppressDisplayport(false); }
|
||||
|
||||
void BrowserParent::SetBrowserBridgeParent(BrowserBridgeParent* aBrowser) {
|
||||
// We should not have either a browser bridge or browser host yet
|
||||
MOZ_ASSERT(!mBrowserBridgeParent);
|
||||
MOZ_ASSERT(!mBrowserHost);
|
||||
// We should not have owner content yet
|
||||
MOZ_ASSERT(!mFrameElement);
|
||||
mBrowserBridgeParent = aBrowser;
|
||||
}
|
||||
|
||||
void BrowserParent::SetBrowserHost(BrowserHost* aBrowser) {
|
||||
// We should not have either a browser bridge or browser host yet
|
||||
MOZ_ASSERT(!mBrowserBridgeParent);
|
||||
MOZ_ASSERT(!mBrowserHost);
|
||||
// We should not have owner content yet
|
||||
MOZ_ASSERT(!mFrameElement);
|
||||
mBrowserHost = aBrowser;
|
||||
}
|
||||
|
||||
/* static */
|
||||
size_t BrowserParent::gNumActiveRecordReplayTabs;
|
||||
|
||||
|
@ -73,6 +73,8 @@ class ClonedMessageData;
|
||||
class ContentParent;
|
||||
class Element;
|
||||
class DataTransfer;
|
||||
class BrowserHost;
|
||||
class BrowserBridgeParent;
|
||||
|
||||
namespace ipc {
|
||||
class StructuredCloneData;
|
||||
@ -93,7 +95,6 @@ class BrowserParent final : public PBrowserParent,
|
||||
typedef mozilla::dom::ClonedMessageData ClonedMessageData;
|
||||
|
||||
friend class PBrowserParent;
|
||||
friend class BrowserBridgeParent; // for clearing mBrowserBridgeParent
|
||||
|
||||
virtual ~BrowserParent();
|
||||
|
||||
@ -113,8 +114,7 @@ class BrowserParent final : public PBrowserParent,
|
||||
BrowserParent(ContentParent* aManager, const TabId& aTabId,
|
||||
const TabContext& aContext,
|
||||
CanonicalBrowsingContext* aBrowsingContext,
|
||||
uint32_t aChromeFlags,
|
||||
BrowserBridgeParent* aBrowserBridgeParent = nullptr);
|
||||
uint32_t aChromeFlags);
|
||||
|
||||
// Call from LayoutStatics only
|
||||
static void InitializeStatics();
|
||||
@ -154,12 +154,6 @@ class BrowserParent final : public PBrowserParent,
|
||||
|
||||
nsIBrowserDOMWindow* GetBrowserDOMWindow() const { return mBrowserDOMWindow; }
|
||||
|
||||
// Returns the BrowserBridgeParent if this BrowserParent is for an
|
||||
// out-of-process iframe and nullptr otherwise.
|
||||
BrowserBridgeParent* GetBrowserBridgeParent() const {
|
||||
return mBrowserBridgeParent;
|
||||
}
|
||||
|
||||
already_AddRefed<nsPIDOMWindowOuter> GetParentWindowOuter();
|
||||
|
||||
already_AddRefed<nsIWidget> GetTopLevelWidget();
|
||||
@ -179,6 +173,14 @@ class BrowserParent final : public PBrowserParent,
|
||||
|
||||
layout::RenderFrame* GetRenderFrame();
|
||||
|
||||
// Returns the BrowserBridgeParent if this BrowserParent is for an
|
||||
// out-of-process iframe and nullptr otherwise.
|
||||
BrowserBridgeParent* GetBrowserBridgeParent() const;
|
||||
|
||||
// Returns the BrowserHost if this BrowserParent is for a top-level browser
|
||||
// and nullptr otherwise.
|
||||
BrowserHost* GetBrowserHost() const;
|
||||
|
||||
ShowInfo GetShowInfo();
|
||||
|
||||
/**
|
||||
@ -677,6 +679,12 @@ class BrowserParent final : public PBrowserParent,
|
||||
void SkipBrowsingContextDetach();
|
||||
|
||||
protected:
|
||||
friend BrowserBridgeParent;
|
||||
friend BrowserHost;
|
||||
|
||||
void SetBrowserBridgeParent(BrowserBridgeParent* aBrowser);
|
||||
void SetBrowserHost(BrowserHost* aBrowser);
|
||||
|
||||
bool ReceiveMessage(
|
||||
const nsString& aMessage, bool aSync, ipc::StructuredCloneData* aData,
|
||||
mozilla::jsipc::CpowHolder* aCpows, nsIPrincipal* aPrincipal,
|
||||
@ -787,6 +795,10 @@ class BrowserParent final : public PBrowserParent,
|
||||
// by the BrowserBridgeParent instance, which has the strong reference
|
||||
// to this BrowserParent.
|
||||
BrowserBridgeParent* mBrowserBridgeParent;
|
||||
// Pointer to the BrowserHost that owns us, if any. This is mutually
|
||||
// exclusive with mBrowserBridgeParent, and one is guaranteed to be
|
||||
// non-null.
|
||||
BrowserHost* mBrowserHost;
|
||||
|
||||
ContentCacheInParent mContentCache;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user