Bug 1366921 - stylo: Update user fonts in cached font metrics' gfxFontGroups in the pre-traversal step. r=bholley,jfkthame

MozReview-Commit-ID: DAhhWyAjxku

--HG--
extra : rebase_source : a1a9f4530a500c3d8edf6caeb2a91f91425d9b5a
This commit is contained in:
Cameron McCormack 2017-05-26 22:29:10 +08:00
parent 5429cb6065
commit 2d0337cf6f
5 changed files with 33 additions and 2 deletions

View File

@ -62,6 +62,8 @@ public:
void Compact();
void Flush();
void UpdateUserFonts(gfxUserFontSet* aUserFontSet);
protected:
~nsFontCache() {}
@ -146,6 +148,17 @@ nsFontCache::GetMetricsFor(const nsFont& aFont,
return fm.forget();
}
void
nsFontCache::UpdateUserFonts(gfxUserFontSet* aUserFontSet)
{
for (nsFontMetrics* fm : mFontMetrics) {
gfxFontGroup* fg = fm->GetThebesFontGroup();
if (fg->GetUserFontSet() == aUserFontSet) {
fg->UpdateUserFonts();
}
}
}
void
nsFontCache::FontMetricsDeleted(const nsFontMetrics* aFontMetrics)
{
@ -215,6 +228,14 @@ nsDeviceContext::InitFontCache()
}
}
void
nsDeviceContext::UpdateFontCacheUserFonts(gfxUserFontSet* aUserFontSet)
{
if (mFontCache) {
mFontCache->UpdateUserFonts(aUserFontSet);
}
}
already_AddRefed<nsFontMetrics>
nsDeviceContext::GetMetricsFor(const nsFont& aFont,
const nsFontMetrics::Params& aParams)

View File

@ -61,6 +61,8 @@ public:
*/
void InitFontCache();
void UpdateFontCacheUserFonts(gfxUserFontSet* aUserFontSet);
/**
* Initialize the device context from a device context spec
* @param aDevSpec the specification of the printing device

View File

@ -25,6 +25,7 @@
#include "nsSMILAnimationController.h"
#include "nsStyleContext.h"
#include "nsStyleSet.h"
#include "gfxUserFontSet.h"
using namespace mozilla;
using namespace mozilla::dom;
@ -43,6 +44,7 @@ ServoStyleSet::ServoStyleSet()
, mAllowResolveStaleStyles(false)
, mAuthorStyleDisabled(false)
, mStylistState(StylistState::NotDirty)
, mUserFontSetUpdateGeneration(0)
, mNeedsRestyleAfterEnsureUniqueInner(false)
{
}
@ -322,7 +324,13 @@ ServoStyleSet::PreTraverseSync()
mPresContext->Document()->GetDocumentState();
// Ensure that the @font-face data is not stale
mPresContext->Document()->GetUserFontSet();
if (gfxUserFontSet* userFontSet = mPresContext->Document()->GetUserFontSet()) {
uint64_t generation = userFontSet->GetGeneration();
if (generation != mUserFontSetUpdateGeneration) {
mPresContext->DeviceContext()->UpdateFontCacheUserFonts(userFontSet);
mUserFontSetUpdateGeneration = generation;
}
}
UpdateStylistIfNeeded();
mPresContext->CacheAllLangs();

View File

@ -543,6 +543,7 @@ private:
bool mAllowResolveStaleStyles;
bool mAuthorStyleDisabled;
StylistState mStylistState;
uint64_t mUserFontSetUpdateGeneration;
bool mNeedsRestyleAfterEnsureUniqueInner;

View File

@ -296,7 +296,6 @@ support-files = file_transitions_replacement_on_busy_frame.html
support-files = file_transitions_with_disabled_properties.html
[test_unclosed_parentheses.html]
[test_unicode_range_loading.html]
skip-if = stylo # bug 1366921
support-files = ../../reftests/fonts/markA.woff ../../reftests/fonts/markB.woff ../../reftests/fonts/markC.woff ../../reftests/fonts/markD.woff
[test_units_angle.html]
[test_units_frequency.html]