diff --git a/layout/base/nsPresContext.cpp b/layout/base/nsPresContext.cpp index 626d1b3d273c..a03249ff13a6 100644 --- a/layout/base/nsPresContext.cpp +++ b/layout/base/nsPresContext.cpp @@ -2524,6 +2524,11 @@ nsPresContext::NotifyDidPaintForSubtree(uint32_t aFlags) return; } } + + if (!PresShell()->IsVisible() && !mFireAfterPaintEvents) { + return; + } + // Non-root prescontexts fire MozAfterPaint to all their descendants // unconditionally, even if no invalidations have been collected. This is // because we don't want to eat the cost of collecting invalidations for