Bug 384836. Relanding fix to pass around gfxContexts a bit more instead of hanging on to one in nsTransformedTextRun. r=smontagu,pavlov
git-svn-id: svn://10.0.0.236/trunk@228811 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -61,8 +61,7 @@ public:
|
||||
const PRUint32 aFlags, nsStyleContext** aStyles,
|
||||
PRBool aOwnsFactory)
|
||||
: gfxTextRun(aParams, aString, aLength, aFontGroup, aFlags),
|
||||
mFactory(aFactory), mRefContext(aParams->mContext),
|
||||
mOwnsFactory(aOwnsFactory)
|
||||
mFactory(aFactory), mOwnsFactory(aOwnsFactory)
|
||||
{
|
||||
PRUint32 i;
|
||||
for (i = 0; i < aLength; ++i) {
|
||||
@@ -80,18 +79,20 @@ public:
|
||||
}
|
||||
|
||||
virtual PRBool SetPotentialLineBreaks(PRUint32 aStart, PRUint32 aLength,
|
||||
PRPackedBool* aBreakBefore)
|
||||
PRPackedBool* aBreakBefore,
|
||||
gfxContext* aRefContext)
|
||||
{
|
||||
PRBool changed = gfxTextRun::SetPotentialLineBreaks(aStart, aLength, aBreakBefore);
|
||||
mFactory->RebuildTextRun(this);
|
||||
PRBool changed = gfxTextRun::SetPotentialLineBreaks(aStart, aLength,
|
||||
aBreakBefore, aRefContext);
|
||||
mFactory->RebuildTextRun(this, aRefContext);
|
||||
return changed;
|
||||
}
|
||||
virtual PRBool SetLineBreaks(PRUint32 aStart, PRUint32 aLength,
|
||||
PRBool aLineBreakBefore, PRBool aLineBreakAfter,
|
||||
gfxFloat* aAdvanceWidthDelta);
|
||||
gfxFloat* aAdvanceWidthDelta,
|
||||
gfxContext* aRefContext);
|
||||
|
||||
nsTransformingTextRunFactory *mFactory;
|
||||
nsRefPtr<gfxContext> mRefContext;
|
||||
nsTArray<PRUint32> mLineBreaks;
|
||||
nsTArray<nsRefPtr<nsStyleContext> > mStyles;
|
||||
PRPackedBool mOwnsFactory;
|
||||
@@ -100,7 +101,8 @@ public:
|
||||
PRBool
|
||||
nsTransformedTextRun::SetLineBreaks(PRUint32 aStart, PRUint32 aLength,
|
||||
PRBool aLineBreakBefore, PRBool aLineBreakAfter,
|
||||
gfxFloat* aAdvanceWidthDelta)
|
||||
gfxFloat* aAdvanceWidthDelta,
|
||||
gfxContext* aRefContext)
|
||||
{
|
||||
nsTArray<PRUint32> newBreaks;
|
||||
PRUint32 i;
|
||||
@@ -141,7 +143,7 @@ nsTransformedTextRun::SetLineBreaks(PRUint32 aStart, PRUint32 aLength,
|
||||
mLineBreaks.SwapElements(newBreaks);
|
||||
|
||||
gfxFloat currentAdvance = GetAdvanceWidth(aStart, aLength, nsnull);
|
||||
mFactory->RebuildTextRun(this);
|
||||
mFactory->RebuildTextRun(this, aRefContext);
|
||||
if (aAdvanceWidthDelta) {
|
||||
*aAdvanceWidthDelta = GetAdvanceWidth(aStart, aLength, nsnull) - currentAdvance;
|
||||
}
|
||||
@@ -160,7 +162,7 @@ nsTransformingTextRunFactory::MakeTextRun(const PRUnichar* aString, PRUint32 aLe
|
||||
if (!textRun)
|
||||
return nsnull;
|
||||
|
||||
RebuildTextRun(textRun);
|
||||
RebuildTextRun(textRun, aParams->mContext);
|
||||
return textRun;
|
||||
}
|
||||
|
||||
@@ -310,10 +312,11 @@ MergeCharactersInTextRun(gfxTextRun* aDest, gfxTextRun* aSrc,
|
||||
}
|
||||
|
||||
static gfxTextRunFactory::Parameters
|
||||
GetParametersForInner(nsTransformedTextRun* aTextRun, PRUint32* aFlags)
|
||||
GetParametersForInner(nsTransformedTextRun* aTextRun, PRUint32* aFlags,
|
||||
gfxContext* aRefContext)
|
||||
{
|
||||
gfxTextRunFactory::Parameters params =
|
||||
{ aTextRun->mRefContext, nsnull, nsnull,
|
||||
{ aRefContext, nsnull, nsnull,
|
||||
nsnull, nsnull, PRUint32(aTextRun->GetAppUnitsPerDevUnit())
|
||||
};
|
||||
*aFlags = aTextRun->GetFlags() & ~gfxFontGroup::TEXT_IS_PERSISTENT;
|
||||
@@ -321,7 +324,8 @@ GetParametersForInner(nsTransformedTextRun* aTextRun, PRUint32* aFlags)
|
||||
}
|
||||
|
||||
void
|
||||
nsFontVariantTextRunFactory::RebuildTextRun(nsTransformedTextRun* aTextRun)
|
||||
nsFontVariantTextRunFactory::RebuildTextRun(nsTransformedTextRun* aTextRun,
|
||||
gfxContext* aRefContext)
|
||||
{
|
||||
nsICaseConversion* converter = nsTextTransformer::GetCaseConv();
|
||||
if (!converter)
|
||||
@@ -335,7 +339,8 @@ nsFontVariantTextRunFactory::RebuildTextRun(nsTransformedTextRun* aTextRun)
|
||||
return;
|
||||
|
||||
PRUint32 flags;
|
||||
gfxTextRunFactory::Parameters innerParams = GetParametersForInner(aTextRun, &flags);
|
||||
gfxTextRunFactory::Parameters innerParams =
|
||||
GetParametersForInner(aTextRun, &flags, aRefContext);
|
||||
// The text outlives the child and inner textruns
|
||||
flags |= gfxFontGroup::TEXT_IS_PERSISTENT;
|
||||
|
||||
@@ -404,7 +409,8 @@ nsFontVariantTextRunFactory::RebuildTextRun(nsTransformedTextRun* aTextRun)
|
||||
// (and also child will be shaped appropriately)
|
||||
NS_ASSERTION(canBreakBeforeArray.Length() == i - runStart,
|
||||
"lost some break-before values?");
|
||||
child->SetPotentialLineBreaks(0, canBreakBeforeArray.Length(), canBreakBeforeArray.Elements());
|
||||
child->SetPotentialLineBreaks(0, canBreakBeforeArray.Length(),
|
||||
canBreakBeforeArray.Elements(), aRefContext);
|
||||
AppendTextRun(aTextRun, child, runStart);
|
||||
|
||||
runStart = i;
|
||||
@@ -427,7 +433,8 @@ nsFontVariantTextRunFactory::RebuildTextRun(nsTransformedTextRun* aTextRun)
|
||||
}
|
||||
|
||||
void
|
||||
nsCaseTransformTextRunFactory::RebuildTextRun(nsTransformedTextRun* aTextRun)
|
||||
nsCaseTransformTextRunFactory::RebuildTextRun(nsTransformedTextRun* aTextRun,
|
||||
gfxContext* aRefContext)
|
||||
{
|
||||
nsICaseConversion* converter = nsTextTransformer::GetCaseConv();
|
||||
if (!converter)
|
||||
@@ -507,7 +514,8 @@ nsCaseTransformTextRunFactory::RebuildTextRun(nsTransformedTextRun* aTextRun)
|
||||
"lost track of line breaks somehow");
|
||||
|
||||
PRUint32 flags;
|
||||
gfxTextRunFactory::Parameters innerParams = GetParametersForInner(aTextRun, &flags);
|
||||
gfxTextRunFactory::Parameters innerParams =
|
||||
GetParametersForInner(aTextRun, &flags, aRefContext);
|
||||
gfxFontGroup* fontGroup = aTextRun->GetFontGroup();
|
||||
|
||||
nsAutoPtr<gfxTextRun> child;
|
||||
@@ -531,7 +539,8 @@ nsCaseTransformTextRunFactory::RebuildTextRun(nsTransformedTextRun* aTextRun)
|
||||
// (and also child will be shaped appropriately)
|
||||
NS_ASSERTION(convertedString.Length() == canBreakBeforeArray.Length(),
|
||||
"Dropped characters or break-before values somewhere!");
|
||||
child->SetPotentialLineBreaks(0, canBreakBeforeArray.Length(), canBreakBeforeArray.Elements());
|
||||
child->SetPotentialLineBreaks(0, canBreakBeforeArray.Length(),
|
||||
canBreakBeforeArray.Elements(), aRefContext);
|
||||
// Now merge multiple characters into one multi-glyph character as required
|
||||
MergeCharactersInTextRun(aTextRun, child, charsToMergeArray.Elements());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user