зеркало из https://github.com/mozilla/gecko-dev.git
Backed out 10 changesets (bug 1523638
) for causing high frequency Android 7.0 mochitests failures CLOSED TREE
Backed out changeset 644ceb2fe568 (bug1523638
) Backed out changeset 27647ee7a927 (bug1523638
) Backed out changeset 96f1ccb95570 (bug1523638
) Backed out changeset b60a17ea716a (bug1523638
) Backed out changeset 507e63186c5f (bug1523638
) Backed out changeset 33255408ca61 (bug1523638
) Backed out changeset d97b2d223616 (bug1523638
) Backed out changeset eba2a0514cde (bug1523638
) Backed out changeset d7065174c5c4 (bug1523638
) Backed out changeset c21b361e175d (bug1523638
)
This commit is contained in:
Родитель
c2592a1c3b
Коммит
c0756f3389
|
@ -307,10 +307,9 @@ static void DecreasePrivateDocShellCount() {
|
|||
}
|
||||
}
|
||||
|
||||
nsDocShell::nsDocShell(BrowsingContext* aBrowsingContext,
|
||||
uint64_t aContentWindowID)
|
||||
nsDocShell::nsDocShell(BrowsingContext* aBrowsingContext)
|
||||
: nsDocLoader(),
|
||||
mContentWindowID(aContentWindowID),
|
||||
mContentWindowID(NextWindowID()),
|
||||
mBrowsingContext(aBrowsingContext),
|
||||
mForcedCharset(nullptr),
|
||||
mParentCharset(nullptr),
|
||||
|
@ -396,11 +395,6 @@ nsDocShell::nsDocShell(BrowsingContext* aBrowsingContext,
|
|||
|
||||
nsContentUtils::GenerateUUIDInPlace(mHistoryID);
|
||||
|
||||
// If no outer window ID was provided, generate a new one.
|
||||
if (aContentWindowID == 0) {
|
||||
mContentWindowID = nsContentUtils::GenerateWindowId();
|
||||
}
|
||||
|
||||
if (gDocShellCount++ == 0) {
|
||||
NS_ASSERTION(sURIFixup == nullptr,
|
||||
"Huh, sURIFixup not null in first nsDocShell ctor!");
|
||||
|
@ -467,11 +461,11 @@ nsDocShell::~nsDocShell() {
|
|||
|
||||
/* static */
|
||||
already_AddRefed<nsDocShell> nsDocShell::Create(
|
||||
BrowsingContext* aBrowsingContext, uint64_t aContentWindowID) {
|
||||
BrowsingContext* aBrowsingContext) {
|
||||
MOZ_ASSERT(aBrowsingContext, "DocShell without a BrowsingContext!");
|
||||
|
||||
nsresult rv;
|
||||
RefPtr<nsDocShell> ds = new nsDocShell(aBrowsingContext, aContentWindowID);
|
||||
RefPtr<nsDocShell> ds = new nsDocShell(aBrowsingContext);
|
||||
|
||||
// Initialize the underlying nsDocLoader.
|
||||
rv = ds->nsDocLoader::Init();
|
||||
|
@ -525,7 +519,6 @@ already_AddRefed<nsDocShell> nsDocShell::Create(
|
|||
|
||||
// Make |ds| the primary DocShell for the given context.
|
||||
aBrowsingContext->SetDocShell(ds);
|
||||
|
||||
return ds.forget();
|
||||
}
|
||||
|
||||
|
@ -6376,12 +6369,12 @@ nsresult nsDocShell::RefreshURIFromQueue() {
|
|||
}
|
||||
|
||||
nsresult nsDocShell::Embed(nsIContentViewer* aContentViewer,
|
||||
WindowGlobalChild* aWindowActor) {
|
||||
const char* aCommand, nsISupports* aExtraInfo) {
|
||||
// Save the LayoutHistoryState of the previous document, before
|
||||
// setting up new document
|
||||
PersistLayoutHistoryState();
|
||||
|
||||
nsresult rv = SetupNewViewer(aContentViewer, aWindowActor);
|
||||
nsresult rv = SetupNewViewer(aContentViewer);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// XXX What if SetupNewViewer fails?
|
||||
|
@ -7017,7 +7010,6 @@ nsresult nsDocShell::EnsureContentViewer() {
|
|||
nsCOMPtr<nsIURI> baseURI;
|
||||
nsIPrincipal* principal = GetInheritedPrincipal(false);
|
||||
nsIPrincipal* storagePrincipal = GetInheritedPrincipal(false, true);
|
||||
|
||||
nsCOMPtr<nsIDocShellTreeItem> parentItem;
|
||||
GetSameTypeParent(getter_AddRefs(parentItem));
|
||||
if (parentItem) {
|
||||
|
@ -7059,14 +7051,11 @@ nsresult nsDocShell::EnsureContentViewer() {
|
|||
nsresult nsDocShell::CreateAboutBlankContentViewer(
|
||||
nsIPrincipal* aPrincipal, nsIPrincipal* aStoragePrincipal,
|
||||
nsIContentSecurityPolicy* aCSP, nsIURI* aBaseURI,
|
||||
bool aTryToSaveOldPresentation, bool aCheckPermitUnload,
|
||||
WindowGlobalChild* aActor) {
|
||||
bool aTryToSaveOldPresentation, bool aCheckPermitUnload) {
|
||||
RefPtr<Document> blankDoc;
|
||||
nsCOMPtr<nsIContentViewer> viewer;
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
|
||||
MOZ_ASSERT_IF(aActor, aActor->DocumentPrincipal() == aPrincipal);
|
||||
|
||||
/* mCreatingDocument should never be true at this point. However, it's
|
||||
a theoretical possibility. We want to know about it and make it stop,
|
||||
and this sounds like a job for an assertion. */
|
||||
|
@ -7195,7 +7184,7 @@ nsresult nsDocShell::CreateAboutBlankContentViewer(
|
|||
// hook 'em up
|
||||
if (viewer) {
|
||||
viewer->SetContainer(this);
|
||||
rv = Embed(viewer, aActor);
|
||||
rv = Embed(viewer, "", 0);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
SetCurrentURI(blankDoc->GetDocumentURI(), nullptr, true, 0);
|
||||
|
@ -7225,32 +7214,6 @@ nsDocShell::CreateAboutBlankContentViewer(nsIPrincipal* aPrincipal,
|
|||
nullptr);
|
||||
}
|
||||
|
||||
nsresult nsDocShell::CreateContentViewerForActor(
|
||||
WindowGlobalChild* aWindowActor) {
|
||||
MOZ_ASSERT(aWindowActor);
|
||||
|
||||
// FIXME: WindowGlobalChild should provide the StoragePrincipal.
|
||||
nsresult rv = CreateAboutBlankContentViewer(
|
||||
aWindowActor->DocumentPrincipal(), aWindowActor->DocumentPrincipal(),
|
||||
/* aCsp */ nullptr,
|
||||
/* aBaseURI */ nullptr,
|
||||
/* aTryToSaveOldPresentation */ true,
|
||||
/* aCheckPermitUnload */ true, aWindowActor);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
RefPtr<Document> doc(GetDocument());
|
||||
MOZ_ASSERT(
|
||||
doc,
|
||||
"Should have a document if CreateAboutBlankContentViewer succeeded");
|
||||
MOZ_ASSERT(doc->GetOwnerGlobal() == aWindowActor->WindowGlobal(),
|
||||
"New document should be in the same global as our actor");
|
||||
|
||||
// FIXME: We may want to support non-initial documents here.
|
||||
doc->SetIsInitialDocument(true);
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
bool nsDocShell::CanSavePresentation(uint32_t aLoadType,
|
||||
nsIRequest* aNewRequest,
|
||||
Document* aNewDocument) {
|
||||
|
@ -8378,7 +8341,7 @@ nsresult nsDocShell::CreateContentViewer(const nsACString& aContentType,
|
|||
}
|
||||
}
|
||||
|
||||
NS_ENSURE_SUCCESS(Embed(viewer), NS_ERROR_FAILURE);
|
||||
NS_ENSURE_SUCCESS(Embed(viewer, "", nullptr), NS_ERROR_FAILURE);
|
||||
|
||||
if (TreatAsBackgroundLoad()) {
|
||||
nsCOMPtr<nsIRunnable> triggerParentCheckDocShell =
|
||||
|
@ -8451,8 +8414,7 @@ nsresult nsDocShell::NewContentViewerObj(const nsACString& aContentType,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsDocShell::SetupNewViewer(nsIContentViewer* aNewViewer,
|
||||
WindowGlobalChild* aWindowActor) {
|
||||
nsresult nsDocShell::SetupNewViewer(nsIContentViewer* aNewViewer) {
|
||||
MOZ_ASSERT(!mIsBeingDestroyed);
|
||||
|
||||
//
|
||||
|
@ -8576,7 +8538,7 @@ nsresult nsDocShell::SetupNewViewer(nsIContentViewer* aNewViewer,
|
|||
|
||||
mContentViewer->SetNavigationTiming(mTiming);
|
||||
|
||||
if (NS_FAILED(mContentViewer->Init(widget, bounds, aWindowActor))) {
|
||||
if (NS_FAILED(mContentViewer->Init(widget, bounds))) {
|
||||
mContentViewer = nullptr;
|
||||
NS_WARNING("ContentViewer Initialization failed");
|
||||
return NS_ERROR_FAILURE;
|
||||
|
|
|
@ -201,8 +201,7 @@ class nsDocShell final : public nsDocLoader,
|
|||
|
||||
// Create a new nsDocShell object, initializing it.
|
||||
static already_AddRefed<nsDocShell> Create(
|
||||
mozilla::dom::BrowsingContext* aBrowsingContext,
|
||||
uint64_t aContentWindowID = 0);
|
||||
mozilla::dom::BrowsingContext* aBrowsingContext);
|
||||
|
||||
NS_IMETHOD Stop() override {
|
||||
// Need this here because otherwise nsIWebNavigation::Stop
|
||||
|
@ -474,11 +473,6 @@ class nsDocShell final : public nsDocLoader,
|
|||
mSkipBrowsingContextDetachOnDestroy = true;
|
||||
}
|
||||
|
||||
// Create a content viewer within this nsDocShell for the given
|
||||
// `WindowGlobalChild` actor.
|
||||
nsresult CreateContentViewerForActor(
|
||||
mozilla::dom::WindowGlobalChild* aWindowActor);
|
||||
|
||||
private: // member functions
|
||||
friend class nsDSURIContentListener;
|
||||
friend class FramingChecker;
|
||||
|
@ -503,8 +497,7 @@ class nsDocShell final : public nsDocLoader,
|
|||
friend void mozilla::TimelineConsumers::PopMarkers(
|
||||
nsDocShell*, JSContext*, nsTArray<dom::ProfileTimelineMarker>&);
|
||||
|
||||
nsDocShell(mozilla::dom::BrowsingContext* aBrowsingContext,
|
||||
uint64_t aContentWindowID);
|
||||
explicit nsDocShell(mozilla::dom::BrowsingContext* aBrowsingContext);
|
||||
|
||||
// Security checks to prevent frameset spoofing. See comments at
|
||||
// implementation sites.
|
||||
|
@ -558,11 +551,12 @@ class nsDocShell final : public nsDocLoader,
|
|||
// aPrincipal can be passed in if the caller wants. If null is
|
||||
// passed in, the about:blank principal will end up being used.
|
||||
// aCSP, if any, will be used for the new about:blank load.
|
||||
nsresult CreateAboutBlankContentViewer(
|
||||
nsIPrincipal* aPrincipal, nsIPrincipal* aStoragePrincipal,
|
||||
nsIContentSecurityPolicy* aCSP, nsIURI* aBaseURI,
|
||||
bool aTryToSaveOldPresentation = true, bool aCheckPermitUnload = true,
|
||||
mozilla::dom::WindowGlobalChild* aActor = nullptr);
|
||||
nsresult CreateAboutBlankContentViewer(nsIPrincipal* aPrincipal,
|
||||
nsIPrincipal* aStoragePrincipal,
|
||||
nsIContentSecurityPolicy* aCSP,
|
||||
nsIURI* aBaseURI,
|
||||
bool aTryToSaveOldPresentation = true,
|
||||
bool aCheckPermitUnload = true);
|
||||
|
||||
nsresult CreateContentViewer(const nsACString& aContentType,
|
||||
nsIRequest* aRequest,
|
||||
|
@ -573,9 +567,7 @@ class nsDocShell final : public nsDocLoader,
|
|||
nsIStreamListener** aContentHandler,
|
||||
nsIContentViewer** aViewer);
|
||||
|
||||
nsresult SetupNewViewer(
|
||||
nsIContentViewer* aNewViewer,
|
||||
mozilla::dom::WindowGlobalChild* aWindowActor = nullptr);
|
||||
nsresult SetupNewViewer(nsIContentViewer* aNewViewer);
|
||||
|
||||
//
|
||||
// Session History
|
||||
|
@ -988,8 +980,8 @@ class nsDocShell final : public nsDocLoader,
|
|||
nsresult EnsureFind();
|
||||
nsresult EnsureCommandHandler();
|
||||
nsresult RefreshURIFromQueue();
|
||||
nsresult Embed(nsIContentViewer* aContentViewer,
|
||||
mozilla::dom::WindowGlobalChild* aWindowActor = nullptr);
|
||||
nsresult Embed(nsIContentViewer* aContentViewer, const char* aCommand,
|
||||
nsISupports* aExtraInfo);
|
||||
nsPresContext* GetEldestPresContext();
|
||||
nsresult CheckLoadingPermissions();
|
||||
nsresult PersistLayoutHistoryState();
|
||||
|
|
|
@ -21,10 +21,7 @@ class nsDOMNavigationTiming;
|
|||
namespace mozilla {
|
||||
class Encoding;
|
||||
class PresShell;
|
||||
namespace dom {
|
||||
class WindowGlobalChild;
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
}
|
||||
%}
|
||||
|
||||
[ptr] native nsIWidgetPtr(nsIWidget);
|
||||
|
@ -35,14 +32,12 @@ class WindowGlobalChild;
|
|||
[ref] native nsIContentViewerTArray(nsTArray<nsCOMPtr<nsIContentViewer> >);
|
||||
[ptr] native Encoding(const mozilla::Encoding);
|
||||
[ptr] native PresShellPtr(mozilla::PresShell);
|
||||
[ptr] native WindowGlobalChildPtr(mozilla::dom::WindowGlobalChild);
|
||||
|
||||
[scriptable, builtinclass, uuid(2da17016-7851-4a45-a7a8-00b360e01595)]
|
||||
interface nsIContentViewer : nsISupports
|
||||
{
|
||||
[noscript] void init(in nsIWidgetPtr aParentWidget,
|
||||
[const] in nsIntRectRef aBounds,
|
||||
in WindowGlobalChildPtr aWindowActor);
|
||||
[const] in nsIntRectRef aBounds);
|
||||
|
||||
attribute nsIDocShell container;
|
||||
|
||||
|
|
|
@ -834,7 +834,7 @@ nsresult ExternalResourceMap::AddExternalResource(nsIURI* aURI,
|
|||
// Make sure that hiding our viewer will tear down its presentation.
|
||||
aViewer->SetSticky(false);
|
||||
|
||||
rv = aViewer->Init(nullptr, nsIntRect(0, 0, 0, 0), nullptr);
|
||||
rv = aViewer->Init(nullptr, nsIntRect(0, 0, 0, 0));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
rv = aViewer->Open(nullptr, nullptr);
|
||||
}
|
||||
|
@ -3375,8 +3375,9 @@ void Document::SetDocumentURI(nsIURI* aURI) {
|
|||
|
||||
// Tell our WindowGlobalParent that the document's URI has been changed.
|
||||
nsPIDOMWindowInner* inner = GetInnerWindow();
|
||||
if (inner && inner->GetWindowGlobalChild()) {
|
||||
inner->GetWindowGlobalChild()->SetDocumentURI(mDocumentURI);
|
||||
WindowGlobalChild* wgc = inner ? inner->GetWindowGlobalChild() : nullptr;
|
||||
if (wgc) {
|
||||
Unused << wgc->SendUpdateDocumentURI(mDocumentURI);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -9848,12 +9848,8 @@ bool nsContentUtils::IsLocalRefURL(const nsString& aString) {
|
|||
return !aString.IsEmpty() && aString[0] == '#';
|
||||
}
|
||||
|
||||
// We use only 53 bits for the ID so that it can be converted to and from a JS
|
||||
// value without loss of precision. The upper bits of the ID hold the process
|
||||
// ID. The lower bits identify the object itself.
|
||||
static constexpr uint64_t kIdTotalBits = 53;
|
||||
static constexpr uint64_t kIdProcessBits = 22;
|
||||
static constexpr uint64_t kIdBits = kIdTotalBits - kIdProcessBits;
|
||||
static const uint64_t kIdProcessBits = 32;
|
||||
static const uint64_t kIdBits = 64 - kIdProcessBits;
|
||||
|
||||
/* static */ uint64_t GenerateProcessSpecificId(uint64_t aId) {
|
||||
uint64_t processId = 0;
|
||||
|
@ -9878,7 +9874,7 @@ static constexpr uint64_t kIdBits = kIdTotalBits - kIdProcessBits;
|
|||
return (processBits << kIdBits) | bits;
|
||||
}
|
||||
|
||||
// Next process-local Tab ID.
|
||||
// Tab ID is composed in a similar manner of Window ID.
|
||||
static uint64_t gNextTabId = 0;
|
||||
|
||||
/* static */
|
||||
|
@ -9886,7 +9882,7 @@ uint64_t nsContentUtils::GenerateTabId() {
|
|||
return GenerateProcessSpecificId(++gNextTabId);
|
||||
}
|
||||
|
||||
// Next process-local Browsing Context ID.
|
||||
// Browsing context ID is composed in a similar manner of Window ID.
|
||||
static uint64_t gNextBrowsingContextId = 0;
|
||||
|
||||
/* static */
|
||||
|
@ -9894,14 +9890,6 @@ uint64_t nsContentUtils::GenerateBrowsingContextId() {
|
|||
return GenerateProcessSpecificId(++gNextBrowsingContextId);
|
||||
}
|
||||
|
||||
// Next process-local Window ID.
|
||||
static uint64_t gNextWindowId = 0;
|
||||
|
||||
/* static */
|
||||
uint64_t nsContentUtils::GenerateWindowId() {
|
||||
return GenerateProcessSpecificId(++gNextWindowId);
|
||||
}
|
||||
|
||||
/* static */
|
||||
bool nsContentUtils::GetUserIsInteracting() {
|
||||
return UserInteractionObserver::sUserActive;
|
||||
|
|
|
@ -3075,12 +3075,6 @@ class nsContentUtils {
|
|||
*/
|
||||
static uint64_t GenerateBrowsingContextId();
|
||||
|
||||
/**
|
||||
* Generate a window ID which is unique across processes and will never be
|
||||
* recycled.
|
||||
*/
|
||||
static uint64_t GenerateWindowId();
|
||||
|
||||
/**
|
||||
* Determine whether or not the user is currently interacting with the web
|
||||
* browser. This method is safe to call from off of the main thread.
|
||||
|
|
|
@ -838,9 +838,8 @@ class PromiseDocumentFlushedResolver final {
|
|||
//*** nsGlobalWindowInner: Object Management
|
||||
//*****************************************************************************
|
||||
|
||||
nsGlobalWindowInner::nsGlobalWindowInner(nsGlobalWindowOuter* aOuterWindow,
|
||||
WindowGlobalChild* aActor)
|
||||
: nsPIDOMWindowInner(aOuterWindow, aActor),
|
||||
nsGlobalWindowInner::nsGlobalWindowInner(nsGlobalWindowOuter* aOuterWindow)
|
||||
: nsPIDOMWindowInner(aOuterWindow),
|
||||
mozilla::webgpu::InstanceProvider(this),
|
||||
mWasOffline(false),
|
||||
mHasHadSlowScript(false),
|
||||
|
@ -1616,7 +1615,9 @@ void nsGlobalWindowInner::InnerSetNewDocument(JSContext* aCx,
|
|||
// FIXME: Currently, devtools can crete a fallback webextension window global
|
||||
// in the content process which does not have a corresponding BrowserChild
|
||||
// actor. This means we have no actor to be our parent. (Bug 1498293)
|
||||
if (!mWindowGlobalChild && (XRE_IsParentProcess() || mBrowserChild)) {
|
||||
MOZ_DIAGNOSTIC_ASSERT(!mWindowGlobalChild,
|
||||
"Shouldn't have created WindowGlobalChild yet!");
|
||||
if (XRE_IsParentProcess() || mBrowserChild) {
|
||||
mWindowGlobalChild = WindowGlobalChild::Create(this);
|
||||
}
|
||||
|
||||
|
@ -7139,19 +7140,13 @@ mozilla::dom::TabGroup* nsPIDOMWindowInner::TabGroup() {
|
|||
|
||||
/* static */
|
||||
already_AddRefed<nsGlobalWindowInner> nsGlobalWindowInner::Create(
|
||||
nsGlobalWindowOuter* aOuterWindow, bool aIsChrome,
|
||||
WindowGlobalChild* aActor) {
|
||||
RefPtr<nsGlobalWindowInner> window =
|
||||
new nsGlobalWindowInner(aOuterWindow, aActor);
|
||||
nsGlobalWindowOuter* aOuterWindow, bool aIsChrome) {
|
||||
RefPtr<nsGlobalWindowInner> window = new nsGlobalWindowInner(aOuterWindow);
|
||||
if (aIsChrome) {
|
||||
window->mIsChrome = true;
|
||||
window->mCleanMessageManager = true;
|
||||
}
|
||||
|
||||
if (aActor) {
|
||||
aActor->InitWindowGlobal(window);
|
||||
}
|
||||
|
||||
window->InitWasOffline();
|
||||
return window.forget();
|
||||
}
|
||||
|
@ -7204,8 +7199,14 @@ bool nsPIDOMWindowInner::HasStorageAccessGranted(
|
|||
return mStorageAccessGranted.Contains(aPermissionKey);
|
||||
}
|
||||
|
||||
nsPIDOMWindowInner::nsPIDOMWindowInner(nsPIDOMWindowOuter* aOuterWindow,
|
||||
WindowGlobalChild* aActor)
|
||||
// XXX: Can we define this in a header instead of here?
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
extern uint64_t NextWindowID();
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
nsPIDOMWindowInner::nsPIDOMWindowInner(nsPIDOMWindowOuter* aOuterWindow)
|
||||
: mMutationBits(0),
|
||||
mActivePeerConnections(0),
|
||||
mIsDocumentLoaded(false),
|
||||
|
@ -7217,24 +7218,16 @@ nsPIDOMWindowInner::nsPIDOMWindowInner(nsPIDOMWindowOuter* aOuterWindow,
|
|||
mMayHavePointerEnterLeaveEventListener(false),
|
||||
mMayHaveTextEventListenerInDefaultGroup(false),
|
||||
mOuterWindow(aOuterWindow),
|
||||
mWindowID(0),
|
||||
// Make sure no actual window ends up with mWindowID == 0
|
||||
mWindowID(NextWindowID()),
|
||||
mHasNotifiedGlobalCreated(false),
|
||||
mMarkedCCGeneration(0),
|
||||
mHasTriedToCacheTopInnerWindow(false),
|
||||
mNumOfIndexedDBDatabases(0),
|
||||
mNumOfOpenWebSockets(0),
|
||||
mEvent(nullptr),
|
||||
mWindowGlobalChild(aActor) {
|
||||
mEvent(nullptr) {
|
||||
MOZ_ASSERT(aOuterWindow);
|
||||
mBrowsingContext = aOuterWindow->GetBrowsingContext();
|
||||
|
||||
if (mWindowGlobalChild) {
|
||||
mWindowID = aActor->InnerWindowId();
|
||||
|
||||
MOZ_ASSERT(mWindowGlobalChild->BrowsingContext() == mBrowsingContext);
|
||||
} else {
|
||||
mWindowID = nsContentUtils::GenerateWindowId();
|
||||
}
|
||||
}
|
||||
|
||||
void nsPIDOMWindowInner::RegisterReportingObserver(ReportingObserver* aObserver,
|
||||
|
|
|
@ -232,8 +232,7 @@ class nsGlobalWindowInner final : public mozilla::dom::EventTarget,
|
|||
}
|
||||
|
||||
static already_AddRefed<nsGlobalWindowInner> Create(
|
||||
nsGlobalWindowOuter* aOuter, bool aIsChrome,
|
||||
mozilla::dom::WindowGlobalChild* aActor);
|
||||
nsGlobalWindowOuter* aOuter, bool aIsChrome);
|
||||
|
||||
// nsISupports
|
||||
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
||||
|
@ -619,8 +618,7 @@ class nsGlobalWindowInner final : public mozilla::dom::EventTarget,
|
|||
mozilla::ErrorResult& aError);
|
||||
|
||||
protected:
|
||||
explicit nsGlobalWindowInner(nsGlobalWindowOuter* aOuterWindow,
|
||||
mozilla::dom::WindowGlobalChild* aActor);
|
||||
explicit nsGlobalWindowInner(nsGlobalWindowOuter* aOuterWindow);
|
||||
// Initializes the mWasOffline member variable
|
||||
void InitWasOffline();
|
||||
|
||||
|
|
|
@ -1875,8 +1875,7 @@ static nsresult CreateNativeGlobalForInner(JSContext* aCx,
|
|||
|
||||
nsresult nsGlobalWindowOuter::SetNewDocument(Document* aDocument,
|
||||
nsISupports* aState,
|
||||
bool aForceReuseInnerWindow,
|
||||
WindowGlobalChild* aActor) {
|
||||
bool aForceReuseInnerWindow) {
|
||||
MOZ_ASSERT(mDocumentPrincipal == nullptr,
|
||||
"mDocumentPrincipal prematurely set!");
|
||||
MOZ_ASSERT(mDocumentStoragePrincipal == nullptr,
|
||||
|
@ -2009,7 +2008,7 @@ nsresult nsGlobalWindowOuter::SetNewDocument(Document* aDocument,
|
|||
newInnerWindow = wsh->GetInnerWindow();
|
||||
newInnerGlobal = newInnerWindow->GetWrapper();
|
||||
} else {
|
||||
newInnerWindow = nsGlobalWindowInner::Create(this, thisChrome, aActor);
|
||||
newInnerWindow = nsGlobalWindowInner::Create(this, thisChrome);
|
||||
if (StaticPrefs::dom_timeout_defer_during_load()) {
|
||||
// ensure the initial loading state is known
|
||||
newInnerWindow->SetActiveLoadingState(
|
||||
|
@ -2216,9 +2215,9 @@ nsresult nsGlobalWindowOuter::SetNewDocument(Document* aDocument,
|
|||
|
||||
// Tell the WindowGlobalParent that it should become the current window global
|
||||
// for our BrowsingContext if it isn't already.
|
||||
WindowGlobalChild* wgc = mInnerWindow->GetWindowGlobalChild();
|
||||
wgc->SetDocumentURI(aDocument->GetDocumentURI());
|
||||
wgc->SendBecomeCurrentWindowGlobal();
|
||||
mInnerWindow->GetWindowGlobalChild()->SendUpdateDocumentURI(
|
||||
aDocument->GetDocumentURI());
|
||||
mInnerWindow->GetWindowGlobalChild()->SendBecomeCurrentWindowGlobal();
|
||||
|
||||
// We no longer need the old inner window. Start its destruction if
|
||||
// its not being reused and clear our reference.
|
||||
|
|
|
@ -312,9 +312,8 @@ class nsGlobalWindowOuter final : public mozilla::dom::EventTarget,
|
|||
|
||||
void DetachFromDocShell();
|
||||
|
||||
virtual nsresult SetNewDocument(
|
||||
Document* aDocument, nsISupports* aState, bool aForceReuseInnerWindow,
|
||||
mozilla::dom::WindowGlobalChild* aActor = nullptr) override;
|
||||
virtual nsresult SetNewDocument(Document* aDocument, nsISupports* aState,
|
||||
bool aForceReuseInnerWindow) override;
|
||||
|
||||
// Outer windows only.
|
||||
static void PrepareForProcessChange(JSObject* aProxy);
|
||||
|
|
|
@ -140,8 +140,7 @@ class nsPIDOMWindowInner : public mozIDOMWindow {
|
|||
friend nsGlobalWindowInner;
|
||||
friend nsGlobalWindowOuter;
|
||||
|
||||
nsPIDOMWindowInner(nsPIDOMWindowOuter* aOuterWindow,
|
||||
mozilla::dom::WindowGlobalChild* aActor);
|
||||
explicit nsPIDOMWindowInner(nsPIDOMWindowOuter* aOuterWindow);
|
||||
|
||||
~nsPIDOMWindowInner();
|
||||
|
||||
|
@ -876,9 +875,8 @@ class nsPIDOMWindowOuter : public mozIDOMWindowProxy {
|
|||
*
|
||||
* aDocument must not be null.
|
||||
*/
|
||||
virtual nsresult SetNewDocument(
|
||||
Document* aDocument, nsISupports* aState, bool aForceReuseInnerWindow,
|
||||
mozilla::dom::WindowGlobalChild* aActor = nullptr) = 0;
|
||||
virtual nsresult SetNewDocument(Document* aDocument, nsISupports* aState,
|
||||
bool aForceReuseInnerWindow) = 0;
|
||||
|
||||
/**
|
||||
* Set the opener window. aOriginalOpener is true if and only if this is the
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
#include "mozilla/dom/ContentProcessManager.h"
|
||||
#include "mozilla/dom/CanonicalBrowsingContext.h"
|
||||
#include "mozilla/dom/BrowsingContextGroup.h"
|
||||
#include "mozilla/dom/WindowGlobalParent.h"
|
||||
#include "mozilla/layers/InputAPZContext.h"
|
||||
|
||||
using namespace mozilla::ipc;
|
||||
|
@ -35,13 +34,10 @@ BrowserBridgeParent::~BrowserBridgeParent() { Destroy(); }
|
|||
|
||||
nsresult BrowserBridgeParent::Init(const nsString& aPresentationURL,
|
||||
const nsString& aRemoteType,
|
||||
const WindowGlobalInit& aWindowInit,
|
||||
CanonicalBrowsingContext* aBrowsingContext,
|
||||
const uint32_t& aChromeFlags, TabId aTabId) {
|
||||
mIPCOpen = true;
|
||||
|
||||
RefPtr<CanonicalBrowsingContext> browsingContext =
|
||||
aWindowInit.browsingContext()->Canonical();
|
||||
|
||||
// We can inherit most TabContext fields for the new BrowserParent actor from
|
||||
// our Manager BrowserParent.
|
||||
//
|
||||
|
@ -66,8 +62,8 @@ nsresult BrowserBridgeParent::Init(const nsString& aPresentationURL,
|
|||
|
||||
// Ensure that our content process is subscribed to our newly created
|
||||
// BrowsingContextGroup.
|
||||
browsingContext->Group()->EnsureSubscribed(constructorSender);
|
||||
browsingContext->SetOwnerProcessId(constructorSender->ChildID());
|
||||
aBrowsingContext->Group()->EnsureSubscribed(constructorSender);
|
||||
aBrowsingContext->SetOwnerProcessId(constructorSender->ChildID());
|
||||
|
||||
ContentProcessManager* cpm = ContentProcessManager::GetSingleton();
|
||||
cpm->RegisterRemoteFrame(aTabId, ContentParentId(0), TabId(0),
|
||||
|
@ -75,8 +71,8 @@ nsresult BrowserBridgeParent::Init(const nsString& aPresentationURL,
|
|||
constructorSender->ChildID());
|
||||
|
||||
// Construct the BrowserParent object for our subframe.
|
||||
auto browserParent = MakeRefPtr<BrowserParent>(
|
||||
constructorSender, aTabId, tabContext, browsingContext, aChromeFlags);
|
||||
RefPtr<BrowserParent> browserParent(new BrowserParent(
|
||||
constructorSender, aTabId, tabContext, aBrowsingContext, aChromeFlags));
|
||||
browserParent->SetBrowserBridgeParent(this);
|
||||
|
||||
// Open a remote endpoint for our PBrowser actor. DeallocPBrowserParent
|
||||
|
@ -88,23 +84,11 @@ nsresult BrowserBridgeParent::Init(const nsString& aPresentationURL,
|
|||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
auto windowParent =
|
||||
MakeRefPtr<WindowGlobalParent>(aWindowInit, /* inprocess */ false);
|
||||
|
||||
// DeallocPWindowGlobalParent releases the ref taken.
|
||||
ManagedEndpoint<PWindowGlobalChild> windowChildEp =
|
||||
browserParent->OpenPWindowGlobalEndpoint(do_AddRef(windowParent).take());
|
||||
if (NS_WARN_IF(!windowChildEp.IsValid())) {
|
||||
MOZ_ASSERT(false, "WindowGlobal Open Endpoint Failed");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
// Tell the content process to set up its PBrowserChild.
|
||||
bool ok = constructorSender->SendConstructBrowser(
|
||||
std::move(childEp), std::move(windowChildEp), aTabId, TabId(0),
|
||||
tabContext.AsIPCTabContext(), aWindowInit, aChromeFlags,
|
||||
constructorSender->ChildID(), constructorSender->IsForBrowser(),
|
||||
/* aIsTopLevel */ false);
|
||||
std::move(childEp), aTabId, TabId(0), tabContext.AsIPCTabContext(),
|
||||
aBrowsingContext, aChromeFlags, constructorSender->ChildID(),
|
||||
constructorSender->IsForBrowser(), /* aIsTopLevel */ false);
|
||||
if (NS_WARN_IF(!ok)) {
|
||||
MOZ_ASSERT(false, "Browser Constructor Failed");
|
||||
return NS_ERROR_FAILURE;
|
||||
|
@ -115,8 +99,6 @@ nsresult BrowserBridgeParent::Init(const nsString& aPresentationURL,
|
|||
mBrowserParent->SetOwnerElement(Manager()->GetOwnerElement());
|
||||
mBrowserParent->InitRendering();
|
||||
|
||||
windowParent->Init(aWindowInit);
|
||||
|
||||
// Send the newly created layers ID back into content.
|
||||
Unused << SendSetLayersId(mBrowserParent->GetLayersId());
|
||||
return NS_OK;
|
||||
|
|
|
@ -33,7 +33,7 @@ class BrowserBridgeParent : public PBrowserBridgeParent {
|
|||
|
||||
// Initialize this actor after performing startup.
|
||||
nsresult Init(const nsString& aPresentationURL, const nsString& aRemoteType,
|
||||
const WindowGlobalInit& aWindowInit,
|
||||
CanonicalBrowsingContext* aBrowsingContext,
|
||||
const uint32_t& aChromeFlags, TabId aTabId);
|
||||
|
||||
BrowserParent* GetBrowserParent() { return mBrowserParent; }
|
||||
|
|
|
@ -490,11 +490,8 @@ bool BrowserChild::DoUpdateZoomConstraints(
|
|||
return true;
|
||||
}
|
||||
|
||||
nsresult BrowserChild::Init(mozIDOMWindowProxy* aParent,
|
||||
WindowGlobalChild* aInitialWindowChild) {
|
||||
nsresult BrowserChild::Init(mozIDOMWindowProxy* aParent) {
|
||||
MOZ_DIAGNOSTIC_ASSERT(mTabGroup);
|
||||
MOZ_ASSERT_IF(aInitialWindowChild,
|
||||
aInitialWindowChild->BrowsingContext() == mBrowsingContext);
|
||||
|
||||
nsCOMPtr<nsIWidget> widget = nsIWidget::CreatePuppetWidget(this);
|
||||
mPuppetWidget = static_cast<PuppetWidget*>(widget.get());
|
||||
|
@ -505,10 +502,11 @@ nsresult BrowserChild::Init(mozIDOMWindowProxy* aParent,
|
|||
mPuppetWidget->InfallibleCreate(nullptr,
|
||||
nullptr, // no parents
|
||||
LayoutDeviceIntRect(0, 0, 0, 0),
|
||||
nullptr); // HandleWidgetEvent
|
||||
nullptr // HandleWidgetEvent
|
||||
);
|
||||
|
||||
mWebBrowser = nsWebBrowser::Create(this, mPuppetWidget, OriginAttributesRef(),
|
||||
mBrowsingContext, aInitialWindowChild);
|
||||
mBrowsingContext);
|
||||
nsIWebBrowser* webBrowser = mWebBrowser;
|
||||
|
||||
mWebNav = do_QueryInterface(webBrowser);
|
||||
|
@ -3287,9 +3285,11 @@ bool BrowserChild::DeallocPWindowGlobalChild(PWindowGlobalChild* aActor) {
|
|||
return true;
|
||||
}
|
||||
|
||||
PBrowserBridgeChild* BrowserChild::AllocPBrowserBridgeChild(
|
||||
const nsString&, const nsString&, const WindowGlobalInit&, const uint32_t&,
|
||||
const TabId&) {
|
||||
PBrowserBridgeChild* BrowserChild::AllocPBrowserBridgeChild(const nsString&,
|
||||
const nsString&,
|
||||
BrowsingContext*,
|
||||
const uint32_t&,
|
||||
const TabId&) {
|
||||
MOZ_CRASH(
|
||||
"We should never be manually allocating PBrowserBridgeChild actors");
|
||||
return nullptr;
|
||||
|
|
|
@ -190,8 +190,7 @@ class BrowserChild final : public nsMessageManagerScriptExecutor,
|
|||
const TabContext& aContext, BrowsingContext* aBrowsingContext,
|
||||
uint32_t aChromeFlags, bool aIsTopLevel);
|
||||
|
||||
nsresult Init(mozIDOMWindowProxy* aParent,
|
||||
WindowGlobalChild* aInitialWindowChild);
|
||||
nsresult Init(mozIDOMWindowProxy* aParent);
|
||||
|
||||
/** Return a BrowserChild with the given attributes. */
|
||||
static already_AddRefed<BrowserChild> Create(
|
||||
|
@ -666,7 +665,7 @@ class BrowserChild final : public nsMessageManagerScriptExecutor,
|
|||
|
||||
PBrowserBridgeChild* AllocPBrowserBridgeChild(
|
||||
const nsString& aName, const nsString& aRemoteType,
|
||||
const WindowGlobalInit& aWindowInit, const uint32_t& aChromeFlags,
|
||||
BrowsingContext* aBrowsingContext, const uint32_t& aChromeFlags,
|
||||
const TabId& aTabId);
|
||||
|
||||
bool DeallocPBrowserBridgeChild(PBrowserBridgeChild* aActor);
|
||||
|
|
|
@ -1235,30 +1235,31 @@ IPCResult BrowserParent::RecvIndexedDBPermissionRequest(
|
|||
return IPC_OK();
|
||||
}
|
||||
|
||||
IPCResult BrowserParent::RecvNewWindowGlobal(
|
||||
ManagedEndpoint<PWindowGlobalParent>&& aEndpoint,
|
||||
const WindowGlobalInit& aInit) {
|
||||
// Construct our new WindowGlobalParent, bind, and initialize it.
|
||||
auto wgp = MakeRefPtr<WindowGlobalParent>(aInit, /* inproc */ false);
|
||||
|
||||
// Reference freed in DeallocPWindowGlobalParent.
|
||||
BindPWindowGlobalEndpoint(std::move(aEndpoint), do_AddRef(wgp).take());
|
||||
wgp->Init(aInit);
|
||||
IPCResult BrowserParent::RecvPWindowGlobalConstructor(
|
||||
PWindowGlobalParent* aActor, const WindowGlobalInit& aInit) {
|
||||
static_cast<WindowGlobalParent*>(aActor)->Init(aInit);
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
PWindowGlobalParent* BrowserParent::AllocPWindowGlobalParent(
|
||||
const WindowGlobalInit& aInit) {
|
||||
// Reference freed in DeallocPWindowGlobalParent.
|
||||
return do_AddRef(new WindowGlobalParent(aInit, /* inproc */ false)).take();
|
||||
}
|
||||
|
||||
bool BrowserParent::DeallocPWindowGlobalParent(PWindowGlobalParent* aActor) {
|
||||
// Free reference from RecvNewWindowGlobal.
|
||||
// Free reference from AllocPWindowGlobalParent.
|
||||
static_cast<WindowGlobalParent*>(aActor)->Release();
|
||||
return true;
|
||||
}
|
||||
|
||||
IPCResult BrowserParent::RecvPBrowserBridgeConstructor(
|
||||
PBrowserBridgeParent* aActor, const nsString& aName,
|
||||
const nsString& aRemoteType, const WindowGlobalInit& aWindowInit,
|
||||
const nsString& aRemoteType, BrowsingContext* aBrowsingContext,
|
||||
const uint32_t& aChromeFlags, const TabId& aTabId) {
|
||||
nsresult rv = static_cast<BrowserBridgeParent*>(aActor)->Init(
|
||||
aName, aRemoteType, aWindowInit, aChromeFlags, aTabId);
|
||||
aName, aRemoteType, CanonicalBrowsingContext::Cast(aBrowsingContext),
|
||||
aChromeFlags, aTabId);
|
||||
if (NS_FAILED(rv)) {
|
||||
return IPC_FAIL(this, "Failed to construct BrowserBridgeParent");
|
||||
}
|
||||
|
@ -1267,7 +1268,7 @@ IPCResult BrowserParent::RecvPBrowserBridgeConstructor(
|
|||
|
||||
PBrowserBridgeParent* BrowserParent::AllocPBrowserBridgeParent(
|
||||
const nsString& aName, const nsString& aRemoteType,
|
||||
const WindowGlobalInit& aWindowInit, const uint32_t& aChromeFlags,
|
||||
BrowsingContext* aBrowsingContext, const uint32_t& aChromeFlags,
|
||||
const TabId& aTabId) {
|
||||
// Reference freed in DeallocPBrowserBridgeParent.
|
||||
return do_AddRef(new BrowserBridgeParent()).take();
|
||||
|
|
|
@ -470,22 +470,23 @@ class BrowserParent final : public PBrowserParent,
|
|||
const uint64_t& aParentID, const uint32_t& aMsaaID,
|
||||
const IAccessibleHolder& aDocCOMProxy) override;
|
||||
|
||||
PWindowGlobalParent* AllocPWindowGlobalParent(const WindowGlobalInit& aInit);
|
||||
|
||||
bool DeallocPWindowGlobalParent(PWindowGlobalParent* aActor);
|
||||
|
||||
mozilla::ipc::IPCResult RecvNewWindowGlobal(
|
||||
ManagedEndpoint<PWindowGlobalParent>&& aEndpoint,
|
||||
const WindowGlobalInit& aInit);
|
||||
virtual mozilla::ipc::IPCResult RecvPWindowGlobalConstructor(
|
||||
PWindowGlobalParent* aActor, const WindowGlobalInit& aInit) override;
|
||||
|
||||
PBrowserBridgeParent* AllocPBrowserBridgeParent(
|
||||
const nsString& aPresentationURL, const nsString& aRemoteType,
|
||||
const WindowGlobalInit& aWindowInit, const uint32_t& aChromeFlags,
|
||||
BrowsingContext* aBrowsingContext, const uint32_t& aChromeFlags,
|
||||
const TabId& aTabId);
|
||||
|
||||
bool DeallocPBrowserBridgeParent(PBrowserBridgeParent* aActor);
|
||||
|
||||
virtual mozilla::ipc::IPCResult RecvPBrowserBridgeConstructor(
|
||||
PBrowserBridgeParent* aActor, const nsString& aPresentationURL,
|
||||
const nsString& aRemoteType, const WindowGlobalInit& aWindowInit,
|
||||
const nsString& aRemoteType, BrowsingContext* aBrowsingContext,
|
||||
const uint32_t& aChromeFlags, const TabId& aTabId) override;
|
||||
|
||||
void LoadURL(nsIURI* aURI);
|
||||
|
|
|
@ -55,7 +55,6 @@
|
|||
#include "mozilla/dom/ServiceWorkerManager.h"
|
||||
#include "mozilla/dom/TabGroup.h"
|
||||
#include "mozilla/dom/URLClassifierChild.h"
|
||||
#include "mozilla/dom/WindowGlobalChild.h"
|
||||
#include "mozilla/dom/WorkerDebugger.h"
|
||||
#include "mozilla/dom/WorkerDebuggerManager.h"
|
||||
#include "mozilla/dom/ipc/SharedMap.h"
|
||||
|
@ -975,25 +974,9 @@ nsresult ContentChild::ProvideWindowCommon(
|
|||
nullptr, openerBC, aName, BrowsingContext::Type::Content);
|
||||
|
||||
TabContext newTabContext = aTabOpener ? *aTabOpener : TabContext();
|
||||
|
||||
// The initial about:blank document we generate within the nsDocShell will
|
||||
// almost certainly be replaced at some point. Unfortunately, getting the
|
||||
// principal right here causes bugs due to frame scripts not getting events
|
||||
// they expect, due to the real initial about:blank not being created yet.
|
||||
//
|
||||
// For this reason, we intentionally mispredict the initial principal here, so
|
||||
// that we can act the same as we did before when not predicting a result
|
||||
// principal. This `PWindowGlobal` will almost immediately be destroyed.
|
||||
nsCOMPtr<nsIPrincipal> initialPrincipal =
|
||||
NullPrincipal::Create(newTabContext.OriginAttributesRef());
|
||||
WindowGlobalInit windowInit = WindowGlobalActor::AboutBlankInitializer(
|
||||
browsingContext, initialPrincipal);
|
||||
|
||||
auto windowChild = MakeRefPtr<WindowGlobalChild>(windowInit, nullptr);
|
||||
|
||||
auto newChild = MakeRefPtr<BrowserChild>(this, tabId, tabGroup, newTabContext,
|
||||
browsingContext, aChromeFlags,
|
||||
/* aIsTopLevel */ true);
|
||||
RefPtr<BrowserChild> newChild =
|
||||
new BrowserChild(this, tabId, tabGroup, newTabContext, browsingContext,
|
||||
aChromeFlags, /* aIsTopLevel */ true);
|
||||
|
||||
if (aTabOpener) {
|
||||
MOZ_ASSERT(ipcContext->type() == IPCTabContext::TPopupIPCTabContext);
|
||||
|
@ -1016,26 +999,16 @@ nsresult ContentChild::ProvideWindowCommon(
|
|||
return NS_ERROR_ABORT;
|
||||
}
|
||||
|
||||
// Open a remote endpoint for our PWindowGlobal actor.
|
||||
// DeallocPWindowGlobalChild releases the ref taken.
|
||||
ManagedEndpoint<PWindowGlobalParent> windowParentEp =
|
||||
newChild->OpenPWindowGlobalEndpoint(do_AddRef(windowChild).take());
|
||||
if (NS_WARN_IF(!windowParentEp.IsValid())) {
|
||||
return NS_ERROR_ABORT;
|
||||
}
|
||||
|
||||
// Tell the parent process to set up its PBrowserParent.
|
||||
if (NS_WARN_IF(!SendConstructPopupBrowser(
|
||||
std::move(parentEp), std::move(windowParentEp), tabId, *ipcContext,
|
||||
windowInit, aChromeFlags))) {
|
||||
if (NS_WARN_IF(!SendConstructPopupBrowser(std::move(parentEp), tabId,
|
||||
*ipcContext, browsingContext,
|
||||
aChromeFlags))) {
|
||||
return NS_ERROR_ABORT;
|
||||
}
|
||||
|
||||
windowChild->Init();
|
||||
|
||||
// Now that |newChild| has had its IPC link established, call |Init| to set it
|
||||
// up.
|
||||
if (NS_FAILED(newChild->Init(aParent, windowChild))) {
|
||||
if (NS_FAILED(newChild->Init(aParent))) {
|
||||
return NS_ERROR_ABORT;
|
||||
}
|
||||
|
||||
|
@ -1834,10 +1807,9 @@ bool ContentChild::DeallocPJavaScriptChild(PJavaScriptChild* aChild) {
|
|||
}
|
||||
|
||||
mozilla::ipc::IPCResult ContentChild::RecvConstructBrowser(
|
||||
ManagedEndpoint<PBrowserChild>&& aBrowserEp,
|
||||
ManagedEndpoint<PWindowGlobalChild>&& aWindowEp, const TabId& aTabId,
|
||||
ManagedEndpoint<PBrowserChild>&& aBrowserEp, const TabId& aTabId,
|
||||
const TabId& aSameTabGroupAs, const IPCTabContext& aContext,
|
||||
const WindowGlobalInit& aWindowInit, const uint32_t& aChromeFlags,
|
||||
BrowsingContext* aBrowsingContext, const uint32_t& aChromeFlags,
|
||||
const ContentParentId& aCpID, const bool& aIsForBrowser,
|
||||
const bool& aIsTopLevel) {
|
||||
MOZ_ASSERT(!IsShuttingDown());
|
||||
|
@ -1868,11 +1840,9 @@ mozilla::ipc::IPCResult ContentChild::RecvConstructBrowser(
|
|||
MOZ_CRASH("Invalid TabContext received from the parent process.");
|
||||
}
|
||||
|
||||
auto windowChild = MakeRefPtr<WindowGlobalChild>(aWindowInit, nullptr);
|
||||
|
||||
RefPtr<BrowserChild> browserChild = BrowserChild::Create(
|
||||
this, aTabId, aSameTabGroupAs, tc.GetTabContext(),
|
||||
aWindowInit.browsingContext(), aChromeFlags, aIsTopLevel);
|
||||
RefPtr<BrowserChild> browserChild =
|
||||
BrowserChild::Create(this, aTabId, aSameTabGroupAs, tc.GetTabContext(),
|
||||
aBrowsingContext, aChromeFlags, aIsTopLevel);
|
||||
|
||||
// Bind the created BrowserChild to IPC to actually link the actor. The ref
|
||||
// here is released in DeallocPBrowserChild.
|
||||
|
@ -1881,14 +1851,6 @@ mozilla::ipc::IPCResult ContentChild::RecvConstructBrowser(
|
|||
return IPC_FAIL(this, "BindPBrowserEndpoint failed");
|
||||
}
|
||||
|
||||
// The ref here is released in DeallocPWindowGlobalChild.
|
||||
if (NS_WARN_IF(!browserChild->BindPWindowGlobalEndpoint(
|
||||
std::move(aWindowEp), do_AddRef(windowChild).take()))) {
|
||||
return IPC_FAIL(this, "BindPWindowGlobalEndpoint failed");
|
||||
}
|
||||
windowChild->Init();
|
||||
|
||||
// Ensure that a TabGroup is set for our BrowserChild before running `Init`.
|
||||
if (!browserChild->mTabGroup) {
|
||||
browserChild->mTabGroup = TabGroup::GetFromActor(browserChild);
|
||||
|
||||
|
@ -1898,8 +1860,7 @@ mozilla::ipc::IPCResult ContentChild::RecvConstructBrowser(
|
|||
}
|
||||
}
|
||||
|
||||
if (NS_WARN_IF(
|
||||
NS_FAILED(browserChild->Init(/* aOpener */ nullptr, windowChild)))) {
|
||||
if (NS_WARN_IF(NS_FAILED(browserChild->Init(/* aOpener */ nullptr)))) {
|
||||
return IPC_FAIL(browserChild, "BrowserChild::Init failed");
|
||||
}
|
||||
|
||||
|
@ -2108,17 +2069,14 @@ already_AddRefed<RemoteBrowser> ContentChild::CreateBrowser(
|
|||
chromeFlags |= nsIWebBrowserChrome::CHROME_PRIVATE_LIFETIME;
|
||||
}
|
||||
|
||||
WindowGlobalInit windowInit = WindowGlobalActor::AboutBlankInitializer(
|
||||
aBrowsingContext, owner->NodePrincipal());
|
||||
|
||||
TabId tabId(nsContentUtils::GenerateTabId());
|
||||
RefPtr<BrowserBridgeChild> browserBridge =
|
||||
new BrowserBridgeChild(aFrameLoader, aBrowsingContext, tabId);
|
||||
// Reference is freed in BrowserChild::DeallocPBrowserBridgeChild.
|
||||
browserChild->SendPBrowserBridgeConstructor(
|
||||
do_AddRef(browserBridge).take(),
|
||||
PromiseFlatString(aContext.PresentationURL()), aRemoteType, windowInit,
|
||||
chromeFlags, tabId);
|
||||
PromiseFlatString(aContext.PresentationURL()), aRemoteType,
|
||||
aBrowsingContext, chromeFlags, tabId);
|
||||
browserBridge->mIPCOpen = true;
|
||||
|
||||
#if defined(ACCESSIBILITY)
|
||||
|
@ -3255,6 +3213,48 @@ mozilla::ipc::IPCResult ContentChild::RecvSetAudioSessionData(
|
|||
#endif
|
||||
}
|
||||
|
||||
// This code goes here rather than nsGlobalWindow.cpp because nsGlobalWindow.cpp
|
||||
// can't include ContentChild.h since it includes windows.h.
|
||||
|
||||
static uint64_t gNextWindowID = 0;
|
||||
|
||||
// We use only 53 bits for the window ID so that it can be converted to and from
|
||||
// a JS value without loss of precision. The upper bits of the window ID hold
|
||||
// the process ID. The lower bits identify the window.
|
||||
static const uint64_t kWindowIDTotalBits = 53;
|
||||
static const uint64_t kWindowIDProcessBits = 22;
|
||||
static const uint64_t kWindowIDWindowBits =
|
||||
kWindowIDTotalBits - kWindowIDProcessBits;
|
||||
|
||||
// Try to return a window ID that is unique across processes and that will never
|
||||
// be recycled.
|
||||
uint64_t NextWindowID() {
|
||||
uint64_t processID = 0;
|
||||
if (XRE_IsContentProcess()) {
|
||||
ContentChild* cc = ContentChild::GetSingleton();
|
||||
processID = cc->GetID();
|
||||
}
|
||||
|
||||
MOZ_RELEASE_ASSERT(processID < (uint64_t(1) << kWindowIDProcessBits));
|
||||
uint64_t processBits =
|
||||
processID & ((uint64_t(1) << kWindowIDProcessBits) - 1);
|
||||
|
||||
// Make sure no actual window ends up with mWindowID == 0.
|
||||
uint64_t windowID = ++gNextWindowID;
|
||||
|
||||
MOZ_RELEASE_ASSERT(windowID < (uint64_t(1) << kWindowIDWindowBits));
|
||||
uint64_t windowBits = windowID & ((uint64_t(1) << kWindowIDWindowBits) - 1);
|
||||
|
||||
// Make sure that the middleman process doesn't generate WindowIDs which
|
||||
// conflict with the process it's wrapping (which shares a ContentParentID
|
||||
// with it).
|
||||
if (recordreplay::IsMiddleman()) {
|
||||
windowBits |= uint64_t(1) << (kWindowIDWindowBits - 1);
|
||||
}
|
||||
|
||||
return (processBits << kWindowIDWindowBits) | windowBits;
|
||||
}
|
||||
|
||||
mozilla::ipc::IPCResult ContentChild::RecvInvokeDragSession(
|
||||
nsTArray<IPCDataTransfer>&& aTransfers, const uint32_t& aAction) {
|
||||
nsCOMPtr<nsIDragService> dragService =
|
||||
|
@ -3775,17 +3775,12 @@ already_AddRefed<nsIEventTarget> ContentChild::GetSpecificMessageEventTarget(
|
|||
// our newly created actor, and sameTabGroupAs is needed to determine if
|
||||
// we're going to join an existing TabGroup.
|
||||
ManagedEndpoint<PBrowserChild> endpoint;
|
||||
ManagedEndpoint<PWindowGlobalChild> windowGlobalEndpoint;
|
||||
TabId tabId, sameTabGroupAs;
|
||||
PickleIterator iter(aMsg);
|
||||
if (NS_WARN_IF(!IPC::ReadParam(&aMsg, &iter, &endpoint))) {
|
||||
return nullptr;
|
||||
}
|
||||
aMsg.IgnoreSentinel(&iter);
|
||||
if (NS_WARN_IF(!IPC::ReadParam(&aMsg, &iter, &windowGlobalEndpoint))) {
|
||||
return nullptr;
|
||||
}
|
||||
aMsg.IgnoreSentinel(&iter);
|
||||
if (NS_WARN_IF(!IPC::ReadParam(&aMsg, &iter, &tabId))) {
|
||||
return nullptr;
|
||||
}
|
||||
|
|
|
@ -520,10 +520,9 @@ class ContentChild final : public PContentChild,
|
|||
bool DeallocPFileDescriptorSetChild(PFileDescriptorSetChild*);
|
||||
|
||||
mozilla::ipc::IPCResult RecvConstructBrowser(
|
||||
ManagedEndpoint<PBrowserChild>&& aBrowserEp,
|
||||
ManagedEndpoint<PWindowGlobalChild>&& aWindowEp, const TabId& aTabId,
|
||||
ManagedEndpoint<PBrowserChild>&& aBrowserEp, const TabId& aTabId,
|
||||
const TabId& aSameTabGroupAs, const IPCTabContext& aContext,
|
||||
const WindowGlobalInit& aWindowInit, const uint32_t& aChromeFlags,
|
||||
BrowsingContext* aBrowsingContext, const uint32_t& aChromeFlags,
|
||||
const ContentParentId& aCpID, const bool& aIsForBrowser,
|
||||
const bool& aIsTopLevel);
|
||||
|
||||
|
@ -836,6 +835,8 @@ class ContentChild final : public PContentChild,
|
|||
DISALLOW_EVIL_CONSTRUCTORS(ContentChild);
|
||||
};
|
||||
|
||||
uint64_t NextWindowID();
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
|
|
|
@ -1217,36 +1217,17 @@ already_AddRefed<RemoteBrowser> ContentParent::CreateBrowser(
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIPrincipal> initialPrincipal =
|
||||
NullPrincipal::Create(aContext.OriginAttributesRef());
|
||||
WindowGlobalInit windowInit = WindowGlobalActor::AboutBlankInitializer(
|
||||
aBrowsingContext, initialPrincipal);
|
||||
|
||||
auto windowParent =
|
||||
MakeRefPtr<WindowGlobalParent>(windowInit, /* inprocess */ false);
|
||||
|
||||
// Open a remote endpoint for the initial PWindowGlobal actor.
|
||||
// DeallocPWindowGlobalParent releases the ref taken.
|
||||
ManagedEndpoint<PWindowGlobalChild> windowEp =
|
||||
browserParent->OpenPWindowGlobalEndpoint(
|
||||
do_AddRef(windowParent).take());
|
||||
if (NS_WARN_IF(!windowEp.IsValid())) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// Tell the content process to set up its PBrowserChild.
|
||||
bool ok = constructorSender->SendConstructBrowser(
|
||||
std::move(childEp), std::move(windowEp), tabId,
|
||||
std::move(childEp), tabId,
|
||||
aSameTabGroupAs ? aSameTabGroupAs->GetTabId() : TabId(0),
|
||||
aContext.AsIPCTabContext(), windowInit, chromeFlags,
|
||||
aContext.AsIPCTabContext(), aBrowsingContext, chromeFlags,
|
||||
constructorSender->ChildID(), constructorSender->IsForBrowser(),
|
||||
/* aIsTopLevel */ true);
|
||||
if (NS_WARN_IF(!ok)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
windowParent->Init(windowInit);
|
||||
|
||||
if (remoteType.EqualsLiteral(LARGE_ALLOCATION_REMOTE_TYPE)) {
|
||||
// Tell the BrowserChild object that it was created due to a
|
||||
// Large-Allocation request.
|
||||
|
@ -3291,9 +3272,8 @@ bool ContentParent::DeallocPBrowserParent(PBrowserParent* frame) {
|
|||
}
|
||||
|
||||
mozilla::ipc::IPCResult ContentParent::RecvConstructPopupBrowser(
|
||||
ManagedEndpoint<PBrowserParent>&& aBrowserEp,
|
||||
ManagedEndpoint<PWindowGlobalParent>&& aWindowEp, const TabId& aTabId,
|
||||
const IPCTabContext& aContext, const WindowGlobalInit& aInitialWindowInit,
|
||||
ManagedEndpoint<PBrowserParent>&& aBrowserEp, const TabId& aTabId,
|
||||
const IPCTabContext& aContext, BrowsingContext* aBrowsingContext,
|
||||
const uint32_t& aChromeFlags) {
|
||||
if (!CanOpenBrowser(aContext)) {
|
||||
return IPC_FAIL(this, "CanOpenBrowser Failed");
|
||||
|
@ -3348,19 +3328,15 @@ mozilla::ipc::IPCResult ContentParent::RecvConstructPopupBrowser(
|
|||
chromeFlags |= nsIWebBrowserChrome::CHROME_REMOTE_WINDOW;
|
||||
|
||||
CanonicalBrowsingContext* browsingContext =
|
||||
CanonicalBrowsingContext::Cast(aInitialWindowInit.browsingContext());
|
||||
CanonicalBrowsingContext::Cast(aBrowsingContext);
|
||||
if (NS_WARN_IF(!browsingContext->IsOwnedByProcess(ChildID()))) {
|
||||
return IPC_FAIL(this, "BrowsingContext Owned by Incorrect Process!");
|
||||
}
|
||||
|
||||
MaybeInvalidTabContext tc(aContext);
|
||||
MOZ_ASSERT(tc.IsValid());
|
||||
|
||||
auto initialWindow =
|
||||
MakeRefPtr<WindowGlobalParent>(aInitialWindowInit, /* inprocess */ false);
|
||||
|
||||
auto parent = MakeRefPtr<BrowserParent>(this, aTabId, tc.GetTabContext(),
|
||||
browsingContext, chromeFlags);
|
||||
RefPtr<BrowserParent> parent = new BrowserParent(
|
||||
this, aTabId, tc.GetTabContext(), browsingContext, chromeFlags);
|
||||
|
||||
// Bind the created BrowserParent to IPC to actually link the actor. The ref
|
||||
// here is released in DeallocPBrowserParent.
|
||||
|
@ -3369,14 +3345,6 @@ mozilla::ipc::IPCResult ContentParent::RecvConstructPopupBrowser(
|
|||
return IPC_FAIL(this, "BindPBrowserEndpoint failed");
|
||||
}
|
||||
|
||||
// The ref here is released in DeallocPWindowGlobalParent.
|
||||
if (NS_WARN_IF(!parent->BindPWindowGlobalEndpoint(
|
||||
std::move(aWindowEp), do_AddRef(initialWindow).take()))) {
|
||||
return IPC_FAIL(this, "BindPWindowGlobalEndpoint failed");
|
||||
}
|
||||
|
||||
initialWindow->Init(aInitialWindowInit);
|
||||
|
||||
// When enabling input event prioritization, input events may preempt other
|
||||
// normal priority IPC messages. To prevent the input events preempt
|
||||
// PBrowserConstructor, we use an IPC 'RemoteIsReadyToHandleInputEvents' to
|
||||
|
|
|
@ -842,9 +842,8 @@ class ContentParent final : public PContentParent,
|
|||
bool DeallocPBrowserParent(PBrowserParent* frame);
|
||||
|
||||
mozilla::ipc::IPCResult RecvConstructPopupBrowser(
|
||||
ManagedEndpoint<PBrowserParent>&& actor,
|
||||
ManagedEndpoint<PWindowGlobalParent>&& windowEp, const TabId& tabId,
|
||||
const IPCTabContext& context, const WindowGlobalInit& initialWindowInit,
|
||||
ManagedEndpoint<PBrowserParent>&& actor, const TabId& tabId,
|
||||
const IPCTabContext& context, BrowsingContext* aBrowsingContext,
|
||||
const uint32_t& chromeFlags);
|
||||
|
||||
PIPCBlobInputStreamParent* AllocPIPCBlobInputStreamParent(
|
||||
|
|
|
@ -69,7 +69,7 @@ class AsyncMessageToParent : public Runnable {
|
|||
void JSWindowActorChild::SendRawMessage(const JSWindowActorMessageMeta& aMeta,
|
||||
ipc::StructuredCloneData&& aData,
|
||||
ErrorResult& aRv) {
|
||||
if (NS_WARN_IF(!mCanSend || !mManager || !mManager->CanSend())) {
|
||||
if (NS_WARN_IF(!mCanSend || !mManager || mManager->IsClosed())) {
|
||||
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -64,7 +64,7 @@ class AsyncMessageToChild : public Runnable {
|
|||
void JSWindowActorParent::SendRawMessage(const JSWindowActorMessageMeta& aMeta,
|
||||
ipc::StructuredCloneData&& aData,
|
||||
ErrorResult& aRv) {
|
||||
if (NS_WARN_IF(!mCanSend || !mManager || !mManager->CanSend())) {
|
||||
if (NS_WARN_IF(!mCanSend || !mManager || mManager->IsClosed())) {
|
||||
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -200,11 +200,17 @@ parent:
|
|||
|
||||
async PPaymentRequest();
|
||||
|
||||
/**
|
||||
* Construct a new WindowGlobal actor for a window global in the given
|
||||
* BrowsingContext and with the given principal.
|
||||
*/
|
||||
async PWindowGlobal(WindowGlobalInit init);
|
||||
|
||||
/**
|
||||
* Construct a new Remote iframe actor.
|
||||
*/
|
||||
async PBrowserBridge(nsString aPresentationURL, nsString aRemoteType,
|
||||
WindowGlobalInit aWindowInit, uint32_t aChromeFlags,
|
||||
BrowsingContext aBrowsingContext, uint32_t aChromeFlags,
|
||||
TabId tabId);
|
||||
|
||||
/**
|
||||
|
@ -1014,12 +1020,6 @@ parent:
|
|||
/** Fetches the visited status for an array of URIs (Android-only). */
|
||||
async QueryVisitedState(URIParams[] aURIs);
|
||||
|
||||
/**
|
||||
* Construct a new WindowGlobal for an existing global in the content process
|
||||
*/
|
||||
async NewWindowGlobal(ManagedEndpoint<PWindowGlobalParent> aEndpoint,
|
||||
WindowGlobalInit aInit);
|
||||
|
||||
/*
|
||||
* FIXME: write protocol!
|
||||
|
||||
|
|
|
@ -37,7 +37,6 @@ include protocol PJavaScript;
|
|||
include protocol PRemoteSpellcheckEngine;
|
||||
include protocol PWebBrowserPersistDocument;
|
||||
include protocol PWebrtcGlobal;
|
||||
include protocol PWindowGlobal;
|
||||
include protocol PPresentation;
|
||||
include protocol PURLClassifier;
|
||||
include protocol PURLClassifierLocal;
|
||||
|
@ -383,17 +382,15 @@ nested(upto inside_cpow) sync protocol PContent
|
|||
// Keep the last 3 attributes in sync with GetProcessAttributes!
|
||||
parent:
|
||||
async ConstructPopupBrowser(ManagedEndpoint<PBrowserParent> browserEp,
|
||||
ManagedEndpoint<PWindowGlobalParent> windowEp,
|
||||
TabId tabId, IPCTabContext context,
|
||||
WindowGlobalInit windowInit,
|
||||
BrowsingContext browsingContext,
|
||||
uint32_t chromeFlags);
|
||||
|
||||
child:
|
||||
async ConstructBrowser(ManagedEndpoint<PBrowserChild> browserEp,
|
||||
ManagedEndpoint<PWindowGlobalChild> windowEp,
|
||||
TabId tabId, TabId sameTabGroupAs,
|
||||
IPCTabContext context,
|
||||
WindowGlobalInit windowInit,
|
||||
BrowsingContext browsingContext,
|
||||
uint32_t chromeFlags, ContentParentId cpId,
|
||||
bool isForBrowser, bool isTopLevel);
|
||||
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
|
||||
#include "mozilla/dom/WindowGlobalActor.h"
|
||||
|
||||
#include "nsContentUtils.h"
|
||||
#include "mozJSComponentLoader.h"
|
||||
#include "mozilla/Logging.h"
|
||||
#include "mozilla/dom/JSWindowActorService.h"
|
||||
|
@ -16,21 +15,6 @@
|
|||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
WindowGlobalInit WindowGlobalActor::AboutBlankInitializer(
|
||||
dom::BrowsingContext* aBrowsingContext, nsIPrincipal* aPrincipal) {
|
||||
MOZ_ASSERT(aBrowsingContext);
|
||||
MOZ_ASSERT(aPrincipal);
|
||||
|
||||
nsCOMPtr<nsIURI> documentURI;
|
||||
Unused << NS_NewURI(getter_AddRefs(documentURI), "about:blank");
|
||||
|
||||
uint64_t outerWindowId = nsContentUtils::GenerateWindowId();
|
||||
uint64_t innerWindowId = nsContentUtils::GenerateWindowId();
|
||||
|
||||
return WindowGlobalInit(aPrincipal, documentURI, aBrowsingContext,
|
||||
innerWindowId, outerWindowId);
|
||||
}
|
||||
|
||||
void WindowGlobalActor::ConstructActor(const nsAString& aName,
|
||||
JS::MutableHandleObject aActor,
|
||||
ErrorResult& aRv) {
|
||||
|
@ -133,4 +117,4 @@ NS_IMPL_CYCLE_COLLECTING_ADDREF(WindowGlobalActor)
|
|||
NS_IMPL_CYCLE_COLLECTING_RELEASE(WindowGlobalActor)
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
} // namespace mozilla
|
|
@ -24,9 +24,6 @@ class WindowGlobalActor : public nsISupports, public nsWrapperCache {
|
|||
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
||||
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(WindowGlobalActor)
|
||||
|
||||
static WindowGlobalInit AboutBlankInitializer(
|
||||
dom::BrowsingContext* aBrowsingContext, nsIPrincipal* aPrincipal);
|
||||
|
||||
protected:
|
||||
virtual ~WindowGlobalActor() = default;
|
||||
|
||||
|
@ -44,4 +41,4 @@ class WindowGlobalActor : public nsISupports, public nsWrapperCache {
|
|||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // mozilla_dom_WindowGlobalActor_h
|
||||
#endif // mozilla_dom_WindowGlobalActor_h
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
#include "mozilla/ClearOnShutdown.h"
|
||||
#include "mozilla/dom/WindowGlobalParent.h"
|
||||
#include "mozilla/ipc/InProcessChild.h"
|
||||
#include "mozilla/dom/BrowsingContext.h"
|
||||
#include "mozilla/dom/ContentChild.h"
|
||||
#include "mozilla/dom/MozFrameLoaderOwnerBinding.h"
|
||||
|
@ -17,7 +18,6 @@
|
|||
#include "mozilla/dom/WindowGlobalActorsBinding.h"
|
||||
#include "mozilla/dom/WindowGlobalParent.h"
|
||||
#include "mozilla/ipc/InProcessChild.h"
|
||||
#include "mozilla/ipc/InProcessParent.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsDocShell.h"
|
||||
#include "nsFrameLoaderOwner.h"
|
||||
|
@ -40,22 +40,14 @@ namespace dom {
|
|||
typedef nsRefPtrHashtable<nsUint64HashKey, WindowGlobalChild> WGCByIdMap;
|
||||
static StaticAutoPtr<WGCByIdMap> gWindowGlobalChildById;
|
||||
|
||||
WindowGlobalChild::WindowGlobalChild(const WindowGlobalInit& aInit,
|
||||
nsGlobalWindowInner* aWindow)
|
||||
WindowGlobalChild::WindowGlobalChild(nsGlobalWindowInner* aWindow,
|
||||
dom::BrowsingContext* aBrowsingContext)
|
||||
: mWindowGlobal(aWindow),
|
||||
mBrowsingContext(aInit.browsingContext()),
|
||||
mDocumentPrincipal(aInit.principal()),
|
||||
mDocumentURI(aInit.documentURI()),
|
||||
mInnerWindowId(aInit.innerWindowId()),
|
||||
mOuterWindowId(aInit.outerWindowId()),
|
||||
mBeforeUnloadListeners(0) {
|
||||
MOZ_DIAGNOSTIC_ASSERT(mBrowsingContext);
|
||||
MOZ_DIAGNOSTIC_ASSERT(mDocumentPrincipal);
|
||||
|
||||
MOZ_ASSERT_IF(aWindow, mInnerWindowId == aWindow->WindowID());
|
||||
MOZ_ASSERT_IF(aWindow,
|
||||
mOuterWindowId == aWindow->GetOuterWindow()->WindowID());
|
||||
}
|
||||
mBrowsingContext(aBrowsingContext),
|
||||
mInnerWindowId(aWindow->WindowID()),
|
||||
mOuterWindowId(aWindow->GetOuterWindow()->WindowID()),
|
||||
mBeforeUnloadListeners(0),
|
||||
mIPCClosed(true) {}
|
||||
|
||||
already_AddRefed<WindowGlobalChild> WindowGlobalChild::Create(
|
||||
nsGlobalWindowInner* aWindow) {
|
||||
|
@ -78,11 +70,7 @@ already_AddRefed<WindowGlobalChild> WindowGlobalChild::Create(
|
|||
bc->SetOpenerPolicy(policy);
|
||||
}
|
||||
|
||||
WindowGlobalInit init(principal, aWindow->GetDocumentURI(), bc,
|
||||
aWindow->WindowID(),
|
||||
aWindow->GetOuterWindow()->WindowID());
|
||||
|
||||
auto wgc = MakeRefPtr<WindowGlobalChild>(init, aWindow);
|
||||
RefPtr<WindowGlobalChild> wgc = new WindowGlobalChild(aWindow, bc);
|
||||
|
||||
// If we have already closed our browsing context, return a pre-destroyed
|
||||
// WindowGlobalChild actor.
|
||||
|
@ -91,57 +79,38 @@ already_AddRefed<WindowGlobalChild> WindowGlobalChild::Create(
|
|||
return wgc.forget();
|
||||
}
|
||||
|
||||
// Send the link constructor over PBrowser, or link over PInProcess.
|
||||
WindowGlobalInit init(principal, aWindow->GetDocumentURI(), bc,
|
||||
wgc->mInnerWindowId, wgc->mOuterWindowId);
|
||||
|
||||
// Send the link constructor over PInProcessChild or PBrowser.
|
||||
if (XRE_IsParentProcess()) {
|
||||
InProcessChild* ipChild = InProcessChild::Singleton();
|
||||
InProcessParent* ipParent = InProcessParent::Singleton();
|
||||
if (!ipChild || !ipParent) {
|
||||
InProcessChild* ipc = InProcessChild::Singleton();
|
||||
if (!ipc) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// Note: ref is released in DeallocPWindowGlobalChild
|
||||
ManagedEndpoint<PWindowGlobalParent> endpoint =
|
||||
ipChild->OpenPWindowGlobalEndpoint(do_AddRef(wgc).take());
|
||||
|
||||
auto wgp = MakeRefPtr<WindowGlobalParent>(init, /* aInProcess */ true);
|
||||
|
||||
// Note: ref is released in DeallocPWindowGlobalParent
|
||||
ipParent->BindPWindowGlobalEndpoint(std::move(endpoint),
|
||||
do_AddRef(wgp).take());
|
||||
wgp->Init(init);
|
||||
ipc->SendPWindowGlobalConstructor(do_AddRef(wgc).take(), init);
|
||||
} else {
|
||||
RefPtr<BrowserChild> browserChild =
|
||||
BrowserChild::GetFrom(static_cast<mozIDOMWindow*>(aWindow));
|
||||
MOZ_ASSERT(browserChild);
|
||||
|
||||
// Note: ref is released in DeallocPWindowGlobalChild
|
||||
ManagedEndpoint<PWindowGlobalParent> endpoint =
|
||||
browserChild->OpenPWindowGlobalEndpoint(do_AddRef(wgc).take());
|
||||
|
||||
browserChild->SendNewWindowGlobal(std::move(endpoint), init);
|
||||
}
|
||||
|
||||
wgc->Init();
|
||||
return wgc.forget();
|
||||
}
|
||||
|
||||
void WindowGlobalChild::Init() {
|
||||
if (!mDocumentURI) {
|
||||
NS_NewURI(getter_AddRefs(mDocumentURI), "about:blank");
|
||||
browserChild->SendPWindowGlobalConstructor(do_AddRef(wgc).take(), init);
|
||||
}
|
||||
wgc->mIPCClosed = false;
|
||||
|
||||
// Register this WindowGlobal in the gWindowGlobalParentsById map.
|
||||
if (!gWindowGlobalChildById) {
|
||||
gWindowGlobalChildById = new WGCByIdMap();
|
||||
ClearOnShutdown(&gWindowGlobalChildById);
|
||||
}
|
||||
auto entry = gWindowGlobalChildById->LookupForAdd(mInnerWindowId);
|
||||
auto entry = gWindowGlobalChildById->LookupForAdd(wgc->mInnerWindowId);
|
||||
MOZ_RELEASE_ASSERT(!entry, "Duplicate WindowGlobalChild entry for ID!");
|
||||
entry.OrInsert([&] { return this; });
|
||||
}
|
||||
entry.OrInsert([&] { return wgc; });
|
||||
|
||||
void WindowGlobalChild::InitWindowGlobal(nsGlobalWindowInner* aWindow) {
|
||||
mWindowGlobal = aWindow;
|
||||
return wgc.forget();
|
||||
}
|
||||
|
||||
/* static */
|
||||
|
@ -154,11 +123,11 @@ already_AddRefed<WindowGlobalChild> WindowGlobalChild::GetByInnerWindowId(
|
|||
}
|
||||
|
||||
bool WindowGlobalChild::IsCurrentGlobal() {
|
||||
return CanSend() && mWindowGlobal->IsCurrentInnerWindow();
|
||||
return !mIPCClosed && mWindowGlobal->IsCurrentInnerWindow();
|
||||
}
|
||||
|
||||
already_AddRefed<WindowGlobalParent> WindowGlobalChild::GetParentActor() {
|
||||
if (!CanSend()) {
|
||||
if (mIPCClosed) {
|
||||
return nullptr;
|
||||
}
|
||||
IProtocol* otherSide = InProcessChild::ParentActorFor(this);
|
||||
|
@ -166,7 +135,7 @@ already_AddRefed<WindowGlobalParent> WindowGlobalChild::GetParentActor() {
|
|||
}
|
||||
|
||||
already_AddRefed<BrowserChild> WindowGlobalChild::GetBrowserChild() {
|
||||
if (IsInProcess() || !CanSend()) {
|
||||
if (IsInProcess() || mIPCClosed) {
|
||||
return nullptr;
|
||||
}
|
||||
return do_AddRef(static_cast<BrowserChild*>(Manager()));
|
||||
|
@ -191,7 +160,7 @@ bool WindowGlobalChild::IsProcessRoot() {
|
|||
|
||||
void WindowGlobalChild::BeforeUnloadAdded() {
|
||||
// Don't bother notifying the parent if we don't have an IPC link open.
|
||||
if (mBeforeUnloadListeners == 0 && CanSend()) {
|
||||
if (mBeforeUnloadListeners == 0 && !mIPCClosed) {
|
||||
SendSetHasBeforeUnload(true);
|
||||
}
|
||||
|
||||
|
@ -204,7 +173,7 @@ void WindowGlobalChild::BeforeUnloadRemoved() {
|
|||
MOZ_ASSERT(mBeforeUnloadListeners >= 0);
|
||||
|
||||
// Don't bother notifying the parent if we don't have an IPC link open.
|
||||
if (mBeforeUnloadListeners == 0 && CanSend()) {
|
||||
if (mBeforeUnloadListeners == 0 && !mIPCClosed) {
|
||||
SendSetHasBeforeUnload(false);
|
||||
}
|
||||
}
|
||||
|
@ -227,6 +196,8 @@ void WindowGlobalChild::Destroy() {
|
|||
}
|
||||
SendDestroy();
|
||||
}
|
||||
|
||||
mIPCClosed = true;
|
||||
}
|
||||
|
||||
static nsresult ChangeFrameRemoteness(WindowGlobalChild* aWgc,
|
||||
|
@ -370,9 +341,8 @@ void WindowGlobalChild::ReceiveRawMessage(const JSWindowActorMessageMeta& aMeta,
|
|||
}
|
||||
}
|
||||
|
||||
void WindowGlobalChild::SetDocumentURI(nsIURI* aDocumentURI) {
|
||||
mDocumentURI = aDocumentURI;
|
||||
SendUpdateDocumentURI(aDocumentURI);
|
||||
nsIURI* WindowGlobalChild::GetDocumentURI() {
|
||||
return mWindowGlobal->GetDocumentURI();
|
||||
}
|
||||
|
||||
const nsAString& WindowGlobalChild::GetRemoteType() {
|
||||
|
@ -385,7 +355,7 @@ const nsAString& WindowGlobalChild::GetRemoteType() {
|
|||
|
||||
already_AddRefed<JSWindowActorChild> WindowGlobalChild::GetActor(
|
||||
const nsAString& aName, ErrorResult& aRv) {
|
||||
if (!CanSend()) {
|
||||
if (mIPCClosed) {
|
||||
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -416,6 +386,7 @@ already_AddRefed<JSWindowActorChild> WindowGlobalChild::GetActor(
|
|||
}
|
||||
|
||||
void WindowGlobalChild::ActorDestroy(ActorDestroyReason aWhy) {
|
||||
mIPCClosed = true;
|
||||
gWindowGlobalChildById->Remove(mInnerWindowId);
|
||||
|
||||
// Destroy our JSWindowActors, and reject any pending queries.
|
||||
|
|
|
@ -50,18 +50,13 @@ class WindowGlobalChild final : public WindowGlobalActor,
|
|||
nsGlobalWindowInner* WindowGlobal() { return mWindowGlobal; }
|
||||
|
||||
// Has this actor been shut down
|
||||
bool IsClosed() { return !CanSend(); }
|
||||
bool IsClosed() { return mIPCClosed; }
|
||||
void Destroy();
|
||||
|
||||
// Check if this actor is managed by PInProcess, as-in the document is loaded
|
||||
// in the chrome process.
|
||||
bool IsInProcess() { return XRE_IsParentProcess(); }
|
||||
|
||||
nsIURI* GetDocumentURI() override { return mDocumentURI; }
|
||||
void SetDocumentURI(nsIURI* aDocumentURI);
|
||||
|
||||
nsIPrincipal* DocumentPrincipal() { return mDocumentPrincipal; }
|
||||
|
||||
// The Window ID for this WindowGlobal
|
||||
uint64_t InnerWindowId() { return mInnerWindowId; }
|
||||
uint64_t OuterWindowId() { return mOuterWindowId; }
|
||||
|
@ -95,16 +90,10 @@ class WindowGlobalChild final : public WindowGlobalActor,
|
|||
static already_AddRefed<WindowGlobalChild> Create(
|
||||
nsGlobalWindowInner* aWindow);
|
||||
|
||||
WindowGlobalChild(const WindowGlobalInit& aInit,
|
||||
nsGlobalWindowInner* aWindow);
|
||||
|
||||
void Init();
|
||||
|
||||
void InitWindowGlobal(nsGlobalWindowInner* aWindow);
|
||||
|
||||
nsISupports* GetParentObject();
|
||||
JSObject* WrapObject(JSContext* aCx,
|
||||
JS::Handle<JSObject*> aGivenProto) override;
|
||||
nsIURI* GetDocumentURI() override;
|
||||
|
||||
protected:
|
||||
const nsAString& GetRemoteType() override;
|
||||
|
@ -129,16 +118,16 @@ class WindowGlobalChild final : public WindowGlobalActor,
|
|||
virtual void ActorDestroy(ActorDestroyReason aWhy) override;
|
||||
|
||||
private:
|
||||
WindowGlobalChild(nsGlobalWindowInner* aWindow, dom::BrowsingContext* aBc);
|
||||
~WindowGlobalChild();
|
||||
|
||||
RefPtr<nsGlobalWindowInner> mWindowGlobal;
|
||||
RefPtr<dom::BrowsingContext> mBrowsingContext;
|
||||
nsRefPtrHashtable<nsStringHashKey, JSWindowActorChild> mWindowActors;
|
||||
nsCOMPtr<nsIPrincipal> mDocumentPrincipal;
|
||||
nsCOMPtr<nsIURI> mDocumentURI;
|
||||
uint64_t mInnerWindowId;
|
||||
uint64_t mOuterWindowId;
|
||||
int64_t mBeforeUnloadListeners;
|
||||
bool mIPCClosed;
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
|
|
|
@ -52,6 +52,7 @@ WindowGlobalParent::WindowGlobalParent(const WindowGlobalInit& aInit,
|
|||
mInnerWindowId(aInit.innerWindowId()),
|
||||
mOuterWindowId(aInit.outerWindowId()),
|
||||
mInProcess(aInProcess),
|
||||
mIPCClosed(true), // Closed until WGP::Init
|
||||
mIsInitialDocument(false),
|
||||
mHasBeforeUnload(false) {
|
||||
MOZ_DIAGNOSTIC_ASSERT(XRE_IsParentProcess(), "Parent process only");
|
||||
|
@ -64,6 +65,10 @@ WindowGlobalParent::WindowGlobalParent(const WindowGlobalInit& aInit,
|
|||
|
||||
void WindowGlobalParent::Init(const WindowGlobalInit& aInit) {
|
||||
MOZ_ASSERT(Manager(), "Should have a manager!");
|
||||
MOZ_ASSERT(!mFrameLoader, "Cannot Init() a WindowGlobalParent twice!");
|
||||
|
||||
MOZ_ASSERT(mIPCClosed, "IPC shouldn't be open yet");
|
||||
mIPCClosed = false;
|
||||
|
||||
// Register this WindowGlobal in the gWindowGlobalParentsById map.
|
||||
if (!gWindowGlobalParentsById) {
|
||||
|
@ -77,11 +82,7 @@ void WindowGlobalParent::Init(const WindowGlobalInit& aInit) {
|
|||
// Determine which content process the window global is coming from.
|
||||
dom::ContentParentId processId(0);
|
||||
if (!mInProcess) {
|
||||
ContentParent* cp = static_cast<ContentParent*>(Manager()->Manager());
|
||||
processId = cp->ChildID();
|
||||
|
||||
// Ensure the content process has permissions for this principal.
|
||||
cp->TransmitPermissionsForPrincipal(mDocumentPrincipal);
|
||||
processId = static_cast<ContentParent*>(Manager()->Manager())->ChildID();
|
||||
}
|
||||
|
||||
mBrowsingContext = CanonicalBrowsingContext::Cast(aInit.browsingContext());
|
||||
|
@ -96,9 +97,33 @@ void WindowGlobalParent::Init(const WindowGlobalInit& aInit) {
|
|||
mBrowsingContext->SetCurrentWindowGlobal(this);
|
||||
}
|
||||
|
||||
// Ensure we have a document URI
|
||||
if (!mDocumentURI) {
|
||||
NS_NewURI(getter_AddRefs(mDocumentURI), "about:blank");
|
||||
// Determine what toplevel frame element our WindowGlobalParent is being
|
||||
// embedded in.
|
||||
RefPtr<Element> frameElement;
|
||||
if (mInProcess) {
|
||||
// In the in-process case, we can get it from the other side's
|
||||
// WindowGlobalChild.
|
||||
MOZ_ASSERT(Manager()->GetProtocolId() == PInProcessMsgStart);
|
||||
RefPtr<WindowGlobalChild> otherSide = GetChildActor();
|
||||
if (otherSide && otherSide->WindowGlobal()) {
|
||||
// Get the toplevel window from the other side.
|
||||
RefPtr<nsDocShell> docShell =
|
||||
nsDocShell::Cast(otherSide->WindowGlobal()->GetDocShell());
|
||||
if (docShell) {
|
||||
docShell->GetTopFrameElement(getter_AddRefs(frameElement));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// In the cross-process case, we can get the frame element from our manager.
|
||||
MOZ_ASSERT(Manager()->GetProtocolId() == PBrowserMsgStart);
|
||||
frameElement = static_cast<BrowserParent*>(Manager())->GetOwnerElement();
|
||||
}
|
||||
|
||||
// Extract the nsFrameLoader from the current frame element. We may not have a
|
||||
// nsFrameLoader if we are a chrome document.
|
||||
RefPtr<nsFrameLoaderOwner> flOwner = do_QueryObject(frameElement);
|
||||
if (flOwner) {
|
||||
mFrameLoader = flOwner->GetFrameLoader();
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIObserverService> obs = services::GetObserverService();
|
||||
|
@ -117,7 +142,7 @@ already_AddRefed<WindowGlobalParent> WindowGlobalParent::GetByInnerWindowId(
|
|||
}
|
||||
|
||||
already_AddRefed<WindowGlobalChild> WindowGlobalParent::GetChildActor() {
|
||||
if (!CanSend()) {
|
||||
if (mIPCClosed) {
|
||||
return nullptr;
|
||||
}
|
||||
IProtocol* otherSide = InProcessParent::ChildActorFor(this);
|
||||
|
@ -125,23 +150,12 @@ already_AddRefed<WindowGlobalChild> WindowGlobalParent::GetChildActor() {
|
|||
}
|
||||
|
||||
already_AddRefed<BrowserParent> WindowGlobalParent::GetBrowserParent() {
|
||||
if (IsInProcess() || !CanSend()) {
|
||||
if (IsInProcess() || mIPCClosed) {
|
||||
return nullptr;
|
||||
}
|
||||
return do_AddRef(static_cast<BrowserParent*>(Manager()));
|
||||
}
|
||||
|
||||
already_AddRefed<nsFrameLoader> WindowGlobalParent::GetRootFrameLoader() {
|
||||
dom::BrowsingContext* top = BrowsingContext()->Top();
|
||||
|
||||
RefPtr<nsFrameLoaderOwner> frameLoaderOwner =
|
||||
do_QueryObject(top->GetEmbedderElement());
|
||||
if (frameLoaderOwner) {
|
||||
return frameLoaderOwner->GetFrameLoader();
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
uint64_t WindowGlobalParent::ContentParentId() {
|
||||
RefPtr<BrowserParent> browserParent = GetBrowserParent();
|
||||
return browserParent ? browserParent->Manager()->ChildID() : 0;
|
||||
|
@ -185,7 +199,7 @@ IPCResult WindowGlobalParent::RecvBecomeCurrentWindowGlobal() {
|
|||
}
|
||||
|
||||
IPCResult WindowGlobalParent::RecvDestroy() {
|
||||
if (CanSend()) {
|
||||
if (!mIPCClosed) {
|
||||
RefPtr<BrowserParent> browserParent = GetBrowserParent();
|
||||
if (!browserParent || !browserParent->IsDestroyed()) {
|
||||
// Make a copy so that we can avoid potential iterator invalidation when
|
||||
|
@ -231,7 +245,7 @@ const nsAString& WindowGlobalParent::GetRemoteType() {
|
|||
|
||||
already_AddRefed<JSWindowActorParent> WindowGlobalParent::GetActor(
|
||||
const nsAString& aName, ErrorResult& aRv) {
|
||||
if (!CanSend()) {
|
||||
if (mIPCClosed) {
|
||||
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -262,7 +276,7 @@ already_AddRefed<JSWindowActorParent> WindowGlobalParent::GetActor(
|
|||
}
|
||||
|
||||
bool WindowGlobalParent::IsCurrentGlobal() {
|
||||
return CanSend() && mBrowsingContext->GetCurrentWindowGlobal() == this;
|
||||
return !mIPCClosed && mBrowsingContext->GetCurrentWindowGlobal() == this;
|
||||
}
|
||||
|
||||
IPCResult WindowGlobalParent::RecvDidEmbedBrowsingContext(
|
||||
|
@ -421,6 +435,7 @@ already_AddRefed<Promise> WindowGlobalParent::GetSecurityInfo(
|
|||
}
|
||||
|
||||
void WindowGlobalParent::ActorDestroy(ActorDestroyReason aWhy) {
|
||||
mIPCClosed = true;
|
||||
gWindowGlobalParentsById->Remove(mInnerWindowId);
|
||||
mBrowsingContext->UnregisterWindowGlobal(this);
|
||||
|
||||
|
@ -455,7 +470,8 @@ nsIGlobalObject* WindowGlobalParent::GetParentObject() {
|
|||
}
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_INHERITED(WindowGlobalParent, WindowGlobalActor,
|
||||
mBrowsingContext, mWindowActors)
|
||||
mFrameLoader, mBrowsingContext,
|
||||
mWindowActors)
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN_INHERITED(WindowGlobalParent,
|
||||
WindowGlobalActor)
|
||||
|
|
|
@ -55,7 +55,7 @@ class WindowGlobalParent final : public WindowGlobalActor,
|
|||
}
|
||||
|
||||
// Has this actor been shut down
|
||||
bool IsClosed() { return !CanSend(); }
|
||||
bool IsClosed() { return mIPCClosed; }
|
||||
|
||||
// Check if this actor is managed by PInProcess, as-in the document is loaded
|
||||
// in-process.
|
||||
|
@ -90,7 +90,7 @@ class WindowGlobalParent final : public WindowGlobalActor,
|
|||
// which this WindowGlobal is a part of. This will be the nsFrameLoader
|
||||
// holding the BrowserParent for remote tabs, and the root content frameloader
|
||||
// for non-remote tabs.
|
||||
already_AddRefed<nsFrameLoader> GetRootFrameLoader();
|
||||
nsFrameLoader* GetRootFrameLoader() { return mFrameLoader; }
|
||||
|
||||
// The current URI which loaded in the document.
|
||||
nsIURI* GetDocumentURI() override { return mDocumentURI; }
|
||||
|
@ -165,11 +165,13 @@ class WindowGlobalParent final : public WindowGlobalActor,
|
|||
// mutations which may have been made in the actual document.
|
||||
nsCOMPtr<nsIPrincipal> mDocumentPrincipal;
|
||||
nsCOMPtr<nsIURI> mDocumentURI;
|
||||
RefPtr<nsFrameLoader> mFrameLoader;
|
||||
RefPtr<CanonicalBrowsingContext> mBrowsingContext;
|
||||
nsRefPtrHashtable<nsStringHashKey, JSWindowActorParent> mWindowActors;
|
||||
uint64_t mInnerWindowId;
|
||||
uint64_t mOuterWindowId;
|
||||
bool mInProcess;
|
||||
bool mIPCClosed;
|
||||
bool mIsInitialDocument;
|
||||
|
||||
// True if this window has a "beforeunload" event listener.
|
||||
|
|
|
@ -143,7 +143,7 @@ nsresult gfxSVGGlyphsDocument::SetupPresentation() {
|
|||
getter_AddRefs(viewer));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = viewer->Init(nullptr, gfx::IntRect(0, 0, 1000, 1000), nullptr);
|
||||
rv = viewer->Init(nullptr, gfx::IntRect(0, 0, 1000, 1000));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
rv = viewer->Open(nullptr, nullptr);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
|
|
@ -200,7 +200,7 @@ SVGDocumentWrapper::OnStartRequest(nsIRequest* aRequest) {
|
|||
mViewer->GetDocument()->SetIsBeingUsedAsImage();
|
||||
StopAnimation(); // otherwise animations start automatically in helper doc
|
||||
|
||||
rv = mViewer->Init(nullptr, nsIntRect(0, 0, 0, 0), nullptr);
|
||||
rv = mViewer->Init(nullptr, nsIntRect(0, 0, 0, 0));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
rv = mViewer->Open(nullptr, nullptr);
|
||||
}
|
||||
|
|
|
@ -12,6 +12,12 @@ using namespace mozilla::dom;
|
|||
namespace mozilla {
|
||||
namespace ipc {
|
||||
|
||||
PWindowGlobalChild* InProcessChild::AllocPWindowGlobalChild(
|
||||
const WindowGlobalInit& aInit) {
|
||||
MOZ_ASSERT_UNREACHABLE("PWindowGlobalChild should not be created manually");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool InProcessChild::DeallocPWindowGlobalChild(PWindowGlobalChild* aActor) {
|
||||
// Free IPC-held reference
|
||||
static_cast<WindowGlobalChild*>(aActor)->Release();
|
||||
|
|
|
@ -44,6 +44,9 @@ class InProcessChild : public PInProcessChild {
|
|||
static IProtocol* ParentActorFor(IProtocol* aActor);
|
||||
|
||||
protected:
|
||||
mozilla::dom::PWindowGlobalChild* AllocPWindowGlobalChild(
|
||||
const WindowGlobalInit& aInit);
|
||||
|
||||
bool DeallocPWindowGlobalChild(mozilla::dom::PWindowGlobalChild* aActor);
|
||||
|
||||
private:
|
||||
|
|
|
@ -14,6 +14,18 @@ namespace ipc {
|
|||
|
||||
NS_IMPL_ISUPPORTS(InProcessParent, nsIObserver)
|
||||
|
||||
IPCResult InProcessParent::RecvPWindowGlobalConstructor(
|
||||
PWindowGlobalParent* aActor, const WindowGlobalInit& aInit) {
|
||||
static_cast<WindowGlobalParent*>(aActor)->Init(aInit);
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
PWindowGlobalParent* InProcessParent::AllocPWindowGlobalParent(
|
||||
const WindowGlobalInit& aInit) {
|
||||
// Reference freed in DeallocPWindowGlobalParent.
|
||||
return do_AddRef(new WindowGlobalParent(aInit, /* inproc */ true)).take();
|
||||
}
|
||||
|
||||
bool InProcessParent::DeallocPWindowGlobalParent(PWindowGlobalParent* aActor) {
|
||||
// Free IPC-held reference.
|
||||
static_cast<WindowGlobalParent*>(aActor)->Release();
|
||||
|
@ -21,4 +33,4 @@ bool InProcessParent::DeallocPWindowGlobalParent(PWindowGlobalParent* aActor) {
|
|||
}
|
||||
|
||||
} // namespace ipc
|
||||
} // namespace mozilla
|
||||
} // namespace mozilla
|
|
@ -45,8 +45,15 @@ class InProcessParent : public nsIObserver, public PInProcessParent {
|
|||
static IProtocol* ChildActorFor(IProtocol* aActor);
|
||||
|
||||
protected:
|
||||
mozilla::dom::PWindowGlobalParent* AllocPWindowGlobalParent(
|
||||
const WindowGlobalInit& aInit);
|
||||
|
||||
bool DeallocPWindowGlobalParent(mozilla::dom::PWindowGlobalParent* aActor);
|
||||
|
||||
virtual IPCResult RecvPWindowGlobalConstructor(
|
||||
mozilla::dom::PWindowGlobalParent* aActor,
|
||||
const WindowGlobalInit& aInit) override;
|
||||
|
||||
private:
|
||||
// Lifecycle management is implemented in InProcessImpl.cpp
|
||||
virtual void ActorDestroy(ActorDestroyReason aWhy) override;
|
||||
|
|
|
@ -22,6 +22,13 @@ namespace ipc {
|
|||
async protocol PInProcess
|
||||
{
|
||||
manages PWindowGlobal;
|
||||
|
||||
parent:
|
||||
/**
|
||||
* Construct a new WindowGlobal actor for a window global in the given
|
||||
* BrowsingContext and with the given principal.
|
||||
*/
|
||||
async PWindowGlobal(WindowGlobalInit init);
|
||||
};
|
||||
|
||||
} // namespace ipc
|
||||
|
|
|
@ -974,7 +974,7 @@ class GatherDecls(TcheckVisitor):
|
|||
managed.manager = p
|
||||
managed.accept(self)
|
||||
|
||||
if not (p.managers or p.messageDecls or p.managesStmts):
|
||||
if 0 == len(p.managers) and 0 == len(p.messageDecls):
|
||||
self.error(p.loc,
|
||||
"top-level protocol `%s' cannot be empty",
|
||||
p.name)
|
||||
|
|
|
@ -120,7 +120,6 @@
|
|||
#include "mozilla/dom/Event.h"
|
||||
#include "mozilla/Telemetry.h"
|
||||
#include "mozilla/dom/ScriptLoader.h"
|
||||
#include "mozilla/dom/WindowGlobalChild.h"
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::dom;
|
||||
|
@ -345,7 +344,6 @@ class nsDocumentViewer final : public nsIContentViewer,
|
|||
* called if the window's current document is already mDocument.
|
||||
*/
|
||||
nsresult InitInternal(nsIWidget* aParentWidget, nsISupports* aState,
|
||||
mozilla::dom::WindowGlobalChild* aActor,
|
||||
const nsIntRect& aBounds, bool aDoCreation,
|
||||
bool aNeedMakeCX = true,
|
||||
bool aForceSetNewDocument = true);
|
||||
|
@ -715,9 +713,8 @@ nsDocumentViewer::GetContainer(nsIDocShell** aResult) {
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocumentViewer::Init(nsIWidget* aParentWidget, const nsIntRect& aBounds,
|
||||
WindowGlobalChild* aActor) {
|
||||
return InitInternal(aParentWidget, nullptr, aActor, aBounds, true);
|
||||
nsDocumentViewer::Init(nsIWidget* aParentWidget, const nsIntRect& aBounds) {
|
||||
return InitInternal(aParentWidget, nullptr, aBounds, true);
|
||||
}
|
||||
|
||||
nsresult nsDocumentViewer::InitPresentationStuff(bool aDoInitialReflow) {
|
||||
|
@ -848,10 +845,12 @@ static nsPresContext* CreatePresContext(Document* aDocument,
|
|||
// This method can be used to initial the "presentation"
|
||||
// The aDoCreation indicates whether it should create
|
||||
// all the new objects or just initialize the existing ones
|
||||
nsresult nsDocumentViewer::InitInternal(
|
||||
nsIWidget* aParentWidget, nsISupports* aState, WindowGlobalChild* aActor,
|
||||
const nsIntRect& aBounds, bool aDoCreation, bool aNeedMakeCX /*= true*/,
|
||||
bool aForceSetNewDocument /* = true*/) {
|
||||
nsresult nsDocumentViewer::InitInternal(nsIWidget* aParentWidget,
|
||||
nsISupports* aState,
|
||||
const nsIntRect& aBounds,
|
||||
bool aDoCreation,
|
||||
bool aNeedMakeCX /*= true*/,
|
||||
bool aForceSetNewDocument /* = true*/) {
|
||||
if (mIsPageMode) {
|
||||
// XXXbz should the InitInternal in SetPageModeForTesting just pass false
|
||||
// here itself?
|
||||
|
@ -957,7 +956,7 @@ nsresult nsDocumentViewer::InitInternal(
|
|||
if (window) {
|
||||
nsCOMPtr<Document> curDoc = window->GetExtantDoc();
|
||||
if (aForceSetNewDocument || curDoc != mDocument) {
|
||||
rv = window->SetNewDocument(mDocument, aState, false, aActor);
|
||||
rv = window->SetNewDocument(mDocument, aState, false);
|
||||
if (NS_FAILED(rv)) {
|
||||
Destroy();
|
||||
return rv;
|
||||
|
@ -1556,7 +1555,7 @@ nsDocumentViewer::Open(nsISupports* aState, nsISHEntry* aSHEntry) {
|
|||
mDocument->SetContainer(mContainer);
|
||||
}
|
||||
|
||||
nsresult rv = InitInternal(mParentWidget, aState, nullptr, mBounds, false);
|
||||
nsresult rv = InitInternal(mParentWidget, aState, mBounds, false);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
mHidden = false;
|
||||
|
@ -2015,8 +2014,7 @@ nsDocumentViewer::SetDocumentInternal(Document* aDocument,
|
|||
DestroyPresContext();
|
||||
|
||||
mWindow = nullptr;
|
||||
rv = InitInternal(mParentWidget, nullptr, nullptr, mBounds, true, true,
|
||||
false);
|
||||
rv = InitInternal(mParentWidget, nullptr, mBounds, true, true, false);
|
||||
}
|
||||
|
||||
return rv;
|
||||
|
@ -4131,9 +4129,8 @@ NS_IMETHODIMP nsDocumentViewer::SetPageModeForTesting(
|
|||
nsresult rv = mPresContext->Init(mDeviceContext);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
NS_ENSURE_SUCCESS(
|
||||
InitInternal(mParentWidget, nullptr, nullptr, mBounds, true, false),
|
||||
NS_ERROR_FAILURE);
|
||||
NS_ENSURE_SUCCESS(InitInternal(mParentWidget, nullptr, mBounds, true, false),
|
||||
NS_ERROR_FAILURE);
|
||||
|
||||
Show();
|
||||
return NS_OK;
|
||||
|
|
|
@ -34,8 +34,6 @@ UNIFIED_SOURCES += [
|
|||
'nsWebBrowserContentPolicy.cpp',
|
||||
]
|
||||
|
||||
include('/ipc/chromium/chromium-config.mozbuild')
|
||||
|
||||
FINAL_LIBRARY = 'xul'
|
||||
LOCAL_INCLUDES += [
|
||||
'/docshell/base',
|
||||
|
|
|
@ -38,7 +38,6 @@
|
|||
#include "mozilla/dom/Element.h"
|
||||
#include "mozilla/dom/BrowsingContext.h"
|
||||
#include "mozilla/dom/LoadURIOptionsBinding.h"
|
||||
#include "mozilla/dom/WindowGlobalChild.h"
|
||||
|
||||
// for painting the background window
|
||||
#include "mozilla/LookAndFeel.h"
|
||||
|
@ -104,11 +103,7 @@ already_AddRefed<nsWebBrowser> nsWebBrowser::Create(
|
|||
nsIWebBrowserChrome* aContainerWindow, nsIWidget* aParentWidget,
|
||||
const OriginAttributes& aOriginAttributes,
|
||||
dom::BrowsingContext* aBrowsingContext,
|
||||
dom::WindowGlobalChild* aInitialWindowChild,
|
||||
bool aDisableHistory /* = false */) {
|
||||
MOZ_ASSERT_IF(aInitialWindowChild,
|
||||
aInitialWindowChild->BrowsingContext() == aBrowsingContext);
|
||||
|
||||
RefPtr<nsWebBrowser> browser = new nsWebBrowser(
|
||||
aBrowsingContext->IsContent() ? typeContentWrapper : typeChromeWrapper);
|
||||
|
||||
|
@ -121,11 +116,7 @@ already_AddRefed<nsWebBrowser> nsWebBrowser::Create(
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
uint64_t outerWindowId =
|
||||
aInitialWindowChild ? aInitialWindowChild->OuterWindowId() : 0;
|
||||
|
||||
RefPtr<nsDocShell> docShell =
|
||||
nsDocShell::Create(aBrowsingContext, outerWindowId);
|
||||
RefPtr<nsDocShell> docShell = nsDocShell::Create(aBrowsingContext);
|
||||
if (NS_WARN_IF(!docShell)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -187,10 +178,6 @@ already_AddRefed<nsWebBrowser> nsWebBrowser::Create(
|
|||
docShellTreeOwner->AddToWatcher(); // evil twin of Remove in SetDocShell(0)
|
||||
docShellTreeOwner->AddChromeListeners();
|
||||
|
||||
if (aInitialWindowChild) {
|
||||
docShell->CreateContentViewerForActor(aInitialWindowChild);
|
||||
}
|
||||
|
||||
return browser.forget();
|
||||
}
|
||||
|
||||
|
|
|
@ -58,12 +58,6 @@ class nsWebBrowserInitInfo {
|
|||
|
||||
class mozIDOMWindowProxy;
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
class WindowGlobalChild;
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
class nsWebBrowser final : public nsIWebBrowser,
|
||||
public nsIWebNavigation,
|
||||
public nsIDocShellTreeItem,
|
||||
|
@ -115,7 +109,6 @@ class nsWebBrowser final : public nsIWebBrowser,
|
|||
nsIWebBrowserChrome* aContainerWindow, nsIWidget* aParentWidget,
|
||||
const mozilla::OriginAttributes& aOriginAttributes,
|
||||
mozilla::dom::BrowsingContext* aBrowsingContext,
|
||||
mozilla::dom::WindowGlobalChild* aInitialWindowChild,
|
||||
bool aDisableHistory = false);
|
||||
|
||||
protected:
|
||||
|
|
|
@ -494,9 +494,9 @@ nsAppShellService::CreateWindowlessBrowser(bool aIsChrome,
|
|||
/* Next, we create an instance of nsWebBrowser. Instances of this class have
|
||||
* an associated doc shell, which is what we're interested in.
|
||||
*/
|
||||
nsCOMPtr<nsIWebBrowser> browser = nsWebBrowser::Create(
|
||||
stub, widget, OriginAttributes(), browsingContext,
|
||||
nullptr /* initialWindowChild */, true /* disable history */);
|
||||
nsCOMPtr<nsIWebBrowser> browser =
|
||||
nsWebBrowser::Create(stub, widget, OriginAttributes(), browsingContext,
|
||||
true /* disable history */);
|
||||
|
||||
if (NS_WARN_IF(!browser)) {
|
||||
NS_ERROR("Couldn't create instance of nsWebBrowser!");
|
||||
|
|
Загрузка…
Ссылка в новой задаче