Bug 1867152 - Fix the assertion in nsPresContext::UserInputEventsAllowed r=smaug

Differential Revision: https://phabricator.services.mozilla.com/D196106
This commit is contained in:
Sean Feng 2023-12-12 22:49:38 +00:00
Родитель 61ea0a804b
Коммит 290a5f22de
3 изменённых файлов: 17 добавлений и 1 удалений

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

@ -1309,6 +1309,7 @@ Document::Document(const char* aContentType)
mMayNeedFontPrefsUpdate(true),
mMathMLEnabled(false),
mIsInitialDocumentInWindow(false),
mIsEverInitialDocumentInWindow(false),
mIgnoreDocGroupMismatches(false),
mLoadedAsData(false),
mAddedToMemoryReportingAsDataDocument(false),
@ -18689,6 +18690,10 @@ nsIPrincipal* Document::GetPrincipalForPrefBasedHacks() const {
void Document::SetIsInitialDocument(bool aIsInitialDocument) {
mIsInitialDocumentInWindow = aIsInitialDocument;
if (aIsInitialDocument && !mIsEverInitialDocumentInWindow) {
mIsEverInitialDocumentInWindow = aIsInitialDocument;
}
// Asynchronously tell the parent process that we are, or are no longer, the
// initial document. This happens async.
if (auto* wgc = GetWindowGlobalChild()) {

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

@ -994,6 +994,12 @@ class Document : public nsINode,
*/
bool IsInitialDocument() const { return mIsInitialDocumentInWindow; }
/**
* Ask this document whether it has ever been a initial document in its
* window.
*/
bool IsEverInitialDocument() const { return mIsEverInitialDocumentInWindow; }
/**
* Tell this document that it's the initial document in its window. See
* comments on mIsInitialDocumentInWindow for when this should be called.
@ -4555,6 +4561,11 @@ class Document : public nsINode,
// document in it.
bool mIsInitialDocumentInWindow : 1;
// True if this document has ever been the initial document for a window. This
// is useful to determine if a document that was the initial document at one
// point, and became non-initial later.
bool mIsEverInitialDocumentInWindow : 1;
bool mIgnoreDocGroupMismatches : 1;
// True if we're loaded as data and therefor has any dangerous stuff, such

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

@ -1237,7 +1237,7 @@ bool nsPresContext::UserInputEventsAllowed() {
}
// Special document
if (Document()->IsInitialDocument()) {
if (Document()->IsEverInitialDocument()) {
return true;
}