[not part of default build] Removed the static ctors and the hard-coding of the mutable characters. These characters and their attributes are now described in external extensible sets of MathFont property files

This commit is contained in:
rbs%maths.uq.edu.au 2001-02-02 09:40:53 +00:00
Родитель e9d5a79b4c
Коммит 24f525c998
3 изменённых файлов: 1410 добавлений и 1019 удалений

Разница между файлами не показана из-за своего большого размера Загрузить разницу

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

@ -29,34 +29,32 @@
typedef PRUnichar nsGlyphCode;
class nsGlyphTable;
// List of enums of all known chars
enum nsMathMLCharEnum {
eMathMLChar_DONT_STRETCH = -1,
#define WANT_CHAR_ENUM
#include "nsMathMLCharList.h"
#undef WANT_CHAR_ENUM
eMathMLChar_COUNT
};
// Hints for Stretch() to indicate criteria for stretching
#define NS_STRETCH_SMALLER -1 // don't stretch more than requested size
#define NS_STRETCH_NORMAL 0 // try to stretch to requested size - DEFAULT
#define NS_STRETCH_LARGER 1 // try to stretch more than requested size
#define NS_STRETCH_NORMAL 0x00000001 // try to stretch to requested size - DEFAULT
#define NS_STRETCH_NEARER 0x00000002 // stretch very close to requested size
#define NS_STRETCH_SMALLER 0x00000004 // don't stretch more than requested size
#define NS_STRETCH_LARGER 0x00000008 // don't stretch less than requested size
#define NS_STRETCH_LARGEOP 0x00000010 // for a largeop in displaystyle
// class used to handle stretchy symbols (accent, delimiter and boundary symbols)
class nsMathMLChar
{
public:
// constructor and destructor
nsMathMLChar()
{
nsMathMLChar(nsMathMLChar* aParent = nsnull) {
MOZ_COUNT_CTOR(nsMathMLChar);
mStyleContext = nsnull;
mSibling = nsnull;
mParent = aParent;
}
~nsMathMLChar() // not a virtual destructor: this class is not intended to be subclassed
{
~nsMathMLChar() { // not a virtual destructor: this class is not intended to be subclassed
MOZ_COUNT_DTOR(nsMathMLChar);
if (mSibling) {
delete mSibling;
}
}
nsresult
Paint(nsIPresContext* aPresContext,
nsIRenderingContext& aRenderingContext,
@ -65,21 +63,16 @@ public:
nsIFrame* aForFrame);
// This is the method called to ask the char to stretch itself.
// aDesiredStretchSize is an IN/OUT parameter.
// On input - it contains our current size, or zero if current size is unknown
// On output - the same size or the new size that the char wants.
// @param aContainerSize - IN - suggested size for the stretched char
// @param aDesiredStretchSize - OUT - the size that the char wants
nsresult
Stretch(nsIPresContext* aPresContext,
nsIRenderingContext& aRenderingContext,
nsStretchDirection aStretchDirection,
nsBoundingMetrics& aContainerSize,
nsBoundingMetrics& aDesiredStretchSize,
PRInt32 aStretchHint = NS_STRETCH_NORMAL);
PRUint32 aStretchHint = NS_STRETCH_NORMAL);
// If you call SetData(), it will lookup the enum of the data
// and set mEnum for you. If the data is an arbitrary string for
// which no enum is defined, mEnum is set to eMathMLChar_DONT_STRETCH
// and the data is interpreted as a normal string.
void
SetData(nsIPresContext* aPresContext,
nsString& aData);
@ -89,17 +82,6 @@ public:
aData = mData;
}
// If you call SetEnum(), it will lookup the actual value of the data and
// set it for you. All the enums listed above have their corresponding data.
void
SetEnum(nsIPresContext* aPresContext,
nsMathMLCharEnum aEnum);
nsMathMLCharEnum
GetEnum() {
return mEnum;
}
PRInt32
Length() {
return mData.Length();
@ -125,9 +107,18 @@ public:
void
SetRect(const nsRect& aRect) {
mRect = aRect;
// shift the orgins of child chars if any
if (!mParent && mSibling) { // only a "root" having child chars can enter here
for (nsMathMLChar* child = mSibling; child; child = child->mSibling) {
nsRect rect;
child->GetRect(rect);
rect.MoveBy(mRect.x, mRect.y);
child->SetRect(rect);
}
}
}
// Metrics that _exactly_ enclose the char. The char *must* have *already*
// Metrics that _exactly_ enclose the char. The char *must* have *already*
// being stretched before you can call the GetBoundingMetrics() method.
// IMPORTANT: since chars have their own style contexts, and may be rendered
// with glyphs that are not in the parent font, just calling the default
@ -147,24 +138,38 @@ public:
nsresult
SetStyleContext(nsIStyleContext* aStyleContext);
private:
protected:
friend class nsGlyphTable;
nsString mData;
nsMathMLCharEnum mEnum;
nsStretchDirection mDirection;
// support for handling composite stretchy chars like TeX over/under braces
nsMathMLChar* mSibling;
nsMathMLChar* mParent;
private:
nsRect mRect;
nsStretchDirection mDirection;
nsBoundingMetrics mBoundingMetrics;
nsIStyleContext* mStyleContext;
nsGlyphTable* mGlyphTable;
nsGlyphCode mGlyph;
// helper methods
nsresult
ComposeChildren(nsIPresContext* aPresContext,
nsIRenderingContext& aRenderingContext,
nsGlyphTable* aGlyphTable,
nsBoundingMetrics& aContainerSize,
nsBoundingMetrics& aCompositeSize,
PRUint32 aStretchHint);
static nsresult
PaintVertically(nsIPresContext* aPresContext,
nsIRenderingContext& aRenderingContext,
nscoord aFontAscent,
nsIStyleContext* aStyleContext,
nsGlyphTable* aGlyphTable,
nsMathMLCharEnum aCharEnum,
nsMathMLChar* aChar,
nsRect aRect);
static nsresult
@ -173,7 +178,7 @@ private:
nscoord aFontAscent,
nsIStyleContext* aStyleContext,
nsGlyphTable* aGlyphTable,
nsMathMLCharEnum aCharEnum,
nsMathMLChar* aChar,
nsRect aRect);
};

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

@ -153,7 +153,7 @@ nsMathMLmoFrame::Init(nsIPresContext* aPresContext,
{
// Let the base class do its Init()
nsresult rv = nsMathMLContainerFrame::Init(aPresContext, aContent, aParent, aContext, aPrevInFlow);
// Init our local attributes
mFlags = 0;
mLeftSpace = 0.0f; // .27777f;
@ -339,7 +339,7 @@ nsMathMLmoFrame::InitData(nsIPresContext* aPresContext)
aMathMLFrame->GetEmbellishData(embellishData);
}
else {
embellishData.core = nsnull;
embellishData.core = nsnull;
}
} while (embellishData.core == this);
// flag if we have an embellished ancestor
@ -388,28 +388,9 @@ nsMathMLmoFrame::InitData(nsIPresContext* aPresContext)
// Lookup the operator dictionary
nsAutoString aData;
mMathMLChar.GetData(aData);
mMathMLChar.SetData(aPresContext, aData); // XXX hack to reset the enum, bug 45010
mMathMLChar.SetData(aPresContext, aData); // XXX hack to reset, bug 45010
PRBool found = nsMathMLOperators::LookupOperator(aData, aForm,
&mFlags, &mLeftSpace, &mRightSpace);
// All operators are symmetric. But this symmetric flag is *not* stored in
// the Operator Dictionary ... Add it now
mFlags |= NS_MATHML_OPERATOR_SYMMETRIC;
#if 0
// If the operator exists in the dictionary and is stretchy or largeop,
// then it is mutable
if (found &&
(NS_MATHML_OPERATOR_IS_STRETCHY(mFlags) ||
NS_MATHML_OPERATOR_IS_LARGEOP(mFlags)))
{
mFlags |= NS_MATHML_OPERATOR_MUTABLE;
}
// Set the flag if the operator has an embellished ancestor
if (hasEmbellishAncestor) {
mFlags |= NS_MATHML_OPERATOR_EMBELLISH_ANCESTOR;
}
#endif
// If we don't want too much extra space when we are a script
if ((0 < mPresentationData.scriptLevel) &&
@ -422,9 +403,8 @@ nsMathMLmoFrame::InitData(nsIPresContext* aPresContext)
// XXX If an attribute can be forced to be true when it is false in the
// dictionary, then the following code has to change...
// For each attribute disabled by the user, turn off its bit flag.
// movablelimits|separator|largeop|accent|fence|stretchy|form
// For each attribute overriden by the user, turn off its bit flag.
// symmetric|movablelimits|separator|largeop|accent|fence|stretchy|form
nsAutoString kfalse, ktrue;
kfalse.AssignWithConversion("false");
ktrue.AssignWithConversion("true");
@ -458,7 +438,6 @@ nsMathMLmoFrame::InitData(nsIPresContext* aPresContext)
nsMathMLAtoms::movablelimits_, value) && value == kfalse)
mFlags &= ~NS_MATHML_OPERATOR_MOVABLELIMITS;
}
if (NS_CONTENT_ATTR_HAS_VALUE == GetAttribute(mContent, mPresentationData.mstyle,
nsMathMLAtoms::symmetric_, value)) {
if (value == kfalse) mFlags &= ~NS_MATHML_OPERATOR_SYMMETRIC;
@ -620,15 +599,13 @@ nsMathMLmoFrame::Stretch(nsIPresContext* aPresContext,
nsBoundingMetrics container = initialSize;
PRBool isVertical = PR_FALSE;
PRInt32 stretchHint = NS_STRETCH_NORMAL;
PRUint32 stretchHint = NS_STRETCH_NORMAL;
// see if it is okay to stretch
if (NS_MATHML_OPERATOR_IS_MUTABLE(mFlags)) {
container = aContainerSize;
// some adjustments if the operator is symmetric and vertical
if (((aStretchDirection == NS_STRETCH_DIRECTION_VERTICAL) ||
(aStretchDirection == NS_STRETCH_DIRECTION_DEFAULT)) &&
(mMathMLChar.GetStretchDirection() == NS_STRETCH_DIRECTION_VERTICAL))
@ -636,6 +613,23 @@ nsMathMLmoFrame::Stretch(nsIPresContext* aPresContext,
isVertical = PR_TRUE;
}
// see if we are in display mode, and set largeop or largeopOnly
// . largeopOnly is taken if largeop=true and stretchy=false
// . largeop is taken if largeop=true and stretchy=true
if (NS_MATHML_IS_DISPLAYSTYLE(mPresentationData.flags) &&
NS_MATHML_OPERATOR_IS_LARGEOP(mFlags)) {
stretchHint = NS_STRETCH_LARGEOP; // (largeopOnly, not mask!)
if (NS_MATHML_OPERATOR_IS_STRETCHY(mFlags)) {
stretchHint |= NS_STRETCH_NEARER | NS_STRETCH_LARGER;
}
}
else if (isVertical) {
// TeX hint. Can impact some sloppy markups missing <mrow></mrow>
stretchHint = NS_STRETCH_NEARER;
}
// some adjustments if the operator is symmetric and vertical
if (isVertical && NS_MATHML_OPERATOR_IS_SYMMETRIC(mFlags))
{
// we need to center about the axis
@ -662,7 +656,7 @@ nsMathMLmoFrame::Stretch(nsIPresContext* aPresContext,
container.ascent =
PR_MIN(container.ascent, nscoord(initialSize.ascent * aspect));
container.descent =
PR_MIN(container.descent, nscoord(initialSize.descent * aspect));
PR_MIN(container.descent, nscoord(initialSize.descent * aspect));
// below we use a type cast instead of a conversion to avoid a VC++ bug
// see http://support.microsoft.com/support/kb/articles/Q115/7/05.ASP
container.width =
@ -681,7 +675,7 @@ nsMathMLmoFrame::Stretch(nsIPresContext* aPresContext,
{
// re-adjust to align the char with the bottom of the initial container
height = container.ascent + container.descent;
container.descent = aContainerSize.descent;
container.descent = aContainerSize.descent;
container.ascent = height - container.descent;
}
}
@ -712,31 +706,30 @@ nsMathMLmoFrame::Stretch(nsIPresContext* aPresContext,
{
// re-adjust to align the char with the bottom of the initial container
height = container.ascent + container.descent;
container.descent = aContainerSize.descent;
container.descent = aContainerSize.descent;
container.ascent = height - container.descent;
}
}
}
// let the MathMLChar stretch itself...
charSize.Clear(); // this will tell stretch that we don't know the default size
nsresult res = mMathMLChar.Stretch(aPresContext, aRenderingContext,
aStretchDirection, container, charSize, stretchHint);
if (NS_FAILED(res)) {
// gracefully handle cases where stretching the char failed (i.e., GetBoundingMetrics failed)
// gracefully handle cases where stretching the char failed (i.e., GetBoundingMetrics failed)
// clear our 'form' to behave as if the operator wasn't in the dictionary
mFlags &= ~0x3;
mFlags &= ~NS_MATHML_OPERATOR_FORM;
}
else {
// update our bounding metrics... it becomes that of our MathML char
mMathMLChar.GetBoundingMetrics(mBoundingMetrics);
if (isVertical)
{
// the desired size returned by mMathMLChar maybe different
// from the size of the container.
// the mMathMLChar.mRect.y calculation is subtle, watch out!!!
height = mBoundingMetrics.ascent + mBoundingMetrics.descent;
if (NS_MATHML_OPERATOR_IS_SYMMETRIC(mFlags)) {
// For symmetric and vertical operators,
@ -749,26 +742,26 @@ nsMathMLmoFrame::Stretch(nsIPresContext* aPresContext,
}
mBoundingMetrics.ascent = height - mBoundingMetrics.descent;
}
// Prepare the metrics to return
aDesiredStretchSize.ascent = PR_MAX(fontAscent, mBoundingMetrics.ascent); /* + delta1*/
aDesiredStretchSize.descent = PR_MAX(fontDescent, mBoundingMetrics.descent); /* + delta2*/
aDesiredStretchSize.width = mBoundingMetrics.width;
aDesiredStretchSize.height = aDesiredStretchSize.ascent + aDesiredStretchSize.descent;
aDesiredStretchSize.mBoundingMetrics = mBoundingMetrics;
nscoord dy = aDesiredStretchSize.ascent - mBoundingMetrics.ascent;
if (mMathMLChar.GetEnum() == eMathMLChar_DONT_STRETCH)
if (mMathMLChar.GetStretchDirection() == NS_STRETCH_DIRECTION_UNSUPPORTED)
{
// reset
dy = aDesiredStretchSize.ascent - charSize.ascent;
aDesiredStretchSize.mBoundingMetrics = mBoundingMetrics = charSize;
}
mMathMLChar.SetRect(
nsRect(0, dy, charSize.width,
charSize.ascent + charSize.descent));
mReference.x = 0;
mReference.y = aDesiredStretchSize.ascent;
}