Skip to content
This repository was archived by the owner on Jul 9, 2025. It is now read-only.

Commit 2d0337c

Browse files
committed
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
1 parent 5429cb6 commit 2d0337c

5 files changed

Lines changed: 33 additions & 2 deletions

File tree

gfx/src/nsDeviceContext.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ class nsFontCache final : public nsIObserver
6262
void Compact();
6363
void Flush();
6464

65+
void UpdateUserFonts(gfxUserFontSet* aUserFontSet);
66+
6567
protected:
6668
~nsFontCache() {}
6769

@@ -146,6 +148,17 @@ nsFontCache::GetMetricsFor(const nsFont& aFont,
146148
return fm.forget();
147149
}
148150

151+
void
152+
nsFontCache::UpdateUserFonts(gfxUserFontSet* aUserFontSet)
153+
{
154+
for (nsFontMetrics* fm : mFontMetrics) {
155+
gfxFontGroup* fg = fm->GetThebesFontGroup();
156+
if (fg->GetUserFontSet() == aUserFontSet) {
157+
fg->UpdateUserFonts();
158+
}
159+
}
160+
}
161+
149162
void
150163
nsFontCache::FontMetricsDeleted(const nsFontMetrics* aFontMetrics)
151164
{
@@ -215,6 +228,14 @@ nsDeviceContext::InitFontCache()
215228
}
216229
}
217230

231+
void
232+
nsDeviceContext::UpdateFontCacheUserFonts(gfxUserFontSet* aUserFontSet)
233+
{
234+
if (mFontCache) {
235+
mFontCache->UpdateUserFonts(aUserFontSet);
236+
}
237+
}
238+
218239
already_AddRefed<nsFontMetrics>
219240
nsDeviceContext::GetMetricsFor(const nsFont& aFont,
220241
const nsFontMetrics::Params& aParams)

gfx/src/nsDeviceContext.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ class nsDeviceContext final
6161
*/
6262
void InitFontCache();
6363

64+
void UpdateFontCacheUserFonts(gfxUserFontSet* aUserFontSet);
65+
6466
/**
6567
* Initialize the device context from a device context spec
6668
* @param aDevSpec the specification of the printing device

layout/style/ServoStyleSet.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include "nsSMILAnimationController.h"
2626
#include "nsStyleContext.h"
2727
#include "nsStyleSet.h"
28+
#include "gfxUserFontSet.h"
2829

2930
using namespace mozilla;
3031
using namespace mozilla::dom;
@@ -43,6 +44,7 @@ ServoStyleSet::ServoStyleSet()
4344
, mAllowResolveStaleStyles(false)
4445
, mAuthorStyleDisabled(false)
4546
, mStylistState(StylistState::NotDirty)
47+
, mUserFontSetUpdateGeneration(0)
4648
, mNeedsRestyleAfterEnsureUniqueInner(false)
4749
{
4850
}
@@ -322,7 +324,13 @@ ServoStyleSet::PreTraverseSync()
322324
mPresContext->Document()->GetDocumentState();
323325

324326
// Ensure that the @font-face data is not stale
325-
mPresContext->Document()->GetUserFontSet();
327+
if (gfxUserFontSet* userFontSet = mPresContext->Document()->GetUserFontSet()) {
328+
uint64_t generation = userFontSet->GetGeneration();
329+
if (generation != mUserFontSetUpdateGeneration) {
330+
mPresContext->DeviceContext()->UpdateFontCacheUserFonts(userFontSet);
331+
mUserFontSetUpdateGeneration = generation;
332+
}
333+
}
326334

327335
UpdateStylistIfNeeded();
328336
mPresContext->CacheAllLangs();

layout/style/ServoStyleSet.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -543,6 +543,7 @@ class ServoStyleSet
543543
bool mAllowResolveStaleStyles;
544544
bool mAuthorStyleDisabled;
545545
StylistState mStylistState;
546+
uint64_t mUserFontSetUpdateGeneration;
546547

547548
bool mNeedsRestyleAfterEnsureUniqueInner;
548549

layout/style/test/mochitest.ini

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,6 @@ support-files = file_transitions_replacement_on_busy_frame.html
296296
support-files = file_transitions_with_disabled_properties.html
297297
[test_unclosed_parentheses.html]
298298
[test_unicode_range_loading.html]
299-
skip-if = stylo # bug 1366921
300299
support-files = ../../reftests/fonts/markA.woff ../../reftests/fonts/markB.woff ../../reftests/fonts/markC.woff ../../reftests/fonts/markD.woff
301300
[test_units_angle.html]
302301
[test_units_frequency.html]

0 commit comments

Comments
 (0)