Bug 916704 - Always initialize SVGTextContentPaint::Paint and check SetupCairoState return value in nsSVGTextFrame2::PaintSVG. r=longsonr

This commit is contained in:
Cameron McCormack 2013-09-25 17:18:41 +10:00
parent 46581519af
commit e740c96c5b
3 changed files with 18 additions and 12 deletions

View File

@ -1143,6 +1143,7 @@ mozilla::SVGTextContextPaint::Paint::GetPattern(float aOpacity,
// cache it, we'll have to compute mPatternMatrix, which is annoying.
return pattern.forget();
default:
MOZ_ASSERT(false, "invalid paint type");
return nullptr;
}

View File

@ -46,7 +46,7 @@ struct SVGTextContextPaint : public gfxTextContextPaint {
float GetStrokeOpacity() MOZ_OVERRIDE { return mStrokeOpacity; }
struct Paint {
Paint() {}
Paint() : mPaintType(eStyleSVGPaintType_None) {}
void SetPaintServer(nsIFrame *aFrame, const gfxMatrix& aContextMatrix,
nsSVGPaintServerFrame *aPaintServerFrame) {

View File

@ -3531,7 +3531,9 @@ nsSVGTextFrame2::PaintSVG(nsRenderingContext* aContext,
(gfxTextContextPaint*)aContext->GetUserData(&gfxTextContextPaint::sUserDataKey);
nsAutoPtr<gfxTextContextPaint> contextPaint;
SetupCairoState(gfx, frame, outerContextPaint, getter_Transfers(contextPaint));
gfxFont::DrawMode drawMode =
SetupCairoState(gfx, frame, outerContextPaint,
getter_Transfers(contextPaint));
// Set up the transform for painting the text frame for the substring
// indicated by the run.
@ -3540,16 +3542,19 @@ nsSVGTextFrame2::PaintSVG(nsRenderingContext* aContext,
runTransform.Multiply(currentMatrix);
gfx->SetMatrix(runTransform);
nsRect frameRect = frame->GetVisualOverflowRect();
bool paintSVGGlyphs;
if (ShouldRenderAsPath(aContext, frame, paintSVGGlyphs)) {
SVGTextDrawPathCallbacks callbacks(aContext, frame, matrixForPaintServers,
paintSVGGlyphs);
frame->PaintText(aContext, nsPoint(), frameRect, item,
contextPaint, &callbacks);
} else {
frame->PaintText(aContext, nsPoint(), frameRect, item,
contextPaint, nullptr);
if (drawMode != gfxFont::DrawMode(0)) {
nsRect frameRect = frame->GetVisualOverflowRect();
bool paintSVGGlyphs;
if (ShouldRenderAsPath(aContext, frame, paintSVGGlyphs)) {
SVGTextDrawPathCallbacks callbacks(aContext, frame,
matrixForPaintServers,
paintSVGGlyphs);
frame->PaintText(aContext, nsPoint(), frameRect, item,
contextPaint, &callbacks);
} else {
frame->PaintText(aContext, nsPoint(), frameRect, item,
contextPaint, nullptr);
}
}
if (frame == caretFrame && ShouldPaintCaret(run, caret)) {