Bug 1704686: Rename Document::GetTopLevelContentDocument. r=nika

It's deprecated, and returns null if the top document isn't in-process, so its
name should be clear on that point.

Differential Revision: https://phabricator.services.mozilla.com/D111771
This commit is contained in:
Kris Maglione 2021-04-15 21:19:28 +00:00
Родитель 5372cacc54
Коммит 62019b1fab
6 изменённых файлов: 14 добавлений и 40 удалений

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

@ -15081,7 +15081,7 @@ WindowContext* Document::GetTopLevelWindowContext() const {
return windowContext ? windowContext->TopWindowContext() : nullptr;
}
Document* Document::GetTopLevelContentDocument() {
Document* Document::GetTopLevelContentDocumentIfSameProcess() {
Document* parent;
if (!mLoadedAsData) {
@ -15115,38 +15115,8 @@ Document* Document::GetTopLevelContentDocument() {
return parent;
}
const Document* Document::GetTopLevelContentDocument() const {
const Document* parent;
if (!mLoadedAsData) {
parent = this;
} else {
nsCOMPtr<nsPIDOMWindowInner> window = do_QueryInterface(GetScopeObject());
if (!window) {
return nullptr;
}
parent = window->GetExtantDoc();
if (!parent) {
return nullptr;
}
}
do {
if (parent->IsTopLevelContentDocument()) {
break;
}
// If we ever have a non-content parent before we hit a toplevel content
// parent, then we're never going to find one. Just bail.
if (!parent->IsContentDocument()) {
return nullptr;
}
parent = parent->GetInProcessParentDocument();
} while (parent);
return parent;
const Document* Document::GetTopLevelContentDocumentIfSameProcess() const {
return const_cast<Document*>(this)->GetTopLevelContentDocumentIfSameProcess();
}
void Document::PropagateImageUseCounters(Document* aReferencingDocument) {

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

@ -3253,8 +3253,11 @@ class Document : public nsINode,
WindowContext* GetTopLevelWindowContext() const;
Document* GetTopLevelContentDocument();
const Document* GetTopLevelContentDocument() const;
// If the top-level ancestor content document for this document is in the same
// process, returns it. Otherwise, returns null. This function is not
// Fission-compatible, and should not be used in new code.
Document* GetTopLevelContentDocumentIfSameProcess();
const Document* GetTopLevelContentDocumentIfSameProcess() const;
// Returns the associated app window if this is a top-level chrome document,
// null otherwise.

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

@ -3800,7 +3800,7 @@ Maybe<CSSIntSize> nsGlobalWindowOuter::GetRDMDeviceSize(
// Bug 1576256: This does not work for cross-process subframes.
const Document* topInProcessContentDoc =
aDocument.GetTopLevelContentDocument();
aDocument.GetTopLevelContentDocumentIfSameProcess();
BrowsingContext* bc = topInProcessContentDoc
? topInProcessContentDoc->GetBrowsingContext()
: nullptr;

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

@ -86,7 +86,8 @@ bool IsImageExtractionAllowed(dom::Document* aDocument, JSContext* aCx,
return true;
}
dom::Document* topLevelDocument = aDocument->GetTopLevelContentDocument();
dom::Document* topLevelDocument =
aDocument->GetTopLevelContentDocumentIfSameProcess();
nsIURI* topLevelDocURI =
topLevelDocument ? topLevelDocument->GetDocumentURI() : nullptr;
nsCString topLevelDocURISpec;

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

@ -47,7 +47,7 @@ already_AddRefed<Promise> MediaDevices::GetUserMedia(
if (!owner->IsSecureContext()) {
doc->SetUseCounter(eUseCounter_custom_GetUserMediaInsec);
}
Document* topDoc = doc->GetTopLevelContentDocument();
Document* topDoc = doc->GetTopLevelContentDocumentIfSameProcess();
IgnoredErrorResult ignored;
if (topDoc && !topDoc->HasFocus(ignored)) {
doc->SetUseCounter(eUseCounter_custom_GetUserMediaUnfocused);
@ -101,7 +101,7 @@ already_AddRefed<Promise> MediaDevices::EnumerateDevices(CallerType aCallerType,
if (!owner->IsSecureContext()) {
doc->SetUseCounter(eUseCounter_custom_EnumerateDevicesInsec);
}
Document* topDoc = doc->GetTopLevelContentDocument();
Document* topDoc = doc->GetTopLevelContentDocumentIfSameProcess();
IgnoredErrorResult ignored;
if (topDoc && !topDoc->HasFocus(ignored)) {
doc->SetUseCounter(eUseCounter_custom_EnumerateDevicesUnfocused);

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

@ -610,7 +610,7 @@ already_AddRefed<PaymentRequest> PaymentRequest::Constructor(
}
// Get the top level principal
nsCOMPtr<Document> topLevelDoc = doc->GetTopLevelContentDocument();
RefPtr<Document> topLevelDoc = doc->GetTopLevelContentDocumentIfSameProcess();
MOZ_ASSERT(topLevelDoc);
nsCOMPtr<nsIPrincipal> topLevelPrincipal = topLevelDoc->NodePrincipal();