зеркало из https://github.com/mozilla/gecko-dev.git
Backed out changeset e4cd98b5984d (bug 1779519) for causing build bustages. CLOSED TREE
This commit is contained in:
Родитель
b2f117c4d5
Коммит
ba063e13c6
|
@ -410,7 +410,7 @@ bool TextAttrsMgr::FontFamilyTextAttr::GetFontFamily(nsIFrame* aFrame,
|
|||
nsLayoutUtils::GetFontMetricsForFrame(aFrame, 1.0f);
|
||||
|
||||
gfxFontGroup* fontGroup = fm->GetThebesFontGroup();
|
||||
RefPtr<gfxFont> font = fontGroup->GetFirstValidFont();
|
||||
gfxFont* font = fontGroup->GetFirstValidFont();
|
||||
gfxFontEntry* fontEntry = font->GetFontEntry();
|
||||
aFamily.Append(NS_ConvertUTF8toUTF16(fontEntry->FamilyName()));
|
||||
return true;
|
||||
|
@ -551,7 +551,7 @@ FontWeight TextAttrsMgr::FontWeightTextAttr::GetFontWeight(nsIFrame* aFrame) {
|
|||
nsLayoutUtils::GetFontMetricsForFrame(aFrame, 1.0f);
|
||||
|
||||
gfxFontGroup* fontGroup = fm->GetThebesFontGroup();
|
||||
RefPtr<gfxFont> font = fontGroup->GetFirstValidFont();
|
||||
gfxFont* font = fontGroup->GetFirstValidFont();
|
||||
|
||||
// When there doesn't exist a bold font in the family and so the rendering of
|
||||
// a non-bold font face is changed so that the user sees what looks like a
|
||||
|
|
|
@ -4245,9 +4245,9 @@ TextMetrics* CanvasRenderingContext2D::DrawOrMeasureText(
|
|||
|
||||
processor.mFontgrp
|
||||
->UpdateUserFonts(); // ensure user font generation is current
|
||||
RefPtr<gfxFont> font = processor.mFontgrp->GetFirstValidFont();
|
||||
const gfxFont::Metrics& fontMetrics =
|
||||
font->GetMetrics(nsFontMetrics::eHorizontal);
|
||||
processor.mFontgrp->GetFirstValidFont()->GetMetrics(
|
||||
nsFontMetrics::eHorizontal);
|
||||
|
||||
// calls bidi algo twice since it needs the full text width and the
|
||||
// bounding boxes before rendering anything
|
||||
|
|
|
@ -159,9 +159,8 @@ void nsFontMetrics::Destroy() { mPresContext = nullptr; }
|
|||
|
||||
static const gfxFont::Metrics& GetMetrics(
|
||||
nsFontMetrics* aFontMetrics, nsFontMetrics::FontOrientation aOrientation) {
|
||||
RefPtr<gfxFont> font =
|
||||
aFontMetrics->GetThebesFontGroup()->GetFirstValidFont();
|
||||
return font->GetMetrics(aOrientation);
|
||||
return aFontMetrics->GetThebesFontGroup()->GetFirstValidFont()->GetMetrics(
|
||||
aOrientation);
|
||||
}
|
||||
|
||||
static const gfxFont::Metrics& GetMetrics(nsFontMetrics* aFontMetrics) {
|
||||
|
|
|
@ -231,9 +231,9 @@ bool gfxFontCache::HashEntry::KeyEquals(const KeyTypePointer aKey) const {
|
|||
aKey->mUnicodeRangeMap->Equals(fontUnicodeRangeMap)));
|
||||
}
|
||||
|
||||
already_AddRefed<gfxFont> gfxFontCache::Lookup(
|
||||
const gfxFontEntry* aFontEntry, const gfxFontStyle* aStyle,
|
||||
const gfxCharacterMap* aUnicodeRangeMap) {
|
||||
gfxFont* gfxFontCache::Lookup(const gfxFontEntry* aFontEntry,
|
||||
const gfxFontStyle* aStyle,
|
||||
const gfxCharacterMap* aUnicodeRangeMap) {
|
||||
MutexAutoLock lock(mMutex);
|
||||
|
||||
Key key(aFontEntry, aStyle, aUnicodeRangeMap);
|
||||
|
@ -241,19 +241,11 @@ already_AddRefed<gfxFont> gfxFontCache::Lookup(
|
|||
|
||||
Telemetry::Accumulate(Telemetry::FONT_CACHE_HIT, entry != nullptr);
|
||||
|
||||
if (!entry) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
RefPtr<gfxFont> font = entry->mFont;
|
||||
if (font->GetExpirationState()->IsTracked()) {
|
||||
RemoveObjectLocked(font, lock);
|
||||
}
|
||||
return font.forget();
|
||||
return entry ? entry->mFont : nullptr;
|
||||
}
|
||||
|
||||
void gfxFontCache::AddNew(gfxFont* aFont) {
|
||||
nsTArray<gfxFont*> discard;
|
||||
gfxFont* oldFont;
|
||||
{
|
||||
MutexAutoLock lock(mMutex);
|
||||
|
||||
|
@ -263,39 +255,28 @@ void gfxFontCache::AddNew(gfxFont* aFont) {
|
|||
if (!entry) {
|
||||
return;
|
||||
}
|
||||
gfxFont* oldFont = entry->mFont;
|
||||
oldFont = entry->mFont;
|
||||
entry->mFont = aFont;
|
||||
// Assert that we can find the entry we just put in (this fails if the key
|
||||
// has a NaN float value in it, e.g. 'sizeAdjust').
|
||||
MOZ_ASSERT(entry == mFonts.GetEntry(key));
|
||||
|
||||
// If someone's asked us to replace an existing font entry, then that's a
|
||||
// bit weird, but let it happen, and expire the old font if it's not used.
|
||||
if (oldFont && oldFont->GetExpirationState()->IsTracked()) {
|
||||
// if oldFont == aFont, recount should be > 0,
|
||||
// so we shouldn't be here.
|
||||
NS_ASSERTION(aFont != oldFont, "new font is tracked for expiry!");
|
||||
NotifyExpiredLocked(oldFont, lock);
|
||||
discard = std::move(mTrackerDiscard);
|
||||
}
|
||||
}
|
||||
DestroyDiscard(discard);
|
||||
|
||||
// If someone's asked us to replace an existing font entry, then that's a
|
||||
// bit weird, but let it happen, and expire the old font if it's not used.
|
||||
if (oldFont && oldFont->GetExpirationState()->IsTracked()) {
|
||||
// if oldFont == aFont, recount should be > 0,
|
||||
// so we shouldn't be here.
|
||||
NS_ASSERTION(aFont != oldFont, "new font is tracked for expiry!");
|
||||
NotifyExpired(oldFont);
|
||||
}
|
||||
}
|
||||
|
||||
void gfxFontCache::NotifyReleased(gfxFont* aFont) {
|
||||
nsTArray<gfxFont*> discard;
|
||||
{
|
||||
MutexAutoLock lock(mMutex);
|
||||
if (NS_SUCCEEDED(AddObjectLocked(aFont, lock))) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (NS_FAILED(AddObject(aFont))) {
|
||||
// We couldn't track it for some reason. Kill it now.
|
||||
DestroyFontLocked(aFont);
|
||||
discard = std::move(mTrackerDiscard);
|
||||
DestroyFont(aFont);
|
||||
}
|
||||
|
||||
DestroyDiscard(discard);
|
||||
// Note that we might have fonts that aren't in the hashtable, perhaps because
|
||||
// of OOM adding to the hashtable or because someone did an AddNew where
|
||||
// we already had a font. These fonts are added to the expiration tracker
|
||||
|
@ -304,17 +285,15 @@ void gfxFontCache::NotifyReleased(gfxFont* aFont) {
|
|||
}
|
||||
|
||||
void gfxFontCache::NotifyExpiredLocked(gfxFont* aFont, const AutoLock& aLock) {
|
||||
aFont->ClearCachedWords();
|
||||
RemoveObjectLocked(aFont, aLock);
|
||||
DestroyFontLocked(aFont);
|
||||
}
|
||||
|
||||
void gfxFontCache::NotifyHandlerEnd() {
|
||||
nsTArray<gfxFont*> discard;
|
||||
{
|
||||
MutexAutoLock lock(mMutex);
|
||||
discard = std::move(mTrackerDiscard);
|
||||
}
|
||||
DestroyDiscard(discard);
|
||||
void gfxFontCache::NotifyExpired(gfxFont* aFont) {
|
||||
aFont->ClearCachedWords();
|
||||
RemoveObject(aFont);
|
||||
DestroyFont(aFont);
|
||||
}
|
||||
|
||||
void gfxFontCache::DestroyFontLocked(gfxFont* aFont) {
|
||||
|
@ -326,38 +305,23 @@ void gfxFontCache::DestroyFontLocked(gfxFont* aFont) {
|
|||
}
|
||||
NS_ASSERTION(aFont->GetRefCount() == 0,
|
||||
"Destroying with non-zero ref count!");
|
||||
mTrackerDiscard.AppendElement(aFont);
|
||||
MutexAutoUnlock unlock(mMutex);
|
||||
delete aFont;
|
||||
}
|
||||
|
||||
void gfxFontCache::DestroyDiscard(nsTArray<gfxFont*>& aDiscard) {
|
||||
for (auto* font : aDiscard) {
|
||||
NS_ASSERTION(font->GetRefCount() == 0,
|
||||
"Destroying with non-zero ref count!");
|
||||
font->ClearCachedWords();
|
||||
delete font;
|
||||
}
|
||||
aDiscard.Clear();
|
||||
}
|
||||
|
||||
void gfxFontCache::Flush() {
|
||||
nsTArray<gfxFont*> discard;
|
||||
void gfxFontCache::DestroyFont(gfxFont* aFont) {
|
||||
{
|
||||
MutexAutoLock lock(mMutex);
|
||||
mFonts.Clear();
|
||||
AgeAllGenerationsLocked(lock);
|
||||
discard = std::move(mTrackerDiscard);
|
||||
Key key(aFont->GetFontEntry(), aFont->GetStyle(),
|
||||
aFont->GetUnicodeRangeMap());
|
||||
HashEntry* entry = mFonts.GetEntry(key);
|
||||
if (entry && entry->mFont == aFont) {
|
||||
mFonts.RemoveEntry(entry);
|
||||
}
|
||||
}
|
||||
DestroyDiscard(discard);
|
||||
}
|
||||
|
||||
void gfxFontCache::AgeAllGenerations() {
|
||||
nsTArray<gfxFont*> discard;
|
||||
{
|
||||
MutexAutoLock lock(mMutex);
|
||||
AgeAllGenerationsLocked(lock);
|
||||
discard = std::move(mTrackerDiscard);
|
||||
}
|
||||
DestroyDiscard(discard);
|
||||
NS_ASSERTION(aFont->GetRefCount() == 0,
|
||||
"Destroying with non-zero ref count!");
|
||||
delete aFont;
|
||||
}
|
||||
|
||||
/*static*/
|
||||
|
@ -3617,7 +3581,7 @@ bool gfxFont::InitFakeSmallCapsRun(
|
|||
aSyntheticUpper);
|
||||
}
|
||||
|
||||
already_AddRefed<gfxFont> gfxFont::GetSmallCapsFont() const {
|
||||
gfxFont* gfxFont::GetSmallCapsFont() const {
|
||||
gfxFontStyle style(*GetStyle());
|
||||
style.size *= SMALL_CAPS_SCALE_FACTOR;
|
||||
style.variantCaps = NS_FONT_VARIANT_CAPS_NORMAL;
|
||||
|
@ -3625,8 +3589,7 @@ already_AddRefed<gfxFont> gfxFont::GetSmallCapsFont() const {
|
|||
return fe->FindOrMakeFont(&style, mUnicodeRangeMap);
|
||||
}
|
||||
|
||||
already_AddRefed<gfxFont> gfxFont::GetSubSuperscriptFont(
|
||||
int32_t aAppUnitsPerDevPixel) const {
|
||||
gfxFont* gfxFont::GetSubSuperscriptFont(int32_t aAppUnitsPerDevPixel) const {
|
||||
gfxFontStyle style(*GetStyle());
|
||||
style.AdjustForSubSuperscript(aAppUnitsPerDevPixel);
|
||||
gfxFontEntry* fe = GetFontEntry();
|
||||
|
|
|
@ -317,9 +317,8 @@ class gfxFontCache final
|
|||
|
||||
// Look up a font in the cache. Returns null if there's nothing matching
|
||||
// in the cache
|
||||
already_AddRefed<gfxFont> Lookup(const gfxFontEntry* aFontEntry,
|
||||
const gfxFontStyle* aStyle,
|
||||
const gfxCharacterMap* aUnicodeRangeMap);
|
||||
gfxFont* Lookup(const gfxFontEntry* aFontEntry, const gfxFontStyle* aStyle,
|
||||
const gfxCharacterMap* aUnicodeRangeMap);
|
||||
|
||||
// We created a new font (presumably because Lookup returned null);
|
||||
// put it in the cache. The font's refcount should be nonzero. It is
|
||||
|
@ -335,7 +334,13 @@ class gfxFontCache final
|
|||
// Cleans out the hashtable and removes expired fonts waiting for cleanup.
|
||||
// Other gfxFont objects may be still in use but they will be pushed
|
||||
// into the expiration queues and removed.
|
||||
void Flush();
|
||||
void Flush() {
|
||||
{
|
||||
mozilla::MutexAutoLock lock(mMutex);
|
||||
mFonts.Clear();
|
||||
}
|
||||
AgeAllGenerations();
|
||||
}
|
||||
|
||||
void FlushShapedWordCaches();
|
||||
void NotifyGlyphsChanged();
|
||||
|
@ -369,7 +374,15 @@ class gfxFontCache final
|
|||
void AddSizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf,
|
||||
FontCacheSizes* aSizes) const;
|
||||
|
||||
void AgeAllGenerations();
|
||||
void AgeAllGenerations() {
|
||||
AutoLock lock(mMutex);
|
||||
AgeAllGenerationsLocked(lock);
|
||||
}
|
||||
|
||||
void RemoveObject(gfxFont* aFont) {
|
||||
AutoLock lock(mMutex);
|
||||
RemoveObjectLocked(aFont, lock);
|
||||
}
|
||||
|
||||
protected:
|
||||
class MemoryReporter final : public nsIMemoryReporter {
|
||||
|
@ -398,10 +411,10 @@ class gfxFontCache final
|
|||
// font; we just delete it.
|
||||
void NotifyExpiredLocked(gfxFont* aFont, const AutoLock&)
|
||||
REQUIRES(mMutex) override;
|
||||
void NotifyHandlerEnd() override;
|
||||
void NotifyExpired(gfxFont* aFont);
|
||||
|
||||
void DestroyFont(gfxFont* aFont);
|
||||
void DestroyFontLocked(gfxFont* aFont) REQUIRES(mMutex);
|
||||
void DestroyDiscard(nsTArray<gfxFont*>& aDiscard);
|
||||
|
||||
static gfxFontCache* gGlobalCache;
|
||||
|
||||
|
@ -442,8 +455,6 @@ class gfxFontCache final
|
|||
|
||||
nsTHashtable<HashEntry> mFonts GUARDED_BY(mMutex);
|
||||
|
||||
nsTArray<gfxFont*> mTrackerDiscard GUARDED_BY(mMutex);
|
||||
|
||||
static void WordCacheExpirationTimerCallback(nsITimer* aTimer, void* aCache);
|
||||
|
||||
nsCOMPtr<nsITimer> mWordCacheExpirationTimer GUARDED_BY(mMutex);
|
||||
|
@ -1428,6 +1439,14 @@ class gfxFont {
|
|||
|
||||
nsrefcnt AddRef(void) {
|
||||
MOZ_ASSERT(int32_t(mRefCnt) >= 0, "illegal refcnt");
|
||||
nsExpirationState state;
|
||||
{
|
||||
mozilla::AutoReadLock lock(mLock);
|
||||
state = mExpirationState;
|
||||
}
|
||||
if (state.IsTracked()) {
|
||||
gfxFontCache::GetCache()->RemoveObject(this);
|
||||
}
|
||||
++mRefCnt;
|
||||
NS_LOG_ADDREF(this, mRefCnt, "gfxFont", sizeof(*this));
|
||||
return mRefCnt;
|
||||
|
@ -1947,8 +1966,7 @@ class gfxFont {
|
|||
|
||||
// Return a cloned font resized and offset to simulate sub/superscript
|
||||
// glyphs. This does not add a reference to the returned font.
|
||||
already_AddRefed<gfxFont> GetSubSuperscriptFont(
|
||||
int32_t aAppUnitsPerDevPixel) const;
|
||||
gfxFont* GetSubSuperscriptFont(int32_t aAppUnitsPerDevPixel) const;
|
||||
|
||||
bool HasColorGlyphFor(uint32_t aCh, uint32_t aNextCh);
|
||||
|
||||
|
@ -1999,7 +2017,7 @@ class gfxFont {
|
|||
// Return a font that is a "clone" of this one, but reduced to 80% size
|
||||
// (and with variantCaps set to normal). This does not add a reference to
|
||||
// the returned font.
|
||||
already_AddRefed<gfxFont> GetSmallCapsFont() const;
|
||||
gfxFont* GetSmallCapsFont() const;
|
||||
|
||||
// subclasses may provide (possibly hinted) glyph widths (in font units);
|
||||
// if they do not override this, harfbuzz will use unhinted widths
|
||||
|
@ -2221,9 +2239,7 @@ class gfxFont {
|
|||
// This is OK because we only multiply by this factor, never divide.
|
||||
float mFUnitsConvFactor;
|
||||
|
||||
// This is guarded by gfxFontCache::GetCache()->GetMutex() but it is difficult
|
||||
// to annotate that fact.
|
||||
nsExpirationState mExpirationState;
|
||||
nsExpirationState mExpirationState GUARDED_BY(mLock);
|
||||
|
||||
// Glyph ID of the font's <space> glyph, zero if missing
|
||||
uint16_t mSpaceGlyph = 0;
|
||||
|
|
|
@ -266,9 +266,9 @@ nsCString gfxFontEntry::RealFaceName() {
|
|||
return Name();
|
||||
}
|
||||
|
||||
already_AddRefed<gfxFont> gfxFontEntry::FindOrMakeFont(
|
||||
const gfxFontStyle* aStyle, gfxCharacterMap* aUnicodeRangeMap) {
|
||||
RefPtr<gfxFont> font =
|
||||
gfxFont* gfxFontEntry::FindOrMakeFont(const gfxFontStyle* aStyle,
|
||||
gfxCharacterMap* aUnicodeRangeMap) {
|
||||
gfxFont* font =
|
||||
gfxFontCache::GetCache()->Lookup(this, aStyle, aUnicodeRangeMap);
|
||||
|
||||
if (!font) {
|
||||
|
@ -284,7 +284,7 @@ already_AddRefed<gfxFont> gfxFontEntry::FindOrMakeFont(
|
|||
font->SetUnicodeRangeMap(aUnicodeRangeMap);
|
||||
gfxFontCache::GetCache()->AddNew(font);
|
||||
}
|
||||
return font.forget();
|
||||
return font;
|
||||
}
|
||||
|
||||
uint16_t gfxFontEntry::UnitsPerEm() {
|
||||
|
|
|
@ -329,8 +329,8 @@ class gfxFontEntry {
|
|||
// cached instance; but we also don't return already_AddRefed, because
|
||||
// the caller may only need to use the font temporarily and doesn't need
|
||||
// a strong reference.
|
||||
already_AddRefed<gfxFont> FindOrMakeFont(
|
||||
const gfxFontStyle* aStyle, gfxCharacterMap* aUnicodeRangeMap = nullptr);
|
||||
gfxFont* FindOrMakeFont(const gfxFontStyle* aStyle,
|
||||
gfxCharacterMap* aUnicodeRangeMap = nullptr);
|
||||
|
||||
// Get an existing font table cache entry in aBlob if it has been
|
||||
// registered, or return false if not. Callers must call
|
||||
|
|
|
@ -950,7 +950,7 @@ void gfxPlatformFontList::GetFontFamilyList(
|
|||
}
|
||||
}
|
||||
|
||||
already_AddRefed<gfxFont> gfxPlatformFontList::SystemFindFontForChar(
|
||||
gfxFont* gfxPlatformFontList::SystemFindFontForChar(
|
||||
nsPresContext* aPresContext, uint32_t aCh, uint32_t aNextCh,
|
||||
Script aRunScript, eFontPresentation aPresentation,
|
||||
const gfxFontStyle* aStyle, FontVisibility* aVisibility) {
|
||||
|
@ -991,17 +991,17 @@ already_AddRefed<gfxFont> gfxPlatformFontList::SystemFindFontForChar(
|
|||
// search commonly available fonts
|
||||
bool common = true;
|
||||
FontFamily fallbackFamily;
|
||||
RefPtr<gfxFont> candidate =
|
||||
gfxFont* candidate =
|
||||
CommonFontFallback(aPresContext, aCh, aNextCh, aRunScript, aPresentation,
|
||||
aStyle, fallbackFamily);
|
||||
RefPtr<gfxFont> font;
|
||||
gfxFont* font = nullptr;
|
||||
if (candidate) {
|
||||
if (aPresentation == eFontPresentation::Any) {
|
||||
font = std::move(candidate);
|
||||
font = candidate;
|
||||
} else {
|
||||
bool hasColorGlyph = candidate->HasColorGlyphFor(aCh, aNextCh);
|
||||
if (hasColorGlyph == PrefersColor(aPresentation)) {
|
||||
font = std::move(candidate);
|
||||
font = candidate;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1018,7 +1018,10 @@ already_AddRefed<gfxFont> gfxPlatformFontList::SystemFindFontForChar(
|
|||
if (font && aPresentation != eFontPresentation::Any && candidate) {
|
||||
bool hasColorGlyph = font->HasColorGlyphFor(aCh, aNextCh);
|
||||
if (hasColorGlyph != PrefersColor(aPresentation)) {
|
||||
font = std::move(candidate);
|
||||
// We're discarding `font` and using `candidate` instead, so ensure
|
||||
// `font` is known to the global cache expiration tracker.
|
||||
RefPtr<gfxFont> autoRefDeref(font);
|
||||
font = candidate;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1063,12 +1066,12 @@ already_AddRefed<gfxFont> gfxPlatformFontList::SystemFindFontForChar(
|
|||
Telemetry::Accumulate(Telemetry::SYSTEM_FONT_FALLBACK_SCRIPT,
|
||||
int(aRunScript) + 1);
|
||||
|
||||
return font.forget();
|
||||
return font;
|
||||
}
|
||||
|
||||
#define NUM_FALLBACK_FONTS 8
|
||||
|
||||
already_AddRefed<gfxFont> gfxPlatformFontList::CommonFontFallback(
|
||||
gfxFont* gfxPlatformFontList::CommonFontFallback(
|
||||
nsPresContext* aPresContext, uint32_t aCh, uint32_t aNextCh,
|
||||
Script aRunScript, eFontPresentation aPresentation,
|
||||
const gfxFontStyle* aMatchStyle, FontFamily& aMatchedFamily) {
|
||||
|
@ -1082,20 +1085,19 @@ already_AddRefed<gfxFont> gfxPlatformFontList::CommonFontFallback(
|
|||
// If a color-emoji presentation is requested, we will check any font found
|
||||
// to see if it can provide this; if not, we'll remember it as a possible
|
||||
// candidate but search the remainder of the list for a better choice.
|
||||
RefPtr<gfxFont> candidateFont;
|
||||
gfxFont* candidateFont = nullptr;
|
||||
FontFamily candidateFamily;
|
||||
auto check = [&](gfxFontEntry* aFontEntry,
|
||||
FontFamily aFamily) -> already_AddRefed<gfxFont> {
|
||||
RefPtr<gfxFont> font = aFontEntry->FindOrMakeFont(aMatchStyle);
|
||||
auto check = [&](gfxFontEntry* aFontEntry, FontFamily aFamily) -> gfxFont* {
|
||||
gfxFont* font = aFontEntry->FindOrMakeFont(aMatchStyle);
|
||||
if (aPresentation < eFontPresentation::EmojiDefault ||
|
||||
font->HasColorGlyphFor(aCh, aNextCh)) {
|
||||
aMatchedFamily = aFamily;
|
||||
return font.forget();
|
||||
return font;
|
||||
}
|
||||
// We want a color glyph but this font only has monochrome; remember it
|
||||
// (unless we already have a candidate) but continue to search.
|
||||
if (!candidateFont) {
|
||||
candidateFont = std::move(font);
|
||||
candidateFont = font;
|
||||
candidateFamily = aFamily;
|
||||
}
|
||||
return nullptr;
|
||||
|
@ -1112,9 +1114,12 @@ already_AddRefed<gfxFont> gfxPlatformFontList::CommonFontFallback(
|
|||
// always do a potential sync initialization of the family?
|
||||
family->SearchAllFontsForChar(SharedFontList(), &data);
|
||||
if (data.mBestMatch) {
|
||||
RefPtr<gfxFont> font = check(data.mBestMatch, FontFamily(family));
|
||||
gfxFont* font = check(data.mBestMatch, FontFamily(family));
|
||||
if (font) {
|
||||
return font.forget();
|
||||
// Twiddle the refcount of any stored candidate (that we're not going
|
||||
// to return after all) so that the cache gets a chance to drop it.
|
||||
RefPtr<gfxFont> autoRefDeref(candidateFont);
|
||||
return font;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1127,9 +1132,10 @@ already_AddRefed<gfxFont> gfxPlatformFontList::CommonFontFallback(
|
|||
}
|
||||
fallback->FindFontForChar(&data);
|
||||
if (data.mBestMatch) {
|
||||
RefPtr<gfxFont> font = check(data.mBestMatch, FontFamily(fallback));
|
||||
gfxFont* font = check(data.mBestMatch, FontFamily(fallback));
|
||||
if (font) {
|
||||
return font.forget();
|
||||
RefPtr<gfxFont> autoRefDeref(candidateFont);
|
||||
return font;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1140,13 +1146,13 @@ already_AddRefed<gfxFont> gfxPlatformFontList::CommonFontFallback(
|
|||
// found.
|
||||
if (candidateFont) {
|
||||
aMatchedFamily = candidateFamily;
|
||||
return candidateFont.forget();
|
||||
return candidateFont;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
already_AddRefed<gfxFont> gfxPlatformFontList::GlobalFontFallback(
|
||||
gfxFont* gfxPlatformFontList::GlobalFontFallback(
|
||||
nsPresContext* aPresContext, uint32_t aCh, uint32_t aNextCh,
|
||||
Script aRunScript, eFontPresentation aPresentation,
|
||||
const gfxFontStyle* aMatchStyle, uint32_t& aCmapCount,
|
||||
|
@ -1162,28 +1168,32 @@ already_AddRefed<gfxFont> gfxPlatformFontList::GlobalFontFallback(
|
|||
if (fe) {
|
||||
if (aMatchedFamily.mIsShared) {
|
||||
if (IsVisibleToCSS(*aMatchedFamily.mShared, level)) {
|
||||
RefPtr<gfxFont> font = fe->FindOrMakeFont(aMatchStyle);
|
||||
gfxFont* font = fe->FindOrMakeFont(aMatchStyle);
|
||||
if (font) {
|
||||
if (aPresentation == eFontPresentation::Any) {
|
||||
return font.forget();
|
||||
return font;
|
||||
}
|
||||
bool hasColorGlyph = font->HasColorGlyphFor(aCh, aNextCh);
|
||||
if (hasColorGlyph == PrefersColor(aPresentation)) {
|
||||
return font.forget();
|
||||
return font;
|
||||
}
|
||||
// If we don't use this font, we need to touch its refcount
|
||||
// to trigger gfxFontCache expiration tracking.
|
||||
RefPtr<gfxFont> autoRefDeref(font);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (IsVisibleToCSS(*aMatchedFamily.mUnshared, level)) {
|
||||
RefPtr<gfxFont> font = fe->FindOrMakeFont(aMatchStyle);
|
||||
gfxFont* font = fe->FindOrMakeFont(aMatchStyle);
|
||||
if (font) {
|
||||
if (aPresentation == eFontPresentation::Any) {
|
||||
return font.forget();
|
||||
return font;
|
||||
}
|
||||
bool hasColorGlyph = font->HasColorGlyphFor(aCh, aNextCh);
|
||||
if (hasColorGlyph == PrefersColor(aPresentation)) {
|
||||
return font.forget();
|
||||
return font;
|
||||
}
|
||||
RefPtr<gfxFont> autoRefDeref(font);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -275,10 +275,11 @@ class gfxPlatformFontList : public gfxFontInfoLoader {
|
|||
|
||||
void GetFontFamilyList(nsTArray<RefPtr<gfxFontFamily>>& aFamilyArray);
|
||||
|
||||
already_AddRefed<gfxFont> SystemFindFontForChar(
|
||||
nsPresContext* aPresContext, uint32_t aCh, uint32_t aNextCh,
|
||||
Script aRunScript, eFontPresentation aPresentation,
|
||||
const gfxFontStyle* aStyle, FontVisibility* aVisibility);
|
||||
gfxFont* SystemFindFontForChar(nsPresContext* aPresContext, uint32_t aCh,
|
||||
uint32_t aNextCh, Script aRunScript,
|
||||
eFontPresentation aPresentation,
|
||||
const gfxFontStyle* aStyle,
|
||||
FontVisibility* aVisibility);
|
||||
|
||||
// Flags to control optional behaviors in FindAndAddFamilies. The sense
|
||||
// of the bit flags have been chosen such that the default parameter of
|
||||
|
@ -786,20 +787,19 @@ class gfxPlatformFontList : public gfxFontInfoLoader {
|
|||
}
|
||||
|
||||
// returns default font for a given character, null otherwise
|
||||
already_AddRefed<gfxFont> CommonFontFallback(nsPresContext* aPresContext,
|
||||
uint32_t aCh, uint32_t aNextCh,
|
||||
Script aRunScript,
|
||||
eFontPresentation aPresentation,
|
||||
const gfxFontStyle* aMatchStyle,
|
||||
FontFamily& aMatchedFamily)
|
||||
REQUIRES(mLock);
|
||||
gfxFont* CommonFontFallback(nsPresContext* aPresContext, uint32_t aCh,
|
||||
uint32_t aNextCh, Script aRunScript,
|
||||
eFontPresentation aPresentation,
|
||||
const gfxFontStyle* aMatchStyle,
|
||||
FontFamily& aMatchedFamily) REQUIRES(mLock);
|
||||
|
||||
// Search fonts system-wide for a given character, null if not found.
|
||||
already_AddRefed<gfxFont> GlobalFontFallback(
|
||||
nsPresContext* aPresContext, uint32_t aCh, uint32_t aNextCh,
|
||||
Script aRunScript, eFontPresentation aPresentation,
|
||||
const gfxFontStyle* aMatchStyle, uint32_t& aCmapCount,
|
||||
FontFamily& aMatchedFamily) REQUIRES(mLock);
|
||||
gfxFont* GlobalFontFallback(nsPresContext* aPresContext, uint32_t aCh,
|
||||
uint32_t aNextCh, Script aRunScript,
|
||||
eFontPresentation aPresentation,
|
||||
const gfxFontStyle* aMatchStyle,
|
||||
uint32_t& aCmapCount, FontFamily& aMatchedFamily)
|
||||
REQUIRES(mLock);
|
||||
|
||||
// Platform-specific implementation of global font fallback, if any;
|
||||
// this may return nullptr in which case the default cmap-based fallback
|
||||
|
|
|
@ -2045,8 +2045,7 @@ bool gfxFontGroup::HasFont(const gfxFontEntry* aFontEntry) {
|
|||
return false;
|
||||
}
|
||||
|
||||
already_AddRefed<gfxFont> gfxFontGroup::GetFontAt(int32_t i, uint32_t aCh,
|
||||
bool* aLoading) {
|
||||
gfxFont* gfxFontGroup::GetFontAt(int32_t i, uint32_t aCh, bool* aLoading) {
|
||||
if (uint32_t(i) >= mFonts.Length()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -2056,7 +2055,7 @@ already_AddRefed<gfxFont> gfxFontGroup::GetFontAt(int32_t i, uint32_t aCh,
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
RefPtr<gfxFont> font = ff.Font();
|
||||
gfxFont* font = ff.Font();
|
||||
if (!font) {
|
||||
gfxFontEntry* fe = ff.FontEntry();
|
||||
if (!fe) {
|
||||
|
@ -2080,11 +2079,14 @@ already_AddRefed<gfxFont> gfxFontGroup::GetFontAt(int32_t i, uint32_t aCh,
|
|||
font = fe->FindOrMakeFont(&mStyle, unicodeRangeMap);
|
||||
if (!font || !font->Valid()) {
|
||||
ff.SetInvalid();
|
||||
// We can't just |delete font| here, in case there are other
|
||||
// references to the object FindOrMakeFont returned.
|
||||
RefPtr<gfxFont> ref(font);
|
||||
return nullptr;
|
||||
}
|
||||
ff.SetFont(font);
|
||||
}
|
||||
return font.forget();
|
||||
return font;
|
||||
}
|
||||
|
||||
void gfxFontGroup::FamilyFace::CheckState(bool& aSkipDrawing) {
|
||||
|
@ -2136,9 +2138,9 @@ static nsAutoCString FamilyListToString(
|
|||
});
|
||||
}
|
||||
|
||||
already_AddRefed<gfxFont> gfxFontGroup::GetDefaultFont() {
|
||||
gfxFont* gfxFontGroup::GetDefaultFont() {
|
||||
if (mDefaultFont) {
|
||||
return do_AddRef(mDefaultFont);
|
||||
return mDefaultFont.get();
|
||||
}
|
||||
|
||||
gfxPlatformFontList* pfl = gfxPlatformFontList::PlatformFontList();
|
||||
|
@ -2230,9 +2232,9 @@ already_AddRefed<gfxFont> gfxFontGroup::GetDefaultFont() {
|
|||
} else {
|
||||
gfxFontEntry* fe = pfl->GetDefaultFontEntry();
|
||||
if (fe) {
|
||||
RefPtr<gfxFont> f = fe->FindOrMakeFont(&mStyle);
|
||||
gfxFont* f = fe->FindOrMakeFont(&mStyle);
|
||||
if (f) {
|
||||
return f.forget();
|
||||
return f;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2261,11 +2263,11 @@ already_AddRefed<gfxFont> gfxFontGroup::GetDefaultFont() {
|
|||
MOZ_CRASH_UNSAFE(msg);
|
||||
}
|
||||
|
||||
return do_AddRef(mDefaultFont);
|
||||
return mDefaultFont.get();
|
||||
}
|
||||
|
||||
already_AddRefed<gfxFont> gfxFontGroup::GetFirstValidFont(
|
||||
uint32_t aCh, StyleGenericFontFamily* aGeneric) {
|
||||
gfxFont* gfxFontGroup::GetFirstValidFont(uint32_t aCh,
|
||||
StyleGenericFontFamily* aGeneric) {
|
||||
// Ensure cached font instances are valid.
|
||||
CheckForUpdatedPlatformList();
|
||||
|
||||
|
@ -2278,12 +2280,12 @@ already_AddRefed<gfxFont> gfxFontGroup::GetFirstValidFont(
|
|||
}
|
||||
|
||||
// already have a font?
|
||||
RefPtr<gfxFont> font = ff.Font();
|
||||
gfxFont* font = ff.Font();
|
||||
if (font) {
|
||||
if (aGeneric) {
|
||||
*aGeneric = ff.Generic();
|
||||
}
|
||||
return font.forget();
|
||||
return font;
|
||||
}
|
||||
|
||||
// Need to build a font, loading userfont if not loaded. In
|
||||
|
@ -2313,7 +2315,7 @@ already_AddRefed<gfxFont> gfxFontGroup::GetFirstValidFont(
|
|||
if (aGeneric) {
|
||||
*aGeneric = ff.Generic();
|
||||
}
|
||||
return font.forget();
|
||||
return font;
|
||||
}
|
||||
}
|
||||
if (aGeneric) {
|
||||
|
@ -2322,12 +2324,12 @@ already_AddRefed<gfxFont> gfxFontGroup::GetFirstValidFont(
|
|||
return GetDefaultFont();
|
||||
}
|
||||
|
||||
already_AddRefed<gfxFont> gfxFontGroup::GetFirstMathFont() {
|
||||
gfxFont* gfxFontGroup::GetFirstMathFont() {
|
||||
uint32_t count = mFonts.Length();
|
||||
for (uint32_t i = 0; i < count; ++i) {
|
||||
RefPtr<gfxFont> font = GetFontAt(i);
|
||||
gfxFont* font = GetFontAt(i);
|
||||
if (font && font->TryGetMathTable()) {
|
||||
return font.forget();
|
||||
return font;
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
|
@ -2377,7 +2379,7 @@ already_AddRefed<gfxTextRun> gfxFontGroup::MakeSpaceTextRun(
|
|||
orientation = ShapedTextFlags::TEXT_ORIENT_VERTICAL_SIDEWAYS_RIGHT;
|
||||
}
|
||||
|
||||
RefPtr<gfxFont> font = GetFirstValidFont();
|
||||
gfxFont* font = GetFirstValidFont();
|
||||
if (MOZ_UNLIKELY(GetStyle()->AdjustedSizeMustBeZero())) {
|
||||
// Short-circuit for size-0 fonts, as Windows and ATSUI can't handle
|
||||
// them, and always create at least size 1 fonts, i.e. they still
|
||||
|
@ -2393,7 +2395,7 @@ already_AddRefed<gfxTextRun> gfxFontGroup::MakeSpaceTextRun(
|
|||
// In case the primary font doesn't have <space> (bug 970891),
|
||||
// find one that does.
|
||||
FontMatchType matchType;
|
||||
RefPtr<gfxFont> spaceFont =
|
||||
gfxFont* spaceFont =
|
||||
FindFontForChar(' ', 0, 0, Script::LATIN, nullptr, &matchType);
|
||||
if (spaceFont) {
|
||||
textRun->SetSpaceGlyph(spaceFont, aParams->mDrawTarget, 0, orientation);
|
||||
|
@ -2421,9 +2423,8 @@ already_AddRefed<gfxTextRun> gfxFontGroup::MakeBlankTextRun(
|
|||
if (orientation == ShapedTextFlags::TEXT_ORIENT_VERTICAL_MIXED) {
|
||||
orientation = ShapedTextFlags::TEXT_ORIENT_VERTICAL_UPRIGHT;
|
||||
}
|
||||
RefPtr<gfxFont> font = GetFirstValidFont();
|
||||
textRun->AddGlyphRun(font, FontMatchType::Kind::kUnspecified, 0, false,
|
||||
orientation, false);
|
||||
textRun->AddGlyphRun(GetFirstValidFont(), FontMatchType::Kind::kUnspecified,
|
||||
0, false, orientation, false);
|
||||
|
||||
for (uint32_t i = 0; i < aLength; i++) {
|
||||
if (aString[i] == '\n') {
|
||||
|
@ -2443,7 +2444,7 @@ already_AddRefed<gfxTextRun> gfxFontGroup::MakeHyphenTextRun(
|
|||
// it's better to use ASCII '-' from the primary font than to fall back to
|
||||
// U+2010 from some other, possibly poorly-matching face
|
||||
static const char16_t hyphen = 0x2010;
|
||||
RefPtr<gfxFont> font = GetFirstValidFont(uint32_t(hyphen));
|
||||
gfxFont* font = GetFirstValidFont(uint32_t(hyphen));
|
||||
if (font->HasCharacter(hyphen)) {
|
||||
return MakeTextRun(&hyphen, 1, aDrawTarget, aAppUnitsPerDevUnit, aFlags,
|
||||
nsTextFrameUtils::Flags(), nullptr);
|
||||
|
@ -2705,7 +2706,7 @@ void gfxFontGroup::InitScriptRun(DrawTarget* aDrawTarget, gfxTextRun* aTextRun,
|
|||
UpdateUserFonts();
|
||||
}
|
||||
|
||||
RefPtr<gfxFont> mainFont = GetFirstValidFont();
|
||||
gfxFont* mainFont = GetFirstValidFont();
|
||||
|
||||
ShapedTextFlags orientation =
|
||||
aTextRun->GetFlags() & ShapedTextFlags::TEXT_ORIENT_MASK;
|
||||
|
@ -2731,7 +2732,7 @@ void gfxFontGroup::InitScriptRun(DrawTarget* aDrawTarget, gfxTextRun* aTextRun,
|
|||
for (uint32_t r = 0; r < numRanges; r++) {
|
||||
const TextRange& range = fontRanges[r];
|
||||
uint32_t matchedLength = range.Length();
|
||||
RefPtr<gfxFont> matchedFont = range.font;
|
||||
gfxFont* matchedFont = range.font;
|
||||
// create the glyph run for this range
|
||||
if (matchedFont && mStyle.noFallbackVariantFeatures) {
|
||||
// common case - just do glyph layout and record the
|
||||
|
@ -2915,7 +2916,7 @@ gfxTextRun* gfxFontGroup::GetEllipsisTextRun(
|
|||
|
||||
// Use a Unicode ellipsis if the font supports it,
|
||||
// otherwise use three ASCII periods as fallback.
|
||||
RefPtr<gfxFont> firstFont = GetFirstValidFont(uint32_t(kEllipsisChar[0]));
|
||||
gfxFont* firstFont = GetFirstValidFont(uint32_t(kEllipsisChar[0]));
|
||||
nsString ellipsis =
|
||||
firstFont->HasCharacter(kEllipsisChar[0])
|
||||
? nsDependentString(kEllipsisChar, ArrayLength(kEllipsisChar) - 1)
|
||||
|
@ -2937,7 +2938,7 @@ gfxTextRun* gfxFontGroup::GetEllipsisTextRun(
|
|||
return mCachedEllipsisTextRun.get();
|
||||
}
|
||||
|
||||
already_AddRefed<gfxFont> gfxFontGroup::FindFallbackFaceForChar(
|
||||
gfxFont* gfxFontGroup::FindFallbackFaceForChar(
|
||||
gfxFontFamily* aFamily, uint32_t aCh, uint32_t aNextCh,
|
||||
eFontPresentation aPresentation) {
|
||||
GlobalFontMatch data(aCh, aNextCh, mStyle, aPresentation);
|
||||
|
@ -2949,7 +2950,7 @@ already_AddRefed<gfxFont> gfxFontGroup::FindFallbackFaceForChar(
|
|||
return fe->FindOrMakeFont(&mStyle);
|
||||
}
|
||||
|
||||
already_AddRefed<gfxFont> gfxFontGroup::FindFallbackFaceForChar(
|
||||
gfxFont* gfxFontGroup::FindFallbackFaceForChar(
|
||||
fontlist::Family* aFamily, uint32_t aCh, uint32_t aNextCh,
|
||||
eFontPresentation aPresentation) {
|
||||
auto* pfl = gfxPlatformFontList::PlatformFontList();
|
||||
|
@ -2973,7 +2974,7 @@ already_AddRefed<gfxFont> gfxFontGroup::FindFallbackFaceForChar(
|
|||
return fe->FindOrMakeFont(&mStyle);
|
||||
}
|
||||
|
||||
already_AddRefed<gfxFont> gfxFontGroup::FindFallbackFaceForChar(
|
||||
gfxFont* gfxFontGroup::FindFallbackFaceForChar(
|
||||
const FamilyFace& aFamily, uint32_t aCh, uint32_t aNextCh,
|
||||
eFontPresentation aPresentation) {
|
||||
if (aFamily.IsSharedFamily()) {
|
||||
|
@ -3000,14 +3001,14 @@ gfxFloat gfxFontGroup::GetUnderlineOffset() {
|
|||
ff.SharedFamily()->IsBadUnderlineFamily()) ||
|
||||
(!ff.IsSharedFamily() && ff.OwnedFamily() &&
|
||||
ff.OwnedFamily()->IsBadUnderlineFamily()))) {
|
||||
RefPtr<gfxFont> font = GetFontAt(i);
|
||||
gfxFont* font = GetFontAt(i);
|
||||
if (!font) {
|
||||
continue;
|
||||
}
|
||||
gfxFloat bad =
|
||||
font->GetMetrics(nsFontMetrics::eHorizontal).underlineOffset;
|
||||
RefPtr<gfxFont> firstValidFont = GetFirstValidFont();
|
||||
gfxFloat first = firstValidFont->GetMetrics(nsFontMetrics::eHorizontal)
|
||||
gfxFloat first = GetFirstValidFont()
|
||||
->GetMetrics(nsFontMetrics::eHorizontal)
|
||||
.underlineOffset;
|
||||
mUnderlineOffset = std::min(first, bad);
|
||||
return mUnderlineOffset;
|
||||
|
@ -3015,9 +3016,9 @@ gfxFloat gfxFontGroup::GetUnderlineOffset() {
|
|||
}
|
||||
|
||||
// no bad underline fonts, use the first valid font's metric
|
||||
RefPtr<gfxFont> firstValidFont = GetFirstValidFont();
|
||||
mUnderlineOffset =
|
||||
firstValidFont->GetMetrics(nsFontMetrics::eHorizontal).underlineOffset;
|
||||
mUnderlineOffset = GetFirstValidFont()
|
||||
->GetMetrics(nsFontMetrics::eHorizontal)
|
||||
.underlineOffset;
|
||||
}
|
||||
|
||||
return mUnderlineOffset;
|
||||
|
@ -3025,15 +3026,16 @@ gfxFloat gfxFontGroup::GetUnderlineOffset() {
|
|||
|
||||
#define NARROW_NO_BREAK_SPACE 0x202fu
|
||||
|
||||
already_AddRefed<gfxFont> gfxFontGroup::FindFontForChar(
|
||||
uint32_t aCh, uint32_t aPrevCh, uint32_t aNextCh, Script aRunScript,
|
||||
gfxFont* aPrevMatchedFont, FontMatchType* aMatchType) {
|
||||
gfxFont* gfxFontGroup::FindFontForChar(uint32_t aCh, uint32_t aPrevCh,
|
||||
uint32_t aNextCh, Script aRunScript,
|
||||
gfxFont* aPrevMatchedFont,
|
||||
FontMatchType* aMatchType) {
|
||||
// If the char is a cluster extender, we want to use the same font as the
|
||||
// preceding character if possible. This is preferable to using the font
|
||||
// group because it avoids breaks in shaping within a cluster.
|
||||
if (aPrevMatchedFont && IsClusterExtender(aCh)) {
|
||||
if (aPrevMatchedFont->HasCharacter(aCh) || IsDefaultIgnorable(aCh)) {
|
||||
return do_AddRef(aPrevMatchedFont);
|
||||
return aPrevMatchedFont;
|
||||
}
|
||||
// Get the singleton NFC normalizer; this does not need to be deleted.
|
||||
static UErrorCode err = U_ZERO_ERROR;
|
||||
|
@ -3042,7 +3044,7 @@ already_AddRefed<gfxFont> gfxFontGroup::FindFontForChar(
|
|||
// combination supported by the current font.
|
||||
int32_t composed = unorm2_composePair(nfc, aPrevCh, aCh);
|
||||
if (composed > 0 && aPrevMatchedFont->HasCharacter(composed)) {
|
||||
return do_AddRef(aPrevMatchedFont);
|
||||
return aPrevMatchedFont;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3052,16 +3054,16 @@ already_AddRefed<gfxFont> gfxFontGroup::FindFontForChar(
|
|||
// for the next char (unless it's just another NNBSP; we don't try
|
||||
// to look ahead through a whole run of them).
|
||||
if (!aPrevCh && aNextCh && aNextCh != NARROW_NO_BREAK_SPACE) {
|
||||
RefPtr<gfxFont> nextFont = FindFontForChar(aNextCh, 0, 0, aRunScript,
|
||||
aPrevMatchedFont, aMatchType);
|
||||
gfxFont* nextFont = FindFontForChar(aNextCh, 0, 0, aRunScript,
|
||||
aPrevMatchedFont, aMatchType);
|
||||
if (nextFont && nextFont->HasCharacter(aCh)) {
|
||||
return nextFont.forget();
|
||||
return nextFont;
|
||||
}
|
||||
}
|
||||
// Otherwise, treat NNBSP like a cluster extender (as above) and try
|
||||
// to continue the preceding font run.
|
||||
if (aPrevMatchedFont && aPrevMatchedFont->HasCharacter(aCh)) {
|
||||
return do_AddRef(aPrevMatchedFont);
|
||||
return aPrevMatchedFont;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3121,15 +3123,15 @@ already_AddRefed<gfxFont> gfxFontGroup::FindFontForChar(
|
|||
|
||||
if (!isJoinControl && !wasJoinCauser && !isVarSelector &&
|
||||
!nextIsVarSelector && presentation == eFontPresentation::Any) {
|
||||
RefPtr<gfxFont> firstFont = GetFontAt(0, aCh, &loading);
|
||||
gfxFont* firstFont = GetFontAt(0, aCh, &loading);
|
||||
if (firstFont) {
|
||||
if (firstFont->HasCharacter(aCh) ||
|
||||
(fallbackChar && firstFont->HasCharacter(fallbackChar))) {
|
||||
*aMatchType = {FontMatchType::Kind::kFontGroup, mFonts[0].Generic()};
|
||||
return firstFont.forget();
|
||||
return firstFont;
|
||||
}
|
||||
|
||||
RefPtr<gfxFont> font;
|
||||
gfxFont* font = nullptr;
|
||||
if (mFonts[0].CheckForFallbackFaces()) {
|
||||
font = FindFallbackFaceForChar(mFonts[0], aCh, aNextCh, presentation);
|
||||
} else if (!firstFont->GetFontEntry()->IsUserFont()) {
|
||||
|
@ -3141,7 +3143,7 @@ already_AddRefed<gfxFont> gfxFontGroup::FindFontForChar(
|
|||
}
|
||||
if (font) {
|
||||
*aMatchType = {FontMatchType::Kind::kFontGroup, mFonts[0].Generic()};
|
||||
return font.forget();
|
||||
return font;
|
||||
}
|
||||
} else {
|
||||
if (fontListLength > 0) {
|
||||
|
@ -3159,14 +3161,14 @@ already_AddRefed<gfxFont> gfxFontGroup::FindFontForChar(
|
|||
// actually be rendered (see bug 716229)
|
||||
if (isJoinControl ||
|
||||
GetGeneralCategory(aCh) == HB_UNICODE_GENERAL_CATEGORY_CONTROL) {
|
||||
return do_AddRef(aPrevMatchedFont);
|
||||
return aPrevMatchedFont;
|
||||
}
|
||||
|
||||
// if previous character was a join-causer (ZWJ),
|
||||
// use the same font as the previous range if we can
|
||||
if (wasJoinCauser) {
|
||||
if (aPrevMatchedFont->HasCharacter(aCh)) {
|
||||
return do_AddRef(aPrevMatchedFont);
|
||||
return aPrevMatchedFont;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3176,7 +3178,7 @@ already_AddRefed<gfxFont> gfxFontGroup::FindFontForChar(
|
|||
// (We don't want to unnecessarily split glyph runs, and the character will
|
||||
// not be visibly rendered.)
|
||||
if (isVarSelector || IsDefaultIgnorable(aCh)) {
|
||||
return do_AddRef(aPrevMatchedFont);
|
||||
return aPrevMatchedFont;
|
||||
}
|
||||
|
||||
// Used to remember the first "candidate" font that would provide a fallback
|
||||
|
@ -3185,7 +3187,7 @@ already_AddRefed<gfxFont> gfxFontGroup::FindFontForChar(
|
|||
// that it goes into the global font cache as a candidate for deletion.
|
||||
// This is done for us by CheckCandidate, but any code path that returns
|
||||
// WITHOUT calling CheckCandidate needs to handle it explicitly.
|
||||
RefPtr<gfxFont> candidateFont;
|
||||
gfxFont* candidateFont = nullptr;
|
||||
FontMatchType candidateMatchType;
|
||||
|
||||
// Handle a candidate font that could support the character, returning true
|
||||
|
@ -3197,6 +3199,7 @@ already_AddRefed<gfxFont> gfxFontGroup::FindFontForChar(
|
|||
if (presentation == eFontPresentation::Any ||
|
||||
(presentation == eFontPresentation::EmojiDefault &&
|
||||
f->GetFontEntry()->IsUserFont())) {
|
||||
RefPtr<gfxFont> autoRefDeref(candidateFont);
|
||||
*aMatchType = t;
|
||||
return true;
|
||||
}
|
||||
|
@ -3204,6 +3207,7 @@ already_AddRefed<gfxFont> gfxFontGroup::FindFontForChar(
|
|||
bool hasColorGlyph = f->HasColorGlyphFor(aCh, aNextCh);
|
||||
// If the provided glyph matches the preference, accept the font.
|
||||
if (hasColorGlyph == PrefersColor(presentation)) {
|
||||
RefPtr<gfxFont> autoRefDeref(candidateFont);
|
||||
*aMatchType = t;
|
||||
return true;
|
||||
}
|
||||
|
@ -3225,14 +3229,14 @@ already_AddRefed<gfxFont> gfxFontGroup::FindFontForChar(
|
|||
continue;
|
||||
}
|
||||
|
||||
RefPtr<gfxFont> font = ff.Font();
|
||||
gfxFont* font = ff.Font();
|
||||
if (font) {
|
||||
// if available, use already-made gfxFont and check for character
|
||||
if (font->HasCharacter(aCh) ||
|
||||
(fallbackChar && font->HasCharacter(fallbackChar))) {
|
||||
if (CheckCandidate(font,
|
||||
{FontMatchType::Kind::kFontGroup, ff.Generic()})) {
|
||||
return font.forget();
|
||||
return font;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -3267,7 +3271,7 @@ already_AddRefed<gfxFont> gfxFontGroup::FindFontForChar(
|
|||
if (font) {
|
||||
if (CheckCandidate(font, {FontMatchType::Kind::kFontGroup,
|
||||
mFonts[i].Generic()})) {
|
||||
return font.forget();
|
||||
return font;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3279,7 +3283,7 @@ already_AddRefed<gfxFont> gfxFontGroup::FindFontForChar(
|
|||
if (font) {
|
||||
if (CheckCandidate(font, {FontMatchType::Kind::kFontGroup,
|
||||
mFonts[i].Generic()})) {
|
||||
return font.forget();
|
||||
return font;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3305,7 +3309,7 @@ already_AddRefed<gfxFont> gfxFontGroup::FindFontForChar(
|
|||
if (font) {
|
||||
if (CheckCandidate(font,
|
||||
{FontMatchType::Kind::kFontGroup, ff.Generic()})) {
|
||||
return font.forget();
|
||||
return font;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -3318,7 +3322,7 @@ already_AddRefed<gfxFont> gfxFontGroup::FindFontForChar(
|
|||
if (font) {
|
||||
if (CheckCandidate(font,
|
||||
{FontMatchType::Kind::kFontGroup, ff.Generic()})) {
|
||||
return font.forget();
|
||||
return font;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3326,11 +3330,11 @@ already_AddRefed<gfxFont> gfxFontGroup::FindFontForChar(
|
|||
}
|
||||
|
||||
if (fontListLength == 0) {
|
||||
RefPtr<gfxFont> defaultFont = GetDefaultFont();
|
||||
gfxFont* defaultFont = GetDefaultFont();
|
||||
if (defaultFont->HasCharacter(aCh) ||
|
||||
(fallbackChar && defaultFont->HasCharacter(fallbackChar))) {
|
||||
if (CheckCandidate(defaultFont, FontMatchType::Kind::kFontGroup)) {
|
||||
return defaultFont.forget();
|
||||
return defaultFont;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3350,11 +3354,11 @@ already_AddRefed<gfxFont> gfxFontGroup::FindFontForChar(
|
|||
if (candidateFont) {
|
||||
*aMatchType = candidateMatchType;
|
||||
}
|
||||
return candidateFont.forget();
|
||||
return candidateFont;
|
||||
}
|
||||
|
||||
// 2. search pref fonts
|
||||
RefPtr<gfxFont> font = WhichPrefFontSupportsChar(aCh, aNextCh, presentation);
|
||||
gfxFont* font = WhichPrefFontSupportsChar(aCh, aNextCh, presentation);
|
||||
if (font) {
|
||||
if (PrefersColor(presentation) &&
|
||||
gfxPlatformFontList::PlatformFontList()->EmojiPrefHasUserValue()) {
|
||||
|
@ -3366,11 +3370,13 @@ already_AddRefed<gfxFont> gfxFontGroup::FindFontForChar(
|
|||
// over the Unicode presentation style here.
|
||||
RefPtr<gfxFont> autoRefDeref(candidateFont);
|
||||
*aMatchType = FontMatchType::Kind::kPrefsFallback;
|
||||
return font.forget();
|
||||
return font;
|
||||
}
|
||||
if (CheckCandidate(font, FontMatchType::Kind::kPrefsFallback)) {
|
||||
return font.forget();
|
||||
return font;
|
||||
}
|
||||
// Don't leak `font` if we decided not to return it.
|
||||
RefPtr<gfxFont> autoRefDeref(font);
|
||||
}
|
||||
|
||||
// For fallback searches, we don't want to use a color-emoji font unless
|
||||
|
@ -3388,15 +3394,15 @@ already_AddRefed<gfxFont> gfxFontGroup::FindFontForChar(
|
|||
(fallbackChar && aPrevMatchedFont->HasCharacter(fallbackChar)))) {
|
||||
if (CheckCandidate(aPrevMatchedFont,
|
||||
FontMatchType::Kind::kSystemFallback)) {
|
||||
return do_AddRef(aPrevMatchedFont);
|
||||
return aPrevMatchedFont;
|
||||
}
|
||||
}
|
||||
|
||||
// for known "space" characters, don't do a full system-fallback search;
|
||||
// we'll synthesize appropriate-width spaces instead of missing-glyph boxes
|
||||
font = GetFirstValidFont();
|
||||
if (GetGeneralCategory(aCh) == HB_UNICODE_GENERAL_CATEGORY_SPACE_SEPARATOR &&
|
||||
font->SynthesizeSpaceWidth(aCh) >= 0.0) {
|
||||
GetFirstValidFont()->SynthesizeSpaceWidth(aCh) >= 0.0) {
|
||||
RefPtr<gfxFont> autoRefDeref(candidateFont);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -3404,13 +3410,14 @@ already_AddRefed<gfxFont> gfxFontGroup::FindFontForChar(
|
|||
font = WhichSystemFontSupportsChar(aCh, aNextCh, aRunScript, presentation);
|
||||
if (font) {
|
||||
if (CheckCandidate(font, FontMatchType::Kind::kSystemFallback)) {
|
||||
return font.forget();
|
||||
return font;
|
||||
}
|
||||
RefPtr<gfxFont> autoRefDeref(font);
|
||||
}
|
||||
if (candidateFont) {
|
||||
*aMatchType = candidateMatchType;
|
||||
}
|
||||
return candidateFont.forget();
|
||||
return candidateFont;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
|
@ -3433,7 +3440,7 @@ void gfxFontGroup::ComputeRanges(nsTArray<TextRange>& aRanges, const T* aString,
|
|||
// used for string-initial control chars, etc rather than risk hitting font
|
||||
// fallback for these (bug 716229)
|
||||
StyleGenericFontFamily generic = StyleGenericFontFamily::None;
|
||||
RefPtr<gfxFont> prevFont = GetFirstValidFont(' ', &generic);
|
||||
gfxFont* prevFont = GetFirstValidFont(' ', &generic);
|
||||
|
||||
// if we use the initial value of prevFont, we treat this as a match from
|
||||
// the font group; fixes bug 978313
|
||||
|
@ -3466,7 +3473,7 @@ void gfxFontGroup::ComputeRanges(nsTArray<TextRange>& aRanges, const T* aString,
|
|||
nextCh = i < aLength - 1 ? aString[i + 1] : 0;
|
||||
}
|
||||
|
||||
RefPtr<gfxFont> font;
|
||||
gfxFont* font;
|
||||
|
||||
// Find the font for this char; but try to avoid calling the expensive
|
||||
// FindFontForChar method for the most common case, where the first
|
||||
|
@ -3543,7 +3550,7 @@ void gfxFontGroup::ComputeRanges(nsTArray<TextRange>& aRanges, const T* aString,
|
|||
// first char ==> make a new range
|
||||
aRanges.AppendElement(TextRange(0, 1, font, matchType, orient));
|
||||
lastRangeIndex++;
|
||||
prevFont = std::move(font);
|
||||
prevFont = font;
|
||||
} else {
|
||||
// if font or orientation has changed, make a new range...
|
||||
// unless ch is a variation selector (bug 1248248)
|
||||
|
@ -3559,7 +3566,7 @@ void gfxFontGroup::ComputeRanges(nsTArray<TextRange>& aRanges, const T* aString,
|
|||
// fonts on a ZWJ, in which case propagating the changed font
|
||||
// is probably not a good idea (see bug 619511)
|
||||
if (sizeof(T) == sizeof(uint8_t) || !gfxFontUtils::IsJoinCauser(ch)) {
|
||||
prevFont = std::move(font);
|
||||
prevFont = font;
|
||||
}
|
||||
} else {
|
||||
prevRange.matchType |= matchType;
|
||||
|
@ -3676,7 +3683,7 @@ bool gfxFontGroup::ContainsUserFont(const gfxUserFontEntry* aUserFont) {
|
|||
return false;
|
||||
}
|
||||
|
||||
already_AddRefed<gfxFont> gfxFontGroup::WhichPrefFontSupportsChar(
|
||||
gfxFont* gfxFontGroup::WhichPrefFontSupportsChar(
|
||||
uint32_t aCh, uint32_t aNextCh, eFontPresentation aPresentation) {
|
||||
eFontPrefLang charLang;
|
||||
gfxPlatformFontList* pfl = gfxPlatformFontList::PlatformFontList();
|
||||
|
@ -3692,7 +3699,7 @@ already_AddRefed<gfxFont> gfxFontGroup::WhichPrefFontSupportsChar(
|
|||
// recheck through a list of families
|
||||
if (mLastPrefFont && charLang == mLastPrefLang && mLastPrefFirstFont &&
|
||||
mLastPrefFont->HasCharacter(aCh)) {
|
||||
return do_AddRef(mLastPrefFont);
|
||||
return mLastPrefFont;
|
||||
}
|
||||
|
||||
// based on char lang and page lang, set up list of pref lang fonts to check
|
||||
|
@ -3726,7 +3733,7 @@ already_AddRefed<gfxFont> gfxFontGroup::WhichPrefFontSupportsChar(
|
|||
// than calling FindOrMakeFont repeatedly. speeds up FindFontForChar
|
||||
// lookup times for subsequent pref font lookups
|
||||
if (family == mLastPrefFamily && mLastPrefFont->HasCharacter(aCh)) {
|
||||
return do_AddRef(mLastPrefFont);
|
||||
return mLastPrefFont;
|
||||
}
|
||||
|
||||
gfxFontEntry* fe = nullptr;
|
||||
|
@ -3748,7 +3755,7 @@ already_AddRefed<gfxFont> gfxFontGroup::WhichPrefFontSupportsChar(
|
|||
}
|
||||
|
||||
// if ch in cmap, create and return a gfxFont
|
||||
RefPtr<gfxFont> prefFont;
|
||||
gfxFont* prefFont = nullptr;
|
||||
if (fe->HasCharacter(aCh)) {
|
||||
prefFont = fe->FindOrMakeFont(&mStyle);
|
||||
if (!prefFont) {
|
||||
|
@ -3770,7 +3777,7 @@ already_AddRefed<gfxFont> gfxFontGroup::WhichPrefFontSupportsChar(
|
|||
mLastPrefFont = prefFont;
|
||||
mLastPrefLang = charLang;
|
||||
mLastPrefFirstFont = (i == 0 && j == 0);
|
||||
return prefFont.forget();
|
||||
return prefFont;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3778,13 +3785,19 @@ already_AddRefed<gfxFont> gfxFontGroup::WhichPrefFontSupportsChar(
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
already_AddRefed<gfxFont> gfxFontGroup::WhichSystemFontSupportsChar(
|
||||
gfxFont* gfxFontGroup::WhichSystemFontSupportsChar(
|
||||
uint32_t aCh, uint32_t aNextCh, Script aRunScript,
|
||||
eFontPresentation aPresentation) {
|
||||
FontVisibility visibility;
|
||||
return gfxPlatformFontList::PlatformFontList()->SystemFindFontForChar(
|
||||
mPresContext, aCh, aNextCh, aRunScript, aPresentation, &mStyle,
|
||||
&visibility);
|
||||
gfxFont* font =
|
||||
gfxPlatformFontList::PlatformFontList()->SystemFindFontForChar(
|
||||
mPresContext, aCh, aNextCh, aRunScript, aPresentation, &mStyle,
|
||||
&visibility);
|
||||
if (font) {
|
||||
return font;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void gfxMissingFontRecorder::Flush() {
|
||||
|
|
|
@ -941,13 +941,13 @@ class gfxFontGroup final : public gfxTextRunFactory {
|
|||
// Initiates userfont loads if userfont not loaded.
|
||||
// aGeneric: if non-null, returns the CSS generic type that was mapped to
|
||||
// this font
|
||||
already_AddRefed<gfxFont> GetFirstValidFont(
|
||||
gfxFont* GetFirstValidFont(
|
||||
uint32_t aCh = 0x20, mozilla::StyleGenericFontFamily* aGeneric = nullptr);
|
||||
|
||||
// Returns the first font in the font-group that has an OpenType MATH table,
|
||||
// or null if no such font is available. The GetMathConstant methods may be
|
||||
// called on the returned font.
|
||||
already_AddRefed<gfxFont> GetFirstMathFont();
|
||||
gfxFont* GetFirstMathFont();
|
||||
|
||||
const gfxFontStyle* GetStyle() const { return &mStyle; }
|
||||
|
||||
|
@ -1032,10 +1032,9 @@ class gfxFontGroup final : public gfxTextRunFactory {
|
|||
enum { UNDERLINE_OFFSET_NOT_SET = INT16_MAX };
|
||||
gfxFloat GetUnderlineOffset();
|
||||
|
||||
already_AddRefed<gfxFont> FindFontForChar(uint32_t ch, uint32_t prevCh,
|
||||
uint32_t aNextCh, Script aRunScript,
|
||||
gfxFont* aPrevMatchedFont,
|
||||
FontMatchType* aMatchType);
|
||||
gfxFont* FindFontForChar(uint32_t ch, uint32_t prevCh, uint32_t aNextCh,
|
||||
Script aRunScript, gfxFont* aPrevMatchedFont,
|
||||
FontMatchType* aMatchType);
|
||||
|
||||
gfxUserFontSet* GetUserFontSet();
|
||||
|
||||
|
@ -1119,12 +1118,12 @@ class gfxFontGroup final : public gfxTextRunFactory {
|
|||
|
||||
// search through pref fonts for a character, return nullptr if no matching
|
||||
// pref font
|
||||
already_AddRefed<gfxFont> WhichPrefFontSupportsChar(
|
||||
uint32_t aCh, uint32_t aNextCh, eFontPresentation aPresentation);
|
||||
gfxFont* WhichPrefFontSupportsChar(uint32_t aCh, uint32_t aNextCh,
|
||||
eFontPresentation aPresentation);
|
||||
|
||||
already_AddRefed<gfxFont> WhichSystemFontSupportsChar(
|
||||
uint32_t aCh, uint32_t aNextCh, Script aRunScript,
|
||||
eFontPresentation aPresentation);
|
||||
gfxFont* WhichSystemFontSupportsChar(uint32_t aCh, uint32_t aNextCh,
|
||||
Script aRunScript,
|
||||
eFontPresentation aPresentation);
|
||||
|
||||
template <typename T>
|
||||
void ComputeRanges(nsTArray<TextRange>& aRanges, const T* aString,
|
||||
|
@ -1449,17 +1448,17 @@ class gfxFontGroup final : public gfxTextRunFactory {
|
|||
// If *aLoading is true, a relevant resource is already being loaded so no
|
||||
// new download will be initiated; if a download is started, *aLoading will
|
||||
// be set to true on return.
|
||||
already_AddRefed<gfxFont> GetFontAt(int32_t i, uint32_t aCh, bool* aLoading);
|
||||
gfxFont* GetFontAt(int32_t i, uint32_t aCh, bool* aLoading);
|
||||
|
||||
// Simplified version of GetFontAt() for use where we just need a font for
|
||||
// metrics, math layout tables, etc.
|
||||
already_AddRefed<gfxFont> GetFontAt(int32_t i, uint32_t aCh = 0x20) {
|
||||
gfxFont* GetFontAt(int32_t i, uint32_t aCh = 0x20) {
|
||||
bool loading = false;
|
||||
return GetFontAt(i, aCh, &loading);
|
||||
}
|
||||
|
||||
// will always return a font or force a shutdown
|
||||
already_AddRefed<gfxFont> GetDefaultFont();
|
||||
gfxFont* GetDefaultFont();
|
||||
|
||||
// Init this font group's font metrics. If there no bad fonts, you don't need
|
||||
// to call this. But if there are one or more bad fonts which have bad
|
||||
|
@ -1484,17 +1483,17 @@ class gfxFontGroup final : public gfxTextRunFactory {
|
|||
// Helper for font-matching:
|
||||
// search all faces in a family for a fallback in cases where it's unclear
|
||||
// whether the family might have a font for a given character
|
||||
already_AddRefed<gfxFont> FindFallbackFaceForChar(
|
||||
const FamilyFace& aFamily, uint32_t aCh, uint32_t aNextCh,
|
||||
eFontPresentation aPresentation);
|
||||
gfxFont* FindFallbackFaceForChar(const FamilyFace& aFamily, uint32_t aCh,
|
||||
uint32_t aNextCh,
|
||||
eFontPresentation aPresentation);
|
||||
|
||||
already_AddRefed<gfxFont> FindFallbackFaceForChar(
|
||||
mozilla::fontlist::Family* aFamily, uint32_t aCh, uint32_t aNextCh,
|
||||
eFontPresentation aPresentation);
|
||||
gfxFont* FindFallbackFaceForChar(mozilla::fontlist::Family* aFamily,
|
||||
uint32_t aCh, uint32_t aNextCh,
|
||||
eFontPresentation aPresentation);
|
||||
|
||||
already_AddRefed<gfxFont> FindFallbackFaceForChar(
|
||||
gfxFontFamily* aFamily, uint32_t aCh, uint32_t aNextCh,
|
||||
eFontPresentation aPresentation);
|
||||
gfxFont* FindFallbackFaceForChar(gfxFontFamily* aFamily, uint32_t aCh,
|
||||
uint32_t aNextCh,
|
||||
eFontPresentation aPresentation);
|
||||
|
||||
// helper methods for looking up fonts
|
||||
|
||||
|
|
|
@ -607,9 +607,11 @@ static nscoord ListImageDefaultLength(const nsImageFrame& aFrame) {
|
|||
auto* pc = aFrame.PresContext();
|
||||
RefPtr<nsFontMetrics> fm =
|
||||
nsLayoutUtils::GetFontMetricsForComputedStyle(aFrame.Style(), pc);
|
||||
RefPtr<gfxFont> font = fm->GetThebesFontGroup()->GetFirstValidFont();
|
||||
auto emAU =
|
||||
font->GetMetrics(fm->Orientation()).emHeight * pc->AppUnitsPerDevPixel();
|
||||
auto emAU = fm->GetThebesFontGroup()
|
||||
->GetFirstValidFont()
|
||||
->GetMetrics(fm->Orientation())
|
||||
.emHeight *
|
||||
pc->AppUnitsPerDevPixel();
|
||||
return std::max(NSToCoordRound(0.4f * emAU),
|
||||
nsPresContext::CSSPixelsToAppUnits(1));
|
||||
}
|
||||
|
|
|
@ -1826,7 +1826,7 @@ static bool HasTerminalNewline(const nsTextFrame* aFrame) {
|
|||
static gfxFont::Metrics GetFirstFontMetrics(gfxFontGroup* aFontGroup,
|
||||
bool aVerticalMetrics) {
|
||||
if (!aFontGroup) return gfxFont::Metrics();
|
||||
RefPtr<gfxFont> font = aFontGroup->GetFirstValidFont();
|
||||
gfxFont* font = aFontGroup->GetFirstValidFont();
|
||||
return font->GetMetrics(aVerticalMetrics ? nsFontMetrics::eVertical
|
||||
: nsFontMetrics::eHorizontal);
|
||||
}
|
||||
|
@ -5646,11 +5646,10 @@ void nsTextFrame::UnionAdditionalOverflow(nsPresContext* aPresContext,
|
|||
|
||||
bool useVerticalMetrics = verticalRun && mTextRun->UseCenterBaseline();
|
||||
nsFontMetrics* fontMetrics = aProvider.GetFontMetrics();
|
||||
RefPtr<gfxFont> font =
|
||||
fontMetrics->GetThebesFontGroup()->GetFirstValidFont();
|
||||
const gfxFont::Metrics& metrics =
|
||||
font->GetMetrics(useVerticalMetrics ? nsFontMetrics::eVertical
|
||||
: nsFontMetrics::eHorizontal);
|
||||
fontMetrics->GetThebesFontGroup()->GetFirstValidFont()->GetMetrics(
|
||||
useVerticalMetrics ? nsFontMetrics::eVertical
|
||||
: nsFontMetrics::eHorizontal);
|
||||
|
||||
params.defaultLineThickness = metrics.underlineSize;
|
||||
params.lineSize.height = ComputeDecorationLineThickness(
|
||||
|
@ -6584,8 +6583,7 @@ void nsTextFrame::PaintTextSelectionDecorations(
|
|||
}
|
||||
}
|
||||
|
||||
RefPtr<gfxFont> firstFont =
|
||||
aParams.provider->GetFontGroup()->GetFirstValidFont();
|
||||
gfxFont* firstFont = aParams.provider->GetFontGroup()->GetFirstValidFont();
|
||||
bool verticalRun = mTextRun->IsVertical();
|
||||
bool useVerticalMetrics = verticalRun && mTextRun->UseCenterBaseline();
|
||||
bool rightUnderline = useVerticalMetrics && IsUnderlineRight(*Style());
|
||||
|
@ -7548,7 +7546,7 @@ bool nsTextFrame::CombineSelectionUnderlineRect(nsPresContext* aPresContext,
|
|||
nsRect givenRect = aRect;
|
||||
|
||||
gfxFontGroup* fontGroup = GetInflatedFontGroupForFrame(this);
|
||||
RefPtr<gfxFont> firstFont = fontGroup->GetFirstValidFont();
|
||||
gfxFont* firstFont = fontGroup->GetFirstValidFont();
|
||||
WritingMode wm = GetWritingMode();
|
||||
bool verticalRun = wm.IsVertical();
|
||||
bool useVerticalMetrics = verticalRun && !wm.IsSideways();
|
||||
|
|
|
@ -499,15 +499,16 @@ already_AddRefed<gfxTextRun> nsOpenTypeTable::MakeTextRun(
|
|||
RefPtr<gfxTextRun> textRun =
|
||||
gfxTextRun::Create(¶ms, 1, aFontGroup, gfx::ShapedTextFlags(),
|
||||
nsTextFrameUtils::Flags());
|
||||
RefPtr<gfxFont> font = aFontGroup->GetFirstValidFont();
|
||||
textRun->AddGlyphRun(font, FontMatchType::Kind::kFontGroup, 0, false,
|
||||
textRun->AddGlyphRun(aFontGroup->GetFirstValidFont(),
|
||||
FontMatchType::Kind::kFontGroup, 0, false,
|
||||
gfx::ShapedTextFlags::TEXT_ORIENT_HORIZONTAL, false);
|
||||
// We don't care about CSS writing mode here;
|
||||
// math runs are assumed to be horizontal.
|
||||
gfxTextRun::DetailedGlyph detailedGlyph;
|
||||
detailedGlyph.mGlyphID = aGlyph.glyphID;
|
||||
detailedGlyph.mAdvance = NSToCoordRound(
|
||||
aAppUnitsPerDevPixel * font->GetGlyphAdvance(aGlyph.glyphID));
|
||||
aAppUnitsPerDevPixel *
|
||||
aFontGroup->GetFirstValidFont()->GetGlyphAdvance(aGlyph.glyphID));
|
||||
textRun->SetDetailedGlyphs(0, 1, &detailedGlyph);
|
||||
|
||||
return textRun.forget();
|
||||
|
@ -874,7 +875,7 @@ bool nsMathMLChar::SetFontFamily(nsPresContext* aPresContext,
|
|||
|
||||
const auto& firstFontInList = familyList.list.AsSpan()[0];
|
||||
|
||||
RefPtr<gfxFont> firstFont = fm->GetThebesFontGroup()->GetFirstValidFont();
|
||||
gfxFont* firstFont = fm->GetThebesFontGroup()->GetFirstValidFont();
|
||||
RefPtr<nsAtom> firstFontName =
|
||||
NS_Atomize(firstFont->GetFontEntry()->FamilyName());
|
||||
|
||||
|
@ -986,7 +987,7 @@ bool nsMathMLChar::StretchEnumContext::TryVariants(
|
|||
ch = aGlyphTable->BigOf(mDrawTarget, oneDevPixel, *aFontGroup, uchar,
|
||||
isVertical, 0);
|
||||
if (ch.IsGlyphID()) {
|
||||
RefPtr<gfxFont> mathFont = aFontGroup->get()->GetFirstMathFont();
|
||||
gfxFont* mathFont = aFontGroup->get()->GetFirstMathFont();
|
||||
// For OpenType MATH fonts, we will rely on the DisplayOperatorMinHeight
|
||||
// to select the right size variant. Note that the value is sometimes too
|
||||
// small so we use kLargeOpFactor/kIntegralFactor as a minimum value.
|
||||
|
@ -1026,7 +1027,7 @@ bool nsMathMLChar::StretchEnumContext::TryVariants(
|
|||
aGlyphTable->MakeTextRun(mDrawTarget, oneDevPixel, *aFontGroup, ch);
|
||||
nsBoundingMetrics bm = MeasureTextRun(mDrawTarget, textRun.get());
|
||||
if (ch.IsGlyphID()) {
|
||||
RefPtr<gfxFont> mathFont = aFontGroup->get()->GetFirstMathFont();
|
||||
gfxFont* mathFont = aFontGroup->get()->GetFirstMathFont();
|
||||
if (mathFont) {
|
||||
// MeasureTextRun should have set the advance width to the right
|
||||
// bearing for OpenType MATH fonts. We now subtract the italic
|
||||
|
@ -1293,8 +1294,7 @@ bool nsMathMLChar::StretchEnumContext::EnumCallback(
|
|||
glyphTable = &gGlyphTableList->mUnicodeTable;
|
||||
} else {
|
||||
// If the font contains an Open Type MATH table, use it.
|
||||
RefPtr<gfxFont> font = fontGroup->GetFirstValidFont();
|
||||
openTypeTable = nsOpenTypeTable::Create(font);
|
||||
openTypeTable = nsOpenTypeTable::Create(fontGroup->GetFirstValidFont());
|
||||
if (openTypeTable) {
|
||||
glyphTable = openTypeTable.get();
|
||||
} else if (StaticPrefs::mathml_stixgeneral_operator_stretching_disabled()) {
|
||||
|
@ -1547,8 +1547,7 @@ nsresult nsMathMLChar::StretchInternal(
|
|||
// operator. Verify whether a font with an OpenType MATH table is available
|
||||
// and record missing math script otherwise.
|
||||
gfxMissingFontRecorder* MFR = presContext->MissingFontRecorder();
|
||||
RefPtr<gfxFont> firstMathFont = fm->GetThebesFontGroup()->GetFirstMathFont();
|
||||
if (MFR && !firstMathFont) {
|
||||
if (MFR && !fm->GetThebesFontGroup()->GetFirstMathFont()) {
|
||||
MFR->RecordScript(intl::Script::MATHEMATICAL_NOTATION);
|
||||
}
|
||||
|
||||
|
|
|
@ -162,8 +162,7 @@ void nsMathMLFrame::GetRuleThickness(DrawTarget* aDrawTarget,
|
|||
void nsMathMLFrame::GetAxisHeight(DrawTarget* aDrawTarget,
|
||||
nsFontMetrics* aFontMetrics,
|
||||
nscoord& aAxisHeight) {
|
||||
RefPtr<gfxFont> mathFont =
|
||||
aFontMetrics->GetThebesFontGroup()->GetFirstMathFont();
|
||||
gfxFont* mathFont = aFontMetrics->GetThebesFontGroup()->GetFirstMathFont();
|
||||
if (mathFont) {
|
||||
aAxisHeight = mathFont->MathTable()->Constant(
|
||||
gfxMathTable::AxisHeight, aFontMetrics->AppUnitsPerDevPixel());
|
||||
|
@ -346,8 +345,7 @@ void nsMathMLFrame::GetRadicalParameters(nsFontMetrics* aFontMetrics,
|
|||
nscoord& aRadicalExtraAscender,
|
||||
nscoord& aRadicalVerticalGap) {
|
||||
nscoord oneDevPixel = aFontMetrics->AppUnitsPerDevPixel();
|
||||
RefPtr<gfxFont> mathFont =
|
||||
aFontMetrics->GetThebesFontGroup()->GetFirstMathFont();
|
||||
gfxFont* mathFont = aFontMetrics->GetThebesFontGroup()->GetFirstMathFont();
|
||||
|
||||
// get the radical rulethickness
|
||||
if (mathFont) {
|
||||
|
|
|
@ -230,7 +230,7 @@ nsresult nsMathMLmfracFrame::PlaceInternal(DrawTarget* aDrawTarget,
|
|||
|
||||
nscoord defaultRuleThickness, axisHeight;
|
||||
nscoord oneDevPixel = fm->AppUnitsPerDevPixel();
|
||||
RefPtr<gfxFont> mathFont = fm->GetThebesFontGroup()->GetFirstMathFont();
|
||||
gfxFont* mathFont = fm->GetThebesFontGroup()->GetFirstMathFont();
|
||||
if (mathFont) {
|
||||
defaultRuleThickness = mathFont->MathTable()->Constant(
|
||||
gfxMathTable::FractionRuleThickness, oneDevPixel);
|
||||
|
|
|
@ -191,7 +191,7 @@ nsresult nsMathMLmmultiscriptsFrame::PlaceMultiScript(
|
|||
nscoord xHeight = fm->XHeight();
|
||||
|
||||
nscoord oneDevPixel = fm->AppUnitsPerDevPixel();
|
||||
RefPtr<gfxFont> mathFont = fm->GetThebesFontGroup()->GetFirstMathFont();
|
||||
gfxFont* mathFont = fm->GetThebesFontGroup()->GetFirstMathFont();
|
||||
// scriptspace from TeX for extra spacing after sup/subscript
|
||||
nscoord scriptSpace;
|
||||
if (mathFont) {
|
||||
|
|
|
@ -98,8 +98,7 @@ void nsMathMLmrootFrame::GetRadicalXOffsets(nscoord aIndexWidth,
|
|||
nscoord xHeight = aFontMetrics->XHeight();
|
||||
nscoord indexRadicalKern = NSToCoordRound(1.35f * xHeight);
|
||||
nscoord oneDevPixel = aFontMetrics->AppUnitsPerDevPixel();
|
||||
RefPtr<gfxFont> mathFont =
|
||||
aFontMetrics->GetThebesFontGroup()->GetFirstMathFont();
|
||||
gfxFont* mathFont = aFontMetrics->GetThebesFontGroup()->GetFirstMathFont();
|
||||
if (mathFont) {
|
||||
indexRadicalKern = mathFont->MathTable()->Constant(
|
||||
gfxMathTable::RadicalKernAfterDegree, oneDevPixel);
|
||||
|
@ -268,7 +267,7 @@ void nsMathMLmrootFrame::Reflow(nsPresContext* aPresContext,
|
|||
// the index is raised by some fraction of the height
|
||||
// of the radical, see \mroot macro in App. B, TexBook
|
||||
float raiseIndexPercent = 0.6f;
|
||||
RefPtr<gfxFont> mathFont = fm->GetThebesFontGroup()->GetFirstMathFont();
|
||||
gfxFont* mathFont = fm->GetThebesFontGroup()->GetFirstMathFont();
|
||||
if (mathFont) {
|
||||
raiseIndexPercent = mathFont->MathTable()->Constant(
|
||||
gfxMathTable::RadicalDegreeBottomRaisePercent);
|
||||
|
|
|
@ -452,7 +452,7 @@ nsresult nsMathMLmunderoverFrame::Place(DrawTarget* aDrawTarget,
|
|||
|
||||
nscoord xHeight = fm->XHeight();
|
||||
nscoord oneDevPixel = fm->AppUnitsPerDevPixel();
|
||||
RefPtr<gfxFont> mathFont = fm->GetThebesFontGroup()->GetFirstMathFont();
|
||||
gfxFont* mathFont = fm->GetThebesFontGroup()->GetFirstMathFont();
|
||||
|
||||
nscoord ruleThickness;
|
||||
GetRuleThickness(aDrawTarget, fm, ruleThickness);
|
||||
|
|
|
@ -1384,8 +1384,9 @@ GeckoFontMetrics Gecko_GetFontMetrics(const nsPresContext* aPresContext,
|
|||
|
||||
RefPtr<nsFontMetrics> fm = nsLayoutUtils::GetMetricsFor(
|
||||
presContext, aIsVertical, aFont, aFontSize, aUseUserFontSet);
|
||||
RefPtr<gfxFont> font = fm->GetThebesFontGroup()->GetFirstValidFont();
|
||||
const auto& metrics = font->GetMetrics(fm->Orientation());
|
||||
const auto& metrics =
|
||||
fm->GetThebesFontGroup()->GetFirstValidFont()->GetMetrics(
|
||||
fm->Orientation());
|
||||
|
||||
int32_t d2a = aPresContext->AppUnitsPerDevPixel();
|
||||
auto ToLength = [](nscoord aLen) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче