diff --git a/mozilla/gfx/thebes/public/gfxFont.h b/mozilla/gfx/thebes/public/gfxFont.h index 03ef48947ea..c20f6f4d522 100644 --- a/mozilla/gfx/thebes/public/gfxFont.h +++ b/mozilla/gfx/thebes/public/gfxFont.h @@ -468,7 +468,8 @@ public: */ TEXT_ENABLE_HYPHEN_BREAKS = 0x0040, /** - * When set, the text has no characters above 255. + * When set, the text has no characters above 255 and it is stored + * in the textrun in 8-bit format. */ TEXT_IS_8BIT = 0x0080, /** @@ -485,9 +486,10 @@ public: */ TEXT_NEED_BOUNDING_BOX = 0x0200, /** - * When set, ligatures are disabled. + * When set, optional ligatures are disabled. Ligatures that are + * required for legible text should still be enabled. */ - TEXT_DISABLE_LIGATURES = 0x0400 + TEXT_DISABLE_OPTIONAL_LIGATURES = 0x0400 }; /** diff --git a/mozilla/gfx/thebes/src/gfxAtsuiFonts.cpp b/mozilla/gfx/thebes/src/gfxAtsuiFonts.cpp index a665dffaae2..ee413c4fef5 100644 --- a/mozilla/gfx/thebes/src/gfxAtsuiFonts.cpp +++ b/mozilla/gfx/thebes/src/gfxAtsuiFonts.cpp @@ -936,10 +936,9 @@ AddGlyphRun(gfxTextRun *aRun, gfxAtsuiFont *aFont, PRUint32 aOffset) } static void -DisableLigaturesInStyle(ATSUStyle aStyle) +DisableOptionalLigaturesInStyle(ATSUStyle aStyle) { - static ATSUFontFeatureType selectors[9] = { - kRequiredLigaturesOffSelector, + static ATSUFontFeatureType selectors[] = { kCommonLigaturesOffSelector, kRareLigaturesOffSelector, kLogosOffSelector, @@ -957,7 +956,6 @@ DisableLigaturesInStyle(ATSUStyle aStyle) kLigaturesType, kLigaturesType, kLigaturesType, - kLigaturesType, kLigaturesType }; ATSUSetFontFeatures(aStyle, NS_ARRAY_LENGTH(selectors), types, selectors); @@ -1027,11 +1025,11 @@ gfxAtsuiFontGroup::InitTextRun(gfxTextRun *aRun, printf("%p(%s) TEXTRUN \"%s\" ENDTEXTRUN\n", this, families.get(), str.get()); #endif - if (aRun->GetFlags() & TEXT_DISABLE_LIGATURES) { + if (aRun->GetFlags() & TEXT_DISABLE_OPTIONAL_LIGATURES) { status = ATSUCreateAndCopyStyle(mainStyle, &mainStyle); if (status == noErr) { stylesToDispose.AppendElement(mainStyle); - DisableLigaturesInStyle(mainStyle); + DisableOptionalLigaturesInStyle(mainStyle); } } diff --git a/mozilla/gfx/thebes/src/gfxTextRunWordCache.cpp b/mozilla/gfx/thebes/src/gfxTextRunWordCache.cpp index 21d81a0f57d..70f7aef204e 100644 --- a/mozilla/gfx/thebes/src/gfxTextRunWordCache.cpp +++ b/mozilla/gfx/thebes/src/gfxTextRunWordCache.cpp @@ -37,7 +37,6 @@ #include "gfxTextRunWordCache.h" - /** * Cache individual "words" (strings delimited by white-space or white-space-like * characters that don't involve kerning or ligatures) in textruns. @@ -93,6 +92,19 @@ protected: PRUint32 mStringHash; PRPackedBool mIsDoubleByteText; PRPackedBool mIsRTL; + PRPackedBool mEnabledOptionalLigatures; + + CacheHashKey(gfxTextRun *aBaseTextRun, void *aFontOrGroup, + PRUint32 aStart, PRUint32 aLength, PRUint32 aHash) + : mFontOrGroup(aFontOrGroup), mString(aBaseTextRun->GetTextAt(aStart)), + mLength(aLength), + mAppUnitsPerDevUnit(aBaseTextRun->GetAppUnitsPerDevUnit()), + mStringHash(aHash), + mIsDoubleByteText((aBaseTextRun->GetFlags() & gfxTextRunFactory::TEXT_IS_8BIT) == 0), + mIsRTL(aBaseTextRun->IsRightToLeft()), + mEnabledOptionalLigatures((aBaseTextRun->GetFlags() & gfxTextRunFactory::TEXT_DISABLE_OPTIONAL_LIGATURES) == 0) + { + } }; class CacheHashEntry : public PLDHashEntryHdr { @@ -220,12 +232,7 @@ TextRunWordCache::LookupWord(gfxTextRun *aTextRun, gfxFont *aFirstFont, if (aEnd <= aStart) return PR_TRUE; - PRUint32 length = aEnd - aStart; - CacheHashKey key = - { aFirstFont, aTextRun->GetTextAt(aStart), - length, aTextRun->GetAppUnitsPerDevUnit(), aHash, - (aTextRun->GetFlags() & gfxTextRunFactory::TEXT_IS_8BIT) == 0, - aTextRun->IsRightToLeft() }; + CacheHashKey key(aTextRun, aFirstFont, aStart, aEnd - aStart, aHash); CacheHashEntry *fontEntry = mCache.PutEntry(key); if (!fontEntry) return PR_FALSE; @@ -304,11 +311,8 @@ TextRunWordCache::FinishTextRun(gfxTextRun *aTextRun, gfxTextRun *aNewRun, // keyed off the fontgroup. if (!aSuccessful || GetWordFontOrGroup(aNewRun, word->mSourceOffset, word->mLength) != font) { - CacheHashKey key = - { font, aTextRun->GetTextAt(word->mDestOffset), - word->mLength, aTextRun->GetAppUnitsPerDevUnit(), word->mHash, - (aTextRun->GetFlags() & gfxTextRunFactory::TEXT_IS_8BIT) == 0, - aTextRun->IsRightToLeft() }; + CacheHashKey key(aTextRun, font, word->mDestOffset, word->mLength, + word->mHash); NS_ASSERTION(mCache.GetEntry(key), "This entry should have been added previously!"); mCache.RemoveEntry(key); @@ -506,18 +510,15 @@ TextRunWordCache::RemoveWord(gfxTextRun *aTextRun, PRUint32 aStart, return; PRUint32 length = aEnd - aStart; - CacheHashKey key = - { GetWordFontOrGroup(aTextRun, aStart, length), aTextRun->GetTextAt(aStart), - length, aTextRun->GetAppUnitsPerDevUnit(), aHash, - (aTextRun->GetFlags() & gfxTextRunFactory::TEXT_IS_8BIT) == 0, - aTextRun->IsRightToLeft() }; + CacheHashKey key(aTextRun, GetWordFontOrGroup(aTextRun, aStart, length), + aStart, length, aHash); CacheHashEntry *entry = mCache.GetEntry(key); if (entry && entry->mTextRun == aTextRun) { // XXX would like to use RawRemoveEntry here plus some extra method // that conditionally shrinks the hashtable mCache.RemoveEntry(key); PR_LOG(gWordCacheLog, PR_LOG_DEBUG, ("%p(%d-%d,%d): removed using %s", - aTextRun, aStart, aEnd - aStart, aHash, + aTextRun, aStart, length, aHash, key.mFontOrGroup == aTextRun->GetFontGroup() ? "fontgroup" : "font")); } } @@ -584,7 +585,8 @@ TextRunWordCache::CacheHashEntry::KeyEquals(const KeyTypePointer aKey) const if (!IsWordEnd(mTextRun, mWordOffset + length) || GetFontOrGroup(fontGroup, mHashedByFont) != aKey->mFontOrGroup || aKey->mAppUnitsPerDevUnit != mTextRun->GetAppUnitsPerDevUnit() || - aKey->mIsRTL != mTextRun->IsRightToLeft()) + aKey->mIsRTL != mTextRun->IsRightToLeft() || + aKey->mEnabledOptionalLigatures != ((mTextRun->GetFlags() & gfxTextRunFactory::TEXT_DISABLE_OPTIONAL_LIGATURES) == 0)) return PR_FALSE; if (mTextRun->GetFlags() & gfxFontGroup::TEXT_IS_8BIT) { @@ -606,7 +608,7 @@ PLDHashNumber TextRunWordCache::CacheHashEntry::HashKey(const KeyTypePointer aKey) { return aKey->mStringHash + (long)aKey->mFontOrGroup + aKey->mAppUnitsPerDevUnit + - aKey->mIsDoubleByteText + aKey->mIsRTL * 2; + aKey->mIsDoubleByteText + aKey->mIsRTL*2 + aKey->mEnabledOptionalLigatures*4; } static TextRunWordCache *gTextRunWordCache = nsnull; diff --git a/mozilla/layout/generic/nsTextFrameThebes.cpp b/mozilla/layout/generic/nsTextFrameThebes.cpp index d293b947d1f..e010ddef44b 100644 --- a/mozilla/layout/generic/nsTextFrameThebes.cpp +++ b/mozilla/layout/generic/nsTextFrameThebes.cpp @@ -1285,7 +1285,7 @@ static nscoord StyleToCoord(const nsStyleCoord& aCoord) } static PRBool -ShouldDisableLigatures(const nsStyleText* aTextStyle) +ShouldDisableOptionalLigatures(const nsStyleText* aTextStyle) { return StyleToCoord(aTextStyle->mLetterSpacing) != 0; } @@ -1322,7 +1322,7 @@ BuildTextRunsScanner::ContinueTextRunAcrossFrames(nsTextFrame* aFrame1, nsTextFr return PR_TRUE; return sc1->GetStyleFont()->mFont.BaseEquals(sc2->GetStyleFont()->mFont) && sc1->GetStyleVisibility()->mLangGroup == sc2->GetStyleVisibility()->mLangGroup && - ShouldDisableLigatures(textStyle1) == ShouldDisableLigatures(sc2->GetStyleText()); + ShouldDisableOptionalLigatures(textStyle1) == ShouldDisableOptionalLigatures(sc2->GetStyleText()); } void BuildTextRunsScanner::ScanFrame(nsIFrame* aFrame) @@ -1708,8 +1708,8 @@ BuildTextRunsScanner::BuildTextRunForFrames(void* aTextBuffer) if (mTrimNextRunLeadingWhitespace) { textFlags |= nsTextFrameUtils::TEXT_TRAILING_WHITESPACE; } - if (ShouldDisableLigatures(firstFrame->GetStyleText())) { - textFlags |= gfxTextRunFactory::TEXT_DISABLE_LIGATURES; + if (ShouldDisableOptionalLigatures(firstFrame->GetStyleText())) { + textFlags |= gfxTextRunFactory::TEXT_DISABLE_OPTIONAL_LIGATURES; } gfxSkipChars skipChars;