b=605605 Uninitialised value used in nsMathMLChar r=karlt

--HG--
extra : transplant_source : _G%B6%C6%C6q%C0a%F0f-%CD%AF%FB%FE%F0%BAYc%D5
This commit is contained in:
Frédéric Wang 2011-03-25 16:38:59 +13:00
parent fb9546d73f
commit e14021d292

View File

@ -1156,7 +1156,8 @@ public:
nscoord aTargetSize, nscoord aTargetSize,
PRUint32 aStretchHint, PRUint32 aStretchHint,
nsBoundingMetrics& aStretchedMetrics, nsBoundingMetrics& aStretchedMetrics,
const nsAString& aFamilies) const nsAString& aFamilies,
PRBool& aGlyphFound)
: mChar(aChar), : mChar(aChar),
mPresContext(aPresContext), mPresContext(aPresContext),
mRenderingContext(aRenderingContext), mRenderingContext(aRenderingContext),
@ -1166,7 +1167,8 @@ public:
mBoundingMetrics(aStretchedMetrics), mBoundingMetrics(aStretchedMetrics),
mFamilies(aFamilies), mFamilies(aFamilies),
mTryVariants(PR_TRUE), mTryVariants(PR_TRUE),
mTryParts(PR_TRUE) {} mTryParts(PR_TRUE),
mGlyphFound(aGlyphFound) {}
static PRBool static PRBool
EnumCallback(const nsString& aFamily, PRBool aGeneric, void *aData); EnumCallback(const nsString& aFamily, PRBool aGeneric, void *aData);
@ -1195,6 +1197,7 @@ public:
private: private:
nsAutoTArray<nsGlyphTable*,16> mTablesTried; nsAutoTArray<nsGlyphTable*,16> mTablesTried;
nsGlyphTable* mGlyphTable; // for this callback nsGlyphTable* mGlyphTable; // for this callback
PRBool& mGlyphFound;
}; };
@ -1250,6 +1253,7 @@ nsMathMLChar::StretchEnumContext::TryVariants(nsGlyphTable* aGlyphTable,
if (largeopOnly || if (largeopOnly ||
IsSizeBetter(charSize, bestSize, mTargetSize, mStretchHint)) { IsSizeBetter(charSize, bestSize, mTargetSize, mStretchHint)) {
mGlyphFound = PR_TRUE;
if (maxWidth) { if (maxWidth) {
// IsSizeBetter() checked that charSize < maxsize; // IsSizeBetter() checked that charSize < maxsize;
// Leave ascent, descent, and bestsize as these contain maxsize. // Leave ascent, descent, and bestsize as these contain maxsize.
@ -1320,6 +1324,7 @@ nsMathMLChar::StretchEnumContext::TryParts(nsGlyphTable* aGlyphTable,
// all went well, painting will be delegated from now on to children // all went well, painting will be delegated from now on to children
mChar->mGlyph = kNullGlyph; // this will tell paint to build by parts mChar->mGlyph = kNullGlyph; // this will tell paint to build by parts
mGlyphFound = PR_TRUE;
mChar->mGlyphTable = aGlyphTable; mChar->mGlyphTable = aGlyphTable;
mBoundingMetrics = compositeSize; mBoundingMetrics = compositeSize;
return PR_TRUE; // no more searching return PR_TRUE; // no more searching
@ -1447,6 +1452,7 @@ nsMathMLChar::StretchEnumContext::TryParts(nsGlyphTable* aGlyphTable,
mBoundingMetrics.leftBearing = 0; mBoundingMetrics.leftBearing = 0;
mBoundingMetrics.rightBearing = computedSize; mBoundingMetrics.rightBearing = computedSize;
} }
mGlyphFound = PR_TRUE;
if (maxWidth) if (maxWidth)
return PR_FALSE; // Continue to check other sizes return PR_FALSE; // Continue to check other sizes
@ -1565,7 +1571,6 @@ nsMathMLChar::StretchInternal(nsPresContext* aPresContext,
} }
if (!maxWidth) { if (!maxWidth) {
mScaleY = mScaleX = 1.0;
mUnscaledAscent = aDesiredStretchSize.ascent; mUnscaledAscent = aDesiredStretchSize.ascent;
} }
@ -1655,6 +1660,7 @@ nsMathMLChar::StretchInternal(nsPresContext* aPresContext,
// 2/3. Search for a glyph or set of part glyphs of appropriate size // 2/3. Search for a glyph or set of part glyphs of appropriate size
//////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////
PRBool glyphFound = PR_FALSE;
nsAutoString cssFamilies; nsAutoString cssFamilies;
if (!done) { if (!done) {
@ -1669,7 +1675,7 @@ nsMathMLChar::StretchInternal(nsPresContext* aPresContext,
StretchEnumContext enumData(this, aPresContext, aRenderingContext, StretchEnumContext enumData(this, aPresContext, aRenderingContext,
aStretchDirection, targetSize, aStretchHint, aStretchDirection, targetSize, aStretchHint,
aDesiredStretchSize, font.name); aDesiredStretchSize, font.name, glyphFound);
enumData.mTryParts = PR_FALSE; enumData.mTryParts = PR_FALSE;
done = !font.EnumerateFamilies(StretchEnumContext::EnumCallback, &enumData); done = !font.EnumerateFamilies(StretchEnumContext::EnumCallback, &enumData);
@ -1683,7 +1689,7 @@ nsMathMLChar::StretchInternal(nsPresContext* aPresContext,
StretchEnumContext enumData(this, aPresContext, aRenderingContext, StretchEnumContext enumData(this, aPresContext, aRenderingContext,
aStretchDirection, targetSize, aStretchHint, aStretchDirection, targetSize, aStretchHint,
aDesiredStretchSize, font.name); aDesiredStretchSize, font.name, glyphFound);
enumData.mTryVariants = PR_FALSE; enumData.mTryVariants = PR_FALSE;
done = !font.EnumerateFamilies(StretchEnumContext::EnumCallback, &enumData); done = !font.EnumerateFamilies(StretchEnumContext::EnumCallback, &enumData);
@ -1704,7 +1710,7 @@ nsMathMLChar::StretchInternal(nsPresContext* aPresContext,
#endif #endif
StretchEnumContext enumData(this, aPresContext, aRenderingContext, StretchEnumContext enumData(this, aPresContext, aRenderingContext,
aStretchDirection, targetSize, aStretchHint, aStretchDirection, targetSize, aStretchHint,
aDesiredStretchSize, font.name); aDesiredStretchSize, font.name, glyphFound);
enumData.mTryParts = !largeopOnly; enumData.mTryParts = !largeopOnly;
font.EnumerateFamilies(StretchEnumContext::EnumCallback, &enumData); font.EnumerateFamilies(StretchEnumContext::EnumCallback, &enumData);
@ -1713,7 +1719,7 @@ nsMathMLChar::StretchInternal(nsPresContext* aPresContext,
if (!maxWidth) { if (!maxWidth) {
// Now, we know how we are going to draw the char. Update the member // Now, we know how we are going to draw the char. Update the member
// variables accordingly. // variables accordingly.
mDrawNormal = (mGlyph.font == -1); mDrawNormal = !glyphFound;
mUnscaledAscent = aDesiredStretchSize.ascent; mUnscaledAscent = aDesiredStretchSize.ascent;
} }
@ -1725,7 +1731,9 @@ nsMathMLChar::StretchInternal(nsPresContext* aPresContext,
(aDesiredStretchSize.ascent + aDesiredStretchSize.descent); (aDesiredStretchSize.ascent + aDesiredStretchSize.descent);
if (!largeop || scale > 1.0) { if (!largeop || scale > 1.0) {
// make the character match the desired height. // make the character match the desired height.
mScaleY *= scale; if (!maxWidth) {
mScaleY *= scale;
}
aDesiredStretchSize.ascent *= scale; aDesiredStretchSize.ascent *= scale;
aDesiredStretchSize.descent *= scale; aDesiredStretchSize.descent *= scale;
} }
@ -1735,7 +1743,9 @@ nsMathMLChar::StretchInternal(nsPresContext* aPresContext,
(aDesiredStretchSize.rightBearing - aDesiredStretchSize.leftBearing); (aDesiredStretchSize.rightBearing - aDesiredStretchSize.leftBearing);
if (!largeop || scale > 1.0) { if (!largeop || scale > 1.0) {
// make the character match the desired width. // make the character match the desired width.
mScaleX *= scale; if (!maxWidth) {
mScaleX *= scale;
}
aDesiredStretchSize.leftBearing *= scale; aDesiredStretchSize.leftBearing *= scale;
aDesiredStretchSize.rightBearing *= scale; aDesiredStretchSize.rightBearing *= scale;
aDesiredStretchSize.width *= scale; aDesiredStretchSize.width *= scale;
@ -1745,7 +1755,7 @@ nsMathMLChar::StretchInternal(nsPresContext* aPresContext,
// We do not have a char variant for this largeop in display mode, so we // We do not have a char variant for this largeop in display mode, so we
// apply a scale transform to the base char. // apply a scale transform to the base char.
if (mGlyph.font == -1 && largeop) { if (!glyphFound && largeop) {
float scale; float scale;
float largeopFactor = M_SQRT2; float largeopFactor = M_SQRT2;
@ -1756,7 +1766,9 @@ nsMathMLChar::StretchInternal(nsPresContext* aPresContext,
scale = (largeopFactor * scale = (largeopFactor *
(initialSize.rightBearing - initialSize.leftBearing)) / (initialSize.rightBearing - initialSize.leftBearing)) /
(aDesiredStretchSize.rightBearing - aDesiredStretchSize.leftBearing); (aDesiredStretchSize.rightBearing - aDesiredStretchSize.leftBearing);
mScaleX *= scale; if (!maxWidth) {
mScaleX *= scale;
}
aDesiredStretchSize.leftBearing *= scale; aDesiredStretchSize.leftBearing *= scale;
aDesiredStretchSize.rightBearing *= scale; aDesiredStretchSize.rightBearing *= scale;
aDesiredStretchSize.width *= scale; aDesiredStretchSize.width *= scale;
@ -1773,7 +1785,9 @@ nsMathMLChar::StretchInternal(nsPresContext* aPresContext,
scale = (largeopFactor * scale = (largeopFactor *
(initialSize.ascent + initialSize.descent)) / (initialSize.ascent + initialSize.descent)) /
(aDesiredStretchSize.ascent + aDesiredStretchSize.descent); (aDesiredStretchSize.ascent + aDesiredStretchSize.descent);
mScaleY *= scale; if (!maxWidth) {
mScaleY *= scale;
}
aDesiredStretchSize.ascent *= scale; aDesiredStretchSize.ascent *= scale;
aDesiredStretchSize.descent *= scale; aDesiredStretchSize.descent *= scale;
} }
@ -1795,9 +1809,8 @@ nsMathMLChar::Stretch(nsPresContext* aPresContext,
NS_STRETCH_INTEGRAL)), NS_STRETCH_INTEGRAL)),
"Unexpected stretch flags"); "Unexpected stretch flags");
// This will be updated if a better match than the base character is found mDrawNormal = PR_TRUE;
mGlyph.font = -1; mScaleY = mScaleX = 1.0;
mDirection = aStretchDirection; mDirection = aStretchDirection;
nsresult rv = nsresult rv =
StretchInternal(aPresContext, aRenderingContext, mDirection, StretchInternal(aPresContext, aRenderingContext, mDirection,