Bug 1871107 - Use do_AddRef more r=TYLin

Differential Revision: https://phabricator.services.mozilla.com/D197001
This commit is contained in:
Robert Longson 2023-12-20 23:34:03 +00:00
Родитель c2a72cd8ea
Коммит cad8a108e0
9 изменённых файлов: 50 добавлений и 108 удалений

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

@ -53,6 +53,5 @@ using namespace mozilla::dom;
already_AddRefed<TimeEvent> NS_NewDOMTimeEvent(EventTarget* aOwner,
nsPresContext* aPresContext,
InternalSMILTimeEvent* aEvent) {
RefPtr<TimeEvent> it = new TimeEvent(aOwner, aPresContext, aEvent);
return it.forget();
return do_AddRef(new TimeEvent(aOwner, aPresContext, aEvent));
}

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

@ -126,8 +126,7 @@ already_AddRefed<DOMSVGPoint> DOMSVGPoint::MatrixTransform(
return nullptr;
}
auto pt = matrix2D->TransformPoint(InternalItem());
RefPtr<DOMSVGPoint> newPoint = new DOMSVGPoint(ToPoint(pt));
return newPoint.forget();
return do_AddRef(new DOMSVGPoint(ToPoint(pt)));
}
void DOMSVGPoint::InsertingIntoList(DOMSVGPointList* aList, uint32_t aListIndex,

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

@ -238,9 +238,8 @@ already_AddRefed<DOMSVGPoint> SVGGeometryElement::GetPointAtLength(
return nullptr;
}
RefPtr<DOMSVGPoint> point = new DOMSVGPoint(path->ComputePointAtLength(
clamped(distance, 0.f, path->ComputeLength())));
return point.forget();
return do_AddRef(new DOMSVGPoint(path->ComputePointAtLength(
clamped(distance, 0.f, path->ComputeLength()))));
}
float SVGGeometryElement::GetPathLengthScale(PathLengthScaleForType aFor) {

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

@ -90,8 +90,7 @@ void SVGMatrix::SetF(float aF, ErrorResult& rv) {
}
already_AddRefed<SVGMatrix> SVGMatrix::Multiply(SVGMatrix& aMatrix) {
RefPtr<SVGMatrix> matrix = new SVGMatrix(aMatrix.GetMatrix() * GetMatrix());
return matrix.forget();
return do_AddRef(new SVGMatrix(aMatrix.GetMatrix() * GetMatrix()));
}
already_AddRefed<SVGMatrix> SVGMatrix::Inverse(ErrorResult& rv) {
@ -100,14 +99,12 @@ already_AddRefed<SVGMatrix> SVGMatrix::Inverse(ErrorResult& rv) {
rv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
return nullptr;
}
RefPtr<SVGMatrix> matrix = new SVGMatrix(mat);
return matrix.forget();
return do_AddRef(new SVGMatrix(mat));
}
already_AddRefed<SVGMatrix> SVGMatrix::Translate(float x, float y) {
RefPtr<SVGMatrix> matrix =
new SVGMatrix(gfxMatrix(GetMatrix()).PreTranslate(gfxPoint(x, y)));
return matrix.forget();
return do_AddRef(
new SVGMatrix(gfxMatrix(GetMatrix()).PreTranslate(gfxPoint(x, y))));
}
already_AddRefed<SVGMatrix> SVGMatrix::Scale(float scaleFactor) {
@ -116,15 +113,13 @@ already_AddRefed<SVGMatrix> SVGMatrix::Scale(float scaleFactor) {
already_AddRefed<SVGMatrix> SVGMatrix::ScaleNonUniform(float scaleFactorX,
float scaleFactorY) {
RefPtr<SVGMatrix> matrix = new SVGMatrix(
gfxMatrix(GetMatrix()).PreScale(scaleFactorX, scaleFactorY));
return matrix.forget();
return do_AddRef(new SVGMatrix(
gfxMatrix(GetMatrix()).PreScale(scaleFactorX, scaleFactorY)));
}
already_AddRefed<SVGMatrix> SVGMatrix::Rotate(float angle) {
RefPtr<SVGMatrix> matrix =
new SVGMatrix(gfxMatrix(GetMatrix()).PreRotate(angle * radPerDegree));
return matrix.forget();
return do_AddRef(
new SVGMatrix(gfxMatrix(GetMatrix()).PreRotate(angle * radPerDegree)));
}
already_AddRefed<SVGMatrix> SVGMatrix::RotateFromVector(float x, float y,
@ -134,23 +129,20 @@ already_AddRefed<SVGMatrix> SVGMatrix::RotateFromVector(float x, float y,
return nullptr;
}
RefPtr<SVGMatrix> matrix =
new SVGMatrix(gfxMatrix(GetMatrix()).PreRotate(atan2(y, x)));
return matrix.forget();
return do_AddRef(
new SVGMatrix(gfxMatrix(GetMatrix()).PreRotate(atan2(y, x))));
}
already_AddRefed<SVGMatrix> SVGMatrix::FlipX() {
const gfxMatrix& mx = GetMatrix();
RefPtr<SVGMatrix> matrix = new SVGMatrix(
gfxMatrix(-mx._11, -mx._12, mx._21, mx._22, mx._31, mx._32));
return matrix.forget();
return do_AddRef(new SVGMatrix(
gfxMatrix(-mx._11, -mx._12, mx._21, mx._22, mx._31, mx._32)));
}
already_AddRefed<SVGMatrix> SVGMatrix::FlipY() {
const gfxMatrix& mx = GetMatrix();
RefPtr<SVGMatrix> matrix = new SVGMatrix(
gfxMatrix(mx._11, mx._12, -mx._21, -mx._22, mx._31, mx._32));
return matrix.forget();
return do_AddRef(new SVGMatrix(
gfxMatrix(mx._11, mx._12, -mx._21, -mx._22, mx._31, mx._32)));
}
already_AddRefed<SVGMatrix> SVGMatrix::SkewX(float angle, ErrorResult& rv) {
@ -163,8 +155,7 @@ already_AddRefed<SVGMatrix> SVGMatrix::SkewX(float angle, ErrorResult& rv) {
const gfxMatrix& mx = GetMatrix();
gfxMatrix skewMx(mx._11, mx._12, mx._21 + mx._11 * ta, mx._22 + mx._12 * ta,
mx._31, mx._32);
RefPtr<SVGMatrix> matrix = new SVGMatrix(skewMx);
return matrix.forget();
return do_AddRef(new SVGMatrix(skewMx));
}
already_AddRefed<SVGMatrix> SVGMatrix::SkewY(float angle, ErrorResult& rv) {
@ -178,8 +169,7 @@ already_AddRefed<SVGMatrix> SVGMatrix::SkewY(float angle, ErrorResult& rv) {
gfxMatrix skewMx(mx._11 + mx._21 * ta, mx._12 + mx._22 * ta, mx._21, mx._22,
mx._31, mx._32);
RefPtr<SVGMatrix> matrix = new SVGMatrix(skewMx);
return matrix.forget();
return do_AddRef(new SVGMatrix(skewMx));
}
} // namespace mozilla::dom

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

@ -75,32 +75,27 @@ uint32_t SVGPathElement::GetPathSegAtLength(float distance) {
already_AddRefed<DOMSVGPathSegClosePath>
SVGPathElement::CreateSVGPathSegClosePath() {
RefPtr<DOMSVGPathSegClosePath> pathSeg = new DOMSVGPathSegClosePath();
return pathSeg.forget();
return do_AddRef(new DOMSVGPathSegClosePath());
}
already_AddRefed<DOMSVGPathSegMovetoAbs>
SVGPathElement::CreateSVGPathSegMovetoAbs(float x, float y) {
RefPtr<DOMSVGPathSegMovetoAbs> pathSeg = new DOMSVGPathSegMovetoAbs(x, y);
return pathSeg.forget();
return do_AddRef(new DOMSVGPathSegMovetoAbs(x, y));
}
already_AddRefed<DOMSVGPathSegMovetoRel>
SVGPathElement::CreateSVGPathSegMovetoRel(float x, float y) {
RefPtr<DOMSVGPathSegMovetoRel> pathSeg = new DOMSVGPathSegMovetoRel(x, y);
return pathSeg.forget();
return do_AddRef(new DOMSVGPathSegMovetoRel(x, y));
}
already_AddRefed<DOMSVGPathSegLinetoAbs>
SVGPathElement::CreateSVGPathSegLinetoAbs(float x, float y) {
RefPtr<DOMSVGPathSegLinetoAbs> pathSeg = new DOMSVGPathSegLinetoAbs(x, y);
return pathSeg.forget();
return do_AddRef(new DOMSVGPathSegLinetoAbs(x, y));
}
already_AddRefed<DOMSVGPathSegLinetoRel>
SVGPathElement::CreateSVGPathSegLinetoRel(float x, float y) {
RefPtr<DOMSVGPathSegLinetoRel> pathSeg = new DOMSVGPathSegLinetoRel(x, y);
return pathSeg.forget();
return do_AddRef(new DOMSVGPathSegLinetoRel(x, y));
}
already_AddRefed<DOMSVGPathSegCurvetoCubicAbs>
@ -109,114 +104,88 @@ SVGPathElement::CreateSVGPathSegCurvetoCubicAbs(float x, float y, float x1,
// Note that we swap from DOM API argument order to the argument order used
// in the <path> element's 'd' attribute (i.e. we put the arguments for the
// end point of the segment last instead of first).
RefPtr<DOMSVGPathSegCurvetoCubicAbs> pathSeg =
new DOMSVGPathSegCurvetoCubicAbs(x1, y1, x2, y2, x, y);
return pathSeg.forget();
return do_AddRef(new DOMSVGPathSegCurvetoCubicAbs(x1, y1, x2, y2, x, y));
}
already_AddRefed<DOMSVGPathSegCurvetoCubicRel>
SVGPathElement::CreateSVGPathSegCurvetoCubicRel(float x, float y, float x1,
float y1, float x2, float y2) {
// See comment in CreateSVGPathSegCurvetoCubicAbs
RefPtr<DOMSVGPathSegCurvetoCubicRel> pathSeg =
new DOMSVGPathSegCurvetoCubicRel(x1, y1, x2, y2, x, y);
return pathSeg.forget();
return do_AddRef(new DOMSVGPathSegCurvetoCubicRel(x1, y1, x2, y2, x, y));
}
already_AddRefed<DOMSVGPathSegCurvetoQuadraticAbs>
SVGPathElement::CreateSVGPathSegCurvetoQuadraticAbs(float x, float y, float x1,
float y1) {
// See comment in CreateSVGPathSegCurvetoCubicAbs
RefPtr<DOMSVGPathSegCurvetoQuadraticAbs> pathSeg =
new DOMSVGPathSegCurvetoQuadraticAbs(x1, y1, x, y);
return pathSeg.forget();
return do_AddRef(new DOMSVGPathSegCurvetoQuadraticAbs(x1, y1, x, y));
}
already_AddRefed<DOMSVGPathSegCurvetoQuadraticRel>
SVGPathElement::CreateSVGPathSegCurvetoQuadraticRel(float x, float y, float x1,
float y1) {
// See comment in CreateSVGPathSegCurvetoCubicAbs
RefPtr<DOMSVGPathSegCurvetoQuadraticRel> pathSeg =
new DOMSVGPathSegCurvetoQuadraticRel(x1, y1, x, y);
return pathSeg.forget();
return do_AddRef(new DOMSVGPathSegCurvetoQuadraticRel(x1, y1, x, y));
}
already_AddRefed<DOMSVGPathSegArcAbs> SVGPathElement::CreateSVGPathSegArcAbs(
float x, float y, float r1, float r2, float angle, bool largeArcFlag,
bool sweepFlag) {
// See comment in CreateSVGPathSegCurvetoCubicAbs
RefPtr<DOMSVGPathSegArcAbs> pathSeg =
new DOMSVGPathSegArcAbs(r1, r2, angle, largeArcFlag, sweepFlag, x, y);
return pathSeg.forget();
return do_AddRef(
new DOMSVGPathSegArcAbs(r1, r2, angle, largeArcFlag, sweepFlag, x, y));
}
already_AddRefed<DOMSVGPathSegArcRel> SVGPathElement::CreateSVGPathSegArcRel(
float x, float y, float r1, float r2, float angle, bool largeArcFlag,
bool sweepFlag) {
// See comment in CreateSVGPathSegCurvetoCubicAbs
RefPtr<DOMSVGPathSegArcRel> pathSeg =
new DOMSVGPathSegArcRel(r1, r2, angle, largeArcFlag, sweepFlag, x, y);
return pathSeg.forget();
return do_AddRef(
new DOMSVGPathSegArcRel(r1, r2, angle, largeArcFlag, sweepFlag, x, y));
}
already_AddRefed<DOMSVGPathSegLinetoHorizontalAbs>
SVGPathElement::CreateSVGPathSegLinetoHorizontalAbs(float x) {
RefPtr<DOMSVGPathSegLinetoHorizontalAbs> pathSeg =
new DOMSVGPathSegLinetoHorizontalAbs(x);
return pathSeg.forget();
return do_AddRef(new DOMSVGPathSegLinetoHorizontalAbs(x));
}
already_AddRefed<DOMSVGPathSegLinetoHorizontalRel>
SVGPathElement::CreateSVGPathSegLinetoHorizontalRel(float x) {
RefPtr<DOMSVGPathSegLinetoHorizontalRel> pathSeg =
new DOMSVGPathSegLinetoHorizontalRel(x);
return pathSeg.forget();
return do_AddRef(new DOMSVGPathSegLinetoHorizontalRel(x));
}
already_AddRefed<DOMSVGPathSegLinetoVerticalAbs>
SVGPathElement::CreateSVGPathSegLinetoVerticalAbs(float y) {
RefPtr<DOMSVGPathSegLinetoVerticalAbs> pathSeg =
new DOMSVGPathSegLinetoVerticalAbs(y);
return pathSeg.forget();
return do_AddRef(new DOMSVGPathSegLinetoVerticalAbs(y));
}
already_AddRefed<DOMSVGPathSegLinetoVerticalRel>
SVGPathElement::CreateSVGPathSegLinetoVerticalRel(float y) {
RefPtr<DOMSVGPathSegLinetoVerticalRel> pathSeg =
new DOMSVGPathSegLinetoVerticalRel(y);
return pathSeg.forget();
return do_AddRef(new DOMSVGPathSegLinetoVerticalRel(y));
}
already_AddRefed<DOMSVGPathSegCurvetoCubicSmoothAbs>
SVGPathElement::CreateSVGPathSegCurvetoCubicSmoothAbs(float x, float y,
float x2, float y2) {
// See comment in CreateSVGPathSegCurvetoCubicAbs
RefPtr<DOMSVGPathSegCurvetoCubicSmoothAbs> pathSeg =
new DOMSVGPathSegCurvetoCubicSmoothAbs(x2, y2, x, y);
return pathSeg.forget();
return do_AddRef(new DOMSVGPathSegCurvetoCubicSmoothAbs(x2, y2, x, y));
}
already_AddRefed<DOMSVGPathSegCurvetoCubicSmoothRel>
SVGPathElement::CreateSVGPathSegCurvetoCubicSmoothRel(float x, float y,
float x2, float y2) {
// See comment in CreateSVGPathSegCurvetoCubicAbs
RefPtr<DOMSVGPathSegCurvetoCubicSmoothRel> pathSeg =
new DOMSVGPathSegCurvetoCubicSmoothRel(x2, y2, x, y);
return pathSeg.forget();
return do_AddRef(new DOMSVGPathSegCurvetoCubicSmoothRel(x2, y2, x, y));
}
already_AddRefed<DOMSVGPathSegCurvetoQuadraticSmoothAbs>
SVGPathElement::CreateSVGPathSegCurvetoQuadraticSmoothAbs(float x, float y) {
RefPtr<DOMSVGPathSegCurvetoQuadraticSmoothAbs> pathSeg =
new DOMSVGPathSegCurvetoQuadraticSmoothAbs(x, y);
return pathSeg.forget();
return do_AddRef(new DOMSVGPathSegCurvetoQuadraticSmoothAbs(x, y));
}
already_AddRefed<DOMSVGPathSegCurvetoQuadraticSmoothRel>
SVGPathElement::CreateSVGPathSegCurvetoQuadraticSmoothRel(float x, float y) {
RefPtr<DOMSVGPathSegCurvetoQuadraticSmoothRel> pathSeg =
new DOMSVGPathSegCurvetoQuadraticSmoothRel(x, y);
return pathSeg.forget();
return do_AddRef(new DOMSVGPathSegCurvetoQuadraticSmoothRel(x, y));
}
// FIXME: This API is enabled only if dom.svg.pathSeg.enabled is true. This

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

@ -21,17 +21,11 @@ SVGPolyElement::SVGPolyElement(
: SVGPolyElementBase(std::move(aNodeInfo)) {}
already_AddRefed<DOMSVGPointList> SVGPolyElement::Points() {
void* key = mPoints.GetBaseValKey();
RefPtr<DOMSVGPointList> points =
DOMSVGPointList::GetDOMWrapper(key, this, false);
return points.forget();
return DOMSVGPointList::GetDOMWrapper(mPoints.GetBaseValKey(), this, false);
}
already_AddRefed<DOMSVGPointList> SVGPolyElement::AnimatedPoints() {
void* key = mPoints.GetAnimValKey();
RefPtr<DOMSVGPointList> points =
DOMSVGPointList::GetDOMWrapper(key, this, true);
return points.forget();
return DOMSVGPointList::GetDOMWrapper(mPoints.GetAnimValKey(), this, true);
}
//----------------------------------------------------------------------

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

@ -481,8 +481,7 @@ already_AddRefed<gfxPattern> SVGLinearGradientFrame::CreateGradient() {
float x2 = GetLengthValue(dom::SVGLinearGradientElement::ATTR_X2);
float y2 = GetLengthValue(dom::SVGLinearGradientElement::ATTR_Y2);
RefPtr<gfxPattern> pattern = new gfxPattern(x1, y1, x2, y2);
return pattern.forget();
return do_AddRef(new gfxPattern(x1, y1, x2, y2));
}
// -------------------------------------------------------------------------
@ -591,8 +590,7 @@ already_AddRefed<gfxPattern> SVGRadialGradientFrame::CreateGradient() {
float fy = GetLengthValue(dom::SVGRadialGradientElement::ATTR_FY, cy);
float fr = GetLengthValue(dom::SVGRadialGradientElement::ATTR_FR);
RefPtr<gfxPattern> pattern = new gfxPattern(fx, fy, fr, cx, cy, r);
return pattern.forget();
return do_AddRef(new gfxPattern(fx, fy, fr, cx, cy, r));
}
} // namespace mozilla

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

@ -1189,8 +1189,7 @@ already_AddRefed<gfxDrawable> SVGIntegrationUtils::DrawableFromPaintServer(
gfxFloat scaleY = overrideBounds.Height() / aRenderSize.height;
gfxMatrix scaleMatrix = gfxMatrix::Scaling(scaleX, scaleY);
pattern->SetMatrix(scaleMatrix * pattern->GetMatrix());
RefPtr<gfxDrawable> drawable = new gfxPatternDrawable(pattern, aRenderSize);
return drawable.forget();
return do_AddRef(new gfxPatternDrawable(pattern, aRenderSize));
}
if (aFrame->IsSVGFrame() &&
@ -1205,8 +1204,7 @@ already_AddRefed<gfxDrawable> SVGIntegrationUtils::DrawableFromPaintServer(
// set up a drawing callback.
RefPtr<gfxDrawingCallback> cb =
new PaintFrameCallback(aFrame, aPaintServerSize, aRenderSize, aFlags);
RefPtr<gfxDrawable> drawable = new gfxCallbackDrawable(cb, aRenderSize);
return drawable.forget();
return do_AddRef(new gfxCallbackDrawable(cb, aRenderSize));
}
} // namespace mozilla

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

@ -3760,9 +3760,7 @@ already_AddRefed<DOMSVGPoint> SVGTextFrame::GetStartPositionOfChar(
// We need to return the start position of the whole glyph.
uint32_t startIndex = it.GlyphStartTextElementCharIndex();
RefPtr<DOMSVGPoint> point =
new DOMSVGPoint(ToPoint(mPositions[startIndex].mPosition));
return point.forget();
return do_AddRef(new DOMSVGPoint(ToPoint(mPositions[startIndex].mPosition)));
}
/**
@ -3858,8 +3856,7 @@ already_AddRefed<DOMSVGPoint> SVGTextFrame::GetEndPositionOfChar(
Matrix::Translation(ToPoint(mPositions[startIndex].mPosition));
Point p = m.TransformPoint(Point(advance / mFontSizeScaleFactor, 0));
RefPtr<DOMSVGPoint> point = new DOMSVGPoint(p);
return point.forget();
return do_AddRef(new DOMSVGPoint(p));
}
/**
@ -3927,8 +3924,7 @@ already_AddRefed<SVGRect> SVGTextFrame::GetExtentOfChar(nsIContent* aContent,
// Transform the glyph's rect into user space.
gfxRect r = m.TransformBounds(glyphRect);
RefPtr<SVGRect> rect = new SVGRect(aContent, ToRect(r));
return rect.forget();
return do_AddRef(new SVGRect(aContent, ToRect(r)));
}
/**