Bug 1523638 - Part 9: Use provided 'WindowGlobalChild' actors to create the initial about:blank document, r=kmag
Differential Revision: https://phabricator.services.mozilla.com/D37656
This commit is contained in:
@@ -307,9 +307,10 @@ static void DecreasePrivateDocShellCount() {
|
||||
}
|
||||
}
|
||||
|
||||
nsDocShell::nsDocShell(BrowsingContext* aBrowsingContext)
|
||||
nsDocShell::nsDocShell(BrowsingContext* aBrowsingContext,
|
||||
uint64_t aContentWindowID)
|
||||
: nsDocLoader(),
|
||||
mContentWindowID(nsContentUtils::GenerateWindowId()),
|
||||
mContentWindowID(aContentWindowID),
|
||||
mBrowsingContext(aBrowsingContext),
|
||||
mForcedCharset(nullptr),
|
||||
mParentCharset(nullptr),
|
||||
@@ -395,6 +396,11 @@ 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!");
|
||||
@@ -461,11 +467,11 @@ nsDocShell::~nsDocShell() {
|
||||
|
||||
/* static */
|
||||
already_AddRefed<nsDocShell> nsDocShell::Create(
|
||||
BrowsingContext* aBrowsingContext) {
|
||||
BrowsingContext* aBrowsingContext, uint64_t aContentWindowID) {
|
||||
MOZ_ASSERT(aBrowsingContext, "DocShell without a BrowsingContext!");
|
||||
|
||||
nsresult rv;
|
||||
RefPtr<nsDocShell> ds = new nsDocShell(aBrowsingContext);
|
||||
RefPtr<nsDocShell> ds = new nsDocShell(aBrowsingContext, aContentWindowID);
|
||||
|
||||
// Initialize the underlying nsDocLoader.
|
||||
rv = ds->nsDocLoader::Init();
|
||||
@@ -519,6 +525,7 @@ already_AddRefed<nsDocShell> nsDocShell::Create(
|
||||
|
||||
// Make |ds| the primary DocShell for the given context.
|
||||
aBrowsingContext->SetDocShell(ds);
|
||||
|
||||
return ds.forget();
|
||||
}
|
||||
|
||||
@@ -6368,12 +6375,13 @@ nsresult nsDocShell::RefreshURIFromQueue() {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsDocShell::Embed(nsIContentViewer* aContentViewer) {
|
||||
nsresult nsDocShell::Embed(nsIContentViewer* aContentViewer,
|
||||
WindowGlobalChild* aWindowActor) {
|
||||
// Save the LayoutHistoryState of the previous document, before
|
||||
// setting up new document
|
||||
PersistLayoutHistoryState();
|
||||
|
||||
nsresult rv = SetupNewViewer(aContentViewer);
|
||||
nsresult rv = SetupNewViewer(aContentViewer, aWindowActor);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// XXX What if SetupNewViewer fails?
|
||||
@@ -7009,6 +7017,7 @@ nsresult nsDocShell::EnsureContentViewer() {
|
||||
nsCOMPtr<nsIURI> baseURI;
|
||||
nsIPrincipal* principal = GetInheritedPrincipal(false);
|
||||
nsIPrincipal* storagePrincipal = GetInheritedPrincipal(false, true);
|
||||
|
||||
nsCOMPtr<nsIDocShellTreeItem> parentItem;
|
||||
GetSameTypeParent(getter_AddRefs(parentItem));
|
||||
if (parentItem) {
|
||||
@@ -7050,11 +7059,14 @@ nsresult nsDocShell::EnsureContentViewer() {
|
||||
nsresult nsDocShell::CreateAboutBlankContentViewer(
|
||||
nsIPrincipal* aPrincipal, nsIPrincipal* aStoragePrincipal,
|
||||
nsIContentSecurityPolicy* aCSP, nsIURI* aBaseURI,
|
||||
bool aTryToSaveOldPresentation, bool aCheckPermitUnload) {
|
||||
bool aTryToSaveOldPresentation, bool aCheckPermitUnload,
|
||||
WindowGlobalChild* aActor) {
|
||||
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. */
|
||||
@@ -7183,7 +7195,7 @@ nsresult nsDocShell::CreateAboutBlankContentViewer(
|
||||
// hook 'em up
|
||||
if (viewer) {
|
||||
viewer->SetContainer(this);
|
||||
rv = Embed(viewer);
|
||||
rv = Embed(viewer, aActor);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
SetCurrentURI(blankDoc->GetDocumentURI(), nullptr, true, 0);
|
||||
@@ -7213,6 +7225,32 @@ 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) {
|
||||
@@ -8413,7 +8451,8 @@ nsresult nsDocShell::NewContentViewerObj(const nsACString& aContentType,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsDocShell::SetupNewViewer(nsIContentViewer* aNewViewer) {
|
||||
nsresult nsDocShell::SetupNewViewer(nsIContentViewer* aNewViewer,
|
||||
WindowGlobalChild* aWindowActor) {
|
||||
MOZ_ASSERT(!mIsBeingDestroyed);
|
||||
|
||||
//
|
||||
@@ -8537,7 +8576,7 @@ nsresult nsDocShell::SetupNewViewer(nsIContentViewer* aNewViewer) {
|
||||
|
||||
mContentViewer->SetNavigationTiming(mTiming);
|
||||
|
||||
if (NS_FAILED(mContentViewer->Init(widget, bounds))) {
|
||||
if (NS_FAILED(mContentViewer->Init(widget, bounds, aWindowActor))) {
|
||||
mContentViewer = nullptr;
|
||||
NS_WARNING("ContentViewer Initialization failed");
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
Reference in New Issue
Block a user