Make MathML handle the <semantics> tag implicitly

RESOLVED FIXED in mozilla1.3final

Status

()

Core
MathML
RESOLVED FIXED
15 years ago
6 years ago

People

(Reporter: Jason Harris, Assigned: rbs)

Tracking

Trunk
mozilla1.3final
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(3 attachments)

(Reporter)

Description

15 years ago
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.1a+) Gecko/20020628
BuildID:    2002062808

The two main generators of MathML generate MathML with both presentation and
content. Unfortunately due to XSLT issues it is not always viable to use style
sheets to transform the content away.

Thus, it is vital for the support of MathML in Mozilla that Mozilla handles the
content tags implicitly. A good stopgap measure might be just to ignore all
other annotations besides the primary child. This would make Mozilla work with
both Mathematica and Maple since by default both of these MathML generators put
presentation first.

Indeed the majority of users who perform computations with MathML highly desire
the ability to have both presentation and content mathml in the same mathML
fragment. 

Here is an example of a simple MathML fragment which is causing problems:

<math xmlns='http://www.w3.org/1998/Math/MathML'>
 <semantics>
  <mrow>
   <msup>
    <mi>x</mi>
    <mn>2</mn>
   </msup>
   <mo>+</mo>
   <mi>y</mi>
  </mrow>
  <annotation-xml encoding='MathML-Content'>
   <apply>
    <plus/>
    <apply>
     <power/>
     <ci>x</ci>
     <cn type='integer'>2</cn>
    </apply>
    <ci>y</ci>
   </apply>
  </annotation-xml>
 </semantics>
</math>

Reproducible: Always
Steps to Reproduce:
1.Create a text file containing the above MathML
2.Open the text file in Mozilla

Actual Results:  You will see the presentation renders correctly, but it will be
followed by garbage semantics.

Expected Results:  You should see the presentation renders correctly, but the
semantics should not appear at all.
(Reporter)

Comment 1

15 years ago
Created attachment 89658 [details]
testcase
(Assignee)

Comment 2

15 years ago
I am sending this comment from a public booth at the Interntaional MathML 
Conference in Chicago where Mathematica & Maple folks have been hammering me 
with this issue. A stop-gap fix is simply to add the following style rule in 
mathml.css:

annotation-xml[encoding='MathML-Content'] { 
  display: none;
}

roc/waterson/asa, care to r/sr/a, thanks.

hixie, would be so kind to checkin the fix too, if approved? As you might 
imagine, I don't have all the setup to pursue the fix in the proper channels 
from this end, but I am hoping that the one-liner can still make it before the 
final build for Netscape 7.0 is pulled -- which is really why Wolfram & Maple 
have been hammering me with the issue here.
Status: UNCONFIRMED → NEW
Ever confirmed: true
Keywords: mozilla1.0.1
Summary: Not handling semantics tags implicitly → [PATCH] Not handling semantics tags implicitly
Target Milestone: --- → mozilla1.0.1
That style rule should really be in a namespace.  Otherwise it could slow things
down.  What namespace should it be in?
mathml.css has a default namespace declared
erm, i was about to make a patch for this, when i found that attachment 89658 [details]
already works fine. I can't see why. The annotation-xml node is display:none but
there are no corresponding rules.

In principle, r=hixie, but I think something odd may be going on here.
Oh, I think actually that may just have been a bug in the DOM inspector. I think
I changed the mathml.css file before loading any MathML content, and since the
exported mathml.css file is just a symlink to the one I was editing, it took
effect. Or something.

Anyway, r=hixie on rbs' patch:

Index: mathml.css
===================================================================
RCS file: /cvsroot/mozilla/layout/mathml/content/src/mathml.css,v
retrieving revision 1.14
diff -u -r1.14 mathml.css
--- mathml.css	27 Feb 2002 01:35:24 -0000	1.14
+++ mathml.css	29 Jun 2002 22:57:23 -0000
@@ -407,3 +407,10 @@
 }
 :-moz-math-font-style-anonymous {
 }
+
+/**********************************************************************/
+/* Hide embedded semantic MathML content (as opposed to presentational
+   content, which we render). */
+annotation-xml[encoding="MathML-Content"] { 
+  display: none;
+}
r=dbaron too, then.
sr=roc+moz
checked in to trunk

Comment 10

15 years ago
please checkin to the 1.0.1 branch. once there, remove the "mozilla1.0.1+"
keyword and add the "fixed1.0.1" keyword.
Keywords: mozilla1.0.1 → mozilla1.0.1+
(Assignee)

Comment 11

15 years ago
checked in to branch - marking fixed1.0.1
Status: NEW → RESOLVED
Last Resolved: 15 years ago
Keywords: mozilla1.0.1+ → fixed1.0.1
Resolution: --- → FIXED
Summary: [PATCH] Not handling semantics tags implicitly → Not handling semantics tags implicitly
(Assignee)

Updated

15 years ago
Summary: Not handling semantics tags implicitly → Make MathML handle the <semantics> tag implicitly
(Assignee)

Comment 12

15 years ago
re-opening due to the following comment:
http://groups.google.com/groups?selm=200302031132.LAA06605%40penguin.nag.co.uk

From: David Carlisle (davidc@nag.co.uk)
Subject: rendering of semantics elements in mozilla.
Newsgroups: netscape.public.mozilla.mathml
Date: 2003-02-03 03:55:20 PST

As Mozilla doesn't render Content MathML it would be nice to be able
to combine Content expressions together with Presentation MathML
(and other things) in a semantics element, and have mozilla ignore
everything except the presentation mathml.

In addition to Content mathml, editors and computer algebra systems
often use the semantics element to annotate an expression with
processor-specific information (which is the intended use of this
element). All a browser has to do is ignore the annotations.

there was/is a bugzilla report for this which is marked as fixed

http://bugzilla.mozilla.org/show_bug.cgi?id=154931


however the css rule added at that time appears to be:

/**********************************************************************/
/* Hide embedded semantic MathML content (as opposed to presentational
   content, which we render). */
annotation-xml[encoding="MathML-Content"] { 
  display: none;
}


This leaves non xml annotation elements being rendered (these typically
contain maple or mathematica encodings of the expression)

Also it renders all annotation-xml except content-mathml (for example
the openmath as used examples in chapter 5 of the spec).

The simplest css based rendering rules would be

annotation{  display: none; }
annotation-xml{  display: none; }

ie don't render any annotation at all (and so just render the first child of
the semantics element)

A more complete rule would be:

if there is an <annotation-XML encoding="MathML-presentation">
  render that annotation, and ignore the first child of the semantics
  element and all other annotations, 
else
  render the first child of semantics and ignore all annotations


I don't think you can express this rule purely in css though.
The simpler rule of just ignoring all annotations is still conformant
with the specification and would cover most existing cases that are
causing problems. (The XSLT stylesheet for MathML implements the more
complete rule, as well as doing content-presentation transformation, for
cases when the full functionality is needed).




For example, asking maple to output the expression  cos x as mathml
produces

<math xmlns='http://www.w3.org/1998/Math/MathML'>
<semantics>
 <mrow xref='id3'>
   <mi xref='id1'>cos</mi>
   <mo>&ApplyFunction;</mo>
   <mfenced><mi xref='id2'>x</mi></mfenced>
 </mrow>
 <annotation-xml encoding='MathML-Content'>
  <apply id='id3'><cos id='id1'/><ci id='id2'>x</ci></apply>
 </annotation-xml>
 <annotation encoding='Maple'>
  cos(x)
 </annotation>
</semantics>
</math>


which renders as cos(x)cos(x) in mozilla 1.1 (which I suppose is a bit
old, but I believe newer mozilla are the same?)


David
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
(Reporter)

Comment 13

15 years ago
David is right here. It would be nice to have this additional intelligence from the MathML renderer for Mozilla.

In Mathematica by default the first annotation of a semantics element is presentation MathML. (However the user can of course override this.) From David's example and from my vague memory of talking to the Maple folks at MathML2002 I guess the same default is true for Maple.

But, I would expect that Maple has the ability to control which annotations are included in the MathML. (Certainly, Mathematica has a very easy way to control this.) Thus just trying to render the first element of the semantics element should just be a stop gap measure until better handling is implemented for annotations in Mozilla
(Assignee)

Comment 14

15 years ago
Using Opera? I was bitten once... Resending with a more capable browser that
knows how to wrap :-)

------- Additional Comment #13 From Jason Harris  2003-02-04 02:57 -------

David is right here. It would be nice to have this additional intelligence from
the MathML renderer for Mozilla.

In Mathematica by default the first annotation of a semantics element is
presentation MathML. (However the user can of course override this.) From
David's example and from my vague memory of talking to the Maple folks at
MathML2002 I guess the same default is true for Maple.

But, I would expect that Maple has the ability to control which annotations are
included in the MathML. (Certainly, Mathematica has a very easy way to control
this.) Thus just trying to render the first element of the semantics element
should just be a stop gap measure until better handling is implemented for
annotations in Mozilla
(Assignee)

Comment 15

15 years ago
Created attachment 113525 [details]
extended testcase
(Assignee)

Comment 16

15 years ago
So, the ideal is:

if there is an <annotation-XML encoding="MathML-presentation">
  render that annotation, and ignore the first child of the semantics
  element and all other annotations, 
else
  render the first child of semantics and ignore all annotations


I applied the patch on bug 135141 thinking that it might help. But there doesn't
seem a way to get the desired effect -- or my CSS is a bit rusty to get there...

As a stop-gap, we can either have:
annotation { display: none; }
annotation-xml { display: none; }

or as suggested, just render the first child:

semantics > :not(:first-child) { display: none; }
(Assignee)

Comment 17

15 years ago
Created attachment 113534 [details] [diff] [review]
stop-gap patch
(Assignee)

Comment 18

15 years ago
Comment on attachment 113534 [details] [diff] [review]
stop-gap patch

re-requesting r/sr
Attachment #113534 - Flags: superreview?(roc+moz)
Attachment #113534 - Flags: review?(dbaron)
(Assignee)

Comment 19

15 years ago
The reason why the patch on bug 135141 didn't help is because 'adjacent' (CSS
operator '~') is interpred as 'preceded by'. Since :first-child is preceded by
nothing, there was no way to conditionally select it. If 'adjacent' really meant
what its name suggests, CSS could have done the trick:

semantics > :not(:first-child) {
  display: none;
}
semantics > annotation-xml[encoding="MathML-Presentation"] {
  display: inline;
}
annotation-xml[encoding="MathML-Presentation"] ~ semantics:first-child {
  display: none;
}
(Assignee)

Comment 20

15 years ago
Oops, s/ semantics:first-child / semantics > :first-child /
With that correction, not sure if the CSS is still valid though.
Attachment #113534 - Flags: review?(dbaron) → review+
Yeah, CSS can't do what you're describing. Should be quite easy to do at the C++
level though...
(Assignee)

Comment 22

15 years ago
Would have been nice if '~' means 'sibling'.
(Assignee)

Comment 23

15 years ago
Or rather if there was a 'sibling' operator, rather than just the 'preceded by'
operator.
I've proposed :matches(), which is a superset of that, several times. It's very
well defined, but has so far been rejected because it would be a MASSIVE
performance hit.
Attachment #113534 - Flags: superreview?(roc+moz) → superreview+
(Assignee)

Comment 25

15 years ago
Comment on attachment 113534 [details] [diff] [review]
stop-gap patch

Seeking a= on this simple patch to apply some CSS rules to the <semantics> tag
so that a certain behavior is emulated.
Attachment #113534 - Flags: approval1.3b?

Comment 26

15 years ago
Comment on attachment 113534 [details] [diff] [review]
stop-gap patch

This is going to have to wait 'till we open for final. I think we've got what
we need for beta and until we get the beta released we can't take further
non-critical changes.
Attachment #113534 - Flags: approval1.3b? → approval1.3b-
(Assignee)

Comment 27

15 years ago
>I've proposed :matches(), which is a superset of that, several times. It's very
>well defined, but has so far been rejected because it would be a MASSIVE
>performance hit.

Got a reference? I am not that thrilled to add some special C++ for this
<semantics>. Maybe a :-moz-matches() can be of wide use, here and elsewhere? XBL
isn't particularly fast, yet it avoids repetition, thereby cutting the bloat.
(Assignee)

Comment 28

15 years ago
Comment on attachment 113534 [details] [diff] [review]
stop-gap patch

per asa's comment 26, migrating request for a=1.3final.
Attachment #113534 - Flags: approval1.3?

Comment 29

15 years ago
Comment on attachment 113534 [details] [diff] [review]
stop-gap patch

a=asa (on behalf of drivers) for checkin to 1.3 final.
Attachment #113534 - Flags: approval1.3? → approval1.3+
(Assignee)

Comment 30

15 years ago
Checked in mozilla1.3 final.
Status: REOPENED → RESOLVED
Last Resolved: 15 years ago15 years ago
Resolution: --- → FIXED
Target Milestone: mozilla1.0.1 → mozilla1.3final
You need to log in before you can comment on or make changes to this bug.