Bug 1362417 - Pass imgDrawingParams into SVGTextDrawPathCallbacks r=jwatt

This commit is contained in:
Robert Longson 2018-03-18 20:35:13 +00:00
parent cfec2a2890
commit c0bb15d317

View File

@ -2758,18 +2758,21 @@ public:
* @param aCanvasTM The transformation matrix to set when painting; this
* should be the FOR_OUTERSVG_TM canvas TM of the text, so that
* paint servers are painted correctly.
* @param aImgParams Whether we need to synchronously decode images.
* @param aShouldPaintSVGGlyphs Whether SVG glyphs should be painted.
*/
SVGTextDrawPathCallbacks(SVGTextFrame* aSVGTextFrame,
gfxContext& aContext,
nsTextFrame* aFrame,
const gfxMatrix& aCanvasTM,
imgDrawingParams& aImgParams,
bool aShouldPaintSVGGlyphs)
: DrawPathCallbacks(aShouldPaintSVGGlyphs),
mSVGTextFrame(aSVGTextFrame),
mContext(aContext),
mFrame(aFrame),
mCanvasTM(aCanvasTM)
mCanvasTM(aCanvasTM),
mImgParams(aImgParams)
{
}
@ -2799,8 +2802,7 @@ private:
* Sets the gfxContext paint to the appropriate color or pattern
* for filling text geometry.
*/
void MakeFillPattern(GeneralPattern* aOutPattern,
imgDrawingParams& aImgParams);
void MakeFillPattern(GeneralPattern* aOutPattern);
/**
* Fills and strokes a piece of text geometry, using group opacity
@ -2822,6 +2824,7 @@ private:
gfxContext& mContext;
nsTextFrame* mFrame;
const gfxMatrix& mCanvasTM;
imgDrawingParams& mImgParams;
/**
* The color that we were last told from one of the path callback functions.
@ -2846,9 +2849,7 @@ SVGTextDrawPathCallbacks::NotifySelectionBackgroundNeedsFill(
mColor = aColor; // currently needed by MakeFillPattern
GeneralPattern fillPattern;
// XXX cku Bug 1362417 we should pass imgDrawingParams from nsTextFrame.
imgDrawingParams imgParams;
MakeFillPattern(&fillPattern, imgParams);
MakeFillPattern(&fillPattern);
if (fillPattern.GetPattern()) {
DrawOptions drawOptions(aColor == NS_40PERCENT_FOREGROUND_COLOR ? 0.4 : 1.0);
aDrawTarget.FillRect(aBackgroundRect, fillPattern, drawOptions);
@ -2945,12 +2946,11 @@ SVGTextDrawPathCallbacks::HandleTextGeometry()
}
void
SVGTextDrawPathCallbacks::MakeFillPattern(GeneralPattern* aOutPattern,
imgDrawingParams& aImgParams)
SVGTextDrawPathCallbacks::MakeFillPattern(GeneralPattern* aOutPattern)
{
if (mColor == NS_SAME_AS_FOREGROUND_COLOR ||
mColor == NS_40PERCENT_FOREGROUND_COLOR) {
nsSVGUtils::MakeFillPatternFor(mFrame, &mContext, aOutPattern, aImgParams);
nsSVGUtils::MakeFillPatternFor(mFrame, &mContext, aOutPattern, mImgParams);
return;
}
@ -2999,9 +2999,7 @@ void
SVGTextDrawPathCallbacks::FillGeometry()
{
GeneralPattern fillPattern;
// XXX cku Bug 1362417 we should pass imgDrawingParams from nsTextFrame.
imgDrawingParams imgParams;
MakeFillPattern(&fillPattern, imgParams);
MakeFillPattern(&fillPattern);
if (fillPattern.GetPattern()) {
RefPtr<Path> path = mContext.GetPath();
FillRule fillRule = nsSVGUtils::ToFillRule(IsClipPathChild() ?
@ -3023,10 +3021,8 @@ SVGTextDrawPathCallbacks::StrokeGeometry()
mColor == NS_40PERCENT_FOREGROUND_COLOR) {
if (nsSVGUtils::HasStroke(mFrame, /*aContextPaint*/ nullptr)) {
GeneralPattern strokePattern;
// XXX cku Bug 1362417 we should pass imgDrawingParams from nsTextFrame.
imgDrawingParams imgParams;
nsSVGUtils::MakeStrokePatternFor(mFrame, &mContext, &strokePattern,
imgParams, /*aContextPaint*/ nullptr);
mImgParams, /*aContextPaint*/ nullptr);
if (strokePattern.GetPattern()) {
if (!mFrame->GetParent()->GetContent()->IsSVGElement()) {
// The cast that follows would be unsafe
@ -3682,6 +3678,7 @@ SVGTextFrame::PaintSVG(gfxContext& aContext,
if (ShouldRenderAsPath(frame, paintSVGGlyphs)) {
SVGTextDrawPathCallbacks callbacks(this, aContext, frame,
matrixForPaintServers,
aImgParams,
paintSVGGlyphs);
params.callbacks = &callbacks;
frame->PaintText(params, item);