mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-14 13:55:43 +00:00
Backing out bug 430332 to try to fix reftest and Tp crashes
This commit is contained in:
commit
f42e933787
@ -46,8 +46,7 @@
|
||||
*/
|
||||
class THEBES_API gfxTextRunWordCache {
|
||||
public:
|
||||
enum { TEXT_IN_CACHE = 0x10000000,
|
||||
TEXT_UNUSED_FLAGS = 0xE0000000 };
|
||||
enum { TEXT_IN_CACHE = 0x10000000 };
|
||||
|
||||
/**
|
||||
* Create a textrun using cached words.
|
||||
|
@ -1394,10 +1394,6 @@ gfxTextRun::~gfxTextRun()
|
||||
{
|
||||
#ifdef DEBUG_TEXT_RUN_STORAGE_METRICS
|
||||
AccountStorageForTextRun(this, -1);
|
||||
#endif
|
||||
#ifdef DEBUG
|
||||
// Make it easy to detect a dead text run
|
||||
mFlags = 0xFFFFFFFF;
|
||||
#endif
|
||||
NS_RELEASE(mFontGroup);
|
||||
MOZ_COUNT_DTOR(gfxTextRun);
|
||||
|
@ -1,17 +0,0 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<body style="font-family:monospace; width:6ch;">
|
||||
<b>ab</b> cd
|
||||
<b>ab</b> cd
|
||||
<b>ab</b> cd
|
||||
<b>ab</b> cd
|
||||
<b>ab</b> cd
|
||||
<b>ab</b> cd
|
||||
<b>ab</b> cd
|
||||
<b>ab</b> cd<span id="s">ef</span>
|
||||
<script>
|
||||
document.body.clientWidth;
|
||||
document.getElementById("s").style.fontSize = "200%";
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -153,7 +153,6 @@ load 425253-1.html
|
||||
load 426272-1.html
|
||||
load 428263-1.html
|
||||
load 429981-1.html
|
||||
load 430332-1.html
|
||||
load 430352-1.html
|
||||
load 437156-1.html
|
||||
load 438259-1.html
|
||||
|
@ -725,18 +725,6 @@ public:
|
||||
aCapitalize, mContext);
|
||||
}
|
||||
|
||||
void Finish() {
|
||||
NS_ASSERTION(!(mTextRun->GetFlags() &
|
||||
(gfxTextRunWordCache::TEXT_UNUSED_FLAGS |
|
||||
nsTextFrameUtils::TEXT_UNUSED_FLAG)),
|
||||
"Flag set that should never be set! (memory safety error?)");
|
||||
if (mTextRun->GetFlags() & nsTextFrameUtils::TEXT_IS_TRANSFORMED) {
|
||||
nsTransformedTextRun* transformedTextRun =
|
||||
static_cast<nsTransformedTextRun*>(mTextRun);
|
||||
transformedTextRun->FinishSettingProperties(mContext);
|
||||
}
|
||||
}
|
||||
|
||||
gfxTextRun* mTextRun;
|
||||
gfxContext* mContext;
|
||||
PRUint32 mOffsetIntoTextRun;
|
||||
@ -748,7 +736,6 @@ private:
|
||||
nsAutoTArray<MappedFlow,10> mMappedFlows;
|
||||
nsAutoTArray<nsTextFrame*,50> mLineBreakBeforeFrames;
|
||||
nsAutoTArray<nsAutoPtr<BreakSink>,10> mBreakSinks;
|
||||
nsAutoTArray<gfxTextRun*,5> mTextRunsToDelete;
|
||||
nsLineBreaker mLineBreaker;
|
||||
gfxTextRun* mCurrentFramesAllSameTextRun;
|
||||
gfxContext* mContext;
|
||||
@ -1172,23 +1159,14 @@ void BuildTextRunsScanner::FlushFrames(PRBool aFlushLineBreaks, PRBool aSuppress
|
||||
if (NS_SUCCEEDED(rv) && trailingLineBreak && textRun && !aSuppressTrailingBreak) {
|
||||
textRun->SetFlagBits(nsTextFrameUtils::TEXT_HAS_TRAILING_BREAK);
|
||||
}
|
||||
|
||||
PRUint32 i;
|
||||
for (i = 0; i < mBreakSinks.Length(); ++i) {
|
||||
if (!mBreakSinks[i]->mExistingTextRun || mBreakSinks[i]->mChangedBreaks) {
|
||||
// TODO cause frames associated with the textrun to be reflowed, if they
|
||||
// aren't being reflowed already!
|
||||
}
|
||||
mBreakSinks[i]->Finish();
|
||||
}
|
||||
mBreakSinks.Clear();
|
||||
|
||||
for (i = 0; i < mTextRunsToDelete.Length(); ++i) {
|
||||
gfxTextRun* textRun = mTextRunsToDelete[i];
|
||||
gTextRuns->RemoveFromCache(textRun);
|
||||
delete textRun;
|
||||
}
|
||||
mTextRunsToDelete.Clear();
|
||||
}
|
||||
|
||||
mCanStopOnThisLine = PR_TRUE;
|
||||
@ -1504,18 +1482,15 @@ BuildTextRunsScanner::BuildTextRunForFrames(void* aTextBuffer)
|
||||
TextRunMappedFlow dummyMappedFlow;
|
||||
|
||||
TextRunUserData* userData;
|
||||
TextRunUserData* userDataToDestroy;
|
||||
// If the situation is particularly simple (and common) we don't need to
|
||||
// allocate userData.
|
||||
if (mMappedFlows.Length() == 1 && !mMappedFlows[0].mEndFrame &&
|
||||
mMappedFlows[0].mStartFrame->GetContentOffset() == 0) {
|
||||
userData = &dummyData;
|
||||
userDataToDestroy = nsnull;
|
||||
dummyData.mMappedFlows = &dummyMappedFlow;
|
||||
} else {
|
||||
userData = static_cast<TextRunUserData*>
|
||||
(nsMemory::Alloc(sizeof(TextRunUserData) + mMappedFlows.Length()*sizeof(TextRunMappedFlow)));
|
||||
userDataToDestroy = userData;
|
||||
userData->mMappedFlows = reinterpret_cast<TextRunMappedFlow*>(userData + 1);
|
||||
}
|
||||
userData->mMappedFlowCount = mMappedFlows.Length();
|
||||
@ -1592,7 +1567,7 @@ BuildTextRunsScanner::BuildTextRunForFrames(void* aTextBuffer)
|
||||
// then expand.
|
||||
nsAutoTArray<PRUint8,BIG_TEXT_NODE_SIZE> tempBuf;
|
||||
if (!tempBuf.AppendElements(contentLength)) {
|
||||
DestroyUserData(userDataToDestroy);
|
||||
DestroyUserData(userData);
|
||||
return nsnull;
|
||||
}
|
||||
PRUint8* bufStart = tempBuf.Elements();
|
||||
@ -1622,7 +1597,7 @@ BuildTextRunsScanner::BuildTextRunForFrames(void* aTextBuffer)
|
||||
|
||||
// Check for out-of-memory in gfxSkipCharsBuilder
|
||||
if (!builder.IsOK()) {
|
||||
DestroyUserData(userDataToDestroy);
|
||||
DestroyUserData(userData);
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
@ -1657,7 +1632,7 @@ BuildTextRunsScanner::BuildTextRunForFrames(void* aTextBuffer)
|
||||
nsTextFrame* firstFrame = mMappedFlows[0].mStartFrame;
|
||||
gfxFontGroup* fontGroup = GetFontGroupForFrame(firstFrame);
|
||||
if (!fontGroup) {
|
||||
DestroyUserData(userDataToDestroy);
|
||||
DestroyUserData(userData);
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
@ -1764,7 +1739,7 @@ BuildTextRunsScanner::BuildTextRunForFrames(void* aTextBuffer)
|
||||
}
|
||||
}
|
||||
if (!textRun) {
|
||||
DestroyUserData(userDataToDestroy);
|
||||
DestroyUserData(userData);
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
@ -1777,10 +1752,11 @@ BuildTextRunsScanner::BuildTextRunForFrames(void* aTextBuffer)
|
||||
if (mSkipIncompleteTextRuns) {
|
||||
mSkipIncompleteTextRuns = !TextContainsLineBreakerWhiteSpace(textPtr,
|
||||
transformedLength, mDoubleByteText);
|
||||
// Arrange for this textrun to be deleted the next time the linebreaker
|
||||
// is flushed out
|
||||
mTextRunsToDelete.AppendElement(textRun);
|
||||
DestroyUserData(userDataToDestroy);
|
||||
|
||||
// Nuke the textrun
|
||||
gTextRuns->RemoveFromCache(textRun);
|
||||
delete textRun;
|
||||
DestroyUserData(userData);
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
|
@ -78,10 +78,7 @@ public:
|
||||
// We normally don't use this break opportunity because the following text
|
||||
// will have a break opportunity at the start, but it's useful for line
|
||||
// layout to know about it in case the following content is not text
|
||||
TEXT_HAS_TRAILING_BREAK = 0x4000000,
|
||||
|
||||
// We don't currently use these flgas
|
||||
TEXT_UNUSED_FLAG = 0x8000000
|
||||
TEXT_HAS_TRAILING_BREAK = 0x4000000
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -72,7 +72,7 @@ nsTransformedTextRun::SetCapitalization(PRUint32 aStart, PRUint32 aLength,
|
||||
memset(mCapitalize.Elements(), 0, GetLength()*sizeof(PRPackedBool));
|
||||
}
|
||||
memcpy(mCapitalize.Elements() + aStart, aCapitalization, aLength*sizeof(PRPackedBool));
|
||||
mNeedsRebuild = PR_TRUE;
|
||||
mFactory->RebuildTextRun(this, aRefContext);
|
||||
}
|
||||
|
||||
PRBool
|
||||
@ -82,20 +82,76 @@ nsTransformedTextRun::SetPotentialLineBreaks(PRUint32 aStart, PRUint32 aLength,
|
||||
{
|
||||
PRBool changed = gfxTextRun::SetPotentialLineBreaks(aStart, aLength,
|
||||
aBreakBefore, aRefContext);
|
||||
if (changed) {
|
||||
mNeedsRebuild = PR_TRUE;
|
||||
}
|
||||
mFactory->RebuildTextRun(this, aRefContext);
|
||||
return changed;
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsTransformedTextRun::SetLineBreaks(PRUint32 aStart, PRUint32 aLength,
|
||||
PRBool aLineBreakBefore, PRBool aLineBreakAfter,
|
||||
gfxFloat* aAdvanceWidthDelta,
|
||||
gfxContext* aRefContext)
|
||||
{
|
||||
nsTArray<PRUint32> newBreaks;
|
||||
PRUint32 i;
|
||||
PRBool changed = PR_FALSE;
|
||||
for (i = 0; i < mLineBreaks.Length(); ++i) {
|
||||
PRUint32 pos = mLineBreaks[i];
|
||||
if (pos >= aStart)
|
||||
break;
|
||||
newBreaks.AppendElement(pos);
|
||||
}
|
||||
if (aLineBreakBefore != (i < mLineBreaks.Length() &&
|
||||
mLineBreaks[i] == aStart)) {
|
||||
changed = PR_TRUE;
|
||||
}
|
||||
if (aLineBreakBefore) {
|
||||
nsTextFrameUtils::AppendLineBreakOffset(&newBreaks, aStart);
|
||||
}
|
||||
if (aLineBreakAfter != (i + 1 < mLineBreaks.Length() &&
|
||||
mLineBreaks[i + 1] == aStart + aLength)) {
|
||||
changed = PR_TRUE;
|
||||
}
|
||||
if (aLineBreakAfter) {
|
||||
nsTextFrameUtils::AppendLineBreakOffset(&newBreaks, aStart + aLength);
|
||||
}
|
||||
for (; i < mLineBreaks.Length(); ++i) {
|
||||
if (mLineBreaks[i] > aStart + aLength)
|
||||
break;
|
||||
changed = PR_TRUE;
|
||||
}
|
||||
if (!changed) {
|
||||
if (aAdvanceWidthDelta) {
|
||||
*aAdvanceWidthDelta = 0;
|
||||
}
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
newBreaks.AppendElements(mLineBreaks.Elements() + i, mLineBreaks.Length() - i);
|
||||
mLineBreaks.SwapElements(newBreaks);
|
||||
|
||||
gfxFloat currentAdvance = GetAdvanceWidth(aStart, aLength, nsnull);
|
||||
mFactory->RebuildTextRun(this, aRefContext);
|
||||
if (aAdvanceWidthDelta) {
|
||||
*aAdvanceWidthDelta = GetAdvanceWidth(aStart, aLength, nsnull) - currentAdvance;
|
||||
}
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
gfxTextRun*
|
||||
nsTransformingTextRunFactory::MakeTextRun(const PRUnichar* aString, PRUint32 aLength,
|
||||
const gfxTextRunFactory::Parameters* aParams,
|
||||
gfxFontGroup* aFontGroup, PRUint32 aFlags,
|
||||
nsStyleContext** aStyles, PRBool aOwnsFactory)
|
||||
{
|
||||
return nsTransformedTextRun::Create(aParams, this, aFontGroup,
|
||||
nsTransformedTextRun* textRun =
|
||||
nsTransformedTextRun::Create(aParams, this, aFontGroup,
|
||||
aString, aLength, aFlags, aStyles, aOwnsFactory);
|
||||
if (!textRun)
|
||||
return nsnull;
|
||||
|
||||
RebuildTextRun(textRun, aParams->mContext);
|
||||
return textRun;
|
||||
}
|
||||
|
||||
gfxTextRun*
|
||||
@ -215,7 +271,7 @@ GetParametersForInner(nsTransformedTextRun* aTextRun, PRUint32* aFlags,
|
||||
{
|
||||
gfxTextRunFactory::Parameters params =
|
||||
{ aRefContext, nsnull, nsnull,
|
||||
nsnull, 0, aTextRun->GetAppUnitsPerDevUnit()
|
||||
nsnull, nsnull, aTextRun->GetAppUnitsPerDevUnit()
|
||||
};
|
||||
*aFlags = aTextRun->GetFlags() & ~gfxFontGroup::TEXT_IS_PERSISTENT;
|
||||
return params;
|
||||
@ -257,9 +313,17 @@ nsFontVariantTextRunFactory::RebuildTextRun(nsTransformedTextRun* aTextRun,
|
||||
PRBool runIsLowercase = PR_FALSE;
|
||||
nsAutoTArray<nsStyleContext*,50> styleArray;
|
||||
nsAutoTArray<PRPackedBool,50> canBreakBeforeArray;
|
||||
nsAutoTArray<PRUint32,10> lineBreakBeforeArray;
|
||||
|
||||
PRUint32 nextLineBreak = 0;
|
||||
PRUint32 i;
|
||||
for (i = 0; i <= length; ++i) {
|
||||
if (nextLineBreak < aTextRun->mLineBreaks.Length() &&
|
||||
aTextRun->mLineBreaks[nextLineBreak] == i) {
|
||||
lineBreakBeforeArray.AppendElement(i - runStart);
|
||||
++nextLineBreak;
|
||||
}
|
||||
|
||||
PRBool isLowercase = PR_FALSE;
|
||||
if (i < length) {
|
||||
// Characters that aren't the start of a cluster are ignored here. They
|
||||
@ -282,7 +346,9 @@ nsFontVariantTextRunFactory::RebuildTextRun(nsTransformedTextRun* aTextRun,
|
||||
nsAutoPtr<gfxTextRun> transformedChild;
|
||||
gfxTextRunCache::AutoTextRun cachedChild;
|
||||
gfxTextRun* child;
|
||||
|
||||
// Setup actual line break data for child (which may affect shaping)
|
||||
innerParams.mInitialBreaks = lineBreakBeforeArray.Elements();
|
||||
innerParams.mInitialBreakCount = lineBreakBeforeArray.Length();
|
||||
if (runIsLowercase) {
|
||||
transformedChild = uppercaseFactory.MakeTextRun(str + runStart, i - runStart,
|
||||
&innerParams, smallFont, flags, styleArray.Elements(), PR_FALSE);
|
||||
@ -306,6 +372,10 @@ nsFontVariantTextRunFactory::RebuildTextRun(nsTransformedTextRun* aTextRun,
|
||||
runStart = i;
|
||||
styleArray.Clear();
|
||||
canBreakBeforeArray.Clear();
|
||||
lineBreakBeforeArray.Clear();
|
||||
if (nextLineBreak > 0 && aTextRun->mLineBreaks[nextLineBreak - 1] == i) {
|
||||
lineBreakBeforeArray.AppendElement(0);
|
||||
}
|
||||
}
|
||||
|
||||
if (i < length) {
|
||||
@ -314,6 +384,8 @@ nsFontVariantTextRunFactory::RebuildTextRun(nsTransformedTextRun* aTextRun,
|
||||
canBreakBeforeArray.AppendElement(aTextRun->CanBreakLineBefore(i));
|
||||
}
|
||||
}
|
||||
NS_ASSERTION(nextLineBreak == aTextRun->mLineBreaks.Length(),
|
||||
"lost track of line breaks somehow");
|
||||
}
|
||||
|
||||
void
|
||||
@ -332,6 +404,8 @@ nsCaseTransformTextRunFactory::RebuildTextRun(nsTransformedTextRun* aTextRun,
|
||||
nsAutoTArray<PRPackedBool,50> charsToMergeArray;
|
||||
nsAutoTArray<nsStyleContext*,50> styleArray;
|
||||
nsAutoTArray<PRPackedBool,50> canBreakBeforeArray;
|
||||
nsAutoTArray<PRUint32,10> lineBreakBeforeArray;
|
||||
PRUint32 nextLineBreak = 0;
|
||||
PRUint32 extraCharsCount = 0;
|
||||
|
||||
PRUint32 i;
|
||||
@ -341,6 +415,11 @@ nsCaseTransformTextRunFactory::RebuildTextRun(nsTransformedTextRun* aTextRun,
|
||||
charsToMergeArray.AppendElement(PR_FALSE);
|
||||
styleArray.AppendElement(styles[i]);
|
||||
canBreakBeforeArray.AppendElement(aTextRun->CanBreakLineBefore(i));
|
||||
if (nextLineBreak < aTextRun->mLineBreaks.Length() &&
|
||||
aTextRun->mLineBreaks[nextLineBreak] == i) {
|
||||
lineBreakBeforeArray.AppendElement(i + extraCharsCount);
|
||||
++nextLineBreak;
|
||||
}
|
||||
|
||||
PRUint8 style = mAllUppercase ? NS_STYLE_TEXT_TRANSFORM_UPPERCASE
|
||||
: styles[i]->GetStyleText()->mTextTransform;
|
||||
@ -382,6 +461,13 @@ nsCaseTransformTextRunFactory::RebuildTextRun(nsTransformedTextRun* aTextRun,
|
||||
canBreakBeforeArray.AppendElement(PR_FALSE);
|
||||
}
|
||||
}
|
||||
if (nextLineBreak < aTextRun->mLineBreaks.Length() &&
|
||||
aTextRun->mLineBreaks[nextLineBreak] == length) {
|
||||
lineBreakBeforeArray.AppendElement(length + extraCharsCount);
|
||||
++nextLineBreak;
|
||||
}
|
||||
NS_ASSERTION(nextLineBreak == aTextRun->mLineBreaks.Length(),
|
||||
"lost track of line breaks somehow");
|
||||
|
||||
PRUint32 flags;
|
||||
gfxTextRunFactory::Parameters innerParams =
|
||||
@ -391,7 +477,9 @@ nsCaseTransformTextRunFactory::RebuildTextRun(nsTransformedTextRun* aTextRun,
|
||||
nsAutoPtr<gfxTextRun> transformedChild;
|
||||
gfxTextRunCache::AutoTextRun cachedChild;
|
||||
gfxTextRun* child;
|
||||
|
||||
// Setup actual line break data for child (which may affect shaping)
|
||||
innerParams.mInitialBreaks = lineBreakBeforeArray.Elements();
|
||||
innerParams.mInitialBreakCount = lineBreakBeforeArray.Length();
|
||||
if (mInnerTransformingTextRunFactory) {
|
||||
transformedChild = mInnerTransformingTextRunFactory->MakeTextRun(
|
||||
convertedString.BeginReading(), convertedString.Length(),
|
||||
|
@ -113,30 +113,22 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
void SetCapitalization(PRUint32 aStart, PRUint32 aLength,
|
||||
virtual void SetCapitalization(PRUint32 aStart, PRUint32 aLength,
|
||||
PRPackedBool* aCapitalization,
|
||||
gfxContext* aRefContext);
|
||||
virtual PRBool SetPotentialLineBreaks(PRUint32 aStart, PRUint32 aLength,
|
||||
PRPackedBool* aBreakBefore,
|
||||
gfxContext* aRefContext);
|
||||
/**
|
||||
* Called after SetCapitalization and SetPotentialLineBreaks
|
||||
* are done and before we request any data from the textrun. Also always
|
||||
* called after a Create.
|
||||
*/
|
||||
void FinishSettingProperties(gfxContext* aRefContext)
|
||||
{
|
||||
if (mNeedsRebuild) {
|
||||
mNeedsRebuild = PR_FALSE;
|
||||
mFactory->RebuildTextRun(this, aRefContext);
|
||||
}
|
||||
}
|
||||
virtual PRBool SetLineBreaks(PRUint32 aStart, PRUint32 aLength,
|
||||
PRBool aLineBreakBefore, PRBool aLineBreakAfter,
|
||||
gfxFloat* aAdvanceWidthDelta,
|
||||
gfxContext* aRefContext);
|
||||
|
||||
nsTransformingTextRunFactory *mFactory;
|
||||
nsTArray<PRUint32> mLineBreaks;
|
||||
nsTArray<nsRefPtr<nsStyleContext> > mStyles;
|
||||
nsTArray<PRPackedBool> mCapitalize;
|
||||
PRPackedBool mOwnsFactory;
|
||||
PRPackedBool mNeedsRebuild;
|
||||
|
||||
private:
|
||||
nsTransformedTextRun(const gfxTextRunFactory::Parameters* aParams,
|
||||
@ -146,12 +138,15 @@ private:
|
||||
const PRUint32 aFlags, nsStyleContext** aStyles,
|
||||
PRBool aOwnsFactory)
|
||||
: gfxTextRun(aParams, aString, aLength, aFontGroup, aFlags, sizeof(nsTransformedTextRun)),
|
||||
mFactory(aFactory), mOwnsFactory(aOwnsFactory), mNeedsRebuild(PR_TRUE)
|
||||
mFactory(aFactory), mOwnsFactory(aOwnsFactory)
|
||||
{
|
||||
PRUint32 i;
|
||||
for (i = 0; i < aLength; ++i) {
|
||||
mStyles.AppendElement(aStyles[i]);
|
||||
}
|
||||
for (i = 0; i < aParams->mInitialBreakCount; ++i) {
|
||||
mLineBreaks.AppendElement(aParams->mInitialBreaks[i]);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user