Bug 475518 - MathML layout code should use _moz* attributes instead of -moz-* attributes. r=karlt, sr=bz

--HG--
extra : rebase_source : 34bb7055d4deaad9a0ee55aa40b9bcbdd19153ea
This commit is contained in:
Frédéric Wang 2010-03-10 13:49:33 +01:00
Родитель 8839200e69
Коммит af2f349608
6 изменённых файлов: 72 добавлений и 66 удалений

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

@ -1301,12 +1301,14 @@ GK_ATOM(XML, "XML")
#endif
#ifdef MOZ_MATHML
GK_ATOM(MOZcolumnalign, "-moz-math-columnalign")
GK_ATOM(MOZcolumnline, "-moz-math-columnline") // different from columnlines_
GK_ATOM(MOZfontsize, "-moz-math-font-size") // different from fontsize_
GK_ATOM(MOZfontstyle, "-moz-math-font-style") // different from fontstyle_
GK_ATOM(MOZrowalign, "-moz-math-rowalign")
GK_ATOM(MOZrowline, "-moz-math-rowline") // different from rowlines_
// internal MathML attributes: different from columnalign_, columnlines_,
// fontstyle_, rowalign_ and rowlines_
GK_ATOM(_moz_math_columnalign_, "_moz-math-columnalign")
GK_ATOM(_moz_math_columnline_, "_moz-math-columnline")
GK_ATOM(_moz_math_fontstyle_, "_moz-math-font-style")
GK_ATOM(_moz_math_rowalign_, "_moz-math-rowalign")
GK_ATOM(_moz_math_rowline_, "_moz-math-rowline")
GK_ATOM(abs_, "abs")
GK_ATOM(accent_, "accent")
GK_ATOM(accentunder_, "accentunder")

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

@ -368,13 +368,6 @@ nsXHTMLContentSerializer::SerializeAttributes(nsIContent* aContent,
aContent->GetAttr(namespaceID, attrName, valueStr);
nsDependentAtomString nameStr(attrName);
// XXX Hack to get around the fact that MathML can add
// attributes starting with '-', which makes them
// invalid XML. see Bug 475518
if (!nameStr.IsEmpty() && nameStr.First() == '-')
continue;
PRBool isJS = PR_FALSE;
if (kNameSpaceID_XHTML == contentNamespaceID) {

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

@ -65,6 +65,8 @@
#include "nsAttrName.h"
#include "nsILineBreaker.h"
static const char kMozStr[] = "moz";
#define kXMLNS "xmlns"
// to be readable, we assume that an indented line contains
@ -853,6 +855,13 @@ nsXMLContentSerializer::SerializeAttributes(nsIContent* aContent,
nsIAtom* attrName = name->LocalName();
nsIAtom* attrPrefix = name->GetPrefix();
// Filter out any attribute starting with [-|_]moz
nsDependentAtomString attrNameStr(attrName);
if (StringBeginsWith(attrNameStr, NS_LITERAL_STRING("_moz")) ||
StringBeginsWith(attrNameStr, NS_LITERAL_STRING("-moz"))) {
continue;
}
if (attrPrefix) {
attrPrefix->ToString(prefixStr);
}
@ -867,14 +876,8 @@ nsXMLContentSerializer::SerializeAttributes(nsIContent* aContent,
}
aContent->GetAttr(namespaceID, attrName, valueStr);
nsDependentAtomString nameStr(attrName);
// XXX Hack to get around the fact that MathML can add
// attributes starting with '-', which makes them
// invalid XML. see Bug 475518
if (!nameStr.IsEmpty() && nameStr.First() == '-')
continue;
PRBool isJS = IsJavaScript(aContent, attrName, namespaceID, valueStr);
SerializeAttr(prefixStr, nameStr, valueStr, aStr, !isJS);

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

@ -75,7 +75,7 @@ math[display="inline"] {
/* If the textual content of an <mi> consists of a single character
with a corresponding mathematical italic alphanumeric character,
then try to emulate that character */
[-moz-math-font-style="italic"] {
[_moz-math-font-style="italic"] {
font-style: italic;
font-weight: normal;
}
@ -90,11 +90,11 @@ math[display="inline"] {
(non-slanted) for all tokens except mi. ... (The deprecated fontslant
attribute also behaves this way.)"
*/
[-moz-math-font-style="normal"] {
[_moz-math-font-style="normal"] {
font-style: normal;
}
/* A style-invariant character preserves its own style */
[-moz-math-font-style="invariant"] {
[_moz-math-font-style="invariant"] {
font-style: normal;
font-weight: normal;
}
@ -256,15 +256,15 @@ mtd {
/***********************/
/* -- mtd: columnalign */
mtd[-moz-math-columnalign="left"],
mtd[_moz-math-columnalign="left"],
mtd[columnalign="left"] {
text-align: left;
}
mtd[-moz-math-columnalign="right"],
mtd[_moz-math-columnalign="right"],
mtd[columnalign="right"] {
text-align: right;
}
mtd[-moz-math-columnalign="center"],
mtd[_moz-math-columnalign="center"],
mtd[columnalign="center"] {
text-align: -moz-center;
}
@ -272,28 +272,28 @@ mtd[columnalign="center"] {
/*************************/
/* -- mtr, mtd: rowalign */
mtr[-moz-math-rowalign="top"],
mtr[_moz-math-rowalign="top"],
mtr[rowalign="top"],
mtd[rowalign="top"] {
vertical-align: top;
}
mtr[-moz-math-rowalign="bottom"],
mtr[_moz-math-rowalign="bottom"],
mtr[rowalign="bottom"],
mtd[rowalign="bottom"] {
vertical-align: bottom;
}
mtr[-moz-math-rowalign="center"],
mtr[_moz-math-rowalign="center"],
mtr[rowalign="center"],
mtd[rowalign="center"] {
vertical-align: middle;
}
mtr[-moz-math-rowalign="baseline"],
mtr[_moz-math-rowalign="baseline"],
mtr[rowalign="baseline"],
mtd[rowalign="baseline"] {
vertical-align: baseline;
}
/* -- not yet supported --
mtr[-moz-math-rowalign="axis"],
mtr[_moz-math-rowalign="axis"],
mtr[rowalign="axis"],
mtd[rowalign="axis"] {
vertical-align: mathline;
@ -349,22 +349,22 @@ mtable[frame="dashed"] > mtr > mtd:last-child {
unsuitable rules on the cells on the first row and the first column.
In general, however, authors can use the 'border' property of CSS to
achieve varying effects down to the level of the table cell. */
mtr[-moz-math-rowline="none"] > mtd {
mtr[_moz-math-rowline="none"] > mtd {
border-top: none;
}
mtr[-moz-math-rowline="solid"] > mtd {
mtr[_moz-math-rowline="solid"] > mtd {
border-top: solid thin;
}
mtr[-moz-math-rowline="dashed"] > mtd {
mtr[_moz-math-rowline="dashed"] > mtd {
border-top: dashed thin;
}
mtd[-moz-math-columnline="none"] {
mtd[_moz-math-columnline="none"] {
border-left: none;
}
mtd[-moz-math-columnline="solid"] {
mtd[_moz-math-columnline="solid"] {
border-left: solid thin;
}
mtd[-moz-math-columnline="dashed"] {
mtd[_moz-math-columnline="dashed"] {
border-left: dashed thin;
}

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

@ -74,7 +74,8 @@ nsMathMLTokenFrame::GetMathMLFrameType()
nsAutoString style;
// mathvariant overrides fontstyle
// http://www.w3.org/TR/2003/REC-MathML2-20031021/chapter3.html#presm.deprecatt
mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::MOZfontstyle, style) ||
mContent->GetAttr(kNameSpaceID_None,
nsGkAtoms::_moz_math_fontstyle_, style) ||
mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::mathvariant_, style) ||
mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::fontstyle_, style);
@ -351,16 +352,18 @@ nsMathMLTokenFrame::SetTextStyle()
}
}
// set the -moz-math-font-style attribute without notifying that we want a reflow
// set the _moz-math-font-style attribute without notifying that we want a reflow
if (fontstyle.IsEmpty()) {
if (mContent->HasAttr(kNameSpaceID_None, nsGkAtoms::MOZfontstyle)) {
mContent->UnsetAttr(kNameSpaceID_None, nsGkAtoms::MOZfontstyle, PR_FALSE);
if (mContent->HasAttr(kNameSpaceID_None, nsGkAtoms::_moz_math_fontstyle_)) {
mContent->UnsetAttr(kNameSpaceID_None, nsGkAtoms::_moz_math_fontstyle_,
PR_FALSE);
return PR_TRUE;
}
}
else if (!mContent->AttrValueIs(kNameSpaceID_None, nsGkAtoms::MOZfontstyle,
else if (!mContent->AttrValueIs(kNameSpaceID_None,
nsGkAtoms::_moz_math_fontstyle_,
fontstyle, eCaseMatters)) {
mContent->SetAttr(kNameSpaceID_None, nsGkAtoms::MOZfontstyle,
mContent->SetAttr(kNameSpaceID_None, nsGkAtoms::_moz_math_fontstyle_,
fontstyle, PR_FALSE);
return PR_TRUE;
}

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

@ -178,12 +178,12 @@ MapRowAttributesIntoCSS(nsIFrame* aTableFrame,
// see if the rowalign attribute is not already set
if (!rowContent->HasAttr(kNameSpaceID_None, nsGkAtoms::rowalign_) &&
!rowContent->HasAttr(kNameSpaceID_None, nsGkAtoms::MOZrowalign)) {
!rowContent->HasAttr(kNameSpaceID_None, nsGkAtoms::_moz_math_rowalign_)) {
// see if the rowalign attribute was specified on the table
attr = GetValueAt(aTableFrame, nsGkAtoms::rowalign_, rowIndex);
if (attr) {
// set our special -moz attribute on the row without notifying a reflow
rowContent->SetAttr(kNameSpaceID_None, nsGkAtoms::MOZrowalign,
// set our special _moz attribute on the row without notifying a reflow
rowContent->SetAttr(kNameSpaceID_None, nsGkAtoms::_moz_math_rowalign_,
nsDependentString(attr), PR_FALSE);
}
}
@ -194,11 +194,11 @@ MapRowAttributesIntoCSS(nsIFrame* aTableFrame,
// This way of doing so allows us to handle selective lines, [row]\hline[row][row]',
// and cases of spanning cells without further complications.
if (rowIndex > 0 &&
!rowContent->HasAttr(kNameSpaceID_None, nsGkAtoms::MOZrowline)) {
!rowContent->HasAttr(kNameSpaceID_None, nsGkAtoms::_moz_math_rowline_)) {
attr = GetValueAt(aTableFrame, nsGkAtoms::rowlines_, rowIndex-1);
if (attr) {
// set our special -moz attribute on the row without notifying a reflow
rowContent->SetAttr(kNameSpaceID_None, nsGkAtoms::MOZrowline,
// set our special _moz attribute on the row without notifying a reflow
rowContent->SetAttr(kNameSpaceID_None, nsGkAtoms::_moz_math_rowline_,
nsDependentString(attr), PR_FALSE);
}
}
@ -221,7 +221,8 @@ MapColAttributesIntoCSS(nsIFrame* aTableFrame,
// see if the columnalign attribute is not already set
if (!cellContent->HasAttr(kNameSpaceID_None, nsGkAtoms::columnalign_) &&
!cellContent->HasAttr(kNameSpaceID_None, nsGkAtoms::MOZcolumnalign)) {
!cellContent->HasAttr(kNameSpaceID_None,
nsGkAtoms::_moz_math_columnalign_)) {
// see if the columnalign attribute was specified on the row
attr = GetValueAt(aRowFrame, nsGkAtoms::columnalign_, colIndex);
if (!attr) {
@ -229,8 +230,8 @@ MapColAttributesIntoCSS(nsIFrame* aTableFrame,
attr = GetValueAt(aTableFrame, nsGkAtoms::columnalign_, colIndex);
}
if (attr) {
// set our special -moz attribute without notifying a reflow
cellContent->SetAttr(kNameSpaceID_None, nsGkAtoms::MOZcolumnalign,
// set our special _moz attribute without notifying a reflow
cellContent->SetAttr(kNameSpaceID_None, nsGkAtoms::_moz_math_columnalign_,
nsDependentString(attr), PR_FALSE);
}
}
@ -241,11 +242,12 @@ MapColAttributesIntoCSS(nsIFrame* aTableFrame,
// of the previous cell. This way of doing so allows us to handle selective lines,
// e.g., 'r|cl', and cases of spanning cells without further complications.
if (colIndex > 0 &&
!cellContent->HasAttr(kNameSpaceID_None, nsGkAtoms::MOZcolumnline)) {
!cellContent->HasAttr(kNameSpaceID_None,
nsGkAtoms::_moz_math_columnline_)) {
attr = GetValueAt(aTableFrame, nsGkAtoms::columnlines_, colIndex-1);
if (attr) {
// set our special -moz attribute without notifying a reflow
cellContent->SetAttr(kNameSpaceID_None, nsGkAtoms::MOZcolumnline,
// set our special _moz attribute without notifying a reflow
cellContent->SetAttr(kNameSpaceID_None, nsGkAtoms::_moz_math_columnline_,
nsDependentString(attr), PR_FALSE);
}
}
@ -463,13 +465,13 @@ nsMathMLmtableOuterFrame::AttributeChanged(PRInt32 aNameSpaceID,
nsIAtom* MOZrowAtom = nsnull;
nsIAtom* MOZcolAtom = nsnull;
if (aAttribute == nsGkAtoms::rowalign_)
MOZrowAtom = nsGkAtoms::MOZrowalign;
MOZrowAtom = nsGkAtoms::_moz_math_rowalign_;
else if (aAttribute == nsGkAtoms::rowlines_)
MOZrowAtom = nsGkAtoms::MOZrowline;
MOZrowAtom = nsGkAtoms::_moz_math_rowline_;
else if (aAttribute == nsGkAtoms::columnalign_)
MOZcolAtom = nsGkAtoms::MOZcolumnalign;
MOZcolAtom = nsGkAtoms::_moz_math_columnalign_;
else if (aAttribute == nsGkAtoms::columnlines_)
MOZcolAtom = nsGkAtoms::MOZcolumnline;
MOZcolAtom = nsGkAtoms::_moz_math_columnline_;
if (!MOZrowAtom && !MOZcolAtom)
return NS_OK;
@ -477,7 +479,7 @@ nsMathMLmtableOuterFrame::AttributeChanged(PRInt32 aNameSpaceID,
// clear any cached nsValueList for this table
tableFrame->DeleteProperty(aAttribute);
// unset any -moz attribute that we may have set earlier, and re-sync
// unset any _moz attribute that we may have set earlier, and re-sync
nsIFrame* rowFrame = rgFrame->GetFirstChild(nsnull);
for ( ; rowFrame; rowFrame = rowFrame->GetNextSibling()) {
if (rowFrame->GetType() == nsGkAtoms::tableRowFrame) {
@ -707,8 +709,9 @@ nsMathMLmtrFrame::AttributeChanged(PRInt32 aNameSpaceID,
// columnalign : Need an explicit re-style call.
if (aAttribute == nsGkAtoms::rowalign_) {
// unset any -moz attribute that we may have set earlier, and re-sync
mContent->UnsetAttr(kNameSpaceID_None, nsGkAtoms::MOZrowalign, PR_FALSE);
// unset any _moz attribute that we may have set earlier, and re-sync
mContent->UnsetAttr(kNameSpaceID_None, nsGkAtoms::_moz_math_rowalign_,
PR_FALSE);
MapRowAttributesIntoCSS(nsTableFrame::GetTableFrame(this), this);
// That's all - see comment above.
return NS_OK;
@ -720,14 +723,15 @@ nsMathMLmtrFrame::AttributeChanged(PRInt32 aNameSpaceID,
// Clear any cached columnalign's nsValueList for this row
DeleteProperty(aAttribute);
// Clear any internal -moz attribute that we may have set earlier
// Clear any internal _moz attribute that we may have set earlier
// in our cells and re-sync their columnalign attribute
nsTableFrame* tableFrame = nsTableFrame::GetTableFrame(this);
nsIFrame* cellFrame = GetFirstChild(nsnull);
for ( ; cellFrame; cellFrame = cellFrame->GetNextSibling()) {
if (IS_TABLE_CELL(cellFrame->GetType())) {
cellFrame->GetContent()->
UnsetAttr(kNameSpaceID_None, nsGkAtoms::MOZcolumnalign, PR_FALSE);
UnsetAttr(kNameSpaceID_None, nsGkAtoms::_moz_math_columnalign_,
PR_FALSE);
MapColAttributesIntoCSS(tableFrame, this, cellFrame);
}
}
@ -806,8 +810,9 @@ nsMathMLmtdFrame::AttributeChanged(PRInt32 aNameSpaceID,
// columnspan : here
if (aAttribute == nsGkAtoms::columnalign_) {
// unset any -moz attribute that we may have set earlier, and re-sync
mContent->UnsetAttr(kNameSpaceID_None, nsGkAtoms::MOZcolumnalign, PR_FALSE);
// unset any _moz attribute that we may have set earlier, and re-sync
mContent->UnsetAttr(kNameSpaceID_None, nsGkAtoms::_moz_math_columnalign_,
PR_FALSE);
MapColAttributesIntoCSS(nsTableFrame::GetTableFrame(this), mParent, this);
return NS_OK;
}