Bug 1265715 - Part 2. Add nsDisplayListBuilderMode parameter into nsLayoutUtils::PaintFrame;
MozReview-Commit-ID: 1jkJOOH8KCi
--- a/dom/base/nsDOMWindowUtils.cpp
+++ b/dom/base/nsDOMWindowUtils.cpp
@@ -375,17 +375,19 @@ nsDOMWindowUtils::SetDisplayPortForEleme
if (displayport.IsEmpty() &&
rootFrame == nsLayoutUtils::GetDisplayRootFrame(rootFrame)) {
nsCOMPtr<nsIWidget> widget = GetWidget();
if (widget) {
bool isRetainingManager;
LayerManager* manager = widget->GetLayerManager(&isRetainingManager);
if (isRetainingManager) {
manager->BeginTransaction();
- nsLayoutUtils::PaintFrame(nullptr, rootFrame, nsRegion(), NS_RGB(255, 255, 255),
+ nsLayoutUtils::PaintFrame(nullptr, rootFrame, nsRegion(),
+ NS_RGB(255, 255, 255),
+ nsDisplayListBuilderMode::PAINTING,
nsLayoutUtils::PAINT_WIDGET_LAYERS |
nsLayoutUtils::PAINT_EXISTING_TRANSACTION);
}
}
}
}
return NS_OK;
--- a/layout/base/nsLayoutUtils.cpp
+++ b/layout/base/nsLayoutUtils.cpp
@@ -3291,16 +3291,17 @@ nsLayoutUtils::ExpireDisplayPortOnAsyncS
break;
}
}
}
nsresult
nsLayoutUtils::PaintFrame(nsRenderingContext* aRenderingContext, nsIFrame* aFrame,
const nsRegion& aDirtyRegion, nscolor aBackstop,
+ nsDisplayListBuilderMode aBuilderMode,
uint32_t aFlags)
{
PROFILER_LABEL("nsLayoutUtils", "PaintFrame",
js::ProfileEntry::Category::GRAPHICS);
#ifdef MOZ_DUMP_PAINTING
if (!gPaintCountStack) {
gPaintCountStack = new nsTArray<int>();
@@ -3323,18 +3324,18 @@ nsLayoutUtils::PaintFrame(nsRenderingCon
nsPresContext* presContext = aFrame->PresContext();
nsIPresShell* presShell = presContext->PresShell();
nsRootPresContext* rootPresContext = presContext->GetRootPresContext();
if (!rootPresContext) {
return NS_OK;
}
TimeStamp startBuildDisplayList = TimeStamp::Now();
- nsDisplayListBuilder builder(aFrame, nsDisplayListBuilderMode::PAINTING,
- !(aFlags & PAINT_HIDE_CARET));
+ nsDisplayListBuilder builder(aFrame, aBuilderMode,
+ !(aFlags & PAINT_HIDE_CARET));
if (aFlags & PAINT_IN_TRANSFORM) {
builder.SetInTransform(true);
}
if (aFlags & PAINT_SYNC_DECODE_IMAGES) {
builder.SetSyncDecodeImages(true);
}
if (aFlags & (PAINT_WIDGET_LAYERS | PAINT_TO_WINDOW)) {
builder.SetPaintingToWindow(true);
--- a/layout/base/nsLayoutUtils.h
+++ b/layout/base/nsLayoutUtils.h
@@ -36,16 +36,17 @@
class nsPresContext;
class nsIContent;
class nsIAtom;
class nsIScrollableFrame;
class nsIDOMEvent;
class nsRegion;
class nsDisplayListBuilder;
+enum class nsDisplayListBuilderMode : uint8_t;
class nsDisplayItem;
class nsFontMetrics;
class nsFontFaceList;
class nsIImageLoadingContent;
class nsStyleContext;
class nsBlockFrame;
class nsContainerFrame;
class nsView;
@@ -1041,16 +1042,17 @@ public:
* to pixel-aligned coordinates. This can be null, in which case
* aFrame must be a "display root" (root frame for a root document,
* or the root of a popup) with an associated widget and we draw using
* the layer manager for the frame's widget.
* @param aDirtyRegion the region that must be painted, in the coordinates
* of aFrame.
* @param aBackstop paint the dirty area with this color before drawing
* the actual content; pass NS_RGBA(0,0,0,0) to draw no background.
+ * @param aBuilderMode Passed through to the display-list builder.
* @param aFlags if PAINT_IN_TRANSFORM is set, then we assume
* this is inside a transform or SVG foreignObject. If
* PAINT_SYNC_DECODE_IMAGES is set, we force synchronous decode on all
* images. If PAINT_WIDGET_LAYERS is set, aFrame must be a display root,
* and we will use the frame's widget's layer manager to paint
* even if aRenderingContext is non-null. This is useful if you want
* to force rendering to use the widget's layer manager for testing
* or speed. PAINT_WIDGET_LAYERS must be set if aRenderingContext is null.
@@ -1076,17 +1078,19 @@ public:
* we paint by construct a BasicLayerManager and calling
* BeginTransactionWithTarget on it. This is desirable if we're doing
* something like drawWindow in a mode where what gets rendered doesn't
* necessarily correspond to what's visible in the window; we don't
* want to mess up the widget's layer tree.
*/
static nsresult PaintFrame(nsRenderingContext* aRenderingContext, nsIFrame* aFrame,
const nsRegion& aDirtyRegion, nscolor aBackstop,
- uint32_t aFlags = 0);
+ nsDisplayListBuilderMode aBuilderMode,
+ uint32_t aFlags = 0
+ );
/**
* Uses a binary search for find where the cursor falls in the line of text
* It also keeps track of the part of the string that has already been
* measured so it doesn't have to keep measuring the same text over and over.
*
* @param "aBaseWidth" contains the width in twips of the portion
* of the text that has already been measured, and aBaseInx contains
--- a/layout/base/nsPresShell.cpp
+++ b/layout/base/nsPresShell.cpp
@@ -4727,17 +4727,19 @@ PresShell::RenderDocument(const nsRect&
}
// Don't let drawWindow blow away our retained layer tree
if ((flags & nsLayoutUtils::PAINT_WIDGET_LAYERS) && wouldFlushRetainedLayers) {
flags &= ~nsLayoutUtils::PAINT_WIDGET_LAYERS;
}
nsLayoutUtils::PaintFrame(&rc, rootFrame, nsRegion(aRect),
- aBackgroundColor, flags);
+ aBackgroundColor,
+ nsDisplayListBuilderMode::PAINTING,
+ 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;
}
/*
@@ -6354,17 +6356,18 @@ PresShell::Paint(nsView* aViewToP
// 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);
+ nsLayoutUtils::PaintFrame(nullptr, frame, aDirtyRegion, bgcolor,
+ nsDisplayListBuilderMode::PAINTING, 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.
--- a/layout/generic/nsSimplePageSequenceFrame.cpp
+++ b/layout/generic/nsSimplePageSequenceFrame.cpp
@@ -770,16 +770,17 @@ nsSimplePageSequenceFrame::PrintNextPage
NS_ENSURE_TRUE(gCtx, NS_ERROR_OUT_OF_MEMORY);
nsRenderingContext renderingContext(gCtx);
nsRect drawingRect(nsPoint(0, 0), currentPage->GetSize());
nsRegion drawingRegion(drawingRect);
nsLayoutUtils::PaintFrame(&renderingContext, currentPage,
drawingRegion, NS_RGBA(0,0,0,0),
+ nsDisplayListBuilderMode::PAINTING,
nsLayoutUtils::PAINT_SYNC_DECODE_IMAGES);
if (mSelectionHeight >= 0 && selectionY < mSelectionHeight) {
selectionY += height;
printedPageNum++;
pf->SetPageNumInfo(printedPageNum, mTotalPages);
conFrame->SetPosition(conFrame->GetPosition() + nsPoint(0, -height));
nsContainerFrame::PositionChildViews(conFrame);
--- a/layout/svg/nsSVGForeignObjectFrame.cpp
+++ b/layout/svg/nsSVGForeignObjectFrame.cpp
@@ -271,17 +271,19 @@ nsSVGForeignObjectFrame::PaintSVG(gfxCon
aContext.Multiply(canvasTMForChildren);
uint32_t flags = nsLayoutUtils::PAINT_IN_TRANSFORM;
if (SVGAutoRenderState::IsPaintingToWindow(aContext.GetDrawTarget())) {
flags |= nsLayoutUtils::PAINT_TO_WINDOW;
}
nsRenderingContext rendCtx(&aContext);
nsresult rv = nsLayoutUtils::PaintFrame(&rendCtx, kid, nsRegion(kidDirtyRect),
- NS_RGBA(0,0,0,0), flags);
+ NS_RGBA(0,0,0,0),
+ nsDisplayListBuilderMode::PAINTING,
+ flags);
aContext.Restore();
return rv;
}
nsIFrame*
nsSVGForeignObjectFrame::GetFrameForPoint(const gfxPoint& aPoint)
--- a/layout/svg/nsSVGIntegrationUtils.cpp
+++ b/layout/svg/nsSVGIntegrationUtils.cpp
@@ -793,30 +793,32 @@ PaintFrameCallback::operator()(gfxContex
uint32_t flags = nsLayoutUtils::PAINT_IN_TRANSFORM;
if (mFlags & nsSVGIntegrationUtils::FLAG_SYNC_DECODE_IMAGES) {
flags |= nsLayoutUtils::PAINT_SYNC_DECODE_IMAGES;
}
nsRenderingContext context(aContext);
nsLayoutUtils::PaintFrame(&context, mFrame,
dirty, NS_RGBA(0, 0, 0, 0),
+ nsDisplayListBuilderMode::PAINTING,
flags);
nsIFrame* currentFrame = mFrame;
while ((currentFrame = currentFrame->GetNextContinuation()) != nullptr) {
offset = currentFrame->GetOffsetToCrossDoc(mFrame);
devPxOffset = gfxPoint(offset.x, offset.y) / appUnitsPerDevPixel;
aContext->Save();
aContext->Multiply(gfxMatrix::Scaling(1/scaleX, 1/scaleY));
aContext->Multiply(gfxMatrix::Translation(devPxOffset));
aContext->Multiply(gfxMatrix::Scaling(scaleX, scaleY));
nsLayoutUtils::PaintFrame(&context, currentFrame,
dirty - offset, NS_RGBA(0, 0, 0, 0),
+ nsDisplayListBuilderMode::PAINTING,
flags);
aContext->Restore();
}
aContext->Restore();
mFrame->RemoveStateBits(NS_FRAME_DRAWING_AS_PAINTSERVER);