<!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>[205101] 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/205101">205101</a></dd>
<dt>Author</dt> <dd>fred.wang@free.fr</dd>
<dt>Date</dt> <dd>2016-08-28 02:35:33 -0700 (Sun, 28 Aug 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>Improve parsing of the menclose notation attribute value
https://bugs.webkit.org/show_bug.cgi?id=161045

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

Source/WebCore:

We improve the way the list of menclose notations is parsed to avoid allocating a vector and
accept any whitespace as separators.

New test cases in mathml/presentation/menclose-notation-equivalence.html

* mathml/MathMLMencloseElement.cpp: Include HTMLParserIdioms.h to use isHTMLSpace.
(WebCore::MathMLMencloseElement::addNotationFlags): Helper function to perform the relevant
addNotation calls from a notation name.
(WebCore::MathMLMencloseElement::parseNotationAttribute): Use only simple string operations
to determine the list of notations.
* mathml/MathMLMencloseElement.h: Declare the new helper function.

LayoutTests:

We add some cases in menclose-notation-equivalence to verify that one can use any sequence of
whitespace to separate notation values. We try with 0, 1, 2 or 3 notation values.

* mathml/presentation/menclose-notation-equivalence-expected.html:
* mathml/presentation/menclose-notation-equivalence.html:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsmathmlpresentationmenclosenotationequivalenceexpectedhtml">trunk/LayoutTests/mathml/presentation/menclose-notation-equivalence-expected.html</a></li>
<li><a href="#trunkLayoutTestsmathmlpresentationmenclosenotationequivalencehtml">trunk/LayoutTests/mathml/presentation/menclose-notation-equivalence.html</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoremathmlMathMLMencloseElementcpp">trunk/Source/WebCore/mathml/MathMLMencloseElement.cpp</a></li>
<li><a href="#trunkSourceWebCoremathmlMathMLMencloseElementh">trunk/Source/WebCore/mathml/MathMLMencloseElement.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (205100 => 205101)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2016-08-28 08:50:57 UTC (rev 205100)
+++ trunk/LayoutTests/ChangeLog        2016-08-28 09:35:33 UTC (rev 205101)
</span><span class="lines">@@ -1,5 +1,18 @@
</span><span class="cx"> 2016-08-28  Frederic Wang  &lt;fwang@igalia.com&gt;
</span><span class="cx"> 
</span><ins>+        Improve parsing of the menclose notation attribute value
+        https://bugs.webkit.org/show_bug.cgi?id=161045
+
+        Reviewed by Darin Adler.
+
+        We add some cases in menclose-notation-equivalence to verify that one can use any sequence of
+        whitespace to separate notation values. We try with 0, 1, 2 or 3 notation values.
+
+        * mathml/presentation/menclose-notation-equivalence-expected.html:
+        * mathml/presentation/menclose-notation-equivalence.html:
+
+2016-08-28  Frederic Wang  &lt;fwang@igalia.com&gt;
+
</ins><span class="cx">         More cleanup for the mpadded implementation
</span><span class="cx">         https://bugs.webkit.org/show_bug.cgi?id=161136
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkLayoutTestsmathmlpresentationmenclosenotationequivalenceexpectedhtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/mathml/presentation/menclose-notation-equivalence-expected.html (205100 => 205101)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/mathml/presentation/menclose-notation-equivalence-expected.html        2016-08-28 08:50:57 UTC (rev 205100)
+++ trunk/LayoutTests/mathml/presentation/menclose-notation-equivalence-expected.html        2016-08-28 09:35:33 UTC (rev 205101)
</span><span class="lines">@@ -25,5 +25,13 @@
</span><span class="cx">     &lt;!-- menclose notations are independent of overall directionality --&gt;
</span><span class="cx">     &lt;math&gt;&lt;mrow&gt;&lt;menclose notation=&quot;left updiagonalstrike&quot;&gt;&lt;mspace width=&quot;100px&quot; height=&quot;50px&quot; mathbackground=&quot;red&quot;/&gt;&lt;/menclose&gt;&lt;/mrow&gt;&lt;/math&gt;
</span><span class="cx"> 
</span><ins>+    &lt;!-- menclose notations can be separated by any sequence of whitespace. --&gt;
+    &lt;p&gt;
+      &lt;math&gt;&lt;mrow&gt;&lt;menclose notation=&quot;&quot;&gt;&lt;mspace width=&quot;100px&quot; height=&quot;50px&quot; mathbackground=&quot;red&quot;/&gt;&lt;/menclose&gt;&lt;/mrow&gt;&lt;/math&gt;
+      &lt;math&gt;&lt;mrow&gt;&lt;menclose notation=&quot;top&quot;&gt;&lt;mspace width=&quot;100px&quot; height=&quot;50px&quot; mathbackground=&quot;red&quot;/&gt;&lt;/menclose&gt;&lt;/mrow&gt;&lt;/math&gt;
+      &lt;math&gt;&lt;mrow&gt;&lt;menclose notation=&quot;top circle&quot;&gt;&lt;mspace width=&quot;100px&quot; height=&quot;50px&quot; mathbackground=&quot;red&quot;/&gt;&lt;/menclose&gt;&lt;/mrow&gt;&lt;/math&gt;
+      &lt;math&gt;&lt;mrow&gt;&lt;menclose notation=&quot;top circle horizontalstrike&quot;&gt;&lt;mspace width=&quot;100px&quot; height=&quot;50px&quot; mathbackground=&quot;red&quot;/&gt;&lt;/menclose&gt;&lt;/mrow&gt;&lt;/math&gt;
+    &lt;/p&gt;
+
</ins><span class="cx">   &lt;/body&gt;
</span><span class="cx"> &lt;/html&gt;
</span></span></pre></div>
<a id="trunkLayoutTestsmathmlpresentationmenclosenotationequivalencehtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/mathml/presentation/menclose-notation-equivalence.html (205100 => 205101)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/mathml/presentation/menclose-notation-equivalence.html        2016-08-28 08:50:57 UTC (rev 205100)
+++ trunk/LayoutTests/mathml/presentation/menclose-notation-equivalence.html        2016-08-28 09:35:33 UTC (rev 205101)
</span><span class="lines">@@ -25,5 +25,13 @@
</span><span class="cx">     &lt;!-- menclose notations are independent of overall directionality --&gt;
</span><span class="cx">     &lt;math dir=&quot;rtl&quot;&gt;&lt;mrow&gt;&lt;menclose notation=&quot;left updiagonalstrike&quot;&gt;&lt;mspace width=&quot;100px&quot; height=&quot;50px&quot; mathbackground=&quot;red&quot;/&gt;&lt;/menclose&gt;&lt;/mrow&gt;&lt;/math&gt;
</span><span class="cx"> 
</span><ins>+    &lt;!-- menclose notations can be separated by any sequence of whitespace. --&gt;
+    &lt;p&gt;
+      &lt;math&gt;&lt;mrow&gt;&lt;menclose notation=&quot;&amp;#x20;&amp;#x9;&amp;#xA;&amp;#xD;&amp;#x20;&amp;#x9;&amp;#xA;&amp;#xD;&quot;&gt;&lt;mspace width=&quot;100px&quot; height=&quot;50px&quot; mathbackground=&quot;red&quot;/&gt;&lt;/menclose&gt;&lt;/mrow&gt;&lt;/math&gt;
+      &lt;math&gt;&lt;mrow&gt;&lt;menclose notation=&quot;&amp;#x20;&amp;#x9;&amp;#xA;&amp;#xD;&amp;#x20;&amp;#x9;&amp;#xA;&amp;#xD;top&amp;#x20;&amp;#x9;&amp;#xA;&amp;#xD;&amp;#x20;&amp;#x9;&amp;#xA;&amp;#xD;&quot;&gt;&lt;mspace width=&quot;100px&quot; height=&quot;50px&quot; mathbackground=&quot;red&quot;/&gt;&lt;/menclose&gt;&lt;/mrow&gt;&lt;/math&gt;
+      &lt;math&gt;&lt;mrow&gt;&lt;menclose notation=&quot;&amp;#x20;&amp;#x9;&amp;#xA;&amp;#xD;&amp;#x20;&amp;#x9;&amp;#xA;&amp;#xD;top&amp;#x20;&amp;#x9;&amp;#xA;&amp;#xD;&amp;#x20;&amp;#x9;&amp;#xA;&amp;#xD;circle&amp;#x20;&amp;#x9;&amp;#xA;&amp;#xD;&amp;#x20;&amp;#x9;&amp;#xA;&amp;#xD;&quot;&gt;&lt;mspace width=&quot;100px&quot; height=&quot;50px&quot; mathbackground=&quot;red&quot;/&gt;&lt;/menclose&gt;&lt;/mrow&gt;&lt;/math&gt;
+      &lt;math&gt;&lt;mrow&gt;&lt;menclose notation=&quot;&amp;#x20;&amp;#x9;&amp;#xA;&amp;#xD;&amp;#x20;&amp;#x9;&amp;#xA;&amp;#xD;top&amp;#x20;&amp;#x9;&amp;#xA;&amp;#xD;&amp;#x20;&amp;#x9;&amp;#xA;&amp;#xD;circle&amp;#x20;&amp;#x9;&amp;#xA;&amp;#xD;&amp;#x20;&amp;#x9;&amp;#xA;&amp;#xD;horizontalstrike&amp;#x20;&amp;#x9;&amp;#xA;&amp;#xD;&amp;#x20;&amp;#x9;&amp;#xA;&amp;#xD;&quot;&gt;&lt;mspace width=&quot;100px&quot; height=&quot;50px&quot; mathbackground=&quot;red&quot;/&gt;&lt;/menclose&gt;&lt;/mrow&gt;&lt;/math&gt;
+    &lt;/p&gt;
+
</ins><span class="cx">   &lt;/body&gt;
</span><span class="cx"> &lt;/html&gt;
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (205100 => 205101)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-08-28 08:50:57 UTC (rev 205100)
+++ trunk/Source/WebCore/ChangeLog        2016-08-28 09:35:33 UTC (rev 205101)
</span><span class="lines">@@ -1,5 +1,24 @@
</span><span class="cx"> 2016-08-28  Frederic Wang  &lt;fwang@igalia.com&gt;
</span><span class="cx"> 
</span><ins>+        Improve parsing of the menclose notation attribute value
+        https://bugs.webkit.org/show_bug.cgi?id=161045
+
+        Reviewed by Darin Adler.
+
+        We improve the way the list of menclose notations is parsed to avoid allocating a vector and
+        accept any whitespace as separators.
+
+        New test cases in mathml/presentation/menclose-notation-equivalence.html
+
+        * mathml/MathMLMencloseElement.cpp: Include HTMLParserIdioms.h to use isHTMLSpace.
+        (WebCore::MathMLMencloseElement::addNotationFlags): Helper function to perform the relevant
+        addNotation calls from a notation name.
+        (WebCore::MathMLMencloseElement::parseNotationAttribute): Use only simple string operations
+        to determine the list of notations.
+        * mathml/MathMLMencloseElement.h: Declare the new helper function.
+
+2016-08-28  Frederic Wang  &lt;fwang@igalia.com&gt;
+
</ins><span class="cx">         Make MathMLSpaceElement and MathMLTokenElement inherit from MathMLPresentationElement
</span><span class="cx">         https://bugs.webkit.org/show_bug.cgi?id=161232
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoremathmlMathMLMencloseElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/mathml/MathMLMencloseElement.cpp (205100 => 205101)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/mathml/MathMLMencloseElement.cpp        2016-08-28 08:50:57 UTC (rev 205100)
+++ trunk/Source/WebCore/mathml/MathMLMencloseElement.cpp        2016-08-28 09:35:33 UTC (rev 205101)
</span><span class="lines">@@ -29,6 +29,7 @@
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(MATHML)
</span><span class="cx"> 
</span><ins>+#include &quot;HTMLParserIdioms.h&quot;
</ins><span class="cx"> #include &quot;MathMLNames.h&quot;
</span><span class="cx"> #include &quot;RenderMathMLMenclose.h&quot;
</span><span class="cx"> 
</span><span class="lines">@@ -54,6 +55,49 @@
</span><span class="cx">     return createRenderer&lt;RenderMathMLMenclose&gt;(*this, WTFMove(style));
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void MathMLMencloseElement::addNotationFlags(StringView notation)
+{
+    ASSERT(m_notationFlags);
+    if (notation == &quot;longdiv&quot;) {
+        addNotation(LongDiv);
+    } else if (notation == &quot;roundedbox&quot;) {
+        addNotation(RoundedBox);
+    } else if (notation == &quot;circle&quot;) {
+        addNotation(Circle);
+    } else if (notation == &quot;left&quot;) {
+        addNotation(Left);
+    } else if (notation == &quot;right&quot;) {
+        addNotation(Right);
+    } else if (notation == &quot;top&quot;) {
+        addNotation(Top);
+    } else if (notation == &quot;bottom&quot;) {
+        addNotation(Bottom);
+    } else if (notation == &quot;updiagonalstrike&quot;) {
+        addNotation(UpDiagonalStrike);
+    } else if (notation == &quot;downdiagonalstrike&quot;) {
+        addNotation(DownDiagonalStrike);
+    } else if (notation == &quot;verticalstrike&quot;) {
+        addNotation(VerticalStrike);
+    } else if (notation == &quot;horizontalstrike&quot;) {
+        addNotation(HorizontalStrike);
+    } else if (notation == &quot;updiagonalarrow&quot;) {
+        addNotation(UpDiagonalArrow);
+    } else if (notation == &quot;phasorangle&quot;) {
+        addNotation(PhasorAngle);
+    } else if (notation == &quot;box&quot;) {
+        addNotation(Left);
+        addNotation(Right);
+        addNotation(Top);
+        addNotation(Bottom);
+    } else if (notation == &quot;actuarial&quot;) {
+        addNotation(Right);
+        addNotation(Top);
+    } else if (notation == &quot;madruwb&quot;) {
+        addNotation(Right);
+        addNotation(Bottom);
+    }
+}
+
</ins><span class="cx"> void MathMLMencloseElement::parseNotationAttribute()
</span><span class="cx"> {
</span><span class="cx">     clearNotations();
</span><span class="lines">@@ -61,48 +105,20 @@
</span><span class="cx">         addNotation(LongDiv); // The default value is longdiv.
</span><span class="cx">         return;
</span><span class="cx">     }
</span><del>-    auto&amp; value = attributeWithoutSynchronization(notationAttr);
-    Vector&lt;String&gt; notationsList;
-    String(value).split(' ', notationsList);
-    for (auto&amp; notation : notationsList) {
-        if (notation == &quot;longdiv&quot;) {
-            addNotation(LongDiv);
-        } else if (notation == &quot;roundedbox&quot;) {
-            addNotation(RoundedBox);
-        } else if (notation == &quot;circle&quot;) {
-            addNotation(Circle);
-        } else if (notation == &quot;left&quot;) {
-            addNotation(Left);
-        } else if (notation == &quot;right&quot;) {
-            addNotation(Right);
-        } else if (notation == &quot;top&quot;) {
-            addNotation(Top);
-        } else if (notation == &quot;bottom&quot;) {
-            addNotation(Bottom);
-        } else if (notation == &quot;updiagonalstrike&quot;) {
-            addNotation(UpDiagonalStrike);
-        } else if (notation == &quot;downdiagonalstrike&quot;) {
-            addNotation(DownDiagonalStrike);
-        } else if (notation == &quot;verticalstrike&quot;) {
-            addNotation(VerticalStrike);
-        } else if (notation == &quot;horizontalstrike&quot;) {
-            addNotation(HorizontalStrike);
-        } else if (notation == &quot;updiagonalarrow&quot;) {
-            addNotation(UpDiagonalArrow);
-        } else if (notation == &quot;phasorangle&quot;) {
-            addNotation(PhasorAngle);
-        } else if (notation == &quot;box&quot;) {
-            addNotation(Left);
-            addNotation(Right);
-            addNotation(Top);
-            addNotation(Bottom);
-        } else if (notation == &quot;actuarial&quot;) {
-            addNotation(Right);
-            addNotation(Top);
-        } else if (notation == &quot;madruwb&quot;) {
-            addNotation(Right);
-            addNotation(Bottom);
</del><ins>+    // We parse the list of whitespace-separated notation names.
+    StringView value = attributeWithoutSynchronization(notationAttr).string();
+    unsigned length = value.length();
+    unsigned start = 0;
+    while (start &lt; length) {
+        if (isHTMLSpace(value[start])) {
+            start++;
+            continue;
</ins><span class="cx">         }
</span><ins>+        unsigned end = start + 1;
+        while (end &lt; length &amp;&amp; !isHTMLSpace(value[end]))
+            end++;
+        addNotationFlags(value.substring(start, end - start));
+        start = end;
</ins><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoremathmlMathMLMencloseElementh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/mathml/MathMLMencloseElement.h (205100 => 205101)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/mathml/MathMLMencloseElement.h        2016-08-28 08:50:57 UTC (rev 205100)
+++ trunk/Source/WebCore/mathml/MathMLMencloseElement.h        2016-08-28 09:35:33 UTC (rev 205101)
</span><span class="lines">@@ -62,6 +62,7 @@
</span><span class="cx">     void parseNotationAttribute();
</span><span class="cx">     void clearNotations() { m_notationFlags = 0; }
</span><span class="cx">     void addNotation(MencloseNotationFlag notationFlag) { m_notationFlags.value() |= notationFlag; }
</span><ins>+    void addNotationFlags(StringView notation);
</ins><span class="cx">     Optional&lt;uint16_t&gt; m_notationFlags;
</span><span class="cx"> };
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>