<!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>[203395] 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/203395">203395</a></dd>
<dt>Author</dt> <dd>fred.wang@free.fr</dd>
<dt>Date</dt> <dd>2016-07-18 22:36:16 -0700 (Mon, 18 Jul 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>Do not store gap and shift parameters on RenderMathMLFraction
https://bugs.webkit.org/show_bug.cgi?id=159876

Patch by Frederic Wang &lt;fwang@igalia.com&gt; on 2016-07-18
Reviewed by Darin Adler.

After <a href="http://trac.webkit.org/projects/webkit/changeset/203285">r203285</a>, the stack and fraction layout parameters are only used in layoutBlock so we
do not need to store them on the class. We remove them and split updateLayoutParameters into
three functions: one to update the linethickness and two others to retrieve the fraction and
stack respectively.

No new tests, rendering is unchanged.

* rendering/mathml/RenderMathMLFraction.cpp:
(WebCore::RenderMathMLFraction::updateLineThickness): Move code to update thickness members here.
(WebCore::RenderMathMLFraction::getFractionParameters): Move code to retrieve fraction parameters here.
(WebCore::RenderMathMLFraction::getStackParameters): Move code to retrieve stack parameters here.
(WebCore::RenderMathMLFraction::layoutBlock): Use the new helper functions and local variables
for fraction and stack parameters.
(WebCore::RenderMathMLFraction::updateLayoutParameters): Deleted.
* rendering/mathml/RenderMathMLFraction.h: Declare new helper functions and remove members
for stack and fraction parameters.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorerenderingmathmlRenderMathMLFractioncpp">trunk/Source/WebCore/rendering/mathml/RenderMathMLFraction.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingmathmlRenderMathMLFractionh">trunk/Source/WebCore/rendering/mathml/RenderMathMLFraction.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (203394 => 203395)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-07-19 04:45:53 UTC (rev 203394)
+++ trunk/Source/WebCore/ChangeLog        2016-07-19 05:36:16 UTC (rev 203395)
</span><span class="lines">@@ -1,3 +1,27 @@
</span><ins>+2016-07-18  Frederic Wang  &lt;fwang@igalia.com&gt;
+
+        Do not store gap and shift parameters on RenderMathMLFraction
+        https://bugs.webkit.org/show_bug.cgi?id=159876
+
+        Reviewed by Darin Adler.
+
+        After r203285, the stack and fraction layout parameters are only used in layoutBlock so we
+        do not need to store them on the class. We remove them and split updateLayoutParameters into
+        three functions: one to update the linethickness and two others to retrieve the fraction and
+        stack respectively.
+
+        No new tests, rendering is unchanged.
+
+        * rendering/mathml/RenderMathMLFraction.cpp:
+        (WebCore::RenderMathMLFraction::updateLineThickness): Move code to update thickness members here.
+        (WebCore::RenderMathMLFraction::getFractionParameters): Move code to retrieve fraction parameters here.
+        (WebCore::RenderMathMLFraction::getStackParameters): Move code to retrieve stack parameters here.
+        (WebCore::RenderMathMLFraction::layoutBlock): Use the new helper functions and local variables
+        for fraction and stack parameters.
+        (WebCore::RenderMathMLFraction::updateLayoutParameters): Deleted.
+        * rendering/mathml/RenderMathMLFraction.h: Declare new helper functions and remove members
+        for stack and fraction parameters.
+
</ins><span class="cx"> 2016-07-18  Chris Dumez  &lt;cdumez@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         input.formEnctype / formMethod and button.formEnctype / formMethod / type should treat null as &quot;null&quot;
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingmathmlRenderMathMLFractioncpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/mathml/RenderMathMLFraction.cpp (203394 => 203395)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/mathml/RenderMathMLFraction.cpp        2016-07-19 04:45:53 UTC (rev 203394)
+++ trunk/Source/WebCore/rendering/mathml/RenderMathMLFraction.cpp        2016-07-19 05:36:16 UTC (rev 203395)
</span><span class="lines">@@ -67,11 +67,8 @@
</span><span class="cx">     return *firstChildBox()-&gt;nextSiblingBox();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void RenderMathMLFraction::updateLayoutParameters()
</del><ins>+void RenderMathMLFraction::updateLineThickness()
</ins><span class="cx"> {
</span><del>-    // We try and read constants to draw the fraction from the OpenType MATH and use fallback values otherwise.
-    // We also parse presentation attributes of the &lt;mfrac&gt; element.
-
</del><span class="cx">     // We first determine the default line thickness.
</span><span class="cx">     const auto&amp; primaryFont = style().fontCascade().primaryFont();
</span><span class="cx">     const auto* mathData = style().fontCascade().primaryFont().mathData();
</span><span class="lines">@@ -80,38 +77,55 @@
</span><span class="cx">     else
</span><span class="cx">         m_defaultLineThickness = ruleThicknessFallback();
</span><span class="cx"> 
</span><del>-    // Resolve the thickness using m_defaultLineThickness as the default value.
</del><ins>+    // Next we resolve the thickness using m_defaultLineThickness as the default value.
</ins><span class="cx">     m_lineThickness = toUserUnits(element().lineThickness(), style(), m_defaultLineThickness);
</span><span class="cx">     if (m_lineThickness &lt; 0)
</span><span class="cx">         m_lineThickness = 0;
</span><ins>+}
</ins><span class="cx"> 
</span><del>-    // We now know whether we should layout as a normal fraction or as a stack (fraction without bar) and so determine the relevant constants.
</del><ins>+void RenderMathMLFraction::getFractionParameters(LayoutUnit&amp; numeratorGapMin, LayoutUnit&amp; denominatorGapMin, LayoutUnit&amp; numeratorMinShiftUp, LayoutUnit&amp; denominatorMinShiftDown)
+{
+    ASSERT(!isStack());
+
+    // We try and read constants to draw the fraction from the OpenType MATH and use fallback values otherwise.
+    const auto&amp; primaryFont = style().fontCascade().primaryFont();
+    const auto* mathData = style().fontCascade().primaryFont().mathData();
</ins><span class="cx">     bool display = mathMLStyle()-&gt;displayStyle();
</span><del>-    if (isStack()) {
-        if (mathData) {
-            m_gapMin = mathData-&gt;getMathConstant(primaryFont, display ? OpenTypeMathData::StackDisplayStyleGapMin : OpenTypeMathData::StackGapMin);
-            m_topShiftUp = mathData-&gt;getMathConstant(primaryFont, display ? OpenTypeMathData::StackTopDisplayStyleShiftUp : OpenTypeMathData::StackTopShiftUp);
-            m_bottomShiftDown = mathData-&gt;getMathConstant(primaryFont, display ? OpenTypeMathData::StackBottomDisplayStyleShiftDown : OpenTypeMathData::StackBottomShiftDown);
-        } else {
-            // We use the values suggested in the MATH table specification.
-            m_gapMin = m_denominatorGapMin = display ? 7 * ruleThicknessFallback() : 3 * ruleThicknessFallback();
</del><ins>+    if (mathData) {
+        numeratorGapMin = mathData-&gt;getMathConstant(primaryFont, display ? OpenTypeMathData::FractionNumDisplayStyleGapMin : OpenTypeMathData::FractionNumeratorGapMin);
+        denominatorGapMin = mathData-&gt;getMathConstant(primaryFont, display ? OpenTypeMathData::FractionDenomDisplayStyleGapMin : OpenTypeMathData::FractionDenominatorGapMin);
+        numeratorMinShiftUp = mathData-&gt;getMathConstant(primaryFont, display ? OpenTypeMathData::FractionNumeratorDisplayStyleShiftUp : OpenTypeMathData::FractionNumeratorShiftUp);
+        denominatorMinShiftDown = mathData-&gt;getMathConstant(primaryFont, display ? OpenTypeMathData::FractionDenominatorDisplayStyleShiftDown : OpenTypeMathData::FractionDenominatorShiftDown);
+    } else {
+        // The MATH table specification suggests default rule thickness or (in displaystyle) 3 times default rule thickness for the gaps.
+        numeratorGapMin = display ? 3 * ruleThicknessFallback() : ruleThicknessFallback();
+        denominatorGapMin = numeratorGapMin;
</ins><span class="cx"> 
</span><del>-            // The MATH table specification does not suggest any values for shifts, so we leave them at zero.
-            m_topShiftUp = m_bottomShiftDown = 0;
-        }
</del><ins>+        // The MATH table specification does not suggest any values for shifts, so we leave them at zero.
+        numeratorMinShiftUp = 0;
+        denominatorMinShiftDown = 0;
+    }
+}
+
+void RenderMathMLFraction::getStackParameters(LayoutUnit&amp; gapMin, LayoutUnit&amp; topShiftUp, LayoutUnit&amp; bottomShiftDown)
+{
+    ASSERT(isStack());
+
+    // We try and read constants to draw the stack from the OpenType MATH and use fallback values otherwise.
+    const auto&amp; primaryFont = style().fontCascade().primaryFont();
+    const auto* mathData = style().fontCascade().primaryFont().mathData();
+    bool display = mathMLStyle()-&gt;displayStyle();
+    if (mathData) {
+        gapMin = mathData-&gt;getMathConstant(primaryFont, display ? OpenTypeMathData::StackDisplayStyleGapMin : OpenTypeMathData::StackGapMin);
+        topShiftUp = mathData-&gt;getMathConstant(primaryFont, display ? OpenTypeMathData::StackTopDisplayStyleShiftUp : OpenTypeMathData::StackTopShiftUp);
+        bottomShiftDown = mathData-&gt;getMathConstant(primaryFont, display ? OpenTypeMathData::StackBottomDisplayStyleShiftDown : OpenTypeMathData::StackBottomShiftDown);
</ins><span class="cx">     } else {
</span><del>-        if (mathData) {
-            m_numeratorGapMin = mathData-&gt;getMathConstant(primaryFont, display ? OpenTypeMathData::FractionNumDisplayStyleGapMin : OpenTypeMathData::FractionNumeratorGapMin);
-            m_denominatorGapMin = mathData-&gt;getMathConstant(primaryFont, display ? OpenTypeMathData::FractionDenomDisplayStyleGapMin : OpenTypeMathData::FractionDenominatorGapMin);
-            m_numeratorMinShiftUp = mathData-&gt;getMathConstant(primaryFont, display ? OpenTypeMathData::FractionNumeratorDisplayStyleShiftUp : OpenTypeMathData::FractionNumeratorShiftUp);
-            m_denominatorMinShiftDown = mathData-&gt;getMathConstant(primaryFont, display ? OpenTypeMathData::FractionDenominatorDisplayStyleShiftDown : OpenTypeMathData::FractionDenominatorShiftDown);
-        } else {
-            // The MATH table specification suggests default rule thickness or (in displaystyle) 3 times default rule thickness for the gaps.
-            m_numeratorGapMin = m_denominatorGapMin = display ? 3 * ruleThicknessFallback() : ruleThicknessFallback();
</del><ins>+        // We use the values suggested in the MATH table specification.
+        gapMin = display ? 7 * ruleThicknessFallback() : 3 * ruleThicknessFallback();
</ins><span class="cx"> 
</span><del>-            // The MATH table specification does not suggest any values for shifts, so we leave them at zero.
-            m_numeratorMinShiftUp = m_denominatorMinShiftDown = 0;
-        }
</del><ins>+        // The MATH table specification does not suggest any values for shifts, so we leave them at zero.
+        topShiftUp = 0;
+        bottomShiftDown = 0;
</ins><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -127,7 +141,8 @@
</span><span class="cx"> {
</span><span class="cx">     ASSERT(preferredLogicalWidthsDirty());
</span><span class="cx"> 
</span><del>-    m_minPreferredLogicalWidth = m_maxPreferredLogicalWidth = 0;
</del><ins>+    m_minPreferredLogicalWidth = 0;
+    m_maxPreferredLogicalWidth = 0;
</ins><span class="cx"> 
</span><span class="cx">     if (isValid()) {
</span><span class="cx">         LayoutUnit numeratorWidth = numerator().maxPreferredLogicalWidth();
</span><span class="lines">@@ -172,7 +187,7 @@
</span><span class="cx"> 
</span><span class="cx">     setLogicalWidth(std::max(numerator().logicalWidth(), denominator().logicalWidth()));
</span><span class="cx"> 
</span><del>-    updateLayoutParameters();
</del><ins>+    updateLineThickness();
</ins><span class="cx">     LayoutUnit verticalOffset = 0; // This is the top of the renderer.
</span><span class="cx">     LayoutPoint numeratorLocation(horizontalOffset(numerator(), element().numeratorAlignment()), verticalOffset);
</span><span class="cx">     numerator().setLocation(numeratorLocation);
</span><span class="lines">@@ -182,12 +197,12 @@
</span><span class="cx">     LayoutUnit denominatorAscent = ascentForChild(denominator());
</span><span class="cx">     LayoutUnit denominatorDescent = denominator().logicalHeight() - denominatorAscent;
</span><span class="cx">     if (isStack()) {
</span><del>-        LayoutUnit topShiftUp = m_topShiftUp;
-        LayoutUnit bottomShiftDown = m_bottomShiftDown;
</del><ins>+        LayoutUnit gapMin, topShiftUp, bottomShiftDown;
+        getStackParameters(gapMin, topShiftUp, bottomShiftDown);
</ins><span class="cx">         LayoutUnit gap = topShiftUp - numeratorDescent + bottomShiftDown - denominatorAscent;
</span><del>-        if (gap &lt; m_gapMin) {
</del><ins>+        if (gap &lt; gapMin) {
</ins><span class="cx">             // If the gap is not large enough, we increase the shifts by the same value.
</span><del>-            LayoutUnit delta = (m_gapMin - gap) / 2;
</del><ins>+            LayoutUnit delta = (gapMin - gap) / 2;
</ins><span class="cx">             topShiftUp += delta;
</span><span class="cx">             bottomShiftDown += delta;
</span><span class="cx">         }
</span><span class="lines">@@ -195,9 +210,11 @@
</span><span class="cx">         m_ascent = verticalOffset + mathAxisHeight();
</span><span class="cx">         verticalOffset += bottomShiftDown - denominatorAscent;
</span><span class="cx">     } else {
</span><del>-        verticalOffset += std::max(numerator().logicalHeight() + m_numeratorGapMin + m_lineThickness / 2, numeratorAscent + m_numeratorMinShiftUp); // This is the middle of the fraction bar.
</del><ins>+        LayoutUnit numeratorGapMin, denominatorGapMin, numeratorMinShiftUp, denominatorMinShiftDown;
+        getFractionParameters(numeratorGapMin, denominatorGapMin, numeratorMinShiftUp, denominatorMinShiftDown);
+        verticalOffset += std::max(numerator().logicalHeight() + numeratorGapMin + m_lineThickness / 2, numeratorAscent + numeratorMinShiftUp); // This is the middle of the fraction bar.
</ins><span class="cx">         m_ascent = verticalOffset + mathAxisHeight();
</span><del>-        verticalOffset += std::max(m_lineThickness / 2 + m_denominatorGapMin, m_denominatorMinShiftDown - denominatorAscent);
</del><ins>+        verticalOffset += std::max(m_lineThickness / 2 + denominatorGapMin, denominatorMinShiftDown - denominatorAscent);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     LayoutPoint denominatorLocation(horizontalOffset(denominator(), element().denominatorAlignment()), verticalOffset);
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingmathmlRenderMathMLFractionh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/mathml/RenderMathMLFraction.h (203394 => 203395)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/mathml/RenderMathMLFraction.h        2016-07-19 04:45:53 UTC (rev 203394)
+++ trunk/Source/WebCore/rendering/mathml/RenderMathMLFraction.h        2016-07-19 05:36:16 UTC (rev 203395)
</span><span class="lines">@@ -58,24 +58,13 @@
</span><span class="cx">     RenderBox&amp; numerator() const;
</span><span class="cx">     RenderBox&amp; denominator() const;
</span><span class="cx">     LayoutUnit horizontalOffset(RenderBox&amp;, MathMLFractionElement::FractionAlignment);
</span><del>-    void updateLayoutParameters();
</del><ins>+    void updateLineThickness();
+    void getFractionParameters(LayoutUnit&amp; numeratorGapMin, LayoutUnit&amp; denominatorGapMin, LayoutUnit&amp; numeratorMinShiftUp, LayoutUnit&amp; denominatorMinShiftDown);
+    void getStackParameters(LayoutUnit&amp; gapMin, LayoutUnit&amp; topShiftUp, LayoutUnit&amp; bottomShiftDown);
</ins><span class="cx"> 
</span><span class="cx">     LayoutUnit m_ascent;
</span><span class="cx">     LayoutUnit m_defaultLineThickness { 1 };
</span><span class="cx">     LayoutUnit m_lineThickness;
</span><del>-    union {
-        LayoutUnit m_numeratorGapMin;
-        LayoutUnit m_gapMin;
-    };
-    LayoutUnit m_denominatorGapMin;
-    union {
-        LayoutUnit m_numeratorMinShiftUp;
-        LayoutUnit m_topShiftUp;
-    };
-    union {
-        LayoutUnit m_denominatorMinShiftDown;
-        LayoutUnit m_bottomShiftDown;
-    };
</del><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebCore
</span></span></pre>
</div>
</div>

</body>
</html>