Open Bug 562460 (mathml-form) Opened 14 years ago Updated 2 years ago

Implement heuristic rules to determine the default value of the form attribute of MathML operators

Categories

(Core :: MathML, defect)

defect

Tracking

()

People

(Reporter: fredw, Unassigned)

References

()

Details

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.
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.
Once this is implemented, we need to check the behavior of \u005F (see bug 414294 comment 24) and update the operator dictionary.
Assignee: nobody → fred.wang
Status: NEW → ASSIGNED
Assignee: fred.wang → nobody
Status: ASSIGNED → NEW
Blocks: 958947
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.