author | Cameron McCormack <cam@mcc.id.au> |
Fri, 12 Apr 2013 17:58:03 +1000 | |
changeset 128565 | 46c36b3006172b13250882dd255246d5db1cc2b2 |
parent 128564 | c81138a2c6adff60f2c3975d4b358de2e3f7b0ab |
child 128566 | 17f9958f5d990c65e4277899662357959164d0fe |
push id | 24532 |
push user | ryanvm@gmail.com |
push date | Fri, 12 Apr 2013 19:06:49 +0000 |
treeherder | mozilla-central@2aff2d574a1e [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | longsonr |
bugs | 860653 |
milestone | 23.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/layout/svg/nsSVGTextFrame2.cpp +++ b/layout/svg/nsSVGTextFrame2.cpp @@ -2613,19 +2613,30 @@ private: /** * Sets the gfxContext paint to the appropriate color or pattern * for filling text geometry. */ 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; nsTextFrame* mFrame; const gfxMatrix& mCanvasTM; /** * The color that we were last told from one of the path callback functions. @@ -2726,17 +2737,17 @@ SVGTextDrawPathCallbacks::NotifyBeforeSe void SVGTextDrawPathCallbacks::NotifySelectionDecorationLinePathEmitted() { if (mRenderMode != SVGAutoRenderState::NORMAL) { // Don't paint selection decorations when in a clip path. return; } - FillAndStroke(); + FillAndStrokeGeometry(); gfx->Restore(); } void SVGTextDrawPathCallbacks::FillWithOpacity() { gfx->FillWithOpacity(mColor == NS_40PERCENT_FOREGROUND_COLOR ? 0.4 : 1.0); } @@ -2773,17 +2784,17 @@ SVGTextDrawPathCallbacks::HandleTextGeom gfx->SetColor(gfxRGBA(1.0f, 1.0f, 1.0f, 1.0f)); gfx->Fill(); } } else { // Normal painting. gfxContextMatrixAutoSaveRestore saveMatrix(gfx); gfx->SetMatrix(mCanvasTM); - FillAndStroke(); + FillAndStrokeGeometry(); } } bool SVGTextDrawPathCallbacks::SetFillColor() { if (mColor == NS_SAME_AS_FOREGROUND_COLOR || mColor == NS_40PERCENT_FOREGROUND_COLOR) { @@ -2794,40 +2805,68 @@ SVGTextDrawPathCallbacks::SetFillColor() return false; } gfx->SetColor(gfxRGBA(mColor)); return true; } void -SVGTextDrawPathCallbacks::FillAndStroke() +SVGTextDrawPathCallbacks::FillAndStrokeGeometry() { bool pushedGroup = false; if (mColor == NS_40PERCENT_FOREGROUND_COLOR) { pushedGroup = true; gfx->PushGroup(gfxASurface::CONTENT_COLOR_ALPHA); } + 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; + } + paintOrder >>= NS_STYLE_PAINT_ORDER_BITWIDTH; + } + } + + if (pushedGroup) { + gfx->PopGroupToSource(); + gfx->Paint(0.4); + } +} + +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(); } } - - if (pushedGroup) { - gfx->PopGroupToSource(); - gfx->Paint(0.4); - } } // ----------------------------------------------------------------------------- // GlyphMetricsUpdater NS_IMETHODIMP GlyphMetricsUpdater::Run() {