mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-06 22:53:08 +00:00
bug 950590 - part 2 - make SetUserFontSet support updating a gfxFontGroup's user font set on the fly, and use this in canvas rendering context. r=roc
This commit is contained in:
parent
7d783a454c
commit
147ed55ba9
@ -2620,6 +2620,10 @@ CanvasRenderingContext2D::DrawOrMeasureText(const nsAString& aRawText,
|
||||
gfxFontGroup* currentFontStyle = GetCurrentFontStyle();
|
||||
NS_ASSERTION(currentFontStyle, "font group is null");
|
||||
|
||||
// ensure user font set is up to date
|
||||
currentFontStyle->
|
||||
SetUserFontSet(presShell->GetPresContext()->GetUserFontSet());
|
||||
|
||||
if (currentFontStyle->GetStyle()->size == 0.0F) {
|
||||
if (aWidth) {
|
||||
*aWidth = 0;
|
||||
|
@ -4062,11 +4062,14 @@ gfxFontGroup::gfxFontGroup(const nsAString& aFamilies,
|
||||
, mStyle(*aStyle)
|
||||
, mUnderlineOffset(UNDERLINE_OFFSET_NOT_SET)
|
||||
, mHyphenWidth(-1)
|
||||
, mUserFontSet(aUserFontSet)
|
||||
, mTextPerf(nullptr)
|
||||
, mPageLang(gfxPlatform::GetFontPrefLangFor(aStyle->language))
|
||||
, mSkipDrawing(false)
|
||||
{
|
||||
SetUserFontSet(aUserFontSet);
|
||||
// We don't use SetUserFontSet() here, as we want to unconditionally call
|
||||
// BuildFontList() rather than only do UpdateFontList() if it changed.
|
||||
mCurrGeneration = GetGeneration();
|
||||
BuildFontList();
|
||||
}
|
||||
|
||||
@ -5108,8 +5111,12 @@ gfxFontGroup::GetUserFontSet()
|
||||
void
|
||||
gfxFontGroup::SetUserFontSet(gfxUserFontSet *aUserFontSet)
|
||||
{
|
||||
if (aUserFontSet == mUserFontSet) {
|
||||
return;
|
||||
}
|
||||
mUserFontSet = aUserFontSet;
|
||||
mCurrGeneration = GetGeneration();
|
||||
mCurrGeneration = GetGeneration() - 1;
|
||||
UpdateFontList();
|
||||
}
|
||||
|
||||
uint64_t
|
||||
@ -5123,7 +5130,7 @@ gfxFontGroup::GetGeneration()
|
||||
void
|
||||
gfxFontGroup::UpdateFontList()
|
||||
{
|
||||
if (mUserFontSet && mCurrGeneration != GetGeneration()) {
|
||||
if (mCurrGeneration != GetGeneration()) {
|
||||
// xxx - can probably improve this to detect when all fonts were found, so no need to update list
|
||||
mFonts.Clear();
|
||||
mUnderlineOffset = UNDERLINE_OFFSET_NOT_SET;
|
||||
|
@ -3511,6 +3511,9 @@ public:
|
||||
gfxTextPerfMetrics *GetTextPerfMetrics() { return mTextPerf; }
|
||||
void SetTextPerfMetrics(gfxTextPerfMetrics *aTextPerf) { mTextPerf = aTextPerf; }
|
||||
|
||||
// This will call UpdateFontList() if the user font set is changed.
|
||||
void SetUserFontSet(gfxUserFontSet *aUserFontSet);
|
||||
|
||||
// If there is a user font set, check to see whether the font list or any
|
||||
// caches need updating.
|
||||
virtual void UpdateFontList();
|
||||
@ -3567,10 +3570,6 @@ protected:
|
||||
gfxTextRun *MakeBlankTextRun(uint32_t aLength,
|
||||
const Parameters *aParams, uint32_t aFlags);
|
||||
|
||||
// Used for construction/destruction. Not intended to change the font set
|
||||
// as invalidation of font lists and caches is not considered.
|
||||
void SetUserFontSet(gfxUserFontSet *aUserFontSet);
|
||||
|
||||
// Initialize the list of fonts
|
||||
void BuildFontList();
|
||||
|
||||
|
@ -1410,10 +1410,7 @@ gfxPangoFontGroup::GetFontAt(int32_t i)
|
||||
void
|
||||
gfxPangoFontGroup::UpdateFontList()
|
||||
{
|
||||
if (!mUserFontSet)
|
||||
return;
|
||||
|
||||
uint64_t newGeneration = mUserFontSet->GetGeneration();
|
||||
uint64_t newGeneration = GetGeneration();
|
||||
if (newGeneration == mCurrGeneration)
|
||||
return;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user