diff --git a/layout/base/nsPresShell.cpp b/layout/base/nsPresShell.cpp index f5e21c4a103e..00c65d04a00a 100644 --- a/layout/base/nsPresShell.cpp +++ b/layout/base/nsPresShell.cpp @@ -4745,6 +4745,9 @@ PresShell::RenderDocument(const nsRect& aRect, uint32_t aFlags, nsLayoutUtils::PaintFrame(&rc, rootFrame, nsRegion(aRect), aBackgroundColor, flags); + // We don't call NotifyCompositorOfVisibleRegionsChange here because we're + // not painting to the window, and hence there should be no change. + return NS_OK; } @@ -6432,8 +6435,30 @@ PresShell::Paint(nsView* aViewToPaint, } if (frame) { + // Remove the entries of the mInDisplayPortFrames hashtable and put them + // in oldInDisplayPortFrames. + VisibleFrames oldInDisplayPortFrames; + mInDisplayPortFrames.SwapElements(oldInDisplayPortFrames); + + InitVisibleRegionsIfVisualizationEnabled(VisibilityCounter::IN_DISPLAYPORT); + // We can paint directly into the widget using its layer manager. nsLayoutUtils::PaintFrame(nullptr, frame, aDirtyRegion, bgcolor, flags); + + DecVisibleCount(oldInDisplayPortFrames, VisibilityCounter::IN_DISPLAYPORT); + + if (mVisibleRegions && + !mNotifyCompositorOfVisibleRegionsChangeEvent.IsPending()) { + // Asynchronously notify the compositor of the new visible regions, + // since this is happening during a paint and updating the visible + // regions triggers a recomposite. + RefPtr> event = + NS_NewRunnableMethod(this, &PresShell::NotifyCompositorOfVisibleRegionsChange); + if (NS_SUCCEEDED(NS_DispatchToMainThread(event))) { + mNotifyCompositorOfVisibleRegionsChangeEvent = event; + } + } + return; } diff --git a/layout/generic/nsFrame.cpp b/layout/generic/nsFrame.cpp index a40df63f597e..d2f25afecd0e 100644 --- a/layout/generic/nsFrame.cpp +++ b/layout/generic/nsFrame.cpp @@ -2704,6 +2704,14 @@ nsIFrame::BuildDisplayListForChild(nsDisplayListBuilder* aBuilder, !PresContext()->GetTheme()->WidgetIsContainer(ourDisp->mAppearance)) return; + // Since we're now sure that we're adding this frame to the display list + // (which means we're painting it, modulo occlusion), mark it as visible + // within the displayport. + if (aBuilder->IsPaintingToWindow() && child->TrackingVisibility()) { + nsIPresShell* shell = child->PresContext()->PresShell(); + shell->MarkFrameVisibleInDisplayPort(child); + } + // Child is composited if it's transformed, partially transparent, or has // SVG effects or a blend mode.. const nsStyleDisplay* disp = child->StyleDisplay();