Backed out changesets 6c097bdfc079, 51f5d900cd27, 9fdf99c07466, and b322938b37ef (bug 798843) due to intermittent Windows test failures.

This commit is contained in:
Ryan VanderMeulen
2013-09-13 11:15:54 -04:00
parent 1c53be8fe0
commit 442d2f8435
31 changed files with 411 additions and 511 deletions

View File

@@ -290,11 +290,11 @@ gfxFontEntry::GetSVGGlyphExtents(gfxContext *aContext, uint32_t aGlyphId,
bool
gfxFontEntry::RenderSVGGlyph(gfxContext *aContext, uint32_t aGlyphId,
int aDrawMode, gfxTextContextPaint *aContextPaint)
int aDrawMode, gfxTextObjectPaint *aObjectPaint)
{
NS_ASSERTION(mSVGInitialized, "SVG data has not yet been loaded. TryGetSVGData() first.");
return mSVGGlyphs->RenderGlyph(aContext, aGlyphId, gfxFont::DrawMode(aDrawMode),
aContextPaint);
aObjectPaint);
}
bool
@@ -2118,7 +2118,7 @@ struct GlyphBuffer {
}
void Flush(cairo_t *aCR, gfxFont::DrawMode aDrawMode, bool aReverse,
gfxTextContextPaint *aContextPaint,
gfxTextObjectPaint *aObjectPaint,
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, aContextPaint, aGlobalMatrix);
FlushStroke(aCR, aObjectPaint, aGlobalMatrix);
}
if (aDrawMode & gfxFont::GLYPH_FILL) {
PROFILER_LABEL("GlyphBuffer", "cairo_show_glyphs");
nsRefPtr<gfxPattern> pattern;
if (aContextPaint &&
!!(pattern = aContextPaint->GetFillPattern(aGlobalMatrix))) {
if (aObjectPaint &&
!!(pattern = aObjectPaint->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, aContextPaint, aGlobalMatrix);
FlushStroke(aCR, aObjectPaint, aGlobalMatrix);
}
}
@@ -2166,11 +2166,11 @@ struct GlyphBuffer {
}
private:
void FlushStroke(cairo_t *aCR, gfxTextContextPaint *aContextPaint,
void FlushStroke(cairo_t *aCR, gfxTextObjectPaint *aObjectPaint,
const gfxMatrix& aGlobalMatrix) {
nsRefPtr<gfxPattern> pattern;
if (aContextPaint &&
!!(pattern = aContextPaint->GetStrokePattern(aGlobalMatrix))) {
if (aObjectPaint &&
!!(pattern = aObjectPaint->GetStrokePattern(aGlobalMatrix))) {
cairo_save(aCR);
cairo_set_source(aCR, pattern->CairoPattern());
}
@@ -2212,7 +2212,7 @@ struct GlyphBufferAzure {
return &mGlyphBuffer[mNumGlyphs++];
}
void Flush(DrawTarget *aDT, gfxTextContextPaint *aContextPaint, ScaledFont *aFont,
void Flush(DrawTarget *aDT, gfxTextObjectPaint *aObjectPaint, 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, aContextPaint, aFont, aThebesContext, buf, state);
FlushStroke(aDT, aObjectPaint, aFont, aThebesContext, buf, state);
}
if (aDrawMode & gfxFont::GLYPH_FILL) {
if (state.pattern || aContextPaint) {
if (state.pattern || aObjectPaint) {
Pattern *pat;
nsRefPtr<gfxPattern> fillPattern;
if (!aContextPaint ||
!(fillPattern = aContextPaint->GetFillPattern(aThebesContext->CurrentMatrix()))) {
if (!aObjectPaint ||
!(fillPattern = aObjectPaint->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, aContextPaint, aFont, aThebesContext, buf, state);
FlushStroke(aDT, aObjectPaint, aFont, aThebesContext, buf, state);
}
mNumGlyphs = 0;
}
private:
void FlushStroke(DrawTarget *aDT, gfxTextContextPaint *aContextPaint,
void FlushStroke(DrawTarget *aDT, gfxTextObjectPaint *aObjectPaint,
ScaledFont *aFont, gfxContext *aThebesContext,
gfx::GlyphBuffer& aBuf, gfxContext::AzureState& aState)
{
RefPtr<Path> path = aFont->GetPathForGlyphs(aBuf, aDT);
if (aContextPaint) {
if (aObjectPaint) {
nsRefPtr<gfxPattern> strokePattern =
aContextPaint->GetStrokePattern(aThebesContext->CurrentMatrix());
aObjectPaint->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, gfxTextContextPaint *aContextPaint,
Spacing *aSpacing, gfxTextObjectPaint *aObjectPaint,
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<gfxTextContextPaint> contextPaint;
if (haveSVGGlyphs && !aContextPaint) {
nsAutoPtr<gfxTextObjectPaint> objectPaint;
if (haveSVGGlyphs && !aObjectPaint) {
// 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();
contextPaint = new SimpleTextContextPaint(fillPattern, nullptr,
objectPaint = new SimpleTextObjectPaint(fillPattern, nullptr,
aContext->CurrentMatrix());
aContextPaint = contextPaint;
aObjectPaint = objectPaint;
}
// 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(), aContextPaint,
glyphData->GetSimpleGlyph(), aObjectPaint,
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, aContextPaint, globalMatrix);
glyphs.Flush(cr, aDrawMode, isRTL, aObjectPaint, 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, aContextPaint, globalMatrix);
glyphs.Flush(cr, aDrawMode, isRTL, aObjectPaint, 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,
aContextPaint, aCallbacks,
aObjectPaint, 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, aContextPaint, globalMatrix);
glyphs.Flush(cr, aDrawMode, isRTL, aObjectPaint, 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, aContextPaint, globalMatrix);
glyphs.Flush(cr, aDrawMode, isRTL, aObjectPaint, 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, aContextPaint, globalMatrix, true);
glyphs.Flush(cr, aDrawMode, isRTL, aObjectPaint, 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(), aContextPaint,
glyphData->GetSimpleGlyph(), aObjectPaint,
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, aContextPaint, scaledFont,
glyphs.Flush(dt, aObjectPaint, 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, aContextPaint, scaledFont,
glyphs.Flush(dt, aObjectPaint, 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,
aContextPaint, aCallbacks,
aObjectPaint, 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, aContextPaint, scaledFont, aDrawMode,
glyphs.Flush(dt, aObjectPaint, 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, aContextPaint, scaledFont,
glyphs.Flush(dt, aObjectPaint, 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, aContextPaint, scaledFont, aDrawMode, isRTL,
glyphs.Flush(dt, aObjectPaint, 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, gfxTextContextPaint *aContextPaint)
uint32_t aGlyphId, gfxTextObjectPaint *aObjectPaint)
{
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);
aContextPaint->InitStrokeGeometry(aContext, devUnitsPerSVGUnit);
aObjectPaint->InitStrokeGeometry(aContext, devUnitsPerSVGUnit);
return GetFontEntry()->RenderSVGGlyph(aContext, aGlyphId, aDrawMode,
aContextPaint);
aObjectPaint);
}
bool
gfxFont::RenderSVGGlyph(gfxContext *aContext, gfxPoint aPoint, DrawMode aDrawMode,
uint32_t aGlyphId, gfxTextContextPaint *aContextPaint,
uint32_t aGlyphId, gfxTextObjectPaint *aObjectPaint,
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,
aContextPaint);
aObjectPaint);
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,
gfxTextContextPaint *aContextPaint,
gfxTextObjectPaint *aObjectPaint,
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, aContextPaint,
haveSpacing ? spacingBuffer.Elements() : nullptr, aObjectPaint,
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,
gfxTextContextPaint *aContextPaint,
gfxTextObjectPaint *aObjectPaint,
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, aContextPaint, ligatureRunStart,
DrawGlyphs(font, aContext, aDrawMode, &pt, aObjectPaint, ligatureRunStart,
ligatureRunEnd, aProvider, ligatureRunStart, ligatureRunEnd,
aCallbacks);

View File

@@ -49,7 +49,7 @@ class gfxUserFontData;
class gfxShapedText;
class gfxShapedWord;
class gfxSVGGlyphs;
class gfxTextContextPaint;
class gfxTextObjectPaint;
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,
gfxTextContextPaint *aContextPaint);
gfxTextObjectPaint *aObjectPaint);
// 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 aContextPaint information about how to construct the fill and
* @param aObjectPaint 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, gfxTextContextPaint *aContextPaint,
Spacing *aSpacing, gfxTextObjectPaint *aObjectPaint,
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, gfxTextContextPaint *aContextPaint);
uint32_t aGlyphId, gfxTextObjectPaint *aObjectPaint);
bool RenderSVGGlyph(gfxContext *aContext, gfxPoint aPoint, DrawMode aDrawMode,
uint32_t aGlyphId, gfxTextContextPaint *aContextPaint,
uint32_t aGlyphId, gfxTextObjectPaint *aObjectPaint,
gfxTextRunDrawCallbacks *aCallbacks,
bool& aEmittedGlyphs);
@@ -2818,7 +2818,7 @@ public:
gfxFont::DrawMode aDrawMode,
uint32_t aStart, uint32_t aLength,
PropertyProvider *aProvider,
gfxFloat *aAdvanceWidth, gfxTextContextPaint *aContextPaint,
gfxFloat *aAdvanceWidth, gfxTextObjectPaint *aObjectPaint,
gfxTextRunDrawCallbacks *aCallbacks = nullptr);
/**
@@ -3245,7 +3245,7 @@ private:
// **** drawing helper ****
void DrawGlyphs(gfxFont *aFont, gfxContext *aContext,
gfxFont::DrawMode aDrawMode, gfxPoint *aPt,
gfxTextContextPaint *aContextPaint, uint32_t aStart,
gfxTextObjectPaint *aObjectPaint, 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 gfxTextContextPaint::sUserDataKey;
mozilla::gfx::UserDataKey gfxTextObjectPaint::sUserDataKey;
const float gfxSVGGlyphs::SVG_UNITS_PER_EM = 1000.0f;
const gfxRGBA SimpleTextContextPaint::sZero = gfxRGBA(0.0f, 0.0f, 0.0f, 0.0f);
const gfxRGBA SimpleTextObjectPaint::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, gfxTextContextPaint *aContextPaint)
DrawMode aDrawMode, gfxTextObjectPaint *aObjectPaint)
{
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, aContextPaint);
return nsSVGUtils::PaintSVGGlyph(glyph, aContext, aDrawMode, aObjectPaint);
}
bool
@@ -446,7 +446,7 @@ gfxSVGGlyphsDocument::InsertGlyphId(Element *aGlyphElement)
}
void
gfxTextContextPaint::InitStrokeGeometry(gfxContext *aContext,
gfxTextObjectPaint::InitStrokeGeometry(gfxContext *aContext,
float devUnitsPerSVGUnit)
{
mStrokeWidth = aContext->CurrentLineWidth() / devUnitsPerSVGUnit;

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 aContextPaint Information on text context paints.
* See |gfxTextContextPaint|.
* @param aObjectPaint Information on outer text object paints.
* See |gfxTextObjectPaint|.
*/
bool RenderGlyph(gfxContext *aContext, uint32_t aGlyphId, DrawMode aDrawMode,
gfxTextContextPaint *aContextPaint);
gfxTextObjectPaint *aObjectPaint);
/**
* Get the extents for the SVG glyph associated with |aGlyphId|
@@ -160,17 +160,18 @@ private:
/**
* Used for trickling down paint information through to SVG glyphs.
* Will be extended in later patch.
*/
class gfxTextContextPaint
class gfxTextObjectPaint
{
protected:
gfxTextContextPaint() { }
gfxTextObjectPaint() { }
public:
static mozilla::gfx::UserDataKey sUserDataKey;
/*
* Get text context pattern with the specified opacity value.
* Get outer text object pattern with the specified opacity value.
* This lets us inherit paints and paint opacities (i.e. fill/stroke and
* fill-opacity/stroke-opacity) separately.
*/
@@ -205,7 +206,7 @@ public:
return GetStrokePattern(GetStrokeOpacity(), aCTM);
}
virtual ~gfxTextContextPaint() { }
virtual ~gfxTextObjectPaint() { }
private:
FallibleTArray<gfxFloat> mDashes;
@@ -214,10 +215,10 @@ private:
};
/**
* For passing in patterns where the text context has no separate pattern
* For passing in patterns where the outer text object has no separate pattern
* opacity value.
*/
class SimpleTextContextPaint : public gfxTextContextPaint
class SimpleTextObjectPaint : public gfxTextObjectPaint
{
private:
static const gfxRGBA sZero;
@@ -234,7 +235,7 @@ public:
return deviceToUser * aPattern->GetMatrix();
}
SimpleTextContextPaint(gfxPattern *aFillPattern, gfxPattern *aStrokePattern,
SimpleTextObjectPaint(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,
gfxTextContextPaint* aContextPaint,
gfxTextObjectPaint* aObjectPaint,
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,
gfxTextContextPaint* aContextPaint,
gfxTextObjectPaint* aObjectPaint,
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, aContextPaint,
textPaintStyle, clipEdges, aObjectPaint,
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, aContextPaint, aCallbacks);
nullptr, aObjectPaint, aCallbacks);
}
static void
@@ -5884,7 +5884,7 @@ DrawTextRun(gfxTextRun* aTextRun,
PropertyProvider* aProvider,
nscolor aTextColor,
gfxFloat* aAdvanceWidth,
gfxTextContextPaint* aContextPaint,
gfxTextObjectPaint* aObjectPaint,
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, aContextPaint, aCallbacks);
aProvider, aAdvanceWidth, aObjectPaint, aCallbacks);
aCallbacks->NotifyAfterText();
} else {
aCtx->SetColor(gfxRGBA(aTextColor));
aTextRun->Draw(aCtx, aTextBaselinePt, drawMode, aOffset, aLength,
aProvider, aAdvanceWidth, aContextPaint);
aProvider, aAdvanceWidth, aObjectPaint);
}
}
@@ -5909,11 +5909,11 @@ nsTextFrame::DrawTextRun(gfxContext* const aCtx,
nscolor aTextColor,
gfxFloat& aAdvanceWidth,
bool aDrawSoftHyphen,
gfxTextContextPaint* aContextPaint,
gfxTextObjectPaint* aObjectPaint,
nsTextFrame::DrawPathCallbacks* aCallbacks)
{
::DrawTextRun(mTextRun, aCtx, aTextBaselinePt, aOffset, aLength, &aProvider,
aTextColor, &aAdvanceWidth, aContextPaint, aCallbacks);
aTextColor, &aAdvanceWidth, aObjectPaint, 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, aContextPaint, aCallbacks);
nullptr, aTextColor, nullptr, aObjectPaint, aCallbacks);
}
}
}
@@ -5945,7 +5945,7 @@ nsTextFrame::DrawTextRunAndDecorations(
bool aDrawSoftHyphen,
const TextDecorations& aDecorations,
const nscolor* const aDecorationOverrideColor,
gfxTextContextPaint* aContextPaint,
gfxTextObjectPaint* aObjectPaint,
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, aContextPaint, aCallbacks);
aAdvanceWidth, aDrawSoftHyphen, aObjectPaint, 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,
gfxTextContextPaint* aContextPaint,
gfxTextObjectPaint* aObjectPaint,
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, aContextPaint, aCallbacks);
aDecorationOverrideColor, aObjectPaint, aCallbacks);
} else {
DrawTextRun(aCtx, aTextBaselinePt, aOffset, aLength, aProvider,
aTextColor, aAdvanceWidth, aDrawSoftHyphen, aContextPaint, aCallbacks);
aTextColor, aAdvanceWidth, aDrawSoftHyphen, aObjectPaint, aCallbacks);
}
}

View File

@@ -374,7 +374,7 @@ public:
// context.
void PaintText(nsRenderingContext* aRenderingContext, nsPoint aPt,
const nsRect& aDirtyRect, const nsCharClipDisplayItem& aItem,
gfxTextContextPaint* aContextPaint = nullptr,
gfxTextObjectPaint* aObjectPaint = 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,
gfxTextContextPaint* aContextPaint,
gfxTextObjectPaint* aObjectPaint,
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,
gfxTextContextPaint* aContextPaint,
gfxTextObjectPaint* aObjectPaint,
DrawPathCallbacks* aCallbacks);
void DrawTextRunAndDecorations(gfxContext* const aCtx,
@@ -667,7 +667,7 @@ protected:
bool aDrawSoftHyphen,
const TextDecorations& aDecorations,
const nscolor* const aDecorationOverrideColor,
gfxTextContextPaint* aContextPaint,
gfxTextObjectPaint* aObjectPaint,
DrawPathCallbacks* aCallbacks);
void DrawText(gfxContext* const aCtx,
@@ -683,7 +683,7 @@ protected:
gfxFloat& aAdvanceWidth,
bool aDrawSoftHyphen,
const nscolor* const aDecorationOverrideColor = nullptr,
gfxTextContextPaint* aContextPaint = nullptr,
gfxTextObjectPaint* aObjectPaint = nullptr,
DrawPathCallbacks* aCallbacks = nullptr);
// Set non empty rect to aRect, it should be overflow rect or frame rect.

View File

@@ -1,37 +1,11 @@
.woff files for SVG-in-OpenType testing
=======================================
Fonts in this directory:
There are three .woff files in this directory:
* nosvg.woff
* svg.woff
* rubbish.woff
rubbish.woff contains an SVG table with the contents of rubbish.txt. This is
not a valid SVG table so no SVG glyphs will be used.
nosvg.woff
----------
This font is Liberation Serif with the addition of a glyph with a UVS selector
(Liberation fonts do not come with UVS glyphs; one had to be added to test that
SVG glyphs work with UVS selectors). It contains no 'SVG ' table.
nosvg.woff is derived from the "Liberation" font. It contains no SVG table.
svg.woff
--------
This font is the same as nosvg.woff above, but with the glyphs-*.svg SVG
documents from this directory embedded in it using the tools described below.
rubbish.woff
------------
This font is the same as nosvg.woff above, but with the addition of an 'SVG '
table with the contents of rubbish.txt. Its purpose is to test that SVG tables
without valid XML are ignored.
Creating the Fonts
------------------
The tools used here are insertsvg.py from [1] and sfnt2woff from [2].
svg.woff can be recreated with:
woff2sfnt nosvg.woff > nosvg.ttf
insertsvg.py nosvg.ttf svg.ttf glyphs-*.svg
sfnt2woff svg.ttf
[1] https://github.com/edf825/SVG-OpenType-Utils
[2] http://people.mozilla.com/~jkew/woff/
svg.woff is nosvg.woff with an SVG table added. The
table contains the glyph documents glyphs-base.svg, glyphs-invalid.svg,
glyphs-objectcolor.svg, glyphs-objectopacity.svg, glyphs-objectstroke.svg,
glyphs-paintservers.svg and glyphs-transforms.svg.

View File

@@ -3,22 +3,22 @@
Test SVG glyphs for text object pattern inheritance
Covers glyph ID range 48 (N) to 51 (Q)
-->
<!-- context-fill, no stroke -->
<!-- -moz-objectfill, no stroke -->
<!-- N -->
<rect x="100" y="-900" width="800" height="800" stroke-width="50"
stroke="none" fill="context-fill" id="glyph48"/>
stroke="none" fill="-moz-objectFill" id="glyph48"/>
<!-- O -->
<rect x="50" y="-950" width="900" height="900" stroke-width="100"
fill="context-fill" stroke="none" id="glyph49"/>
fill="-moz-objectFill" stroke="none" id="glyph49"/>
<!-- context-stroke -->
<!-- -moz-objectstroke -->
<!-- P -->
<rect x="100" y="-900" width="800" height="800" stroke-width="50"
stroke="context-stroke" fill="burlywood" id="glyph50"/>
stroke="-moz-objectStroke" fill="burlywood" id="glyph50"/>
<!-- both context-stroke and context-fill (but note swapped usage!) -->
<!-- both -moz-objectstroke and -moz-objectfill -->
<!-- Q -->
<rect x="50" y="-950" width="900" height="900" stroke-width="100"
fill="context-stroke" stroke="context-fill" id="glyph51"/>
fill="-moz-objectStroke" stroke="-moz-objectFill" id="glyph51"/>
</svg>

Before

Width:  |  Height:  |  Size: 841 B

After

Width:  |  Height:  |  Size: 842 B

View File

@@ -5,47 +5,47 @@
-->
<!-- R -->
<rect x="100" y="-900" width="800" height="800" stroke-width="50"
fill="context-fill" stroke="context-stroke"
fill-opacity="context-fill-opacity"
stroke-opacity="context-stroke-opacity" id="glyph52"/>
fill="-moz-objectFill" stroke="-moz-objectStroke"
fill-opacity="-moz-objectFillOpacity"
stroke-opacity="-moz-objectStrokeOpacity" id="glyph52"/>
<!-- S -->
<rect x="100" y="-900" width="800" height="800" stroke-width="50"
fill="context-fill" stroke="context-stroke"
fill-opacity="context-stroke-opacity"
stroke-opacity="context-fill-opacity" id="glyph53"/>
fill="-moz-objectFill" stroke="-moz-objectStroke"
fill-opacity="-moz-objectStrokeOpacity"
stroke-opacity="-moz-objectFillOpacity" id="glyph53"/>
<!-- T -->
<rect x="100" y="-900" width="800" height="800" stroke-width="50"
fill="context-stroke" stroke="context-fill"
fill-opacity="context-fill-opacity"
stroke-opacity="context-stroke-opacity" id="glyph54"/>
fill="-moz-objectStroke" stroke="-moz-objectFill"
fill-opacity="-moz-objectFillOpacity"
stroke-opacity="-moz-objectStrokeOpacity" id="glyph54"/>
<!-- U -->
<!-- Test for bug where explicit `inherit' would fail for
*-opacity="objectStrokeOpacity" or "objectFillOpacity" -->
<g style="fill-opacity : context-stroke-opacity; stroke-opacity : context-fill-opacity">
<g style="fill-opacity : -moz-objectStrokeOpacity; stroke-opacity : -moz-objectFillOpacity">
<rect x="100" y="-900" width="800" height="800" stroke-width="50"
fill="context-stroke" stroke="context-fill"
fill="-moz-objectStroke" stroke="-moz-objectFill"
fill-opacity="inherit" stroke-opacity="inherit" id="glyph55"/>
</g>
<!-- W -->
<rect x="100" y="-900" width="800" height="800" stroke-width="50"
fill="darkorchid" stroke="goldenrod"
fill-opacity="context-fill-opacity"
stroke-opacity="context-stroke-opacity" id="glyph57"/>
fill-opacity="-moz-objectFillOpacity"
stroke-opacity="-moz-objectStrokeOpacity" id="glyph57"/>
<!-- X -->
<rect x="100" y="-900" width="800" height="800" stroke-width="50"
fill="darkorchid" stroke="goldenrod"
fill-opacity="context-stroke-opacity"
stroke-opacity="context-fill-opacity" id="glyph58"/>
fill-opacity="-moz-objectStrokeOpacity"
stroke-opacity="-moz-objectFillOpacity" id="glyph58"/>
<style type="text/css"><![CDATA[
#glyph59 {
fill-opacity : context-fill-opacity;
stroke-opacity : context-stroke-opacity;
fill-opacity : -moz-objectFillOpacity;
stroke-opacity : -moz-objectStrokeOpacity;
}
#ychild {
color-interpolation : sRGB;

Before

Width:  |  Height:  |  Size: 2.1 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB

View File

@@ -11,15 +11,15 @@
<!-- b -->
<rect x="100" y="-900" width="800" height="800" stroke="chartreuse"
stroke-width="50" stroke-dashoffset="35"
stroke-dasharray="context-value" id="glyph68" />
stroke-dasharray="-moz-objectValue" id="glyph68" />
<!-- c -->
<rect x="100" y="-900" width="800" height="800" stroke="sienna"
stroke-width="50" stroke-dasharray="50 50"
stroke-dashoffset="context-value" id="glyph69" />
stroke-dashoffset="-moz-objectValue" id="glyph69" />
<!-- d -->
<rect x="100" y="-900" width="800" height="800" stroke="olivedrab"
stroke-width="context-value" stroke-dasharray="context-value"
stroke-dashoffset="context-value" id="glyph70" />
stroke-width="-moz-objectValue" stroke-dasharray="-moz-objectValue"
stroke-dashoffset="-moz-objectValue" id="glyph70" />
</svg>

Before

Width:  |  Height:  |  Size: 900 B

After

Width:  |  Height:  |  Size: 915 B

View File

@@ -123,6 +123,11 @@ CSS_KEY(-moz-min-content, _moz_min_content)
CSS_KEY(-moz-myanmar, _moz_myanmar)
CSS_KEY(-moz-nativehyperlinktext, _moz_nativehyperlinktext)
CSS_KEY(-moz-none, _moz_none)
CSS_KEY(-moz-objectfill, _moz_objectfill)
CSS_KEY(-moz-objectfillopacity, _moz_objectfillopacity)
CSS_KEY(-moz-objectstroke, _moz_objectstroke)
CSS_KEY(-moz-objectstrokeopacity, _moz_objectstrokeopacity)
CSS_KEY(-moz-objectvalue, _moz_objectvalue)
CSS_KEY(-moz-oddtreerow, _moz_oddtreerow)
CSS_KEY(-moz-oriya, _moz_oriya)
CSS_KEY(-moz-persian, _moz_persian)
@@ -218,12 +223,7 @@ CSS_KEY(column-reverse, column_reverse)
CSS_KEY(condensed, condensed)
CSS_KEY(contain, contain)
CSS_KEY(content-box, content_box)
CSS_KEY(context-fill, context_fill)
CSS_KEY(context-fill-opacity, context_fill_opacity)
CSS_KEY(context-menu, context_menu)
CSS_KEY(context-stroke, context_stroke)
CSS_KEY(context-stroke-opacity, context_stroke_opacity)
CSS_KEY(context-value, context_value)
CSS_KEY(continuous, continuous)
CSS_KEY(contrast, contrast)
CSS_KEY(copy, copy)

View File

@@ -4984,8 +4984,7 @@ CSSParserImpl::TranslateDimension(nsCSSValue& aValue,
VARIANT_GRADIENT | \
VARIANT_TIMING_FUNCTION | \
VARIANT_ALL | \
VARIANT_CALC | \
VARIANT_OPENTYPE_SVG_KEYWORD
VARIANT_CALC
// Note that callers passing VARIANT_CALC in aVariantMask will get
// full-range parsing inside the calc() expression, and the code that
@@ -5134,18 +5133,6 @@ CSSParserImpl::ParseVariant(nsCSSValue& aValue,
return true;
}
}
if ((aVariantMask & VARIANT_OPENTYPE_SVG_KEYWORD) != 0) {
static bool sOpentypeSVGEnabled;
static bool sOpentypeSVGEnabledCached = false;
if (!sOpentypeSVGEnabledCached) {
sOpentypeSVGEnabledCached = true;
Preferences::AddBoolVarCache(&sOpentypeSVGEnabled,
"gfx.font_rendering.opentype_svg.enabled");
}
if (sOpentypeSVGEnabled) {
aVariantMask |= VARIANT_KEYWORD;
}
}
if ((aVariantMask & VARIANT_KEYWORD) != 0) {
int32_t value;
if (nsCSSProps::FindKeyword(keyword, aKeywordTable, value)) {
@@ -10852,10 +10839,8 @@ bool
CSSParserImpl::ParsePaint(nsCSSProperty aPropID)
{
nsCSSValue x, y;
if (!ParseVariant(x, VARIANT_HC | VARIANT_NONE | VARIANT_URL |
VARIANT_OPENTYPE_SVG_KEYWORD,
nsCSSProps::kContextPatternKTable)) {
if (!ParseVariant(x, VARIANT_HCK | VARIANT_NONE | VARIANT_URL,
nsCSSProps::kObjectPatternKTable)) {
return false;
}
@@ -10882,10 +10867,8 @@ bool
CSSParserImpl::ParseDasharray()
{
nsCSSValue value;
if (ParseVariant(value, VARIANT_INHERIT | VARIANT_NONE |
VARIANT_OPENTYPE_SVG_KEYWORD,
nsCSSProps::kStrokeContextValueKTable)) {
if (ParseVariant(value, VARIANT_HK | VARIANT_NONE,
nsCSSProps::kStrokeObjectValueKTable)) {
// 'inherit', 'initial', and 'none' are only allowed on their own
if (!ExpectEndProperty()) {
return false;

View File

@@ -3342,7 +3342,7 @@ CSS_PROP_SVG(
CSS_PROPERTY_PARSE_FUNCTION,
"",
0,
kContextPatternKTable,
kObjectPatternKTable,
offsetof(nsStyleSVG, mFill),
eStyleAnimType_PaintServer)
CSS_PROP_SVG(
@@ -3351,8 +3351,8 @@ CSS_PROP_SVG(
FillOpacity,
CSS_PROPERTY_PARSE_VALUE,
"",
VARIANT_HN | VARIANT_OPENTYPE_SVG_KEYWORD,
kContextOpacityKTable,
VARIANT_HN | VARIANT_KEYWORD,
kObjectOpacityKTable,
offsetof(nsStyleSVG, mFillOpacity),
eStyleAnimType_float)
CSS_PROP_SVG(
@@ -3508,7 +3508,7 @@ CSS_PROP_SVG(
CSS_PROPERTY_PARSE_FUNCTION,
"",
0,
kContextPatternKTable,
kObjectPatternKTable,
offsetof(nsStyleSVG, mStroke),
eStyleAnimType_PaintServer)
CSS_PROP_SVG(
@@ -3520,7 +3520,7 @@ CSS_PROP_SVG(
// NOTE: Internal values have range restrictions.
"",
0,
kStrokeContextValueKTable,
kStrokeObjectValueKTable,
CSS_PROP_NO_OFFSET, /* property stored in 2 separate members */
eStyleAnimType_Custom)
CSS_PROP_SVG(
@@ -3529,8 +3529,8 @@ CSS_PROP_SVG(
StrokeDashoffset,
CSS_PROPERTY_PARSE_VALUE,
"",
VARIANT_HLPN | VARIANT_OPENTYPE_SVG_KEYWORD,
kStrokeContextValueKTable,
VARIANT_HLPN | VARIANT_KEYWORD,
kStrokeObjectValueKTable,
offsetof(nsStyleSVG, mStrokeDashoffset),
eStyleAnimType_Coord)
CSS_PROP_SVG(
@@ -3570,8 +3570,8 @@ CSS_PROP_SVG(
StrokeOpacity,
CSS_PROPERTY_PARSE_VALUE,
"",
VARIANT_HN | VARIANT_OPENTYPE_SVG_KEYWORD,
kContextOpacityKTable,
VARIANT_HN | VARIANT_KEYWORD,
kObjectOpacityKTable,
offsetof(nsStyleSVG, mStrokeOpacity),
eStyleAnimType_float)
CSS_PROP_SVG(
@@ -3581,8 +3581,8 @@ CSS_PROP_SVG(
CSS_PROPERTY_PARSE_VALUE |
CSS_PROPERTY_VALUE_NONNEGATIVE,
"",
VARIANT_HLPN | VARIANT_OPENTYPE_SVG_KEYWORD,
kStrokeContextValueKTable,
VARIANT_HLPN | VARIANT_KEYWORD,
kStrokeObjectValueKTable,
offsetof(nsStyleSVG, mStrokeWidth),
eStyleAnimType_Coord)
CSS_PROP_SVG(

View File

@@ -793,7 +793,7 @@ const int32_t nsCSSProps::kClearKTable[] = {
eCSSKeyword_UNKNOWN,-1
};
// See also kContextPatternKTable for SVG paint-specific values
// See also kObjectPatternKTable for SVG paint-specific values
const int32_t nsCSSProps::kColorKTable[] = {
eCSSKeyword_activeborder, LookAndFeel::eColorID_activeborder,
eCSSKeyword_activecaption, LookAndFeel::eColorID_activecaption,
@@ -1268,15 +1268,15 @@ const int32_t nsCSSProps::kListStyleKTable[] = {
eCSSKeyword_UNKNOWN,-1
};
const int32_t nsCSSProps::kContextOpacityKTable[] = {
eCSSKeyword_context_fill_opacity, NS_STYLE_CONTEXT_FILL_OPACITY,
eCSSKeyword_context_stroke_opacity, NS_STYLE_CONTEXT_STROKE_OPACITY,
const int32_t nsCSSProps::kObjectOpacityKTable[] = {
eCSSKeyword__moz_objectfillopacity, NS_STYLE_OBJECT_FILL_OPACITY,
eCSSKeyword__moz_objectstrokeopacity, NS_STYLE_OBJECT_STROKE_OPACITY,
eCSSKeyword_UNKNOWN,-1
};
const int32_t nsCSSProps::kContextPatternKTable[] = {
eCSSKeyword_context_fill, NS_COLOR_CONTEXT_FILL,
eCSSKeyword_context_stroke, NS_COLOR_CONTEXT_STROKE,
const int32_t nsCSSProps::kObjectPatternKTable[] = {
eCSSKeyword__moz_objectfill, NS_COLOR_OBJECTFILL,
eCSSKeyword__moz_objectstroke, NS_COLOR_OBJECTSTROKE,
eCSSKeyword_UNKNOWN,-1
};
@@ -1746,8 +1746,8 @@ const int32_t nsCSSProps::kStrokeLinejoinKTable[] = {
// Lookup table to store the sole objectValue keyword to let SVG glyphs inherit
// certain stroke-* properties from the outer text object
const int32_t nsCSSProps::kStrokeContextValueKTable[] = {
eCSSKeyword_context_value, NS_STYLE_STROKE_PROP_CONTEXT_VALUE,
const int32_t nsCSSProps::kStrokeObjectValueKTable[] = {
eCSSKeyword__moz_objectvalue, NS_STYLE_STROKE_PROP_OBJECTVALUE,
eCSSKeyword_UNKNOWN, -1
};

View File

@@ -49,8 +49,6 @@
#define VARIANT_ELEMENT 0x08000000 // eCSSUnit_Element
#define VARIANT_POSITIVE_DIMENSION 0x10000000 // Only lengths greater than 0.0
#define VARIANT_NONNEGATIVE_DIMENSION 0x20000000 // Only lengths greater than or equal to 0.0
// Keyword used iff gfx.font_rendering.opentype_svg.enabled is true:
#define VARIANT_OPENTYPE_SVG_KEYWORD 0x40000000
// Common combinations of variants
#define VARIANT_AL (VARIANT_AUTO | VARIANT_LENGTH)
@@ -458,7 +456,7 @@ public:
static const int32_t kShapeRenderingKTable[];
static const int32_t kStrokeLinecapKTable[];
static const int32_t kStrokeLinejoinKTable[];
static const int32_t kStrokeContextValueKTable[];
static const int32_t kStrokeObjectValueKTable[];
static const int32_t kVectorEffectKTable[];
static const int32_t kTextAnchorKTable[];
static const int32_t kTextRenderingKTable[];
@@ -507,8 +505,8 @@ public:
static const int32_t kListStylePositionKTable[];
static const int32_t kListStyleKTable[];
static const int32_t kMaskTypeKTable[];
static const int32_t kContextOpacityKTable[];
static const int32_t kContextPatternKTable[];
static const int32_t kObjectOpacityKTable[];
static const int32_t kObjectPatternKTable[];
static const int32_t kOrientKTable[];
static const int32_t kOutlineStyleKTable[];
static const int32_t kOutlineColorKTable[];

View File

@@ -4294,14 +4294,14 @@ nsComputedDOMStyle::GetSVGPaintFor(bool aFill)
SetToRGBAColor(fallback, paint->mFallbackColor);
return valueList;
}
case eStyleSVGPaintType_ContextFill:
case eStyleSVGPaintType_ObjectFill:
{
val->SetIdent(eCSSKeyword_context_fill);
val->SetIdent(eCSSKeyword__moz_objectfill);
break;
}
case eStyleSVGPaintType_ContextStroke:
case eStyleSVGPaintType_ObjectStroke:
{
val->SetIdent(eCSSKeyword_context_stroke);
val->SetIdent(eCSSKeyword__moz_objectstroke);
break;
}
}

View File

@@ -7420,11 +7420,11 @@ SetSVGPaint(const nsCSSValue& aValue, const nsStyleSVGPaint& parentPaint,
} else if (pair.mXValue.GetUnit() == eCSSUnit_Enumerated) {
switch (pair.mXValue.GetIntValue()) {
case NS_COLOR_CONTEXT_FILL:
aResult.SetType(eStyleSVGPaintType_ContextFill);
case NS_COLOR_OBJECTFILL:
aResult.SetType(eStyleSVGPaintType_ObjectFill);
break;
case NS_COLOR_CONTEXT_STROKE:
aResult.SetType(eStyleSVGPaintType_ContextStroke);
case NS_COLOR_OBJECTSTROKE:
aResult.SetType(eStyleSVGPaintType_ObjectStroke);
break;
default:
NS_NOTREACHED("unknown keyword as paint server value");
@@ -7456,11 +7456,11 @@ SetSVGOpacity(const nsCSSValue& aValue,
{
if (eCSSUnit_Enumerated == aValue.GetUnit()) {
switch (aValue.GetIntValue()) {
case NS_STYLE_CONTEXT_FILL_OPACITY:
aOpacityTypeField = eStyleSVGOpacitySource_ContextFillOpacity;
case NS_STYLE_OBJECT_FILL_OPACITY:
aOpacityTypeField = eStyleSVGOpacitySource_ObjectFillOpacity;
break;
case NS_STYLE_CONTEXT_STROKE_OPACITY:
aOpacityTypeField = eStyleSVGOpacitySource_ContextStrokeOpacity;
case NS_STYLE_OBJECT_STROKE_OPACITY:
aOpacityTypeField = eStyleSVGOpacitySource_ObjectStrokeOpacity;
break;
default:
NS_NOTREACHED("SetSVGOpacity: Unknown keyword");
@@ -7480,10 +7480,10 @@ SetSVGOpacity(const nsCSSValue& aValue,
template <typename FieldT, typename T>
static bool
SetTextContextValue(const nsCSSValue& aValue, FieldT& aField, T aFallbackValue)
SetTextObjectValue(const nsCSSValue& aValue, FieldT& aField, T aFallbackValue)
{
if (aValue.GetUnit() != eCSSUnit_Enumerated ||
aValue.GetIntValue() != NS_STYLE_STROKE_PROP_CONTEXT_VALUE) {
aValue.GetIntValue() != NS_STYLE_STROKE_PROP_OBJECTVALUE) {
return false;
}
aField = aFallbackValue;
@@ -7523,13 +7523,12 @@ nsRuleNode::ComputeSVGData(void* aStartStruct,
parentSVG->mFill, mPresContext, aContext,
svg->mFill, eStyleSVGPaintType_Color, canStoreInRuleTree);
// fill-opacity: factor, inherit, initial,
// context-fill-opacity, context-stroke-opacity
nsStyleSVGOpacitySource contextFillOpacity = svg->mFillOpacitySource;
// fill-opacity: factor, inherit, initial, objectFillOpacity, objectStrokeOpacity
nsStyleSVGOpacitySource objectFillOpacity = svg->mFillOpacitySource;
SetSVGOpacity(*aRuleData->ValueForFillOpacity(),
svg->mFillOpacity, contextFillOpacity, canStoreInRuleTree,
svg->mFillOpacity, objectFillOpacity, canStoreInRuleTree,
parentSVG->mFillOpacity, parentSVG->mFillOpacitySource);
svg->mFillOpacitySource = contextFillOpacity;
svg->mFillOpacitySource = objectFillOpacity;
// fill-rule: enum, inherit, initial
SetDiscrete(*aRuleData->ValueForFillRule(),
@@ -7616,7 +7615,7 @@ nsRuleNode::ComputeSVGData(void* aStartStruct,
parentSVG->mStroke, mPresContext, aContext,
svg->mStroke, eStyleSVGPaintType_None, canStoreInRuleTree);
// stroke-dasharray: <dasharray>, none, inherit, context-value
// stroke-dasharray: <dasharray>, none, inherit, -moz-objectValue
const nsCSSValue* strokeDasharrayValue = aRuleData->ValueForStrokeDasharray();
switch (strokeDasharrayValue->GetUnit()) {
case eCSSUnit_Null:
@@ -7643,7 +7642,7 @@ nsRuleNode::ComputeSVGData(void* aStartStruct,
case eCSSUnit_Enumerated:
NS_ABORT_IF_FALSE(strokeDasharrayValue->GetIntValue() ==
NS_STYLE_STROKE_PROP_CONTEXT_VALUE,
NS_STYLE_STROKE_PROP_OBJECTVALUE,
"Unknown keyword for stroke-dasharray");
svg->mStrokeDasharrayFromObject = true;
delete [] svg->mStrokeDasharray;
@@ -7698,9 +7697,9 @@ nsRuleNode::ComputeSVGData(void* aStartStruct,
aRuleData->ValueForStrokeDashoffset();
svg->mStrokeDashoffsetFromObject =
strokeDashoffsetValue->GetUnit() == eCSSUnit_Enumerated &&
strokeDashoffsetValue->GetIntValue() == NS_STYLE_STROKE_PROP_CONTEXT_VALUE;
strokeDashoffsetValue->GetIntValue() == NS_STYLE_STROKE_PROP_OBJECTVALUE;
if (svg->mStrokeDashoffsetFromObject) {
svg->mStrokeDashoffset.SetCoordValue(0);
svg->mStrokeDashoffset.SetIntValue(0, eStyleUnit_Integer);
} else {
SetCoord(*aRuleData->ValueForStrokeDashoffset(),
svg->mStrokeDashoffset, parentSVG->mStrokeDashoffset,
@@ -7727,18 +7726,18 @@ nsRuleNode::ComputeSVGData(void* aStartStruct,
parentSVG->mStrokeMiterlimit, 4.0f);
// stroke-opacity:
nsStyleSVGOpacitySource contextStrokeOpacity = svg->mStrokeOpacitySource;
nsStyleSVGOpacitySource objectStrokeOpacity = svg->mStrokeOpacitySource;
SetSVGOpacity(*aRuleData->ValueForStrokeOpacity(),
svg->mStrokeOpacity, contextStrokeOpacity, canStoreInRuleTree,
svg->mStrokeOpacity, objectStrokeOpacity, canStoreInRuleTree,
parentSVG->mStrokeOpacity, parentSVG->mStrokeOpacitySource);
svg->mStrokeOpacitySource = contextStrokeOpacity;
svg->mStrokeOpacitySource = objectStrokeOpacity;
// stroke-width:
const nsCSSValue* strokeWidthValue = aRuleData->ValueForStrokeWidth();
switch (strokeWidthValue->GetUnit()) {
case eCSSUnit_Enumerated:
NS_ABORT_IF_FALSE(strokeWidthValue->GetIntValue() ==
NS_STYLE_STROKE_PROP_CONTEXT_VALUE,
NS_STYLE_STROKE_PROP_OBJECTVALUE,
"Unrecognized keyword for stroke-width");
svg->mStrokeWidthFromObject = true;
svg->mStrokeWidth.SetCoordValue(nsPresContext::CSSPixelsToAppUnits(1));

View File

@@ -3433,11 +3433,11 @@ nsStyleAnimation::ExtractComputedValue(nsCSSProperty aProperty,
eUnit_CSSValuePair);
return true;
}
if (paint.mType == eStyleSVGPaintType_ContextFill ||
paint.mType == eStyleSVGPaintType_ContextStroke) {
if (paint.mType == eStyleSVGPaintType_ObjectFill ||
paint.mType == eStyleSVGPaintType_ObjectStroke) {
nsAutoPtr<nsCSSValuePair> pair(new nsCSSValuePair);
pair->mXValue.SetIntValue(paint.mType == eStyleSVGPaintType_ContextFill ?
NS_COLOR_CONTEXT_FILL : NS_COLOR_CONTEXT_STROKE,
pair->mXValue.SetIntValue(paint.mType == eStyleSVGPaintType_ObjectFill ?
NS_COLOR_OBJECTFILL : NS_COLOR_OBJECTSTROKE,
eCSSUnit_Enumerated);
pair->mYValue.SetColorValue(paint.mFallbackColor);
aComputedValue.SetAndAdoptCSSValuePairValue(pair.forget(),

View File

@@ -208,8 +208,8 @@ static inline mozilla::css::Side operator++(mozilla::css::Side& side, int) {
#define NS_COLOR_MOZ_VISITEDHYPERLINKTEXT -5
#define NS_COLOR_MOZ_ACTIVEHYPERLINKTEXT -6
// Only valid as paints in SVG glyphs
#define NS_COLOR_CONTEXT_FILL -7
#define NS_COLOR_CONTEXT_STROKE -8
#define NS_COLOR_OBJECTFILL -7
#define NS_COLOR_OBJECTSTROKE -8
// See nsStyleDisplay
#define NS_STYLE_ANIMATION_DIRECTION_NORMAL 0
@@ -914,7 +914,7 @@ static inline mozilla::css::Side operator++(mozilla::css::Side& side, int) {
#define NS_STYLE_STROKE_LINEJOIN_BEVEL 2
// stroke-dasharray, stroke-dashoffset, stroke-width
#define NS_STYLE_STROKE_PROP_CONTEXT_VALUE 0
#define NS_STYLE_STROKE_PROP_OBJECTVALUE 0
// text-anchor
#define NS_STYLE_TEXT_ANCHOR_START 0
@@ -943,9 +943,9 @@ static inline mozilla::css::Side operator++(mozilla::css::Side& side, int) {
#define NS_STYLE_TRANSFORM_STYLE_FLAT 0
#define NS_STYLE_TRANSFORM_STYLE_PRESERVE_3D 1
// object {fill,stroke}-opacity inherited from context for SVG glyphs
#define NS_STYLE_CONTEXT_FILL_OPACITY 0
#define NS_STYLE_CONTEXT_STROKE_OPACITY 1
// object {fill,stroke}-opacity for SVG glyphs
#define NS_STYLE_OBJECT_FILL_OPACITY 0
#define NS_STYLE_OBJECT_STROKE_OPACITY 1
// blending
#define NS_STYLE_BLEND_NORMAL 0

View File

@@ -2280,14 +2280,14 @@ enum nsStyleSVGPaintType {
eStyleSVGPaintType_None = 1,
eStyleSVGPaintType_Color,
eStyleSVGPaintType_Server,
eStyleSVGPaintType_ContextFill,
eStyleSVGPaintType_ContextStroke
eStyleSVGPaintType_ObjectFill,
eStyleSVGPaintType_ObjectStroke
};
enum nsStyleSVGOpacitySource {
eStyleSVGOpacitySource_Normal,
eStyleSVGOpacitySource_ContextFillOpacity,
eStyleSVGOpacitySource_ContextStrokeOpacity
eStyleSVGOpacitySource_ObjectFillOpacity,
eStyleSVGOpacitySource_ObjectStrokeOpacity
};
struct nsStyleSVGPaint

View File

@@ -77,7 +77,6 @@ MOCHITEST_FILES = test_acid3_test46.html \
test_bug716226.html \
test_bug765590.html \
test_bug798567.html \
test_bug798843_pref.html \
test_bug829816.html \
file_bug829816.css \
test_bug887741_at-rules_in_declaration_lists.html \

View File

@@ -3479,14 +3479,14 @@ var gCSSProperties = {
type: CSS_TYPE_LONGHAND,
prerequisites: { "color": "blue" },
initial_values: [ "black", "#000", "#000000", "rgb(0,0,0)", "rgba(0,0,0,1)" ],
other_values: [ "green", "#fc3", "url('#myserver')", "url(foo.svg#myserver)", 'url("#myserver") green', "none", "currentColor", "context-fill", "context-stroke" ],
other_values: [ "green", "#fc3", "url('#myserver')", "url(foo.svg#myserver)", 'url("#myserver") green', "none", "currentColor", "-moz-objectFill", "-moz-objectStroke" ],
invalid_values: [ "000000", "ff00ff" ]
},
"fill-opacity": {
domProp: "fillOpacity",
inherited: true,
type: CSS_TYPE_LONGHAND,
initial_values: [ "1", "2.8", "1.000", "context-fill-opacity", "context-stroke-opacity" ],
initial_values: [ "1", "2.8", "1.000", "-moz-objectFillOpacity", "-moz-objectStrokeOpacity" ],
other_values: [ "0", "0.3", "-7.3" ],
invalid_values: []
},
@@ -3611,14 +3611,14 @@ var gCSSProperties = {
inherited: true,
type: CSS_TYPE_LONGHAND,
initial_values: [ "none" ],
other_values: [ "black", "#000", "#000000", "rgb(0,0,0)", "rgba(0,0,0,1)", "green", "#fc3", "url('#myserver')", "url(foo.svg#myserver)", 'url("#myserver") green', "currentColor", "context-fill", "context-stroke" ],
other_values: [ "black", "#000", "#000000", "rgb(0,0,0)", "rgba(0,0,0,1)", "green", "#fc3", "url('#myserver')", "url(foo.svg#myserver)", 'url("#myserver") green', "currentColor", "-moz-objectFill", "-moz-objectStroke" ],
invalid_values: [ "000000", "ff00ff" ]
},
"stroke-dasharray": {
domProp: "strokeDasharray",
inherited: true,
type: CSS_TYPE_LONGHAND,
initial_values: [ "none", "context-value" ],
initial_values: [ "none", "-moz-objectValue" ],
other_values: [ "5px,3px,2px", "5px 3px 2px", " 5px ,3px , 2px ", "1px", "5%", "3em" ],
invalid_values: [ "-5px,3px,2px", "5px,3px,-2px" ]
},
@@ -3626,7 +3626,7 @@ var gCSSProperties = {
domProp: "strokeDashoffset",
inherited: true,
type: CSS_TYPE_LONGHAND,
initial_values: [ "0", "-0px", "0em", "context-value" ],
initial_values: [ "0", "-0px", "0em", "-moz-objectValue" ],
other_values: [ "3px", "3%", "1em" ],
invalid_values: []
},
@@ -3658,7 +3658,7 @@ var gCSSProperties = {
domProp: "strokeOpacity",
inherited: true,
type: CSS_TYPE_LONGHAND,
initial_values: [ "1", "2.8", "1.000", "context-fill-opacity", "context-stroke-opacity" ],
initial_values: [ "1", "2.8", "1.000", "-moz-objectFillOpacity", "-moz-objectStrokeOpacity" ],
other_values: [ "0", "0.3", "-7.3" ],
invalid_values: []
},
@@ -3666,7 +3666,7 @@ var gCSSProperties = {
domProp: "strokeWidth",
inherited: true,
type: CSS_TYPE_LONGHAND,
initial_values: [ "1px", "context-value" ],
initial_values: [ "1px", "-moz-objectValue" ],
other_values: [ "0", "0px", "-0em", "17px", "0.2em" ],
invalid_values: [ "-0.1px", "-3px" ]
},

View File

@@ -1,54 +0,0 @@
<!DOCTYPE HTML>
<html>
<!--
Make sure that the SVG glyph context-* values are not considered real values
when gfx.font_rendering.opentype_svg.enabled is pref'ed off.
-->
<head>
<title>Test that SVG glyph context-* values can be pref'ed off</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
</head>
<body>
<script>
var props = {
"fill" : "context-stroke none",
"stroke" : "context-fill none",
"fillOpacity" : "context-stroke-opacity",
"strokeOpacity" : "context-fill-opacity",
"strokeDasharray" : "context-value",
"strokeDashoffset" : "context-value",
"strokeWidth" : "context-value"
};
function testDisabled() {
for (var p in props) {
document.body.style[p] = props[p];
is(document.body.style[p], "", p + " not settable to " + props[p]);
document.body.style[p] = "";
}
}
function testEnabled() {
for (var p in props) {
document.body.style[p] = props[p];
is(document.body.style[p], props[p], p + " settable to " + props[p]);
document.body.style[p] = "";
}
SpecialPowers.pushPrefEnv(
{'set': [['gfx.font_rendering.opentype_svg.enabled', false]]},
testDisabled
);
}
SpecialPowers.pushPrefEnv(
{'set': [['gfx.font_rendering.opentype_svg.enabled', true]]},
testEnabled
);
</script>
</body>
</html>

View File

@@ -416,11 +416,11 @@ nsSVGGlyphFrame::PaintSVG(nsRenderingContext *aContext,
return NS_OK;
}
gfxTextContextPaint *outerContextPaint =
(gfxTextContextPaint*)aContext->GetUserData(&gfxTextContextPaint::sUserDataKey);
gfxTextObjectPaint *outerObjectPaint =
(gfxTextObjectPaint*)aContext->GetUserData(&gfxTextObjectPaint::sUserDataKey);
nsAutoPtr<gfxTextContextPaint> objectPaint;
DrawMode drawMode = SetupCairoState(gfx, outerContextPaint, getter_Transfers(objectPaint));
nsAutoPtr<gfxTextObjectPaint> objectPaint;
DrawMode drawMode = SetupCairoState(gfx, outerObjectPaint, getter_Transfers(objectPaint));
if (drawMode) {
DrawCharacters(&iter, gfx, drawMode, objectPaint);
@@ -587,7 +587,7 @@ void
nsSVGGlyphFrame::DrawCharacters(CharacterIterator *aIter,
gfxContext *aContext,
DrawMode aDrawMode,
gfxTextContextPaint *aContextPaint)
gfxTextObjectPaint *aObjectPaint)
{
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, aContextPaint);
mTextRun->GetLength(), nullptr, nullptr, aObjectPaint);
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, aContextPaint);
aIter->ClusterLength(), nullptr, nullptr, aObjectPaint);
}
}
@@ -929,17 +929,17 @@ nsSVGGlyphFrame::GetBaselineOffset(float aMetricsScale)
DrawMode
nsSVGGlyphFrame::SetupCairoState(gfxContext *aContext,
gfxTextContextPaint *aOuterContextPaint,
gfxTextContextPaint **aThisContextPaint)
gfxTextObjectPaint *aOuterObjectPaint,
gfxTextObjectPaint **aThisObjectPaint)
{
DrawMode toDraw = DrawMode(0);
SVGTextContextPaint *thisContextPaint = new SVGTextContextPaint();
SVGTextObjectPaint *thisObjectPaint = new SVGTextObjectPaint();
if (SetupCairoStroke(aContext, aOuterContextPaint, thisContextPaint)) {
if (SetupCairoStroke(aContext, aOuterObjectPaint, thisObjectPaint)) {
toDraw = DrawMode(toDraw | gfxFont::GLYPH_STROKE);
}
if (SetupCairoFill(aContext, aOuterContextPaint, thisContextPaint)) {
if (SetupCairoFill(aContext, aOuterObjectPaint, thisObjectPaint)) {
toDraw = DrawMode(toDraw | gfxFont::GLYPH_FILL);
}
@@ -957,55 +957,55 @@ nsSVGGlyphFrame::SetupCairoState(gfxContext *aContext,
paintOrder >>= NS_STYLE_PAINT_ORDER_BITWIDTH;
}
*aThisContextPaint = thisContextPaint;
*aThisObjectPaint = thisObjectPaint;
return toDraw;
}
bool
nsSVGGlyphFrame::SetupCairoStroke(gfxContext *aContext,
gfxTextContextPaint *aOuterContextPaint,
SVGTextContextPaint *aThisContextPaint)
gfxTextObjectPaint *aOuterObjectPaint,
SVGTextObjectPaint *aThisObjectPaint)
{
if (!nsSVGUtils::HasStroke(this, aOuterContextPaint)) {
if (!nsSVGUtils::HasStroke(this, aOuterObjectPaint)) {
return false;
}
const nsStyleSVG *style = StyleSVG();
nsSVGUtils::SetupCairoStrokeGeometry(this, aContext, aOuterContextPaint);
nsSVGUtils::SetupCairoStrokeGeometry(this, aContext, aOuterObjectPaint);
float opacity = nsSVGUtils::GetOpacity(style->mStrokeOpacitySource,
style->mStrokeOpacity,
aOuterContextPaint);
aOuterObjectPaint);
SetupInheritablePaint(aContext, opacity, aOuterContextPaint,
aThisContextPaint->mStrokePaint, &nsStyleSVG::mStroke,
SetupInheritablePaint(aContext, opacity, aOuterObjectPaint,
aThisObjectPaint->mStrokePaint, &nsStyleSVG::mStroke,
nsSVGEffects::StrokeProperty());
aThisContextPaint->SetStrokeOpacity(opacity);
aThisObjectPaint->SetStrokeOpacity(opacity);
return opacity != 0.0f;
}
bool
nsSVGGlyphFrame::SetupCairoFill(gfxContext *aContext,
gfxTextContextPaint *aOuterContextPaint,
SVGTextContextPaint *aThisContextPaint)
gfxTextObjectPaint *aOuterObjectPaint,
SVGTextObjectPaint *aThisObjectPaint)
{
const nsStyleSVG *style = StyleSVG();
if (style->mFill.mType == eStyleSVGPaintType_None) {
aThisContextPaint->SetFillOpacity(0.0f);
aThisObjectPaint->SetFillOpacity(0.0f);
return false;
}
float opacity = nsSVGUtils::GetOpacity(style->mFillOpacitySource,
style->mFillOpacity,
aOuterContextPaint);
aOuterObjectPaint);
SetupInheritablePaint(aContext, opacity, aOuterContextPaint,
aThisContextPaint->mFillPaint, &nsStyleSVG::mFill,
SetupInheritablePaint(aContext, opacity, aOuterObjectPaint,
aThisObjectPaint->mFillPaint, &nsStyleSVG::mFill,
nsSVGEffects::FillProperty());
aThisContextPaint->SetFillOpacity(opacity);
aThisObjectPaint->SetFillOpacity(opacity);
return true;
}
@@ -1013,8 +1013,8 @@ nsSVGGlyphFrame::SetupCairoFill(gfxContext *aContext,
void
nsSVGGlyphFrame::SetupInheritablePaint(gfxContext *aContext,
float& aOpacity,
gfxTextContextPaint *aOuterContextPaint,
SVGTextContextPaint::Paint& aTargetPaint,
gfxTextObjectPaint *aOuterObjectPaint,
SVGTextObjectPaint::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 (SetupContextPaint(aContext, aFillOrStroke, aOpacity, aOuterContextPaint)) {
aTargetPaint.SetContextPaint(aOuterContextPaint, (style->*aFillOrStroke).mType);
} else if (SetupObjectPaint(aContext, aFillOrStroke, aOpacity, aOuterObjectPaint)) {
aTargetPaint.SetObjectPaint(aOuterObjectPaint, (style->*aFillOrStroke).mType);
} else {
nscolor color = nsSVGUtils::GetFallbackOrPaintColor(aContext,
StyleContext(),
@@ -1043,12 +1043,12 @@ nsSVGGlyphFrame::SetupInheritablePaint(gfxContext *aContext,
}
bool
nsSVGGlyphFrame::SetupContextPaint(gfxContext *aContext,
nsSVGGlyphFrame::SetupObjectPaint(gfxContext *aContext,
nsStyleSVGPaint nsStyleSVG::*aFillOrStroke,
float& aOpacity,
gfxTextContextPaint *aOuterContextPaint)
gfxTextObjectPaint *aOuterObjectPaint)
{
if (!aOuterContextPaint) {
if (!aOuterObjectPaint) {
NS_WARNING("Outer object paint value used outside SVG glyph");
return false;
}
@@ -1056,16 +1056,16 @@ nsSVGGlyphFrame::SetupContextPaint(gfxContext *aContext,
const nsStyleSVG *style = StyleSVG();
const nsStyleSVGPaint &paint = style->*aFillOrStroke;
if (paint.mType != eStyleSVGPaintType_ContextFill &&
paint.mType != eStyleSVGPaintType_ContextStroke) {
if (paint.mType != eStyleSVGPaintType_ObjectFill &&
paint.mType != eStyleSVGPaintType_ObjectStroke) {
return false;
}
gfxMatrix current = aContext->CurrentMatrix();
nsRefPtr<gfxPattern> pattern =
paint.mType == eStyleSVGPaintType_ContextFill ?
aOuterContextPaint->GetFillPattern(aOpacity, current) :
aOuterContextPaint->GetStrokePattern(aOpacity, current);
paint.mType == eStyleSVGPaintType_ObjectFill ?
aOuterObjectPaint->GetFillPattern(aOpacity, current) :
aOuterObjectPaint->GetStrokePattern(aOpacity, current);
if (!pattern) {
return false;
}
@@ -1075,24 +1075,24 @@ nsSVGGlyphFrame::SetupContextPaint(gfxContext *aContext,
}
//----------------------------------------------------------------------
// SVGTextContextPaint methods:
// SVGTextObjectPaint methods:
already_AddRefed<gfxPattern>
mozilla::SVGTextContextPaint::GetFillPattern(float aOpacity,
mozilla::SVGTextObjectPaint::GetFillPattern(float aOpacity,
const gfxMatrix& aCTM)
{
return mFillPaint.GetPattern(aOpacity, &nsStyleSVG::mFill, aCTM);
}
already_AddRefed<gfxPattern>
mozilla::SVGTextContextPaint::GetStrokePattern(float aOpacity,
mozilla::SVGTextObjectPaint::GetStrokePattern(float aOpacity,
const gfxMatrix& aCTM)
{
return mStrokePaint.GetPattern(aOpacity, &nsStyleSVG::mStroke, aCTM);
}
already_AddRefed<gfxPattern>
mozilla::SVGTextContextPaint::Paint::GetPattern(float aOpacity,
mozilla::SVGTextObjectPaint::Paint::GetPattern(float aOpacity,
nsStyleSVGPaint nsStyleSVG::*aFillOrStroke,
const gfxMatrix& aCTM)
{
@@ -1132,14 +1132,14 @@ mozilla::SVGTextContextPaint::Paint::GetPattern(float aOpacity,
}
pattern->SetMatrix(aCTM * mPatternMatrix);
break;
case eStyleSVGPaintType_ContextFill:
pattern = mPaintDefinition.mContextPaint->GetFillPattern(aOpacity, aCTM);
// Don't cache this. mContextPaint will have cached it anyway. If we
case eStyleSVGPaintType_ObjectFill:
pattern = mPaintDefinition.mObjectPaint->GetFillPattern(aOpacity, aCTM);
// Don't cache this. mObjectPaint will have cached it anyway. If we
// cache it, we'll have to compute mPatternMatrix, which is annoying.
return pattern.forget();
case eStyleSVGPaintType_ContextStroke:
pattern = mPaintDefinition.mContextPaint->GetStrokePattern(aOpacity, aCTM);
// Don't cache this. mContextPaint will have cached it anyway. If we
case eStyleSVGPaintType_ObjectStroke:
pattern = mPaintDefinition.mObjectPaint->GetStrokePattern(aOpacity, aCTM);
// Don't cache this. mObjectPaint 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 gfxTextContextPaint;
class gfxTextObjectPaint;
struct CharacterPosition;
@@ -33,7 +33,7 @@ class SVGIRect;
}
// Slightly horrible callback for deferring application of opacity
struct SVGTextContextPaint : public gfxTextContextPaint {
struct SVGTextObjectPaint : public gfxTextObjectPaint {
already_AddRefed<gfxPattern> GetFillPattern(float aOpacity,
const gfxMatrix& aCTM) MOZ_OVERRIDE;
already_AddRefed<gfxPattern> GetStrokePattern(float aOpacity,
@@ -61,18 +61,18 @@ struct SVGTextContextPaint : public gfxTextContextPaint {
mPaintDefinition.mColor = aColor;
}
void SetContextPaint(gfxTextContextPaint *aContextPaint,
void SetObjectPaint(gfxTextObjectPaint *aObjectPaint,
nsStyleSVGPaintType aPaintType) {
NS_ASSERTION(aPaintType == eStyleSVGPaintType_ContextFill ||
aPaintType == eStyleSVGPaintType_ContextStroke,
"Invalid context paint type");
NS_ASSERTION(aPaintType == eStyleSVGPaintType_ObjectFill ||
aPaintType == eStyleSVGPaintType_ObjectStroke,
"Invalid object paint type");
mPaintType = aPaintType;
mPaintDefinition.mContextPaint = aContextPaint;
mPaintDefinition.mObjectPaint = aObjectPaint;
}
union {
nsSVGPaintServerFrame *mPaintServerFrame;
gfxTextContextPaint *mContextPaint;
gfxTextObjectPaint *mObjectPaint;
nscolor mColor;
} mPaintDefinition;
@@ -312,7 +312,7 @@ private:
void DrawCharacters(CharacterIterator *aIter,
gfxContext *aContext,
DrawMode aDrawMode,
gfxTextContextPaint *aContextPaint = nullptr);
gfxTextObjectPaint *aObjectPaint = nullptr);
void NotifyGlyphMetricsChange();
void SetupGlobalTransform(gfxContext *aContext, uint32_t aFor,
@@ -340,40 +340,40 @@ private:
private:
DrawMode SetupCairoState(gfxContext *aContext,
gfxTextContextPaint *aOuterContextPaint,
gfxTextContextPaint **aThisContextPaint);
gfxTextObjectPaint *aOuterObjectPaint,
gfxTextObjectPaint **aThisObjectPaint);
/**
* Sets up the stroke style in |aContext| and stores stroke pattern
* information in |aThisContextPaint|.
* information in |aThisObjectPaint|.
*/
bool SetupCairoStroke(gfxContext *aContext,
gfxTextContextPaint *aOuterContextPaint,
SVGTextContextPaint *aThisContextPaint);
gfxTextObjectPaint *aOuterObjectPaint,
SVGTextObjectPaint *aThisObjectPaint);
/**
* Sets up the fill style in |aContext| and stores fill pattern information
* in |aThisContextPaint|.
* in |aThisObjectPaint|.
*/
bool SetupCairoFill(gfxContext *aContext,
gfxTextContextPaint *aOuterContextPaint,
SVGTextContextPaint *aThisContextPaint);
gfxTextObjectPaint *aOuterObjectPaint,
SVGTextObjectPaint *aThisObjectPaint);
/**
* Sets the current pattern to the fill or stroke style of the outer text
* context. Will also set the paint opacity to transparent if the paint is set
* object. Will also set the paint opacity to transparent if the paint is set
* to "none".
*/
bool SetupContextPaint(gfxContext *aContext,
bool SetupObjectPaint(gfxContext *aContext,
nsStyleSVGPaint nsStyleSVG::*aFillOrStroke,
float& aOpacity,
gfxTextContextPaint *aContextPaint);
gfxTextObjectPaint *aObjectPaint);
/**
* 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 aOuterContextPaint pattern information from the outer text context
* @param aOuterObjectPaint pattern information from the outer text object
* @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,
gfxTextContextPaint *aOuterContextPaint,
SVGTextContextPaint::Paint& aTargetPaint,
gfxTextObjectPaint *aOuterObjectPaint,
SVGTextObjectPaint::Paint& aTargetPaint,
nsStyleSVGPaint nsStyleSVG::*aFillOrStroke,
const FramePropertyDescriptor *aProperty);

View File

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

View File

@@ -3525,13 +3525,13 @@ nsSVGTextFrame2::PaintSVG(nsRenderingContext* aContext,
SVGCharClipDisplayItem item(run);
// Set up the fill and stroke so that SVG glyphs can get painted correctly
// when they use context-fill etc.
// when they use -moz-objectFill values etc.
gfx->SetMatrix(initialMatrix);
gfxTextContextPaint *outerContextPaint =
(gfxTextContextPaint*)aContext->GetUserData(&gfxTextContextPaint::sUserDataKey);
gfxTextObjectPaint *outerObjectPaint =
(gfxTextObjectPaint*)aContext->GetUserData(&gfxTextObjectPaint::sUserDataKey);
nsAutoPtr<gfxTextContextPaint> contextPaint;
SetupCairoState(gfx, frame, outerContextPaint, getter_Transfers(contextPaint));
nsAutoPtr<gfxTextObjectPaint> objectPaint;
SetupCairoState(gfx, frame, outerObjectPaint, getter_Transfers(objectPaint));
// 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,
contextPaint, &callbacks);
objectPaint, &callbacks);
} else {
frame->PaintText(aContext, nsPoint(), frameRect, item,
contextPaint, nullptr);
objectPaint, nullptr);
}
if (frame == caretFrame && ShouldPaintCaret(run, caret)) {
@@ -5389,21 +5389,21 @@ nsSVGTextFrame2::TransformFrameRectFromTextChild(const nsRect& aRect,
gfxFont::DrawMode
nsSVGTextFrame2::SetupCairoState(gfxContext* aContext,
nsIFrame* aFrame,
gfxTextContextPaint* aOuterContextPaint,
gfxTextContextPaint** aThisContextPaint)
gfxTextObjectPaint* aOuterObjectPaint,
gfxTextObjectPaint** aThisObjectPaint)
{
gfxFont::DrawMode toDraw = gfxFont::DrawMode(0);
SVGTextContextPaint *thisContextPaint = new SVGTextContextPaint();
SVGTextObjectPaint *thisObjectPaint = new SVGTextObjectPaint();
if (SetupCairoStroke(aContext, aFrame, aOuterContextPaint, thisContextPaint)) {
if (SetupCairoStroke(aContext, aFrame, aOuterObjectPaint, thisObjectPaint)) {
toDraw = gfxFont::DrawMode(toDraw | gfxFont::GLYPH_STROKE);
}
if (SetupCairoFill(aContext, aFrame, aOuterContextPaint, thisContextPaint)) {
if (SetupCairoFill(aContext, aFrame, aOuterObjectPaint, thisObjectPaint)) {
toDraw = gfxFont::DrawMode(toDraw | gfxFont::GLYPH_FILL);
}
*aThisContextPaint = thisContextPaint;
*aThisObjectPaint = thisObjectPaint;
return toDraw;
}
@@ -5411,25 +5411,25 @@ nsSVGTextFrame2::SetupCairoState(gfxContext* aContext,
bool
nsSVGTextFrame2::SetupCairoStroke(gfxContext* aContext,
nsIFrame* aFrame,
gfxTextContextPaint* aOuterContextPaint,
SVGTextContextPaint* aThisContextPaint)
gfxTextObjectPaint* aOuterObjectPaint,
SVGTextObjectPaint* aThisObjectPaint)
{
const nsStyleSVG *style = aFrame->StyleSVG();
if (style->mStroke.mType == eStyleSVGPaintType_None) {
aThisContextPaint->SetStrokeOpacity(0.0f);
aThisObjectPaint->SetStrokeOpacity(0.0f);
return false;
}
nsSVGUtils::SetupCairoStrokeGeometry(aFrame, aContext, aOuterContextPaint);
nsSVGUtils::SetupCairoStrokeGeometry(aFrame, aContext, aOuterObjectPaint);
float opacity = nsSVGUtils::GetOpacity(style->mStrokeOpacitySource,
style->mStrokeOpacity,
aOuterContextPaint);
aOuterObjectPaint);
SetupInheritablePaint(aContext, aFrame, opacity, aOuterContextPaint,
aThisContextPaint->mStrokePaint, &nsStyleSVG::mStroke,
SetupInheritablePaint(aContext, aFrame, opacity, aOuterObjectPaint,
aThisObjectPaint->mStrokePaint, &nsStyleSVG::mStroke,
nsSVGEffects::StrokeProperty());
aThisContextPaint->SetStrokeOpacity(opacity);
aThisObjectPaint->SetStrokeOpacity(opacity);
return opacity != 0.0f;
}
@@ -5437,24 +5437,24 @@ nsSVGTextFrame2::SetupCairoStroke(gfxContext* aContext,
bool
nsSVGTextFrame2::SetupCairoFill(gfxContext* aContext,
nsIFrame* aFrame,
gfxTextContextPaint* aOuterContextPaint,
SVGTextContextPaint* aThisContextPaint)
gfxTextObjectPaint* aOuterObjectPaint,
SVGTextObjectPaint* aThisObjectPaint)
{
const nsStyleSVG *style = aFrame->StyleSVG();
if (style->mFill.mType == eStyleSVGPaintType_None) {
aThisContextPaint->SetFillOpacity(0.0f);
aThisObjectPaint->SetFillOpacity(0.0f);
return false;
}
float opacity = nsSVGUtils::GetOpacity(style->mFillOpacitySource,
style->mFillOpacity,
aOuterContextPaint);
aOuterObjectPaint);
SetupInheritablePaint(aContext, aFrame, opacity, aOuterContextPaint,
aThisContextPaint->mFillPaint, &nsStyleSVG::mFill,
SetupInheritablePaint(aContext, aFrame, opacity, aOuterObjectPaint,
aThisObjectPaint->mFillPaint, &nsStyleSVG::mFill,
nsSVGEffects::FillProperty());
aThisContextPaint->SetFillOpacity(opacity);
aThisObjectPaint->SetFillOpacity(opacity);
return true;
}
@@ -5463,8 +5463,8 @@ void
nsSVGTextFrame2::SetupInheritablePaint(gfxContext* aContext,
nsIFrame* aFrame,
float& aOpacity,
gfxTextContextPaint* aOuterContextPaint,
SVGTextContextPaint::Paint& aTargetPaint,
gfxTextObjectPaint* aOuterObjectPaint,
SVGTextObjectPaint::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 (SetupContextPaint(aContext, aFrame, aFillOrStroke, aOpacity, aOuterContextPaint)) {
aTargetPaint.SetContextPaint(aOuterContextPaint, (style->*aFillOrStroke).mType);
} else if (SetupObjectPaint(aContext, aFrame, aFillOrStroke, aOpacity, aOuterObjectPaint)) {
aTargetPaint.SetObjectPaint(aOuterObjectPaint, (style->*aFillOrStroke).mType);
} else {
nscolor color = nsSVGUtils::GetFallbackOrPaintColor(aContext,
aFrame->StyleContext(),
@@ -5492,29 +5492,29 @@ nsSVGTextFrame2::SetupInheritablePaint(gfxContext* aContext,
}
bool
nsSVGTextFrame2::SetupContextPaint(gfxContext* aContext,
nsSVGTextFrame2::SetupObjectPaint(gfxContext* aContext,
nsIFrame* aFrame,
nsStyleSVGPaint nsStyleSVG::*aFillOrStroke,
float& aOpacity,
gfxTextContextPaint* aOuterContextPaint)
gfxTextObjectPaint* aOuterObjectPaint)
{
if (!aOuterContextPaint) {
if (!aOuterObjectPaint) {
return false;
}
const nsStyleSVG *style = aFrame->StyleSVG();
const nsStyleSVGPaint &paint = style->*aFillOrStroke;
if (paint.mType != eStyleSVGPaintType_ContextFill &&
paint.mType != eStyleSVGPaintType_ContextStroke) {
if (paint.mType != eStyleSVGPaintType_ObjectFill &&
paint.mType != eStyleSVGPaintType_ObjectStroke) {
return false;
}
gfxMatrix current = aContext->CurrentMatrix();
nsRefPtr<gfxPattern> pattern =
paint.mType == eStyleSVGPaintType_ContextFill ?
aOuterContextPaint->GetFillPattern(aOpacity, current) :
aOuterContextPaint->GetStrokePattern(aOpacity, current);
paint.mType == eStyleSVGPaintType_ObjectFill ?
aOuterObjectPaint->GetFillPattern(aOpacity, current) :
aOuterObjectPaint->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 SVGTextContextPaint
#include "nsSVGGlyphFrame.h" // for SVGTextObjectPaint
#include "nsSVGTextContainerFrame.h"
class nsDisplaySVGText;
@@ -523,43 +523,43 @@ private:
gfxFont::DrawMode SetupCairoState(gfxContext* aContext,
nsIFrame* aFrame,
gfxTextContextPaint* aOuterContextPaint,
gfxTextContextPaint** aThisContextPaint);
gfxTextObjectPaint* aOuterObjectPaint,
gfxTextObjectPaint** aThisObjectPaint);
/**
* Sets up the stroke style for |aFrame| in |aContext| and stores stroke
* pattern information in |aThisContextPaint|.
* pattern information in |aThisObjectPaint|.
*/
bool SetupCairoStroke(gfxContext* aContext,
nsIFrame* aFrame,
gfxTextContextPaint* aOuterContextPaint,
SVGTextContextPaint* aThisContextPaint);
gfxTextObjectPaint* aOuterObjectPaint,
SVGTextObjectPaint* aThisObjectPaint);
/**
* Sets up the fill style for |aFrame| in |aContext| and stores fill pattern
* information in |aThisContextPaint|.
* information in |aThisObjectPaint|.
*/
bool SetupCairoFill(gfxContext* aContext,
nsIFrame* aFrame,
gfxTextContextPaint* aOuterContextPaint,
SVGTextContextPaint* aThisContextPaint);
gfxTextObjectPaint* aOuterObjectPaint,
SVGTextObjectPaint* aThisObjectPaint);
/**
* Sets the current pattern for |aFrame| to the fill or stroke style of the
* outer text context. Will also set the paint opacity to transparent if the
* outer text object. Will also set the paint opacity to transparent if the
* paint is set to "none".
*/
bool SetupContextPaint(gfxContext* aContext,
bool SetupObjectPaint(gfxContext* aContext,
nsIFrame* aFrame,
nsStyleSVGPaint nsStyleSVG::*aFillOrStroke,
float& aOpacity,
gfxTextContextPaint* aContextPaint);
gfxTextObjectPaint* aObjectPaint);
/**
* 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 aOuterContextPaint pattern information from the outer text context
* @param aOuterObjectPaint pattern information from the outer text object
* @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,
gfxTextContextPaint* aOuterContextPaint,
SVGTextContextPaint::Paint& aTargetPaint,
gfxTextObjectPaint* aOuterObjectPaint,
SVGTextObjectPaint::Paint& aTargetPaint,
nsStyleSVGPaint nsStyleSVG::*aFillOrStroke,
const FramePropertyDescriptor* aProperty);

View File

@@ -1436,8 +1436,8 @@ nsSVGUtils::GetFallbackOrPaintColor(gfxContext *aContext, nsStyleContext *aStyle
const nsStyleSVGPaint &paint = aStyleContext->StyleSVG()->*aFillOrStroke;
nsStyleContext *styleIfVisited = aStyleContext->GetStyleIfVisited();
bool isServer = paint.mType == eStyleSVGPaintType_Server ||
paint.mType == eStyleSVGPaintType_ContextFill ||
paint.mType == eStyleSVGPaintType_ContextStroke;
paint.mType == eStyleSVGPaintType_ObjectFill ||
paint.mType == eStyleSVGPaintType_ObjectStroke;
nscolor color = isServer ? paint.mFallbackColor : paint.mPaint.mColor;
if (styleIfVisited) {
const nsStyleSVGPaint &paintIfVisited =
@@ -1484,23 +1484,23 @@ MaybeOptimizeOpacity(nsIFrame *aFrame, float aFillOrStrokeOpacity)
}
/* static */ bool
nsSVGUtils::SetupContextPaint(gfxContext *aContext,
gfxTextContextPaint *aContextPaint,
nsSVGUtils::SetupObjectPaint(gfxContext *aContext,
gfxTextObjectPaint *aObjectPaint,
const nsStyleSVGPaint &aPaint,
float aOpacity)
{
nsRefPtr<gfxPattern> pattern;
if (!aContextPaint) {
if (!aObjectPaint) {
return false;
}
switch (aPaint.mType) {
case eStyleSVGPaintType_ContextFill:
pattern = aContextPaint->GetFillPattern(aOpacity, aContext->CurrentMatrix());
case eStyleSVGPaintType_ObjectFill:
pattern = aObjectPaint->GetFillPattern(aOpacity, aContext->CurrentMatrix());
break;
case eStyleSVGPaintType_ContextStroke:
pattern = aContextPaint->GetStrokePattern(aOpacity, aContext->CurrentMatrix());
case eStyleSVGPaintType_ObjectStroke:
pattern = aObjectPaint->GetStrokePattern(aOpacity, aContext->CurrentMatrix());
break;
default:
return false;
@@ -1517,7 +1517,7 @@ nsSVGUtils::SetupContextPaint(gfxContext *aContext,
bool
nsSVGUtils::SetupCairoFillPaint(nsIFrame *aFrame, gfxContext* aContext,
gfxTextContextPaint *aContextPaint)
gfxTextObjectPaint *aObjectPaint)
{
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,
aContextPaint));
aObjectPaint));
nsSVGPaintServerFrame *ps =
nsSVGEffects::GetPaintServer(aFrame, &style->mFill, nsSVGEffects::FillProperty());
if (ps && ps->SetupPaintServer(aContext, aFrame, &nsStyleSVG::mFill, opacity))
return true;
if (SetupContextPaint(aContext, aContextPaint, style->mFill, opacity)) {
if (SetupObjectPaint(aContext, aObjectPaint, style->mFill, opacity)) {
return true;
}
@@ -1552,7 +1552,7 @@ nsSVGUtils::SetupCairoFillPaint(nsIFrame *aFrame, gfxContext* aContext,
bool
nsSVGUtils::SetupCairoStrokePaint(nsIFrame *aFrame, gfxContext* aContext,
gfxTextContextPaint *aContextPaint)
gfxTextObjectPaint *aObjectPaint)
{
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,
aContextPaint));
aObjectPaint));
nsSVGPaintServerFrame *ps =
nsSVGEffects::GetPaintServer(aFrame, &style->mStroke, nsSVGEffects::StrokeProperty());
if (ps && ps->SetupPaintServer(aContext, aFrame, &nsStyleSVG::mStroke, opacity))
return true;
if (SetupContextPaint(aContext, aContextPaint, style->mStroke, opacity)) {
if (SetupObjectPaint(aContext, aObjectPaint, style->mStroke, opacity)) {
return true;
}
@@ -1584,25 +1584,25 @@ nsSVGUtils::SetupCairoStrokePaint(nsIFrame *aFrame, gfxContext* aContext,
/* static */ float
nsSVGUtils::GetOpacity(nsStyleSVGOpacitySource aOpacityType,
const float& aOpacity,
gfxTextContextPaint *aOuterContextPaint)
gfxTextObjectPaint *aOuterObjectPaint)
{
float opacity = 1.0f;
switch (aOpacityType) {
case eStyleSVGOpacitySource_Normal:
opacity = aOpacity;
break;
case eStyleSVGOpacitySource_ContextFillOpacity:
if (aOuterContextPaint) {
opacity = aOuterContextPaint->GetFillOpacity();
case eStyleSVGOpacitySource_ObjectFillOpacity:
if (aOuterObjectPaint) {
opacity = aOuterObjectPaint->GetFillOpacity();
} else {
NS_WARNING("context-fill-opacity used outside of an SVG glyph");
NS_WARNING("objectFillOpacity used outside of an SVG glyph");
}
break;
case eStyleSVGOpacitySource_ContextStrokeOpacity:
if (aOuterContextPaint) {
opacity = aOuterContextPaint->GetStrokeOpacity();
case eStyleSVGOpacitySource_ObjectStrokeOpacity:
if (aOuterObjectPaint) {
opacity = aOuterObjectPaint->GetStrokeOpacity();
} else {
NS_WARNING("context-stroke-opacity used outside of an SVG glyph");
NS_WARNING("objectStrokeOpacity used outside of an SVG glyph");
}
break;
default:
@@ -1612,20 +1612,20 @@ nsSVGUtils::GetOpacity(nsStyleSVGOpacitySource aOpacityType,
}
bool
nsSVGUtils::HasStroke(nsIFrame* aFrame, gfxTextContextPaint *aContextPaint)
nsSVGUtils::HasStroke(nsIFrame* aFrame, gfxTextObjectPaint *aObjectPaint)
{
const nsStyleSVG *style = aFrame->StyleSVG();
return style->mStroke.mType != eStyleSVGPaintType_None &&
style->mStrokeOpacity > 0 &&
GetStrokeWidth(aFrame, aContextPaint) > 0;
GetStrokeWidth(aFrame, aObjectPaint) > 0;
}
float
nsSVGUtils::GetStrokeWidth(nsIFrame* aFrame, gfxTextContextPaint *aContextPaint)
nsSVGUtils::GetStrokeWidth(nsIFrame* aFrame, gfxTextObjectPaint *aObjectPaint)
{
const nsStyleSVG *style = aFrame->StyleSVG();
if (aContextPaint && style->mStrokeWidthFromObject) {
return aContextPaint->GetStrokeWidth();
if (aObjectPaint && style->mStrokeWidthFromObject) {
return aObjectPaint->GetStrokeWidth();
}
nsIContent* content = aFrame->GetContent();
@@ -1642,9 +1642,9 @@ nsSVGUtils::GetStrokeWidth(nsIFrame* aFrame, gfxTextContextPaint *aContextPaint)
void
nsSVGUtils::SetupCairoStrokeBBoxGeometry(nsIFrame* aFrame,
gfxContext *aContext,
gfxTextContextPaint *aContextPaint)
gfxTextObjectPaint *aObjectPaint)
{
float width = GetStrokeWidth(aFrame, aContextPaint);
float width = GetStrokeWidth(aFrame, aObjectPaint);
if (width <= 0)
return;
aContext->SetLineWidth(width);
@@ -1685,7 +1685,7 @@ static bool
GetStrokeDashData(nsIFrame* aFrame,
FallibleTArray<gfxFloat>& aDashes,
gfxFloat* aDashOffset,
gfxTextContextPaint *aContextPaint)
gfxTextObjectPaint *aObjectPaint)
{
const nsStyleSVG* style = aFrame->StyleSVG();
nsPresContext *presContext = aFrame->PresContext();
@@ -1695,8 +1695,8 @@ GetStrokeDashData(nsIFrame* aFrame,
content->GetParent() : content);
gfxFloat totalLength = 0.0;
if (aContextPaint && style->mStrokeDasharrayFromObject) {
aDashes = aContextPaint->GetStrokeDashArray();
if (aObjectPaint && style->mStrokeDasharrayFromObject) {
aDashes = aObjectPaint->GetStrokeDashArray();
for (uint32_t i = 0; i < aDashes.Length(); i++) {
if (aDashes[i] < 0.0) {
@@ -1734,8 +1734,8 @@ GetStrokeDashData(nsIFrame* aFrame,
}
}
if (aContextPaint && style->mStrokeDashoffsetFromObject) {
*aDashOffset = aContextPaint->GetStrokeDashOffset();
if (aObjectPaint && style->mStrokeDashoffsetFromObject) {
*aDashOffset = aObjectPaint->GetStrokeDashOffset();
} else {
*aDashOffset = nsSVGUtils::CoordToFloat(presContext,
ctx,
@@ -1747,13 +1747,13 @@ GetStrokeDashData(nsIFrame* aFrame,
void
nsSVGUtils::SetupCairoStrokeGeometry(nsIFrame* aFrame, gfxContext* aContext,
gfxTextContextPaint *aContextPaint)
gfxTextObjectPaint *aObjectPaint)
{
SetupCairoStrokeBBoxGeometry(aFrame, aContext, aContextPaint);
SetupCairoStrokeBBoxGeometry(aFrame, aContext, aObjectPaint);
AutoFallibleTArray<gfxFloat, 10> dashes;
gfxFloat dashOffset;
if (GetStrokeDashData(aFrame, dashes, &dashOffset, aContextPaint)) {
if (GetStrokeDashData(aFrame, dashes, &dashOffset, aObjectPaint)) {
aContext->SetDash(dashes.Elements(), dashes.Length(), dashOffset);
}
}
@@ -1819,20 +1819,20 @@ nsSVGUtils::GetGeometryHitTestFlags(nsIFrame* aFrame)
bool
nsSVGUtils::SetupCairoStroke(nsIFrame* aFrame, gfxContext* aContext,
gfxTextContextPaint *aContextPaint)
gfxTextObjectPaint *aObjectPaint)
{
if (!HasStroke(aFrame, aContextPaint)) {
if (!HasStroke(aFrame, aObjectPaint)) {
return false;
}
SetupCairoStrokeGeometry(aFrame, aContext, aContextPaint);
SetupCairoStrokeGeometry(aFrame, aContext, aObjectPaint);
return SetupCairoStrokePaint(aFrame, aContext, aContextPaint);
return SetupCairoStrokePaint(aFrame, aContext, aObjectPaint);
}
bool
nsSVGUtils::PaintSVGGlyph(Element* aElement, gfxContext* aContext,
gfxFont::DrawMode aDrawMode,
gfxTextContextPaint* aContextPaint)
gfxTextObjectPaint* aObjectPaint)
{
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(&gfxTextContextPaint::sUserDataKey, aContextPaint, nullptr);
context.AddUserData(&gfxTextObjectPaint::sUserDataKey, aObjectPaint, 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 gfxTextContextPaint;
class gfxTextObjectPaint;
struct nsStyleSVG;
struct nsStyleSVGPaint;
@@ -608,8 +608,8 @@ public:
/**
* Set up cairo context with an object pattern
*/
static bool SetupContextPaint(gfxContext *aContext,
gfxTextContextPaint *aContextPaint,
static bool SetupObjectPaint(gfxContext *aContext,
gfxTextObjectPaint *aObjectPaint,
const nsStyleSVGPaint& aPaint,
float aOpacity);
@@ -618,48 +618,48 @@ public:
* for the given frame.
*/
static bool SetupCairoFillPaint(nsIFrame* aFrame, gfxContext* aContext,
gfxTextContextPaint *aContextPaint = nullptr);
gfxTextObjectPaint *aObjectPaint = 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,
gfxTextContextPaint *aContextPaint = nullptr);
gfxTextObjectPaint *aObjectPaint = nullptr);
static float GetOpacity(nsStyleSVGOpacitySource aOpacityType,
const float& aOpacity,
gfxTextContextPaint *aOuterContextPaint);
gfxTextObjectPaint *aOuterObjectPaint);
/*
* @return false if there is no stroke
*/
static bool HasStroke(nsIFrame* aFrame,
gfxTextContextPaint *aContextPaint = nullptr);
gfxTextObjectPaint *aObjectPaint = nullptr);
static float GetStrokeWidth(nsIFrame* aFrame,
gfxTextContextPaint *aContextPaint = nullptr);
gfxTextObjectPaint *aObjectPaint = nullptr);
/*
* Set up a cairo context for measuring the bounding box of a stroked path.
*/
static void SetupCairoStrokeBBoxGeometry(nsIFrame* aFrame,
gfxContext *aContext,
gfxTextContextPaint *aContextPaint = nullptr);
gfxTextObjectPaint *aObjectPaint = nullptr);
/*
* Set up a cairo context for a stroked path (including any dashing that
* applies).
*/
static void SetupCairoStrokeGeometry(nsIFrame* aFrame, gfxContext *aContext,
gfxTextContextPaint *aContextPaint = nullptr);
gfxTextObjectPaint *aObjectPaint = 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,
gfxTextContextPaint *aContextPaint = nullptr);
gfxTextObjectPaint *aObjectPaint = 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,
gfxTextContextPaint* aContextPaint);
gfxTextObjectPaint* aObjectPaint);
/**
* Get the extents of a SVG glyph.
* @param aElement the SVG glyph element