Bug 1883138 - Ensure HasParserNotified returns true only when parser has actually notified, r=hsivonen

Differential Revision: https://phabricator.services.mozilla.com/D203324
This commit is contained in:
Olli Pettay 2024-03-07 12:52:30 +00:00
Родитель 43e6b85dbe
Коммит f575c3bb9f
3 изменённых файлов: 13 добавлений и 8 удалений

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

@ -3878,7 +3878,12 @@ class Document : public nsINode,
void SetAllowDeclarativeShadowRoots(bool aAllowDeclarativeShadowRoots);
bool AllowsDeclarativeShadowRoots() const;
void SuspendDOMNotifications() { mSuspendDOMNotifications = true; }
void SuspendDOMNotifications() {
MOZ_ASSERT(IsHTMLDocument(),
"Currently suspending DOM notifications is supported only on "
"HTML documents.");
mSuspendDOMNotifications = true;
}
void ResumeDOMNotifications() { mSuspendDOMNotifications = false; }

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

@ -81,9 +81,6 @@ template <NotifyPresShell aNotifyPresShell = NotifyPresShell::After,
static inline void Notify(nsINode* aNode, NotifyObserver&& aNotify,
uint32_t aCallback) {
Document* doc = aNode->OwnerDoc();
if (doc->DOMNotificationsSuspended()) {
return;
}
nsDOMMutationEnterLeave enterLeave(doc);
#ifdef DEBUG

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

@ -257,9 +257,10 @@ nsresult nsHtml5TreeOperation::Append(nsIContent* aNode, nsIContent* aParent,
MOZ_ASSERT(aBuilder);
MOZ_ASSERT(aBuilder->IsInDocUpdate());
ErrorResult rv;
nsHtml5OtherDocUpdate update(aParent->OwnerDoc(), aBuilder->GetDocument());
Document* ownerDoc = aParent->OwnerDoc();
nsHtml5OtherDocUpdate update(ownerDoc, aBuilder->GetDocument());
aParent->AppendChildTo(aNode, false, rv);
if (!rv.Failed()) {
if (!rv.Failed() && !ownerDoc->DOMNotificationsSuspended()) {
aNode->SetParserHasNotified();
MutationObservers::NotifyContentAppended(aParent, aNode);
}
@ -303,8 +304,10 @@ nsresult nsHtml5TreeOperation::AppendToDocument(
return rv.StealNSResult();
}
aNode->SetParserHasNotified();
MutationObservers::NotifyContentInserted(doc, aNode);
if (!doc->DOMNotificationsSuspended()) {
aNode->SetParserHasNotified();
MutationObservers::NotifyContentInserted(doc, aNode);
}
NS_ASSERTION(!nsContentUtils::IsSafeToRunScript(),
"Someone forgot to block scripts");