зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1585074 - Audit usage of nsIDocShellTreeItem in PendingFullscreenChangeList::Iterator::Iterator r=smaug,nika,xidorn
Differential Revision: https://phabricator.services.mozilla.com/D85988
This commit is contained in:
Родитель
a16d25d9f6
Коммит
500f5e4d7c
|
@ -13166,16 +13166,18 @@ class PendingFullscreenChangeList {
|
|||
class Iterator {
|
||||
public:
|
||||
explicit Iterator(Document* aDoc, IteratorOption aOption)
|
||||
: mCurrent(PendingFullscreenChangeList::sList.getFirst()),
|
||||
mRootShellForIteration(aDoc->GetDocShell()) {
|
||||
: mCurrent(PendingFullscreenChangeList::sList.getFirst()) {
|
||||
if (mCurrent) {
|
||||
if (mRootShellForIteration && aOption == eDocumentsWithSameRoot) {
|
||||
// Use a temporary to avoid undefined behavior from passing
|
||||
// mRootShellForIteration.
|
||||
nsCOMPtr<nsIDocShellTreeItem> root;
|
||||
mRootShellForIteration->GetInProcessRootTreeItem(
|
||||
getter_AddRefs(root));
|
||||
mRootShellForIteration = std::move(root);
|
||||
if (aDoc->GetBrowsingContext()) {
|
||||
mRootBCForIteration = aDoc->GetBrowsingContext();
|
||||
if (aOption == eDocumentsWithSameRoot) {
|
||||
RefPtr<BrowsingContext> bc =
|
||||
GetParentIgnoreChromeBoundary(mRootBCForIteration);
|
||||
while (bc) {
|
||||
mRootBCForIteration = bc;
|
||||
bc = GetParentIgnoreChromeBoundary(mRootBCForIteration);
|
||||
}
|
||||
}
|
||||
}
|
||||
SkipToNextMatch();
|
||||
}
|
||||
|
@ -13189,6 +13191,16 @@ class PendingFullscreenChangeList {
|
|||
bool AtEnd() const { return mCurrent == nullptr; }
|
||||
|
||||
private:
|
||||
already_AddRefed<BrowsingContext> GetParentIgnoreChromeBoundary(
|
||||
BrowsingContext* aBC) {
|
||||
// Chrome BrowsingContexts are only available in the parent process, so if
|
||||
// we're in a content process, we only worry about the context tree.
|
||||
if (XRE_IsParentProcess()) {
|
||||
return aBC->Canonical()->GetParentCrossChromeBoundary();
|
||||
}
|
||||
return do_AddRef(aBC->GetParent());
|
||||
}
|
||||
|
||||
UniquePtr<T> TakeAndNextInternal() {
|
||||
FullscreenChange* thisChange = mCurrent;
|
||||
MOZ_ASSERT(thisChange->Type() == T::kType);
|
||||
|
@ -13198,21 +13210,19 @@ class PendingFullscreenChangeList {
|
|||
void SkipToNextMatch() {
|
||||
while (mCurrent) {
|
||||
if (mCurrent->Type() == T::kType) {
|
||||
nsCOMPtr<nsIDocShellTreeItem> docShell =
|
||||
mCurrent->Document()->GetDocShell();
|
||||
if (!docShell) {
|
||||
RefPtr<BrowsingContext> bc =
|
||||
mCurrent->Document()->GetBrowsingContext();
|
||||
if (!bc) {
|
||||
// Always automatically drop fullscreen changes which are
|
||||
// from a document detached from the doc shell.
|
||||
UniquePtr<T> change = TakeAndNextInternal();
|
||||
change->MayRejectPromise("Document is not active");
|
||||
continue;
|
||||
}
|
||||
while (docShell && docShell != mRootShellForIteration) {
|
||||
nsCOMPtr<nsIDocShellTreeItem> parent;
|
||||
docShell->GetInProcessParent(getter_AddRefs(parent));
|
||||
docShell = std::move(parent);
|
||||
while (bc && bc != mRootBCForIteration) {
|
||||
bc = GetParentIgnoreChromeBoundary(bc);
|
||||
}
|
||||
if (docShell) {
|
||||
if (bc) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -13223,7 +13233,7 @@ class PendingFullscreenChangeList {
|
|||
}
|
||||
|
||||
FullscreenChange* mCurrent;
|
||||
nsCOMPtr<nsIDocShellTreeItem> mRootShellForIteration;
|
||||
RefPtr<BrowsingContext> mRootBCForIteration;
|
||||
};
|
||||
|
||||
private:
|
||||
|
@ -13966,6 +13976,7 @@ bool Document::FullscreenElementReadyCheck(FullscreenRequest& aRequest) {
|
|||
}
|
||||
|
||||
static nsCOMPtr<nsPIDOMWindowOuter> GetRootWindow(Document* aDoc) {
|
||||
MOZ_ASSERT(XRE_IsParentProcess());
|
||||
nsIDocShell* docShell = aDoc->GetDocShell();
|
||||
if (!docShell) {
|
||||
return nullptr;
|
||||
|
|
Загрузка…
Ссылка в новой задаче