Bug 906643. Part 6: Add gfxFontEntry::NotifyGlyphsChanged, which calls new gfxFont::NotifyGlyphsChanged, which calls new gfxGlyphExtents::NotifyGlyphsChanged; these methods flush out existing glyph extents and notify all affected gfxUserFontGroups of the glyph changes. r=jfkthame

This commit is contained in:
Robert O'Callahan 2013-08-20 01:08:45 +12:00
parent 97e8e67a9e
commit 1c69a44bd3
2 changed files with 41 additions and 0 deletions

View File

@ -282,6 +282,15 @@ gfxFontEntry::NotifyFontDestroyed(gfxFont* aFont)
mFontsUsingSVGGlyphs.RemoveElement(aFont);
}
void
gfxFontEntry::NotifyGlyphsChanged()
{
for (uint32_t i = 0, count = mFontsUsingSVGGlyphs.Length(); i < count; ++i) {
gfxFont* font = mFontsUsingSVGGlyphs[i];
font->NotifyGlyphsChanged();
}
}
/**
* FontTableBlobData
*
@ -2959,6 +2968,28 @@ gfxFont::Measure(gfxTextRun *aTextRun,
return metrics;
}
static PLDHashOperator
NotifyGlyphChangeObservers(nsPtrHashKey<gfxFont::GlyphChangeObserver>* aKey,
void* aClosure)
{
aKey->GetKey()->NotifyGlyphsChanged();
return PL_DHASH_NEXT;
}
void
gfxFont::NotifyGlyphsChanged()
{
uint32_t i, count = mGlyphExtentsArray.Length();
for (i = 0; i < count; ++i) {
// Flush cached extents array
mGlyphExtentsArray[i]->NotifyGlyphsChanged();
}
if (mGlyphChangeObservers) {
mGlyphChangeObservers->EnumerateEntries(NotifyGlyphChangeObservers, nullptr);
}
}
static bool
IsBoundarySpace(PRUnichar aChar, PRUnichar aNextChar)
{

View File

@ -330,6 +330,9 @@ public:
gfxRect *aResult);
bool RenderSVGGlyph(gfxContext *aContext, uint32_t aGlyphId, int aDrawMode,
gfxTextContextPaint *aContextPaint);
// Call this when glyph geometry or rendering has changed
// (e.g. animated SVG glyphs)
void NotifyGlyphsChanged();
virtual bool MatchesGenericFamily(const nsACString& aGeneric) const {
return true;
@ -1165,6 +1168,10 @@ public:
enum { INVALID_WIDTH = 0xFFFF };
void NotifyGlyphsChanged() {
mTightGlyphExtents.Clear();
}
// returns INVALID_WIDTH => not a contained glyph
// Otherwise the glyph has no before-bearing or vertical bearings,
// and the result is its width measured from the baseline origin, in
@ -1700,6 +1707,9 @@ public:
}
}
// Glyph rendering/geometry has changed, so invalidate data as necessary.
void NotifyGlyphsChanged();
virtual void SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf,
FontCacheSizes* aSizes) const;
virtual void SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf,