diff --git a/layout/base/nsLayoutUtils.cpp b/layout/base/nsLayoutUtils.cpp index 0958f3e17b87..b7e1b9f9d759 100644 --- a/layout/base/nsLayoutUtils.cpp +++ b/layout/base/nsLayoutUtils.cpp @@ -3131,6 +3131,10 @@ nsresult nsLayoutUtils::PaintFrame(gfxContext* aRenderingContext, TimeStamp startBuildDisplayList = TimeStamp::Now(); const bool buildCaret = !(aFlags & PaintFrameFlags::HideCaret); + + // Note that isForPainting here does not include the PaintForPrinting builder + // mode; that's OK because there is no point in using retained display lists + // for a print destination. const bool isForPainting = (aFlags & PaintFrameFlags::WidgetLayers) && aBuilderMode == nsDisplayListBuilderMode::Painting; diff --git a/layout/generic/nsPageSequenceFrame.cpp b/layout/generic/nsPageSequenceFrame.cpp index 09bd79dbba1a..a3459080ea6b 100644 --- a/layout/generic/nsPageSequenceFrame.cpp +++ b/layout/generic/nsPageSequenceFrame.cpp @@ -673,7 +673,7 @@ nsresult nsPageSequenceFrame::PrintNextSheet() { nsRegion drawingRegion(drawingRect); nsLayoutUtils::PaintFrame(gCtx, currentSheetFrame, drawingRegion, NS_RGBA(0, 0, 0, 0), - nsDisplayListBuilderMode::Painting, + nsDisplayListBuilderMode::PaintForPrinting, nsLayoutUtils::PaintFrameFlags::SyncDecodeImages); return rv; } diff --git a/layout/painting/nsDisplayList.h b/layout/painting/nsDisplayList.h index 85cd4b28ab6b..de09de56c918 100644 --- a/layout/painting/nsDisplayList.h +++ b/layout/painting/nsDisplayList.h @@ -341,6 +341,7 @@ struct ActiveScrolledRoot { enum class nsDisplayListBuilderMode : uint8_t { Painting, + PaintForPrinting, EventDelivery, FrameVisibility, TransformComputation, @@ -463,10 +464,20 @@ class nsDisplayListBuilder { } /** - * @return true if the display list is being built for painting. + * @return true if the display list is being built for painting. This + * includes both painting to a window or other buffer and painting to + * a print/pdf destination. */ bool IsForPainting() const { - return mMode == nsDisplayListBuilderMode::Painting; + return mMode == nsDisplayListBuilderMode::Painting || + mMode == nsDisplayListBuilderMode::PaintForPrinting; + } + + /** + * @return true if the display list is being built specifically for printing. + */ + bool IsForPrinting() const { + return mMode == nsDisplayListBuilderMode::PaintForPrinting; } /**