Title: [205101] trunk
- Revision
- 205101
- Author
- [email protected]
- Date
- 2016-08-28 02:35:33 -0700 (Sun, 28 Aug 2016)
Log Message
Improve parsing of the menclose notation attribute value
https://bugs.webkit.org/show_bug.cgi?id=161045
Patch by Frederic Wang <[email protected]> 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:
Modified Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (205100 => 205101)
--- trunk/LayoutTests/ChangeLog 2016-08-28 08:50:57 UTC (rev 205100)
+++ trunk/LayoutTests/ChangeLog 2016-08-28 09:35:33 UTC (rev 205101)
@@ -1,5 +1,18 @@
2016-08-28 Frederic Wang <[email protected]>
+ 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 <[email protected]>
+
More cleanup for the mpadded implementation
https://bugs.webkit.org/show_bug.cgi?id=161136
Modified: trunk/LayoutTests/mathml/presentation/menclose-notation-equivalence-expected.html (205100 => 205101)
--- 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)
@@ -25,5 +25,13 @@
<!-- menclose notations are independent of overall directionality -->
<math><mrow><menclose notation="left updiagonalstrike"><mspace width="100px" height="50px" mathbackground="red"/></menclose></mrow></math>
+ <!-- menclose notations can be separated by any sequence of whitespace. -->
+ <p>
+ <math><mrow><menclose notation=""><mspace width="100px" height="50px" mathbackground="red"/></menclose></mrow></math>
+ <math><mrow><menclose notation="top"><mspace width="100px" height="50px" mathbackground="red"/></menclose></mrow></math>
+ <math><mrow><menclose notation="top circle"><mspace width="100px" height="50px" mathbackground="red"/></menclose></mrow></math>
+ <math><mrow><menclose notation="top circle horizontalstrike"><mspace width="100px" height="50px" mathbackground="red"/></menclose></mrow></math>
+ </p>
+
</body>
</html>
Modified: trunk/LayoutTests/mathml/presentation/menclose-notation-equivalence.html (205100 => 205101)
--- 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)
@@ -25,5 +25,13 @@
<!-- menclose notations are independent of overall directionality -->
<math dir="rtl"><mrow><menclose notation="left updiagonalstrike"><mspace width="100px" height="50px" mathbackground="red"/></menclose></mrow></math>
+ <!-- menclose notations can be separated by any sequence of whitespace. -->
+ <p>
+ <math><mrow><menclose notation=" 	

 	

"><mspace width="100px" height="50px" mathbackground="red"/></menclose></mrow></math>
+ <math><mrow><menclose notation=" 	

 	

top 	

 	

"><mspace width="100px" height="50px" mathbackground="red"/></menclose></mrow></math>
+ <math><mrow><menclose notation=" 	

 	

top 	

 	

circle 	

 	

"><mspace width="100px" height="50px" mathbackground="red"/></menclose></mrow></math>
+ <math><mrow><menclose notation=" 	

 	

top 	

 	

circle 	

 	

horizontalstrike 	

 	

"><mspace width="100px" height="50px" mathbackground="red"/></menclose></mrow></math>
+ </p>
+
</body>
</html>
Modified: trunk/Source/WebCore/ChangeLog (205100 => 205101)
--- 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)
@@ -1,5 +1,24 @@
2016-08-28 Frederic Wang <[email protected]>
+ 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 <[email protected]>
+
Make MathMLSpaceElement and MathMLTokenElement inherit from MathMLPresentationElement
https://bugs.webkit.org/show_bug.cgi?id=161232
Modified: trunk/Source/WebCore/mathml/MathMLMencloseElement.cpp (205100 => 205101)
--- 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)
@@ -29,6 +29,7 @@
#if ENABLE(MATHML)
+#include "HTMLParserIdioms.h"
#include "MathMLNames.h"
#include "RenderMathMLMenclose.h"
@@ -54,6 +55,49 @@
return createRenderer<RenderMathMLMenclose>(*this, WTFMove(style));
}
+void MathMLMencloseElement::addNotationFlags(StringView notation)
+{
+ ASSERT(m_notationFlags);
+ if (notation == "longdiv") {
+ addNotation(LongDiv);
+ } else if (notation == "roundedbox") {
+ addNotation(RoundedBox);
+ } else if (notation == "circle") {
+ addNotation(Circle);
+ } else if (notation == "left") {
+ addNotation(Left);
+ } else if (notation == "right") {
+ addNotation(Right);
+ } else if (notation == "top") {
+ addNotation(Top);
+ } else if (notation == "bottom") {
+ addNotation(Bottom);
+ } else if (notation == "updiagonalstrike") {
+ addNotation(UpDiagonalStrike);
+ } else if (notation == "downdiagonalstrike") {
+ addNotation(DownDiagonalStrike);
+ } else if (notation == "verticalstrike") {
+ addNotation(VerticalStrike);
+ } else if (notation == "horizontalstrike") {
+ addNotation(HorizontalStrike);
+ } else if (notation == "updiagonalarrow") {
+ addNotation(UpDiagonalArrow);
+ } else if (notation == "phasorangle") {
+ addNotation(PhasorAngle);
+ } else if (notation == "box") {
+ addNotation(Left);
+ addNotation(Right);
+ addNotation(Top);
+ addNotation(Bottom);
+ } else if (notation == "actuarial") {
+ addNotation(Right);
+ addNotation(Top);
+ } else if (notation == "madruwb") {
+ addNotation(Right);
+ addNotation(Bottom);
+ }
+}
+
void MathMLMencloseElement::parseNotationAttribute()
{
clearNotations();
@@ -61,48 +105,20 @@
addNotation(LongDiv); // The default value is longdiv.
return;
}
- auto& value = attributeWithoutSynchronization(notationAttr);
- Vector<String> notationsList;
- String(value).split(' ', notationsList);
- for (auto& notation : notationsList) {
- if (notation == "longdiv") {
- addNotation(LongDiv);
- } else if (notation == "roundedbox") {
- addNotation(RoundedBox);
- } else if (notation == "circle") {
- addNotation(Circle);
- } else if (notation == "left") {
- addNotation(Left);
- } else if (notation == "right") {
- addNotation(Right);
- } else if (notation == "top") {
- addNotation(Top);
- } else if (notation == "bottom") {
- addNotation(Bottom);
- } else if (notation == "updiagonalstrike") {
- addNotation(UpDiagonalStrike);
- } else if (notation == "downdiagonalstrike") {
- addNotation(DownDiagonalStrike);
- } else if (notation == "verticalstrike") {
- addNotation(VerticalStrike);
- } else if (notation == "horizontalstrike") {
- addNotation(HorizontalStrike);
- } else if (notation == "updiagonalarrow") {
- addNotation(UpDiagonalArrow);
- } else if (notation == "phasorangle") {
- addNotation(PhasorAngle);
- } else if (notation == "box") {
- addNotation(Left);
- addNotation(Right);
- addNotation(Top);
- addNotation(Bottom);
- } else if (notation == "actuarial") {
- addNotation(Right);
- addNotation(Top);
- } else if (notation == "madruwb") {
- addNotation(Right);
- addNotation(Bottom);
+ // We parse the list of whitespace-separated notation names.
+ StringView value = attributeWithoutSynchronization(notationAttr).string();
+ unsigned length = value.length();
+ unsigned start = 0;
+ while (start < length) {
+ if (isHTMLSpace(value[start])) {
+ start++;
+ continue;
}
+ unsigned end = start + 1;
+ while (end < length && !isHTMLSpace(value[end]))
+ end++;
+ addNotationFlags(value.substring(start, end - start));
+ start = end;
}
}
Modified: trunk/Source/WebCore/mathml/MathMLMencloseElement.h (205100 => 205101)
--- 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)
@@ -62,6 +62,7 @@
void parseNotationAttribute();
void clearNotations() { m_notationFlags = 0; }
void addNotation(MencloseNotationFlag notationFlag) { m_notationFlags.value() |= notationFlag; }
+ void addNotationFlags(StringView notation);
Optional<uint16_t> m_notationFlags;
};
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes