зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1670816 - Handle remote subframe clones slightly earlier. r=nika
Otherwise we end up creating an in-process docshell and an initial, non-static subdocument. This usually won't cause badness, but is wrong and _can_ cause badness when printing selection etc. The assertion I added is hit on existing tests and would've caught this. Also fix another violation by grabbing the original docshell to clone from before actually performing the clone, which could be null (and we'd leave an initial document there). That would cause failures in layout/printing/crashtests/1662259.html. Differential Revision: https://phabricator.services.mozilla.com/D93279
This commit is contained in:
Родитель
85b8db6915
Коммит
dc6e67221c
|
@ -2756,7 +2756,6 @@ void nsFrameLoader::ActivateFrameEvent(const nsAString& aType, bool aCapture,
|
|||
|
||||
nsresult nsFrameLoader::DoRemoteStaticClone(nsFrameLoader* aStaticCloneOf) {
|
||||
MOZ_ASSERT(aStaticCloneOf->IsRemoteFrame());
|
||||
MOZ_DIAGNOSTIC_ASSERT(GetBrowsingContext());
|
||||
auto* cc = ContentChild::GetSingleton();
|
||||
if (!cc) {
|
||||
MOZ_DIAGNOSTIC_ASSERT(XRE_IsParentProcess());
|
||||
|
@ -2767,7 +2766,9 @@ nsresult nsFrameLoader::DoRemoteStaticClone(nsFrameLoader* aStaticCloneOf) {
|
|||
if (NS_WARN_IF(!bcToClone)) {
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
cc->SendCloneDocumentTreeInto(bcToClone, GetBrowsingContext());
|
||||
BrowsingContext* bc = GetBrowsingContext();
|
||||
MOZ_DIAGNOSTIC_ASSERT(bc);
|
||||
cc->SendCloneDocumentTreeInto(bcToClone, bc);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -2789,6 +2790,16 @@ nsresult nsFrameLoader::FinishStaticClone(
|
|||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
if (aStaticCloneOf->IsRemoteFrame()) {
|
||||
return DoRemoteStaticClone(aStaticCloneOf);
|
||||
}
|
||||
|
||||
nsIDocShell* origDocShell = aStaticCloneOf->GetDocShell();
|
||||
NS_ENSURE_STATE(origDocShell);
|
||||
|
||||
nsCOMPtr<Document> doc = origDocShell->GetDocument();
|
||||
NS_ENSURE_STATE(doc);
|
||||
|
||||
MaybeCreateDocShell();
|
||||
RefPtr<nsDocShell> docShell = GetDocShell();
|
||||
NS_ENSURE_STATE(docShell);
|
||||
|
@ -2796,20 +2807,10 @@ nsresult nsFrameLoader::FinishStaticClone(
|
|||
nsCOMPtr<Document> kungFuDeathGrip = docShell->GetDocument();
|
||||
Unused << kungFuDeathGrip;
|
||||
|
||||
if (aStaticCloneOf->IsRemoteFrame()) {
|
||||
return DoRemoteStaticClone(aStaticCloneOf);
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIContentViewer> viewer;
|
||||
docShell->GetContentViewer(getter_AddRefs(viewer));
|
||||
NS_ENSURE_STATE(viewer);
|
||||
|
||||
nsIDocShell* origDocShell = aStaticCloneOf->GetDocShell();
|
||||
NS_ENSURE_STATE(origDocShell);
|
||||
|
||||
nsCOMPtr<Document> doc = origDocShell->GetDocument();
|
||||
NS_ENSURE_STATE(doc);
|
||||
|
||||
nsCOMPtr<Document> clonedDoc =
|
||||
doc->CreateStaticClone(docShell, viewer, aOutHasInProcessPrintCallbacks);
|
||||
|
||||
|
|
|
@ -280,6 +280,8 @@ static void BuildNestedPrintObjects(const UniquePtr<nsPrintObject>& aParentPO,
|
|||
}
|
||||
|
||||
RefPtr<Document> doc = docShell->GetDocument();
|
||||
MOZ_DIAGNOSTIC_ASSERT(doc);
|
||||
MOZ_DIAGNOSTIC_ASSERT(doc->IsStaticDocument());
|
||||
|
||||
auto childPO = MakeUnique<nsPrintObject>();
|
||||
nsresult rv = childPO->InitAsNestedObject(docShell, doc, aParentPO.get());
|
||||
|
|
Загрузка…
Ссылка в новой задаче