[not part of default build] Fix bug 43443, and some updates in the stretchy chars land. a:waterson@mozilla.org

This commit is contained in:
rbs%maths.uq.edu.au 2000-07-03 05:40:13 +00:00
Родитель 6a68400e4e
Коммит 4f754a98e8
4 изменённых файлов: 123 добавлений и 121 удалений

Просмотреть файл

@ -414,7 +414,7 @@ nsGlyphTable(NS_TABLE_TYPE_UNICODE, "UNDEFINED",
// Data sets that we have ...
// -----------------------------------------------------------------------------------
// Data for strecthy chars that are supported by the Symbol font ---------------------
// Data for stretchy chars that are supported by the Symbol font ---------------------
static nsCharData gCharDataSymbol[] = {
#define WANT_SYMBOL_DATA
@ -438,7 +438,7 @@ nsGlyphTable(NS_TABLE_TYPE_UNICODE, "Symbol",
gGlyphCodeSymbol, sizeof(gGlyphCodeSymbol) / sizeof(gGlyphCodeSymbol[0]));
// -----------------------------------------------------------------------------------
// Data for strecthy chars that are supported by the MT Extra font -------------------
// Data for stretchy chars that are supported by the MT Extra font -------------------
static nsCharData gCharDataMTExtra[] = {
#define WANT_MTEXTRA_DATA
@ -462,7 +462,7 @@ nsGlyphTable(NS_TABLE_TYPE_UNICODE, "MT Extra",
gGlyphCodeMTExtra, sizeof(gGlyphCodeMTExtra) / sizeof(gGlyphCodeMTExtra[0]));
// -----------------------------------------------------------------------------------
// Data for strecthy chars that are supported by TeX's CMEX font ---------------------
// Data for stretchy chars that are supported by TeX's CMEX font ---------------------
static nsCharData gCharDataCMEX[] = {
#define WANT_CMEX_DATA
@ -486,7 +486,7 @@ nsGlyphTable(NS_TABLE_TYPE_UNICODE, "CMEX10",
gGlyphCodeCMEX, sizeof(gGlyphCodeCMEX) / sizeof(gGlyphCodeCMEX[0]));
// -----------------------------------------------------------------------------------
// Data for strecthy chars that are supported by TeX's CMSY font ---------------------
// Data for stretchy chars that are supported by TeX's CMSY font ---------------------
static nsCharData gCharDataCMSY[] = {
#define WANT_CMSY_DATA
@ -510,7 +510,7 @@ nsGlyphTable(NS_TABLE_TYPE_UNICODE, "CMSY10",
gGlyphCodeCMSY, sizeof(gGlyphCodeCMSY) / sizeof(gGlyphCodeCMSY[0]));
// -----------------------------------------------------------------------------------
// Data for strecthy chars that are supported by the Math4 font ----------------------
// Data for stretchy chars that are supported by the Math4 font ----------------------
static nsCharData gCharDataMath4[] = {
#define WANT_MATH4_DATA
@ -629,7 +629,7 @@ nsMathMLChar::SetData(nsIPresContext* aPresContext,
if (mDirection != NS_STRETCH_DIRECTION_UNSUPPORTED) {
// ... now see if there is a glyph table for us
mGlyphTable = gGlyphTableList.FindTableFor(mEnum);
// don't bother with the streching if there is no glyph table for us...
// don't bother with the stretching if there is no glyph table for us...
if (!mGlyphTable) {
gCharInfo[i].mDirection = NS_STRETCH_DIRECTION_UNSUPPORTED; // update to never try again
mDirection = NS_STRETCH_DIRECTION_UNSUPPORTED;
@ -670,7 +670,7 @@ nsMathMLChar::SetEnum(nsIPresContext* aPresContext,
if (mDirection != NS_STRETCH_DIRECTION_UNSUPPORTED) {
// ... now see if there is a glyph table for us
mGlyphTable = gGlyphTableList.FindTableFor(mEnum);
// don't bother with the streching if there is no glyph table for us...
// don't bother with the stretching if there is no glyph table for us...
if (!mGlyphTable) {
gCharInfo[mEnum].mDirection = NS_STRETCH_DIRECTION_UNSUPPORTED; // update to never try again
mDirection = NS_STRETCH_DIRECTION_UNSUPPORTED;
@ -1034,9 +1034,7 @@ nsMathMLChar::Stretch(nsIPresContext* aPresContext,
PRInt32 i;
// XXX hack!
float flex[3] = {0.7f, 0.3f, 0.7f};
// compute the bounding metrics of all partial glyphs
nsGlyphCode chdata[4];
nsBoundingMetrics bmdata[4];
for (i = 0; i < 4; i++) {
@ -1050,83 +1048,92 @@ nsMathMLChar::Stretch(nsIPresContext* aPresContext,
rv = glyphTable->GetBoundingMetrics(aRenderingContext, ch, bm);
if (NS_FAILED(rv)) {
printf("GetBoundingMetrics failed for %04X:%c\n", ch, ch&0x00FF);
// ensure that the char later behaves like a normal char
mEnum = eMathMLChar_DONT_STRETCH; // XXX need to reset in dynamic updates
return rv;
// stop if we failed to compute the bounding metrics of a part.
// we will use the best glyph encountered earlier
break;
}
chdata[i] = ch;
bmdata[i] = bm;
}
// refine the flexibility depending on whether some parts are not there
if ((chdata[1] == chdata[0]) || // mid == top (or mid == left)
(chdata[1] == chdata[2]) || // mid == bot (or mid == right)
(chdata[1] == chdata[3])) // mid == glue
{
flex[0] = 0.5f;
flex[1] = 0.0f;
flex[2] = 0.5f;
}
if (aDirection == NS_STRETCH_DIRECTION_VERTICAL) {
// default is to fill-up the area given to us
nscoord lbearing = bmdata[0].leftBearing;
nscoord rbearing = bmdata[0].rightBearing;
nscoord h = 0;
nscoord w = bmdata[0].width;
for (i = 0; i < 4; i++) {
bm = bmdata[i];
if (w < bm.width) w = bm.width;
if (i < 3) {
h += nscoord(flex[i]*(bm.ascent + bm.descent)); // sum heights of the parts...
// compute and cache our bounding metrics (vertical stacking!)
if (lbearing > bm.leftBearing) lbearing = bm.leftBearing;
if (rbearing < bm.rightBearing) rbearing = bm.rightBearing;
// build by parts if we have successfully computed the
// bounding metrics of all partial glyphs
if (NS_SUCCEEDED(rv)) {
// We want to place the glyphs even if they don't fit at their
// full extent, i.e., we may clip to tolerate a small amount of
// overlap between the parts. This is important to cater for fonts
// with long glues.
float flex[3] = {0.7f, 0.3f, 0.7f};
// refine the flexibility depending on whether some parts are not there
if ((chdata[1] == chdata[0]) || // mid == top (or mid == left)
(chdata[1] == chdata[2]) || // mid == bot (or mid == right)
(chdata[1] == chdata[3])) // mid == glue
{
flex[0] = 0.5f;
flex[1] = 0.0f;
flex[2] = 0.5f;
}
if (aDirection == NS_STRETCH_DIRECTION_VERTICAL) {
// default is to fill-up the area given to us
nscoord lbearing = bmdata[0].leftBearing;
nscoord rbearing = bmdata[0].rightBearing;
nscoord h = 0;
nscoord w = bmdata[0].width;
for (i = 0; i < 4; i++) {
bm = bmdata[i];
if (w < bm.width) w = bm.width;
if (i < 3) {
h += nscoord(flex[i]*(bm.ascent + bm.descent)); // sum heights of the parts...
// compute and cache our bounding metrics (vertical stacking)
if (lbearing > bm.leftBearing) lbearing = bm.leftBearing;
if (rbearing < bm.rightBearing) rbearing = bm.rightBearing;
}
}
if (h <= aContainerSize.ascent + aContainerSize.descent) {
// can nicely fit in the available space...
bestbm.width = w;
bestbm.ascent = aContainerSize.ascent;
bestbm.descent = aContainerSize.descent;
bestbm.leftBearing = lbearing;
bestbm.rightBearing = rbearing;
// reset
bestGlyph = 0; // this will tell paint to build by parts
bestGlyphTable = glyphTable;
}
else {
// sum of parts doesn't fit in the space... we will use a single glyph
// we will use the best glyph encountered earlier
}
}
if (h <= aContainerSize.ascent + aContainerSize.descent) {
// can nicely fit in the available space...
bestbm.width = w;
bestbm.ascent = aContainerSize.ascent;
bestbm.descent = aContainerSize.descent;
bestbm.leftBearing = lbearing;
bestbm.rightBearing = rbearing;
// reset
bestGlyph = 0; // this will tell paint to build by parts
bestGlyphTable = glyphTable;
}
else {
// sum of parts doesn't fit in the space... will use a single glyph
// will use the best glyph encountered earlier
}
}
else if (aDirection == NS_STRETCH_DIRECTION_HORIZONTAL) {
// default is to fill-up the area given to us
nscoord a = bmdata[0].ascent;
nscoord d = bmdata[0].descent;
nscoord w = 0;
for (i = 0; i < 4; i++) {
bm = bmdata[i];
if (a < bm.ascent) a = bm.ascent;
if (d < bm.descent) d = bm.descent;
if (i < 3) {
w += nscoord(flex[i]*(bm.rightBearing - bm.leftBearing)); // sum widths of the parts...
else if (aDirection == NS_STRETCH_DIRECTION_HORIZONTAL) {
// default is to fill-up the area given to us
nscoord a = bmdata[0].ascent;
nscoord d = bmdata[0].descent;
nscoord w = 0;
for (i = 0; i < 4; i++) {
bm = bmdata[i];
if (a < bm.ascent) a = bm.ascent;
if (d < bm.descent) d = bm.descent;
if (i < 3) {
w += nscoord(flex[i]*(bm.rightBearing - bm.leftBearing)); // sum widths of the parts...
}
}
if (w <= aContainerSize.width) {
// can nicely fit in the available space...
bestbm.width = aContainerSize.width;
bestbm.ascent = a;
bestbm.descent = d;
bestbm.leftBearing = 0;
bestbm.rightBearing = aContainerSize.width;
// reset
bestGlyph = 0; // this will tell paint to build by parts
bestGlyphTable = glyphTable;
}
else {
// sum of parts doesn't fit in the space... we will use a single glyph
// we will use the best glyph encountered earlier
}
}
if (w <= aContainerSize.width) {
// can nicely fit in the available space...
bestbm.width = aContainerSize.width;
bestbm.ascent = a;
bestbm.descent = d;
bestbm.leftBearing = 0;
bestbm.rightBearing = aContainerSize.width;
// reset
bestGlyph = 0; // this will tell paint to build by parts
bestGlyphTable = glyphTable;
}
else {
// sum of parts doesn't fit in the space... will use a single glyph
// will use the best glyph encountered earlier
}
}
}

Просмотреть файл

@ -391,8 +391,8 @@ nsMathMLContainerFrame::ParseNamedSpaceValue(nsIFrame* aMathMLmstyleFrame,
}
else if (aString.EqualsWithConversion("verythinmathspace"))
{
i = 2;
namedspaceAtom = nsMathMLAtoms::verythinmathspace_;
i = 2;
namedspaceAtom = nsMathMLAtoms::verythinmathspace_;
}
else if (aString.EqualsWithConversion("thinmathspace"))
{
@ -401,23 +401,23 @@ nsMathMLContainerFrame::ParseNamedSpaceValue(nsIFrame* aMathMLmstyleFrame,
}
else if (aString.EqualsWithConversion("mediummathspace"))
{
i = 4;
namedspaceAtom = nsMathMLAtoms::mediummathspace_;
i = 4;
namedspaceAtom = nsMathMLAtoms::mediummathspace_;
}
else if (aString.EqualsWithConversion("thickmathspace"))
{
i = 5;
namedspaceAtom = nsMathMLAtoms::thickmathspace_;
i = 5;
namedspaceAtom = nsMathMLAtoms::thickmathspace_;
}
else if (aString.EqualsWithConversion("verythickmathspace"))
{
i = 6;
namedspaceAtom = nsMathMLAtoms::verythickmathspace_;
i = 6;
namedspaceAtom = nsMathMLAtoms::verythickmathspace_;
}
else if (aString.EqualsWithConversion("veryverythickmathspace"))
{
i = 7;
namedspaceAtom = nsMathMLAtoms::veryverythickmathspace_;
i = 7;
namedspaceAtom = nsMathMLAtoms::veryverythickmathspace_;
}
if (0 != i)
@ -911,10 +911,11 @@ nsMathMLContainerFrame::UpdatePresentationData(PRInt32 aScriptLevelIncrement,
mPresentationData.flags |= NS_MATHML_DISPLAYSTYLE;
else
mPresentationData.flags &= ~NS_MATHML_DISPLAYSTYLE;
if (aCompressed)
if (aCompressed) {
// 'compressed' means 'prime' style in App. G, TeXbook
// (the flag retains its value once it is set)
mPresentationData.flags |= NS_MATHML_COMPRESSED;
else
mPresentationData.flags &= ~NS_MATHML_COMPRESSED;
}
return NS_OK;
}
@ -1124,7 +1125,8 @@ nsMathMLContainerFrame::InsertScriptLevelStyleContext(nsIPresContext* aPresConte
// look ahead for the next smallest font size that will be in the subtree
smallestFontIndex = nsStyleUtil::FindNextSmallerFontSize(smallestFontSize, (PRInt32)defaultFont.size, scaleFactor, aPresContext);
smallestFontSize = nsStyleUtil::CalcFontPointSize(smallestFontIndex, (PRInt32)defaultFont.size, scaleFactor, aPresContext);
//printf("About to move to fontsize:%dpt(%dtwips)\n",
//((nsFrame*)childFrame)->ListTag(stdout);
//printf(" About to move to fontsize:%dpt(%dtwips)\n",
//NSTwipsToFloorIntPoints(smallestFontSize), smallestFontSize);
if (smallestFontSize < scriptminsize) {
// don't bother doing any work
@ -1252,7 +1254,7 @@ nsMathMLContainerFrame::Init(nsIPresContext* aPresContext,
// its scriptlevel and displaystyle. If the parent later wishes to increment
// with other values, it will do so in its SetInitialChildList() method.
mPresentationData.flags = NS_MATHML_DISPLAYSTYLE;
mPresentationData.flags = 0;
mPresentationData.scriptLevel = 0;
mPresentationData.mstyle = nsnull;
@ -1272,6 +1274,16 @@ nsMathMLContainerFrame::Init(nsIPresContext* aPresContext,
else
mPresentationData.flags &= ~NS_MATHML_DISPLAYSTYLE;
}
else {
// see if our parent has 'display: block'
// XXX should we restrict this to the top level <math> parent ?
const nsStyleDisplay* display;
aParent->GetStyleData(eStyleStruct_Display, (const nsStyleStruct*&)display);
if (display->mDisplay == NS_STYLE_DISPLAY_BLOCK) {
mPresentationData.flags |= NS_MATHML_DISPLAYSTYLE;
}
}
return rv;
}

Просмотреть файл

@ -203,9 +203,7 @@ nsMathMLmfracFrame::UpdatePresentationDataFromChildAt(PRInt32 aIndex,
PRBool aDisplayStyle,
PRBool aCompressed)
{
PRBool displayStyle = NS_MATHML_IS_DISPLAYSTYLE(mPresentationData.flags);
PRBool compressed = NS_MATHML_IS_COMPRESSED(mPresentationData.flags);
PRBool compressed;
nsIFrame* childFrame = mFrames.FirstChild();
while (nsnull != childFrame) {
if (!IsOnlyWhitespace(childFrame)) {
@ -214,33 +212,19 @@ nsMathMLmfracFrame::UpdatePresentationDataFromChildAt(PRInt32 aIndex,
(NS_GET_IID(nsIMathMLFrame), (void**)&aMathMLFrame);
if (NS_SUCCEEDED(rv) && nsnull != aMathMLFrame) {
if (0 == aIndex++) {
// update numerator
if (displayStyle) {
// switch to text with current compression
aMathMLFrame->UpdatePresentationData(0, PR_FALSE, compressed);
}
else {
// apply the default rule
aMathMLFrame->UpdatePresentationData
(aScriptLevelIncrement, aDisplayStyle, aCompressed);
}
// numerator uses default compression
compressed = aCompressed;
}
else {
// update denominator
if (displayStyle) {
// switch to text with compression
aMathMLFrame->UpdatePresentationData(0, PR_FALSE, PR_TRUE);
}
else {
// apply the default rule
aMathMLFrame->UpdatePresentationData
(aScriptLevelIncrement, aDisplayStyle, aCompressed);
}
// denominator is 'compressed' (means 'prime' style in App. G, TeXbook)
compressed = PR_TRUE;
}
// update
aMathMLFrame->UpdatePresentationData
(aScriptLevelIncrement, aDisplayStyle, compressed);
// propagate down the subtrees
aMathMLFrame->UpdatePresentationDataFromChildAt
(0, aScriptLevelIncrement, aDisplayStyle, aCompressed);
(0, aScriptLevelIncrement, aDisplayStyle, compressed);
}
}
childFrame->GetNextSibling(&childFrame);
@ -355,7 +339,6 @@ nsMathMLmfracFrame::Place(nsIPresContext* aPresContext,
}
else {
// Rule 15d, App. G, TeXbook
// GetAxisHeight (fm, axisHeight);
GetAxisHeight(aRenderingContext, fm, axisHeight);
// min clearance between numerator or denominator and middle of bar

Просмотреть файл

@ -110,7 +110,7 @@ public:
{
nsresult rv;
rv = nsMathMLContainerFrame::SetInitialChildList(aPresContext, aListName, aChildList);
UpdatePresentationDataFromChildAt(0, 1, PR_FALSE, PR_TRUE);
UpdatePresentationDataFromChildAt(0, 1, PR_FALSE, PR_FALSE);
InsertScriptLevelStyleContext(aPresContext);
return rv;
}