<!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>[165702] 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/165702">165702</a></dd>
<dt>Author</dt> <dd>fred.wang@free.fr</dd>
<dt>Date</dt> <dd>2014-03-16 10:33:48 -0700 (Sun, 16 Mar 2014)</dd>
</dl>
<h3>Log Message</h3>
<pre>[regression] foreign content not displayed in MathML
<https://webkit.org/b/124128>
Reviewed by Chris Fleizach.
Source/WebCore:
This restores foreign content in <mtext>, <mn> and <mi> elements, but only when it is "phrasing content" as defined per the HTML5 specification. Other token elements are not handled here. This change makes mspace-units.html work again on Linux.
Tests: mathml/presentation/foreign-mi-dynamic.html
mathml/presentation/foreign-mi.html
mathml/presentation/foreign-mn.html
mathml/presentation/foreign-mtext-rejected.html
mathml/presentation/foreign-mtext.html
* mathml/MathMLTextElement.cpp:
(WebCore::MathMLTextElement::createElementRenderer): create a RenderMathMLToken for mn, ms and mtext.
(WebCore::isPhrasingContent): helper function to check phrasing content, as defined by the HTML spec.
(WebCore::MathMLTextElement::childShouldCreateRenderer): <mi>, <mn>, <mtext> and, <ms> now accepts phrasing content.
* rendering/mathml/RenderMathMLToken.cpp:
(WebCore::RenderMathMLToken::RenderMathMLToken):
(WebCore::RenderMathMLToken::updateTokenContent): initialize the m_containsElement boolean when updating the token content.
(WebCore::RenderMathMLToken::updateStyle): move <mi> specific handling in its own section and only apply the single-char rule when it does not contain elements.
* rendering/mathml/RenderMathMLToken.h: add an m_containsElement boolean to handle token element specifically.
LayoutTests:
* mathml/presentation/foreign-mi-dynamic-expected.html: Added.
* mathml/presentation/foreign-mi-dynamic.html: Added.
* mathml/presentation/foreign-mi-expected-mismatch.html: Added.
* mathml/presentation/foreign-mi.html: Added.
* mathml/presentation/foreign-mn-expected-mismatch.html: Added.
* mathml/presentation/foreign-mn.html: Added.
* mathml/presentation/foreign-mtext-expected-mismatch.html: Added.
* mathml/presentation/foreign-mtext-rejected-expected.html: Added.
* mathml/presentation/foreign-mtext-rejected.html: Added.
* mathml/presentation/foreign-mtext.html: Added.
* platform/efl/TestExpectations: reenable the test.
* platform/gtk/TestExpectations: ditto.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsplatformeflTestExpectations">trunk/LayoutTests/platform/efl/TestExpectations</a></li>
<li><a href="#trunkLayoutTestsplatformgtkTestExpectations">trunk/LayoutTests/platform/gtk/TestExpectations</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoremathmlMathMLTextElementcpp">trunk/Source/WebCore/mathml/MathMLTextElement.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingmathmlRenderMathMLTokencpp">trunk/Source/WebCore/rendering/mathml/RenderMathMLToken.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingmathmlRenderMathMLTokenh">trunk/Source/WebCore/rendering/mathml/RenderMathMLToken.h</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsmathmlpresentationforeignmidynamicexpectedhtml">trunk/LayoutTests/mathml/presentation/foreign-mi-dynamic-expected.html</a></li>
<li><a href="#trunkLayoutTestsmathmlpresentationforeignmidynamichtml">trunk/LayoutTests/mathml/presentation/foreign-mi-dynamic.html</a></li>
<li><a href="#trunkLayoutTestsmathmlpresentationforeignmiexpectedmismatchhtml">trunk/LayoutTests/mathml/presentation/foreign-mi-expected-mismatch.html</a></li>
<li><a href="#trunkLayoutTestsmathmlpresentationforeignmihtml">trunk/LayoutTests/mathml/presentation/foreign-mi.html</a></li>
<li><a href="#trunkLayoutTestsmathmlpresentationforeignmnexpectedmismatchhtml">trunk/LayoutTests/mathml/presentation/foreign-mn-expected-mismatch.html</a></li>
<li><a href="#trunkLayoutTestsmathmlpresentationforeignmnhtml">trunk/LayoutTests/mathml/presentation/foreign-mn.html</a></li>
<li><a href="#trunkLayoutTestsmathmlpresentationforeignmtextexpectedmismatchhtml">trunk/LayoutTests/mathml/presentation/foreign-mtext-expected-mismatch.html</a></li>
<li><a href="#trunkLayoutTestsmathmlpresentationforeignmtextrejectedexpectedhtml">trunk/LayoutTests/mathml/presentation/foreign-mtext-rejected-expected.html</a></li>
<li><a href="#trunkLayoutTestsmathmlpresentationforeignmtextrejectedhtml">trunk/LayoutTests/mathml/presentation/foreign-mtext-rejected.html</a></li>
<li><a href="#trunkLayoutTestsmathmlpresentationforeignmtexthtml">trunk/LayoutTests/mathml/presentation/foreign-mtext.html</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (165701 => 165702)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2014-03-16 17:05:15 UTC (rev 165701)
+++ trunk/LayoutTests/ChangeLog        2014-03-16 17:33:48 UTC (rev 165702)
</span><span class="lines">@@ -1,3 +1,23 @@
</span><ins>+2014-03-16 Frédéric Wang <fred.wang@free.fr>
+
+ [regression] foreign content not displayed in MathML
+ <https://webkit.org/b/124128>
+
+ Reviewed by Chris Fleizach.
+
+ * mathml/presentation/foreign-mi-dynamic-expected.html: Added.
+ * mathml/presentation/foreign-mi-dynamic.html: Added.
+ * mathml/presentation/foreign-mi-expected-mismatch.html: Added.
+ * mathml/presentation/foreign-mi.html: Added.
+ * mathml/presentation/foreign-mn-expected-mismatch.html: Added.
+ * mathml/presentation/foreign-mn.html: Added.
+ * mathml/presentation/foreign-mtext-expected-mismatch.html: Added.
+ * mathml/presentation/foreign-mtext-rejected-expected.html: Added.
+ * mathml/presentation/foreign-mtext-rejected.html: Added.
+ * mathml/presentation/foreign-mtext.html: Added.
+ * platform/efl/TestExpectations: reenable the test.
+ * platform/gtk/TestExpectations: ditto.
+
</ins><span class="cx"> 2014-03-14 Oliver Hunt <oliver@apple.com>
</span><span class="cx">
</span><span class="cx"> Reinstate intialiser syntax in for-in loops
</span></span></pre></div>
<a id="trunkLayoutTestsmathmlpresentationforeignmidynamicexpectedhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/mathml/presentation/foreign-mi-dynamic-expected.html (0 => 165702)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/mathml/presentation/foreign-mi-dynamic-expected.html         (rev 0)
+++ trunk/LayoutTests/mathml/presentation/foreign-mi-dynamic-expected.html        2014-03-16 17:33:48 UTC (rev 165702)
</span><span class="lines">@@ -0,0 +1,18 @@
</span><ins>+<!doctype html>
+<html>
+ <head>
+ <title>Foreign content in mi</title>
+ </head>
+
+ <body>
+
+ <math><mi>x<span></span></mi></math>
+
+ <math><mi>sin<span></span></mi></math>
+
+ <math><mi>x</mi></math>
+
+ <math><mi>sin</mi></math>
+
+ </body>
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestsmathmlpresentationforeignmidynamichtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/mathml/presentation/foreign-mi-dynamic.html (0 => 165702)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/mathml/presentation/foreign-mi-dynamic.html         (rev 0)
+++ trunk/LayoutTests/mathml/presentation/foreign-mi-dynamic.html        2014-03-16 17:33:48 UTC (rev 165702)
</span><span class="lines">@@ -0,0 +1,37 @@
</span><ins>+<!doctype html>
+<html>
+ <head>
+ <title>Foreign content in mi</title>
+ <script type="text/javascript">
+ function test()
+ {
+ var span1 = document.createElement("span");
+ document.getElementById("mi1").appendChild(span1);
+
+ var span2 = document.createElement("span");
+ document.getElementById("mi2").appendChild(span2);
+
+ span1 = document.getElementById("span1");
+ span1.parentNode.removeChild(span1);
+
+ span2 = document.getElementById("span2");
+ span2.parentNode.removeChild(span2);
+ }
+
+ </script>
+ </head>
+
+ <body onload="test()">
+
+ <!-- This should render the same as the static reference. -->
+
+ <math><mi id="mi1">x</mi></math>
+
+ <math><mi id="mi2">sin</mi></math>
+
+ <math><mi>x<span id="span1"></span></mi></math>
+
+ <math><mi>sin<span id="span2"></span></mi></math>
+
+ </body>
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestsmathmlpresentationforeignmiexpectedmismatchhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/mathml/presentation/foreign-mi-expected-mismatch.html (0 => 165702)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/mathml/presentation/foreign-mi-expected-mismatch.html         (rev 0)
+++ trunk/LayoutTests/mathml/presentation/foreign-mi-expected-mismatch.html        2014-03-16 17:33:48 UTC (rev 165702)
</span><span class="lines">@@ -0,0 +1,11 @@
</span><ins>+<!doctype html>
+<html>
+ <head>
+ <title>Foreign content in mi</title>
+ </head>
+ <body>
+
+ <math><mi></mi></math>
+
+ </body>
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestsmathmlpresentationforeignmihtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/mathml/presentation/foreign-mi.html (0 => 165702)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/mathml/presentation/foreign-mi.html         (rev 0)
+++ trunk/LayoutTests/mathml/presentation/foreign-mi.html        2014-03-16 17:33:48 UTC (rev 165702)
</span><span class="lines">@@ -0,0 +1,13 @@
</span><ins>+<!doctype html>
+<html>
+ <head>
+ <title>Foreign content in mi</title>
+ </head>
+ <body>
+
+ <!-- The HTML-in-MathML span should be visible. -->
+
+ <math><mi><span>HTML-in-MathML</span></mi></math>
+
+ </body>
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestsmathmlpresentationforeignmnexpectedmismatchhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/mathml/presentation/foreign-mn-expected-mismatch.html (0 => 165702)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/mathml/presentation/foreign-mn-expected-mismatch.html         (rev 0)
+++ trunk/LayoutTests/mathml/presentation/foreign-mn-expected-mismatch.html        2014-03-16 17:33:48 UTC (rev 165702)
</span><span class="lines">@@ -0,0 +1,11 @@
</span><ins>+<!doctype html>
+<html>
+ <head>
+ <title>Foreign content in mn</title>
+ </head>
+ <body>
+
+ <math><mn></mn></math>
+
+ </body>
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestsmathmlpresentationforeignmnhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/mathml/presentation/foreign-mn.html (0 => 165702)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/mathml/presentation/foreign-mn.html         (rev 0)
+++ trunk/LayoutTests/mathml/presentation/foreign-mn.html        2014-03-16 17:33:48 UTC (rev 165702)
</span><span class="lines">@@ -0,0 +1,13 @@
</span><ins>+<!doctype html>
+<html>
+ <head>
+ <title>Foreign content in mn</title>
+ </head>
+ <body>
+
+ <!-- The HTML-in-MathML span should be visible. -->
+
+ <math><mn><span>HTML-in-MathML</span></mn></math>
+
+ </body>
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestsmathmlpresentationforeignmtextexpectedmismatchhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/mathml/presentation/foreign-mtext-expected-mismatch.html (0 => 165702)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/mathml/presentation/foreign-mtext-expected-mismatch.html         (rev 0)
+++ trunk/LayoutTests/mathml/presentation/foreign-mtext-expected-mismatch.html        2014-03-16 17:33:48 UTC (rev 165702)
</span><span class="lines">@@ -0,0 +1,11 @@
</span><ins>+<!doctype html>
+<html>
+ <head>
+ <title>Foreign content in mtext</title>
+ </head>
+ <body>
+
+ <math><mtext></mtext></math>
+
+ </body>
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestsmathmlpresentationforeignmtextrejectedexpectedhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/mathml/presentation/foreign-mtext-rejected-expected.html (0 => 165702)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/mathml/presentation/foreign-mtext-rejected-expected.html         (rev 0)
+++ trunk/LayoutTests/mathml/presentation/foreign-mtext-rejected-expected.html        2014-03-16 17:33:48 UTC (rev 165702)
</span><span class="lines">@@ -0,0 +1,15 @@
</span><ins>+<!doctype html>
+<html>
+ <head>
+ <title>Foreign content in mtext</title>
+ </head>
+ <body>
+
+ _<math><mtext></mtext></math>_
+
+ _<math><mtext></mtext></math>_
+
+ _<math><mtext></mtext></math>_
+
+ </body>
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestsmathmlpresentationforeignmtextrejectedhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/mathml/presentation/foreign-mtext-rejected.html (0 => 165702)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/mathml/presentation/foreign-mtext-rejected.html         (rev 0)
+++ trunk/LayoutTests/mathml/presentation/foreign-mtext-rejected.html        2014-03-16 17:33:48 UTC (rev 165702)
</span><span class="lines">@@ -0,0 +1,17 @@
</span><ins>+<!doctype html>
+<html>
+ <head>
+ <title>Foreign content in mtext</title>
+ </head>
+ <body>
+
+ <!-- These HTML-in-MathML elements are not phrasing content and should be rejected. -->
+
+ _<math><mtext><p>HTML-in-MathML</p></mtext></math>_
+
+ _<math><mtext><div>HTML-in-MathML</div></mtext></math>_
+
+ _<math><mtext><blockquote>HTML-in-MathML</blockquote></mtext></math>_
+
+ </body>
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestsmathmlpresentationforeignmtexthtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/mathml/presentation/foreign-mtext.html (0 => 165702)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/mathml/presentation/foreign-mtext.html         (rev 0)
+++ trunk/LayoutTests/mathml/presentation/foreign-mtext.html        2014-03-16 17:33:48 UTC (rev 165702)
</span><span class="lines">@@ -0,0 +1,13 @@
</span><ins>+<!doctype html>
+<html>
+ <head>
+ <title>Foreign content in mtext</title>
+ </head>
+ <body>
+
+ <!-- The HTML-in-MathML span should be visible. -->
+
+ <math><mtext><span>HTML-in-MathML</span></mtext></math>
+
+ </body>
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestsplatformeflTestExpectations"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/platform/efl/TestExpectations (165701 => 165702)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/efl/TestExpectations        2014-03-16 17:05:15 UTC (rev 165701)
+++ trunk/LayoutTests/platform/efl/TestExpectations        2014-03-16 17:33:48 UTC (rev 165702)
</span><span class="lines">@@ -1705,8 +1705,6 @@
</span><span class="cx">
</span><span class="cx"> webkit.org/b/124658 fast/text/break-word-pre-wrap.html [ ImageOnlyFailure ]
</span><span class="cx">
</span><del>-webkit.org/b/124662 mathml/presentation/mspace-units.html [ ImageOnlyFailure ]
-
</del><span class="cx"> webkit.org/b/124663 media/track/track-legacyapi-with-automatic-mode.html [ Skip ]
</span><span class="cx">
</span><span class="cx"> webkit.org/b/124890 platform/efl/accessibility/media-emits-object-replacement.html [ Failure ]
</span></span></pre></div>
<a id="trunkLayoutTestsplatformgtkTestExpectations"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/platform/gtk/TestExpectations (165701 => 165702)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/gtk/TestExpectations        2014-03-16 17:05:15 UTC (rev 165701)
+++ trunk/LayoutTests/platform/gtk/TestExpectations        2014-03-16 17:33:48 UTC (rev 165702)
</span><span class="lines">@@ -1313,8 +1313,6 @@
</span><span class="cx">
</span><span class="cx"> webkit.org/b/124360 media/video-canvas-drawing-output.html [ Failure ]
</span><span class="cx">
</span><del>-webkit.org/b/124503 mathml/presentation/mspace-units.html [ ImageOnlyFailure ]
-
</del><span class="cx"> webkit.org/b/124504 fast/text/break-word-pre-wrap.html [ ImageOnlyFailure ]
</span><span class="cx">
</span><span class="cx"> webkit.org/b/124507 fast/css3-text/css3-text-decoration/text-decoration-skip/text-decoration-skip-ink.html [ ImageOnlyFailure ]
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (165701 => 165702)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2014-03-16 17:05:15 UTC (rev 165701)
+++ trunk/Source/WebCore/ChangeLog        2014-03-16 17:33:48 UTC (rev 165702)
</span><span class="lines">@@ -1,3 +1,28 @@
</span><ins>+2014-03-16 Frédéric Wang <fred.wang@free.fr>
+
+ [regression] foreign content not displayed in MathML
+ <https://webkit.org/b/124128>
+
+ Reviewed by Chris Fleizach.
+
+ This restores foreign content in <mtext>, <mn> and <mi> elements, but only when it is "phrasing content" as defined per the HTML5 specification. Other token elements are not handled here. This change makes mspace-units.html work again on Linux.
+
+ Tests: mathml/presentation/foreign-mi-dynamic.html
+ mathml/presentation/foreign-mi.html
+ mathml/presentation/foreign-mn.html
+ mathml/presentation/foreign-mtext-rejected.html
+ mathml/presentation/foreign-mtext.html
+
+ * mathml/MathMLTextElement.cpp:
+ (WebCore::MathMLTextElement::createElementRenderer): create a RenderMathMLToken for mn, ms and mtext.
+ (WebCore::isPhrasingContent): helper function to check phrasing content, as defined by the HTML spec.
+ (WebCore::MathMLTextElement::childShouldCreateRenderer): <mi>, <mn>, <mtext> and, <ms> now accepts phrasing content.
+ * rendering/mathml/RenderMathMLToken.cpp:
+ (WebCore::RenderMathMLToken::RenderMathMLToken):
+ (WebCore::RenderMathMLToken::updateTokenContent): initialize the m_containsElement boolean when updating the token content.
+ (WebCore::RenderMathMLToken::updateStyle): move <mi> specific handling in its own section and only apply the single-char rule when it does not contain elements.
+ * rendering/mathml/RenderMathMLToken.h: add an m_containsElement boolean to handle token element specifically.
+
</ins><span class="cx"> 2014-03-16 David Kilzer <ddkilzer@apple.com>
</span><span class="cx">
</span><span class="cx"> PlatformTimeRanges::nearest() truncates closestDelta values from double to float
</span></span></pre></div>
<a id="trunkSourceWebCoremathmlMathMLTextElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/mathml/MathMLTextElement.cpp (165701 => 165702)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/mathml/MathMLTextElement.cpp        2014-03-16 17:05:15 UTC (rev 165701)
+++ trunk/Source/WebCore/mathml/MathMLTextElement.cpp        2014-03-16 17:33:48 UTC (rev 165702)
</span><span class="lines">@@ -30,10 +30,14 @@
</span><span class="cx">
</span><span class="cx"> #include "MathMLTextElement.h"
</span><span class="cx">
</span><ins>+#include "HTMLElement.h"
+#include "HTMLNames.h"
</ins><span class="cx"> #include "MathMLNames.h"
</span><span class="cx"> #include "RenderMathMLOperator.h"
</span><span class="cx"> #include "RenderMathMLSpace.h"
</span><span class="cx"> #include "RenderMathMLToken.h"
</span><ins>+#include "SVGElement.h"
+#include "SVGNames.h"
</ins><span class="cx">
</span><span class="cx"> namespace WebCore {
</span><span class="cx">
</span><span class="lines">@@ -68,17 +72,100 @@
</span><span class="cx"> {
</span><span class="cx"> if (hasTagName(MathMLNames::moTag))
</span><span class="cx"> return createRenderer<RenderMathMLOperator>(*this, std::move(style));
</span><del>- if (hasTagName(MathMLNames::miTag))
- return createRenderer<RenderMathMLToken>(*this, std::move(style));
</del><span class="cx"> if (hasTagName(MathMLNames::mspaceTag))
</span><span class="cx"> return createRenderer<RenderMathMLSpace>(*this, std::move(style));
</span><span class="cx">
</span><del>- return MathMLElement::createElementRenderer(std::move(style));
</del><ins>+ ASSERT(hasTagName(MathMLNames::miTag) || hasTagName(MathMLNames::mnTag) || hasTagName(MathMLNames::msTag) || hasTagName(MathMLNames::mtextTag));
+
+ return createRenderer<RenderMathMLToken>(*this, std::move(style));
</ins><span class="cx"> }
</span><span class="cx">
</span><ins>+static bool isPhrasingContent(const Node& node)
+{
+ // Phrasing content is described in the HTML 5 specification:
+ // http://www.w3.org/TR/html5/dom.html#phrasing-content.
+
+ if (!node.isElementNode())
+ return node.isTextNode();
+
+ auto& element = toElement(node);
+
+ if (element.isMathMLElement()) {
+ auto& mathmlElement = toMathMLElement(element);
+ return mathmlElement.hasTagName(MathMLNames::mathTag);
+ }
+
+ if (element.isSVGElement()) {
+ auto& svgElement = toSVGElement(element);
+ return svgElement.hasTagName(SVGNames::svgTag);
+ }
+
+ if (element.isHTMLElement()) {
+ // FIXME: add the <data> and <time> tags when they are implemented.
+ auto& htmlElement = toHTMLElement(element);
+ return htmlElement.hasTagName(HTMLNames::aTag)
+ || htmlElement.hasTagName(HTMLNames::abbrTag)
+ || htmlElement.hasTagName(HTMLNames::areaTag)
+ || htmlElement.hasTagName(HTMLNames::audioTag)
+ || htmlElement.hasTagName(HTMLNames::bTag)
+ || htmlElement.hasTagName(HTMLNames::bdiTag)
+ || htmlElement.hasTagName(HTMLNames::bdoTag)
+ || htmlElement.hasTagName(HTMLNames::brTag)
+ || htmlElement.hasTagName(HTMLNames::buttonTag)
+ || htmlElement.hasTagName(HTMLNames::canvasTag)
+ || htmlElement.hasTagName(HTMLNames::citeTag)
+ || htmlElement.hasTagName(HTMLNames::codeTag)
+ || htmlElement.hasTagName(HTMLNames::datalistTag)
+ || htmlElement.hasTagName(HTMLNames::delTag)
+ || htmlElement.hasTagName(HTMLNames::dfnTag)
+ || htmlElement.hasTagName(HTMLNames::emTag)
+ || htmlElement.hasTagName(HTMLNames::embedTag)
+ || htmlElement.hasTagName(HTMLNames::iTag)
+ || htmlElement.hasTagName(HTMLNames::iframeTag)
+ || htmlElement.hasTagName(HTMLNames::imgTag)
+ || htmlElement.hasTagName(HTMLNames::inputTag)
+ || htmlElement.hasTagName(HTMLNames::insTag)
+ || htmlElement.hasTagName(HTMLNames::kbdTag)
+ || htmlElement.hasTagName(HTMLNames::keygenTag)
+ || htmlElement.hasTagName(HTMLNames::labelTag)
+ || htmlElement.hasTagName(HTMLNames::mapTag)
+ || htmlElement.hasTagName(HTMLNames::markTag)
+ || htmlElement.hasTagName(HTMLNames::meterTag)
+ || htmlElement.hasTagName(HTMLNames::noscriptTag)
+ || htmlElement.hasTagName(HTMLNames::objectTag)
+ || htmlElement.hasTagName(HTMLNames::outputTag)
+ || htmlElement.hasTagName(HTMLNames::progressTag)
+ || htmlElement.hasTagName(HTMLNames::qTag)
+ || htmlElement.hasTagName(HTMLNames::rubyTag)
+ || htmlElement.hasTagName(HTMLNames::sTag)
+ || htmlElement.hasTagName(HTMLNames::sampTag)
+ || htmlElement.hasTagName(HTMLNames::scriptTag)
+ || htmlElement.hasTagName(HTMLNames::selectTag)
+ || htmlElement.hasTagName(HTMLNames::smallTag)
+ || htmlElement.hasTagName(HTMLNames::spanTag)
+ || htmlElement.hasTagName(HTMLNames::strongTag)
+ || htmlElement.hasTagName(HTMLNames::subTag)
+ || htmlElement.hasTagName(HTMLNames::supTag)
+ || htmlElement.hasTagName(HTMLNames::templateTag)
+ || htmlElement.hasTagName(HTMLNames::textareaTag)
+ || htmlElement.hasTagName(HTMLNames::uTag)
+ || htmlElement.hasTagName(HTMLNames::varTag)
+ || htmlElement.hasTagName(HTMLNames::videoTag)
+ || htmlElement.hasTagName(HTMLNames::wbrTag);
+ }
+
+ return false;
+}
+
</ins><span class="cx"> bool MathMLTextElement::childShouldCreateRenderer(const Node& child) const
</span><span class="cx"> {
</span><del>- return !hasTagName(mspaceTag) && child.isTextNode();
</del><ins>+ // The HTML specification defines <mi>, <mo>, <mn>, <ms> and <mtext> as insertion points.
+
+ // FIXME: phrasing content should be accepted in <mo> elements too (https://bugs.webkit.org/show_bug.cgi?id=130245).
+ if (hasTagName(moTag))
+ return child.isTextNode();
+
+ return !hasTagName(MathMLNames::mspaceTag) && isPhrasingContent(child);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingmathmlRenderMathMLTokencpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/mathml/RenderMathMLToken.cpp (165701 => 165702)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/mathml/RenderMathMLToken.cpp        2014-03-16 17:05:15 UTC (rev 165701)
+++ trunk/Source/WebCore/rendering/mathml/RenderMathMLToken.cpp        2014-03-16 17:33:48 UTC (rev 165702)
</span><span class="lines">@@ -29,6 +29,8 @@
</span><span class="cx"> #if ENABLE(MATHML)
</span><span class="cx">
</span><span class="cx"> #include "MathMLNames.h"
</span><ins>+#include "RenderElement.h"
+#include "RenderIterator.h"
</ins><span class="cx">
</span><span class="cx"> namespace WebCore {
</span><span class="cx">
</span><span class="lines">@@ -36,11 +38,13 @@
</span><span class="cx">
</span><span class="cx"> RenderMathMLToken::RenderMathMLToken(Element& element, PassRef<RenderStyle> style)
</span><span class="cx"> : RenderMathMLBlock(element, std::move(style))
</span><ins>+ , m_containsElement(false)
</ins><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> RenderMathMLToken::RenderMathMLToken(Document& document, PassRef<RenderStyle> style)
</span><span class="cx"> : RenderMathMLBlock(document, std::move(style))
</span><ins>+ , m_containsElement(false)
</ins><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -60,8 +64,16 @@
</span><span class="cx">
</span><span class="cx"> void RenderMathMLToken::updateTokenContent()
</span><span class="cx"> {
</span><del>- if (!isEmpty())
</del><ins>+ m_containsElement = false;
+ if (!isEmpty()) {
+ // The renderers corresponding to the children of the token element are wrapped inside an anonymous RenderMathMLBlock.
+ // When one of these renderers is a RenderElement, we handle the RenderMathMLToken differently.
+ // For some reason, an additional anonymous RenderBlock is created as a child of the RenderMathMLToken and the renderers are actually inserted into that RenderBlock so we need to dig down one additional level here.
+ const auto& wrapper = toRenderElement(firstChild());
+ if (const auto& block = toRenderElement(wrapper->firstChild()))
+ m_containsElement = childrenOfType<RenderElement>(*block).first();
</ins><span class="cx"> updateStyle();
</span><ins>+ }
</ins><span class="cx"> setNeedsLayoutAndPrefWidthsRecalc();
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -69,16 +81,20 @@
</span><span class="cx"> {
</span><span class="cx"> const auto& tokenElement = element();
</span><span class="cx">
</span><del>- // This tries to emulate the default mathvariant value on <mi> using the CSS font-style property.
- // FIXME: This should be revised when mathvariant is implemented (http://wkbug/85735) and when fonts with Mathematical Alphanumeric Symbols characters are more popular.
</del><span class="cx"> const auto& wrapper = toRenderElement(firstChild());
</span><span class="cx"> auto newStyle = RenderStyle::createAnonymousStyleWithDisplay(&style(), FLEX);
</span><del>- FontDescription fontDescription(newStyle.get().fontDescription());
- FontSelector* fontSelector = newStyle.get().font().fontSelector();
- if (element().textContent().stripWhiteSpace().simplifyWhiteSpace().length() == 1 && !tokenElement.hasAttribute(mathvariantAttr))
- fontDescription.setItalic(true);
- if (newStyle.get().setFontDescription(fontDescription))
- newStyle.get().font().update(fontSelector);
</del><ins>+
+ if (tokenElement.hasTagName(MathMLNames::miTag)) {
+ // This tries to emulate the default mathvariant value on <mi> using the CSS font-style property.
+ // FIXME: This should be revised when mathvariant is implemented (http://wkbug/85735) and when fonts with Mathematical Alphanumeric Symbols characters are more popular.
+ FontDescription fontDescription(newStyle.get().fontDescription());
+ FontSelector* fontSelector = newStyle.get().font().fontSelector();
+ if (!m_containsElement && element().textContent().stripWhiteSpace().simplifyWhiteSpace().length() == 1 && !tokenElement.hasAttribute(mathvariantAttr))
+ fontDescription.setItalic(true);
+ if (newStyle.get().setFontDescription(fontDescription))
+ newStyle.get().font().update(fontSelector);
+ }
+
</ins><span class="cx"> wrapper->setStyle(std::move(newStyle));
</span><span class="cx"> wrapper->setNeedsLayoutAndPrefWidthsRecalc();
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingmathmlRenderMathMLTokenh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/mathml/RenderMathMLToken.h (165701 => 165702)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/mathml/RenderMathMLToken.h        2014-03-16 17:05:15 UTC (rev 165701)
+++ trunk/Source/WebCore/rendering/mathml/RenderMathMLToken.h        2014-03-16 17:33:48 UTC (rev 165702)
</span><span class="lines">@@ -54,6 +54,9 @@
</span><span class="cx"> virtual const char* renderName() const override { return isAnonymous() ? "RenderMathMLToken (anonymous)" : "RenderMathMLToken"; }
</span><span class="cx"> virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle) override;
</span><span class="cx"> virtual void updateStyle();
</span><ins>+
+ // This boolean indicates whether the token element contains some RenderElement descendants, other than the anonymous renderers created for layout purpose.
+ bool m_containsElement;
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> RENDER_OBJECT_TYPE_CASTS(RenderMathMLToken, isRenderMathMLToken())
</span></span></pre>
</div>
</div>
</body>
</html>