Last Comment Bug 562460 - (mathml-form) Implement heuristic rules to determine the default value of the form attribute of MathML operators
(mathml-form)
: Implement heuristic rules to determine the default value of the form attribut...
Status: NEW
:
Product: Core
Classification: Components
Component: MathML (show other bugs)
: Trunk
: All All
: -- normal (vote)
: ---
Assigned To: Nobody; OK to take it and work on it
:
: Anthony Jones (:kentuckyfriedtakahe, :k17e)
Mentors:
http://www.w3.org/TR/MathML3/chapter3...
Depends on: 21479
Blocks: 958947
  Show dependency treegraph
 
Reported: 2010-04-28 14:07 PDT by Frédéric Wang (:fredw)
Modified: 2014-01-12 06:45 PST (History)
0 users
See Also:
Crash Signature:
(edit)
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---


Attachments

Description Frédéric Wang (:fredw) 2010-04-28 14:07:59 PDT
Currently, we are determining the form here:
http://mxr.mozilla.org/mozilla-central/source/layout/mathml/nsMathMLmoFrame.cpp#355

All what we do is looking for the existence of next/previous frames:
http://mxr.mozilla.org/mozilla-central/source/layout/mathml/nsMathMLmoFrame.cpp#378
(Also, we have NS_MATHML_OPERATOR_EMBELLISH_ISOLATED that behaves similarly and should probably be changed too:
http://mxr.mozilla.org/mozilla-central/source/layout/mathml/nsMathMLmoFrame.cpp#361)

The MathML spec gives more precise rules:

* If the operator is the first argument in an mrow of length (i.e. number of arguments) greater than one (ignoring all space-like arguments (see Section 3.2.7 Space <mspace/>) in the determination of both the length and the first argument), the prefix form is used;
* if it is the last argument in an mrow of length greater than one (ignoring all space-like arguments), the postfix form is used;
* in all other cases, including when the operator is not part of an mrow, the infix form is used.


We support the exception for embellished operator and so the "operator" is given by the nsIFrame* embellishAncestor that represents the whole embellished operator. I think we can use do_QueryFrame(mSelectedFrame) to cast it into a nsIMathMLFrame*. In that case, to implement the exact rules we need to add two things to nsIMathMLFrame's:

1) something to determine if it is "space-like" (for the sibling nsIMathMLFrame's). I've implemented such a function "IsSpaceLike()" in the attachment of bug 21479.
2) something to determine if it is "mrow-like" (for the parent nsIMathMLFrame) and so implement a function "IsMrowLike()". What I call "mrow-like" is an element requiring 1* argument (msqrt, mstyle, merror, mpadded, mphantom, menclose, mtd, mscarry, and math) that has an inferred mrow. So this function will just return PR_FALSE in the base class and be overrided in the derived classes of the previous elements, to return PR_TRUE instead when their number of children is 0 or is more than 1.

For 1), I use TransmitAutomaticData because some elements determine whether they are space-like by looking if some of their children are space-like. I haven't checked yet if the siblings of the operator already know whether they are SpaceLike when determining the form.
Comment 1 Frédéric Wang (:fredw) 2010-08-12 13:23:33 PDT
A new rule has been added for script operators:

* If the operator is the first argument in an mrow with more than one argument (ignoring all space-like arguments (see Section 3.2.7 Space <mspace/>) in the determination of both the length and the first argument), the prefix form is used;
* if it is the last argument in an mrow with more than one argument (ignoring all space-like arguments), the postfix form is used;
* if it is the only element in an implicit or explicit mrow and if it is in a script position of one of the elements listed in Section 3.4 Script and Limit Schemata, the postfix form is used;
* in all other cases, including when the operator is not part of an mrow, the infix form is used.
Comment 2 Frédéric Wang (:fredw) 2011-04-25 07:21:31 PDT
Once this is implemented, we need to check the behavior of \u005F (see bug 414294 comment 24) and update the operator dictionary.

Note You need to log in before you can comment on or make changes to this bug.