Bug 1067755 - Store relevant style data rather than style context pointers on transformed text runs. r=jdaggett
This commit is contained in:
@@ -9,7 +9,6 @@
|
||||
#include "mozilla/BinarySearch.h"
|
||||
|
||||
#include "nsStyleConsts.h"
|
||||
#include "nsStyleContext.h"
|
||||
#include "nsTextFrameUtils.h"
|
||||
#include "nsFontMetrics.h"
|
||||
#include "nsDeviceContext.h"
|
||||
@@ -538,7 +537,7 @@ MathMLTextRunFactory::RebuildTextRun(nsTransformedTextRun* aTextRun,
|
||||
nsAutoString convertedString;
|
||||
nsAutoTArray<bool,50> charsToMergeArray;
|
||||
nsAutoTArray<bool,50> deletedCharsArray;
|
||||
nsAutoTArray<nsStyleContext*,50> styleArray;
|
||||
nsAutoTArray<nsRefPtr<nsTransformedCharStyle>,50> styleArray;
|
||||
nsAutoTArray<uint8_t,50> canBreakBeforeArray;
|
||||
bool mergeNeeded = false;
|
||||
|
||||
@@ -547,10 +546,10 @@ MathMLTextRunFactory::RebuildTextRun(nsTransformedTextRun* aTextRun,
|
||||
|
||||
uint32_t length = aTextRun->GetLength();
|
||||
const char16_t* str = aTextRun->mString.BeginReading();
|
||||
nsRefPtr<nsStyleContext>* styles = aTextRun->mStyles.Elements();
|
||||
const nsTArray<nsRefPtr<nsTransformedCharStyle>>& styles = aTextRun->mStyles;
|
||||
nsFont font;
|
||||
if (length) {
|
||||
font = styles[0]->StyleFont()->mFont;
|
||||
font = styles[0]->mFont;
|
||||
|
||||
if (mSSTYScriptLevel || (mFlags & MATH_FONT_FEATURE_DTLS)) {
|
||||
bool foundSSTY = false;
|
||||
@@ -565,7 +564,7 @@ MathMLTextRunFactory::RebuildTextRun(nsTransformedTextRun* aTextRun,
|
||||
}
|
||||
if (mSSTYScriptLevel && !foundSSTY) {
|
||||
uint8_t sstyLevel = 0;
|
||||
float scriptScaling = pow(styles[0]->StyleFont()->mScriptSizeMultiplier,
|
||||
float scriptScaling = pow(styles[0]->mScriptSizeMultiplier,
|
||||
mSSTYScriptLevel);
|
||||
static_assert(NS_MATHML_DEFAULT_SCRIPT_SIZE_MULTIPLIER < 1,
|
||||
"Shouldn't it make things smaller?");
|
||||
@@ -626,8 +625,7 @@ MathMLTextRunFactory::RebuildTextRun(nsTransformedTextRun* aTextRun,
|
||||
|
||||
for (uint32_t i = 0; i < length; ++i) {
|
||||
int extraChars = 0;
|
||||
nsStyleContext* styleContext = styles[i];
|
||||
mathVar = styleContext->StyleFont()->mMathVariant;
|
||||
mathVar = styles[i]->mMathVariant;
|
||||
|
||||
if (singleCharMI && mathVar == NS_MATHML_MATHVARIANT_NONE) {
|
||||
// If the user has explicitly set a non-default value for fontstyle or
|
||||
@@ -688,7 +686,7 @@ MathMLTextRunFactory::RebuildTextRun(nsTransformedTextRun* aTextRun,
|
||||
|
||||
deletedCharsArray.AppendElement(false);
|
||||
charsToMergeArray.AppendElement(false);
|
||||
styleArray.AppendElement(styleContext);
|
||||
styleArray.AppendElement(styles[i]);
|
||||
canBreakBeforeArray.AppendElement(aTextRun->CanBreakLineBefore(i));
|
||||
|
||||
if (IS_IN_BMP(ch2)) {
|
||||
@@ -707,7 +705,7 @@ MathMLTextRunFactory::RebuildTextRun(nsTransformedTextRun* aTextRun,
|
||||
while (extraChars-- > 0) {
|
||||
mergeNeeded = true;
|
||||
charsToMergeArray.AppendElement(true);
|
||||
styleArray.AppendElement(styleContext);
|
||||
styleArray.AppendElement(styles[i]);
|
||||
canBreakBeforeArray.AppendElement(false);
|
||||
}
|
||||
}
|
||||
@@ -742,12 +740,11 @@ MathMLTextRunFactory::RebuildTextRun(nsTransformedTextRun* aTextRun,
|
||||
// Get the correct gfxFontGroup that corresponds to the earlier font changes.
|
||||
if (length) {
|
||||
font.size = NSToCoordRound(font.size * mFontInflation);
|
||||
nsPresContext* pc = styles[0]->PresContext();
|
||||
nsPresContext* pc = styles[0]->mPresContext;
|
||||
nsRefPtr<nsFontMetrics> metrics;
|
||||
const nsStyleFont* styleFont = styles[0]->StyleFont();
|
||||
pc->DeviceContext()->GetMetricsFor(font,
|
||||
styleFont->mLanguage,
|
||||
styleFont->mExplicitLanguage,
|
||||
styles[0]->mLanguage,
|
||||
styles[0]->mExplicitLanguage,
|
||||
gfxFont::eHorizontal,
|
||||
pc->GetUserFontSet(),
|
||||
pc->GetTextPerfMetrics(),
|
||||
@@ -766,7 +763,7 @@ MathMLTextRunFactory::RebuildTextRun(nsTransformedTextRun* aTextRun,
|
||||
if (mInnerTransformingTextRunFactory) {
|
||||
transformedChild = mInnerTransformingTextRunFactory->MakeTextRun(
|
||||
convertedString.BeginReading(), convertedString.Length(),
|
||||
&innerParams, newFontGroup, flags, styleArray.Elements(), false);
|
||||
&innerParams, newFontGroup, flags, Move(styleArray), false);
|
||||
child = transformedChild.get();
|
||||
} else {
|
||||
cachedChild = newFontGroup->MakeTextRun(
|
||||
|
||||
Reference in New Issue
Block a user