MathML token elements require special treatments that are currently hardly implementable or badly implemented in layout/mathml/:
1) "Whitespace occurring within the content of token elements, except for <cs>, is normalized as follows. All whitespace at the beginning and end of the content is removed, and whitespace internal to content of the element is collapsed canonically, i.e., each sequence of 1 or more whitespace characters is replaced with one space character (U+0020, sometimes called a blank character)."
Bug 15402 was fixed by applying CompressWhitespace to the text children of the token element (http://mxr.mozilla.org/mozilla-central/source/layout/mathml/nsMathMLTokenFrame.cpp#108). This seems to be the cause of the crash in bug 770710. A possibility is to move this operation in the text frame rendering (but we have to be sure that it won't break <mo>: http://mxr.mozilla.org/mozilla-central/source/layout/mathml/nsMathMLmoFrame.cpp#117)
2) Karl also mentioned in bug 114365 comment 15 the case of math content overflowing in matrices (e.g. bug 415413).
3) "The ms element is used to represent "string literals" in expressions meant to be interpreted by computer algebra systems or other systems containing 'programming languages'. By default, string literals are displayed surrounded by double quotes, with no extra spacing added around the string". To implement this element, we use the style rules
and modify the content of the surrounding text frames (http://mxr.mozilla.org/mozilla-central/source/layout/mathml/nsMathMLTokenFrame.cpp#356). I proposed a solution in bug 560100. Maybe a simpler solution (ignoring mstyle) would be to use the following rules from the MathML for CSS Profile:
4) "An mo element represents an operator or anything that should be rendered as an operator.". We could add special treatments for primes and invisible operators (bug 140439, bug 442637 and bug 522393).
5) "An mi element represents a symbolic name or arbitrary text that should be rendered as an identifier. Identifiers can include variables, function names, and symbolic constants.". This element is supposed to be italic when if it is made of a single letter. However, this style should not apply when a non-italic mathvariant is used (bug 114365) or when the character is invariant. Currently, this is more or less implemented via a private _moz-math-font-style attribute (bug 69409, bug 527201). http://mxr.mozilla.org/mozilla-central/source/layout/mathml/nsMathMLTokenFrame.cpp#51
A way to solve these problems would be to move the treatment to the style system. Regarding <ms>, solutions are given above and in bug 560100. As for the others, we can create a -moz-math-token property with values NONE, GENERIC_TEXT, IDENTIFIER and OPERATOR and a -moz-math-variant attribute (corresponding to the mathvariant attributes) and use specific treatments on them during the text rendering / measuring.
Experimental patches are available in my patch queue: https://github.com/fred-wang/MozillaCentralPatches
I'm closing this bug, since all the issues are handled independently in other bugs.