Bug 1896711 part 2: Use MakeRefPtr to reduce boilerplate, in layout/svg. r=TYLin

Also remove one unnecessary null-check for an object that we're allocating
infallibly.

Differential Revision: https://phabricator.services.mozilla.com/D210388
This commit is contained in:
Daniel Holbert 2024-05-15 07:29:20 +00:00
Родитель 65bdc0fc6f
Коммит 88d1a64077
5 изменённых файлов: 6 добавлений и 11 удалений

Просмотреть файл

@ -134,7 +134,7 @@ void SVGMarkerFrame::PaintMark(gfxContext& aContext,
ISVGDisplayableFrame* SVGFrame = do_QueryFrame(kid);
// The CTM of each frame referencing us may be different.
SVGFrame->NotifySVGChanged(ISVGDisplayableFrame::TRANSFORM_CHANGED);
RefPtr<SVGContextPaintImpl> contextPaint = new SVGContextPaintImpl();
auto contextPaint = MakeRefPtr<SVGContextPaintImpl>();
contextPaint->Init(aContext.GetDrawTarget(), aContext.CurrentMatrixDouble(),
aMarkedFrame, SVGContextPaint::GetContextPaint(marker),
aImgParams);

Просмотреть файл

@ -1676,8 +1676,7 @@ Element* SVGObserverUtils::GetAndObserveBackgroundImage(nsIFrame* aFrame,
aFrame->GetContent()
->OwnerDoc()
->ReferrerInfoForInternalCSSAndSVGResources();
RefPtr<URLAndReferrerInfo> url =
new URLAndReferrerInfo(targetURI, referrerInfo);
auto url = MakeRefPtr<URLAndReferrerInfo>(targetURI, referrerInfo);
return static_cast<SVGMozElementObserver*>(
hashtable

Просмотреть файл

@ -688,13 +688,9 @@ already_AddRefed<gfxPattern> SVGPatternFrame::GetPaintServerPattern(
return nullptr;
}
RefPtr<gfxPattern> pattern = new gfxPattern(surface, pMatrix);
if (!pattern) {
return nullptr;
}
auto pattern = MakeRefPtr<gfxPattern>(surface, pMatrix);
pattern->SetExtend(ExtendMode::REPEAT);
return pattern.forget();
}

Просмотреть файл

@ -3142,7 +3142,7 @@ void SVGTextFrame::PaintSVG(gfxContext& aContext, const gfxMatrix& aTransform,
while (run.mFrame) {
nsTextFrame* frame = run.mFrame;
RefPtr<SVGContextPaintImpl> contextPaint = new SVGContextPaintImpl();
auto contextPaint = MakeRefPtr<SVGContextPaintImpl>();
DrawMode drawMode = contextPaint->Init(&aDrawTarget, initialMatrix, frame,
outerContextPaint, aImgParams);
if (drawMode & DrawMode::GLYPH_STROKE) {

Просмотреть файл

@ -513,7 +513,7 @@ class MixModeBlender {
gfxContextAutoSaveRestore save(mSourceCtx);
mSourceCtx->SetMatrix(Matrix()); // This will be restored right after.
RefPtr<gfxPattern> pattern = new gfxPattern(
auto pattern = MakeRefPtr<gfxPattern>(
targetSurf, Matrix::Translation(mTargetOffset.x, mTargetOffset.y));
mSourceCtx->SetPattern(pattern);
mSourceCtx->Paint();