Don't implicitly lossy convert from nsGlyphCode to PRUnichar

b=400938 r+sr=roc a=blocking1.9


git-svn-id: svn://10.0.0.236/trunk@239487 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
karlt+%karlt.net 2007-11-15 21:44:49 +00:00
parent 8321c28a2a
commit 3879b592b5
2 changed files with 43 additions and 31 deletions

View File

@ -467,11 +467,12 @@ nsGlyphTable::ElementAt(nsPresContext* aPresContext, nsMathMLChar* aChar, PRUint
}
// If aChar is a child char, the index of the glyph is relative to
// the offset of the list of glyphs corresponding to the child char
// the offset of the list of glyphs corresponding to the child char.
PRUint32 offset = 0;
PRUint32 length = mGlyphCache.Length();
if (aChar->mParent) {
nsMathMLChar* child = aChar->mParent->mSibling;
// XXXkt composite chars can't have size variants
while (child && (child != aChar)) {
offset += 5; // skip the 4 partial glyphs + the whitespace separator
child = child->mSibling;
@ -483,7 +484,7 @@ nsGlyphTable::ElementAt(nsPresContext* aPresContext, nsMathMLChar* aChar, PRUint
nsGlyphCode ch;
ch.code = mGlyphCache.CharAt(index);
ch.font = mGlyphCache.CharAt(index + 1) - '0'; // the ASCII trick is kept internal...
return (ch == PRUnichar(0xFFFD)) ? kNullGlyph : ch;
return (ch.code == PRUnichar(0xFFFD)) ? kNullGlyph : ch;
}
PRBool
@ -529,7 +530,8 @@ nsGlyphTable::Has(nsPresContext* aPresContext, PRUnichar aChar)
PRBool
nsGlyphTable::HasVariantsOf(nsPresContext* aPresContext, nsMathMLChar* aChar)
{
return BigOf(aPresContext, aChar, 1) != 0;
//XXXkt all variants must be in the same file as size 1
return BigOf(aPresContext, aChar, 1).Exists();
}
PRBool
@ -546,9 +548,11 @@ nsGlyphTable::HasVariantsOf(nsPresContext* aPresContext, PRUnichar aChar)
PRBool
nsGlyphTable::HasPartsOf(nsPresContext* aPresContext, nsMathMLChar* aChar)
{
return GlueOf(aPresContext, aChar) || TopOf(aPresContext, aChar) ||
BottomOf(aPresContext, aChar) || MiddleOf(aPresContext, aChar) ||
IsComposite(aPresContext, aChar);
return GlueOf(aPresContext, aChar).Exists() ||
TopOf(aPresContext, aChar).Exists() ||
BottomOf(aPresContext, aChar).Exists() ||
MiddleOf(aPresContext, aChar).Exists() ||
IsComposite(aPresContext, aChar);
}
PRBool
@ -1682,7 +1686,7 @@ nsMathMLChar::Stretch(nsPresContext* aPresContext,
glyphTable = static_cast<nsGlyphTable*>(tableList.ElementAt(t));
// figure out the starting size : if this is a largeop, start at 2 else 1
size = 1; // size=0 is the char at its normal size
if (largeop && glyphTable->BigOf(aPresContext, this, 2)) {
if (largeop && glyphTable->BigOf(aPresContext, this, 2).Exists()) {
size = 2;
}
glyphTable->GetPrimaryFontName(fontName);
@ -1693,8 +1697,8 @@ nsMathMLChar::Stretch(nsPresContext* aPresContext,
NS_LossyConvertUTF16toASCII(fontName).get());
#endif
ch = glyphTable->BigOf(aPresContext, this, size++);
while (ch) {
NS_ASSERTION(ch != uchar, "glyph table incorrectly set -- duplicate found");
while (ch.Exists()) {
NS_ASSERTION(ch != startingGlyph, "glyph table incorrectly set -- duplicate found");
rv = glyphTable->GetBoundingMetrics(aRenderingContext, theFont, ch, bm);
if (NS_SUCCEEDED(rv)) {
charSize = (isVertical)
@ -1797,8 +1801,8 @@ nsMathMLChar::Stretch(nsPresContext* aPresContext,
case 3: ch = glue; break;
}
// empty slots are filled with the glue if it is not null
if (!ch) ch = glue;
if (!ch) { // glue is null, set bounding metrics to 0
if (!ch.Exists()) ch = glue;
if (!ch.Exists()) { // glue is null, set bounding metrics to 0
bm.Clear();
}
else {
@ -2199,7 +2203,7 @@ nsMathMLChar::PaintForeground(nsPresContext* aPresContext,
SetFirstFamily(theFont, fontName);
aRenderingContext.SetFont(theFont, nsnull);
// if there is a glyph of appropriate size, paint that glyph
if (mGlyph) {
if (mGlyph.Exists()) {
//printf("Painting %04X with a glyph of appropriate size\n", mData[0]);
//aRenderingContext.SetColor(NS_RGB(0,0,255));
mGlyphTable->DrawGlyph(aRenderingContext, theFont, mGlyph,
@ -2264,8 +2268,8 @@ nsMathMLChar::PaintVertically(nsPresContext* aPresContext,
case 3: ch = glue; break;
}
// empty slots are filled with the glue if it is not null
if (!ch) ch = glue;
if (!ch) {
if (!ch.Exists()) ch = glue;
if (!ch.Exists()) {
bm.Clear(); // glue is null, set bounding metrics to 0
}
else {
@ -2305,7 +2309,7 @@ nsMathMLChar::PaintVertically(nsPresContext* aPresContext,
for (i = 0; i < 3; i++) {
ch = chdata[i];
// glue can be null, and other parts could have been set to glue
if (ch) {
if (ch.Exists()) {
#ifdef SHOW_BORDERS
// bounding box of the part
aRenderingContext.SetColor(NS_RGB(0,0,0));
@ -2330,7 +2334,7 @@ nsMathMLChar::PaintVertically(nsPresContext* aPresContext,
///////////////
// fill the gap between top and middle, and between middle and bottom.
if (!glue) { // null glue : draw a rule
if (!glue.Exists()) { // null glue : draw a rule
// figure out the dimensions of the rule to be drawn :
// set lbearing to rightmost lbearing among the two current successive parts.
// set rbearing to leftmost rbearing among the two current successive parts.
@ -2339,21 +2343,21 @@ nsMathMLChar::PaintVertically(nsPresContext* aPresContext,
// in Symbol for small font sizes in unix.
nscoord lbearing, rbearing;
PRInt32 first = 0, last = 2;
if (chdata[1]) { // middle part exists
if (chdata[1].Exists()) { // middle part exists
last = 1;
}
while (last <= 2) {
if (chdata[last]) {
if (chdata[last].Exists()) {
lbearing = bmdata[last].leftBearing;
rbearing = bmdata[last].rightBearing;
if (chdata[first]) {
if (chdata[first].Exists()) {
if (lbearing < bmdata[first].leftBearing)
lbearing = bmdata[first].leftBearing;
if (rbearing > bmdata[first].rightBearing)
rbearing = bmdata[first].rightBearing;
}
}
else if (chdata[first]) {
else if (chdata[first].Exists()) {
lbearing = bmdata[first].leftBearing;
rbearing = bmdata[first].rightBearing;
}
@ -2458,8 +2462,8 @@ nsMathMLChar::PaintHorizontally(nsPresContext* aPresContext,
case 3: ch = glue; break;
}
// empty slots are filled with the glue if it is not null
if (!ch) ch = glue;
if (!ch) {
if (!ch.Exists()) ch = glue;
if (!ch.Exists()) {
bm.Clear(); // glue is null, set bounding metrics to 0
}
else {
@ -2500,7 +2504,7 @@ nsMathMLChar::PaintHorizontally(nsPresContext* aPresContext,
for (i = 0; i < 3; i++) {
ch = chdata[i];
// glue can be null, and other parts could have been set to glue
if (ch) {
if (ch.Exists()) {
#ifdef SHOW_BORDERS
aRenderingContext.SetColor(NS_RGB(255,0,0));
aRenderingContext.DrawRect(nsRect(start[i], dy - bmdata[i].ascent,
@ -2525,7 +2529,7 @@ nsMathMLChar::PaintHorizontally(nsPresContext* aPresContext,
////////////////
// fill the gap between left and middle, and between middle and right.
if (!glue) { // null glue : draw a rule
if (!glue.Exists()) { // null glue : draw a rule
// figure out the dimensions of the rule to be drawn :
// set ascent to lowest ascent among the two current successive parts.
// set descent to highest descent among the two current successive parts.
@ -2533,21 +2537,21 @@ nsMathMLChar::PaintHorizontally(nsPresContext* aPresContext,
// fix broken fonts.
nscoord ascent, descent;
PRInt32 first = 0, last = 2;
if (chdata[1]) { // middle part exists
if (chdata[1].Exists()) { // middle part exists
last = 1;
}
while (last <= 2) {
if (chdata[last]) {
if (chdata[last].Exists()) {
ascent = bmdata[last].ascent;
descent = bmdata[last].descent;
if (chdata[first]) {
if (chdata[first].Exists()) {
if (ascent > bmdata[first].ascent)
ascent = bmdata[first].ascent;
if (descent > bmdata[first].descent)
descent = bmdata[first].descent;
}
}
else if (chdata[first]) {
else if (chdata[first].Exists()) {
ascent = bmdata[first].ascent;
descent = bmdata[first].descent;
}

View File

@ -60,9 +60,17 @@ struct nsGlyphCode {
PRUnichar code;
PRInt32 font;
// conversion operator to just return the code point that we generally want
operator PRUnichar () {
return code;
PRBool Exists() const
{
return (code != 0);
}
PRBool operator==(const nsGlyphCode& other) const
{
return other.code == code && other.font == font;
}
PRBool operator!=(const nsGlyphCode& other) const
{
return ! operator==(other);
}
};