<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[161430] trunk</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/161430">161430</a></dd>
<dt>Author</dt> <dd>commit-queue@webkit.org</dd>
<dt>Date</dt> <dd>2014-01-07 09:49:04 -0800 (Tue, 07 Jan 2014)</dd>
</dl>
<h3>Log Message</h3>
<pre>Add Support for the semantics element.
https://bugs.webkit.org/show_bug.cgi?id=100626
Source/WebCore:
Patch by Frédéric Wang <fred.wang@free.fr> on 2014-01-07
Reviewed by Chris Fleizach.
Tests: mathml/presentation/semantics-2.html
mathml/presentation/semantics-3.html
mathml/presentation/semantics-4.html
This provides a complete support for the semantics element. When the first child is a content MathML, an annotation can be selected and displayed. The selection algorithm is identical to Gecko's one. The recognized annotations are text (e.g. LaTeX), presentation MathML, SVG and HTML.
* mathml/MathMLElement.cpp:
(WebCore::MathMLElement::childShouldCreateRenderer):
(WebCore::MathMLElement::attributeChanged):
(WebCore::MathMLElement::isPresentationMathML):
* mathml/MathMLElement.h:
(WebCore::MathMLElement::isMathMLToken):
(WebCore::MathMLElement::isSemanticAnnotation):
(WebCore::MathMLElement::isPresentationMathML):
(WebCore::MathMLElement::updateSelectedChild):
* mathml/MathMLInlineContainerElement.h:
* mathml/MathMLSelectElement.cpp:
(WebCore::MathMLSelectElement::getSelectedActionChildAndIndex):
(WebCore::MathMLSelectElement::getSelectedActionChild):
(WebCore::MathMLSelectElement::getSelectedSemanticsChild):
(WebCore::MathMLSelectElement::updateSelectedChild):
(WebCore::MathMLSelectElement::toggle):
* mathml/MathMLSelectElement.h:
* mathml/MathMLTextElement.h:
* mathml/mathattrs.in:
* mathml/mathtags.in:
LayoutTests:
Patch by Frédéric Wang <fred.wang@free.fr> on 2014-01-07
Reviewed by Chris Fleizach.
* TestExpectations:
* mathml/presentation/semantics-2-expected.html: Added.
* mathml/presentation/semantics-2.html: Added.
* mathml/presentation/semantics-3-expected.html: Added.
* mathml/presentation/semantics-3.html: Added.
* mathml/presentation/semantics-4-expected.html: Added.
* mathml/presentation/semantics-4.html: Added.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsTestExpectations">trunk/LayoutTests/TestExpectations</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoremathmlMathMLElementcpp">trunk/Source/WebCore/mathml/MathMLElement.cpp</a></li>
<li><a href="#trunkSourceWebCoremathmlMathMLElementh">trunk/Source/WebCore/mathml/MathMLElement.h</a></li>
<li><a href="#trunkSourceWebCoremathmlMathMLInlineContainerElementh">trunk/Source/WebCore/mathml/MathMLInlineContainerElement.h</a></li>
<li><a href="#trunkSourceWebCoremathmlMathMLSelectElementcpp">trunk/Source/WebCore/mathml/MathMLSelectElement.cpp</a></li>
<li><a href="#trunkSourceWebCoremathmlMathMLSelectElementh">trunk/Source/WebCore/mathml/MathMLSelectElement.h</a></li>
<li><a href="#trunkSourceWebCoremathmlMathMLTextElementh">trunk/Source/WebCore/mathml/MathMLTextElement.h</a></li>
<li><a href="#trunkSourceWebCoremathmlmathattrsin">trunk/Source/WebCore/mathml/mathattrs.in</a></li>
<li><a href="#trunkSourceWebCoremathmlmathtagsin">trunk/Source/WebCore/mathml/mathtags.in</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsmathmlpresentationsemantics2expectedhtml">trunk/LayoutTests/mathml/presentation/semantics-2-expected.html</a></li>
<li><a href="#trunkLayoutTestsmathmlpresentationsemantics2html">trunk/LayoutTests/mathml/presentation/semantics-2.html</a></li>
<li><a href="#trunkLayoutTestsmathmlpresentationsemantics3expectedhtml">trunk/LayoutTests/mathml/presentation/semantics-3-expected.html</a></li>
<li><a href="#trunkLayoutTestsmathmlpresentationsemantics3html">trunk/LayoutTests/mathml/presentation/semantics-3.html</a></li>
<li><a href="#trunkLayoutTestsmathmlpresentationsemantics4expectedhtml">trunk/LayoutTests/mathml/presentation/semantics-4-expected.html</a></li>
<li><a href="#trunkLayoutTestsmathmlpresentationsemantics4html">trunk/LayoutTests/mathml/presentation/semantics-4.html</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (161429 => 161430)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2014-01-07 17:39:52 UTC (rev 161429)
+++ trunk/LayoutTests/ChangeLog        2014-01-07 17:49:04 UTC (rev 161430)
</span><span class="lines">@@ -1,3 +1,18 @@
</span><ins>+2014-01-07 Frédéric Wang <fred.wang@free.fr>
+
+ Add Support for the semantics element.
+ https://bugs.webkit.org/show_bug.cgi?id=100626
+
+ Reviewed by Chris Fleizach.
+
+ * TestExpectations:
+ * mathml/presentation/semantics-2-expected.html: Added.
+ * mathml/presentation/semantics-2.html: Added.
+ * mathml/presentation/semantics-3-expected.html: Added.
+ * mathml/presentation/semantics-3.html: Added.
+ * mathml/presentation/semantics-4-expected.html: Added.
+ * mathml/presentation/semantics-4.html: Added.
+
</ins><span class="cx"> 2014-01-07 Manuel Rego Casasnovas <rego@igalia.com>
</span><span class="cx">
</span><span class="cx"> [GTK] fast/repaint/repaint-regions-overflow.html is failing
</span></span></pre></div>
<a id="trunkLayoutTestsTestExpectations"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/TestExpectations (161429 => 161430)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/TestExpectations        2014-01-07 17:39:52 UTC (rev 161429)
+++ trunk/LayoutTests/TestExpectations        2014-01-07 17:49:04 UTC (rev 161430)
</span><span class="lines">@@ -21,9 +21,6 @@
</span><span class="cx"> webkit.org/b/57700 mathml/presentation/row.xhtml [ Failure ]
</span><span class="cx"> webkit.org/b/57700 mathml/presentation/mo.xhtml [ Failure ]
</span><span class="cx">
</span><del>-# MathML regression with foreign objects
-webkit.org/b/124128 mathml/presentation/semantics.html [ Skip ]
-
</del><span class="cx"> # These conformace tests are no longer in sync with the latest specification
</span><span class="cx"> # and expect compareDocumentPosition() to return:
</span><span class="cx"> # DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC | DOCUMENT_POSITION_DISCONNECTED
</span></span></pre></div>
<a id="trunkLayoutTestsmathmlpresentationsemantics2expectedhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/mathml/presentation/semantics-2-expected.html (0 => 161430)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/mathml/presentation/semantics-2-expected.html         (rev 0)
+++ trunk/LayoutTests/mathml/presentation/semantics-2-expected.html        2014-01-07 17:49:04 UTC (rev 161430)
</span><span class="lines">@@ -0,0 +1,15 @@
</span><ins>+<!doctype html>
+<html>
+<head>
+ <title>Semantics</title>
+</head>
+
+<body>
+ <p>presentation MathML (no annotations): <math><mrow><mtext>presentation MathML</mtext></mrow></math></p>
+ <p>content MathML (no annotations): <math><maction actiontype="toggle"><csymbol>content MathML</csymbol></maction></math></p>
+ <p>presentation MathML ; annotation: <math><mrow><mtext>presentation MathML</mtext></mrow></math></p>
+ <p>presentation MathML ; annotation-xml: <math><mrow><mtext>presentation MathML</mtext></mrow></math></p>
+ <p>content MathML ; annotation: <math><mrow><mtext>annotation</mtext></mrow></math></p>
+ <p>content MathML ; annotation-xml: <math><mrow><mrow><mtext>annotation-xml</mtext></mrow></mrow></math></p>
+</body>
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestsmathmlpresentationsemantics2html"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/mathml/presentation/semantics-2.html (0 => 161430)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/mathml/presentation/semantics-2.html         (rev 0)
+++ trunk/LayoutTests/mathml/presentation/semantics-2.html        2014-01-07 17:49:04 UTC (rev 161430)
</span><span class="lines">@@ -0,0 +1,22 @@
</span><ins>+<!doctype html>
+<html>
+<head>
+ <title>Semantics</title>
+</head>
+
+<body>
+
+ <!-- No annotations: the first child is displayed -->
+ <p>presentation MathML (no annotations): <math><semantics><mtext>presentation MathML</mtext></semantics></math></p>
+ <p>content MathML (no annotations): <math><semantics><csymbol>content MathML</csymbol></semantics></math></p>
+
+ <!-- Presentation MathML: the child is displayed -->
+ <p>presentation MathML ; annotation: <math><semantics><mtext>presentation MathML</mtext><annotation>annotation</annotation></semantics></math></p>
+ <p>presentation MathML ; annotation-xml: <math><semantics><mtext>presentation MathML</mtext><annotation-xml encoding="application/mathml-presentation+xml"><mtext>annotation-xml</mtext></annotation-xml></semantics></math></p>
+
+ <!-- Content MathML: the annotation is displayed -->
+ <p>content MathML ; annotation: <math><semantics><csymbol>content MathML</csymbol><annotation>annotation</annotation></semantics></math></p>
+ <p>content MathML ; annotation-xml: <math><semantics><csymbol>content MathML</csymbol><annotation-xml encoding="application/mathml-presentation+xml"><mtext>annotation-xml</mtext></annotation-xml></semantics></math></p>
+
+</body>
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestsmathmlpresentationsemantics3expectedhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/mathml/presentation/semantics-3-expected.html (0 => 161430)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/mathml/presentation/semantics-3-expected.html         (rev 0)
+++ trunk/LayoutTests/mathml/presentation/semantics-3-expected.html        2014-01-07 17:49:04 UTC (rev 161430)
</span><span class="lines">@@ -0,0 +1,19 @@
</span><ins>+<!doctype html>
+<html>
+<head>
+ <title>Semantics</title>
+</head>
+
+<body>
+ <p>annotation 1: <math><mrow><mtext>annotation</mtext></mrow></math></p>
+ <p>annotation 2: <math><mrow><mtext>\sin x + 5</mtext></mrow></math></p>
+ <p>annotation 3: <math><mrow><mtext>annotation</mtext></mrow></math></p>
+
+ <p>annotation-xml 1: <math><mrow><mrow><mtext>application/mathml-presentation+xml</mtext></mrow></mrow></math></p>
+ <p>annotation-xml 2: <math><mrow><mrow><mtext>MathML-Presentation</mtext></mrow></mrow></math></p>
+ <p>annotation-xml 3: <math><semantics><annotation-xml encoding="image/svg+xml"><svg width="20px" height="20px"><rect width="20px" height="20px" fill="red" stroke="none"/></svg></annotation-xml></semantics></math></p>
+ <p>annotation-xml 4: <math><semantics><annotation-xml encoding="image/svg+xml"><svg width="20px" height="20px"><rect width="20px" height="20px" fill="red" stroke="none"/></svg></annotation-xml></semantics></math></p>
+ <p>annotation-xml 5: <math><semantics><annotation-xml encoding="application/xhtml+xml"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>application/xhtml+xml</title></head><body><p>application/xhtml+xml</p></body></html></annotation-xml></math></p>
+ <p>annotation-xml 6: <math><semantics><annotation-xml encoding="application/xhtml+xml"><html><head><title>text/html</title></head><body><p>text/html</p></body></html></annotation-xml></semantics></math></p>
+ <p>annotation-xml 7: <math><mrow><mrow><mtext>annotation-xml</mtext></mrow></mrow></math></p></body>
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestsmathmlpresentationsemantics3html"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/mathml/presentation/semantics-3.html (0 => 161430)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/mathml/presentation/semantics-3.html         (rev 0)
+++ trunk/LayoutTests/mathml/presentation/semantics-3.html        2014-01-07 17:49:04 UTC (rev 161430)
</span><span class="lines">@@ -0,0 +1,26 @@
</span><ins>+<!doctype html>
+<html>
+<head>
+ <title>Semantics</title>
+</head>
+
+<body>
+
+ <!-- These <semantics> elements are content MathML expressions with various annotations. Only the first recognized annotation should be displayed. WebKit recognizes the following annotations:
+ - Any <annotation> element without src attribute.
+ - An <annotation-xml> element without src attribute and with one of the encoding among "application/mathml-presentation+xml", "MathML-Presentation", "image/svg+xml", "SVG1.1", "application/xhtml+xml" and "text/html".
+ -->
+
+ <p>annotation 1: <math><semantics><csymbol>Content MathML</csymbol><annotation>annotation</annotation><annotation>error</annotation><annotation-xml encoding="application/mathml-presentation+xml"><mtext>error</mtext></annotation-xml></semantics></math></p>
+ <p>annotation 2: <math><semantics><csymbol>Content MathML</csymbol><annotation encoding="application/x-tex">\sin x + 5</annotation><annotation>error</annotation><annotation-xml encoding="application/mathml-presentation+xml"><mtext>error</mtext></annotation-xml></semantics></math></p>
+ <p>annotation 3: <math><semantics><csymbol>Content MathML</csymbol><annotation src="external-resource">error</annotation><annotation>annotation</annotation><annotation-xml encoding="application/mathml-presentation+xml"><mtext>error</mtext></annotation-xml></semantics></math></p>
+
+ <p>annotation-xml 1: <math><semantics><csymbol>Content MathML</csymbol><annotation-xml encoding="application/mathml-presentation+xml"><mtext>application/mathml-presentation+xml</mtext></annotation-xml><annotation-xml encoding="application/mathml-presentation+xml"><mtext>error</mtext></annotation-xml><annotation>error</annotation></semantics></math></p>
+ <p>annotation-xml 2: <math><semantics><csymbol>Content MathML</csymbol><annotation-xml encoding="MathML-Presentation"><mtext>MathML-Presentation</mtext></annotation-xml><annotation-xml encoding="application/mathml-presentation+xml"><mtext>error</mtext></annotation-xml><annotation>error</annotation></semantics></math></p>
+ <p>annotation-xml 3: <math><semantics><csymbol>Content MathML</csymbol><annotation-xml encoding="image/svg+xml"><svg width="20px" height="20px"><rect width="20px" height="20px" fill="red" stroke="none"/></svg></annotation-xml><annotation-xml encoding="application/mathml-presentation+xml"><mtext>error</mtext></annotation-xml><annotation>error</annotation></semantics></math></p>
+ <p>annotation-xml 4: <math><semantics><csymbol>Content MathML</csymbol><annotation-xml encoding="SVG1.1"><svg width="20px" height="20px"><rect width="20px" height="20px" fill="red" stroke="none"/></svg></annotation-xml><annotation-xml encoding="application/mathml-presentation+xml"><mtext>error</mtext></annotation-xml><annotation>error</annotation></semantics></math></p>
+ <p>annotation-xml 5: <math><semantics><csymbol>Content MathML</csymbol><annotation-xml encoding="application/xhtml+xml"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>application/xhtml+xml</title></head><body><p>application/xhtml+xml</p></body></html></annotation-xml><annotation-xml encoding="application/mathml-presentation+xml"><mtext>error</mtext></annotation-xml><annotation>error</annotation></math></p>
+ <p>annotation-xml 6: <math><semantics><csymbol>Content MathML</csymbol><annotation-xml encoding="text/html"><html><head><title>text/html</title></head><body><p>text/html</p></body></html></annotation-xml><annotation-xml encoding="application/mathml-presentation+xml"><mtext>error</mtext></annotation-xml><annotation>error</annotation></semantics></math></p>
+ <p>annotation-xml 7: <math><semantics><csymbol>Content MathML</csymbol><annotation-xml encoding="unknown"><mtext>error</mtext></annotation-xml><annotation-xml encoding="application/mathml+xml"><mtext>error</mtext></annotation-xml><annotation-xml encoding="application/mathml-presentation+xml"><mtext>annotation-xml</mtext></annotation-xml><annotation>error</annotation></semantics></math></p>
+</body>
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestsmathmlpresentationsemantics4expectedhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/mathml/presentation/semantics-4-expected.html (0 => 161430)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/mathml/presentation/semantics-4-expected.html         (rev 0)
+++ trunk/LayoutTests/mathml/presentation/semantics-4-expected.html        2014-01-07 17:49:04 UTC (rev 161430)
</span><span class="lines">@@ -0,0 +1,12 @@
</span><ins>+<!doctype html>
+<html>
+<head>
+ <title>Semantics</title>
+</head>
+
+<body>
+
+ <p><math><mrow><mrow id="a"><mtext>PASS</mtext></mrow></mrow></math></p>
+
+</body>
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestsmathmlpresentationsemantics4html"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/mathml/presentation/semantics-4.html (0 => 161430)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/mathml/presentation/semantics-4.html         (rev 0)
+++ trunk/LayoutTests/mathml/presentation/semantics-4.html        2014-01-07 17:49:04 UTC (rev 161430)
</span><span class="lines">@@ -0,0 +1,14 @@
</span><ins>+<!doctype html>
+<html>
+<head>
+ <title>Semantics</title>
+</head>
+
+<body onload="document.getElementById('a').setAttribute('encoding', 'MathML-Presentation')">
+
+ <!-- This test verifies that setting the encoding dynamically updates the selected annotation. This should render the same as the static reference. -->
+
+ <p><math><semantics><csymbol>Content MathML</csymbol><annotation-xml id="a"><mtext>PASS</mtext></annotation-xml><annotation>FAIL</annotation></semantics></math></p>
+
+</body>
+</html>
</ins></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (161429 => 161430)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2014-01-07 17:39:52 UTC (rev 161429)
+++ trunk/Source/WebCore/ChangeLog        2014-01-07 17:49:04 UTC (rev 161430)
</span><span class="lines">@@ -1,3 +1,38 @@
</span><ins>+2014-01-07 Frédéric Wang <fred.wang@free.fr>
+
+ Add Support for the semantics element.
+ https://bugs.webkit.org/show_bug.cgi?id=100626
+
+
+ Reviewed by Chris Fleizach.
+
+ Tests: mathml/presentation/semantics-2.html
+ mathml/presentation/semantics-3.html
+ mathml/presentation/semantics-4.html
+
+ This provides a complete support for the semantics element. When the first child is a content MathML, an annotation can be selected and displayed. The selection algorithm is identical to Gecko's one. The recognized annotations are text (e.g. LaTeX), presentation MathML, SVG and HTML.
+
+ * mathml/MathMLElement.cpp:
+ (WebCore::MathMLElement::childShouldCreateRenderer):
+ (WebCore::MathMLElement::attributeChanged):
+ (WebCore::MathMLElement::isPresentationMathML):
+ * mathml/MathMLElement.h:
+ (WebCore::MathMLElement::isMathMLToken):
+ (WebCore::MathMLElement::isSemanticAnnotation):
+ (WebCore::MathMLElement::isPresentationMathML):
+ (WebCore::MathMLElement::updateSelectedChild):
+ * mathml/MathMLInlineContainerElement.h:
+ * mathml/MathMLSelectElement.cpp:
+ (WebCore::MathMLSelectElement::getSelectedActionChildAndIndex):
+ (WebCore::MathMLSelectElement::getSelectedActionChild):
+ (WebCore::MathMLSelectElement::getSelectedSemanticsChild):
+ (WebCore::MathMLSelectElement::updateSelectedChild):
+ (WebCore::MathMLSelectElement::toggle):
+ * mathml/MathMLSelectElement.h:
+ * mathml/MathMLTextElement.h:
+ * mathml/mathattrs.in:
+ * mathml/mathtags.in:
+
</ins><span class="cx"> 2014-01-07 Pascal Jacquemart <p.jacquemart@samsung.com>
</span><span class="cx">
</span><span class="cx"> Fix compilation issue with GLES2 after http://webkit.org/b/126548
</span></span></pre></div>
<a id="trunkSourceWebCoremathmlMathMLElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/mathml/MathMLElement.cpp (161429 => 161430)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/mathml/MathMLElement.cpp        2014-01-07 17:39:52 UTC (rev 161429)
+++ trunk/Source/WebCore/mathml/MathMLElement.cpp        2014-01-07 17:49:04 UTC (rev 161430)
</span><span class="lines">@@ -48,6 +48,11 @@
</span><span class="cx"> return adoptRef(new MathMLElement(tagName, document));
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+bool MathMLElement::isPresentationMathML() const
+{
+ return hasTagName(MathMLNames::mtrTag) || hasTagName(MathMLNames::mtdTag) || hasTagName(MathMLNames::maligngroupTag) || hasTagName(MathMLNames::malignmarkTag) || hasTagName(MathMLNames::mencloseTag) || hasTagName(MathMLNames::mglyphTag) || hasTagName(MathMLNames::mlabeledtrTag) || hasTagName(MathMLNames::mlongdivTag) || hasTagName(MathMLNames::mpaddedTag) || hasTagName(MathMLNames::msTag) || hasTagName(MathMLNames::mscarriesTag) || hasTagName(MathMLNames::mscarryTag) || hasTagName(MathMLNames::msgroupTag) || hasTagName(MathMLNames::mslineTag) || hasTagName(MathMLNames::msrowTag) || hasTagName(MathMLNames::mstackTag);
+}
+
</ins><span class="cx"> int MathMLElement::colSpan() const
</span><span class="cx"> {
</span><span class="cx"> if (!hasTagName(mtdTag))
</span><span class="lines">@@ -118,13 +123,23 @@
</span><span class="cx">
</span><span class="cx"> bool MathMLElement::childShouldCreateRenderer(const Node& child) const
</span><span class="cx"> {
</span><ins>+ if (hasTagName(annotationTag))
+ return child.isTextNode();
+ if (hasTagName(annotation_xmlTag))
+ return StyledElement::childShouldCreateRenderer(child);
+
</ins><span class="cx"> // Only create renderers for MathML elements or text. MathML prohibits non-MathML markup inside a <math> element.
</span><span class="cx"> return child.isTextNode() || child.isMathMLElement();
</span><span class="cx"> }
</span><span class="cx">
</span><del>-bool MathMLElement::isMathMLToken() const
</del><ins>+void MathMLElement::attributeChanged(const QualifiedName& name, const AtomicString& newValue, AttributeModificationReason reason)
</ins><span class="cx"> {
</span><del>- return hasTagName(miTag) || hasTagName(mnTag) || hasTagName(moTag) || hasTagName(msTag) || hasTagName(mtextTag);
</del><ins>+ if (isSemanticAnnotation() && (name == MathMLNames::srcAttr || name == MathMLNames::encodingAttr)) {
+ Element* parent = parentElement();
+ if (parent && parent->isMathMLElement() && parent->hasTagName(semanticsTag))
+ toMathMLElement(parent)->updateSelectedChild();
+ }
+ StyledElement::attributeChanged(name, newValue, reason);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCoremathmlMathMLElementh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/mathml/MathMLElement.h (161429 => 161430)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/mathml/MathMLElement.h        2014-01-07 17:39:52 UTC (rev 161429)
+++ trunk/Source/WebCore/mathml/MathMLElement.h        2014-01-07 17:49:04 UTC (rev 161430)
</span><span class="lines">@@ -30,6 +30,7 @@
</span><span class="cx">
</span><span class="cx"> #if ENABLE(MATHML)
</span><span class="cx">
</span><ins>+#include "MathMLNames.h"
</ins><span class="cx"> #include "StyledElement.h"
</span><span class="cx">
</span><span class="cx"> namespace WebCore {
</span><span class="lines">@@ -41,17 +42,30 @@
</span><span class="cx"> int colSpan() const;
</span><span class="cx"> int rowSpan() const;
</span><span class="cx">
</span><ins>+ bool isMathMLToken() const
+ {
+ return hasTagName(MathMLNames::miTag) || hasTagName(MathMLNames::mnTag) || hasTagName(MathMLNames::moTag) || hasTagName(MathMLNames::msTag) || hasTagName(MathMLNames::mtextTag);
+ }
+
+ bool isSemanticAnnotation() const
+ {
+ return hasTagName(MathMLNames::annotationTag) || hasTagName(MathMLNames::annotation_xmlTag);
+ }
+
+ virtual bool isPresentationMathML() const;
+
</ins><span class="cx"> protected:
</span><span class="cx"> MathMLElement(const QualifiedName& tagName, Document&);
</span><span class="cx">
</span><span class="cx"> virtual void parseAttribute(const QualifiedName&, const AtomicString&) OVERRIDE;
</span><span class="cx"> virtual bool childShouldCreateRenderer(const Node&) const OVERRIDE;
</span><ins>+ virtual void attributeChanged(const QualifiedName&, const AtomicString& newValue, AttributeModificationReason) OVERRIDE;
</ins><span class="cx">
</span><span class="cx"> private:
</span><span class="cx"> virtual bool isPresentationAttribute(const QualifiedName&) const OVERRIDE;
</span><span class="cx"> virtual void collectStyleForPresentationAttribute(const QualifiedName&, const AtomicString&, MutableStyleProperties&) OVERRIDE;
</span><span class="cx">
</span><del>- inline bool isMathMLToken() const;
</del><ins>+ virtual void updateSelectedChild() { };
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> void isMathMLElement(const MathMLElement&); // Catch unnecessary runtime check of type known at compile time.
</span></span></pre></div>
<a id="trunkSourceWebCoremathmlMathMLInlineContainerElementh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/mathml/MathMLInlineContainerElement.h (161429 => 161430)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/mathml/MathMLInlineContainerElement.h        2014-01-07 17:39:52 UTC (rev 161429)
+++ trunk/Source/WebCore/mathml/MathMLInlineContainerElement.h        2014-01-07 17:49:04 UTC (rev 161430)
</span><span class="lines">@@ -36,6 +36,8 @@
</span><span class="cx"> public:
</span><span class="cx"> static PassRefPtr<MathMLInlineContainerElement> create(const QualifiedName& tagName, Document&);
</span><span class="cx">
</span><ins>+ virtual bool isPresentationMathML() const OVERRIDE { return true; }
+
</ins><span class="cx"> protected:
</span><span class="cx"> MathMLInlineContainerElement(const QualifiedName& tagName, Document&);
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCoremathmlMathMLSelectElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/mathml/MathMLSelectElement.cpp (161429 => 161430)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/mathml/MathMLSelectElement.cpp        2014-01-07 17:39:52 UTC (rev 161429)
+++ trunk/Source/WebCore/mathml/MathMLSelectElement.cpp        2014-01-07 17:49:04 UTC (rev 161430)
</span><span class="lines">@@ -77,8 +77,10 @@
</span><span class="cx"> MathMLInlineContainerElement::attributeChanged(name, newValue, reason);
</span><span class="cx"> }
</span><span class="cx">
</span><del>-int MathMLSelectElement::getSelectedChildAndIndex(Element*& selectedChild)
</del><ins>+int MathMLSelectElement::getSelectedActionChildAndIndex(Element*& selectedChild)
</ins><span class="cx"> {
</span><ins>+ ASSERT(hasLocalName(actionTag));
+
</ins><span class="cx"> // We "round up or down to the closest allowable value" of the selection attribute, as suggested by the MathML specification.
</span><span class="cx"> selectedChild = firstElementChild();
</span><span class="cx"> if (!selectedChild)
</span><span class="lines">@@ -96,30 +98,85 @@
</span><span class="cx"> return i;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void MathMLSelectElement::updateSelectedChild()
</del><ins>+Element* MathMLSelectElement::getSelectedActionChild()
</ins><span class="cx"> {
</span><del>- Element* newSelectedChild = firstElementChild();
</del><ins>+ ASSERT(hasLocalName(actionTag));
</ins><span class="cx">
</span><del>- if (newSelectedChild) {
- if (hasLocalName(mactionTag)) {
- // The value of the actiontype attribute is case-sensitive.
- const AtomicString& actiontype = fastGetAttribute(MathMLNames::actiontypeAttr);
- if (actiontype == "statusline")
- // FIXME: implement user interaction for the "statusline" action type (http://wkbug/124922).
- { }
- else if (actiontype == "tooltip")
- // FIXME: implement user interaction for the "tooltip" action type (http://wkbug/124921).
- { }
- else {
- // For the "toggle" action type or any unknown action type, we rely on the value of the selection attribute to determine the visible child.
- getSelectedChildAndIndex(newSelectedChild);
- }
- } else {
- ASSERT(hasLocalName(semanticsTag));
- // FIXME: implement Gecko's selection algorithm for <semantics> (http://wkbug/100626).
</del><ins>+ Element* child = firstElementChild();
+ if (!child)
+ return child;
+
+ // The value of the actiontype attribute is case-sensitive.
+ const AtomicString& actiontype = fastGetAttribute(MathMLNames::actiontypeAttr);
+ if (actiontype == "statusline")
+ // FIXME: implement user interaction for the "statusline" action type (http://wkbug/124922).
+ { }
+ else if (actiontype == "tooltip")
+ // FIXME: implement user interaction for the "tooltip" action type (http://wkbug/124921).
+ { }
+ else {
+ // For the "toggle" action type or any unknown action type, we rely on the value of the selection attribute to determine the visible child.
+ getSelectedActionChildAndIndex(child);
+ }
+
+ return child;
+}
+
+Element* MathMLSelectElement::getSelectedSemanticsChild()
+{
+ ASSERT(hasLocalName(semanticsTag));
+
+ Element* child = firstElementChild();
+ if (!child)
+ return child;
+
+ if (!child->isMathMLElement() || !toMathMLElement(child)->isPresentationMathML()) {
+ // The first child is not a presentation MathML element. Hence we move to the second child and start searching an annotation child that could be displayed.
+ child = child->nextElementSibling();
+ } else if (!toMathMLElement(child)->isSemanticAnnotation()) {
+ // The first child is a presentation MathML but not an annotation, so we can just display it.
+ return child;
+ }
+ // Otherwise, the first child is an <annotation> or <annotation-xml> element. This is invalid, but some people use this syntax so we take care of this case too and start the search from this first child.
+
+ for ( ; child; child = child->nextElementSibling()) {
+ if (!child->isMathMLElement())
+ continue;
+
+ if (child->hasLocalName(MathMLNames::annotationTag)) {
+ // If the <annotation> element has an src attribute then it is a reference to arbitrary binary data and it is not clear whether we can display it. Hence we just ignore the annotation.
+ if (child->hasAttribute(MathMLNames::srcAttr))
+ continue;
+ // Otherwise, we assume it is a text annotation that can always be displayed and we stop here.
+ return child;
</ins><span class="cx"> }
</span><ins>+
+ if (child->hasLocalName(MathMLNames::annotation_xmlTag)) {
+ // If the <annotation-xml> element has an src attribute then it is a reference to arbitrary binary data and it is not clear whether we can display it. Hence we just ignore the annotation.
+ if (child->hasAttribute(MathMLNames::srcAttr))
+ continue;
+ // If the <annotation-xml> element has an encoding attribute describing presentation MathML, SVG or HTML we assume the content can be displayed and we stop here. We recognize the following encoding values:
+ //
+ // - "MathML-Presentation", which is mentioned in the MathML 3 recommendation.
+ // - "SVG1.1" which is mentioned in the W3C note.
+ // http://www.w3.org/Math/Documents/Notes/graphics.xml
+ // - Other MIME Content-Types for SVG and HTML.
+ //
+ // We exclude "application/mathml+xml" which is ambiguous about whether it is Presentation or Content MathML. Authors must use a more explicit encoding value.
+ const AtomicString& value = child->fastGetAttribute(MathMLNames::encodingAttr);
+ if (value == "application/mathml-presentation+xml" || value == "MathML-Presentation" || value == "image/svg+xml" || value == "SVG1.1" || value == "application/xhtml+xml" || value == "text/html")
+ return child;
+ }
</ins><span class="cx"> }
</span><span class="cx">
</span><ins>+ // We fallback to the first child.
+ return firstElementChild();
+}
+
+void MathMLSelectElement::updateSelectedChild()
+{
+ Element* newSelectedChild = hasLocalName(mactionTag) ? getSelectedActionChild() : getSelectedSemanticsChild();
+
</ins><span class="cx"> if (m_selectedChild == newSelectedChild)
</span><span class="cx"> return;
</span><span class="cx">
</span><span class="lines">@@ -153,7 +210,7 @@
</span><span class="cx"> // Select the successor of the currently selected child
</span><span class="cx"> // or the first child if the currently selected child is the last.
</span><span class="cx"> Element* selectedChild;
</span><del>- int newSelectedChildIndex = getSelectedChildAndIndex(selectedChild) + 1;
</del><ins>+ int newSelectedChildIndex = getSelectedActionChildAndIndex(selectedChild) + 1;
</ins><span class="cx"> if (!selectedChild || !selectedChild->nextElementSibling())
</span><span class="cx"> newSelectedChildIndex = 1;
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCoremathmlMathMLSelectElementh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/mathml/MathMLSelectElement.h (161429 => 161430)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/mathml/MathMLSelectElement.h        2014-01-07 17:39:52 UTC (rev 161429)
+++ trunk/Source/WebCore/mathml/MathMLSelectElement.h        2014-01-07 17:49:04 UTC (rev 161430)
</span><span class="lines">@@ -48,9 +48,11 @@
</span><span class="cx"> virtual bool willRespondToMouseClickEvents() OVERRIDE;
</span><span class="cx">
</span><span class="cx"> void toggle();
</span><del>- int getSelectedChildAndIndex(Element*& selectedChild);
</del><ins>+ int getSelectedActionChildAndIndex(Element*& selectedChild);
+ Element* getSelectedActionChild();
+ Element* getSelectedSemanticsChild();
</ins><span class="cx">
</span><del>- void updateSelectedChild();
</del><ins>+ void updateSelectedChild() OVERRIDE;
</ins><span class="cx"> Element* m_selectedChild;
</span><span class="cx"> };
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCoremathmlMathMLTextElementh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/mathml/MathMLTextElement.h (161429 => 161430)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/mathml/MathMLTextElement.h        2014-01-07 17:39:52 UTC (rev 161429)
+++ trunk/Source/WebCore/mathml/MathMLTextElement.h        2014-01-07 17:49:04 UTC (rev 161430)
</span><span class="lines">@@ -37,6 +37,8 @@
</span><span class="cx"> static PassRefPtr<MathMLTextElement> create(const QualifiedName& tagName, Document&);
</span><span class="cx"> virtual void didAttachRenderers() OVERRIDE;
</span><span class="cx">
</span><ins>+ virtual bool isPresentationMathML() const OVERRIDE { return true; }
+
</ins><span class="cx"> private:
</span><span class="cx"> MathMLTextElement(const QualifiedName& tagName, Document&);
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCoremathmlmathattrsin"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/mathml/mathattrs.in (161429 => 161430)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/mathml/mathattrs.in        2014-01-07 17:39:52 UTC (rev 161429)
+++ trunk/Source/WebCore/mathml/mathattrs.in        2014-01-07 17:49:04 UTC (rev 161430)
</span><span class="lines">@@ -29,6 +29,7 @@
</span><span class="cx"> rowspan
</span><span class="cx"> selection
</span><span class="cx"> separators
</span><ins>+src
</ins><span class="cx"> stretchy
</span><span class="cx"> subscriptshift
</span><span class="cx"> superscriptshift
</span></span></pre></div>
<a id="trunkSourceWebCoremathmlmathtagsin"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/mathml/mathtags.in (161429 => 161430)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/mathml/mathtags.in        2014-01-07 17:39:52 UTC (rev 161429)
+++ trunk/Source/WebCore/mathml/mathtags.in        2014-01-07 17:49:04 UTC (rev 161430)
</span><span class="lines">@@ -34,8 +34,18 @@
</span><span class="cx"> none interfaceName=MathMLInlineContainerElement
</span><span class="cx"> semantics interfaceName=MathMLSelectElement
</span><span class="cx">
</span><del>-#if 0 // Curently only for MathMLNames used by HTMLTreeBuilder.
-ms
-mglyph
-malignmark
-#endif
</del><ins>+# These presentation MathML elements are not implemented.
+maligngroup interfaceName=MathMLElement
+malignmark interfaceName=MathMLElement
+menclose interfaceName=MathMLElement # http://wkbug/85729
+mglyph interfaceName=MathMLElement
+mlabeledtr interfaceName=MathMLElement # http://wkbug/85732
+mlongdiv interfaceName=MathMLElement
+mpadded interfaceName=MathMLElement # http://wkbug/85730
+ms interfaceName=MathMLElement # http://wkbug/125859
+mscarries interfaceName=MathMLElement
+mscarry interfaceName=MathMLElement
+msgroup interfaceName=MathMLElement
+msline interfaceName=MathMLElement
+msrow interfaceName=MathMLElement
+mstack interfaceName=MathMLElement
</ins></span></pre>
</div>
</div>
</body>
</html>