Back out 4d755ea39a56:81d152795bea (bug 798843) for style mochitest failures

This commit is contained in:
Phil Ringnalda 2013-05-15 20:53:30 -07:00
Родитель 125967cb7d
Коммит 95ddec5edc
31 изменённых файлов: 381 добавлений и 497 удалений

Просмотреть файл

@ -231,11 +231,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
@ -1905,7 +1905,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
@ -1926,13 +1926,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());
}
@ -1945,7 +1945,7 @@ struct GlyphBuffer {
}
if ((aDrawMode & (gfxFont::GLYPH_STROKE | gfxFont::GLYPH_STROKE_UNDERNEATH)) ==
gfxFont::GLYPH_STROKE) {
FlushStroke(aCR, aContextPaint, aGlobalMatrix);
FlushStroke(aCR, aObjectPaint, aGlobalMatrix);
}
}
@ -1953,11 +1953,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());
}
@ -1999,7 +1999,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)
@ -2022,15 +2022,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 {
@ -2087,21 +2087,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);
}
@ -2149,7 +2149,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),
@ -2166,14 +2166,14 @@ gfxFont::Draw(gfxTextRun *aTextRun, uint32_t aStart, uint32_t aEnd,
gfxMatrix globalMatrix = aContext->CurrentMatrix();
bool haveSVGGlyphs = GetFontEntry()->TryGetSVGData();
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
@ -2230,7 +2230,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;
}
@ -2245,7 +2245,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)
@ -2261,7 +2261,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;
@ -2308,7 +2308,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;
}
@ -2318,7 +2318,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;
@ -2333,7 +2333,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;
@ -2362,7 +2362,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();
}
@ -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;
}
@ -2461,7 +2461,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);
@ -2481,7 +2481,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);
@ -2531,7 +2531,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;
}
@ -2542,7 +2542,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);
@ -2560,7 +2560,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);
@ -2580,7 +2580,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) {
@ -2597,7 +2597,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;
@ -2609,15 +2609,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)
{
@ -2629,7 +2629,7 @@ gfxFont::RenderSVGGlyph(gfxContext *aContext, gfxPoint aPoint, DrawMode aDrawMod
aCallbacks->NotifyBeforeSVGGlyphPainted();
}
bool rendered = RenderSVGGlyph(aContext, aPoint, aDrawMode, aGlyphId,
aContextPaint);
aObjectPaint);
if (aCallbacks) {
aCallbacks->NotifyAfterSVGGlyphPainted();
}
@ -5441,7 +5441,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,
@ -5451,7 +5451,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);
}
@ -5592,7 +5592,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");
@ -5650,7 +5650,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);

Просмотреть файл

@ -46,7 +46,7 @@ class gfxUserFontData;
class gfxShapedText;
class gfxShapedWord;
class gfxSVGGlyphs;
class gfxTextContextPaint;
class gfxTextObjectPaint;
class nsILanguageAtomService;
@ -313,7 +313,7 @@ public:
bool GetSVGGlyphExtents(gfxContext *aContext, uint32_t aGlyphId,
gfxRect *aResult);
bool RenderSVGGlyph(gfxContext *aContext, uint32_t aGlyphId, int aDrawMode,
gfxTextContextPaint *aContextPaint);
gfxTextObjectPaint *aObjectPaint);
virtual bool MatchesGenericFamily(const nsACString& aGeneric) const {
return true;
@ -1438,7 +1438,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 NULL if we are not stroking the text, which
* indicates that the current source from aContext should be used for filling
*
@ -1451,7 +1451,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);
/**
@ -1852,9 +1852,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);
@ -2708,7 +2708,7 @@ public:
gfxFont::DrawMode aDrawMode,
uint32_t aStart, uint32_t aLength,
PropertyProvider *aProvider,
gfxFloat *aAdvanceWidth, gfxTextContextPaint *aContextPaint,
gfxFloat *aAdvanceWidth, gfxTextObjectPaint *aObjectPaint,
gfxTextRunDrawCallbacks *aCallbacks = nullptr);
/**
@ -3135,7 +3135,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);

Просмотреть файл

@ -66,11 +66,11 @@
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(FallibleTArray<uint8_t>& aSVGTable,
const FallibleTArray<uint8_t>& aCmapTable)
@ -218,7 +218,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;
@ -229,7 +229,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
@ -409,8 +409,6 @@ gfxSVGGlyphsDocument::InsertGlyphId(Element *aGlyphElement)
}
mGlyphIdMap.Put(glyphId, aGlyphElement);
printf("Inserted glyph ID %d", (int)glyphId);
}
void
@ -449,12 +447,10 @@ gfxSVGGlyphsDocument::InsertGlyphChar(Element *aGlyphElement,
if (glyphId) {
mGlyphIdMap.Put(glyphId, aGlyphElement);
}
printf("Inserted glyph char %d", (int)glyphId);
}
void
gfxTextContextPaint::InitStrokeGeometry(gfxContext *aContext,
gfxTextObjectPaint::InitStrokeGeometry(gfxContext *aContext,
float devUnitsPerSVGUnit)
{
mStrokeWidth = aContext->CurrentLineWidth() / devUnitsPerSVGUnit;

Просмотреть файл

@ -137,11 +137,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|
@ -177,17 +177,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.
*/
@ -222,7 +223,7 @@ public:
return GetStrokePattern(GetStrokeOpacity(), aCTM);
}
virtual ~gfxTextContextPaint() { }
virtual ~gfxTextObjectPaint() { }
private:
FallibleTArray<gfxFloat> mDashes;
@ -231,10 +232,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;
@ -251,7 +252,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))

Просмотреть файл

@ -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
@ -885,7 +885,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
@ -915,8 +915,8 @@ static inline mozilla::css::Side operator++(mozilla::css::Side& side, int) {
#define NS_STYLE_TRANSFORM_STYLE_PRESERVE_3D 1
// object {fill,stroke}-opacity for SVG glyphs
#define NS_STYLE_CONTEXT_FILL_OPACITY 0
#define NS_STYLE_CONTEXT_STROKE_OPACITY 1
#define NS_STYLE_OBJECT_FILL_OPACITY 0
#define NS_STYLE_OBJECT_STROKE_OPACITY 1
/*****************************************************************************
* Constants for media features. *

Просмотреть файл

@ -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.

Просмотреть файл

@ -5496,7 +5496,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");
@ -5710,7 +5710,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*
@ -5753,7 +5753,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;
}
@ -5782,7 +5782,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
@ -5793,7 +5793,7 @@ DrawTextRun(gfxTextRun* aTextRun,
PropertyProvider* aProvider,
nscolor aTextColor,
gfxFloat* aAdvanceWidth,
gfxTextContextPaint* aContextPaint,
gfxTextObjectPaint* aObjectPaint,
nsTextFrame::DrawPathCallbacks* aCallbacks)
{
gfxFont::DrawMode drawMode = aCallbacks ? gfxFont::GLYPH_PATH :
@ -5801,12 +5801,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);
}
}
@ -5818,11 +5818,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,
@ -5836,7 +5836,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);
}
}
}
@ -5854,7 +5854,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();
@ -5919,7 +5919,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; ) {
@ -5955,7 +5955,7 @@ nsTextFrame::DrawText(
gfxFloat& aAdvanceWidth,
bool aDrawSoftHyphen,
const nscolor* const aDecorationOverrideColor,
gfxTextContextPaint* aContextPaint,
gfxTextObjectPaint* aObjectPaint,
nsTextFrame::DrawPathCallbacks* aCallbacks)
{
TextDecorations decorations;
@ -5970,10 +5970,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);
}
}

Просмотреть файл

@ -1,5 +1,5 @@
pref(gfx.font_rendering.opentype_svg.enabled,true) == svg-glyph-basic.svg svg-glyph-basic-ref.svg
pref(gfx.font_rendering.opentype_svg.enabled,false) != svg-glyph-basic.svg svg-glyph-basic-ref.svg
pref(gfx.font_rendering.opentype_svg.enabled,true) == svg-glyph-basic.svg svg-glyph-basic-ref.svg
pref(gfx.font_rendering.opentype_svg.enabled,false) != svg-glyph-positioning.svg svg-glyph-positioning-ref.svg
pref(gfx.font_rendering.opentype_svg.enabled,true) == svg-glyph-positioning.svg svg-glyph-positioning-ref.svg
pref(gfx.font_rendering.opentype_svg.enabled,true) == svg-glyph-html.html svg-glyph-html-ref.svg

Просмотреть файл

@ -1,42 +0,0 @@
.woff files
===========
There are three .woff files in this directory:
* svg.woff
* nosvg.woff
* rubbish.woff
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.
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.
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
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.
A tool for creating the rubbish font can also be found at [1]; named
`insertrubbish.py`. rubbish.woff can be created with:
woff2sfnt nosvg.woff > nosvg.ttf
insertsvg.py nosvg.ttf rubbish.ttf rubbish.txt
sfnt2woff rubbish.ttf
[1] https://github.com/edf825/SVG-OpenType-Utils
[2] http://people.mozilla.com/~jkew/woff/

Просмотреть файл

@ -6,19 +6,19 @@
<!-- -moz-objectfill, no stroke -->
<!-- N -->
<rect x="100" y="-900" width="800" height="800" stroke-width="50"
stroke="none" fill="context-fill" glyphchar="N"/>
stroke="none" fill="-moz-objectFill" glyphchar="N"/>
<!-- O -->
<rect x="50" y="-950" width="900" height="900" stroke-width="100"
fill="context-fill" stroke="none" glyphchar="O"/>
fill="-moz-objectFill" stroke="none" glyphchar="O"/>
<!-- -moz-objectstroke -->
<!-- P -->
<rect x="100" y="-900" width="800" height="800" stroke-width="50"
stroke="context-stroke" fill="burlywood" glyphchar="P"/>
stroke="-moz-objectStroke" fill="burlywood" glyphchar="P"/>
<!-- 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" glyphchar="Q"/>
fill="-moz-objectStroke" stroke="-moz-objectFill" glyphchar="Q"/>
</svg>

До

Ширина:  |  Высота:  |  Размер: 831 B

После

Ширина:  |  Высота:  |  Размер: 846 B

Просмотреть файл

@ -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" glyphchar="R"/>
fill="-moz-objectFill" stroke="-moz-objectStroke"
fill-opacity="-moz-objectFillOpacity"
stroke-opacity="-moz-objectStrokeOpacity" glyphchar="R"/>
<!-- 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" glyphchar="S"/>
fill="-moz-objectFill" stroke="-moz-objectStroke"
fill-opacity="-moz-objectStrokeOpacity"
stroke-opacity="-moz-objectFillOpacity" glyphchar="S"/>
<!-- 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" glyphchar="T"/>
fill="-moz-objectStroke" stroke="-moz-objectFill"
fill-opacity="-moz-objectFillOpacity"
stroke-opacity="-moz-objectStrokeOpacity" glyphchar="T"/>
<!-- 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" glyphchar="U"/>
</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" glyphchar="W"/>
fill-opacity="-moz-objectFillOpacity"
stroke-opacity="-moz-objectStrokeOpacity" glyphchar="W"/>
<!-- 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" glyphchar="X"/>
fill-opacity="-moz-objectStrokeOpacity"
stroke-opacity="-moz-objectFillOpacity" glyphchar="X"/>
<style type="text/css"><![CDATA[
#yparent {
fill-opacity : context-fill-opacity;
stroke-opacity : context-stroke-opacity;
fill-opacity : -moz-objectFillOpacity;
stroke-opacity : -moz-objectStrokeOpacity;
}
#ychild {
color-interpolation : sRGB;

До

Ширина:  |  Высота:  |  Размер: 2.1 KiB

После

Ширина:  |  Высота:  |  Размер: 2.2 KiB

Просмотреть файл

@ -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" glyphchar="b" />
stroke-dasharray="-moz-objectValue" glyphchar="b" />
<!-- c -->
<rect x="100" y="-900" width="800" height="800" stroke="sienna"
stroke-width="50" stroke-dasharray="50 50"
stroke-dashoffset="context-value" glyphchar="c" />
stroke-dashoffset="-moz-objectValue" glyphchar="c" />
<!-- d -->
<rect x="100" y="-900" width="800" height="800" stroke="olivedrab"
stroke-width="context-value" stroke-dasharray="context-value"
stroke-dashoffset="context-value" glyphchar="d" />
stroke-width="-moz-objectValue" stroke-dasharray="-moz-objectValue"
stroke-dashoffset="-moz-objectValue" glyphchar="d" />
</svg>

До

Ширина:  |  Высота:  |  Размер: 904 B

После

Ширина:  |  Высота:  |  Размер: 919 B

Двоичный файл не отображается.

Просмотреть файл

@ -124,6 +124,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)
@ -214,12 +219,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(copy, copy)
CSS_KEY(contextual, contextual)

Просмотреть файл

@ -77,8 +77,6 @@ using namespace mozilla;
#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)
@ -5005,8 +5003,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
@ -5156,18 +5153,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)) {
@ -10666,10 +10651,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;
}
@ -10696,10 +10679,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;

Просмотреть файл

@ -3292,7 +3292,7 @@ CSS_PROP_SVG(
CSS_PROPERTY_PARSE_FUNCTION,
"",
0,
kContextPatternKTable,
kObjectPatternKTable,
offsetof(nsStyleSVG, mFill),
eStyleAnimType_PaintServer)
CSS_PROP_SVG(
@ -3301,8 +3301,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(
@ -3458,7 +3458,7 @@ CSS_PROP_SVG(
CSS_PROPERTY_PARSE_FUNCTION,
"",
0,
kContextPatternKTable,
kObjectPatternKTable,
offsetof(nsStyleSVG, mStroke),
eStyleAnimType_PaintServer)
CSS_PROP_SVG(
@ -3470,7 +3470,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(
@ -3479,8 +3479,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(
@ -3520,8 +3520,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(
@ -3531,8 +3531,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(

Просмотреть файл

@ -769,7 +769,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,
@ -1229,15 +1229,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
};
@ -1673,8 +1673,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
};

Просмотреть файл

@ -374,7 +374,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[];
@ -421,8 +421,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[];

Просмотреть файл

@ -4155,14 +4155,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;
}
}

Просмотреть файл

@ -7327,11 +7327,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");
@ -7363,11 +7363,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");
@ -7387,10 +7387,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;
@ -7430,13 +7430,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(),
@ -7523,7 +7522,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:
@ -7550,7 +7549,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;
@ -7605,7 +7604,7 @@ 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.SetIntValue(0, eStyleUnit_Integer);
} else {
@ -7634,18 +7633,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));

Просмотреть файл

@ -3139,11 +3139,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(),

Просмотреть файл

@ -2157,14 +2157,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

Просмотреть файл

@ -84,7 +84,6 @@ MOCHITEST_FILES = test_acid3_test46.html \
test_bug716226.html \
test_bug765590.html \
test_bug798567.html \
test_bug798843_pref.html \
test_cascade.html \
test_ch_ex_no_infloops.html \
test_compute_data_with_start_struct.html \

Просмотреть файл

@ -1,50 +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"
};
var origPref = SpecialPowers.getBoolPref("gfx.font_rendering.opentype_svg.enabled");
SpecialPowers.setBoolPref("gfx.font_rendering.opentype_svg.enabled", true);
for (var prop in props) {
document.body.style[prop] = props[prop];
is(document.body.style[prop], props[prop],
prop + " settable to " + props[prop]);
document.body.style[prop] = "";
}
SpecialPowers.setBoolPref("gfx.font_rendering.opentype_svg.enabled", false);
for (var prop in props) {
document.body.style[prop] = props[prop];
is(document.body.style[prop], "",
prop + " not settable to " + props[prop]);
document.body.style[prop] = "";
}
SpecialPowers.setBoolPref("gfx.font_rendering.opentype_svg.enabled", origPref);
</script>
</body>
</html>

Просмотреть файл

@ -420,11 +420,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);
@ -591,7 +591,7 @@ void
nsSVGGlyphFrame::DrawCharacters(CharacterIterator *aIter,
gfxContext *aContext,
DrawMode aDrawMode,
gfxTextContextPaint *aContextPaint)
gfxTextObjectPaint *aObjectPaint)
{
if (aDrawMode & gfxFont::GLYPH_STROKE) {
aIter->SetLineWidthAndDashesForDrawing(aContext);
@ -599,7 +599,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;
}
@ -607,7 +607,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);
}
}
@ -932,17 +932,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);
}
@ -960,55 +960,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::SetupCairoStrokeHitGeometry(this, aContext, aOuterContextPaint);
nsSVGUtils::SetupCairoStrokeHitGeometry(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;
}
@ -1016,8 +1016,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)
{
@ -1027,8 +1027,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(),
@ -1046,12 +1046,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;
}
@ -1059,16 +1059,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;
}
@ -1078,24 +1078,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)
{
@ -1135,14 +1135,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:

Просмотреть файл

@ -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);
already_AddRefed<gfxPattern> GetStrokePattern(float aOpacity,
@ -63,18 +63,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);
@ -339,40 +339,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
@ -380,8 +380,8 @@ private:
*/
void SetupInheritablePaint(gfxContext *aContext,
float& aOpacity,
gfxTextContextPaint *aOuterContextPaint,
SVGTextContextPaint::Paint& aTargetPaint,
gfxTextObjectPaint *aOuterObjectPaint,
SVGTextObjectPaint::Paint& aTargetPaint,
nsStyleSVGPaint nsStyleSVG::*aFillOrStroke,
const FramePropertyDescriptor *aProperty);

Просмотреть файл

@ -585,16 +585,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();
}
@ -628,14 +628,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*>

Просмотреть файл

@ -3349,13 +3349,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.
@ -3370,10 +3370,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)) {
@ -5159,21 +5159,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;
}
@ -5181,28 +5181,28 @@ 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;
}
gfxContextMatrixAutoSaveRestore matrixRestore(aContext);
aContext->IdentityMatrix();
nsSVGUtils::SetupCairoStrokeHitGeometry(aFrame, aContext, aOuterContextPaint);
nsSVGUtils::SetupCairoStrokeHitGeometry(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;
}
@ -5210,24 +5210,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;
}
@ -5236,8 +5236,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)
{
@ -5247,8 +5247,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(),
@ -5263,29 +5263,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;
}

Просмотреть файл

@ -11,7 +11,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;
@ -515,43 +515,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
@ -560,8 +560,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);

Просмотреть файл

@ -1532,8 +1532,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 =
@ -1580,23 +1580,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;
@ -1613,7 +1613,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)
@ -1627,13 +1627,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;
}
@ -1648,7 +1648,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)
@ -1657,14 +1657,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;
}
@ -1680,48 +1680,48 @@ 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:
NS_NOTREACHED("Unknown context opacity inheritance type for SVG glyph");
NS_NOTREACHED("Unknown object opacity inheritance type for SVG glyph");
}
return opacity;
}
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();
@ -1737,9 +1737,9 @@ nsSVGUtils::GetStrokeWidth(nsIFrame* aFrame, gfxTextContextPaint *aContextPaint)
void
nsSVGUtils::SetupCairoStrokeGeometry(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);
@ -1780,7 +1780,7 @@ static bool
GetStrokeDashData(nsIFrame* aFrame,
FallibleTArray<gfxFloat>& aDashes,
gfxFloat* aDashOffset,
gfxTextContextPaint *aContextPaint)
gfxTextObjectPaint *aObjectPaint)
{
const nsStyleSVG* style = aFrame->StyleSVG();
nsPresContext *presContext = aFrame->PresContext();
@ -1790,8 +1790,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) {
@ -1829,8 +1829,8 @@ GetStrokeDashData(nsIFrame* aFrame,
}
}
if (aContextPaint && style->mStrokeDashoffsetFromObject) {
*aDashOffset = aContextPaint->GetStrokeDashOffset();
if (aObjectPaint && style->mStrokeDashoffsetFromObject) {
*aDashOffset = aObjectPaint->GetStrokeDashOffset();
} else {
*aDashOffset = nsSVGUtils::CoordToFloat(presContext,
ctx,
@ -1846,13 +1846,13 @@ GetStrokeDashData(nsIFrame* aFrame,
void
nsSVGUtils::SetupCairoStrokeHitGeometry(nsIFrame* aFrame, gfxContext* aContext,
gfxTextContextPaint *aContextPaint)
gfxTextObjectPaint *aObjectPaint)
{
SetupCairoStrokeGeometry(aFrame, aContext, aContextPaint);
SetupCairoStrokeGeometry(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);
}
}
@ -1918,20 +1918,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;
}
SetupCairoStrokeHitGeometry(aFrame, aContext, aContextPaint);
SetupCairoStrokeHitGeometry(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);
@ -1939,7 +1939,7 @@ nsSVGUtils::PaintSVGGlyph(Element* aElement, gfxContext* aContext,
if (svgFrame) {
nsRenderingContext context;
context.Init(frame->PresContext()->DeviceContext(), aContext);
context.AddUserData(&gfxTextContextPaint::sUserDataKey, aContextPaint, nullptr);
context.AddUserData(&gfxTextObjectPaint::sUserDataKey, aObjectPaint, nullptr);
nsresult rv = svgFrame->PaintSVG(&context, nullptr);
if (NS_SUCCEEDED(rv)) {
return true;

Просмотреть файл

@ -47,7 +47,7 @@ class nsSVGLength2;
class nsSVGOuterSVGFrame;
class nsSVGPathGeometryFrame;
class nsTextFrame;
class gfxTextContextPaint;
class gfxTextObjectPaint;
struct nsStyleSVG;
struct nsStyleSVGPaint;
@ -589,8 +589,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);
@ -599,46 +599,46 @@ 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 a stroked path
*/
static void SetupCairoStrokeGeometry(nsIFrame* aFrame, gfxContext *aContext,
gfxTextContextPaint *aContextPaint = nullptr);
gfxTextObjectPaint *aObjectPaint = nullptr);
/*
* Set up a cairo context for hit testing a stroked path
*/
static void SetupCairoStrokeHitGeometry(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
@ -657,7 +657,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