<!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>[165464] 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/165464">165464</a></dd>
<dt>Author</dt> <dd>fred.wang@free.fr</dd>
<dt>Date</dt> <dd>2014-03-12 02:49:59 -0700 (Wed, 12 Mar 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>Invisible Operators should not add space.
https://bugs.webkit.org/show_bug.cgi?id=115786

Reviewed by Chris Fleizach.

Source/WebCore:

This change adds special handling for invisible operator to ensure they really behave as empty box. We now ignore their glyph widths and do not paint them.

Test: mathml/presentation/mo-invisible.html

* rendering/mathml/RenderMathMLOperator.cpp:
(WebCore::RenderMathMLOperator::computePreferredLogicalWidths):
(WebCore::RenderMathMLOperator::paint):
* rendering/mathml/RenderMathMLOperator.h:

LayoutTests:

Add a reftest based on the examples of the MathML specification to verify that invisible operators do not add space.

* mathml/presentation/mo-invisible-expected.html: Added.
* mathml/presentation/mo-invisible.html: Added.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorerenderingmathmlRenderMathMLOperatorcpp">trunk/Source/WebCore/rendering/mathml/RenderMathMLOperator.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingmathmlRenderMathMLOperatorh">trunk/Source/WebCore/rendering/mathml/RenderMathMLOperator.h</a></li>
<li><a href="#trunkSourceWebCorerenderingmathmlRenderMathMLRowcpp">trunk/Source/WebCore/rendering/mathml/RenderMathMLRow.cpp</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsmathmlpresentationmoinvisibleexpectedhtml">trunk/LayoutTests/mathml/presentation/mo-invisible-expected.html</a></li>
<li><a href="#trunkLayoutTestsmathmlpresentationmoinvisiblehtml">trunk/LayoutTests/mathml/presentation/mo-invisible.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (165463 => 165464)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2014-03-12 09:44:59 UTC (rev 165463)
+++ trunk/LayoutTests/ChangeLog        2014-03-12 09:49:59 UTC (rev 165464)
</span><span class="lines">@@ -1,3 +1,15 @@
</span><ins>+2014-03-12  Frédéric Wang  &lt;fred.wang@free.fr&gt;
+
+        Invisible Operators should not add space.
+        https://bugs.webkit.org/show_bug.cgi?id=115786
+
+        Reviewed by Chris Fleizach.
+
+        Add a reftest based on the examples of the MathML specification to verify that invisible operators do not add space.
+
+        * mathml/presentation/mo-invisible-expected.html: Added.
+        * mathml/presentation/mo-invisible.html: Added.
+
</ins><span class="cx"> 2014-03-11  Frédéric Wang  &lt;fred.wang@free.fr&gt;
</span><span class="cx"> 
</span><span class="cx">         Implement MathML spacing around operators .
</span></span></pre></div>
<a id="trunkLayoutTestsmathmlpresentationmoinvisibleexpectedhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/mathml/presentation/mo-invisible-expected.html (0 => 165464)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/mathml/presentation/mo-invisible-expected.html                                (rev 0)
+++ trunk/LayoutTests/mathml/presentation/mo-invisible-expected.html        2014-03-12 09:49:59 UTC (rev 165464)
</span><span class="lines">@@ -0,0 +1,56 @@
</span><ins>+&lt;!doctype html&gt;
+&lt;html&gt;
+  &lt;head&gt;
+    &lt;title&gt;invisible operators&lt;/title&gt;
+    &lt;meta charset=&quot;utf-8&quot;/&gt;
+  &lt;/head&gt;
+  &lt;body&gt;
+
+   &lt;math&gt;
+     &lt;mrow&gt;
+       &lt;mi&gt;f&lt;/mi&gt;
+       &lt;mo lspace=&quot;0em&quot; rspace=&quot;0em&quot;&gt;&lt;/mo&gt;
+       &lt;mrow&gt;
+         &lt;mo&gt;(&lt;/mo&gt;
+         &lt;mi&gt;x&lt;/mi&gt;
+         &lt;mo&gt;)&lt;/mo&gt;
+       &lt;/mrow&gt;
+     &lt;/mrow&gt;
+   &lt;/math&gt;
+   &lt;math&gt;
+     &lt;mrow&gt;
+       &lt;mi&gt;sin&lt;/mi&gt;
+       &lt;mo lspace=&quot;0em&quot; rspace=&quot;0em&quot;&gt;&lt;/mo&gt;
+       &lt;mi&gt;x&lt;/mi&gt;
+     &lt;/mrow&gt;
+   &lt;/math&gt;
+   &lt;math&gt;
+     &lt;mrow&gt;
+       &lt;mi&gt;x&lt;/mi&gt;
+       &lt;mo lspace=&quot;0em&quot; rspace=&quot;0em&quot;&gt;&lt;/mo&gt;
+       &lt;mi&gt;y&lt;/mi&gt;
+     &lt;/mrow&gt;
+   &lt;/math&gt;
+   &lt;math&gt;
+     &lt;msub&gt;
+       &lt;mi&gt;m&lt;/mi&gt;
+       &lt;mrow&gt;
+         &lt;mn&gt;1&lt;/mn&gt;
+         &lt;mo lspace=&quot;0em&quot; rspace=&quot;0em&quot;&gt;&lt;/mo&gt;
+         &lt;mn&gt;2&lt;/mn&gt;
+       &lt;/mrow&gt;
+     &lt;/msub&gt;
+   &lt;/math&gt;
+   &lt;math&gt;
+     &lt;mrow&gt;
+       &lt;mn&gt;2&lt;/mn&gt;
+       &lt;mo lspace=&quot;0em&quot; rspace=&quot;0em&quot;&gt;&lt;/mo&gt;
+       &lt;mfrac&gt;
+         &lt;mn&gt;3&lt;/mn&gt;
+         &lt;mn&gt;4&lt;/mn&gt;
+       &lt;/mfrac&gt;
+     &lt;/mrow&gt;
+   &lt;/math&gt;
+
+  &lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsmathmlpresentationmoinvisiblehtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/mathml/presentation/mo-invisible.html (0 => 165464)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/mathml/presentation/mo-invisible.html                                (rev 0)
+++ trunk/LayoutTests/mathml/presentation/mo-invisible.html        2014-03-12 09:49:59 UTC (rev 165464)
</span><span class="lines">@@ -0,0 +1,58 @@
</span><ins>+&lt;!doctype html&gt;
+&lt;html&gt;
+ &lt;head&gt;
+   &lt;title&gt;invisible operators&lt;/title&gt;
+   &lt;meta charset=&quot;utf-8&quot;/&gt;
+ &lt;/head&gt;
+ &lt;body&gt;
+
+   &lt;!-- These examples are taken from http://www.w3.org/TR/MathML/chapter3.html#presm.invisibleops.
+        The invisible operator glyphs should render as empty box and, per the operator dictionary, should not have space around them. --&gt;
+   &lt;math&gt;
+     &lt;mrow&gt;
+       &lt;mi&gt;f&lt;/mi&gt;
+       &lt;mo&gt;&amp;#x2061;&lt;!--FUNCTION APPLICATION--&gt;&lt;/mo&gt;
+       &lt;mrow&gt;
+         &lt;mo&gt;(&lt;/mo&gt;
+         &lt;mi&gt;x&lt;/mi&gt;
+         &lt;mo&gt;)&lt;/mo&gt;
+       &lt;/mrow&gt;
+     &lt;/mrow&gt;
+   &lt;/math&gt;
+   &lt;math&gt;
+     &lt;mrow&gt;
+       &lt;mi&gt;sin&lt;/mi&gt;
+       &lt;mo&gt;&amp;#x2061;&lt;!--FUNCTION APPLICATION--&gt;&lt;/mo&gt;
+       &lt;mi&gt;x&lt;/mi&gt;
+     &lt;/mrow&gt;
+   &lt;/math&gt;
+   &lt;math&gt;
+     &lt;mrow&gt;
+       &lt;mi&gt;x&lt;/mi&gt;
+       &lt;mo&gt;&amp;#x2062;&lt;!--INVISIBLE TIMES--&gt;&lt;/mo&gt;
+       &lt;mi&gt;y&lt;/mi&gt;
+     &lt;/mrow&gt;
+   &lt;/math&gt;
+   &lt;math&gt;
+     &lt;msub&gt;
+       &lt;mi&gt;m&lt;/mi&gt;
+       &lt;mrow&gt;
+         &lt;mn&gt;1&lt;/mn&gt;
+         &lt;mo&gt;&amp;#x2063;&lt;!--INVISIBLE SEPARATOR--&gt;&lt;/mo&gt;
+         &lt;mn&gt;2&lt;/mn&gt;
+       &lt;/mrow&gt;
+     &lt;/msub&gt;
+   &lt;/math&gt;
+   &lt;math&gt;
+     &lt;mrow&gt;
+       &lt;mn&gt;2&lt;/mn&gt;
+       &lt;mo&gt;&amp;#x2064;&lt;!-- INVISIBLE PLUS --&gt;&lt;/mo&gt;
+       &lt;mfrac&gt;
+         &lt;mn&gt;3&lt;/mn&gt;
+         &lt;mn&gt;4&lt;/mn&gt;
+       &lt;/mfrac&gt;
+     &lt;/mrow&gt;
+   &lt;/math&gt;
+
+ &lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (165463 => 165464)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2014-03-12 09:44:59 UTC (rev 165463)
+++ trunk/Source/WebCore/ChangeLog        2014-03-12 09:49:59 UTC (rev 165464)
</span><span class="lines">@@ -1,3 +1,19 @@
</span><ins>+2014-03-12  Frédéric Wang  &lt;fred.wang@free.fr&gt;
+
+        Invisible Operators should not add space.
+        https://bugs.webkit.org/show_bug.cgi?id=115786
+
+        Reviewed by Chris Fleizach.
+
+        This change adds special handling for invisible operator to ensure they really behave as empty box. We now ignore their glyph widths and do not paint them.
+
+        Test: mathml/presentation/mo-invisible.html
+
+        * rendering/mathml/RenderMathMLOperator.cpp:
+        (WebCore::RenderMathMLOperator::computePreferredLogicalWidths):
+        (WebCore::RenderMathMLOperator::paint):
+        * rendering/mathml/RenderMathMLOperator.h:
+
</ins><span class="cx"> 2014-03-11  Frédéric Wang  &lt;fred.wang@free.fr&gt;
</span><span class="cx"> 
</span><span class="cx">         Implement MathML spacing around operators .
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingmathmlRenderMathMLOperatorcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/mathml/RenderMathMLOperator.cpp (165463 => 165464)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/mathml/RenderMathMLOperator.cpp        2014-03-12 09:44:59 UTC (rev 165463)
+++ trunk/Source/WebCore/rendering/mathml/RenderMathMLOperator.cpp        2014-03-12 09:49:59 UTC (rev 165464)
</span><span class="lines">@@ -1302,6 +1302,13 @@
</span><span class="cx">     bool allowStretching = shouldAllowStretching(stretchedCharacter);
</span><span class="cx">     if (!allowStretching) {
</span><span class="cx">         RenderMathMLToken::computePreferredLogicalWidths();
</span><ins>+        if (isInvisibleOperator()) {
+            // In some fonts, glyphs for invisible operators have nonzero width. Consequently, we subtract that width here to avoid wide gaps.
+            float glyphWidth = advanceForCharacter(m_operator);
+            ASSERT(glyphWidth &lt;= m_minPreferredLogicalWidth);
+            m_minPreferredLogicalWidth -= glyphWidth;
+            m_maxPreferredLogicalWidth -= glyphWidth;
+        }
</ins><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -1529,7 +1536,8 @@
</span><span class="cx"> 
</span><span class="cx"> void RenderMathMLOperator::paint(PaintInfo&amp; info, const LayoutPoint&amp; paintOffset)
</span><span class="cx"> {
</span><del>-    if (info.context-&gt;paintingDisabled() || info.phase != PaintPhaseForeground || style().visibility() != VISIBLE)
</del><ins>+    // We skip painting for invisible operators too to avoid some &quot;missing character&quot; glyph to appear if appropriate math fonts are not available.
+    if (info.context-&gt;paintingDisabled() || info.phase != PaintPhaseForeground || style().visibility() != VISIBLE || isInvisibleOperator())
</ins><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx">     if (!m_isStretched &amp;&amp; !m_stretchyCharacter) {
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingmathmlRenderMathMLOperatorh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/mathml/RenderMathMLOperator.h (165463 => 165464)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/mathml/RenderMathMLOperator.h        2014-03-12 09:44:59 UTC (rev 165463)
+++ trunk/Source/WebCore/rendering/mathml/RenderMathMLOperator.h        2014-03-12 09:49:59 UTC (rev 165464)
</span><span class="lines">@@ -87,6 +87,8 @@
</span><span class="cx">     virtual void paintChildren(PaintInfo&amp; forSelf, const LayoutPoint&amp;, PaintInfo&amp; forChild, bool usePrintRect) override;
</span><span class="cx">     virtual bool isRenderMathMLOperator() const override { return true; }
</span><span class="cx">     bool isFencedOperator() { return isAnonymous(); }
</span><ins>+    // The following operators are invisible: U+2061 FUNCTION APPLICATION, U+2062 INVISIBLE TIMES, U+2063 INVISIBLE SEPARATOR, U+2064 INVISIBLE PLUS.
+    bool isInvisibleOperator() const { return 0x2061 &lt;= m_operator &amp;&amp; m_operator &lt;= 0x2064; }
</ins><span class="cx">     virtual bool isChildAllowed(const RenderObject&amp;, const RenderStyle&amp;) const override;
</span><span class="cx">     virtual void computePreferredLogicalWidths() override;
</span><span class="cx">     virtual void computeLogicalHeight(LayoutUnit logicalHeight, LayoutUnit logicalTop, LogicalExtentComputedValues&amp;) const override;
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingmathmlRenderMathMLRowcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/mathml/RenderMathMLRow.cpp (165463 => 165464)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/mathml/RenderMathMLRow.cpp        2014-03-12 09:44:59 UTC (rev 165463)
+++ trunk/Source/WebCore/rendering/mathml/RenderMathMLRow.cpp        2014-03-12 09:49:59 UTC (rev 165464)
</span><span class="lines">@@ -59,8 +59,7 @@
</span><span class="cx"> {
</span><span class="cx">     for (RenderObject* child = firstChild(); child; child = child-&gt;nextSibling()) {
</span><span class="cx">         if (child-&gt;isRenderMathMLBlock()) {
</span><del>-            auto renderOperator = toRenderMathMLBlock(child)-&gt;unembellishedOperator();
-            if (renderOperator)
</del><ins>+            if (auto renderOperator = toRenderMathMLBlock(child)-&gt;unembellishedOperator())
</ins><span class="cx">                 renderOperator-&gt;updateOperatorProperties();
</span><span class="cx">         }
</span><span class="cx">     }
</span></span></pre>
</div>
</div>

</body>
</html>