<!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>[200187] 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/200187">200187</a></dd>
<dt>Author</dt> <dd>fred.wang@free.fr</dd>
<dt>Date</dt> <dd>2016-04-28 05:20:51 -0700 (Thu, 28 Apr 2016)</dd>
</dl>
<h3>Log Message</h3>
<pre>RenderMathMLOperator refactoring: introduce getBaseGlyph and remove parameter from getDisplayStyleLargeOperator
https://bugs.webkit.org/show_bug.cgi?id=156910
Reviewed by Alejandro G. Castro.
No new tests, the behavior is not changed.
* rendering/mathml/RenderMathMLOperator.cpp:
(WebCore::RenderMathMLOperator::italicCorrection): We do not need to pass m_textContent to
getDisplayStyleLargeOperator.
(WebCore::RenderMathMLOperator::computePreferredLogicalWidths): We use getBaseGlyph and do
not pass m_textContent to getDisplayStyleLargeOperator or findStretchyData.
(WebCore::RenderMathMLOperator::getBaseGlyph): Introduce a helper function to retrieve the
base glyph and do some validity checks.
(WebCore::RenderMathMLOperator::getDisplayStyleLargeOperator): We remove the character
parameter as it is always m_textContent.
We use getBaseGlyph and replace primaryFont with baseGlyph.font.
(WebCore::RenderMathMLOperator::findStretchyData): Ditto.
(WebCore::RenderMathMLOperator::updateStyle): We do not pass m_textContent to
getDisplayStyleLargeOperator or findStretchyData.
* rendering/mathml/RenderMathMLOperator.h: Declare getBaseGlyph and remove the parameter
from getDisplayStyleLargeOperator and findStretchyData.</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>
<li><a href="#trunkSourceWebCorerenderingmathmlRenderMathMLOperatorh">trunk/Source/WebCore/rendering/mathml/RenderMathMLOperator.h</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (200186 => 200187)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-04-28 12:18:23 UTC (rev 200186)
+++ trunk/Source/WebCore/ChangeLog        2016-04-28 12:20:51 UTC (rev 200187)
</span><span class="lines">@@ -1,3 +1,28 @@
</span><ins>+2016-04-28 Frederic Wang <fred.wang@free.fr>
+
+ RenderMathMLOperator refactoring: introduce getBaseGlyph and remove parameter from getDisplayStyleLargeOperator
+ https://bugs.webkit.org/show_bug.cgi?id=156910
+
+ Reviewed by Alejandro G. Castro.
+
+ No new tests, the behavior is not changed.
+
+ * rendering/mathml/RenderMathMLOperator.cpp:
+ (WebCore::RenderMathMLOperator::italicCorrection): We do not need to pass m_textContent to
+ getDisplayStyleLargeOperator.
+ (WebCore::RenderMathMLOperator::computePreferredLogicalWidths): We use getBaseGlyph and do
+ not pass m_textContent to getDisplayStyleLargeOperator or findStretchyData.
+ (WebCore::RenderMathMLOperator::getBaseGlyph): Introduce a helper function to retrieve the
+ base glyph and do some validity checks.
+ (WebCore::RenderMathMLOperator::getDisplayStyleLargeOperator): We remove the character
+ parameter as it is always m_textContent.
+ We use getBaseGlyph and replace primaryFont with baseGlyph.font.
+ (WebCore::RenderMathMLOperator::findStretchyData): Ditto.
+ (WebCore::RenderMathMLOperator::updateStyle): We do not pass m_textContent to
+ getDisplayStyleLargeOperator or findStretchyData.
+ * rendering/mathml/RenderMathMLOperator.h: Declare getBaseGlyph and remove the parameter
+ from getDisplayStyleLargeOperator and findStretchyData.
+
</ins><span class="cx"> 2016-04-28 Commit Queue <commit-queue@webkit.org>
</span><span class="cx">
</span><span class="cx"> Unreviewed, rolling out r200185.
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingmathmlRenderMathMLOperatorcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/mathml/RenderMathMLOperator.cpp (200186 => 200187)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/mathml/RenderMathMLOperator.cpp        2016-04-28 12:18:23 UTC (rev 200186)
+++ trunk/Source/WebCore/rendering/mathml/RenderMathMLOperator.cpp        2016-04-28 12:20:51 UTC (rev 200187)
</span><span class="lines">@@ -207,7 +207,7 @@
</span><span class="cx"> if (isLargeOperatorInDisplayStyle()) {
</span><span class="cx"> const auto& primaryFont = style().fontCascade().primaryFont();
</span><span class="cx"> if (auto* mathData = primaryFont.mathData()) {
</span><del>- StretchyData largeOperator = getDisplayStyleLargeOperator(m_textContent);
</del><ins>+ StretchyData largeOperator = getDisplayStyleLargeOperator();
</ins><span class="cx"> return mathData->getItalicCorrection(primaryFont, largeOperator.variant().glyph);
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="lines">@@ -306,8 +306,8 @@
</span><span class="cx"> return;
</span><span class="cx"> }
</span><span class="cx">
</span><del>- GlyphData data = style().fontCascade().glyphDataForCharacter(m_textContent, !style().isLeftToRightDirection());
- float maximumGlyphWidth = advanceWidthForGlyph(data);
</del><ins>+ GlyphData baseGlyph;
+ float maximumGlyphWidth = getBaseGlyph(style(), baseGlyph) ? advanceWidthForGlyph(baseGlyph) : 0;
</ins><span class="cx"> if (!m_isVertical) {
</span><span class="cx"> if (maximumGlyphWidth < stretchSize())
</span><span class="cx"> maximumGlyphWidth = stretchSize();
</span><span class="lines">@@ -317,12 +317,12 @@
</span><span class="cx"> }
</span><span class="cx"> if (isLargeOperatorInDisplayStyle()) {
</span><span class="cx"> // Large operators in STIX Word have incorrect advance width, causing misplacement of superscript, so we use the glyph bound instead (http://sourceforge.net/p/stixfonts/tracking/49/).
</span><del>- StretchyData largeOperator = getDisplayStyleLargeOperator(m_textContent);
</del><ins>+ StretchyData largeOperator = getDisplayStyleLargeOperator();
</ins><span class="cx"> if (largeOperator.mode() == DrawSizeVariant)
</span><span class="cx"> maximumGlyphWidth = boundsForGlyph(largeOperator.variant()).width();
</span><span class="cx"> } else {
</span><span class="cx"> // FIXME: some glyphs (e.g. the one for "FRACTION SLASH" in the STIX Math font or large operators) have a width that depends on the height, resulting in large gaps (https://bugs.webkit.org/show_bug.cgi?id=130326).
</span><del>- findStretchyData(m_textContent, &maximumGlyphWidth);
</del><ins>+ findStretchyData(&maximumGlyphWidth);
</ins><span class="cx"> }
</span><span class="cx"> m_maxPreferredLogicalWidth = m_minPreferredLogicalWidth = m_leadingSpace + maximumGlyphWidth + m_trailingSpace;
</span><span class="cx"> }
</span><span class="lines">@@ -386,6 +386,12 @@
</span><span class="cx"> updateOperatorProperties();
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+bool RenderMathMLOperator::getBaseGlyph(const RenderStyle& style, GlyphData& baseGlyph) const
+{
+ baseGlyph = style.fontCascade().glyphDataForCharacter(m_textContent, !style.isLeftToRightDirection());
+ return baseGlyph.isValid() && baseGlyph.font == &style.fontCascade().primaryFont();
+}
+
</ins><span class="cx"> bool RenderMathMLOperator::getGlyphAssemblyFallBack(Vector<OpenTypeMathData::AssemblyPart> assemblyParts, StretchyData& stretchyData) const
</span><span class="cx"> {
</span><span class="cx"> GlyphData top;
</span><span class="lines">@@ -496,30 +502,29 @@
</span><span class="cx"> return true;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-RenderMathMLOperator::StretchyData RenderMathMLOperator::getDisplayStyleLargeOperator(UChar character) const
</del><ins>+RenderMathMLOperator::StretchyData RenderMathMLOperator::getDisplayStyleLargeOperator() const
</ins><span class="cx"> {
</span><span class="cx"> StretchyData data;
</span><span class="cx">
</span><span class="cx"> ASSERT(m_isVertical && isLargeOperatorInDisplayStyle());
</span><span class="cx">
</span><del>- const auto& primaryFont = style().fontCascade().primaryFont();
- GlyphData baseGlyph = style().fontCascade().glyphDataForCharacter(character, !style().isLeftToRightDirection());
- if (!primaryFont.mathData() || baseGlyph.font != &primaryFont || !baseGlyph.font || !baseGlyph.glyph)
</del><ins>+ GlyphData baseGlyph;
+ if (!getBaseGlyph(style(), baseGlyph) || !baseGlyph.font->mathData())
</ins><span class="cx"> return data;
</span><span class="cx">
</span><span class="cx"> Vector<Glyph> sizeVariants;
</span><span class="cx"> Vector<OpenTypeMathData::AssemblyPart> assemblyParts;
</span><span class="cx">
</span><span class="cx"> // The value of displayOperatorMinHeight is sometimes too small, so we ensure that it is at least \sqrt{2} times the size of the base glyph.
</span><del>- float displayOperatorMinHeight = std::max(baseGlyph.font->boundsForGlyph(baseGlyph.glyph).height() * sqrtOfTwoFloat, primaryFont.mathData()->getMathConstant(primaryFont, OpenTypeMathData::DisplayOperatorMinHeight));
</del><ins>+ float displayOperatorMinHeight = std::max(baseGlyph.font->boundsForGlyph(baseGlyph.glyph).height() * sqrtOfTwoFloat, baseGlyph.font->mathData()->getMathConstant(*baseGlyph.font, OpenTypeMathData::DisplayOperatorMinHeight));
</ins><span class="cx">
</span><del>- primaryFont.mathData()->getMathVariants(baseGlyph.glyph, true, sizeVariants, assemblyParts);
</del><ins>+ baseGlyph.font->mathData()->getMathVariants(baseGlyph.glyph, true, sizeVariants, assemblyParts);
</ins><span class="cx">
</span><span class="cx"> // We choose the first size variant that is larger than the expected displayOperatorMinHeight and otherwise fallback to the largest variant.
</span><span class="cx"> for (auto& variant : sizeVariants) {
</span><span class="cx"> GlyphData sizeVariant;
</span><span class="cx"> sizeVariant.glyph = variant;
</span><del>- sizeVariant.font = &primaryFont;
</del><ins>+ sizeVariant.font = baseGlyph.font;
</ins><span class="cx"> data.setSizeVariantMode(sizeVariant);
</span><span class="cx"> if (boundsForGlyph(sizeVariant).height() >= displayOperatorMinHeight)
</span><span class="cx"> return data;
</span><span class="lines">@@ -527,25 +532,26 @@
</span><span class="cx"> return data;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-RenderMathMLOperator::StretchyData RenderMathMLOperator::findStretchyData(UChar character, float* maximumGlyphWidth)
</del><ins>+RenderMathMLOperator::StretchyData RenderMathMLOperator::findStretchyData(float* maximumGlyphWidth)
</ins><span class="cx"> {
</span><span class="cx"> ASSERT(!maximumGlyphWidth || m_isVertical);
</span><span class="cx">
</span><span class="cx"> StretchyData data;
</span><span class="cx"> StretchyData assemblyData;
</span><span class="cx">
</span><del>- const auto& primaryFont = style().fontCascade().primaryFont();
- GlyphData baseGlyph = style().fontCascade().glyphDataForCharacter(character, !style().isLeftToRightDirection());
</del><ins>+ GlyphData baseGlyph;
+ if (!getBaseGlyph(style(), baseGlyph))
+ return data;
</ins><span class="cx">
</span><del>- if (primaryFont.mathData() && baseGlyph.font == &primaryFont) {
</del><ins>+ if (baseGlyph.font->mathData()) {
</ins><span class="cx"> Vector<Glyph> sizeVariants;
</span><span class="cx"> Vector<OpenTypeMathData::AssemblyPart> assemblyParts;
</span><del>- primaryFont.mathData()->getMathVariants(baseGlyph.glyph, m_isVertical, sizeVariants, assemblyParts);
</del><ins>+ baseGlyph.font->mathData()->getMathVariants(baseGlyph.glyph, m_isVertical, sizeVariants, assemblyParts);
</ins><span class="cx"> // We verify the size variants.
</span><span class="cx"> for (auto& variant : sizeVariants) {
</span><span class="cx"> GlyphData sizeVariant;
</span><span class="cx"> sizeVariant.glyph = variant;
</span><del>- sizeVariant.font = &primaryFont;
</del><ins>+ sizeVariant.font = baseGlyph.font;
</ins><span class="cx"> if (maximumGlyphWidth)
</span><span class="cx"> *maximumGlyphWidth = std::max(*maximumGlyphWidth, advanceWidthForGlyph(sizeVariant));
</span><span class="cx"> else {
</span><span class="lines">@@ -567,7 +573,7 @@
</span><span class="cx"> const StretchyCharacter* stretchyCharacter = nullptr;
</span><span class="cx"> const unsigned maxIndex = WTF_ARRAY_LENGTH(stretchyCharacters);
</span><span class="cx"> for (unsigned index = 0; index < maxIndex; ++index) {
</span><del>- if (stretchyCharacters[index].character == character) {
</del><ins>+ if (stretchyCharacters[index].character == m_textContent) {
</ins><span class="cx"> stretchyCharacter = &stretchyCharacters[index];
</span><span class="cx"> if (!style().isLeftToRightDirection() && index < leftRightPairsCount * 2) {
</span><span class="cx"> // If we are in right-to-left direction we select the mirrored form by adding -1 or +1 according to the parity of index.
</span><span class="lines">@@ -641,14 +647,14 @@
</span><span class="cx"> return;
</span><span class="cx">
</span><span class="cx"> if (m_isVertical && isLargeOperatorInDisplayStyle())
</span><del>- m_stretchyData = getDisplayStyleLargeOperator(m_textContent);
</del><ins>+ m_stretchyData = getDisplayStyleLargeOperator();
</ins><span class="cx"> else {
</span><span class="cx"> // We do not stretch if the base glyph is large enough.
</span><span class="cx"> GlyphData baseGlyph = style().fontCascade().glyphDataForCharacter(m_textContent, !style().isLeftToRightDirection());
</span><span class="cx"> float baseSize = m_isVertical ? heightForGlyph(baseGlyph) : advanceWidthForGlyph(baseGlyph);
</span><span class="cx"> if (stretchSize() <= baseSize)
</span><span class="cx"> return;
</span><del>- m_stretchyData = findStretchyData(m_textContent, nullptr);
</del><ins>+ m_stretchyData = findStretchyData(nullptr);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> if (m_isVertical && m_stretchyData.mode() == DrawSizeVariant) {
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingmathmlRenderMathMLOperatorh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/mathml/RenderMathMLOperator.h (200186 => 200187)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/mathml/RenderMathMLOperator.h        2016-04-28 12:18:23 UTC (rev 200186)
+++ trunk/Source/WebCore/rendering/mathml/RenderMathMLOperator.h        2016-04-28 12:20:51 UTC (rev 200187)
</span><span class="lines">@@ -141,9 +141,10 @@
</span><span class="cx">
</span><span class="cx"> bool shouldAllowStretching() const;
</span><span class="cx">
</span><ins>+ bool getBaseGlyph(const RenderStyle&, GlyphData&) const;
</ins><span class="cx"> bool getGlyphAssemblyFallBack(Vector<OpenTypeMathData::AssemblyPart>, StretchyData&) const;
</span><del>- StretchyData getDisplayStyleLargeOperator(UChar) const;
- StretchyData findStretchyData(UChar, float* maximumGlyphWidth);
</del><ins>+ StretchyData getDisplayStyleLargeOperator() const;
+ StretchyData findStretchyData(float* maximumGlyphWidth);
</ins><span class="cx">
</span><span class="cx"> enum GlyphPaintTrimming {
</span><span class="cx"> TrimTop,
</span></span></pre>
</div>
</div>
</body>
</html>