Bug 860653 - Make paint-order work on SVG text with layout.svg.css-frames.enabled. r=longsonr

This commit is contained in:
Cameron McCormack 2013-04-12 17:58:03 +10:00
parent 0201d8265e
commit cbe40a9555

View File

@ -2618,9 +2618,20 @@ private:
bool SetFillColor();
/**
* Fills and strokes a piece of text geometry.
* Fills and strokes a piece of text geometry, using group opacity
* if the selection style requires it.
*/
void FillAndStroke();
void FillAndStrokeGeometry();
/**
* Fills a piece of text geometry.
*/
void FillGeometry();
/**
* Strokes a piece of text geometry.
*/
void StrokeGeometry();
gfxContext* gfx;
uint16_t mRenderMode;
@ -2731,7 +2742,7 @@ SVGTextDrawPathCallbacks::NotifySelectionDecorationLinePathEmitted()
return;
}
FillAndStroke();
FillAndStrokeGeometry();
gfx->Restore();
}
@ -2778,7 +2789,7 @@ SVGTextDrawPathCallbacks::HandleTextGeometry()
gfxContextMatrixAutoSaveRestore saveMatrix(gfx);
gfx->SetMatrix(mCanvasTM);
FillAndStroke();
FillAndStrokeGeometry();
}
}
@ -2799,7 +2810,7 @@ SVGTextDrawPathCallbacks::SetFillColor()
}
void
SVGTextDrawPathCallbacks::FillAndStroke()
SVGTextDrawPathCallbacks::FillAndStrokeGeometry()
{
bool pushedGroup = false;
if (mColor == NS_40PERCENT_FOREGROUND_COLOR) {
@ -2807,15 +2818,23 @@ SVGTextDrawPathCallbacks::FillAndStroke()
gfx->PushGroup(gfxASurface::CONTENT_COLOR_ALPHA);
}
if (SetFillColor()) {
gfx->Fill();
uint32_t paintOrder = mFrame->StyleSVG()->mPaintOrder;
if (paintOrder == NS_STYLE_PAINT_ORDER_NORMAL) {
FillGeometry();
StrokeGeometry();
} else {
while (paintOrder) {
uint32_t component =
paintOrder & ((1 << NS_STYLE_PAINT_ORDER_BITWIDTH) - 1);
switch (component) {
case NS_STYLE_PAINT_ORDER_FILL:
FillGeometry();
break;
case NS_STYLE_PAINT_ORDER_STROKE:
StrokeGeometry();
break;
}
if (mColor == NS_SAME_AS_FOREGROUND_COLOR ||
mColor == NS_40PERCENT_FOREGROUND_COLOR) {
// Don't paint the stroke when we are filling with a selection color.
if (nsSVGUtils::SetupCairoStroke(mFrame, gfx)) {
gfx->Stroke();
paintOrder >>= NS_STYLE_PAINT_ORDER_BITWIDTH;
}
}
@ -2825,6 +2844,26 @@ SVGTextDrawPathCallbacks::FillAndStroke()
}
}
void
SVGTextDrawPathCallbacks::FillGeometry()
{
if (SetFillColor()) {
gfx->Fill();
}
}
void
SVGTextDrawPathCallbacks::StrokeGeometry()
{
if (mColor == NS_SAME_AS_FOREGROUND_COLOR ||
mColor == NS_40PERCENT_FOREGROUND_COLOR) {
// Don't paint the stroke when we are filling with a selection color.
if (nsSVGUtils::SetupCairoStroke(mFrame, gfx)) {
gfx->Stroke();
}
}
}
// -----------------------------------------------------------------------------
// GlyphMetricsUpdater