Bug 798843 - Replace instances of 'object' with 'context' to match change in CSS values r=roc

This commit is contained in:
Edwin Flores 2013-05-16 14:35:12 +12:00
parent 9ec09b844b
commit d13a612d57
13 changed files with 275 additions and 276 deletions

View File

@ -290,11 +290,11 @@ gfxFontEntry::GetSVGGlyphExtents(gfxContext *aContext, uint32_t aGlyphId,
bool
gfxFontEntry::RenderSVGGlyph(gfxContext *aContext, uint32_t aGlyphId,
int aDrawMode, gfxTextObjectPaint *aObjectPaint)
int aDrawMode, gfxTextContextPaint *aContextPaint)
{
NS_ASSERTION(mSVGInitialized, "SVG data has not yet been loaded. TryGetSVGData() first.");
return mSVGGlyphs->RenderGlyph(aContext, aGlyphId, gfxFont::DrawMode(aDrawMode),
aObjectPaint);
aContextPaint);
}
bool
@ -2118,7 +2118,7 @@ struct GlyphBuffer {
}
void Flush(cairo_t *aCR, gfxFont::DrawMode aDrawMode, bool aReverse,
gfxTextObjectPaint *aObjectPaint,
gfxTextContextPaint *aContextPaint,
const gfxMatrix& aGlobalMatrix, bool aFinish = false) {
// Ensure there's enough room for a glyph to be added to the buffer
// and we actually have glyphs to draw
@ -2139,13 +2139,13 @@ struct GlyphBuffer {
} else {
if ((aDrawMode & (gfxFont::GLYPH_STROKE | gfxFont::GLYPH_STROKE_UNDERNEATH)) ==
(gfxFont::GLYPH_STROKE | gfxFont::GLYPH_STROKE_UNDERNEATH)) {
FlushStroke(aCR, aObjectPaint, aGlobalMatrix);
FlushStroke(aCR, aContextPaint, aGlobalMatrix);
}
if (aDrawMode & gfxFont::GLYPH_FILL) {
PROFILER_LABEL("GlyphBuffer", "cairo_show_glyphs");
nsRefPtr<gfxPattern> pattern;
if (aObjectPaint &&
!!(pattern = aObjectPaint->GetFillPattern(aGlobalMatrix))) {
if (aContextPaint &&
!!(pattern = aContextPaint->GetFillPattern(aGlobalMatrix))) {
cairo_save(aCR);
cairo_set_source(aCR, pattern->CairoPattern());
}
@ -2158,7 +2158,7 @@ struct GlyphBuffer {
}
if ((aDrawMode & (gfxFont::GLYPH_STROKE | gfxFont::GLYPH_STROKE_UNDERNEATH)) ==
gfxFont::GLYPH_STROKE) {
FlushStroke(aCR, aObjectPaint, aGlobalMatrix);
FlushStroke(aCR, aContextPaint, aGlobalMatrix);
}
}
@ -2166,11 +2166,11 @@ struct GlyphBuffer {
}
private:
void FlushStroke(cairo_t *aCR, gfxTextObjectPaint *aObjectPaint,
void FlushStroke(cairo_t *aCR, gfxTextContextPaint *aContextPaint,
const gfxMatrix& aGlobalMatrix) {
nsRefPtr<gfxPattern> pattern;
if (aObjectPaint &&
!!(pattern = aObjectPaint->GetStrokePattern(aGlobalMatrix))) {
if (aContextPaint &&
!!(pattern = aContextPaint->GetStrokePattern(aGlobalMatrix))) {
cairo_save(aCR);
cairo_set_source(aCR, pattern->CairoPattern());
}
@ -2212,7 +2212,7 @@ struct GlyphBufferAzure {
return &mGlyphBuffer[mNumGlyphs++];
}
void Flush(DrawTarget *aDT, gfxTextObjectPaint *aObjectPaint, ScaledFont *aFont,
void Flush(DrawTarget *aDT, gfxTextContextPaint *aContextPaint, ScaledFont *aFont,
gfxFont::DrawMode aDrawMode, bool aReverse, const GlyphRenderingOptions *aOptions,
gfxContext *aThebesContext, const Matrix *aInvFontMatrix, const DrawOptions &aDrawOptions,
bool aFinish = false)
@ -2235,15 +2235,15 @@ struct GlyphBufferAzure {
gfxContext::AzureState state = aThebesContext->CurrentState();
if ((aDrawMode & (gfxFont::GLYPH_STROKE | gfxFont::GLYPH_STROKE_UNDERNEATH)) ==
(gfxFont::GLYPH_STROKE | gfxFont::GLYPH_STROKE_UNDERNEATH)) {
FlushStroke(aDT, aObjectPaint, aFont, aThebesContext, buf, state);
FlushStroke(aDT, aContextPaint, aFont, aThebesContext, buf, state);
}
if (aDrawMode & gfxFont::GLYPH_FILL) {
if (state.pattern || aObjectPaint) {
if (state.pattern || aContextPaint) {
Pattern *pat;
nsRefPtr<gfxPattern> fillPattern;
if (!aObjectPaint ||
!(fillPattern = aObjectPaint->GetFillPattern(aThebesContext->CurrentMatrix()))) {
if (!aContextPaint ||
!(fillPattern = aContextPaint->GetFillPattern(aThebesContext->CurrentMatrix()))) {
if (state.pattern) {
pat = state.pattern->GetPattern(aDT, state.patternTransformChanged ? &state.patternTransform : nullptr);
} else {
@ -2300,21 +2300,21 @@ struct GlyphBufferAzure {
}
if ((aDrawMode & (gfxFont::GLYPH_STROKE | gfxFont::GLYPH_STROKE_UNDERNEATH)) ==
gfxFont::GLYPH_STROKE) {
FlushStroke(aDT, aObjectPaint, aFont, aThebesContext, buf, state);
FlushStroke(aDT, aContextPaint, aFont, aThebesContext, buf, state);
}
mNumGlyphs = 0;
}
private:
void FlushStroke(DrawTarget *aDT, gfxTextObjectPaint *aObjectPaint,
void FlushStroke(DrawTarget *aDT, gfxTextContextPaint *aContextPaint,
ScaledFont *aFont, gfxContext *aThebesContext,
gfx::GlyphBuffer& aBuf, gfxContext::AzureState& aState)
{
RefPtr<Path> path = aFont->GetPathForGlyphs(aBuf, aDT);
if (aObjectPaint) {
if (aContextPaint) {
nsRefPtr<gfxPattern> strokePattern =
aObjectPaint->GetStrokePattern(aThebesContext->CurrentMatrix());
aContextPaint->GetStrokePattern(aThebesContext->CurrentMatrix());
if (strokePattern) {
aDT->Stroke(path, *strokePattern->GetPattern(aDT), aState.strokeOptions);
}
@ -2362,7 +2362,7 @@ ForcePaintingDrawMode(gfxFont::DrawMode aDrawMode)
void
gfxFont::Draw(gfxTextRun *aTextRun, uint32_t aStart, uint32_t aEnd,
gfxContext *aContext, DrawMode aDrawMode, gfxPoint *aPt,
Spacing *aSpacing, gfxTextObjectPaint *aObjectPaint,
Spacing *aSpacing, gfxTextContextPaint *aContextPaint,
gfxTextRunDrawCallbacks *aCallbacks)
{
NS_ASSERTION(aDrawMode == gfxFont::GLYPH_PATH || !(aDrawMode & gfxFont::GLYPH_PATH),
@ -2379,14 +2379,14 @@ gfxFont::Draw(gfxTextRun *aTextRun, uint32_t aStart, uint32_t aEnd,
gfxMatrix globalMatrix = aContext->CurrentMatrix();
bool haveSVGGlyphs = GetFontEntry()->TryGetSVGData(this);
nsAutoPtr<gfxTextObjectPaint> objectPaint;
if (haveSVGGlyphs && !aObjectPaint) {
nsAutoPtr<gfxTextContextPaint> contextPaint;
if (haveSVGGlyphs && !aContextPaint) {
// If no pattern is specified for fill, use the current pattern
NS_ASSERTION((aDrawMode & GLYPH_STROKE) == 0, "no pattern supplied for stroking text");
nsRefPtr<gfxPattern> fillPattern = aContext->GetPattern();
objectPaint = new SimpleTextObjectPaint(fillPattern, nullptr,
aContext->CurrentMatrix());
aObjectPaint = objectPaint;
contextPaint = new SimpleTextContextPaint(fillPattern, nullptr,
aContext->CurrentMatrix());
aContextPaint = contextPaint;
}
// synthetic-bold strikes are each offset one device pixel in run direction
@ -2445,7 +2445,7 @@ gfxFont::Draw(gfxTextRun *aTextRun, uint32_t aStart, uint32_t aEnd,
ToDeviceUnits(y, devUnitsPerAppUnit));
gfxFont::DrawMode mode = ForcePaintingDrawMode(aDrawMode);
if (RenderSVGGlyph(aContext, point, mode,
glyphData->GetSimpleGlyph(), aObjectPaint,
glyphData->GetSimpleGlyph(), aContextPaint,
aCallbacks, emittedGlyphs)) {
continue;
}
@ -2460,7 +2460,7 @@ gfxFont::Draw(gfxTextRun *aTextRun, uint32_t aStart, uint32_t aEnd,
glyph->index = glyphData->GetSimpleGlyph();
glyph->x = ToDeviceUnits(glyphX, devUnitsPerAppUnit);
glyph->y = ToDeviceUnits(y, devUnitsPerAppUnit);
glyphs.Flush(cr, aDrawMode, isRTL, aObjectPaint, globalMatrix);
glyphs.Flush(cr, aDrawMode, isRTL, aContextPaint, globalMatrix);
// synthetic bolding by multi-striking with 1-pixel offsets
// at least once, more if there's room (large font sizes)
@ -2476,7 +2476,7 @@ gfxFont::Draw(gfxTextRun *aTextRun, uint32_t aStart, uint32_t aEnd,
devUnitsPerAppUnit);
doubleglyph->y = glyph->y;
strikeOffset += synBoldOnePixelOffset;
glyphs.Flush(cr, aDrawMode, isRTL, aObjectPaint, globalMatrix);
glyphs.Flush(cr, aDrawMode, isRTL, aContextPaint, globalMatrix);
} while (--strikeCount > 0);
}
emittedGlyphs = true;
@ -2523,7 +2523,7 @@ gfxFont::Draw(gfxTextRun *aTextRun, uint32_t aStart, uint32_t aEnd,
gfxFont::DrawMode mode = ForcePaintingDrawMode(aDrawMode);
if (RenderSVGGlyph(aContext, point, mode,
details->mGlyphID,
aObjectPaint, aCallbacks,
aContextPaint, aCallbacks,
emittedGlyphs)) {
continue;
}
@ -2533,7 +2533,7 @@ gfxFont::Draw(gfxTextRun *aTextRun, uint32_t aStart, uint32_t aEnd,
glyph->index = details->mGlyphID;
glyph->x = ToDeviceUnits(glyphX, devUnitsPerAppUnit);
glyph->y = ToDeviceUnits(y + details->mYOffset, devUnitsPerAppUnit);
glyphs.Flush(cr, aDrawMode, isRTL, aObjectPaint, globalMatrix);
glyphs.Flush(cr, aDrawMode, isRTL, aContextPaint, globalMatrix);
if (IsSyntheticBold()) {
double strikeOffset = synBoldOnePixelOffset;
@ -2548,7 +2548,7 @@ gfxFont::Draw(gfxTextRun *aTextRun, uint32_t aStart, uint32_t aEnd,
devUnitsPerAppUnit);
doubleglyph->y = glyph->y;
strikeOffset += synBoldOnePixelOffset;
glyphs.Flush(cr, aDrawMode, isRTL, aObjectPaint, globalMatrix);
glyphs.Flush(cr, aDrawMode, isRTL, aContextPaint, globalMatrix);
} while (--strikeCount > 0);
}
emittedGlyphs = true;
@ -2577,7 +2577,7 @@ gfxFont::Draw(gfxTextRun *aTextRun, uint32_t aStart, uint32_t aEnd,
}
// draw any remaining glyphs
glyphs.Flush(cr, aDrawMode, isRTL, aObjectPaint, globalMatrix, true);
glyphs.Flush(cr, aDrawMode, isRTL, aContextPaint, globalMatrix, true);
if (aCallbacks && emittedGlyphs) {
aCallbacks->NotifyGlyphPathEmitted();
}
@ -2660,7 +2660,7 @@ gfxFont::Draw(gfxTextRun *aTextRun, uint32_t aStart, uint32_t aEnd,
ToDeviceUnits(y, devUnitsPerAppUnit));
gfxFont::DrawMode mode = ForcePaintingDrawMode(aDrawMode);
if (RenderSVGGlyph(aContext, point, mode,
glyphData->GetSimpleGlyph(), aObjectPaint,
glyphData->GetSimpleGlyph(), aContextPaint,
aCallbacks, emittedGlyphs)) {
continue;
}
@ -2676,7 +2676,7 @@ gfxFont::Draw(gfxTextRun *aTextRun, uint32_t aStart, uint32_t aEnd,
glyph->mPosition.x = ToDeviceUnits(glyphX, devUnitsPerAppUnit);
glyph->mPosition.y = ToDeviceUnits(y, devUnitsPerAppUnit);
glyph->mPosition = matInv * glyph->mPosition;
glyphs.Flush(dt, aObjectPaint, scaledFont,
glyphs.Flush(dt, aContextPaint, scaledFont,
aDrawMode, isRTL, renderingOptions,
aContext, passedInvMatrix,
drawOptions);
@ -2696,7 +2696,7 @@ gfxFont::Draw(gfxTextRun *aTextRun, uint32_t aStart, uint32_t aEnd,
doubleglyph->mPosition.y = glyph->mPosition.y;
doubleglyph->mPosition = matInv * doubleglyph->mPosition;
strikeOffset += synBoldOnePixelOffset;
glyphs.Flush(dt, aObjectPaint, scaledFont,
glyphs.Flush(dt, aContextPaint, scaledFont,
aDrawMode, isRTL, renderingOptions,
aContext, passedInvMatrix,
drawOptions);
@ -2746,7 +2746,7 @@ gfxFont::Draw(gfxTextRun *aTextRun, uint32_t aStart, uint32_t aEnd,
gfxFont::DrawMode mode = ForcePaintingDrawMode(aDrawMode);
if (RenderSVGGlyph(aContext, point, mode,
details->mGlyphID,
aObjectPaint, aCallbacks,
aContextPaint, aCallbacks,
emittedGlyphs)) {
continue;
}
@ -2757,7 +2757,7 @@ gfxFont::Draw(gfxTextRun *aTextRun, uint32_t aStart, uint32_t aEnd,
glyph->mPosition.x = ToDeviceUnits(glyphX, devUnitsPerAppUnit);
glyph->mPosition.y = ToDeviceUnits(y + details->mYOffset, devUnitsPerAppUnit);
glyph->mPosition = matInv * glyph->mPosition;
glyphs.Flush(dt, aObjectPaint, scaledFont, aDrawMode,
glyphs.Flush(dt, aContextPaint, scaledFont, aDrawMode,
isRTL, renderingOptions, aContext, passedInvMatrix,
drawOptions);
@ -2775,7 +2775,7 @@ gfxFont::Draw(gfxTextRun *aTextRun, uint32_t aStart, uint32_t aEnd,
doubleglyph->mPosition.y = glyph->mPosition.y;
strikeOffset += synBoldOnePixelOffset;
doubleglyph->mPosition = matInv * doubleglyph->mPosition;
glyphs.Flush(dt, aObjectPaint, scaledFont,
glyphs.Flush(dt, aContextPaint, scaledFont,
aDrawMode, isRTL, renderingOptions,
aContext, passedInvMatrix, drawOptions);
} while (--strikeCount > 0);
@ -2795,7 +2795,7 @@ gfxFont::Draw(gfxTextRun *aTextRun, uint32_t aStart, uint32_t aEnd,
}
}
glyphs.Flush(dt, aObjectPaint, scaledFont, aDrawMode, isRTL,
glyphs.Flush(dt, aContextPaint, scaledFont, aDrawMode, isRTL,
renderingOptions, aContext, passedInvMatrix,
drawOptions, true);
if (aCallbacks && emittedGlyphs) {
@ -2812,7 +2812,7 @@ gfxFont::Draw(gfxTextRun *aTextRun, uint32_t aStart, uint32_t aEnd,
bool
gfxFont::RenderSVGGlyph(gfxContext *aContext, gfxPoint aPoint, DrawMode aDrawMode,
uint32_t aGlyphId, gfxTextObjectPaint *aObjectPaint)
uint32_t aGlyphId, gfxTextContextPaint *aContextPaint)
{
if (!GetFontEntry()->HasSVGGlyph(aGlyphId)) {
return false;
@ -2824,15 +2824,15 @@ gfxFont::RenderSVGGlyph(gfxContext *aContext, gfxPoint aPoint, DrawMode aDrawMod
aContext->Translate(gfxPoint(aPoint.x, aPoint.y));
aContext->Scale(devUnitsPerSVGUnit, devUnitsPerSVGUnit);
aObjectPaint->InitStrokeGeometry(aContext, devUnitsPerSVGUnit);
aContextPaint->InitStrokeGeometry(aContext, devUnitsPerSVGUnit);
return GetFontEntry()->RenderSVGGlyph(aContext, aGlyphId, aDrawMode,
aObjectPaint);
aContextPaint);
}
bool
gfxFont::RenderSVGGlyph(gfxContext *aContext, gfxPoint aPoint, DrawMode aDrawMode,
uint32_t aGlyphId, gfxTextObjectPaint *aObjectPaint,
uint32_t aGlyphId, gfxTextContextPaint *aContextPaint,
gfxTextRunDrawCallbacks *aCallbacks,
bool& aEmittedGlyphs)
{
@ -2844,7 +2844,7 @@ gfxFont::RenderSVGGlyph(gfxContext *aContext, gfxPoint aPoint, DrawMode aDrawMod
aCallbacks->NotifyBeforeSVGGlyphPainted();
}
bool rendered = RenderSVGGlyph(aContext, aPoint, aDrawMode, aGlyphId,
aObjectPaint);
aContextPaint);
if (aCallbacks) {
aCallbacks->NotifyAfterSVGGlyphPainted();
}
@ -5738,7 +5738,7 @@ gfxTextRun::ShrinkToLigatureBoundaries(uint32_t *aStart, uint32_t *aEnd)
void
gfxTextRun::DrawGlyphs(gfxFont *aFont, gfxContext *aContext,
gfxFont::DrawMode aDrawMode, gfxPoint *aPt,
gfxTextObjectPaint *aObjectPaint,
gfxTextContextPaint *aContextPaint,
uint32_t aStart, uint32_t aEnd,
PropertyProvider *aProvider,
uint32_t aSpacingStart, uint32_t aSpacingEnd,
@ -5748,7 +5748,7 @@ gfxTextRun::DrawGlyphs(gfxFont *aFont, gfxContext *aContext,
bool haveSpacing = GetAdjustedSpacingArray(aStart, aEnd, aProvider,
aSpacingStart, aSpacingEnd, &spacingBuffer);
aFont->Draw(this, aStart, aEnd, aContext, aDrawMode, aPt,
haveSpacing ? spacingBuffer.Elements() : nullptr, aObjectPaint,
haveSpacing ? spacingBuffer.Elements() : nullptr, aContextPaint,
aCallbacks);
}
@ -5889,7 +5889,7 @@ void
gfxTextRun::Draw(gfxContext *aContext, gfxPoint aPt, gfxFont::DrawMode aDrawMode,
uint32_t aStart, uint32_t aLength,
PropertyProvider *aProvider, gfxFloat *aAdvanceWidth,
gfxTextObjectPaint *aObjectPaint,
gfxTextContextPaint *aContextPaint,
gfxTextRunDrawCallbacks *aCallbacks)
{
NS_ASSERTION(aStart + aLength <= GetLength(), "Substring out of range");
@ -5955,7 +5955,7 @@ gfxTextRun::Draw(gfxContext *aContext, gfxPoint aPt, gfxFont::DrawMode aDrawMode
aProvider, aCallbacks);
}
DrawGlyphs(font, aContext, aDrawMode, &pt, aObjectPaint, ligatureRunStart,
DrawGlyphs(font, aContext, aDrawMode, &pt, aContextPaint, ligatureRunStart,
ligatureRunEnd, aProvider, ligatureRunStart, ligatureRunEnd,
aCallbacks);

View File

@ -49,7 +49,7 @@ class gfxUserFontData;
class gfxShapedText;
class gfxShapedWord;
class gfxSVGGlyphs;
class gfxTextObjectPaint;
class gfxTextContextPaint;
class nsILanguageAtomService;
@ -301,7 +301,7 @@ public:
bool GetSVGGlyphExtents(gfxContext *aContext, uint32_t aGlyphId,
gfxRect *aResult);
bool RenderSVGGlyph(gfxContext *aContext, uint32_t aGlyphId, int aDrawMode,
gfxTextObjectPaint *aObjectPaint);
gfxTextContextPaint *aContextPaint);
// Call this when glyph geometry or rendering has changed
// (e.g. animated SVG glyphs)
void NotifyGlyphsChanged();
@ -1512,7 +1512,7 @@ public:
* that there is no spacing.
* @param aDrawMode specifies whether the fill or stroke of the glyph should be
* drawn, or if it should be drawn into the current path
* @param aObjectPaint information about how to construct the fill and
* @param aContextPaint information about how to construct the fill and
* stroke pattern. Can be nullptr if we are not stroking the text, which
* indicates that the current source from aContext should be used for filling
*
@ -1525,7 +1525,7 @@ public:
*/
virtual void Draw(gfxTextRun *aTextRun, uint32_t aStart, uint32_t aEnd,
gfxContext *aContext, DrawMode aDrawMode, gfxPoint *aBaselineOrigin,
Spacing *aSpacing, gfxTextObjectPaint *aObjectPaint,
Spacing *aSpacing, gfxTextContextPaint *aContextPaint,
gfxTextRunDrawCallbacks *aCallbacks);
/**
@ -1962,9 +1962,9 @@ protected:
void SanitizeMetrics(gfxFont::Metrics *aMetrics, bool aIsBadUnderlineFont);
bool RenderSVGGlyph(gfxContext *aContext, gfxPoint aPoint, DrawMode aDrawMode,
uint32_t aGlyphId, gfxTextObjectPaint *aObjectPaint);
uint32_t aGlyphId, gfxTextContextPaint *aContextPaint);
bool RenderSVGGlyph(gfxContext *aContext, gfxPoint aPoint, DrawMode aDrawMode,
uint32_t aGlyphId, gfxTextObjectPaint *aObjectPaint,
uint32_t aGlyphId, gfxTextContextPaint *aContextPaint,
gfxTextRunDrawCallbacks *aCallbacks,
bool& aEmittedGlyphs);
@ -2818,7 +2818,7 @@ public:
gfxFont::DrawMode aDrawMode,
uint32_t aStart, uint32_t aLength,
PropertyProvider *aProvider,
gfxFloat *aAdvanceWidth, gfxTextObjectPaint *aObjectPaint,
gfxFloat *aAdvanceWidth, gfxTextContextPaint *aContextPaint,
gfxTextRunDrawCallbacks *aCallbacks = nullptr);
/**
@ -3245,7 +3245,7 @@ private:
// **** drawing helper ****
void DrawGlyphs(gfxFont *aFont, gfxContext *aContext,
gfxFont::DrawMode aDrawMode, gfxPoint *aPt,
gfxTextObjectPaint *aObjectPaint, uint32_t aStart,
gfxTextContextPaint *aContextPaint, uint32_t aStart,
uint32_t aEnd, PropertyProvider *aProvider,
uint32_t aSpacingStart, uint32_t aSpacingEnd,
gfxTextRunDrawCallbacks *aCallbacks);

View File

@ -42,11 +42,11 @@ using namespace mozilla;
typedef mozilla::dom::Element Element;
mozilla::gfx::UserDataKey gfxTextObjectPaint::sUserDataKey;
mozilla::gfx::UserDataKey gfxTextContextPaint::sUserDataKey;
const float gfxSVGGlyphs::SVG_UNITS_PER_EM = 1000.0f;
const gfxRGBA SimpleTextObjectPaint::sZero = gfxRGBA(0.0f, 0.0f, 0.0f, 0.0f);
const gfxRGBA SimpleTextContextPaint::sZero = gfxRGBA(0.0f, 0.0f, 0.0f, 0.0f);
gfxSVGGlyphs::gfxSVGGlyphs(hb_blob_t *aSVGTable, gfxFontEntry *aFontEntry)
: mSVGData(aSVGTable)
@ -221,7 +221,7 @@ gfxSVGGlyphsDocument::FindGlyphElements(Element *aElem)
*/
bool
gfxSVGGlyphs::RenderGlyph(gfxContext *aContext, uint32_t aGlyphId,
DrawMode aDrawMode, gfxTextObjectPaint *aObjectPaint)
DrawMode aDrawMode, gfxTextContextPaint *aContextPaint)
{
if (aDrawMode == gfxFont::GLYPH_PATH) {
return false;
@ -232,7 +232,7 @@ gfxSVGGlyphs::RenderGlyph(gfxContext *aContext, uint32_t aGlyphId,
Element *glyph = mGlyphIdMap.Get(aGlyphId);
NS_ASSERTION(glyph, "No glyph element. Should check with HasSVGGlyph() first!");
return nsSVGUtils::PaintSVGGlyph(glyph, aContext, aDrawMode, aObjectPaint);
return nsSVGUtils::PaintSVGGlyph(glyph, aContext, aDrawMode, aContextPaint);
}
bool
@ -446,8 +446,8 @@ gfxSVGGlyphsDocument::InsertGlyphId(Element *aGlyphElement)
}
void
gfxTextObjectPaint::InitStrokeGeometry(gfxContext *aContext,
float devUnitsPerSVGUnit)
gfxTextContextPaint::InitStrokeGeometry(gfxContext *aContext,
float devUnitsPerSVGUnit)
{
mStrokeWidth = aContext->CurrentLineWidth() / devUnitsPerSVGUnit;
aContext->CurrentDash(mDashes, &mDashOffset);

View File

@ -114,11 +114,11 @@ public:
/**
* Render the SVG glyph for |aGlyphId|
* @param aDrawMode Whether to fill or stroke or both; see gfxFont::DrawMode
* @param aObjectPaint Information on outer text object paints.
* See |gfxTextObjectPaint|.
* @param aContextPaint Information on text context paints.
* See |gfxTextContextPaint|.
*/
bool RenderGlyph(gfxContext *aContext, uint32_t aGlyphId, DrawMode aDrawMode,
gfxTextObjectPaint *aObjectPaint);
gfxTextContextPaint *aContextPaint);
/**
* Get the extents for the SVG glyph associated with |aGlyphId|
@ -160,18 +160,17 @@ private:
/**
* Used for trickling down paint information through to SVG glyphs.
* Will be extended in later patch.
*/
class gfxTextObjectPaint
class gfxTextContextPaint
{
protected:
gfxTextObjectPaint() { }
gfxTextContextPaint() { }
public:
static mozilla::gfx::UserDataKey sUserDataKey;
/*
* Get outer text object pattern with the specified opacity value.
* Get text context pattern with the specified opacity value.
* This lets us inherit paints and paint opacities (i.e. fill/stroke and
* fill-opacity/stroke-opacity) separately.
*/
@ -206,7 +205,7 @@ public:
return GetStrokePattern(GetStrokeOpacity(), aCTM);
}
virtual ~gfxTextObjectPaint() { }
virtual ~gfxTextContextPaint() { }
private:
FallibleTArray<gfxFloat> mDashes;
@ -215,10 +214,10 @@ private:
};
/**
* For passing in patterns where the outer text object has no separate pattern
* For passing in patterns where the text context has no separate pattern
* opacity value.
*/
class SimpleTextObjectPaint : public gfxTextObjectPaint
class SimpleTextContextPaint : public gfxTextContextPaint
{
private:
static const gfxRGBA sZero;
@ -235,7 +234,7 @@ public:
return deviceToUser * aPattern->GetMatrix();
}
SimpleTextObjectPaint(gfxPattern *aFillPattern, gfxPattern *aStrokePattern,
SimpleTextContextPaint(gfxPattern *aFillPattern, gfxPattern *aStrokePattern,
const gfxMatrix& aCTM) :
mFillPattern(aFillPattern ? aFillPattern : new gfxPattern(sZero)),
mStrokePattern(aStrokePattern ? aStrokePattern : new gfxPattern(sZero))

View File

@ -5587,7 +5587,7 @@ nsTextFrame::PaintTextWithSelection(gfxContext* aCtx,
uint32_t aContentOffset, uint32_t aContentLength,
nsTextPaintStyle& aTextPaintStyle,
const nsCharClipDisplayItem::ClipEdges& aClipEdges,
gfxTextObjectPaint* aObjectPaint,
gfxTextContextPaint* aContextPaint,
nsTextFrame::DrawPathCallbacks* aCallbacks)
{
NS_ASSERTION(GetContent()->IsSelectionDescendant(), "wrong paint path");
@ -5801,7 +5801,7 @@ void
nsTextFrame::PaintText(nsRenderingContext* aRenderingContext, nsPoint aPt,
const nsRect& aDirtyRect,
const nsCharClipDisplayItem& aItem,
gfxTextObjectPaint* aObjectPaint,
gfxTextContextPaint* aContextPaint,
nsTextFrame::DrawPathCallbacks* aCallbacks)
{
// Don't pass in aRenderingContext here, because we need a *reference*
@ -5844,7 +5844,7 @@ nsTextFrame::PaintText(nsRenderingContext* aRenderingContext, nsPoint aPt,
tmp.ConvertSkippedToOriginal(startOffset + maxLength) - contentOffset;
if (PaintTextWithSelection(ctx, framePt, textBaselinePt, dirtyRect,
provider, contentOffset, contentLength,
textPaintStyle, clipEdges, aObjectPaint,
textPaintStyle, clipEdges, aContextPaint,
aCallbacks)) {
return;
}
@ -5873,7 +5873,7 @@ nsTextFrame::PaintText(nsRenderingContext* aRenderingContext, nsPoint aPt,
DrawText(ctx, dirtyRect, framePt, textBaselinePt, startOffset, maxLength, provider,
textPaintStyle, foregroundColor, clipEdges, advanceWidth,
(GetStateBits() & TEXT_HYPHEN_BREAK) != 0,
nullptr, aObjectPaint, aCallbacks);
nullptr, aContextPaint, aCallbacks);
}
static void
@ -5884,7 +5884,7 @@ DrawTextRun(gfxTextRun* aTextRun,
PropertyProvider* aProvider,
nscolor aTextColor,
gfxFloat* aAdvanceWidth,
gfxTextObjectPaint* aObjectPaint,
gfxTextContextPaint* aContextPaint,
nsTextFrame::DrawPathCallbacks* aCallbacks)
{
gfxFont::DrawMode drawMode = aCallbacks ? gfxFont::GLYPH_PATH :
@ -5892,12 +5892,12 @@ DrawTextRun(gfxTextRun* aTextRun,
if (aCallbacks) {
aCallbacks->NotifyBeforeText(aTextColor);
aTextRun->Draw(aCtx, aTextBaselinePt, drawMode, aOffset, aLength,
aProvider, aAdvanceWidth, aObjectPaint, aCallbacks);
aProvider, aAdvanceWidth, aContextPaint, aCallbacks);
aCallbacks->NotifyAfterText();
} else {
aCtx->SetColor(gfxRGBA(aTextColor));
aTextRun->Draw(aCtx, aTextBaselinePt, drawMode, aOffset, aLength,
aProvider, aAdvanceWidth, aObjectPaint);
aProvider, aAdvanceWidth, aContextPaint);
}
}
@ -5909,11 +5909,11 @@ nsTextFrame::DrawTextRun(gfxContext* const aCtx,
nscolor aTextColor,
gfxFloat& aAdvanceWidth,
bool aDrawSoftHyphen,
gfxTextObjectPaint* aObjectPaint,
gfxTextContextPaint* aContextPaint,
nsTextFrame::DrawPathCallbacks* aCallbacks)
{
::DrawTextRun(mTextRun, aCtx, aTextBaselinePt, aOffset, aLength, &aProvider,
aTextColor, &aAdvanceWidth, aObjectPaint, aCallbacks);
aTextColor, &aAdvanceWidth, aContextPaint, aCallbacks);
if (aDrawSoftHyphen) {
// Don't use ctx as the context, because we need a reference context here,
@ -5927,7 +5927,7 @@ nsTextFrame::DrawTextRun(gfxContext* const aCtx,
::DrawTextRun(hyphenTextRun.get(), aCtx,
gfxPoint(hyphenBaselineX, aTextBaselinePt.y),
0, hyphenTextRun->GetLength(),
nullptr, aTextColor, nullptr, aObjectPaint, aCallbacks);
nullptr, aTextColor, nullptr, aContextPaint, aCallbacks);
}
}
}
@ -5945,7 +5945,7 @@ nsTextFrame::DrawTextRunAndDecorations(
bool aDrawSoftHyphen,
const TextDecorations& aDecorations,
const nscolor* const aDecorationOverrideColor,
gfxTextObjectPaint* aObjectPaint,
gfxTextContextPaint* aContextPaint,
nsTextFrame::DrawPathCallbacks* aCallbacks)
{
const gfxFloat app = aTextStyle.PresContext()->AppUnitsPerDevPixel();
@ -6010,7 +6010,7 @@ nsTextFrame::DrawTextRunAndDecorations(
// CSS 2.1 mandates that text be painted after over/underlines, and *then*
// line-throughs
DrawTextRun(aCtx, aTextBaselinePt, aOffset, aLength, aProvider, aTextColor,
aAdvanceWidth, aDrawSoftHyphen, aObjectPaint, aCallbacks);
aAdvanceWidth, aDrawSoftHyphen, aContextPaint, aCallbacks);
// Line-throughs
for (uint32_t i = aDecorations.mStrikes.Length(); i-- > 0; ) {
@ -6046,7 +6046,7 @@ nsTextFrame::DrawText(
gfxFloat& aAdvanceWidth,
bool aDrawSoftHyphen,
const nscolor* const aDecorationOverrideColor,
gfxTextObjectPaint* aObjectPaint,
gfxTextContextPaint* aContextPaint,
nsTextFrame::DrawPathCallbacks* aCallbacks)
{
TextDecorations decorations;
@ -6061,10 +6061,10 @@ nsTextFrame::DrawText(
DrawTextRunAndDecorations(aCtx, aDirtyRect, aFramePt, aTextBaselinePt, aOffset, aLength,
aProvider, aTextStyle, aTextColor, aClipEdges, aAdvanceWidth,
aDrawSoftHyphen, decorations,
aDecorationOverrideColor, aObjectPaint, aCallbacks);
aDecorationOverrideColor, aContextPaint, aCallbacks);
} else {
DrawTextRun(aCtx, aTextBaselinePt, aOffset, aLength, aProvider,
aTextColor, aAdvanceWidth, aDrawSoftHyphen, aObjectPaint, aCallbacks);
aTextColor, aAdvanceWidth, aDrawSoftHyphen, aContextPaint, aCallbacks);
}
}

View File

@ -374,7 +374,7 @@ public:
// context.
void PaintText(nsRenderingContext* aRenderingContext, nsPoint aPt,
const nsRect& aDirtyRect, const nsCharClipDisplayItem& aItem,
gfxTextObjectPaint* aObjectPaint = nullptr,
gfxTextContextPaint* aContextPaint = nullptr,
DrawPathCallbacks* aCallbacks = nullptr);
// helper: paint text frame when we're impacted by at least one selection.
// Return false if the text was not painted and we should continue with
@ -388,7 +388,7 @@ public:
uint32_t aContentLength,
nsTextPaintStyle& aTextPaintStyle,
const nsCharClipDisplayItem::ClipEdges& aClipEdges,
gfxTextObjectPaint* aObjectPaint,
gfxTextContextPaint* aContextPaint,
DrawPathCallbacks* aCallbacks);
// helper: paint text with foreground and background colors determined
// by selection(s). Also computes a mask of all selection types applying to
@ -650,7 +650,7 @@ protected:
nscolor aTextColor,
gfxFloat& aAdvanceWidth,
bool aDrawSoftHyphen,
gfxTextObjectPaint* aObjectPaint,
gfxTextContextPaint* aContextPaint,
DrawPathCallbacks* aCallbacks);
void DrawTextRunAndDecorations(gfxContext* const aCtx,
@ -667,7 +667,7 @@ protected:
bool aDrawSoftHyphen,
const TextDecorations& aDecorations,
const nscolor* const aDecorationOverrideColor,
gfxTextObjectPaint* aObjectPaint,
gfxTextContextPaint* aContextPaint,
DrawPathCallbacks* aCallbacks);
void DrawText(gfxContext* const aCtx,
@ -683,7 +683,7 @@ protected:
gfxFloat& aAdvanceWidth,
bool aDrawSoftHyphen,
const nscolor* const aDecorationOverrideColor = nullptr,
gfxTextObjectPaint* aObjectPaint = nullptr,
gfxTextContextPaint* aContextPaint = nullptr,
DrawPathCallbacks* aCallbacks = nullptr);
// Set non empty rect to aRect, it should be overflow rect or frame rect.

View File

@ -416,11 +416,11 @@ nsSVGGlyphFrame::PaintSVG(nsRenderingContext *aContext,
return NS_OK;
}
gfxTextObjectPaint *outerObjectPaint =
(gfxTextObjectPaint*)aContext->GetUserData(&gfxTextObjectPaint::sUserDataKey);
gfxTextContextPaint *outerContextPaint =
(gfxTextContextPaint*)aContext->GetUserData(&gfxTextContextPaint::sUserDataKey);
nsAutoPtr<gfxTextObjectPaint> objectPaint;
DrawMode drawMode = SetupCairoState(gfx, outerObjectPaint, getter_Transfers(objectPaint));
nsAutoPtr<gfxTextContextPaint> objectPaint;
DrawMode drawMode = SetupCairoState(gfx, outerContextPaint, getter_Transfers(objectPaint));
if (drawMode) {
DrawCharacters(&iter, gfx, drawMode, objectPaint);
@ -587,7 +587,7 @@ void
nsSVGGlyphFrame::DrawCharacters(CharacterIterator *aIter,
gfxContext *aContext,
DrawMode aDrawMode,
gfxTextObjectPaint *aObjectPaint)
gfxTextContextPaint *aContextPaint)
{
if (aDrawMode & gfxFont::GLYPH_STROKE) {
aIter->SetLineWidthAndDashesForDrawing(aContext);
@ -595,7 +595,7 @@ nsSVGGlyphFrame::DrawCharacters(CharacterIterator *aIter,
if (aIter->SetupForDirectTextRunDrawing(aContext)) {
mTextRun->Draw(aContext, gfxPoint(0, 0), aDrawMode, 0,
mTextRun->GetLength(), nullptr, nullptr, aObjectPaint);
mTextRun->GetLength(), nullptr, nullptr, aContextPaint);
return;
}
@ -603,7 +603,7 @@ nsSVGGlyphFrame::DrawCharacters(CharacterIterator *aIter,
while ((i = aIter->NextCluster()) != aIter->InvalidCluster()) {
aIter->SetupForDrawing(aContext);
mTextRun->Draw(aContext, gfxPoint(0, 0), aDrawMode, i,
aIter->ClusterLength(), nullptr, nullptr, aObjectPaint);
aIter->ClusterLength(), nullptr, nullptr, aContextPaint);
}
}
@ -929,17 +929,17 @@ nsSVGGlyphFrame::GetBaselineOffset(float aMetricsScale)
DrawMode
nsSVGGlyphFrame::SetupCairoState(gfxContext *aContext,
gfxTextObjectPaint *aOuterObjectPaint,
gfxTextObjectPaint **aThisObjectPaint)
gfxTextContextPaint *aOuterContextPaint,
gfxTextContextPaint **aThisContextPaint)
{
DrawMode toDraw = DrawMode(0);
SVGTextObjectPaint *thisObjectPaint = new SVGTextObjectPaint();
SVGTextContextPaint *thisContextPaint = new SVGTextContextPaint();
if (SetupCairoStroke(aContext, aOuterObjectPaint, thisObjectPaint)) {
if (SetupCairoStroke(aContext, aOuterContextPaint, thisContextPaint)) {
toDraw = DrawMode(toDraw | gfxFont::GLYPH_STROKE);
}
if (SetupCairoFill(aContext, aOuterObjectPaint, thisObjectPaint)) {
if (SetupCairoFill(aContext, aOuterContextPaint, thisContextPaint)) {
toDraw = DrawMode(toDraw | gfxFont::GLYPH_FILL);
}
@ -957,55 +957,55 @@ nsSVGGlyphFrame::SetupCairoState(gfxContext *aContext,
paintOrder >>= NS_STYLE_PAINT_ORDER_BITWIDTH;
}
*aThisObjectPaint = thisObjectPaint;
*aThisContextPaint = thisContextPaint;
return toDraw;
}
bool
nsSVGGlyphFrame::SetupCairoStroke(gfxContext *aContext,
gfxTextObjectPaint *aOuterObjectPaint,
SVGTextObjectPaint *aThisObjectPaint)
gfxTextContextPaint *aOuterContextPaint,
SVGTextContextPaint *aThisContextPaint)
{
if (!nsSVGUtils::HasStroke(this, aOuterObjectPaint)) {
if (!nsSVGUtils::HasStroke(this, aOuterContextPaint)) {
return false;
}
const nsStyleSVG *style = StyleSVG();
nsSVGUtils::SetupCairoStrokeGeometry(this, aContext, aOuterObjectPaint);
nsSVGUtils::SetupCairoStrokeGeometry(this, aContext, aOuterContextPaint);
float opacity = nsSVGUtils::GetOpacity(style->mStrokeOpacitySource,
style->mStrokeOpacity,
aOuterObjectPaint);
aOuterContextPaint);
SetupInheritablePaint(aContext, opacity, aOuterObjectPaint,
aThisObjectPaint->mStrokePaint, &nsStyleSVG::mStroke,
SetupInheritablePaint(aContext, opacity, aOuterContextPaint,
aThisContextPaint->mStrokePaint, &nsStyleSVG::mStroke,
nsSVGEffects::StrokeProperty());
aThisObjectPaint->SetStrokeOpacity(opacity);
aThisContextPaint->SetStrokeOpacity(opacity);
return opacity != 0.0f;
}
bool
nsSVGGlyphFrame::SetupCairoFill(gfxContext *aContext,
gfxTextObjectPaint *aOuterObjectPaint,
SVGTextObjectPaint *aThisObjectPaint)
gfxTextContextPaint *aOuterContextPaint,
SVGTextContextPaint *aThisContextPaint)
{
const nsStyleSVG *style = StyleSVG();
if (style->mFill.mType == eStyleSVGPaintType_None) {
aThisObjectPaint->SetFillOpacity(0.0f);
aThisContextPaint->SetFillOpacity(0.0f);
return false;
}
float opacity = nsSVGUtils::GetOpacity(style->mFillOpacitySource,
style->mFillOpacity,
aOuterObjectPaint);
aOuterContextPaint);
SetupInheritablePaint(aContext, opacity, aOuterObjectPaint,
aThisObjectPaint->mFillPaint, &nsStyleSVG::mFill,
SetupInheritablePaint(aContext, opacity, aOuterContextPaint,
aThisContextPaint->mFillPaint, &nsStyleSVG::mFill,
nsSVGEffects::FillProperty());
aThisObjectPaint->SetFillOpacity(opacity);
aThisContextPaint->SetFillOpacity(opacity);
return true;
}
@ -1013,8 +1013,8 @@ nsSVGGlyphFrame::SetupCairoFill(gfxContext *aContext,
void
nsSVGGlyphFrame::SetupInheritablePaint(gfxContext *aContext,
float& aOpacity,
gfxTextObjectPaint *aOuterObjectPaint,
SVGTextObjectPaint::Paint& aTargetPaint,
gfxTextContextPaint *aOuterContextPaint,
SVGTextContextPaint::Paint& aTargetPaint,
nsStyleSVGPaint nsStyleSVG::*aFillOrStroke,
const FramePropertyDescriptor *aProperty)
{
@ -1024,8 +1024,8 @@ nsSVGGlyphFrame::SetupInheritablePaint(gfxContext *aContext,
if (ps && ps->SetupPaintServer(aContext, this, aFillOrStroke, aOpacity)) {
aTargetPaint.SetPaintServer(this, aContext->CurrentMatrix(), ps);
} else if (SetupObjectPaint(aContext, aFillOrStroke, aOpacity, aOuterObjectPaint)) {
aTargetPaint.SetObjectPaint(aOuterObjectPaint, (style->*aFillOrStroke).mType);
} else if (SetupContextPaint(aContext, aFillOrStroke, aOpacity, aOuterContextPaint)) {
aTargetPaint.SetContextPaint(aOuterContextPaint, (style->*aFillOrStroke).mType);
} else {
nscolor color = nsSVGUtils::GetFallbackOrPaintColor(aContext,
StyleContext(),
@ -1043,12 +1043,12 @@ nsSVGGlyphFrame::SetupInheritablePaint(gfxContext *aContext,
}
bool
nsSVGGlyphFrame::SetupObjectPaint(gfxContext *aContext,
nsStyleSVGPaint nsStyleSVG::*aFillOrStroke,
float& aOpacity,
gfxTextObjectPaint *aOuterObjectPaint)
nsSVGGlyphFrame::SetupContextPaint(gfxContext *aContext,
nsStyleSVGPaint nsStyleSVG::*aFillOrStroke,
float& aOpacity,
gfxTextContextPaint *aOuterContextPaint)
{
if (!aOuterObjectPaint) {
if (!aOuterContextPaint) {
NS_WARNING("Outer object paint value used outside SVG glyph");
return false;
}
@ -1064,8 +1064,8 @@ nsSVGGlyphFrame::SetupObjectPaint(gfxContext *aContext,
gfxMatrix current = aContext->CurrentMatrix();
nsRefPtr<gfxPattern> pattern =
paint.mType == eStyleSVGPaintType_ObjectFill ?
aOuterObjectPaint->GetFillPattern(aOpacity, current) :
aOuterObjectPaint->GetStrokePattern(aOpacity, current);
aOuterContextPaint->GetFillPattern(aOpacity, current) :
aOuterContextPaint->GetStrokePattern(aOpacity, current);
if (!pattern) {
return false;
}
@ -1075,24 +1075,24 @@ nsSVGGlyphFrame::SetupObjectPaint(gfxContext *aContext,
}
//----------------------------------------------------------------------
// SVGTextObjectPaint methods:
// SVGTextContextPaint methods:
already_AddRefed<gfxPattern>
mozilla::SVGTextObjectPaint::GetFillPattern(float aOpacity,
mozilla::SVGTextContextPaint::GetFillPattern(float aOpacity,
const gfxMatrix& aCTM)
{
return mFillPaint.GetPattern(aOpacity, &nsStyleSVG::mFill, aCTM);
}
already_AddRefed<gfxPattern>
mozilla::SVGTextObjectPaint::GetStrokePattern(float aOpacity,
mozilla::SVGTextContextPaint::GetStrokePattern(float aOpacity,
const gfxMatrix& aCTM)
{
return mStrokePaint.GetPattern(aOpacity, &nsStyleSVG::mStroke, aCTM);
}
already_AddRefed<gfxPattern>
mozilla::SVGTextObjectPaint::Paint::GetPattern(float aOpacity,
mozilla::SVGTextContextPaint::Paint::GetPattern(float aOpacity,
nsStyleSVGPaint nsStyleSVG::*aFillOrStroke,
const gfxMatrix& aCTM)
{
@ -1133,13 +1133,13 @@ mozilla::SVGTextObjectPaint::Paint::GetPattern(float aOpacity,
pattern->SetMatrix(aCTM * mPatternMatrix);
break;
case eStyleSVGPaintType_ObjectFill:
pattern = mPaintDefinition.mObjectPaint->GetFillPattern(aOpacity, aCTM);
// Don't cache this. mObjectPaint will have cached it anyway. If we
pattern = mPaintDefinition.mContextPaint->GetFillPattern(aOpacity, aCTM);
// Don't cache this. mContextPaint will have cached it anyway. If we
// cache it, we'll have to compute mPatternMatrix, which is annoying.
return pattern.forget();
case eStyleSVGPaintType_ObjectStroke:
pattern = mPaintDefinition.mObjectPaint->GetStrokePattern(aOpacity, aCTM);
// Don't cache this. mObjectPaint will have cached it anyway. If we
pattern = mPaintDefinition.mContextPaint->GetStrokePattern(aOpacity, aCTM);
// Don't cache this. mContextPaint will have cached it anyway. If we
// cache it, we'll have to compute mPatternMatrix, which is annoying.
return pattern.forget();
default:

View File

@ -22,7 +22,7 @@ class nsRenderingContext;
class nsSVGGlyphFrame;
class nsSVGTextFrame;
class nsSVGTextPathFrame;
class gfxTextObjectPaint;
class gfxTextContextPaint;
struct CharacterPosition;
@ -33,7 +33,7 @@ class SVGIRect;
}
// Slightly horrible callback for deferring application of opacity
struct SVGTextObjectPaint : public gfxTextObjectPaint {
struct SVGTextContextPaint : public gfxTextContextPaint {
already_AddRefed<gfxPattern> GetFillPattern(float aOpacity,
const gfxMatrix& aCTM) MOZ_OVERRIDE;
already_AddRefed<gfxPattern> GetStrokePattern(float aOpacity,
@ -61,18 +61,18 @@ struct SVGTextObjectPaint : public gfxTextObjectPaint {
mPaintDefinition.mColor = aColor;
}
void SetObjectPaint(gfxTextObjectPaint *aObjectPaint,
nsStyleSVGPaintType aPaintType) {
void SetContextPaint(gfxTextContextPaint *aContextPaint,
nsStyleSVGPaintType aPaintType) {
NS_ASSERTION(aPaintType == eStyleSVGPaintType_ObjectFill ||
aPaintType == eStyleSVGPaintType_ObjectStroke,
"Invalid object paint type");
"Invalid context paint type");
mPaintType = aPaintType;
mPaintDefinition.mObjectPaint = aObjectPaint;
mPaintDefinition.mContextPaint = aContextPaint;
}
union {
nsSVGPaintServerFrame *mPaintServerFrame;
gfxTextObjectPaint *mObjectPaint;
gfxTextContextPaint *mContextPaint;
nscolor mColor;
} mPaintDefinition;
@ -312,7 +312,7 @@ private:
void DrawCharacters(CharacterIterator *aIter,
gfxContext *aContext,
DrawMode aDrawMode,
gfxTextObjectPaint *aObjectPaint = nullptr);
gfxTextContextPaint *aContextPaint = nullptr);
void NotifyGlyphMetricsChange();
void SetupGlobalTransform(gfxContext *aContext, uint32_t aFor,
@ -340,40 +340,40 @@ private:
private:
DrawMode SetupCairoState(gfxContext *aContext,
gfxTextObjectPaint *aOuterObjectPaint,
gfxTextObjectPaint **aThisObjectPaint);
gfxTextContextPaint *aOuterContextPaint,
gfxTextContextPaint **aThisContextPaint);
/**
* Sets up the stroke style in |aContext| and stores stroke pattern
* information in |aThisObjectPaint|.
* information in |aThisContextPaint|.
*/
bool SetupCairoStroke(gfxContext *aContext,
gfxTextObjectPaint *aOuterObjectPaint,
SVGTextObjectPaint *aThisObjectPaint);
gfxTextContextPaint *aOuterContextPaint,
SVGTextContextPaint *aThisContextPaint);
/**
* Sets up the fill style in |aContext| and stores fill pattern information
* in |aThisObjectPaint|.
* in |aThisContextPaint|.
*/
bool SetupCairoFill(gfxContext *aContext,
gfxTextObjectPaint *aOuterObjectPaint,
SVGTextObjectPaint *aThisObjectPaint);
gfxTextContextPaint *aOuterContextPaint,
SVGTextContextPaint *aThisContextPaint);
/**
* Sets the current pattern to the fill or stroke style of the outer text
* object. Will also set the paint opacity to transparent if the paint is set
* context. Will also set the paint opacity to transparent if the paint is set
* to "none".
*/
bool SetupObjectPaint(gfxContext *aContext,
bool SetupContextPaint(gfxContext *aContext,
nsStyleSVGPaint nsStyleSVG::*aFillOrStroke,
float& aOpacity,
gfxTextObjectPaint *aObjectPaint);
gfxTextContextPaint *aContextPaint);
/**
* Stores in |aTargetPaint| information on how to reconstruct the current
* fill or stroke pattern. Will also set the paint opacity to transparent if
* the paint is set to "none".
* @param aOuterObjectPaint pattern information from the outer text object
* @param aOuterContextPaint pattern information from the outer text context
* @param aTargetPaint where to store the current pattern information
* @param aFillOrStroke member pointer to the paint we are setting up
* @param aProperty the frame property descriptor of the fill or stroke paint
@ -381,8 +381,8 @@ private:
*/
void SetupInheritablePaint(gfxContext *aContext,
float& aOpacity,
gfxTextObjectPaint *aOuterObjectPaint,
SVGTextObjectPaint::Paint& aTargetPaint,
gfxTextContextPaint *aOuterContextPaint,
SVGTextContextPaint::Paint& aTargetPaint,
nsStyleSVGPaint nsStyleSVG::*aFillOrStroke,
const FramePropertyDescriptor *aProperty);

View File

@ -610,16 +610,16 @@ nsSVGPathGeometryFrame::Render(nsRenderingContext *aContext,
return;
}
gfxTextObjectPaint *objectPaint =
(gfxTextObjectPaint*)aContext->GetUserData(&gfxTextObjectPaint::sUserDataKey);
gfxTextContextPaint *contextPaint =
(gfxTextContextPaint*)aContext->GetUserData(&gfxTextContextPaint::sUserDataKey);
if ((aRenderComponents & eRenderFill) &&
nsSVGUtils::SetupCairoFillPaint(this, gfx, objectPaint)) {
nsSVGUtils::SetupCairoFillPaint(this, gfx, contextPaint)) {
gfx->Fill();
}
if ((aRenderComponents & eRenderStroke) &&
nsSVGUtils::SetupCairoStroke(this, gfx, objectPaint)) {
nsSVGUtils::SetupCairoStroke(this, gfx, contextPaint)) {
gfx->Stroke();
}
@ -653,14 +653,14 @@ nsSVGPathGeometryFrame::GeneratePath(gfxContext* aContext,
void
nsSVGPathGeometryFrame::PaintMarkers(nsRenderingContext* aContext)
{
gfxTextObjectPaint *objectPaint =
(gfxTextObjectPaint*)aContext->GetUserData(&gfxTextObjectPaint::sUserDataKey);
gfxTextContextPaint *contextPaint =
(gfxTextContextPaint*)aContext->GetUserData(&gfxTextContextPaint::sUserDataKey);
if (static_cast<nsSVGPathGeometryElement*>(mContent)->IsMarkable()) {
MarkerProperties properties = GetMarkerProperties(this);
if (properties.MarkersExist()) {
float strokeWidth = nsSVGUtils::GetStrokeWidth(this, objectPaint);
float strokeWidth = nsSVGUtils::GetStrokeWidth(this, contextPaint);
nsTArray<nsSVGMark> marks;
static_cast<nsSVGPathGeometryElement*>

View File

@ -3527,11 +3527,11 @@ nsSVGTextFrame2::PaintSVG(nsRenderingContext* aContext,
// Set up the fill and stroke so that SVG glyphs can get painted correctly
// when they use -moz-objectFill values etc.
gfx->SetMatrix(initialMatrix);
gfxTextObjectPaint *outerObjectPaint =
(gfxTextObjectPaint*)aContext->GetUserData(&gfxTextObjectPaint::sUserDataKey);
gfxTextContextPaint *outerContextPaint =
(gfxTextContextPaint*)aContext->GetUserData(&gfxTextContextPaint::sUserDataKey);
nsAutoPtr<gfxTextObjectPaint> objectPaint;
SetupCairoState(gfx, frame, outerObjectPaint, getter_Transfers(objectPaint));
nsAutoPtr<gfxTextContextPaint> contextPaint;
SetupCairoState(gfx, frame, outerContextPaint, getter_Transfers(contextPaint));
// Set up the transform for painting the text frame for the substring
// indicated by the run.
@ -3546,10 +3546,10 @@ nsSVGTextFrame2::PaintSVG(nsRenderingContext* aContext,
SVGTextDrawPathCallbacks callbacks(aContext, frame, matrixForPaintServers,
paintSVGGlyphs);
frame->PaintText(aContext, nsPoint(), frameRect, item,
objectPaint, &callbacks);
contextPaint, &callbacks);
} else {
frame->PaintText(aContext, nsPoint(), frameRect, item,
objectPaint, nullptr);
contextPaint, nullptr);
}
if (frame == caretFrame && ShouldPaintCaret(run, caret)) {
@ -5389,21 +5389,21 @@ nsSVGTextFrame2::TransformFrameRectFromTextChild(const nsRect& aRect,
gfxFont::DrawMode
nsSVGTextFrame2::SetupCairoState(gfxContext* aContext,
nsIFrame* aFrame,
gfxTextObjectPaint* aOuterObjectPaint,
gfxTextObjectPaint** aThisObjectPaint)
gfxTextContextPaint* aOuterContextPaint,
gfxTextContextPaint** aThisContextPaint)
{
gfxFont::DrawMode toDraw = gfxFont::DrawMode(0);
SVGTextObjectPaint *thisObjectPaint = new SVGTextObjectPaint();
SVGTextContextPaint *thisContextPaint = new SVGTextContextPaint();
if (SetupCairoStroke(aContext, aFrame, aOuterObjectPaint, thisObjectPaint)) {
if (SetupCairoStroke(aContext, aFrame, aOuterContextPaint, thisContextPaint)) {
toDraw = gfxFont::DrawMode(toDraw | gfxFont::GLYPH_STROKE);
}
if (SetupCairoFill(aContext, aFrame, aOuterObjectPaint, thisObjectPaint)) {
if (SetupCairoFill(aContext, aFrame, aOuterContextPaint, thisContextPaint)) {
toDraw = gfxFont::DrawMode(toDraw | gfxFont::GLYPH_FILL);
}
*aThisObjectPaint = thisObjectPaint;
*aThisContextPaint = thisContextPaint;
return toDraw;
}
@ -5411,25 +5411,25 @@ nsSVGTextFrame2::SetupCairoState(gfxContext* aContext,
bool
nsSVGTextFrame2::SetupCairoStroke(gfxContext* aContext,
nsIFrame* aFrame,
gfxTextObjectPaint* aOuterObjectPaint,
SVGTextObjectPaint* aThisObjectPaint)
gfxTextContextPaint* aOuterContextPaint,
SVGTextContextPaint* aThisContextPaint)
{
const nsStyleSVG *style = aFrame->StyleSVG();
if (style->mStroke.mType == eStyleSVGPaintType_None) {
aThisObjectPaint->SetStrokeOpacity(0.0f);
aThisContextPaint->SetStrokeOpacity(0.0f);
return false;
}
nsSVGUtils::SetupCairoStrokeGeometry(aFrame, aContext, aOuterObjectPaint);
nsSVGUtils::SetupCairoStrokeGeometry(aFrame, aContext, aOuterContextPaint);
float opacity = nsSVGUtils::GetOpacity(style->mStrokeOpacitySource,
style->mStrokeOpacity,
aOuterObjectPaint);
aOuterContextPaint);
SetupInheritablePaint(aContext, aFrame, opacity, aOuterObjectPaint,
aThisObjectPaint->mStrokePaint, &nsStyleSVG::mStroke,
SetupInheritablePaint(aContext, aFrame, opacity, aOuterContextPaint,
aThisContextPaint->mStrokePaint, &nsStyleSVG::mStroke,
nsSVGEffects::StrokeProperty());
aThisObjectPaint->SetStrokeOpacity(opacity);
aThisContextPaint->SetStrokeOpacity(opacity);
return opacity != 0.0f;
}
@ -5437,24 +5437,24 @@ nsSVGTextFrame2::SetupCairoStroke(gfxContext* aContext,
bool
nsSVGTextFrame2::SetupCairoFill(gfxContext* aContext,
nsIFrame* aFrame,
gfxTextObjectPaint* aOuterObjectPaint,
SVGTextObjectPaint* aThisObjectPaint)
gfxTextContextPaint* aOuterContextPaint,
SVGTextContextPaint* aThisContextPaint)
{
const nsStyleSVG *style = aFrame->StyleSVG();
if (style->mFill.mType == eStyleSVGPaintType_None) {
aThisObjectPaint->SetFillOpacity(0.0f);
aThisContextPaint->SetFillOpacity(0.0f);
return false;
}
float opacity = nsSVGUtils::GetOpacity(style->mFillOpacitySource,
style->mFillOpacity,
aOuterObjectPaint);
aOuterContextPaint);
SetupInheritablePaint(aContext, aFrame, opacity, aOuterObjectPaint,
aThisObjectPaint->mFillPaint, &nsStyleSVG::mFill,
SetupInheritablePaint(aContext, aFrame, opacity, aOuterContextPaint,
aThisContextPaint->mFillPaint, &nsStyleSVG::mFill,
nsSVGEffects::FillProperty());
aThisObjectPaint->SetFillOpacity(opacity);
aThisContextPaint->SetFillOpacity(opacity);
return true;
}
@ -5463,8 +5463,8 @@ void
nsSVGTextFrame2::SetupInheritablePaint(gfxContext* aContext,
nsIFrame* aFrame,
float& aOpacity,
gfxTextObjectPaint* aOuterObjectPaint,
SVGTextObjectPaint::Paint& aTargetPaint,
gfxTextContextPaint* aOuterContextPaint,
SVGTextContextPaint::Paint& aTargetPaint,
nsStyleSVGPaint nsStyleSVG::*aFillOrStroke,
const FramePropertyDescriptor* aProperty)
{
@ -5474,8 +5474,8 @@ nsSVGTextFrame2::SetupInheritablePaint(gfxContext* aContext,
if (ps && ps->SetupPaintServer(aContext, aFrame, aFillOrStroke, aOpacity)) {
aTargetPaint.SetPaintServer(aFrame, aContext->CurrentMatrix(), ps);
} else if (SetupObjectPaint(aContext, aFrame, aFillOrStroke, aOpacity, aOuterObjectPaint)) {
aTargetPaint.SetObjectPaint(aOuterObjectPaint, (style->*aFillOrStroke).mType);
} else if (SetupContextPaint(aContext, aFrame, aFillOrStroke, aOpacity, aOuterContextPaint)) {
aTargetPaint.SetContextPaint(aOuterContextPaint, (style->*aFillOrStroke).mType);
} else {
nscolor color = nsSVGUtils::GetFallbackOrPaintColor(aContext,
aFrame->StyleContext(),
@ -5492,13 +5492,13 @@ nsSVGTextFrame2::SetupInheritablePaint(gfxContext* aContext,
}
bool
nsSVGTextFrame2::SetupObjectPaint(gfxContext* aContext,
nsIFrame* aFrame,
nsStyleSVGPaint nsStyleSVG::*aFillOrStroke,
float& aOpacity,
gfxTextObjectPaint* aOuterObjectPaint)
nsSVGTextFrame2::SetupContextPaint(gfxContext* aContext,
nsIFrame* aFrame,
nsStyleSVGPaint nsStyleSVG::*aFillOrStroke,
float& aOpacity,
gfxTextContextPaint* aOuterContextPaint)
{
if (!aOuterObjectPaint) {
if (!aOuterContextPaint) {
return false;
}
@ -5513,8 +5513,8 @@ nsSVGTextFrame2::SetupObjectPaint(gfxContext* aContext,
gfxMatrix current = aContext->CurrentMatrix();
nsRefPtr<gfxPattern> pattern =
paint.mType == eStyleSVGPaintType_ObjectFill ?
aOuterObjectPaint->GetFillPattern(aOpacity, current) :
aOuterObjectPaint->GetStrokePattern(aOpacity, current);
aOuterContextPaint->GetFillPattern(aOpacity, current) :
aOuterContextPaint->GetStrokePattern(aOpacity, current);
if (!pattern) {
return false;
}

View File

@ -12,7 +12,7 @@
#include "gfxRect.h"
#include "gfxSVGGlyphs.h"
#include "nsStubMutationObserver.h"
#include "nsSVGGlyphFrame.h" // for SVGTextObjectPaint
#include "nsSVGGlyphFrame.h" // for SVGTextContextPaint
#include "nsSVGTextContainerFrame.h"
class nsDisplaySVGText;
@ -523,43 +523,43 @@ private:
gfxFont::DrawMode SetupCairoState(gfxContext* aContext,
nsIFrame* aFrame,
gfxTextObjectPaint* aOuterObjectPaint,
gfxTextObjectPaint** aThisObjectPaint);
gfxTextContextPaint* aOuterContextPaint,
gfxTextContextPaint** aThisContextPaint);
/**
* Sets up the stroke style for |aFrame| in |aContext| and stores stroke
* pattern information in |aThisObjectPaint|.
* pattern information in |aThisContextPaint|.
*/
bool SetupCairoStroke(gfxContext* aContext,
nsIFrame* aFrame,
gfxTextObjectPaint* aOuterObjectPaint,
SVGTextObjectPaint* aThisObjectPaint);
gfxTextContextPaint* aOuterContextPaint,
SVGTextContextPaint* aThisContextPaint);
/**
* Sets up the fill style for |aFrame| in |aContext| and stores fill pattern
* information in |aThisObjectPaint|.
* information in |aThisContextPaint|.
*/
bool SetupCairoFill(gfxContext* aContext,
nsIFrame* aFrame,
gfxTextObjectPaint* aOuterObjectPaint,
SVGTextObjectPaint* aThisObjectPaint);
gfxTextContextPaint* aOuterContextPaint,
SVGTextContextPaint* aThisContextPaint);
/**
* Sets the current pattern for |aFrame| to the fill or stroke style of the
* outer text object. Will also set the paint opacity to transparent if the
* outer text context. Will also set the paint opacity to transparent if the
* paint is set to "none".
*/
bool SetupObjectPaint(gfxContext* aContext,
bool SetupContextPaint(gfxContext* aContext,
nsIFrame* aFrame,
nsStyleSVGPaint nsStyleSVG::*aFillOrStroke,
float& aOpacity,
gfxTextObjectPaint* aObjectPaint);
gfxTextContextPaint* aContextPaint);
/**
* Stores in |aTargetPaint| information on how to reconstruct the current
* fill or stroke pattern. Will also set the paint opacity to transparent if
* the paint is set to "none".
* @param aOuterObjectPaint pattern information from the outer text object
* @param aOuterContextPaint pattern information from the outer text context
* @param aTargetPaint where to store the current pattern information
* @param aFillOrStroke member pointer to the paint we are setting up
* @param aProperty the frame property descriptor of the fill or stroke paint
@ -568,8 +568,8 @@ private:
void SetupInheritablePaint(gfxContext* aContext,
nsIFrame* aFrame,
float& aOpacity,
gfxTextObjectPaint* aOuterObjectPaint,
SVGTextObjectPaint::Paint& aTargetPaint,
gfxTextContextPaint* aOuterContextPaint,
SVGTextContextPaint::Paint& aTargetPaint,
nsStyleSVGPaint nsStyleSVG::*aFillOrStroke,
const FramePropertyDescriptor* aProperty);

View File

@ -1484,23 +1484,23 @@ MaybeOptimizeOpacity(nsIFrame *aFrame, float aFillOrStrokeOpacity)
}
/* static */ bool
nsSVGUtils::SetupObjectPaint(gfxContext *aContext,
gfxTextObjectPaint *aObjectPaint,
const nsStyleSVGPaint &aPaint,
float aOpacity)
nsSVGUtils::SetupContextPaint(gfxContext *aContext,
gfxTextContextPaint *aContextPaint,
const nsStyleSVGPaint &aPaint,
float aOpacity)
{
nsRefPtr<gfxPattern> pattern;
if (!aObjectPaint) {
if (!aContextPaint) {
return false;
}
switch (aPaint.mType) {
case eStyleSVGPaintType_ObjectFill:
pattern = aObjectPaint->GetFillPattern(aOpacity, aContext->CurrentMatrix());
pattern = aContextPaint->GetFillPattern(aOpacity, aContext->CurrentMatrix());
break;
case eStyleSVGPaintType_ObjectStroke:
pattern = aObjectPaint->GetStrokePattern(aOpacity, aContext->CurrentMatrix());
pattern = aContextPaint->GetStrokePattern(aOpacity, aContext->CurrentMatrix());
break;
default:
return false;
@ -1517,7 +1517,7 @@ nsSVGUtils::SetupObjectPaint(gfxContext *aContext,
bool
nsSVGUtils::SetupCairoFillPaint(nsIFrame *aFrame, gfxContext* aContext,
gfxTextObjectPaint *aObjectPaint)
gfxTextContextPaint *aContextPaint)
{
const nsStyleSVG* style = aFrame->StyleSVG();
if (style->mFill.mType == eStyleSVGPaintType_None)
@ -1531,13 +1531,13 @@ nsSVGUtils::SetupCairoFillPaint(nsIFrame *aFrame, gfxContext* aContext,
float opacity = MaybeOptimizeOpacity(aFrame,
GetOpacity(style->mFillOpacitySource,
style->mFillOpacity,
aObjectPaint));
aContextPaint));
nsSVGPaintServerFrame *ps =
nsSVGEffects::GetPaintServer(aFrame, &style->mFill, nsSVGEffects::FillProperty());
if (ps && ps->SetupPaintServer(aContext, aFrame, &nsStyleSVG::mFill, opacity))
return true;
if (SetupObjectPaint(aContext, aObjectPaint, style->mFill, opacity)) {
if (SetupContextPaint(aContext, aContextPaint, style->mFill, opacity)) {
return true;
}
@ -1552,7 +1552,7 @@ nsSVGUtils::SetupCairoFillPaint(nsIFrame *aFrame, gfxContext* aContext,
bool
nsSVGUtils::SetupCairoStrokePaint(nsIFrame *aFrame, gfxContext* aContext,
gfxTextObjectPaint *aObjectPaint)
gfxTextContextPaint *aContextPaint)
{
const nsStyleSVG* style = aFrame->StyleSVG();
if (style->mStroke.mType == eStyleSVGPaintType_None)
@ -1561,14 +1561,14 @@ nsSVGUtils::SetupCairoStrokePaint(nsIFrame *aFrame, gfxContext* aContext,
float opacity = MaybeOptimizeOpacity(aFrame,
GetOpacity(style->mStrokeOpacitySource,
style->mStrokeOpacity,
aObjectPaint));
aContextPaint));
nsSVGPaintServerFrame *ps =
nsSVGEffects::GetPaintServer(aFrame, &style->mStroke, nsSVGEffects::StrokeProperty());
if (ps && ps->SetupPaintServer(aContext, aFrame, &nsStyleSVG::mStroke, opacity))
return true;
if (SetupObjectPaint(aContext, aObjectPaint, style->mStroke, opacity)) {
if (SetupContextPaint(aContext, aContextPaint, style->mStroke, opacity)) {
return true;
}
@ -1584,7 +1584,7 @@ nsSVGUtils::SetupCairoStrokePaint(nsIFrame *aFrame, gfxContext* aContext,
/* static */ float
nsSVGUtils::GetOpacity(nsStyleSVGOpacitySource aOpacityType,
const float& aOpacity,
gfxTextObjectPaint *aOuterObjectPaint)
gfxTextContextPaint *aOuterContextPaint)
{
float opacity = 1.0f;
switch (aOpacityType) {
@ -1592,15 +1592,15 @@ nsSVGUtils::GetOpacity(nsStyleSVGOpacitySource aOpacityType,
opacity = aOpacity;
break;
case eStyleSVGOpacitySource_ObjectFillOpacity:
if (aOuterObjectPaint) {
opacity = aOuterObjectPaint->GetFillOpacity();
if (aOuterContextPaint) {
opacity = aOuterContextPaint->GetFillOpacity();
} else {
NS_WARNING("objectFillOpacity used outside of an SVG glyph");
}
break;
case eStyleSVGOpacitySource_ObjectStrokeOpacity:
if (aOuterObjectPaint) {
opacity = aOuterObjectPaint->GetStrokeOpacity();
if (aOuterContextPaint) {
opacity = aOuterContextPaint->GetStrokeOpacity();
} else {
NS_WARNING("objectStrokeOpacity used outside of an SVG glyph");
}
@ -1612,20 +1612,20 @@ nsSVGUtils::GetOpacity(nsStyleSVGOpacitySource aOpacityType,
}
bool
nsSVGUtils::HasStroke(nsIFrame* aFrame, gfxTextObjectPaint *aObjectPaint)
nsSVGUtils::HasStroke(nsIFrame* aFrame, gfxTextContextPaint *aContextPaint)
{
const nsStyleSVG *style = aFrame->StyleSVG();
return style->mStroke.mType != eStyleSVGPaintType_None &&
style->mStrokeOpacity > 0 &&
GetStrokeWidth(aFrame, aObjectPaint) > 0;
GetStrokeWidth(aFrame, aContextPaint) > 0;
}
float
nsSVGUtils::GetStrokeWidth(nsIFrame* aFrame, gfxTextObjectPaint *aObjectPaint)
nsSVGUtils::GetStrokeWidth(nsIFrame* aFrame, gfxTextContextPaint *aContextPaint)
{
const nsStyleSVG *style = aFrame->StyleSVG();
if (aObjectPaint && style->mStrokeWidthFromObject) {
return aObjectPaint->GetStrokeWidth();
if (aContextPaint && style->mStrokeWidthFromObject) {
return aContextPaint->GetStrokeWidth();
}
nsIContent* content = aFrame->GetContent();
@ -1642,9 +1642,9 @@ nsSVGUtils::GetStrokeWidth(nsIFrame* aFrame, gfxTextObjectPaint *aObjectPaint)
void
nsSVGUtils::SetupCairoStrokeBBoxGeometry(nsIFrame* aFrame,
gfxContext *aContext,
gfxTextObjectPaint *aObjectPaint)
gfxTextContextPaint *aContextPaint)
{
float width = GetStrokeWidth(aFrame, aObjectPaint);
float width = GetStrokeWidth(aFrame, aContextPaint);
if (width <= 0)
return;
aContext->SetLineWidth(width);
@ -1685,7 +1685,7 @@ static bool
GetStrokeDashData(nsIFrame* aFrame,
FallibleTArray<gfxFloat>& aDashes,
gfxFloat* aDashOffset,
gfxTextObjectPaint *aObjectPaint)
gfxTextContextPaint *aContextPaint)
{
const nsStyleSVG* style = aFrame->StyleSVG();
nsPresContext *presContext = aFrame->PresContext();
@ -1695,8 +1695,8 @@ GetStrokeDashData(nsIFrame* aFrame,
content->GetParent() : content);
gfxFloat totalLength = 0.0;
if (aObjectPaint && style->mStrokeDasharrayFromObject) {
aDashes = aObjectPaint->GetStrokeDashArray();
if (aContextPaint && style->mStrokeDasharrayFromObject) {
aDashes = aContextPaint->GetStrokeDashArray();
for (uint32_t i = 0; i < aDashes.Length(); i++) {
if (aDashes[i] < 0.0) {
@ -1734,8 +1734,8 @@ GetStrokeDashData(nsIFrame* aFrame,
}
}
if (aObjectPaint && style->mStrokeDashoffsetFromObject) {
*aDashOffset = aObjectPaint->GetStrokeDashOffset();
if (aContextPaint && style->mStrokeDashoffsetFromObject) {
*aDashOffset = aContextPaint->GetStrokeDashOffset();
} else {
*aDashOffset = nsSVGUtils::CoordToFloat(presContext,
ctx,
@ -1747,13 +1747,13 @@ GetStrokeDashData(nsIFrame* aFrame,
void
nsSVGUtils::SetupCairoStrokeGeometry(nsIFrame* aFrame, gfxContext* aContext,
gfxTextObjectPaint *aObjectPaint)
gfxTextContextPaint *aContextPaint)
{
SetupCairoStrokeBBoxGeometry(aFrame, aContext, aObjectPaint);
SetupCairoStrokeBBoxGeometry(aFrame, aContext, aContextPaint);
AutoFallibleTArray<gfxFloat, 10> dashes;
gfxFloat dashOffset;
if (GetStrokeDashData(aFrame, dashes, &dashOffset, aObjectPaint)) {
if (GetStrokeDashData(aFrame, dashes, &dashOffset, aContextPaint)) {
aContext->SetDash(dashes.Elements(), dashes.Length(), dashOffset);
}
}
@ -1819,20 +1819,20 @@ nsSVGUtils::GetGeometryHitTestFlags(nsIFrame* aFrame)
bool
nsSVGUtils::SetupCairoStroke(nsIFrame* aFrame, gfxContext* aContext,
gfxTextObjectPaint *aObjectPaint)
gfxTextContextPaint *aContextPaint)
{
if (!HasStroke(aFrame, aObjectPaint)) {
if (!HasStroke(aFrame, aContextPaint)) {
return false;
}
SetupCairoStrokeGeometry(aFrame, aContext, aObjectPaint);
SetupCairoStrokeGeometry(aFrame, aContext, aContextPaint);
return SetupCairoStrokePaint(aFrame, aContext, aObjectPaint);
return SetupCairoStrokePaint(aFrame, aContext, aContextPaint);
}
bool
nsSVGUtils::PaintSVGGlyph(Element* aElement, gfxContext* aContext,
gfxFont::DrawMode aDrawMode,
gfxTextObjectPaint* aObjectPaint)
gfxTextContextPaint* aContextPaint)
{
nsIFrame* frame = aElement->GetPrimaryFrame();
nsISVGChildFrame* svgFrame = do_QueryFrame(frame);
@ -1841,7 +1841,7 @@ nsSVGUtils::PaintSVGGlyph(Element* aElement, gfxContext* aContext,
}
nsRenderingContext context;
context.Init(frame->PresContext()->DeviceContext(), aContext);
context.AddUserData(&gfxTextObjectPaint::sUserDataKey, aObjectPaint, nullptr);
context.AddUserData(&gfxTextContextPaint::sUserDataKey, aContextPaint, nullptr);
svgFrame->NotifySVGChanged(nsISVGChildFrame::TRANSFORM_CHANGED);
nsresult rv = svgFrame->PaintSVG(&context, nullptr, frame);
return NS_SUCCEEDED(rv);

View File

@ -45,7 +45,7 @@ class nsSVGLength2;
class nsSVGOuterSVGFrame;
class nsSVGPathGeometryFrame;
class nsTextFrame;
class gfxTextObjectPaint;
class gfxTextContextPaint;
struct nsStyleSVG;
struct nsStyleSVGPaint;
@ -608,58 +608,58 @@ public:
/**
* Set up cairo context with an object pattern
*/
static bool SetupObjectPaint(gfxContext *aContext,
gfxTextObjectPaint *aObjectPaint,
const nsStyleSVGPaint& aPaint,
float aOpacity);
static bool SetupContextPaint(gfxContext *aContext,
gfxTextContextPaint *aContextPaint,
const nsStyleSVGPaint& aPaint,
float aOpacity);
/**
* Sets the current paint on the specified gfxContent to be the SVG 'fill'
* for the given frame.
*/
static bool SetupCairoFillPaint(nsIFrame* aFrame, gfxContext* aContext,
gfxTextObjectPaint *aObjectPaint = nullptr);
gfxTextContextPaint *aContextPaint = nullptr);
/**
* Sets the current paint on the specified gfxContent to be the SVG 'stroke'
* for the given frame.
*/
static bool SetupCairoStrokePaint(nsIFrame* aFrame, gfxContext* aContext,
gfxTextObjectPaint *aObjectPaint = nullptr);
gfxTextContextPaint *aContextPaint = nullptr);
static float GetOpacity(nsStyleSVGOpacitySource aOpacityType,
const float& aOpacity,
gfxTextObjectPaint *aOuterObjectPaint);
gfxTextContextPaint *aOuterContextPaint);
/*
* @return false if there is no stroke
*/
static bool HasStroke(nsIFrame* aFrame,
gfxTextObjectPaint *aObjectPaint = nullptr);
gfxTextContextPaint *aContextPaint = nullptr);
static float GetStrokeWidth(nsIFrame* aFrame,
gfxTextObjectPaint *aObjectPaint = nullptr);
gfxTextContextPaint *aContextPaint = nullptr);
/*
* Set up a cairo context for measuring the bounding box of a stroked path.
*/
static void SetupCairoStrokeBBoxGeometry(nsIFrame* aFrame,
gfxContext *aContext,
gfxTextObjectPaint *aObjectPaint = nullptr);
gfxTextContextPaint *aContextPaint = nullptr);
/*
* Set up a cairo context for a stroked path (including any dashing that
* applies).
*/
static void SetupCairoStrokeGeometry(nsIFrame* aFrame, gfxContext *aContext,
gfxTextObjectPaint *aObjectPaint = nullptr);
gfxTextContextPaint *aContextPaint = nullptr);
/*
* Set up a cairo context for stroking, including setting up any stroke-related
* properties such as dashing and setting the current paint on the gfxContext.
*/
static bool SetupCairoStroke(nsIFrame* aFrame, gfxContext *aContext,
gfxTextObjectPaint *aObjectPaint = nullptr);
gfxTextContextPaint *aContextPaint = nullptr);
/**
* This function returns a set of bit flags indicating which parts of the
@ -678,7 +678,7 @@ public:
*/
static bool PaintSVGGlyph(Element* aElement, gfxContext* aContext,
gfxFont::DrawMode aDrawMode,
gfxTextObjectPaint* aObjectPaint);
gfxTextContextPaint* aContextPaint);
/**
* Get the extents of a SVG glyph.
* @param aElement the SVG glyph element