nsString fixes for mathml.

This commit is contained in:
cls%seawood.org 2000-04-28 08:55:55 +00:00
parent a8dbb57e7f
commit 67438c614e
14 changed files with 66 additions and 58 deletions

View File

@ -630,7 +630,7 @@ nsMathMLChar::SetEnum(nsIPresContext* aPresContext,
mEnum = aEnum;
// some assumptions until proven otherwise!
// note that mGlyph is not initialized
mData = "";
mData = nsAutoString();
mDirection = NS_STRETCH_DIRECTION_UNSUPPORTED;
mBoundingMetrics.Clear();
mGlyphTable = nsnull;
@ -742,7 +742,7 @@ static void SetFirstFamily(nsFont& aFont, const nsString& aFamily)
nsAutoString familyList(aFamily);
// XXX hack to force CMSY10 to be at least the second best choice !
if (!aFamily.EqualsIgnoreCase("CMSY10"))
familyList.Append(",CMSY10");
familyList.AppendWithConversion(",CMSY10");
// loop over font-family: (skipping aFamily if present)
aFont.EnumerateFamilies(FontEnumCallback, &familyList);
// overwrite the old value of font-family:

View File

@ -293,19 +293,19 @@ printf("String:%s, Number:%s, Unit:%s\n", s1, s2, s3);
if (0 == unit.Length()) {
cssUnit = eCSSUnit_Number; // no explicit unit, this is a number that will act as a multiplier
}
else if (unit.Equals("%")) {
else if (unit.Equals(NS_ConvertASCIItoUCS2("%"))) {
floatValue = floatValue / 100.0f;
aCSSValue.SetPercentValue(floatValue);
return PR_TRUE;
}
else if (unit.Equals("em")) cssUnit = eCSSUnit_EM;
else if (unit.Equals("ex")) cssUnit = eCSSUnit_XHeight;
else if (unit.Equals("px")) cssUnit = eCSSUnit_Pixel;
else if (unit.Equals("in")) cssUnit = eCSSUnit_Inch;
else if (unit.Equals("cm")) cssUnit = eCSSUnit_Centimeter;
else if (unit.Equals("mm")) cssUnit = eCSSUnit_Millimeter;
else if (unit.Equals("pt")) cssUnit = eCSSUnit_Point;
else if (unit.Equals("pc")) cssUnit = eCSSUnit_Pica;
else if (unit.Equals(NS_ConvertASCIItoUCS2("em"))) cssUnit = eCSSUnit_EM;
else if (unit.Equals(NS_ConvertASCIItoUCS2("ex"))) cssUnit = eCSSUnit_XHeight;
else if (unit.Equals(NS_ConvertASCIItoUCS2("px"))) cssUnit = eCSSUnit_Pixel;
else if (unit.Equals(NS_ConvertASCIItoUCS2("in"))) cssUnit = eCSSUnit_Inch;
else if (unit.Equals(NS_ConvertASCIItoUCS2("cm"))) cssUnit = eCSSUnit_Centimeter;
else if (unit.Equals(NS_ConvertASCIItoUCS2("mm"))) cssUnit = eCSSUnit_Millimeter;
else if (unit.Equals(NS_ConvertASCIItoUCS2("pt"))) cssUnit = eCSSUnit_Point;
else if (unit.Equals(NS_ConvertASCIItoUCS2("pc"))) cssUnit = eCSSUnit_Pica;
else // unexpected unit
return PR_FALSE;
@ -883,8 +883,9 @@ nsMathMLContainerFrame::ResolveMathMLCharStyle(nsIPresContext* aPresContext,
nsAutoString data;
aMathMLChar->GetData(data);
PRBool isStretchy = nsMathMLOperators::MatchOperator(data, NS_MATHML_OPERATOR_STRETCHY);
nsAutoString fontStyle = (isStretchy) ? ":-moz-math-font-style-stretchy"
: ":-moz-math-font-style-anonymous";
nsAutoString fontStyle = (isStretchy) ?
NS_ConvertASCIItoUCS2(":-moz-math-font-style-stretchy") :
NS_ConvertASCIItoUCS2(":-moz-math-font-style-anonymous");
nsCOMPtr<nsIAtom> fontAtom(getter_AddRefs(NS_NewAtom(fontStyle)));
nsCOMPtr<nsIStyleContext> newStyleContext;
nsresult rv = aPresContext->ResolvePseudoStyleContextFor(aContent, fontAtom,
@ -1008,8 +1009,8 @@ nsMathMLContainerFrame::InsertScriptLevelStyleContext(nsIPresContext* aPresConte
// XXX seems not to decrease when the initail font-size is large (100pt)
nsAutoString fontSize = (0 < gap)
? ":-moz-math-font-size-smaller"
: ":-moz-math-font-size-larger";
? NS_ConvertASCIItoUCS2(":-moz-math-font-size-smaller")
: NS_ConvertASCIItoUCS2(":-moz-math-font-size-larger");
nsCOMPtr<nsIAtom> fontAtom(getter_AddRefs(NS_NewAtom(fontSize)));
PRBool isSmaller = PR_TRUE;

View File

@ -123,25 +123,28 @@ nsMathMLmactionFrame::Init(nsIPresContext* aPresContext,
mActionType = NS_MATHML_ACTION_TYPE_NONE;
if (NS_CONTENT_ATTR_HAS_VALUE == aContent->GetAttribute(kNameSpaceID_None,
nsMathMLAtoms::actiontype_, value)) {
if (value == "toggle")
if (value.EqualsWithConversion("toggle"))
mActionType = NS_MATHML_ACTION_TYPE_TOGGLE;
// XXX use goto to jump out of these if?
if (NS_MATHML_ACTION_TYPE_NONE == mActionType) {
prefix = "tooltip#"; // expected tooltip prefix (8ch)...
// expected tooltip prefix (8ch)...
prefix.AssignWithConversion("tooltip#");
if (8 < value.Length() && 0 == value.Find(prefix))
mActionType = NS_MATHML_ACTION_TYPE_TOOLTIP;
}
if (NS_MATHML_ACTION_TYPE_NONE == mActionType) {
prefix = "statusline#"; // expected statusline prefix (11ch)...
// expected statusline prefix (11ch)...
prefix.AssignWithConversion("statusline#");
if (11 < value.Length() && 0 == value.Find(prefix))
mActionType = NS_MATHML_ACTION_TYPE_STATUSLINE;
}
if (NS_MATHML_ACTION_TYPE_NONE == mActionType) {
prefix = "restyle#"; // expected restyle prefix (8ch)...
// expected restyle prefix (8ch)...
prefix.AssignWithConversion("restyle#");
if (8 < value.Length() && 0 == value.Find(prefix)) {
mActionType = NS_MATHML_ACTION_TYPE_RESTYLE;
mRestyle = value;
@ -151,7 +154,7 @@ nsMathMLmactionFrame::Init(nsIPresContext* aPresContext,
// given us the associated style. But we want to start with our default style.
// So... first, remove the attribute actiontype="restyle#id"
value = "";
value.SetLength(0);
PRBool notify = PR_FALSE; // don't trigger a reflow yet!
aContent->SetAttribute(kNameSpaceID_None, nsMathMLAtoms::actiontype_, value, notify);
@ -380,7 +383,9 @@ nsMathMLmactionFrame::MouseOver(nsIDOMEvent* aMouseEvent)
if (NS_CONTENT_ATTR_HAS_VALUE == mContent->GetAttribute(kNameSpaceID_None,
nsMathMLAtoms::actiontype_, value))
{
nsAutoString statusline = "statusline#"; // expected statusline prefix (11ch)...
// expected statusline prefix (11ch)...
nsAutoString statusline;
statusline.AssignWithConversion("statusline#");
if (11 < value.Length() && 0 == value.Find(statusline)) {
value.Cut(0, 11);
ShowStatus(mPresContext, value);
@ -396,7 +401,8 @@ nsMathMLmactionFrame::MouseOut(nsIDOMEvent* aMouseEvent)
// see if we should remove the status message
if (NS_MATHML_ACTION_TYPE_STATUSLINE == mActionType)
{
nsAutoString value = "";
nsAutoString value;
value.SetLength(0);
ShowStatus(mPresContext, value);
}
return NS_OK;
@ -412,7 +418,7 @@ nsMathMLmactionFrame::MouseClick(nsIDOMEvent* aMouseEvent)
PRInt32 selection = (mSelection == mChildCount)? 1 : mSelection + 1;
char cbuf[10];
PR_snprintf(cbuf, sizeof(cbuf), "%d", selection);
value = cbuf;
value.AssignWithConversion(cbuf);
PRBool notify = PR_FALSE; // don't yet notify the document
mContent->SetAttribute(kNameSpaceID_None, nsMathMLAtoms::selection_, value, notify);
@ -427,9 +433,9 @@ nsMathMLmactionFrame::MouseClick(nsIDOMEvent* aMouseEvent)
if (node.get()) {
if (NS_CONTENT_ATTR_HAS_VALUE == mContent->GetAttribute(kNameSpaceID_None,
nsMathMLAtoms::actiontype_, value))
node->RemoveAttribute("actiontype");
node->RemoveAttribute(NS_ConvertASCIItoUCS2("actiontype"));
else
node->SetAttribute("actiontype", mRestyle);
node->SetAttribute(NS_ConvertASCIItoUCS2("actiontype"), mRestyle);
}
}
}

View File

@ -140,7 +140,7 @@ nsMathMLmfencedFrame::ReCreateFencesAndSeparators(nsIPresContext* aPresContext)
else if (NS_CONTENT_ATTR_NOT_THERE == rv)
data = '('; // default as per the MathML REC
else
data = "";
data = nsAutoString();
if (0 < data.Length()) {
mOpenChar = new nsMathMLChar;
@ -160,7 +160,7 @@ nsMathMLmfencedFrame::ReCreateFencesAndSeparators(nsIPresContext* aPresContext)
else if (NS_CONTENT_ATTR_NOT_THERE == rv)
data = ')'; // default as per the MathML REC
else
data = "";
data = nsAutoString();
if (0 < data.Length()) {
mCloseChar = new nsMathMLChar;
@ -180,7 +180,7 @@ nsMathMLmfencedFrame::ReCreateFencesAndSeparators(nsIPresContext* aPresContext)
else if (NS_CONTENT_ATTR_NOT_THERE == rv)
data = ','; // default as per the MathML REC
else
data = "";
data = nsAutoString();
mSeparatorsCount = data.Length();
if (0 < mSeparatorsCount) {

View File

@ -111,21 +111,21 @@ nsMathMLmfracFrame::CalcLineThickness(nsIPresContext* aPresContext,
nscoord minimumThickness = onePixel;
if (0 < aThicknessAttribute.Length()) {
if (aThicknessAttribute.Equals("thin")) {
if (aThicknessAttribute.EqualsWithConversion("thin")) {
lineThickness = NSToCoordFloor(defaultThickness * THIN_FRACTION_LINE);
minimumThickness = onePixel * THIN_FRACTION_LINE_MINIMUM_PIXELS;
// should visually decrease by at least one pixel, if default is not a pixel
if (defaultThickness > onePixel && lineThickness > defaultThickness - onePixel)
lineThickness = defaultThickness - onePixel;
}
else if (aThicknessAttribute.Equals("medium")) {
else if (aThicknessAttribute.EqualsWithConversion("medium")) {
lineThickness = NSToCoordRound(defaultThickness * MEDIUM_FRACTION_LINE);
minimumThickness = onePixel * MEDIUM_FRACTION_LINE_MINIMUM_PIXELS;
// should visually increase by at least one pixel
if (lineThickness < defaultThickness + onePixel)
lineThickness = defaultThickness + onePixel;
}
else if (aThicknessAttribute.Equals("thick")) {
else if (aThicknessAttribute.EqualsWithConversion("thick")) {
lineThickness = NSToCoordCeil(defaultThickness * THICK_FRACTION_LINE);
minimumThickness = onePixel * THICK_FRACTION_LINE_MINIMUM_PIXELS;
// should visually increase by at least two pixels

View File

@ -131,13 +131,13 @@ nsMathMLmiFrame::SetInitialChildList(nsIPresContext* aPresContext,
if (NS_CONTENT_ATTR_HAS_VALUE == mstyleContent->GetAttribute(kNameSpaceID_None,
nsMathMLAtoms::fontstyle_, fontStyle))
{
if (fontStyle.Equals("italic"))
if (fontStyle.EqualsWithConversion("italic"))
return rv;
}
}
// Get a pseudo style context for the appropriate style font
fontStyle.Assign(":-moz-math-font-style-normal");
fontStyle.AssignWithConversion(":-moz-math-font-style-normal");
nsCOMPtr<nsIAtom> fontAtom(getter_AddRefs(NS_NewAtom(fontStyle)));
nsCOMPtr<nsIStyleContext> newStyleContext;
aPresContext->ResolvePseudoStyleContextFor(mContent, fontAtom, mStyleContext,

View File

@ -233,7 +233,7 @@ nsMathMLmoFrame::SetInitialChildList(nsIPresContext* aPresContext,
nsMathMLAtoms::accent_, value))
{
accentAttribute = PR_TRUE;
if (value.Equals("true"))
if (value.EqualsWithConversion("true"))
{
mEmbellishData.flags |= NS_MATHML_EMBELLISH_ACCENT;
}
@ -244,7 +244,7 @@ nsMathMLmoFrame::SetInitialChildList(nsIPresContext* aPresContext,
nsMathMLAtoms::movablelimits_, value))
{
movablelimitsAttribute = PR_TRUE;
if (value.Equals("true"))
if (value.EqualsWithConversion("true"))
{
mEmbellishData.flags |= NS_MATHML_EMBELLISH_MOVABLELIMITS;
}
@ -301,9 +301,9 @@ nsMathMLmoFrame::InitData(nsIPresContext* aPresContext)
PRBool hasEmbellishAncestor = PR_FALSE;
if (NS_CONTENT_ATTR_HAS_VALUE == GetAttribute(mContent, mPresentationData.mstyle,
nsMathMLAtoms::form_, value)) {
if (value == "prefix")
if (value.EqualsWithConversion("prefix"))
aForm = NS_MATHML_OPERATOR_FORM_PREFIX;
else if (value == "postfix")
else if (value.EqualsWithConversion("postfix"))
aForm = NS_MATHML_OPERATOR_FORM_POSTFIX;
// flag if we have an embellished ancestor
@ -409,7 +409,9 @@ nsMathMLmoFrame::InitData(nsIPresContext* aPresContext)
// For each attribute disabled by the user, turn off its bit flag.
// movablelimits|separator|largeop|accent|fence|stretchy|form
nsAutoString kfalse("false"), ktrue("true");
nsAutoString kfalse, ktrue;
kfalse.AssignWithConversion("false");
ktrue.AssignWithConversion("true");
if (NS_MATHML_OPERATOR_IS_STRETCHY(mFlags)) {
if (NS_CONTENT_ATTR_HAS_VALUE == GetAttribute(mContent, mPresentationData.mstyle,
nsMathMLAtoms::stretchy_, value) && value == kfalse)

View File

@ -142,7 +142,7 @@ XXX The winner is the outermost in conflicting settings like these:
baseFrame->GetContent(getter_AddRefs(baseContent));
if (NS_CONTENT_ATTR_HAS_VALUE == baseContent->GetAttribute(kNameSpaceID_None,
nsMathMLAtoms::movablelimits_, value)) {
if (value == "true") {
if (value.EqualsWithConversion("true")) {
mPresentationData.flags |= NS_MATHML_MOVABLELIMITS;
}
}
@ -172,8 +172,8 @@ XXX The winner is the outermost in conflicting settings like these:
if (NS_CONTENT_ATTR_HAS_VALUE == mContent->GetAttribute(kNameSpaceID_None,
nsMathMLAtoms::accent_, value))
{
if (value == "true") embellishData.flags |= NS_MATHML_EMBELLISH_ACCENT;
else if (value == "false") embellishData.flags &= ~NS_MATHML_EMBELLISH_ACCENT;
if (value.EqualsWithConversion("true")) embellishData.flags |= NS_MATHML_EMBELLISH_ACCENT;
else if (value.EqualsWithConversion("false")) embellishData.flags &= ~NS_MATHML_EMBELLISH_ACCENT;
aMathMLFrame->SetEmbellishData(embellishData);
}

View File

@ -235,10 +235,10 @@ nsMathMLmpaddedFrame::ParseAttribute(nsString& aString,
}
aString.Right(value, stringLength - i);
if (value.Equals("width")) aPseudoUnit = NS_MATHML_PSEUDO_UNIT_WIDTH;
else if (value.Equals("height")) aPseudoUnit = NS_MATHML_PSEUDO_UNIT_HEIGHT;
else if (value.Equals("depth")) aPseudoUnit = NS_MATHML_PSEUDO_UNIT_DEPTH;
else if (value.Equals("lspace")) aPseudoUnit = NS_MATHML_PSEUDO_UNIT_LSPACE;
if (value.EqualsWithConversion("width")) aPseudoUnit = NS_MATHML_PSEUDO_UNIT_WIDTH;
else if (value.EqualsWithConversion("height")) aPseudoUnit = NS_MATHML_PSEUDO_UNIT_HEIGHT;
else if (value.EqualsWithConversion("depth")) aPseudoUnit = NS_MATHML_PSEUDO_UNIT_DEPTH;
else if (value.EqualsWithConversion("lspace")) aPseudoUnit = NS_MATHML_PSEUDO_UNIT_LSPACE;
else // unexpected pseudo-unit
{
aCSSValue.Reset();

View File

@ -86,11 +86,11 @@ nsMathMLmstyleFrame::Init(nsIPresContext* aPresContext,
nsAutoString value;
if (NS_CONTENT_ATTR_HAS_VALUE == mContent->GetAttribute(kNameSpaceID_None,
nsMathMLAtoms::displaystyle_, value)) {
if (value == "true") {
if (value.EqualsWithConversion("true")) {
mPresentationData.flags |= NS_MATHML_MSTYLE_WITH_DISPLAYSTYLE;
mPresentationData.flags |= NS_MATHML_DISPLAYSTYLE;
}
else if (value == "false") {
else if (value.EqualsWithConversion("false")) {
mPresentationData.flags |= NS_MATHML_MSTYLE_WITH_DISPLAYSTYLE;
mPresentationData.flags &= ~NS_MATHML_DISPLAYSTYLE;
}

View File

@ -141,7 +141,7 @@ XXX The winner is the outermost setting in conflicting settings like these:
baseFrame->GetContent(getter_AddRefs(baseContent));
if (NS_CONTENT_ATTR_HAS_VALUE == baseContent->GetAttribute(kNameSpaceID_None,
nsMathMLAtoms::movablelimits_, value)) {
if (value == "true") {
if (value.EqualsWithConversion("true")) {
mPresentationData.flags |= NS_MATHML_MOVABLELIMITS;
}
}
@ -171,8 +171,8 @@ XXX The winner is the outermost setting in conflicting settings like these:
if (NS_CONTENT_ATTR_HAS_VALUE == mContent->GetAttribute(kNameSpaceID_None,
nsMathMLAtoms::accentunder_, value))
{
if (value == "true") embellishData.flags |= NS_MATHML_EMBELLISH_ACCENT;
else if (value == "false") embellishData.flags &= ~NS_MATHML_EMBELLISH_ACCENT;
if (value.EqualsWithConversion("true")) embellishData.flags |= NS_MATHML_EMBELLISH_ACCENT;
else if (value.EqualsWithConversion("false")) embellishData.flags &= ~NS_MATHML_EMBELLISH_ACCENT;
aMathMLFrame->SetEmbellishData(embellishData);
}

View File

@ -138,7 +138,7 @@ nsMathMLmunderoverFrame::SetInitialChildList(nsIPresContext* aPresContext,
baseFrame->GetContent(getter_AddRefs(baseContent));
if (NS_CONTENT_ATTR_HAS_VALUE == baseContent->GetAttribute(kNameSpaceID_None,
nsMathMLAtoms::movablelimits_, value)) {
if (value.Equals("true")) {
if (value.EqualsWithConversion("true")) {
mPresentationData.flags |= NS_MATHML_MOVABLELIMITS;
}
}
@ -168,8 +168,8 @@ nsMathMLmunderoverFrame::SetInitialChildList(nsIPresContext* aPresContext,
if (NS_CONTENT_ATTR_HAS_VALUE == mContent->GetAttribute(kNameSpaceID_None,
nsMathMLAtoms::accentunder_, value))
{
if (value.Equals("true")) embellishData.flags |= NS_MATHML_EMBELLISH_ACCENT;
else if (value.Equals("false")) embellishData.flags &= ~NS_MATHML_EMBELLISH_ACCENT;
if (value.EqualsWithConversion("true")) embellishData.flags |= NS_MATHML_EMBELLISH_ACCENT;
else if (value.EqualsWithConversion("false")) embellishData.flags &= ~NS_MATHML_EMBELLISH_ACCENT;
aMathMLFrame->SetEmbellishData(embellishData);
}
@ -196,8 +196,8 @@ nsMathMLmunderoverFrame::SetInitialChildList(nsIPresContext* aPresContext,
if (NS_CONTENT_ATTR_HAS_VALUE == mContent->GetAttribute(kNameSpaceID_None,
nsMathMLAtoms::accent_, value))
{
if (value.Equals("true")) embellishData.flags |= NS_MATHML_EMBELLISH_ACCENT;
else if (value.Equals("false")) embellishData.flags &= ~NS_MATHML_EMBELLISH_ACCENT;
if (value.EqualsWithConversion("true")) embellishData.flags |= NS_MATHML_EMBELLISH_ACCENT;
else if (value.EqualsWithConversion("false")) embellishData.flags &= ~NS_MATHML_EMBELLISH_ACCENT;
aMathMLFrame->SetEmbellishData(embellishData);
}

View File

@ -44,7 +44,7 @@ void nsMathMLAtoms::AddRefAtoms() {
*/
if (NS_SUCCEEDED(NS_NewNameSpaceManager(&gNameSpaceManager)))
// gNameSpaceManager->CreateRootNameSpace(namespace);
gNameSpaceManager->RegisterNameSpace(kMathMLNameSpace, nameSpaceID);
gNameSpaceManager->RegisterNameSpace(NS_ConvertASCIItoUCS2(kMathMLNameSpace), nameSpaceID);
else
NS_ASSERTION(0, "failed to create MathML atoms namespace manager");

View File

@ -238,8 +238,7 @@ nsMathMLOperators::LookupOperator(const nsCString& aOperator,
float* aLeftSpace,
float* aRightSpace)
{
nsAutoString theOperator(aOperator);
return LookupOperator(theOperator,aForm,aFlags,aLeftSpace,aRightSpace);
return LookupOperator(aOperator,aForm,aFlags,aLeftSpace,aRightSpace);
}
PRBool