Changeset 166065 in webkit
- Timestamp:
- Mar 21, 2014 9:19:36 AM (10 years ago)
- Location:
- trunk
- Files:
-
- 6 added
- 8 deleted
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r166064 r166065 1 2014-03-21 Frédéric Wang <fred.wang@free.fr> 2 3 Bug 130345 - Refine childShouldCreateRenderer for MathML elements 4 https://bugs.webkit.org/show_bug.cgi?id=130345 5 6 Reviewed by Chris Fleizach. 7 8 We update the references of some tests after the additional 9 restrictions on MathML children. We replace the foreign-*.html with a 10 single foreign-element-in-token.html and write more tests to verify the 11 accepted and reject content. 12 13 * mathml/msub-anonymous-child-render-crash-expected.txt: Update reference now that text is only allowed in some token MathML elements. 14 * mathml/presentation/annotation-children-expected.html: Added. 15 * mathml/presentation/annotation-children.html: Added. 16 * mathml/presentation/foreign-element-in-annotation-xml.html: Added. 17 * mathml/presentation/foreign-element-in-annotation-xml-expected.txt: Added. 18 * mathml/presentation/foreign-element-in-token-expected.txt: Added. 19 * mathml/presentation/foreign-element-in-token.html: Added. 20 * mathml/presentation/foreign-mi-expected-mismatch.html: Removed. 21 * mathml/presentation/foreign-mi.html: Removed. 22 * mathml/presentation/foreign-mn-expected-mismatch.html: Removed. 23 * mathml/presentation/foreign-mn.html: Removed. 24 * mathml/presentation/foreign-mtext-expected-mismatch.html: Removed. 25 * mathml/presentation/foreign-mtext-rejected-expected.html: Removed. 26 * mathml/presentation/foreign-mtext-rejected.html: Removed. 27 * mathml/presentation/foreign-mtext.html: Removed. 28 * mathml/presentation/semantics-2.html: the mtext elements can not be direct child of annotation-xml. wrap them in a math tag. 29 * mathml/presentation/semantics-3.html: ditto. 30 * mathml/presentation/semantics-4.html: ditto. 31 1 32 2014-03-21 Mark Lam <mark.lam@apple.com> 2 33 -
trunk/LayoutTests/mathml/msub-anonymous-child-render-crash-expected.txt
r128837 r166065 2 2 3 3 X 4 35 4 Y 6 37 5 X 8 39 6 2 10 7 Y 11 312 8 2 13 9 -
trunk/LayoutTests/mathml/presentation/semantics-2.html
r161430 r166065 3 3 <head> 4 4 <title>Semantics</title> 5 <style type="text/css"> 6 .nospacing { 7 border: 0 !important; 8 padding: 0 !important; 9 margin: 0 !important; 10 } 11 </style> 5 12 </head> 6 13 … … 13 20 <!-- Presentation MathML: the child is displayed --> 14 21 <p>presentation MathML ; annotation: <math><semantics><mtext>presentation MathML</mtext><annotation>annotation</annotation></semantics></math></p> 15 <p>presentation MathML ; annotation-xml: <math><semantics><mtext>presentation MathML</mtext><annotation-xml encoding="application/mathml-presentation+xml"><m text>annotation-xml</mtext></annotation-xml></semantics></math></p>22 <p>presentation MathML ; annotation-xml: <math><semantics><mtext>presentation MathML</mtext><annotation-xml encoding="application/mathml-presentation+xml"><math class="nospacing"><mtext>annotation-xml</mtext></math></annotation-xml></semantics></math></p> 16 23 17 24 <!-- Content MathML: the annotation is displayed --> 18 25 <p>content MathML ; annotation: <math><semantics><csymbol>content MathML</csymbol><annotation>annotation</annotation></semantics></math></p> 19 <p>content MathML ; annotation-xml: <math><semantics><csymbol>content MathML</csymbol><annotation-xml encoding="application/mathml-presentation+xml"><m text>annotation-xml</mtext></annotation-xml></semantics></math></p>26 <p>content MathML ; annotation-xml: <math><semantics><csymbol>content MathML</csymbol><annotation-xml encoding="application/mathml-presentation+xml"><math class="nospacing"><mtext>annotation-xml</mtext></math></annotation-xml></semantics></math></p> 20 27 21 28 </body> -
trunk/LayoutTests/mathml/presentation/semantics-3.html
r161430 r166065 3 3 <head> 4 4 <title>Semantics</title> 5 <style type="text/css"> 6 .nospacing { 7 border: 0 !important; 8 padding: 0 !important; 9 margin: 0 !important; 10 } 11 </style> 5 12 </head> 6 13 … … 12 19 --> 13 20 14 <p>annotation 1: <math><semantics><csymbol>Content MathML</csymbol><annotation>annotation</annotation><annotation>error</annotation><annotation-xml encoding="application/mathml-presentation+xml"><m text>error</mtext></annotation-xml></semantics></math></p>15 <p>annotation 2: <math><semantics><csymbol>Content MathML</csymbol><annotation encoding="application/x-tex">\sin x + 5</annotation><annotation>error</annotation><annotation-xml encoding="application/mathml-presentation+xml"><m text>error</mtext></annotation-xml></semantics></math></p>16 <p>annotation 3: <math><semantics><csymbol>Content MathML</csymbol><annotation src="external-resource">error</annotation><annotation>annotation</annotation><annotation-xml encoding="application/mathml-presentation+xml"><m text>error</mtext></annotation-xml></semantics></math></p>21 <p>annotation 1: <math><semantics><csymbol>Content MathML</csymbol><annotation>annotation</annotation><annotation>error</annotation><annotation-xml encoding="application/mathml-presentation+xml"><math class="nospacing"><mtext>error</mtext></math></annotation-xml></semantics></math></p> 22 <p>annotation 2: <math><semantics><csymbol>Content MathML</csymbol><annotation encoding="application/x-tex">\sin x + 5</annotation><annotation>error</annotation><annotation-xml encoding="application/mathml-presentation+xml"><math class="nospacing"><mtext>error</mtext></math></annotation-xml></semantics></math></p> 23 <p>annotation 3: <math><semantics><csymbol>Content MathML</csymbol><annotation src="external-resource">error</annotation><annotation>annotation</annotation><annotation-xml encoding="application/mathml-presentation+xml"><math class="nospacing"><mtext>error</mtext></math></annotation-xml></semantics></math></p> 17 24 18 <p>annotation-xml 1: <math><semantics><csymbol>Content MathML</csymbol><annotation-xml encoding="application/mathml-presentation+xml"><m text>application/mathml-presentation+xml</mtext></annotation-xml><annotation-xml encoding="application/mathml-presentation+xml"><mtext>error</mtext></annotation-xml><annotation>error</annotation></semantics></math></p>19 <p>annotation-xml 2: <math><semantics><csymbol>Content MathML</csymbol><annotation-xml encoding="MathML-Presentation"><m text>MathML-Presentation</mtext></annotation-xml><annotation-xml encoding="application/mathml-presentation+xml"><mtext>error</mtext></annotation-xml><annotation>error</annotation></semantics></math></p>20 <p>annotation-xml 3: <math><semantics><csymbol>Content MathML</csymbol><annotation-xml encoding="image/svg+xml"><svg width="20px" height="20px"><rect width="20px" height="20px" fill="red" stroke="none"/></svg></annotation-xml><annotation-xml encoding="application/mathml-presentation+xml"><m text>error</mtext></annotation-xml><annotation>error</annotation></semantics></math></p>21 <p>annotation-xml 4: <math><semantics><csymbol>Content MathML</csymbol><annotation-xml encoding="SVG1.1"><svg width="20px" height="20px"><rect width="20px" height="20px" fill="red" stroke="none"/></svg></annotation-xml><annotation-xml encoding="application/mathml-presentation+xml"><m text>error</mtext></annotation-xml><annotation>error</annotation></semantics></math></p>22 <p>annotation-xml 5: <math><semantics><csymbol>Content MathML</csymbol><annotation-xml encoding="application/xhtml+xml"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>application/xhtml+xml</title></head><body><p>application/xhtml+xml</p></body></html></annotation-xml><annotation-xml encoding="application/mathml-presentation+xml"><m text>error</mtext></annotation-xml><annotation>error</annotation></math></p>23 <p>annotation-xml 6: <math><semantics><csymbol>Content MathML</csymbol><annotation-xml encoding="text/html"><html><head><title>text/html</title></head><body><p>text/html</p></body></html></annotation-xml><annotation-xml encoding="application/mathml-presentation+xml"><m text>error</mtext></annotation-xml><annotation>error</annotation></semantics></math></p>24 <p>annotation-xml 7: <math><semantics><csymbol>Content MathML</csymbol><annotation-xml encoding="unknown"><m text>error</mtext></annotation-xml><annotation-xml encoding="application/mathml+xml"><mtext>error</mtext></annotation-xml><annotation-xml encoding="application/mathml-presentation+xml"><mtext>annotation-xml</mtext></annotation-xml><annotation>error</annotation></semantics></math></p>25 <p>annotation-xml 1: <math><semantics><csymbol>Content MathML</csymbol><annotation-xml encoding="application/mathml-presentation+xml"><math class="nospacing"><mtext>application/mathml-presentation+xml</mtext></math></annotation-xml><annotation-xml encoding="application/mathml-presentation+xml"><math class="nospacing"><mtext>error</mtext></math></annotation-xml><annotation>error</annotation></semantics></math></p> 26 <p>annotation-xml 2: <math><semantics><csymbol>Content MathML</csymbol><annotation-xml encoding="MathML-Presentation"><math class="nospacing"><mtext>MathML-Presentation</mtext></math></annotation-xml><annotation-xml encoding="application/mathml-presentation+xml"><math class="nospacing"><mtext>error</mtext></math></annotation-xml><annotation>error</annotation></semantics></math></p> 27 <p>annotation-xml 3: <math><semantics><csymbol>Content MathML</csymbol><annotation-xml encoding="image/svg+xml"><svg width="20px" height="20px"><rect width="20px" height="20px" fill="red" stroke="none"/></svg></annotation-xml><annotation-xml encoding="application/mathml-presentation+xml"><math class="nospacing"><mtext>error</mtext></math></annotation-xml><annotation>error</annotation></semantics></math></p> 28 <p>annotation-xml 4: <math><semantics><csymbol>Content MathML</csymbol><annotation-xml encoding="SVG1.1"><svg width="20px" height="20px"><rect width="20px" height="20px" fill="red" stroke="none"/></svg></annotation-xml><annotation-xml encoding="application/mathml-presentation+xml"><math class="nospacing"><mtext>error</mtext></math></annotation-xml><annotation>error</annotation></semantics></math></p> 29 <p>annotation-xml 5: <math><semantics><csymbol>Content MathML</csymbol><annotation-xml encoding="application/xhtml+xml"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>application/xhtml+xml</title></head><body><p>application/xhtml+xml</p></body></html></annotation-xml><annotation-xml encoding="application/mathml-presentation+xml"><math class="nospacing"><mtext>error</mtext></math></annotation-xml><annotation>error</annotation></math></p> 30 <p>annotation-xml 6: <math><semantics><csymbol>Content MathML</csymbol><annotation-xml encoding="text/html"><html><head><title>text/html</title></head><body><p>text/html</p></body></html></annotation-xml><annotation-xml encoding="application/mathml-presentation+xml"><math class="nospacing"><mtext>error</mtext></math></annotation-xml><annotation>error</annotation></semantics></math></p> 31 <p>annotation-xml 7: <math><semantics><csymbol>Content MathML</csymbol><annotation-xml encoding="unknown"><math class="nospacing"><mtext>error</mtext></math></annotation-xml><annotation-xml encoding="application/mathml+xml"><math class="nospacing"><mtext>error</mtext></math></annotation-xml><annotation-xml encoding="application/mathml-presentation+xml"><math class="nospacing"><mtext>annotation-xml</mtext></math></annotation-xml><annotation>error</annotation></semantics></math></p> 25 32 </body> 26 33 </html> -
trunk/LayoutTests/mathml/presentation/semantics-4.html
r161430 r166065 3 3 <head> 4 4 <title>Semantics</title> 5 <style type="text/css"> 6 .nospacing { 7 border: 0 !important; 8 padding: 0 !important; 9 margin: 0 !important; 10 } 11 </style> 5 12 </head> 6 13 … … 9 16 <!-- This test verifies that setting the encoding dynamically updates the selected annotation. This should render the same as the static reference. --> 10 17 11 <p><math><semantics><csymbol>Content MathML</csymbol><annotation-xml id="a"><m text>PASS</mtext></annotation-xml><annotation>FAIL</annotation></semantics></math></p>18 <p><math><semantics><csymbol>Content MathML</csymbol><annotation-xml id="a"><math class="nospacing"><mtext>PASS</mtext></math></annotation-xml><annotation>FAIL</annotation></semantics></math></p> 12 19 13 20 </body> -
trunk/Source/WebCore/ChangeLog
r166063 r166065 1 2014-03-21 Frédéric Wang <fred.wang@free.fr> 2 3 Bug 130345 - Refine childShouldCreateRenderer for MathML elements 4 https://bugs.webkit.org/show_bug.cgi?id=130345 5 6 Reviewed by Chris Fleizach. 7 8 This is a follow-up of bug 124128. We add more restrictions on foreign 9 content of MathML elements. 10 11 Tests: mathml/presentation/annotation-children.html 12 mathml/presentation/foreign-element-in-token.html 13 14 * mathml/MathMLElement.cpp: 15 (WebCore::MathMLElement::isPresentationMathML): fix line wrapping 16 (WebCore::MathMLElement::isPhrasingContent): 17 - move the function from MathMLSelectElement.cpp 18 - add the constraint "is descendant of a map element" for area. 19 (WebCore::MathMLElement::isFlowContent): new function to test flow content. 20 (WebCore::MathMLElement::childShouldCreateRenderer): 21 - remove annotation since it is now tested in MathMLTextElement 22 - refine testing of annotation-xml 23 - do not create renderer for text content in MathML. Such content is only allowed inside token elements. 24 * mathml/MathMLElement.h: Declare isPhrasingContent and isFlowContent. 25 * mathml/MathMLSelectElement.cpp: Add new function to test MathML/SVG/HTML encodings. 26 (WebCore::MathMLSelectElement::isMathMLEncoding): 27 (WebCore::MathMLSelectElement::isSVGEncoding): 28 (WebCore::MathMLSelectElement::isHTMLEncoding): 29 (WebCore::MathMLSelectElement::getSelectedSemanticsChild): use the new functions. 30 * mathml/MathMLSelectElement.h: Declare the new public functions. 31 * mathml/MathMLTextElement.cpp: remove the isPhrasingContent function. 32 (WebCore::MathMLTextElement::childShouldCreateRenderer): Just in case, use the generic StyledElement::childShouldCreateRenderer. 33 1 34 2014-03-21 Darin Adler <darin@apple.com> 2 35 -
trunk/Source/WebCore/mathml/MathMLElement.cpp
r164856 r166065 32 32 #include "MathMLElement.h" 33 33 34 #include "ElementIterator.h" 35 #include "HTMLElement.h" 36 #include "HTMLMapElement.h" 37 #include "HTMLNames.h" 34 38 #include "MathMLNames.h" 39 #include "MathMLSelectElement.h" 35 40 #include "RenderTableCell.h" 41 #include "SVGElement.h" 42 #include "SVGNames.h" 36 43 37 44 namespace WebCore { … … 51 58 bool MathMLElement::isPresentationMathML() const 52 59 { 53 return hasTagName(MathMLNames::mtrTag) || hasTagName(MathMLNames::mtdTag) || hasTagName(MathMLNames::maligngroupTag) || hasTagName(MathMLNames::malignmarkTag) || hasTagName(MathMLNames::mencloseTag) || hasTagName(MathMLNames::mglyphTag) || hasTagName(MathMLNames::mlabeledtrTag) || hasTagName(MathMLNames::mlongdivTag) || hasTagName(MathMLNames::mpaddedTag) || hasTagName(MathMLNames::msTag) || hasTagName(MathMLNames::mscarriesTag) || hasTagName(MathMLNames::mscarryTag) || hasTagName(MathMLNames::msgroupTag) || hasTagName(MathMLNames::mslineTag) || hasTagName(MathMLNames::msrowTag) || hasTagName(MathMLNames::mstackTag); 60 return hasTagName(MathMLNames::mtrTag) 61 || hasTagName(MathMLNames::mtdTag) 62 || hasTagName(MathMLNames::maligngroupTag) 63 || hasTagName(MathMLNames::malignmarkTag) 64 || hasTagName(MathMLNames::mencloseTag) 65 || hasTagName(MathMLNames::mglyphTag) 66 || hasTagName(MathMLNames::mlabeledtrTag) 67 || hasTagName(MathMLNames::mlongdivTag) 68 || hasTagName(MathMLNames::mpaddedTag) 69 || hasTagName(MathMLNames::msTag) 70 || hasTagName(MathMLNames::mscarriesTag) 71 || hasTagName(MathMLNames::mscarryTag) 72 || hasTagName(MathMLNames::msgroupTag) 73 || hasTagName(MathMLNames::mslineTag) 74 || hasTagName(MathMLNames::msrowTag) 75 || hasTagName(MathMLNames::mstackTag); 76 } 77 78 bool MathMLElement::isPhrasingContent(const Node& node) const 79 { 80 // Phrasing content is described in the HTML 5 specification: 81 // http://www.w3.org/TR/html5/dom.html#phrasing-content. 82 83 if (!node.isElementNode()) 84 return node.isTextNode(); 85 86 if (node.isMathMLElement()) { 87 auto& mathmlElement = toMathMLElement(node); 88 return mathmlElement.hasTagName(MathMLNames::mathTag); 89 } 90 91 if (node.isSVGElement()) { 92 auto& svgElement = toSVGElement(node); 93 return svgElement.hasTagName(SVGNames::svgTag); 94 } 95 96 if (node.isHTMLElement()) { 97 // FIXME: add the <data> and <time> tags when they are implemented. 98 auto& htmlElement = toHTMLElement(node); 99 return htmlElement.hasTagName(HTMLNames::aTag) 100 || htmlElement.hasTagName(HTMLNames::abbrTag) 101 || (htmlElement.hasTagName(HTMLNames::areaTag) && ancestorsOfType<HTMLMapElement>(htmlElement).first()) 102 || htmlElement.hasTagName(HTMLNames::audioTag) 103 || htmlElement.hasTagName(HTMLNames::bTag) 104 || htmlElement.hasTagName(HTMLNames::bdiTag) 105 || htmlElement.hasTagName(HTMLNames::bdoTag) 106 || htmlElement.hasTagName(HTMLNames::brTag) 107 || htmlElement.hasTagName(HTMLNames::buttonTag) 108 || htmlElement.hasTagName(HTMLNames::canvasTag) 109 || htmlElement.hasTagName(HTMLNames::citeTag) 110 || htmlElement.hasTagName(HTMLNames::codeTag) 111 || htmlElement.hasTagName(HTMLNames::datalistTag) 112 || htmlElement.hasTagName(HTMLNames::delTag) 113 || htmlElement.hasTagName(HTMLNames::dfnTag) 114 || htmlElement.hasTagName(HTMLNames::emTag) 115 || htmlElement.hasTagName(HTMLNames::embedTag) 116 || htmlElement.hasTagName(HTMLNames::iTag) 117 || htmlElement.hasTagName(HTMLNames::iframeTag) 118 || htmlElement.hasTagName(HTMLNames::imgTag) 119 || htmlElement.hasTagName(HTMLNames::inputTag) 120 || htmlElement.hasTagName(HTMLNames::insTag) 121 || htmlElement.hasTagName(HTMLNames::kbdTag) 122 || htmlElement.hasTagName(HTMLNames::keygenTag) 123 || htmlElement.hasTagName(HTMLNames::labelTag) 124 || htmlElement.hasTagName(HTMLNames::mapTag) 125 || htmlElement.hasTagName(HTMLNames::markTag) 126 || htmlElement.hasTagName(HTMLNames::meterTag) 127 || htmlElement.hasTagName(HTMLNames::noscriptTag) 128 || htmlElement.hasTagName(HTMLNames::objectTag) 129 || htmlElement.hasTagName(HTMLNames::outputTag) 130 || htmlElement.hasTagName(HTMLNames::progressTag) 131 || htmlElement.hasTagName(HTMLNames::qTag) 132 || htmlElement.hasTagName(HTMLNames::rubyTag) 133 || htmlElement.hasTagName(HTMLNames::sTag) 134 || htmlElement.hasTagName(HTMLNames::sampTag) 135 || htmlElement.hasTagName(HTMLNames::scriptTag) 136 || htmlElement.hasTagName(HTMLNames::selectTag) 137 || htmlElement.hasTagName(HTMLNames::smallTag) 138 || htmlElement.hasTagName(HTMLNames::spanTag) 139 || htmlElement.hasTagName(HTMLNames::strongTag) 140 || htmlElement.hasTagName(HTMLNames::subTag) 141 || htmlElement.hasTagName(HTMLNames::supTag) 142 || htmlElement.hasTagName(HTMLNames::templateTag) 143 || htmlElement.hasTagName(HTMLNames::textareaTag) 144 || htmlElement.hasTagName(HTMLNames::uTag) 145 || htmlElement.hasTagName(HTMLNames::varTag) 146 || htmlElement.hasTagName(HTMLNames::videoTag) 147 || htmlElement.hasTagName(HTMLNames::wbrTag); 148 } 149 150 return false; 151 } 152 153 bool MathMLElement::isFlowContent(const Node& node) const 154 { 155 // Flow content is described in the HTML 5 specification: 156 // http://www.w3.org/TR/html5/dom.html#flow-content 157 158 if (isPhrasingContent(node)) 159 return true; 160 161 if (!node.isHTMLElement()) 162 return false; 163 164 auto& htmlElement = toHTMLElement(node); 165 // FIXME add the <dialog> tag when it is implemented. 166 return htmlElement.hasTagName(HTMLNames::addressTag) 167 || htmlElement.hasTagName(HTMLNames::articleTag) 168 || htmlElement.hasTagName(HTMLNames::asideTag) 169 || htmlElement.hasTagName(HTMLNames::blockquoteTag) 170 || htmlElement.hasTagName(HTMLNames::detailsTag) 171 || htmlElement.hasTagName(HTMLNames::divTag) 172 || htmlElement.hasTagName(HTMLNames::dlTag) 173 || htmlElement.hasTagName(HTMLNames::fieldsetTag) 174 || htmlElement.hasTagName(HTMLNames::figureTag) 175 || htmlElement.hasTagName(HTMLNames::footerTag) 176 || htmlElement.hasTagName(HTMLNames::formTag) 177 || htmlElement.hasTagName(HTMLNames::h1Tag) 178 || htmlElement.hasTagName(HTMLNames::h2Tag) 179 || htmlElement.hasTagName(HTMLNames::h3Tag) 180 || htmlElement.hasTagName(HTMLNames::h4Tag) 181 || htmlElement.hasTagName(HTMLNames::h5Tag) 182 || htmlElement.hasTagName(HTMLNames::h6Tag) 183 || htmlElement.hasTagName(HTMLNames::headerTag) 184 || htmlElement.hasTagName(HTMLNames::hrTag) 185 || htmlElement.hasTagName(HTMLNames::mainTag) 186 || htmlElement.hasTagName(HTMLNames::navTag) 187 || htmlElement.hasTagName(HTMLNames::olTag) 188 || htmlElement.hasTagName(HTMLNames::pTag) 189 || htmlElement.hasTagName(HTMLNames::preTag) 190 || htmlElement.hasTagName(HTMLNames::sectionTag) 191 || (htmlElement.hasTagName(HTMLNames::styleTag) && htmlElement.hasAttribute("scoped")) 192 || htmlElement.hasTagName(HTMLNames::tableTag) 193 || htmlElement.hasTagName(HTMLNames::ulTag); 54 194 } 55 195 … … 124 264 bool MathMLElement::childShouldCreateRenderer(const Node& child) const 125 265 { 126 if (hasTagName(annotationTag)) 127 return child.isTextNode(); 128 if (hasTagName(annotation_xmlTag)) 129 return StyledElement::childShouldCreateRenderer(child); 130 131 // Only create renderers for MathML elements or text. MathML prohibits non-MathML markup inside a <math> element. 132 return child.isTextNode() || child.isMathMLElement(); 266 if (hasTagName(annotation_xmlTag)) { 267 const AtomicString& value = fastGetAttribute(MathMLNames::encodingAttr); 268 269 // See annotation-xml.model.mathml, annotation-xml.model.svg and annotation-xml.model.xhtml in the HTML5 RelaxNG schema. 270 271 if (child.isMathMLElement() && (MathMLSelectElement::isMathMLEncoding(value) || MathMLSelectElement::isHTMLEncoding(value))) { 272 auto& mathmlElement = toMathMLElement(child); 273 return mathmlElement.hasTagName(MathMLNames::mathTag); 274 } 275 276 if (child.isSVGElement() && (MathMLSelectElement::isSVGEncoding(value) || MathMLSelectElement::isHTMLEncoding(value))) { 277 auto& svgElement = toSVGElement(child); 278 return svgElement.hasTagName(SVGNames::svgTag); 279 } 280 281 if (child.isHTMLElement() && MathMLSelectElement::isHTMLEncoding(value)) { 282 auto& htmlElement = toHTMLElement(child); 283 return htmlElement.hasTagName(HTMLNames::htmlTag) || (isFlowContent(htmlElement) && StyledElement::childShouldCreateRenderer(child)); 284 } 285 286 return false; 287 } 288 289 // In general, only MathML children are allowed. Text nodes are only visible in token MathML elements. 290 return child.isMathMLElement(); 133 291 } 134 292 -
trunk/Source/WebCore/mathml/MathMLElement.h
r165699 r166065 67 67 virtual void collectStyleForPresentationAttribute(const QualifiedName&, const AtomicString&, MutableStyleProperties&) override; 68 68 69 bool isPhrasingContent(const Node&) const; 70 bool isFlowContent(const Node&) const; 71 69 72 private: 70 73 virtual void updateSelectedChild() { } -
trunk/Source/WebCore/mathml/MathMLSelectElement.cpp
r165699 r166065 30 30 31 31 #include "Event.h" 32 #include "HTMLElement.h" 33 #include "HTMLNames.h" 32 34 #include "MathMLNames.h" 33 35 #include "RenderMathMLRow.h" 36 #include "SVGElement.h" 37 #include "SVGNames.h" 34 38 35 39 namespace WebCore { … … 51 55 { 52 56 return createRenderer<RenderMathMLRow>(*this, std::move(style)); 57 } 58 59 // We recognize the following values for the encoding attribute of the <semantics> element: 60 // 61 // - "MathML-Presentation", which is mentioned in the MathML 3 recommendation. 62 // - "SVG1.1" which is mentioned in the W3C note. 63 // http://www.w3.org/Math/Documents/Notes/graphics.xml 64 // - Other MIME Content-Types for MathML, SVG and HTML. 65 // 66 // We exclude "application/mathml+xml" which is ambiguous about whether it is Presentation or Content MathML. Authors must use a more explicit encoding value. 67 bool MathMLSelectElement::isMathMLEncoding(const AtomicString& value) 68 { 69 return value == "application/mathml-presentation+xml" || value == "MathML-Presentation"; 70 } 71 72 bool MathMLSelectElement::isSVGEncoding(const AtomicString& value) 73 { 74 return value == "image/svg+xml" || value == "SVG1.1"; 75 } 76 77 bool MathMLSelectElement::isHTMLEncoding(const AtomicString& value) 78 { 79 return value == "application/xhtml+xml" || value == "text/html"; 53 80 } 54 81 … … 156 183 if (child->hasAttribute(MathMLNames::srcAttr)) 157 184 continue; 158 // If the <annotation-xml> element has an encoding attribute describing presentation MathML, SVG or HTML we assume the content can be displayed and we stop here. We recognize the following encoding values: 159 // 160 // - "MathML-Presentation", which is mentioned in the MathML 3 recommendation. 161 // - "SVG1.1" which is mentioned in the W3C note. 162 // http://www.w3.org/Math/Documents/Notes/graphics.xml 163 // - Other MIME Content-Types for SVG and HTML. 164 // 165 // We exclude "application/mathml+xml" which is ambiguous about whether it is Presentation or Content MathML. Authors must use a more explicit encoding value. 185 // If the <annotation-xml> element has an encoding attribute describing presentation MathML, SVG or HTML we assume the content can be displayed and we stop here. 166 186 const AtomicString& value = child->fastGetAttribute(MathMLNames::encodingAttr); 167 if ( value == "application/mathml-presentation+xml" || value == "MathML-Presentation" || value == "image/svg+xml" || value == "SVG1.1" || value == "application/xhtml+xml" || value == "text/html")187 if (isMathMLEncoding(value) || isSVGEncoding(value) || isHTMLEncoding(value)) 168 188 return child; 169 189 } -
trunk/Source/WebCore/mathml/MathMLSelectElement.h
r164856 r166065 35 35 public: 36 36 static PassRefPtr<MathMLSelectElement> create(const QualifiedName& tagName, Document&); 37 static bool isMathMLEncoding(const AtomicString& value); 38 static bool isSVGEncoding(const AtomicString& value); 39 static bool isHTMLEncoding(const AtomicString& value); 37 40 38 41 private: -
trunk/Source/WebCore/mathml/MathMLTextElement.cpp
r165739 r166065 31 31 #include "MathMLTextElement.h" 32 32 33 #include "HTMLElement.h"34 #include "HTMLNames.h"35 33 #include "MathMLNames.h" 36 34 #include "RenderMathMLOperator.h" 37 35 #include "RenderMathMLSpace.h" 38 36 #include "RenderMathMLToken.h" 39 #include "SVGElement.h"40 #include "SVGNames.h"41 37 42 38 namespace WebCore { … … 83 79 } 84 80 85 static bool isPhrasingContent(const Node& node)86 {87 // Phrasing content is described in the HTML 5 specification:88 // http://www.w3.org/TR/html5/dom.html#phrasing-content.89 90 if (!node.isElementNode())91 return node.isTextNode();92 93 auto& element = toElement(node);94 95 if (element.isMathMLElement()) {96 auto& mathmlElement = toMathMLElement(element);97 return mathmlElement.hasTagName(MathMLNames::mathTag);98 }99 100 if (element.isSVGElement()) {101 auto& svgElement = toSVGElement(element);102 return svgElement.hasTagName(SVGNames::svgTag);103 }104 105 if (element.isHTMLElement()) {106 // FIXME: add the <data> and <time> tags when they are implemented.107 auto& htmlElement = toHTMLElement(element);108 return htmlElement.hasTagName(HTMLNames::aTag)109 || htmlElement.hasTagName(HTMLNames::abbrTag)110 || htmlElement.hasTagName(HTMLNames::areaTag)111 || htmlElement.hasTagName(HTMLNames::audioTag)112 || htmlElement.hasTagName(HTMLNames::bTag)113 || htmlElement.hasTagName(HTMLNames::bdiTag)114 || htmlElement.hasTagName(HTMLNames::bdoTag)115 || htmlElement.hasTagName(HTMLNames::brTag)116 || htmlElement.hasTagName(HTMLNames::buttonTag)117 || htmlElement.hasTagName(HTMLNames::canvasTag)118 || htmlElement.hasTagName(HTMLNames::citeTag)119 || htmlElement.hasTagName(HTMLNames::codeTag)120 || htmlElement.hasTagName(HTMLNames::datalistTag)121 || htmlElement.hasTagName(HTMLNames::delTag)122 || htmlElement.hasTagName(HTMLNames::dfnTag)123 || htmlElement.hasTagName(HTMLNames::emTag)124 || htmlElement.hasTagName(HTMLNames::embedTag)125 || htmlElement.hasTagName(HTMLNames::iTag)126 || htmlElement.hasTagName(HTMLNames::iframeTag)127 || htmlElement.hasTagName(HTMLNames::imgTag)128 || htmlElement.hasTagName(HTMLNames::inputTag)129 || htmlElement.hasTagName(HTMLNames::insTag)130 || htmlElement.hasTagName(HTMLNames::kbdTag)131 || htmlElement.hasTagName(HTMLNames::keygenTag)132 || htmlElement.hasTagName(HTMLNames::labelTag)133 || htmlElement.hasTagName(HTMLNames::mapTag)134 || htmlElement.hasTagName(HTMLNames::markTag)135 || htmlElement.hasTagName(HTMLNames::meterTag)136 || htmlElement.hasTagName(HTMLNames::noscriptTag)137 || htmlElement.hasTagName(HTMLNames::objectTag)138 || htmlElement.hasTagName(HTMLNames::outputTag)139 || htmlElement.hasTagName(HTMLNames::progressTag)140 || htmlElement.hasTagName(HTMLNames::qTag)141 || htmlElement.hasTagName(HTMLNames::rubyTag)142 || htmlElement.hasTagName(HTMLNames::sTag)143 || htmlElement.hasTagName(HTMLNames::sampTag)144 || htmlElement.hasTagName(HTMLNames::scriptTag)145 || htmlElement.hasTagName(HTMLNames::selectTag)146 || htmlElement.hasTagName(HTMLNames::smallTag)147 || htmlElement.hasTagName(HTMLNames::spanTag)148 || htmlElement.hasTagName(HTMLNames::strongTag)149 || htmlElement.hasTagName(HTMLNames::subTag)150 || htmlElement.hasTagName(HTMLNames::supTag)151 || htmlElement.hasTagName(HTMLNames::templateTag)152 || htmlElement.hasTagName(HTMLNames::textareaTag)153 || htmlElement.hasTagName(HTMLNames::uTag)154 || htmlElement.hasTagName(HTMLNames::varTag)155 || htmlElement.hasTagName(HTMLNames::videoTag)156 || htmlElement.hasTagName(HTMLNames::wbrTag);157 }158 159 return false;160 }161 162 81 bool MathMLTextElement::childShouldCreateRenderer(const Node& child) const 163 82 { … … 170 89 171 90 // The HTML specification defines <mi>, <mo>, <mn>, <ms> and <mtext> as insertion points. 172 return isPhrasingContent(child) ;91 return isPhrasingContent(child) && StyledElement::childShouldCreateRenderer(child); 173 92 } 174 93
Note: See TracChangeset
for help on using the changeset viewer.