From 22e45a4c15957e4d5481df7307f8de48ed1c22ab Mon Sep 17 00:00:00 2001 From: Robert O'Callahan Date: Thu, 30 Jul 2009 14:59:41 +1200 Subject: [PATCH] Bug 492309. Remove useless gfxTextRuNnFactory flags. r=vlad --HG-- extra : rebase_source : 4cdbc37f404c07f509adbfb581c662187813bc4a --- gfx/thebes/public/gfxFont.h | 37 +++------------------ gfx/thebes/public/gfxTextRunCache.h | 3 +- gfx/thebes/public/gfxTextRunWordCache.h | 16 ++++----- gfx/thebes/src/gfxAtsuiFonts.cpp | 1 - gfx/thebes/src/gfxCoreTextFonts.cpp | 1 - gfx/thebes/src/gfxFT2Fonts.cpp | 2 -- gfx/thebes/src/gfxFont.cpp | 24 ------------- gfx/thebes/src/gfxOS2Fonts.cpp | 2 -- gfx/thebes/src/gfxPangoFonts.cpp | 2 -- gfx/thebes/src/gfxTextRunWordCache.cpp | 4 +-- gfx/thebes/src/gfxWindowsFonts.cpp | 2 -- gfx/thebes/test/gfxFontSelectionTest.cpp | 1 - gfx/thebes/test/gfxTextRunPerfTest.cpp | 1 - layout/generic/nsTextFrameThebes.cpp | 7 +--- layout/generic/nsTextRunTransformations.cpp | 6 ++-- 15 files changed, 19 insertions(+), 90 deletions(-) diff --git a/gfx/thebes/public/gfxFont.h b/gfx/thebes/public/gfxFont.h index 795cac374be..ef2d98603a8 100644 --- a/gfx/thebes/public/gfxFont.h +++ b/gfx/thebes/public/gfxFont.h @@ -745,25 +745,16 @@ public: * on the spacing provider. */ TEXT_ENABLE_SPACING = 0x0008, - /** - * When set, GetSpacing can return negative spacing. - */ - TEXT_ENABLE_NEGATIVE_SPACING = 0x0010, /** * When set, GetHyphenationBreaks may return true for some character * positions, otherwise it will always return false for all characters. */ - TEXT_ENABLE_HYPHEN_BREAKS = 0x0040, + TEXT_ENABLE_HYPHEN_BREAKS = 0x0010, /** * When set, the text has no characters above 255 and it is stored * in the textrun in 8-bit format. */ - TEXT_IS_8BIT = 0x0080, - /** - * When set, the text may have UTF16 surrogate pairs, otherwise it - * doesn't. - */ - TEXT_HAS_SURROGATES = 0x0100, + TEXT_IS_8BIT = 0x0020, /** * When set, the RunMetrics::mBoundingBox field will be initialized * properly based on glyph extents, in particular, glyph extents that @@ -771,18 +762,18 @@ public: * and advance width of the glyph). When not set, it may just be the * standard font-box even if glyphs overflow. */ - TEXT_NEED_BOUNDING_BOX = 0x0200, + TEXT_NEED_BOUNDING_BOX = 0x0040, /** * When set, optional ligatures are disabled. Ligatures that are * required for legible text should still be enabled. */ - TEXT_DISABLE_OPTIONAL_LIGATURES = 0x0400, + TEXT_DISABLE_OPTIONAL_LIGATURES = 0x0080, /** * When set, the textrun should favour speed of construction over * quality. This may involve disabling ligatures and/or kerning or * other effects. */ - TEXT_OPTIMIZE_SPEED = 0x0800 + TEXT_OPTIMIZE_SPEED = 0x0100 }; /** @@ -1196,7 +1187,6 @@ public: FLAG_NOT_MISSING = 0x01, FLAG_NOT_CLUSTER_START = 0x02, FLAG_NOT_LIGATURE_GROUP_START = 0x04, - FLAG_LOW_SURROGATE = 0x08, GLYPH_COUNT_MASK = 0x00FFFF00U, GLYPH_COUNT_SHIFT = 8 @@ -1222,9 +1212,6 @@ public: PRUint32 GetSimpleGlyph() const { return mValue & GLYPH_MASK; } PRBool IsMissing() const { return (mValue & (FLAG_NOT_MISSING|FLAG_IS_SIMPLE_GLYPH)) == 0; } - PRBool IsLowSurrogate() const { - return (mValue & (FLAG_LOW_SURROGATE|FLAG_IS_SIMPLE_GLYPH)) == FLAG_LOW_SURROGATE; - } PRBool IsClusterStart() const { return (mValue & FLAG_IS_SIMPLE_GLYPH) || !(mValue & FLAG_NOT_CLUSTER_START); } @@ -1271,15 +1258,6 @@ public: (aGlyphCount << GLYPH_COUNT_SHIFT); return *this; } - /** - * Low surrogates don't have any glyphs and are not the start of - * a cluster or ligature group. - */ - CompressedGlyph& SetLowSurrogate() { - mValue = (mValue & FLAG_CAN_BREAK_BEFORE) | FLAG_NOT_MISSING | - FLAG_LOW_SURROGATE; - return *this; - } PRUint32 GetGlyphCount() const { NS_ASSERTION(!IsSimpleGlyph(), "Expected non-simple-glyph"); return (mValue & GLYPH_COUNT_MASK) >> GLYPH_COUNT_SHIFT; @@ -1351,11 +1329,6 @@ public: // API for setting up the textrun glyphs. Should only be called by // things that construct textruns. - /** - * Record every character that is the second half of a surrogate pair. - * This should be called after creating a Unicode textrun. - */ - void RecordSurrogates(const PRUnichar *aString); /** * We've found a run of text that should use a particular font. Call this * only during initialization when font substitution has been computed. diff --git a/gfx/thebes/public/gfxTextRunCache.h b/gfx/thebes/public/gfxTextRunCache.h index 92d09446de3..dbc6d97878d 100644 --- a/gfx/thebes/public/gfxTextRunCache.h +++ b/gfx/thebes/public/gfxTextRunCache.h @@ -52,8 +52,7 @@ public: * Get a textrun for the given text, using a global cache. The textrun * must be released via ReleaseTextRun, not deleted. * Do not set any state in the textrun (e.g. actual or potential linebreaks). - * Flags IS_8BIT, IS_ASCII and HAS_SURROGATES are automatically set - * appropriately. + * Flags IS_8BIT and IS_ASCII are automatically set appropriately. * Flag IS_PERSISTENT must NOT be set unless aText is guaranteed to live * forever. * The string can contain any characters, invalid ones will be stripped diff --git a/gfx/thebes/public/gfxTextRunWordCache.h b/gfx/thebes/public/gfxTextRunWordCache.h index bc5dc9226a9..9584c955755 100644 --- a/gfx/thebes/public/gfxTextRunWordCache.h +++ b/gfx/thebes/public/gfxTextRunWordCache.h @@ -70,10 +70,10 @@ public: * Create a textrun using cached words. * Invalid characters (see gfxFontGroup::IsInvalidChar) will be automatically * treated as invisible missing. - * @param aFlags the flags TEXT_IS_ASCII and TEXT_HAS_SURROGATES must be set - * by the caller, if applicable; TEXT_IN_CACHE is added if we - * have a reference to the textrun in the cache and RemoveTextRun must - * be called when the textrun dies. + * @param aFlags the flag TEXT_IS_ASCII must be set by the caller, + * if applicable; TEXT_IN_CACHE is added if we have a reference to + * the textrun in the cache and RemoveTextRun must be called when the + * textrun dies. */ static gfxTextRun *MakeTextRun(const PRUnichar *aText, PRUint32 aLength, gfxFontGroup *aFontGroup, @@ -83,10 +83,10 @@ public: * Create a textrun using cached words. * Invalid characters (see gfxFontGroup::IsInvalidChar) will be automatically * treated as invisible missing. - * @param aFlags the flags TEXT_IS_ASCII and TEXT_HAS_SURROGATES must be set - * by the caller, if applicable; TEXT_IN_CACHE is added if we - * have a reference to the textrun in the cache and RemoveTextRun must - * be called when the textrun dies. + * @param aFlags the flag TEXT_IS_ASCII must be set by the caller, + * if applicable; TEXT_IN_CACHE is added if we have a reference to + * the textrun in the cache and RemoveTextRun must be called when the + * textrun dies. */ static gfxTextRun *MakeTextRun(const PRUint8 *aText, PRUint32 aLength, gfxFontGroup *aFontGroup, diff --git a/gfx/thebes/src/gfxAtsuiFonts.cpp b/gfx/thebes/src/gfxAtsuiFonts.cpp index c743ef770a7..5aa2bd715d0 100644 --- a/gfx/thebes/src/gfxAtsuiFonts.cpp +++ b/gfx/thebes/src/gfxAtsuiFonts.cpp @@ -714,7 +714,6 @@ gfxAtsuiFontGroup::MakeTextRun(const PRUnichar *aString, PRUint32 aLength, if (!textRun) return nsnull; - textRun->RecordSurrogates(aString); gfxPlatformMac::SetupClusterBoundaries(textRun, aString); PRUint32 maxLen; diff --git a/gfx/thebes/src/gfxCoreTextFonts.cpp b/gfx/thebes/src/gfxCoreTextFonts.cpp index 5d31b8ea4f7..9f138b33e3b 100644 --- a/gfx/thebes/src/gfxCoreTextFonts.cpp +++ b/gfx/thebes/src/gfxCoreTextFonts.cpp @@ -721,7 +721,6 @@ gfxCoreTextFontGroup::MakeTextRun(const PRUnichar *aString, PRUint32 aLength, if (!textRun) return nsnull; - textRun->RecordSurrogates(aString); gfxPlatformMac::SetupClusterBoundaries(textRun, aString); nsAutoString utf16; diff --git a/gfx/thebes/src/gfxFT2Fonts.cpp b/gfx/thebes/src/gfxFT2Fonts.cpp index d3b2d4381bf..8a7ef15ddbb 100644 --- a/gfx/thebes/src/gfxFT2Fonts.cpp +++ b/gfx/thebes/src/gfxFT2Fonts.cpp @@ -289,8 +289,6 @@ gfxTextRun *gfxFT2FontGroup::MakeTextRun(const PRUnichar* aString, PRUint32 aLen if (!textRun) return nsnull; - textRun->RecordSurrogates(aString); - mString.Assign(nsDependentSubstring(aString, aString + aLength)); InitTextRun(textRun); diff --git a/gfx/thebes/src/gfxFont.cpp b/gfx/thebes/src/gfxFont.cpp index ffc3953f4d8..75f22c58367 100644 --- a/gfx/thebes/src/gfxFont.cpp +++ b/gfx/thebes/src/gfxFont.cpp @@ -2377,30 +2377,6 @@ gfxTextRun::SetMissingGlyph(PRUint32 aIndex, PRUint32 aChar) mCharacterGlyphs[aIndex].SetMissing(1); } -void -gfxTextRun::RecordSurrogates(const PRUnichar *aString) -{ - // !! FIXME !! - // - // This is called from the platform font implementations when making text runs, but currently it - // doesn't do anything because callers do not (consistently, or ever?) set the TEXT_HAS_SURROGATES flag. - // However, I have not seen anything that relies on the surrogate flag on glyphs, so perhaps we can - // simply eliminate this and remove that flag from gfxTextRunFactory? - - if (!(mFlags & gfxTextRunFactory::TEXT_HAS_SURROGATES)) - return; - - // Remember which characters are low surrogates (the second half of - // a surrogate pair). - PRUint32 i; - gfxTextRun::CompressedGlyph g; - for (i = 0; i < mCharacterCount; ++i) { - if (NS_IS_LOW_SURROGATE(aString[i])) { - SetGlyphs(i, g.SetLowSurrogate(), nsnull); - } - } -} - static void ClearCharacters(gfxTextRun::CompressedGlyph *aGlyphs, PRUint32 aLength) { diff --git a/gfx/thebes/src/gfxOS2Fonts.cpp b/gfx/thebes/src/gfxOS2Fonts.cpp index 861520fcb49..bc6b45ca5a4 100644 --- a/gfx/thebes/src/gfxOS2Fonts.cpp +++ b/gfx/thebes/src/gfxOS2Fonts.cpp @@ -548,8 +548,6 @@ gfxTextRun *gfxOS2FontGroup::MakeTextRun(const PRUnichar* aString, PRUint32 aLen mEnableKerning = !(aFlags & gfxTextRunFactory::TEXT_OPTIMIZE_SPEED); - textRun->RecordSurrogates(aString); - nsCAutoString utf8; PRInt32 headerLen = AppendDirectionalIndicatorUTF8(textRun->IsRightToLeft(), utf8); AppendUTF16toUTF8(Substring(aString, aString + aLength), utf8); diff --git a/gfx/thebes/src/gfxPangoFonts.cpp b/gfx/thebes/src/gfxPangoFonts.cpp index aaa0b2686d6..316a64a399f 100644 --- a/gfx/thebes/src/gfxPangoFonts.cpp +++ b/gfx/thebes/src/gfxPangoFonts.cpp @@ -2860,8 +2860,6 @@ gfxPangoFontGroup::MakeTextRun(const PRUnichar *aString, PRUint32 aLength, if (!run) return nsnull; - run->RecordSurrogates(aString); - nsCAutoString utf8; PRInt32 headerLen = AppendDirectionalIndicatorUTF8(run->IsRightToLeft(), utf8); AppendUTF16toUTF8(Substring(aString, aString + aLength), utf8); diff --git a/gfx/thebes/src/gfxTextRunWordCache.cpp b/gfx/thebes/src/gfxTextRunWordCache.cpp index 35e051ace1b..e92cca0d502 100644 --- a/gfx/thebes/src/gfxTextRunWordCache.cpp +++ b/gfx/thebes/src/gfxTextRunWordCache.cpp @@ -93,8 +93,8 @@ public: * Create a textrun using cached words. * Invalid characters (see gfxFontGroup::IsInvalidChar) will be automatically * treated as invisible missing. - * @param aFlags the flags TEXT_IS_ASCII and TEXT_HAS_SURROGATES must be set - * by the caller, if applicable + * @param aFlags the flag TEXT_IS_ASCII must be set by the caller, + * if applicable * @param aIsInCache if true is returned, then RemoveTextRun must be called * before the textrun changes or dies. */ diff --git a/gfx/thebes/src/gfxWindowsFonts.cpp b/gfx/thebes/src/gfxWindowsFonts.cpp index aec428abc3e..9a97fcc180b 100644 --- a/gfx/thebes/src/gfxWindowsFonts.cpp +++ b/gfx/thebes/src/gfxWindowsFonts.cpp @@ -1477,8 +1477,6 @@ gfxWindowsFontGroup::MakeTextRun(const PRUnichar *aString, PRUint32 aLength, return nsnull; NS_ASSERTION(aParams->mContext, "MakeTextRun called without a gfxContext"); - textRun->RecordSurrogates(aString); - #ifdef FORCE_UNISCRIBE const PRBool isComplex = PR_TRUE; #else diff --git a/gfx/thebes/test/gfxFontSelectionTest.cpp b/gfx/thebes/test/gfxFontSelectionTest.cpp index 77f0b6422c0..6109babd075 100644 --- a/gfx/thebes/test/gfxFontSelectionTest.cpp +++ b/gfx/thebes/test/gfxFontSelectionTest.cpp @@ -304,7 +304,6 @@ RunTest (TestEntry *test, gfxContext *ctx) { length = strlen(test->string); textRun = gfxTextRunWordCache::MakeTextRun(reinterpret_cast(test->string), length, fontGroup, ¶ms, flags); } else { - flags |= gfxTextRunFactory::TEXT_HAS_SURROGATES; // just in case NS_ConvertUTF8toUTF16 str(nsDependentCString(test->string)); length = str.Length(); textRun = gfxTextRunWordCache::MakeTextRun(str.get(), length, fontGroup, ¶ms, flags); diff --git a/gfx/thebes/test/gfxTextRunPerfTest.cpp b/gfx/thebes/test/gfxTextRunPerfTest.cpp index 84b57672d9f..483dd2ab6d7 100644 --- a/gfx/thebes/test/gfxTextRunPerfTest.cpp +++ b/gfx/thebes/test/gfxTextRunPerfTest.cpp @@ -119,7 +119,6 @@ RunTest (TestEntry *test, gfxContext *ctx) { length = strlen(test->mString); textRun = fontGroup->MakeTextRun(reinterpret_cast(test->mString), length, ¶ms, flags); } else { - flags |= gfxTextRunFactory::TEXT_HAS_SURROGATES; // just in case NS_ConvertUTF8toUTF16 str(nsDependentCString(test->mString)); length = str.Length(); textRun = fontGroup->MakeTextRun(str.get(), length, ¶ms, flags); diff --git a/layout/generic/nsTextFrameThebes.cpp b/layout/generic/nsTextFrameThebes.cpp index dca4e620f05..5bad68046cb 100644 --- a/layout/generic/nsTextFrameThebes.cpp +++ b/layout/generic/nsTextFrameThebes.cpp @@ -1434,12 +1434,7 @@ BuildTextRunsScanner::GetNextBreakBeforeFrame(PRUint32* aIndex) static PRUint32 GetSpacingFlags(nscoord spacing) { - if (!spacing) - return 0; - if (spacing > 0) - return gfxTextRunFactory::TEXT_ENABLE_SPACING; - return gfxTextRunFactory::TEXT_ENABLE_SPACING | - gfxTextRunFactory::TEXT_ENABLE_NEGATIVE_SPACING; + return spacing ? gfxTextRunFactory::TEXT_ENABLE_SPACING : 0; } static gfxFontGroup* diff --git a/layout/generic/nsTextRunTransformations.cpp b/layout/generic/nsTextRunTransformations.cpp index f0b5fb1cdd1..635b580f889 100644 --- a/layout/generic/nsTextRunTransformations.cpp +++ b/layout/generic/nsTextRunTransformations.cpp @@ -173,15 +173,13 @@ MergeCharactersInTextRun(gfxTextRun* aDest, gfxTextRun* aSrc, // to merge S's (uppercase ß), so it's not worth it. if (k + 1 < iter.GetStringEnd() && aCharsToMerge[k + 1]) { - NS_ASSERTION(g.IsClusterStart() && g.IsLigatureGroupStart() && - !g.IsLowSurrogate(), + NS_ASSERTION(g.IsClusterStart() && g.IsLigatureGroupStart(), "Don't know how to merge this stuff"); continue; } NS_ASSERTION(mergeRunStart == k || - (g.IsClusterStart() && g.IsLigatureGroupStart() && - !g.IsLowSurrogate()), + (g.IsClusterStart() && g.IsLigatureGroupStart()), "Don't know how to merge this stuff"); // If the start of the merge run is actually a character that should