Bug 387867. Rename DISABLE_LIGATURES to DISABLE_OPTIONAL_LIGATURES and make the ATSUI code only disable optional ligatures. r=pavlov
git-svn-id: svn://10.0.0.236/trunk@229884 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -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
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user