зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1778610 - Ensure we support flushing user fonts for FontFaceSetWorkerImpl. r=emilio
This is necessary for when we want to draw text with Canvas 2D and a user font. This ensures the necessary font families are populated prior to processing the text run. Differential Revision: https://phabricator.services.mozilla.com/D151342
This commit is contained in:
Родитель
e23796b95f
Коммит
fc4e22dac5
|
@ -121,7 +121,7 @@ class FontFaceSetImpl : public nsISupports, public gfxUserFontSet {
|
|||
*/
|
||||
virtual void DidRefresh() { MOZ_ASSERT_UNREACHABLE("Not implemented!"); }
|
||||
|
||||
virtual void FlushUserFontSet() {}
|
||||
virtual void FlushUserFontSet() = 0;
|
||||
|
||||
static nsPresContext* GetPresContextFor(gfxUserFontSet* aUserFontSet) {
|
||||
const auto* set = static_cast<FontFaceSetImpl*>(aUserFontSet);
|
||||
|
|
|
@ -191,6 +191,33 @@ uint64_t FontFaceSetWorkerImpl::GetInnerWindowID() {
|
|||
return mWorkerRef->Private()->WindowID();
|
||||
}
|
||||
|
||||
void FontFaceSetWorkerImpl::FlushUserFontSet() {
|
||||
RecursiveMutexAutoLock lock(mMutex);
|
||||
|
||||
// If there was a change to the mNonRuleFaces array, then there could
|
||||
// have been a modification to the user font set.
|
||||
bool modified = mNonRuleFacesDirty;
|
||||
mNonRuleFacesDirty = false;
|
||||
|
||||
for (size_t i = 0, i_end = mNonRuleFaces.Length(); i < i_end; ++i) {
|
||||
InsertNonRuleFontFace(mNonRuleFaces[i].mFontFace, modified);
|
||||
}
|
||||
|
||||
// Remove any residual families that have no font entries.
|
||||
for (auto it = mFontFamilies.Iter(); !it.Done(); it.Next()) {
|
||||
if (!it.Data()->FontListLength()) {
|
||||
it.Remove();
|
||||
}
|
||||
}
|
||||
|
||||
if (modified) {
|
||||
IncrementGeneration(true);
|
||||
mHasLoadingFontFacesIsDirty = true;
|
||||
CheckLoadingStarted();
|
||||
CheckLoadingFinished();
|
||||
}
|
||||
}
|
||||
|
||||
nsresult FontFaceSetWorkerImpl::StartLoad(gfxUserFontEntry* aUserFontEntry,
|
||||
uint32_t aSrcIndex) {
|
||||
RecursiveMutexAutoLock lock(mMutex);
|
||||
|
|
|
@ -28,6 +28,8 @@ class FontFaceSetWorkerImpl final : public FontFaceSetImpl {
|
|||
|
||||
already_AddRefed<URLExtraData> GetURLExtraData() override;
|
||||
|
||||
void FlushUserFontSet() override;
|
||||
|
||||
// gfxUserFontSet
|
||||
|
||||
nsresult StartLoad(gfxUserFontEntry* aUserFontEntry,
|
||||
|
|
Загрузка…
Ссылка в новой задаче