<!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>[199978] trunk/Source/WebCore</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/199978">199978</a></dd>
<dt>Author</dt> <dd>fred.wang@free.fr</dd>
<dt>Date</dt> <dd>2016-04-25 00:04:46 -0700 (Mon, 25 Apr 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>Minor refactoring in RenderMathMLOperator
https://bugs.webkit.org/show_bug.cgi?id=156906

Patch by Frederic Wang &lt;fwang@igalia.com&gt; on 2016-04-25
Reviewed by Martin Robinson.

No new tests, this is only minor refactoring that does not change the behavior.

* rendering/mathml/RenderMathMLOperator.cpp:
(WebCore::RenderMathMLOperator::getGlyphAssemblyFallBack):
We rename the &quot;state&quot; integer to an &quot;expected&quot; enum indicating the next expected part.
(WebCore::RenderMathMLOperator::paintGlyph): We add a missing dot at the end of a sequence.
We also replace ceil(x+1) with ceil(x)+1 to get rid of the temporary variable.</pre>

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

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (199977 => 199978)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-04-25 06:34:48 UTC (rev 199977)
+++ trunk/Source/WebCore/ChangeLog        2016-04-25 07:04:46 UTC (rev 199978)
</span><span class="lines">@@ -1,3 +1,18 @@
</span><ins>+2016-04-25  Frederic Wang  &lt;fwang@igalia.com&gt;
+
+        Minor refactoring in RenderMathMLOperator
+        https://bugs.webkit.org/show_bug.cgi?id=156906
+
+        Reviewed by Martin Robinson.
+
+        No new tests, this is only minor refactoring that does not change the behavior.
+
+        * rendering/mathml/RenderMathMLOperator.cpp:
+        (WebCore::RenderMathMLOperator::getGlyphAssemblyFallBack):
+        We rename the &quot;state&quot; integer to an &quot;expected&quot; enum indicating the next expected part.
+        (WebCore::RenderMathMLOperator::paintGlyph): We add a missing dot at the end of a sequence.
+        We also replace ceil(x+1) with ceil(x)+1 to get rid of the temporary variable.
+
</ins><span class="cx"> 2016-04-24  Chris Dumez  &lt;cdumez@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [Web IDL] Specify default values for boolean parameters
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingmathmlRenderMathMLOperatorcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/mathml/RenderMathMLOperator.cpp (199977 => 199978)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/mathml/RenderMathMLOperator.cpp        2016-04-25 06:34:48 UTC (rev 199977)
+++ trunk/Source/WebCore/rendering/mathml/RenderMathMLOperator.cpp        2016-04-25 07:04:46 UTC (rev 199978)
</span><span class="lines">@@ -406,57 +406,73 @@
</span><span class="cx">     if (nonExtenderCount &gt; 3)
</span><span class="cx">         return false; // This is not supported: there are too many pieces.
</span><span class="cx"> 
</span><del>-    // We now browse the list of pieces.
-    // 1 = look for a left/bottom glyph
-    // 2 = look for an extender between left/bottom and mid
-    // 4 = look for a middle glyph
-    // 5 = look for an extender between middle and right/top
-    // 5 = look for a right/top glyph
-    // 6 = no more piece expected
-    unsigned state = 1;
-
</del><ins>+    // We now browse the list of pieces from left to right for horizontal operators and from bottom to top for vertical operators.
+    enum PartType {
+        Start,
+        ExtenderBetweenStartAndMiddle,
+        Middle,
+        ExtenderBetweenMiddleAndEnd,
+        End,
+        None
+    };
+    PartType expectedPartType = Start;
</ins><span class="cx">     extension.glyph = 0;
</span><span class="cx">     middle.glyph = 0;
</span><span class="cx">     for (auto&amp; part : assemblyParts) {
</span><del>-        if ((state == 2 || state == 3) &amp;&amp; nonExtenderCount &lt; 3) {
-            // We do not try to find a middle glyph.
-            state += 2;
</del><ins>+        if (nonExtenderCount &lt; 3) {
+            // If we only have at most two non-extenders then we skip the middle glyph.
+            if (expectedPartType == ExtenderBetweenStartAndMiddle)
+                expectedPartType = ExtenderBetweenMiddleAndEnd;
+            else if (expectedPartType == Middle)
+                expectedPartType = End;
</ins><span class="cx">         }
</span><span class="cx">         if (part.isExtender) {
</span><span class="cx">             if (!extension.glyph)
</span><del>-                extension.glyph = part.glyph;
</del><ins>+                extension.glyph = part.glyph; // We copy the extender part.
</ins><span class="cx">             else if (extension.glyph != part.glyph)
</span><span class="cx">                 return false; // This is not supported: the assembly has different extenders.
</span><span class="cx"> 
</span><del>-            if (state == 1) {
-                // We ignore left/bottom piece and multiple successive extenders.
-                state = 2;
-            } else if (state == 3) {
-                // We ignore middle piece and multiple successive extenders.
-                state = 4;
-            } else if (state &gt;= 5)
-                return false; // This is not supported: we got an unexpected extender.
-            continue;
</del><ins>+            switch (expectedPartType) {
+            case Start:
+                // We ignore the left/bottom part.
+                expectedPartType = ExtenderBetweenStartAndMiddle;
+                continue;
+            case Middle:
+                // We ignore the middle part.
+                expectedPartType = ExtenderBetweenMiddleAndEnd;
+                continue;
+            case End:
+            case None:
+                // This is not supported: we got an unexpected extender.
+                return false;
+            case ExtenderBetweenStartAndMiddle:
+            case ExtenderBetweenMiddleAndEnd:
+                // We ignore multiple consecutive extenders.
+                continue;
+            }
</ins><span class="cx">         }
</span><span class="cx"> 
</span><del>-        if (state == 1) {
</del><ins>+        switch (expectedPartType) {
+        case Start:
</ins><span class="cx">             // We copy the left/bottom part.
</span><span class="cx">             bottom.glyph = part.glyph;
</span><del>-            state = 2;
</del><ins>+            expectedPartType = ExtenderBetweenStartAndMiddle;
</ins><span class="cx">             continue;
</span><del>-        }
-
-        if (state == 2 || state == 3) {
</del><ins>+        case ExtenderBetweenStartAndMiddle:
+        case Middle:
</ins><span class="cx">             // We copy the middle part.
</span><span class="cx">             middle.glyph = part.glyph;
</span><del>-            state = 4;
</del><ins>+            expectedPartType = ExtenderBetweenMiddleAndEnd;
</ins><span class="cx">             continue;
</span><del>-        }
-
-        if (state == 4 || state == 5) {
</del><ins>+        case ExtenderBetweenMiddleAndEnd:
+        case End:
</ins><span class="cx">             // We copy the right/top part.
</span><span class="cx">             top.glyph = part.glyph;
</span><del>-            state = 6;
</del><ins>+            expectedPartType = None;
+            continue;
+        case None:
+            // This is not supported: we got an unexpected non-extender part.
+            return false;
</ins><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -708,7 +724,7 @@
</span><span class="cx"> 
</span><span class="cx">     // In order to have glyphs fit snugly with one another we snap the connecting edges to pixel boundaries
</span><span class="cx">     // and trim off one pixel. The pixel trim is to account for fonts that have edge pixels that have less
</span><del>-    // than full coverage. These edge pixels can introduce small seams between connected glyphs
</del><ins>+    // than full coverage. These edge pixels can introduce small seams between connected glyphs.
</ins><span class="cx">     FloatRect clipBounds = info.rect;
</span><span class="cx">     switch (trim) {
</span><span class="cx">     case TrimTop:
</span><span class="lines">@@ -719,13 +735,11 @@
</span><span class="cx">         glyphPaintRect.shiftMaxYEdgeTo(glyphPaintRect.maxY().floor() - 1);
</span><span class="cx">         clipBounds.shiftMaxYEdgeTo(glyphPaintRect.maxY());
</span><span class="cx">         break;
</span><del>-    case TrimTopAndBottom: {
-        LayoutUnit temp = glyphPaintRect.y() + 1;
-        glyphPaintRect.shiftYEdgeTo(temp.ceil());
</del><ins>+    case TrimTopAndBottom:
+        glyphPaintRect.shiftYEdgeTo(glyphPaintRect.y().ceil() + 1);
</ins><span class="cx">         glyphPaintRect.shiftMaxYEdgeTo(glyphPaintRect.maxY().floor() - 1);
</span><span class="cx">         clipBounds.shiftYEdgeTo(glyphPaintRect.y());
</span><span class="cx">         clipBounds.shiftMaxYEdgeTo(glyphPaintRect.maxY());
</span><del>-    }
</del><span class="cx">         break;
</span><span class="cx">     case TrimLeft:
</span><span class="cx">         glyphPaintRect.shiftXEdgeTo(glyphPaintRect.x().ceil() + 1);
</span><span class="lines">@@ -735,14 +749,12 @@
</span><span class="cx">         glyphPaintRect.shiftMaxXEdgeTo(glyphPaintRect.maxX().floor() - 1);
</span><span class="cx">         clipBounds.shiftMaxXEdgeTo(glyphPaintRect.maxX());
</span><span class="cx">         break;
</span><del>-    case TrimLeftAndRight: {
-        LayoutUnit temp = glyphPaintRect.x() + 1;
-        glyphPaintRect.shiftXEdgeTo(temp.ceil());
</del><ins>+    case TrimLeftAndRight:
+        glyphPaintRect.shiftXEdgeTo(glyphPaintRect.x().ceil() + 1);
</ins><span class="cx">         glyphPaintRect.shiftMaxXEdgeTo(glyphPaintRect.maxX().floor() - 1);
</span><span class="cx">         clipBounds.shiftXEdgeTo(glyphPaintRect.x());
</span><span class="cx">         clipBounds.shiftMaxXEdgeTo(glyphPaintRect.maxX());
</span><span class="cx">     }
</span><del>-    }
</del><span class="cx"> 
</span><span class="cx">     // Clipping the enclosing IntRect avoids any potential issues at joined edges.
</span><span class="cx">     GraphicsContextStateSaver stateSaver(info.context());
</span></span></pre>
</div>
</div>

</body>
</html>