Last Comment Bug 544001 - "tooltip" actiontype of "maction" element of MathML not implemented
: "tooltip" actiontype of "maction" element of MathML not implemented
Status: NEW
[parity-opera][parity-mathjax]
: dev-doc-needed, helpwanted
Product: Core
Classification: Components
Component: MathML (show other bugs)
: Trunk
: All All
: P5 normal with 4 votes (vote)
: ---
Assigned To: Nobody; OK to take it and work on it
:
Mentors:
https://eyeasme.com/Joe/MathML/MathML...
Depends on: 969906
Blocks: maction 700440
  Show dependency treegraph
 
Reported: 2010-02-03 08:16 PST by Joe Java
Modified: 2014-02-08 12:35 PST (History)
6 users (show)
See Also:
Crash Signature:
(edit)
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---


Attachments
testcase (515 bytes, text/html)
2012-02-23 07:09 PST, Frédéric Wang (:fredw)
no flags Details
testcase (MathJax rendering) (799 bytes, text/html)
2012-02-23 07:09 PST, Frédéric Wang (:fredw)
no flags Details
patch XUL-enabled v1 (3.90 KB, patch)
2012-06-07 13:30 PDT, Andrii Zui
no flags Details | Diff | Splinter Review
patch XUL-disabled v1 (2.30 KB, patch)
2012-06-07 13:31 PDT, Andrii Zui
no flags Details | Diff | Splinter Review

Description Joe Java 2010-02-03 08:16:01 PST
User-Agent:       Mozilla/5.0 (Macintosh; U; PPC Mac OS X 10.5; en-US; rv:1.9.2) Gecko/20100115 Firefox/3.6
Build Identifier: Mozilla/5.0 (Macintosh; U; PPC Mac OS X 10.5; en-US; rv:1.9.2) Gecko/20100115 Firefox/3.6

"tooltip" actiontype of "maction" element of MathML does not work

Reproducible: Always

Steps to Reproduce:
1. visit https://eyeasme.com/Joe/MathML/MathML_tooltip_bug.html
2. hover the cursor over the formula
3. no tooltip appears
Actual Results:  
no tooltip appears when the cursor is hovered over the formula

Expected Results:  
a tooltip should appear when the cursor is hovered over the formula

This page works OK with Opera but fails with Firefox.

NOTE: there is NO "title" attribute with MathML elements, so the 
Firefox default way of displaying tooltips (using the "title" attribute)
does not apply.
Comment 1 Frédéric Wang (:fredw) 2012-02-23 06:55:12 PST
The REC describes actiontype=tooltip like this:

"<maction actiontype="tooltip"> (expression) (message) </maction>

    The renderer displays the first child. When the pointer pauses over the expression for a long enough delay time, the renderer displays a rendering of the message in a pop-up "tooltip" box near the expression. Many systems may limit the popup to be text, so the second child should be an mtext element in most circumstances. For non-mtext messages, renderers may provide a natural language translation of the markup if full MathML rendering is not practical, but this is not required."
Comment 2 Frédéric Wang (:fredw) 2012-02-23 07:09:08 PST
Created attachment 600000 [details]
testcase
Comment 3 Frédéric Wang (:fredw) 2012-02-23 07:09:44 PST
Created attachment 600001 [details]
testcase (MathJax rendering)
Comment 4 Frédéric Wang (:fredw) 2012-02-23 07:36:09 PST
MathJax distinguishes text message (for which it uses HTML title) and MathML messages (for which it uses a div that it shows/hides with CSS). It looks like we can implement something similar by applying CSS rules to the second child of maction.
Comment 5 Frédéric Wang (:fredw) 2012-04-13 05:19:20 PDT
If we only want to consider text message (which is minimum required by the MathML3 spec), the relevant parts of the code to change seem to be:

http://mxr.mozilla.org/mozilla-central/source/browser/base/content/browser.js#3056

and

http://mxr.mozilla.org/mozilla-central/source/embedding/browser/webBrowser/nsDocShellTreeOwner.cpp#1058

The changes should be made in separate patches, since they are likely to be reviewed by different persons.
Comment 6 Frédéric Wang (:fredw) 2012-04-13 05:22:40 PDT
(and of course layout/mathml/nsMathMLmactionFrame.* too)
Comment 7 Frédéric Wang (:fredw) 2012-05-25 22:47:55 PDT
To come back to comment 4, here is how tooltip is implemented in http://www.w3.org/TR/mathml-for-css/ (and so in Opera):

maction > * + *
	{display:none;}
maction[actiontype="tooltip"]:focus > * + *,
maction[actiontype="tooltip"]:hover > * + *
	{position:fixed;
	display:block;
	top:0;
	left:0;
	background-color:InfoBackground;
	color:InfoText;
	padding:0.5ex;
	border:solid 1px;}

The first rule hides the second child of the maction element. The other rule displays the second child as a tooltip when one comes on the maction element.

Putting something like this in layout/mathml/mathml.css and also handling when the second child is displayed in nsMathMLmactionFrame may allow to implement the tooltip actiontype, even for generic formula (as Opera and MathJax do).

That won't share the code for other text tooltip mentioned in comment 5 and maybe not give a consistent behavior, but at least the changes will be restricted to the MathML module, so more easily acceptable. One issue with this method is that the tooltip is placed at the top right corner of the page, not near the maction element. I don't know if we can change that.
Comment 8 Frédéric Wang (:fredw) 2012-06-03 03:55:17 PDT
After discussions with Andrii, the option in comment 5 seems the most appropriate. In the case where XUL is used for the UI (like in Firefox) the implementation relies on

https://developer.mozilla.org/en/XUL/tooltip

It seems that this element can contain arbitrary children, so we could use MathML tooltip in that case.
Comment 9 Andrii Zui 2012-06-07 13:30:13 PDT
Created attachment 631107 [details] [diff] [review]
patch XUL-enabled v1
Comment 10 Andrii Zui 2012-06-07 13:31:20 PDT
Created attachment 631108 [details] [diff] [review]
patch XUL-disabled v1
Comment 11 Andrii Zui 2012-06-07 13:37:54 PDT
These patches implement only <mtext> tooltip. There were some issues with MathML child tooltip, I won't be working with it in the nearest future.
Comment 12 Andrii Zui 2012-06-12 15:15:37 PDT
Comment on attachment 631108 [details] [diff] [review]
patch XUL-disabled v1

I don't really know if XUL-disable part is needed, plus all these brackets look pretty weird. I can move this part into a new function, or remove at all.
Comment 13 Frédéric Wang (:fredw) 2012-06-13 14:55:40 PDT
Maybe we can also add a comment in

layout/mathml/nsMathMLmactionFrame.cpp

to indicate in which places of the code the tooltip actiontype is actually handled.
Comment 14 Frédéric Wang (:fredw) 2012-11-01 09:01:49 PDT
I don't think Andrii will continue to work on this bug. However, if I remember correctly his patches are complete and are just waiting to be reviewed. Probably they are now bit-rotten but I can update them and finish the work if necessary.

Gavin: Can you please give some feedback on this?
Comment 15 :Gavin Sharp [email: gavin@gavinsharp.com] 2012-11-30 16:35:34 PST
Comment on attachment 631107 [details] [diff] [review]
patch XUL-enabled v1

I'm sorry that I haven't been responsive here.

This model where the order of the children within the <maction> element matters is rather odd. It also seems very unusual to bake that kind of logic into the front-end code.

It would be more typical for this front-end code to look something like:

if (tipElement instanceof MathMLmactionElement &&
    tipElement.actionType == "tooltip")
  MathMLTitleText = tipElement.tooltipText;

But obviously that would require some Gecko changes, and I guess the MathML spec doesn't specify this kind of API?
Comment 16 Frédéric Wang (:fredw) 2012-12-01 02:25:34 PST
Thank you Gavin.

I won't argue about the design of maction. This element has been there since the first MathML recommendation in 1998 and @actiontype=tooltip is currently implemented in Opera & MathJax and probably in Webkit soon. We can probably ask the Math WG to integrate the "title" attribute in the MathML syntax but they will certainly keep the tooltip actiontype for backward compatibility as well as for consistency with the other action types. Using children content instead of attribute value allows arbitrary mathematical formula as a tooltip, although not strictly required by the MathML spec. This is implemented in MathJax (attachment 600001 [details]) and Andrii was able to implement this most general syntax by copying the <math> inside <tooltip>. However, there were some issues with his approach and I recommended him to submit the simplest version with text-only tooltip so that the patch would have more chance to get accepted.

The MathML spec defined a DOM but we didn't want to implement it (see bug 377499 comment 48 and bug 143842 comment 17). As a consequence, the MathML WG removed it from the spec. It seems a bit overkill to add this API to Gecko and write more C++ code if that's only to simplify a few lines in the front-end code. Anyway, I'm afraid I won't be able to contribute to the MathML project for a while and the best I can do for this bug is to unbitrot these patches. So please tell me whether you think this small patch (attachment 631107 [details] [diff] [review]) is likely to be accepted or not and I'll see what I can do.

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