mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Backing out 410728 to fix Windows orange
This commit is contained in:
parent
c027962580
commit
1d2bbe2e33
@ -24,4 +24,4 @@ load 404112-2.html
|
||||
load 405268-1.xhtml
|
||||
load 407761-1.html
|
||||
load 407842.html
|
||||
load 410728-1.xml
|
||||
# load 410728-1.xml
|
||||
|
@ -44,21 +44,7 @@
|
||||
/**
|
||||
* Cache individual "words" (strings delimited by white-space or white-space-like
|
||||
* characters that don't involve kerning or ligatures) in textruns.
|
||||
*
|
||||
* The characters treated as word boundaries are defined by IsWordBoundary
|
||||
* below. The characters are: space, NBSP, and all the characters
|
||||
* defined by gfxFontGroup::IsInvalidChar. The latter are all converted
|
||||
* to invisible missing glyphs in this code. Thus, this class ensures
|
||||
* that none of those invalid characters are ever passed to platform
|
||||
* textrun implementations.
|
||||
*
|
||||
* Some platforms support marks combining with spaces to form clusters.
|
||||
* In such cases we treat "before the space" as a word boundary but
|
||||
* "after the space" is not a word boundary; words with a leading space
|
||||
* are kept out of the cache. Also, words at the start of text, which start
|
||||
* with combining marks that would combine with a space if there was one,
|
||||
* are also kept out of the cache.
|
||||
*/
|
||||
*/
|
||||
class TextRunWordCache {
|
||||
public:
|
||||
TextRunWordCache() {
|
||||
@ -173,7 +159,7 @@ protected:
|
||||
PRUint32 aStart, PRUint32 aEnd, PRUint32 aHash,
|
||||
nsTArray<DeferredWord>* aDeferredWords);
|
||||
void FinishTextRun(gfxTextRun *aTextRun, gfxTextRun *aNewRun,
|
||||
const gfxFontGroup::Parameters *aParams,
|
||||
gfxContext *aContext,
|
||||
const nsTArray<DeferredWord>& aDeferredWords,
|
||||
PRBool aSuccessful);
|
||||
void RemoveWord(gfxTextRun *aTextRun, PRUint32 aStart,
|
||||
@ -321,7 +307,7 @@ TextRunWordCache::LookupWord(gfxTextRun *aTextRun, gfxFont *aFirstFont,
|
||||
*/
|
||||
void
|
||||
TextRunWordCache::FinishTextRun(gfxTextRun *aTextRun, gfxTextRun *aNewRun,
|
||||
const gfxFontGroup::Parameters *aParams,
|
||||
gfxContext *aContext,
|
||||
const nsTArray<DeferredWord>& aDeferredWords,
|
||||
PRBool aSuccessful)
|
||||
{
|
||||
@ -336,37 +322,23 @@ TextRunWordCache::FinishTextRun(gfxTextRun *aTextRun, gfxTextRun *aNewRun,
|
||||
gfxTextRun *source = word->mSourceTextRun;
|
||||
if (!source) {
|
||||
source = aNewRun;
|
||||
}
|
||||
// If the word starts inside a cluster we don't want this word
|
||||
// in the cache, so we'll remove the associated cache entry
|
||||
PRBool wordStartsInsideCluster =
|
||||
!source->IsClusterStart(word->mSourceOffset);
|
||||
if (source == aNewRun) {
|
||||
// We created a cache entry for this word based on the assumption
|
||||
// we created a cache entry for this word based on the assumption
|
||||
// that the word matches GetFontAt(0). If this assumption is false,
|
||||
// we need to remove that cache entry and replace it with an entry
|
||||
// keyed off the fontgroup.
|
||||
PRBool rekeyWithFontGroup =
|
||||
GetWordFontOrGroup(aNewRun, word->mSourceOffset, word->mLength) != font;
|
||||
if (!aSuccessful || wordStartsInsideCluster || rekeyWithFontGroup) {
|
||||
// We need to remove the current placeholder cache entry
|
||||
if (!aSuccessful ||
|
||||
GetWordFontOrGroup(aNewRun, word->mSourceOffset, word->mLength) != font) {
|
||||
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);
|
||||
#ifdef DEBUG
|
||||
--aTextRun->mCachedWords;
|
||||
#endif
|
||||
PR_LOG(gWordCacheLog, PR_LOG_DEBUG, ("%p(%d-%d,%d): removed using font", aTextRun, word->mDestOffset, word->mLength, word->mHash));
|
||||
|
||||
if (aSuccessful && !wordStartsInsideCluster) {
|
||||
if (aSuccessful) {
|
||||
key.mFontOrGroup = fontGroup;
|
||||
CacheHashEntry *groupEntry = mCache.PutEntry(key);
|
||||
if (groupEntry) {
|
||||
#ifdef DEBUG
|
||||
++aTextRun->mCachedWords;
|
||||
#endif
|
||||
PR_LOG(gWordCacheLog, PR_LOG_DEBUG, ("%p(%d-%d,%d): added using fontgroup", aTextRun, word->mDestOffset, word->mLength, word->mHash));
|
||||
groupEntry->mTextRun = aTextRun;
|
||||
groupEntry->mWordOffset = word->mDestOffset;
|
||||
@ -381,38 +353,9 @@ TextRunWordCache::FinishTextRun(gfxTextRun *aTextRun, gfxTextRun *aNewRun,
|
||||
// Copy the word. If the source is aNewRun, then
|
||||
// allow CopyGlyphDataFrom to steal the internal data of
|
||||
// aNewRun since that's only temporary anyway.
|
||||
PRUint32 sourceOffset = word->mSourceOffset;
|
||||
PRUint32 destOffset = word->mDestOffset;
|
||||
PRUint32 length = word->mLength;
|
||||
nsAutoPtr<gfxTextRun> tmpTextRun;
|
||||
PRBool stealData = source == aNewRun;
|
||||
if (wordStartsInsideCluster) {
|
||||
NS_ASSERTION(sourceOffset > 0, "How can the first character be inside a cluster?");
|
||||
if (destOffset > 0 && IsBoundarySpace(aTextRun->GetChar(destOffset - 1))) {
|
||||
// We should copy over data for the preceding space
|
||||
// as well. The glyphs have probably been attached
|
||||
// to that character.
|
||||
--sourceOffset;
|
||||
--destOffset;
|
||||
++length;
|
||||
} else {
|
||||
// URK! This case sucks! We have combining marks
|
||||
// at the start of the text. We had to prepend a space
|
||||
// just so we could detect these are combining marks
|
||||
// (so we can keep this "word" out of the cache).
|
||||
// But now the data in aNewRun is no use to us. We
|
||||
// need to find out what the platform would do
|
||||
// if the marks were at the start of the text.
|
||||
tmpTextRun = aNewRun->GetFontGroup()->MakeTextRun(
|
||||
aTextRun->GetTextUnicode(), length, aParams,
|
||||
aNewRun->GetFlags());
|
||||
source = tmpTextRun;
|
||||
sourceOffset = 0;
|
||||
stealData = PR_TRUE;
|
||||
}
|
||||
}
|
||||
aTextRun->CopyGlyphDataFrom(source, sourceOffset, length,
|
||||
destOffset, stealData);
|
||||
aTextRun->CopyGlyphDataFrom(source,
|
||||
word->mSourceOffset, word->mLength, word->mDestOffset,
|
||||
source == aNewRun);
|
||||
// Fill in additional spaces
|
||||
PRUint32 endCharIndex;
|
||||
if (i + 1 < aDeferredWords.Length()) {
|
||||
@ -424,7 +367,7 @@ TextRunWordCache::FinishTextRun(gfxTextRun *aTextRun, gfxTextRun *aNewRun,
|
||||
for (charIndex = word->mDestOffset + word->mLength;
|
||||
charIndex < endCharIndex; ++charIndex) {
|
||||
if (IsBoundarySpace(aTextRun->GetChar(charIndex))) {
|
||||
aTextRun->SetSpaceGlyph(font, aParams->mContext, charIndex);
|
||||
aTextRun->SetSpaceGlyph(font, aContext, charIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -482,9 +425,9 @@ TextRunWordCache::MakeTextRun(const PRUnichar *aText, PRUint32 aLength,
|
||||
PRBool hit = LookupWord(textRun, font, wordStart, i, hash,
|
||||
deferredWords.Length() == 0 ? nsnull : &deferredWords);
|
||||
if (!hit) {
|
||||
// Always put a space before the word so we can detect
|
||||
// combining characters at the start of a word
|
||||
tempString.AppendElement(' ');
|
||||
if (tempString.Length() > 0) {
|
||||
tempString.AppendElement(' ');
|
||||
}
|
||||
PRUint32 offset = tempString.Length();
|
||||
PRUint32 length = i - wordStart;
|
||||
PRUnichar *chars = tempString.AppendElements(length);
|
||||
@ -524,7 +467,7 @@ TextRunWordCache::MakeTextRun(const PRUnichar *aText, PRUint32 aLength,
|
||||
newRun = aFontGroup->MakeTextRun(tempString.Elements(), tempString.Length(),
|
||||
¶ms, aFlags | gfxTextRunFactory::TEXT_IS_PERSISTENT);
|
||||
|
||||
FinishTextRun(textRun, newRun, aParams, deferredWords, newRun != nsnull);
|
||||
FinishTextRun(textRun, newRun, aParams->mContext, deferredWords, newRun != nsnull);
|
||||
return textRun.forget();
|
||||
}
|
||||
|
||||
@ -607,7 +550,7 @@ TextRunWordCache::MakeTextRun(const PRUint8 *aText, PRUint32 aLength,
|
||||
newRun = aFontGroup->MakeTextRun(tempString.Elements(), tempString.Length(),
|
||||
¶ms, aFlags | gfxTextRunFactory::TEXT_IS_PERSISTENT);
|
||||
|
||||
FinishTextRun(textRun, newRun, aParams, deferredWords, newRun != nsnull);
|
||||
FinishTextRun(textRun, newRun, aParams->mContext, deferredWords, newRun != nsnull);
|
||||
return textRun.forget();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user