<html>
    <head>
      <base href="https://bugs.webkit.org/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - MathOperator: Improve alignment for vertical size variant"
   href="https://bugs.webkit.org/show_bug.cgi?id=158866">158866</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>MathOperator: Improve alignment for vertical size variant
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>WebKit
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>WebKit Nightly Build
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>Normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P2
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>MathML
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>webkit-unassigned&#64;lists.webkit.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>fred.wang&#64;free.fr
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>rego&#64;igalia.com
          </td>
        </tr>

        <tr>
          <th>Depends on</th>
          <td>124827, 152244
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Follow-up of <a class="bz_bug_link 
          bz_status_RESOLVED  bz_closed"
   title="RESOLVED FIXED - Add separate MathOperator module for selection/measuring/drawing of stretchy operators"
   href="show_bug.cgi?id=152244#c32">bug 152244 comment 32</a>.

Currently, MathOperator::stretchTo is called with the desired ascent/descent. When m_stretchType == StretchType::GlyphAssembly, this is used to set the desired vertical position of the operator. However, when m_stretchType == StretchType::SizeVariant the actual ascent/descent of the glyph is used for painting, and this may not correspond at all to the original MathOperator::stretchTo request.

One easy way to fix that is to make MathOperator::stretchTo calculate a parameter m_verticalOffset when m_stretchType != StretchType::GlyphAssembly which would measure the difference between targetCenter = (-ascent + descent) / 2 and glyphCenter = (-m_ascent + m_descent) / 2. Then that parameter can be used to apply a shift during MathOperator::paint.

Or maybe MathOperator::stretchTo should only take the target height as the parameter and it will be up to the MathOperator::paint caller to adjust the vertical offset (although that would probably mean that the shift will be stored in the caller's class).

There is a test from the MathML in HTML5 test suite but it does not work well in WebKit yet:
<a href="http://tests.mathml-association.org/mathml/presentation-markup/operators/mo-axis-height-1.html">http://tests.mathml-association.org/mathml/presentation-markup/operators/mo-axis-height-1.html</a></pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are the assignee for the bug.</li>
      </ul>
    </body>
</html>