Changeset 205101 in webkit
- Timestamp:
- Aug 28, 2016 2:35:33 AM (8 years ago)
- Location:
- trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r205098 r205101 1 2016-08-28 Frederic Wang <fwang@igalia.com> 2 3 Improve parsing of the menclose notation attribute value 4 https://bugs.webkit.org/show_bug.cgi?id=161045 5 6 Reviewed by Darin Adler. 7 8 We add some cases in menclose-notation-equivalence to verify that one can use any sequence of 9 whitespace to separate notation values. We try with 0, 1, 2 or 3 notation values. 10 11 * mathml/presentation/menclose-notation-equivalence-expected.html: 12 * mathml/presentation/menclose-notation-equivalence.html: 13 1 14 2016-08-28 Frederic Wang <fwang@igalia.com> 2 15 -
trunk/LayoutTests/mathml/presentation/menclose-notation-equivalence-expected.html
r199980 r205101 26 26 <math><mrow><menclose notation="left updiagonalstrike"><mspace width="100px" height="50px" mathbackground="red"/></menclose></mrow></math> 27 27 28 <!-- menclose notations can be separated by any sequence of whitespace. --> 29 <p> 30 <math><mrow><menclose notation=""><mspace width="100px" height="50px" mathbackground="red"/></menclose></mrow></math> 31 <math><mrow><menclose notation="top"><mspace width="100px" height="50px" mathbackground="red"/></menclose></mrow></math> 32 <math><mrow><menclose notation="top circle"><mspace width="100px" height="50px" mathbackground="red"/></menclose></mrow></math> 33 <math><mrow><menclose notation="top circle horizontalstrike"><mspace width="100px" height="50px" mathbackground="red"/></menclose></mrow></math> 34 </p> 35 28 36 </body> 29 37 </html> -
trunk/LayoutTests/mathml/presentation/menclose-notation-equivalence.html
r199980 r205101 26 26 <math dir="rtl"><mrow><menclose notation="left updiagonalstrike"><mspace width="100px" height="50px" mathbackground="red"/></menclose></mrow></math> 27 27 28 <!-- menclose notations can be separated by any sequence of whitespace. --> 29 <p> 30 <math><mrow><menclose notation=" 	

 	

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

 	

top 	

 	

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

 	

top 	

 	

circle 	

 	

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

 	

top 	

 	

circle 	

 	

horizontalstrike 	

 	

"><mspace width="100px" height="50px" mathbackground="red"/></menclose></mrow></math> 34 </p> 35 28 36 </body> 29 37 </html> -
trunk/Source/WebCore/ChangeLog
r205100 r205101 1 2016-08-28 Frederic Wang <fwang@igalia.com> 2 3 Improve parsing of the menclose notation attribute value 4 https://bugs.webkit.org/show_bug.cgi?id=161045 5 6 Reviewed by Darin Adler. 7 8 We improve the way the list of menclose notations is parsed to avoid allocating a vector and 9 accept any whitespace as separators. 10 11 New test cases in mathml/presentation/menclose-notation-equivalence.html 12 13 * mathml/MathMLMencloseElement.cpp: Include HTMLParserIdioms.h to use isHTMLSpace. 14 (WebCore::MathMLMencloseElement::addNotationFlags): Helper function to perform the relevant 15 addNotation calls from a notation name. 16 (WebCore::MathMLMencloseElement::parseNotationAttribute): Use only simple string operations 17 to determine the list of notations. 18 * mathml/MathMLMencloseElement.h: Declare the new helper function. 19 1 20 2016-08-28 Frederic Wang <fwang@igalia.com> 2 21 -
trunk/Source/WebCore/mathml/MathMLMencloseElement.cpp
r204885 r205101 30 30 #if ENABLE(MATHML) 31 31 32 #include "HTMLParserIdioms.h" 32 33 #include "MathMLNames.h" 33 34 #include "RenderMathMLMenclose.h" … … 55 56 } 56 57 58 void MathMLMencloseElement::addNotationFlags(StringView notation) 59 { 60 ASSERT(m_notationFlags); 61 if (notation == "longdiv") { 62 addNotation(LongDiv); 63 } else if (notation == "roundedbox") { 64 addNotation(RoundedBox); 65 } else if (notation == "circle") { 66 addNotation(Circle); 67 } else if (notation == "left") { 68 addNotation(Left); 69 } else if (notation == "right") { 70 addNotation(Right); 71 } else if (notation == "top") { 72 addNotation(Top); 73 } else if (notation == "bottom") { 74 addNotation(Bottom); 75 } else if (notation == "updiagonalstrike") { 76 addNotation(UpDiagonalStrike); 77 } else if (notation == "downdiagonalstrike") { 78 addNotation(DownDiagonalStrike); 79 } else if (notation == "verticalstrike") { 80 addNotation(VerticalStrike); 81 } else if (notation == "horizontalstrike") { 82 addNotation(HorizontalStrike); 83 } else if (notation == "updiagonalarrow") { 84 addNotation(UpDiagonalArrow); 85 } else if (notation == "phasorangle") { 86 addNotation(PhasorAngle); 87 } else if (notation == "box") { 88 addNotation(Left); 89 addNotation(Right); 90 addNotation(Top); 91 addNotation(Bottom); 92 } else if (notation == "actuarial") { 93 addNotation(Right); 94 addNotation(Top); 95 } else if (notation == "madruwb") { 96 addNotation(Right); 97 addNotation(Bottom); 98 } 99 } 100 57 101 void MathMLMencloseElement::parseNotationAttribute() 58 102 { … … 62 106 return; 63 107 } 64 auto& value = attributeWithoutSynchronization(notationAttr); 65 Vector<String> notationsList; 66 String(value).split(' ', notationsList); 67 for (auto& notation : notationsList) { 68 if (notation == "longdiv") { 69 addNotation(LongDiv); 70 } else if (notation == "roundedbox") { 71 addNotation(RoundedBox); 72 } else if (notation == "circle") { 73 addNotation(Circle); 74 } else if (notation == "left") { 75 addNotation(Left); 76 } else if (notation == "right") { 77 addNotation(Right); 78 } else if (notation == "top") { 79 addNotation(Top); 80 } else if (notation == "bottom") { 81 addNotation(Bottom); 82 } else if (notation == "updiagonalstrike") { 83 addNotation(UpDiagonalStrike); 84 } else if (notation == "downdiagonalstrike") { 85 addNotation(DownDiagonalStrike); 86 } else if (notation == "verticalstrike") { 87 addNotation(VerticalStrike); 88 } else if (notation == "horizontalstrike") { 89 addNotation(HorizontalStrike); 90 } else if (notation == "updiagonalarrow") { 91 addNotation(UpDiagonalArrow); 92 } else if (notation == "phasorangle") { 93 addNotation(PhasorAngle); 94 } else if (notation == "box") { 95 addNotation(Left); 96 addNotation(Right); 97 addNotation(Top); 98 addNotation(Bottom); 99 } else if (notation == "actuarial") { 100 addNotation(Right); 101 addNotation(Top); 102 } else if (notation == "madruwb") { 103 addNotation(Right); 104 addNotation(Bottom); 108 // We parse the list of whitespace-separated notation names. 109 StringView value = attributeWithoutSynchronization(notationAttr).string(); 110 unsigned length = value.length(); 111 unsigned start = 0; 112 while (start < length) { 113 if (isHTMLSpace(value[start])) { 114 start++; 115 continue; 105 116 } 117 unsigned end = start + 1; 118 while (end < length && !isHTMLSpace(value[end])) 119 end++; 120 addNotationFlags(value.substring(start, end - start)); 121 start = end; 106 122 } 107 123 } -
trunk/Source/WebCore/mathml/MathMLMencloseElement.h
r204885 r205101 63 63 void clearNotations() { m_notationFlags = 0; } 64 64 void addNotation(MencloseNotationFlag notationFlag) { m_notationFlags.value() |= notationFlag; } 65 void addNotationFlags(StringView notation); 65 66 Optional<uint16_t> m_notationFlags; 66 67 };
Note: See TracChangeset
for help on using the changeset viewer.