Backed out changeset 0328321272d7 (bug 1897322) for causing multiple failures. CLOSED TREE

This commit is contained in:
Stanca Serban 2024-05-17 14:09:21 +03:00
parent 7d955f6f57
commit e3f541a69d
2 changed files with 17 additions and 19 deletions

View file

@ -10217,7 +10217,6 @@ bool PresShell::RemovePostRefreshObserver(nsAPostRefreshObserver* aObserver) {
} }
void PresShell::DoObserveStyleFlushes() { void PresShell::DoObserveStyleFlushes() {
MOZ_DIAGNOSTIC_ASSERT(!IsDestroying());
MOZ_ASSERT(!ObservingStyleFlushes()); MOZ_ASSERT(!ObservingStyleFlushes());
mObservingStyleFlushes = true; mObservingStyleFlushes = true;

View file

@ -2195,12 +2195,13 @@ void nsRefreshDriver::DispatchResizeEvents() {
if (!mPresContext || !mPresContext->GetPresShell()) { if (!mPresContext || !mPresContext->GetPresShell()) {
break; break;
} }
// Make sure to not process observers which might have been removed during // Make sure to not process observers which might have been removed
// previous iterations. // during previous iterations.
if (!mResizeEventFlushObservers.RemoveElement(presShell)) { if (!mResizeEventFlushObservers.RemoveElement(presShell)) {
continue; continue;
} }
// MOZ_KnownLive because 'observers' is guaranteed to keep it alive. // MOZ_KnownLive because 'observers' is guaranteed to
// keep it alive.
// //
// Fixing https://bugzilla.mozilla.org/show_bug.cgi?id=1620312 on its own // Fixing https://bugzilla.mozilla.org/show_bug.cgi?id=1620312 on its own
// won't help here, because 'observers' is non-const and we have the // won't help here, because 'observers' is non-const and we have the
@ -2210,26 +2211,26 @@ void nsRefreshDriver::DispatchResizeEvents() {
} }
void nsRefreshDriver::FlushLayoutOnPendingDocsAndFixUpFocus() { void nsRefreshDriver::FlushLayoutOnPendingDocsAndFixUpFocus() {
AutoTArray<RefPtr<PresShell>, 16> observers; AutoTArray<PresShell*, 16> observers;
observers.AppendElements(mStyleFlushObservers); observers.AppendElements(mStyleFlushObservers);
for (RefPtr<PresShell>& presShell : Reversed(observers)) { for (uint32_t j = observers.Length();
if (!mPresContext || !mPresContext->GetPresShell()) { j && mPresContext && mPresContext->GetPresShell(); --j) {
break; // Make sure to not process observers which might have been removed
} // during previous iterations.
// Make sure to not process observers which might have been removed during PresShell* rawPresShell = observers[j - 1];
// previous iterations. if (!mStyleFlushObservers.RemoveElement(rawPresShell)) {
if (!mStyleFlushObservers.RemoveElement(presShell)) {
continue; continue;
} }
LogPresShellObserver::Run run(presShell, this); LogPresShellObserver::Run run(rawPresShell, this);
RefPtr<PresShell> presShell = rawPresShell;
presShell->mWasLastReflowInterrupted = false; presShell->mWasLastReflowInterrupted = false;
const ChangesToFlush ctf(FlushType::InterruptibleLayout, false); const ChangesToFlush ctf(FlushType::InterruptibleLayout, false);
// MOZ_KnownLive because 'observers' is guaranteed to keep it alive. presShell->FlushPendingNotifications(ctf);
MOZ_KnownLive(presShell)->FlushPendingNotifications(ctf);
const bool fixedUpFocus = presShell->FixUpFocus(); const bool fixedUpFocus = presShell->FixUpFocus();
if (fixedUpFocus) { if (fixedUpFocus) {
MOZ_KnownLive(presShell)->FlushPendingNotifications(ctf); presShell->FlushPendingNotifications(ctf);
} }
// This is a bit subtle: We intentionally mark the pres shell as not // This is a bit subtle: We intentionally mark the pres shell as not
// observing style flushes here, rather than above the flush, so that // observing style flushes here, rather than above the flush, so that
@ -2243,9 +2244,7 @@ void nsRefreshDriver::FlushLayoutOnPendingDocsAndFixUpFocus() {
if (NS_WARN_IF(presShell->NeedStyleFlush()) || if (NS_WARN_IF(presShell->NeedStyleFlush()) ||
NS_WARN_IF(presShell->NeedLayoutFlush()) || NS_WARN_IF(presShell->NeedLayoutFlush()) ||
NS_WARN_IF(fixedUpFocus && presShell->NeedsFocusFixUp())) { NS_WARN_IF(fixedUpFocus && presShell->NeedsFocusFixUp())) {
if (MOZ_LIKELY(!presShell->IsDestroying())) { presShell->ObserveStyleFlushes();
presShell->ObserveStyleFlushes();
}
} }
// Inform the FontFaceSet that we ticked, so that it can resolve its ready // Inform the FontFaceSet that we ticked, so that it can resolve its ready