Bug 331347 - Use nsAutoArrayPtr for nsSVGCharacterPosition. r+sr=roc
This commit is contained in:
Родитель
4b4cc4665f
Коммит
f6524384f8
|
@ -40,6 +40,7 @@
|
|||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsAutoPtr.h"
|
||||
#include "nsSVGCairoGlyphGeometry.h"
|
||||
#include "nsISVGRendererGlyphGeometry.h"
|
||||
#include "nsISVGCairoCanvas.h"
|
||||
|
@ -170,9 +171,9 @@ nsSVGCairoGlyphGeometry::Render(nsISVGRendererCanvas *canvas)
|
|||
if (!text.Length())
|
||||
return NS_OK;
|
||||
|
||||
nsSVGCharacterPosition *cp;
|
||||
nsAutoArrayPtr<nsSVGCharacterPosition> cp;
|
||||
|
||||
if (NS_FAILED(mSource->GetCharacterPosition(&cp)))
|
||||
if (NS_FAILED(mSource->GetCharacterPosition(getter_Transfers(cp))))
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
cairo_t *ctx = cairoCanvas->GetContext();
|
||||
|
@ -184,10 +185,8 @@ nsSVGCairoGlyphGeometry::Render(nsISVGRendererCanvas *canvas)
|
|||
mSource->GetMetrics(getter_AddRefs(xpmetrics));
|
||||
metrics = do_QueryInterface(xpmetrics);
|
||||
NS_ASSERTION(metrics, "wrong metrics object!");
|
||||
if (!metrics) {
|
||||
delete [] cp;
|
||||
if (!metrics)
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
PRUint16 renderMode;
|
||||
|
@ -204,7 +203,6 @@ nsSVGCairoGlyphGeometry::Render(nsISVGRendererCanvas *canvas)
|
|||
if (NS_FAILED(GetGlobalTransform(ctx, cairoCanvas))) {
|
||||
if (renderMode == nsISVGRendererCanvas::SVG_RENDER_MODE_NORMAL)
|
||||
cairo_restore(ctx);
|
||||
delete [] cp;
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
|
@ -229,8 +227,6 @@ nsSVGCairoGlyphGeometry::Render(nsISVGRendererCanvas *canvas)
|
|||
|
||||
cairo_set_matrix(ctx, &matrix);
|
||||
|
||||
delete [] cp;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -260,7 +256,6 @@ nsSVGCairoGlyphGeometry::Render(nsISVGRendererCanvas *canvas)
|
|||
|
||||
if (!hasFill && !hasStroke) {
|
||||
cairo_restore(ctx);
|
||||
delete [] cp;
|
||||
return NS_OK; // nothing to paint
|
||||
}
|
||||
|
||||
|
@ -404,8 +399,6 @@ nsSVGCairoGlyphGeometry::Render(nsISVGRendererCanvas *canvas)
|
|||
}
|
||||
}
|
||||
|
||||
delete [] cp;
|
||||
|
||||
cairo_restore(ctx);
|
||||
|
||||
return NS_OK;
|
||||
|
@ -488,9 +481,9 @@ nsSVGCairoGlyphGeometry::GetCoveredRegion(nsISVGRendererRegion **_retval)
|
|||
|
||||
metrics->SelectFont(ctx);
|
||||
|
||||
nsSVGCharacterPosition *cp;
|
||||
nsAutoArrayPtr<nsSVGCharacterPosition> cp;
|
||||
|
||||
if (NS_FAILED(mSource->GetCharacterPosition(&cp))) {
|
||||
if (NS_FAILED(mSource->GetCharacterPosition(getter_Transfers(cp)))) {
|
||||
cairo_destroy(ctx);
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
@ -519,7 +512,6 @@ nsSVGCairoGlyphGeometry::GetCoveredRegion(nsISVGRendererRegion **_retval)
|
|||
double xx = x, yy = y;
|
||||
cairo_user_to_device(ctx, &xx, &yy);
|
||||
cairo_destroy(ctx);
|
||||
delete [] cp;
|
||||
return NS_NewSVGCairoRectRegion(_retval, xx, yy, 0, 0);
|
||||
}
|
||||
|
||||
|
@ -560,8 +552,6 @@ nsSVGCairoGlyphGeometry::GetCoveredRegion(nsISVGRendererRegion **_retval)
|
|||
}
|
||||
}
|
||||
|
||||
delete [] cp;
|
||||
|
||||
double xmin, ymin, xmax, ymax;
|
||||
|
||||
if (hasCoveredStroke) {
|
||||
|
@ -642,9 +632,9 @@ nsSVGCairoGlyphGeometry::ContainsPoint(float x, float y, PRBool *_retval)
|
|||
nsAutoString text;
|
||||
mSource->GetCharacterData(text);
|
||||
|
||||
nsSVGCharacterPosition *cp;
|
||||
nsAutoArrayPtr<nsSVGCharacterPosition> cp;
|
||||
|
||||
if (NS_FAILED(mSource->GetCharacterPosition(&cp))) {
|
||||
if (NS_FAILED(mSource->GetCharacterPosition(getter_Transfers(cp)))) {
|
||||
cairo_destroy(ctx);
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
@ -689,8 +679,6 @@ nsSVGCairoGlyphGeometry::ContainsPoint(float x, float y, PRBool *_retval)
|
|||
}
|
||||
}
|
||||
|
||||
delete [] cp;
|
||||
|
||||
cairo_identity_matrix(ctx);
|
||||
*_retval = cairo_in_fill(ctx, x, y);
|
||||
cairo_destroy(ctx);
|
||||
|
@ -755,9 +743,9 @@ nsSVGCairoGlyphGeometry::GetBoundingBox(nsIDOMSVGRect * *aBoundingBox)
|
|||
if (!text.Length())
|
||||
return NS_OK;
|
||||
|
||||
nsSVGCharacterPosition *cp;
|
||||
nsAutoArrayPtr<nsSVGCharacterPosition> cp;
|
||||
|
||||
if (NS_FAILED(mSource->GetCharacterPosition(&cp)))
|
||||
if (NS_FAILED(mSource->GetCharacterPosition(getter_Transfers(cp))))
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
double xmin, ymin, xmax, ymax;
|
||||
|
@ -766,7 +754,6 @@ nsSVGCairoGlyphGeometry::GetBoundingBox(nsIDOMSVGRect * *aBoundingBox)
|
|||
|
||||
if (NS_FAILED(GetGlobalTransform(ctx, nsnull))) {
|
||||
cairo_destroy(ctx);
|
||||
delete [] cp;
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
|
@ -777,10 +764,8 @@ nsSVGCairoGlyphGeometry::GetBoundingBox(nsIDOMSVGRect * *aBoundingBox)
|
|||
mSource->GetMetrics(getter_AddRefs(xpmetrics));
|
||||
metrics = do_QueryInterface(xpmetrics);
|
||||
NS_ASSERTION(metrics, "wrong metrics object!");
|
||||
if (!metrics) {
|
||||
delete [] cp;
|
||||
if (!metrics)
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
metrics->SelectFont(ctx);
|
||||
|
@ -794,8 +779,6 @@ nsSVGCairoGlyphGeometry::GetBoundingBox(nsIDOMSVGRect * *aBoundingBox)
|
|||
|
||||
LOOP_CHARS(cairo_text_path)
|
||||
|
||||
delete [] cp;
|
||||
|
||||
cairo_fill_extents(ctx, &xmin, &ymin, &xmax, &ymax);
|
||||
|
||||
cairo_user_to_device(ctx, &xmin, &ymin);
|
||||
|
|
|
@ -40,6 +40,7 @@
|
|||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsAutoPtr.h"
|
||||
#include "nsISVGGlyphMetricsSource.h"
|
||||
#include "nsPromiseFlatString.h"
|
||||
#include "nsFont.h"
|
||||
|
@ -231,23 +232,20 @@ nsSVGCairoGlyphMetrics::GetStartPositionOfChar(PRUint32 charnum, nsIDOMSVGPoint
|
|||
if (!point)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsSVGCharacterPosition *cp;
|
||||
nsAutoArrayPtr<nsSVGCharacterPosition> cp;
|
||||
|
||||
if (NS_FAILED(mSource->GetCharacterPosition(&cp)))
|
||||
if (NS_FAILED(mSource->GetCharacterPosition(getter_Transfers(cp))))
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
SelectFont(mCT);
|
||||
|
||||
if (cp) {
|
||||
if (cp[charnum].draw == PR_FALSE) {
|
||||
delete [] cp;
|
||||
if (cp[charnum].draw == PR_FALSE)
|
||||
return NS_ERROR_DOM_INDEX_SIZE_ERR;
|
||||
}
|
||||
|
||||
point->SetX(cp[charnum].x);
|
||||
point->SetY(cp[charnum].y);
|
||||
|
||||
delete [] cp;
|
||||
} else {
|
||||
if (charnum > 0) {
|
||||
cairo_text_extents_t extent;
|
||||
|
@ -287,18 +285,16 @@ nsSVGCairoGlyphMetrics::GetEndPositionOfChar(PRUint32 charnum, nsIDOMSVGPoint **
|
|||
if (!point)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsSVGCharacterPosition *cp;
|
||||
nsAutoArrayPtr<nsSVGCharacterPosition> cp;
|
||||
|
||||
if (NS_FAILED(mSource->GetCharacterPosition(&cp)))
|
||||
if (NS_FAILED(mSource->GetCharacterPosition(getter_Transfers(cp))))
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
SelectFont(mCT);
|
||||
|
||||
if (cp) {
|
||||
if (cp[charnum].draw == PR_FALSE) {
|
||||
delete [] cp;
|
||||
if (cp[charnum].draw == PR_FALSE)
|
||||
return NS_ERROR_DOM_INDEX_SIZE_ERR;
|
||||
}
|
||||
|
||||
cairo_text_extents_t extent;
|
||||
|
||||
|
@ -311,8 +307,6 @@ nsSVGCairoGlyphMetrics::GetEndPositionOfChar(PRUint32 charnum, nsIDOMSVGPoint **
|
|||
|
||||
point->SetX(cp[charnum].x + extent.x_advance * c - extent.y_advance * s);
|
||||
point->SetY(cp[charnum].y + extent.y_advance * c + extent.x_advance * s);
|
||||
|
||||
delete [] cp;
|
||||
} else {
|
||||
cairo_text_extents_t extent;
|
||||
|
||||
|
@ -346,9 +340,9 @@ nsSVGCairoGlyphMetrics::GetExtentOfChar(PRUint32 charnum, nsIDOMSVGRect **_retva
|
|||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsSVGCharacterPosition *cp;
|
||||
nsAutoArrayPtr<nsSVGCharacterPosition> cp;
|
||||
|
||||
if (NS_FAILED(mSource->GetCharacterPosition(&cp)))
|
||||
if (NS_FAILED(mSource->GetCharacterPosition(getter_Transfers(cp))))
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
SelectFont(mCT);
|
||||
|
@ -359,10 +353,8 @@ nsSVGCairoGlyphMetrics::GetExtentOfChar(PRUint32 charnum, nsIDOMSVGRect **_retva
|
|||
&extent);
|
||||
|
||||
if (cp) {
|
||||
if (cp[charnum].draw == PR_FALSE) {
|
||||
delete [] cp;
|
||||
if (cp[charnum].draw == PR_FALSE)
|
||||
return NS_ERROR_DOM_INDEX_SIZE_ERR;
|
||||
}
|
||||
|
||||
cairo_matrix_t matrix;
|
||||
cairo_get_matrix(mCT, &matrix);
|
||||
|
@ -370,8 +362,6 @@ nsSVGCairoGlyphMetrics::GetExtentOfChar(PRUint32 charnum, nsIDOMSVGRect **_retva
|
|||
cairo_move_to(mCT, cp[charnum].x, cp[charnum].y);
|
||||
cairo_rotate(mCT, cp[charnum].angle);
|
||||
|
||||
delete [] cp;
|
||||
|
||||
cairo_rel_move_to(mCT, extent.x_bearing, extent.y_bearing);
|
||||
cairo_rel_line_to(mCT, extent.width, 0);
|
||||
cairo_rel_line_to(mCT, 0, extent.height);
|
||||
|
@ -426,19 +416,16 @@ nsSVGCairoGlyphMetrics::GetRotationOfChar(PRUint32 charnum, float *_retval)
|
|||
nsAutoString text;
|
||||
mSource->GetCharacterData(text);
|
||||
|
||||
nsSVGCharacterPosition *cp;
|
||||
nsAutoArrayPtr<nsSVGCharacterPosition> cp;
|
||||
|
||||
if (NS_FAILED(mSource->GetCharacterPosition(&cp)))
|
||||
if (NS_FAILED(mSource->GetCharacterPosition(getter_Transfers(cp))))
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
if (cp) {
|
||||
if (cp[charnum].draw == PR_FALSE) {
|
||||
delete [] cp;
|
||||
if (cp[charnum].draw == PR_FALSE)
|
||||
return NS_ERROR_DOM_INDEX_SIZE_ERR;
|
||||
}
|
||||
|
||||
*_retval = cp[charnum].angle / radPerDeg;
|
||||
delete [] cp;
|
||||
} else {
|
||||
*_retval = 0.0;
|
||||
}
|
||||
|
@ -456,9 +443,9 @@ nsSVGCairoGlyphMetrics::GetCharNumAtPosition(nsIDOMSVGPoint *point, PRInt32 *_re
|
|||
nsAutoString text;
|
||||
mSource->GetCharacterData(text);
|
||||
|
||||
nsSVGCharacterPosition *cp;
|
||||
nsAutoArrayPtr<nsSVGCharacterPosition> cp;
|
||||
|
||||
if (NS_FAILED(mSource->GetCharacterPosition(&cp)))
|
||||
if (NS_FAILED(mSource->GetCharacterPosition(getter_Transfers(cp))))
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
for (PRUint32 charnum = 0; charnum < text.Length(); charnum++) {
|
||||
|
@ -504,7 +491,6 @@ nsSVGCairoGlyphMetrics::GetCharNumAtPosition(nsIDOMSVGPoint *point, PRInt32 *_re
|
|||
|
||||
cairo_set_matrix(mCT, &matrix);
|
||||
}
|
||||
delete [] cp;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче