haikuwebkit/LayoutTests/mathml/scripts-addChild.html

167 lines
10 KiB
HTML
Raw Permalink Normal View History

Implement the mmultiscripts tag https://bugs.webkit.org/show_bug.cgi?id=99618 Patch by Frédéric Wang <fred.wang@free.fr> on 2013-09-15 Reviewed by Chris Fleizach. Source/WebCore: Tests: mathml/invalid-scripts-crash.html mathml/presentation/multiscripts-equivalence.html mathml/presentation/multiscripts-noscripts.html mathml/presentation/multiscripts-positions.html mathml/presentation/scripts-base-alignment.html mathml/presentation/scripts-horizontal-alignment.html mathml/presentation/scripts-vertical-alignment.html mathml/scripts-addChild.html mathml/scripts-removeChild.html This relies on the existing msub/msup/msubsup code to implement the mmultiscripts tag. This also improves dynamic addition/removal of children for these MathML elements and adds a specific style for invalid children, so that they render like an merror tag. Finally, this fixes a bad memory access in the Accessibility render object of msubsup. * CMakeLists.txt: * GNUmakefile.list.am: * Target.pri: * WebCore.vcxproj/WebCore.vcxproj: * WebCore.vcxproj/WebCore.vcxproj.filters: * WebCore.xcodeproj/project.pbxproj: * accessibility/AccessibilityRenderObject.cpp: (WebCore::AccessibilityRenderObject::isMathSubscriptSuperscript): (WebCore::AccessibilityRenderObject::mathSuperscriptObject): * css/mathml.css: (mo, mrow, mfenced, mfrac, msub, msup, msubsup, mmultiscripts, mprescripts, none, munder, mover, munderover, msqrt, mroot): (mover > :last-child, munderover > :last-child): (msub > * + *, msup > * + *, msubsup > * + *, mmultiscripts > * + *, munder > * + *, mover > * + *, munderover > * + *): (merror, msub > * + * + *, msup > * + * + *, msubsup > * + * + * + *, msub > mprescripts, msup > mprescripts, msubsup > mprescripts, msub > none, msup > none, msubsup > none, mmultiscripts > mprescripts ~ mprescripts, mmultiscripts > mprescripts ~ mprescripts ~ *): * mathml/MathMLInlineContainerElement.cpp: (WebCore::MathMLInlineContainerElement::createRenderer): * mathml/mathtags.in: * rendering/mathml/RenderMathMLBlock.h: (WebCore::RenderMathMLBlock::isRenderMathMLScripts): (WebCore::RenderMathMLBlock::isRenderMathMLScriptsWrapper): * rendering/mathml/RenderMathMLScripts.cpp: Added. (WebCore::isMPrescripts): (WebCore::RenderMathMLScripts::RenderMathMLScripts): (WebCore::RenderMathMLScripts::base): (WebCore::RenderMathMLScripts::fixAnonymousStyleForSubSupPair): (WebCore::RenderMathMLScripts::fixAnonymousStyles): (WebCore::RenderMathMLScripts::addChildInternal): (WebCore::RenderMathMLScripts::removeChildInternal): (WebCore::RenderMathMLScripts::addChild): (WebCore::RenderMathMLScripts::removeChild): (WebCore::RenderMathMLScripts::styleDidChange): (WebCore::RenderMathMLScripts::unembellishedOperator): (WebCore::RenderMathMLScripts::layout): (WebCore::RenderMathMLScripts::firstLineBoxBaseline): (WebCore::RenderMathMLScriptsWrapper::createAnonymousWrapper): (WebCore::RenderMathMLScriptsWrapper::addChildInternal): (WebCore::RenderMathMLScriptsWrapper::addChild): (WebCore::RenderMathMLScriptsWrapper::removeChildInternal): (WebCore::RenderMathMLScriptsWrapper::removeChild): * rendering/mathml/RenderMathMLScripts.h: Added. (WebCore::RenderMathMLScriptsWrapper::RenderMathMLScriptsWrapper): (WebCore::RenderMathMLScriptsWrapper::renderName): (WebCore::RenderMathMLScriptsWrapper::isRenderMathMLScriptsWrapper): (WebCore::toRenderMathMLScriptsWrapper): (WebCore::RenderMathMLScripts::isRenderMathMLScripts): (WebCore::RenderMathMLScripts::renderName): (WebCore::toRenderMathMLScripts): * rendering/mathml/RenderMathMLSubSup.cpp: Removed. * rendering/mathml/RenderMathMLSubSup.h: Removed. LayoutTests: Add many tests for script msub/msup/msubsup/mmultiscripts: - invalid markup - equivalence between mmultiscripts without scripts and mrow - equivalence between mmultiscripts and msub/msup/msubsup - position of scripts in mmultiscripts - baseline alignment of msub/msup/msubsup elements - horizontal/vertical alignment of scripts - adding/removing children with the DOM * TestExpectations: Some remaining MathML pixel tests are broken by this patch. * mathml/invalid-scripts-crash-expected.txt: Added. * mathml/invalid-scripts-crash.html: Added. * mathml/presentation/multiscripts-equivalence-expected.html: Added. * mathml/presentation/multiscripts-equivalence.html: Added. * mathml/presentation/multiscripts-noscripts-expected.html: Added. * mathml/presentation/multiscripts-noscripts.html: Added. * mathml/presentation/multiscripts-positions-expected.html: Added. * mathml/presentation/multiscripts-positions.html: Added. * mathml/presentation/scripts-base-alignment-expected.html: Added. * mathml/presentation/scripts-base-alignment.html: Added. * mathml/presentation/scripts-horizontal-alignment-expected.html: Added. * mathml/presentation/scripts-horizontal-alignment.html: Added. * mathml/presentation/scripts-vertical-alignment-expected.html: Added. * mathml/presentation/scripts-vertical-alignment.html: Added. * mathml/scripts-addChild-expected.html: Added. * mathml/scripts-addChild.html: Added. * mathml/scripts-removeChild-expected.html: Added. * mathml/scripts-removeChild.html: Added. * platform/mac/accessibility/mathml-multiscript-expected.txt: Reference updated. Canonical link: https://commits.webkit.org/139354@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@155797 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2013-09-15 08:08:08 +00:00
<!doctype html>
<html>
<head>
<title>MathML script elements: adding children</title>
<!-- This test verifies insertion of children into an <mmultiscripts> element using DOM operations. It should not crash and should render the same as the equivalent static page. -->
<style type="text/css">
div { border: 1px solid; margin: .5em; }
</style>
<script type="text/javascript">
var mathmlNS = "http://www.w3.org/1998/Math/MathML";
function newMn(n)
{
var t = document.createTextNode(n.toString());
var mn = document.createElementNS(mathmlNS, "mn");
mn.appendChild(t);
return mn;
}
function newPrescripts()
{
var mprescripts = document.createElementNS(mathmlNS, "mprescripts");
return mprescripts;
}
function test1()
{
var test1content = document.getElementById("test1content");
var mmultiscripts = document.getElementById("test1").getElementsByTagNameNS(mathmlNS, "mmultiscripts");
// Insert in normal order
for (var child = test1content.firstChild; child; child = child.nextSibling) {
mmultiscripts[0].appendChild(child.cloneNode(true));
}
// Insert in reverse order
for (var child = test1content.lastChild; child; child = child.previousSibling) {
mmultiscripts[1].insertBefore(child.cloneNode(true), mmultiscripts[1].firstChild);
}
}
function test2()
{
var mmultiscripts = document.getElementById("test2").getElementsByTagNameNS(mathmlNS, "mmultiscripts");
for (var i = 0; i < mmultiscripts.length; i++) {
var childRef = mmultiscripts[i].firstChild;
for (var j = 0; j < i; j++) childRef = childRef.nextSibling;
mmultiscripts[i].insertBefore(newPrescripts(), childRef);
}
}
function test3()
{
var mmultiscripts = document.getElementById("test3").getElementsByTagNameNS(mathmlNS, "mmultiscripts");
for (var i = 0; i < mmultiscripts.length; i++) {
var childRef = mmultiscripts[i].firstChild;
for (var j = 0; j < i; j++) childRef = childRef.nextSibling;
mmultiscripts[i].insertBefore(newMn(10+i), childRef);
}
}
function test4()
{
var mmultiscripts = document.getElementById("test4").getElementsByTagNameNS(mathmlNS, "mmultiscripts");
for (var i = 0; i < mmultiscripts.length; i++) {
var childRef = mmultiscripts[i].firstChild;
for (var j = 0; j < i; j++) childRef = childRef.nextSibling;
mmultiscripts[i].insertBefore(newPrescripts(), childRef);
}
}
function test5()
{
var mmultiscripts = document.getElementById("test5").getElementsByTagNameNS(mathmlNS, "mmultiscripts");
for (var i = 0; i < mmultiscripts.length; i++) {
var childRef = mmultiscripts[i].firstChild;
for (var j = 0; j < i; j++) childRef = childRef.nextSibling;
mmultiscripts[i].insertBefore(newMn(10+i), childRef);
}
}
function run()
{
test1();
test2();
test3();
test4();
test5();
}
</script>
</head>
<body onload="run()">
<!-- Test 1: insert in normal and reverse order. -->
<div style="display: none">
<math id="test1content"><mn>0</mn><mn>1</mn><mn>2</mn><mn>3</mn><mn>4</mn><mprescripts/><mn>5</mn><mn>6</mn><mn>7</mn><mn>8</mn></math>
</div>
<div id="test1">Test 1:
<math><mmultiscripts></mmultiscripts></math>
<math><mmultiscripts></mmultiscripts></math>
</div>
<!-- Test 2: insert an <mprescripts/> element. -->
<div id="test2">Test 2:
<math><mmultiscripts><mn>0</mn><mn>1</mn><mn>2</mn><mprescripts/><mn>3</mn><mn>4</mn><mprescripts/><mn>5</mn><mn>6</mn></mmultiscripts></math>
<math><mmultiscripts><mn>0</mn><mn>1</mn><mn>2</mn><mprescripts/><mn>3</mn><mn>4</mn><mprescripts/><mn>5</mn><mn>6</mn></mmultiscripts></math>
<math><mmultiscripts><mn>0</mn><mn>1</mn><mn>2</mn><mprescripts/><mn>3</mn><mn>4</mn><mprescripts/><mn>5</mn><mn>6</mn></mmultiscripts></math>
<math><mmultiscripts><mn>0</mn><mn>1</mn><mn>2</mn><mprescripts/><mn>3</mn><mn>4</mn><mprescripts/><mn>5</mn><mn>6</mn></mmultiscripts></math>
<math><mmultiscripts><mn>0</mn><mn>1</mn><mn>2</mn><mprescripts/><mn>3</mn><mn>4</mn><mprescripts/><mn>5</mn><mn>6</mn></mmultiscripts></math>
<math><mmultiscripts><mn>0</mn><mn>1</mn><mn>2</mn><mprescripts/><mn>3</mn><mn>4</mn><mprescripts/><mn>5</mn><mn>6</mn></mmultiscripts></math>
<math><mmultiscripts><mn>0</mn><mn>1</mn><mn>2</mn><mprescripts/><mn>3</mn><mn>4</mn><mprescripts/><mn>5</mn><mn>6</mn></mmultiscripts></math>
<math><mmultiscripts><mn>0</mn><mn>1</mn><mn>2</mn><mprescripts/><mn>3</mn><mn>4</mn><mprescripts/><mn>5</mn><mn>6</mn></mmultiscripts></math>
<math><mmultiscripts><mn>0</mn><mn>1</mn><mn>2</mn><mprescripts/><mn>3</mn><mn>4</mn><mprescripts/><mn>5</mn><mn>6</mn></mmultiscripts></math>
<math><mmultiscripts><mn>0</mn><mn>1</mn><mn>2</mn><mprescripts/><mn>3</mn><mn>4</mn><mprescripts/><mn>5</mn><mn>6</mn></mmultiscripts></math>
</div>
<!-- Test 3: insert an <mn> element. -->
<div id="test3">Test 3:
<math><mmultiscripts><mn>0</mn><mn>1</mn><mn>2</mn><mprescripts/><mn>3</mn><mn>4</mn><mprescripts/><mn>5</mn><mn>6</mn></mmultiscripts></math>
<math><mmultiscripts><mn>0</mn><mn>1</mn><mn>2</mn><mprescripts/><mn>3</mn><mn>4</mn><mprescripts/><mn>5</mn><mn>6</mn></mmultiscripts></math>
<math><mmultiscripts><mn>0</mn><mn>1</mn><mn>2</mn><mprescripts/><mn>3</mn><mn>4</mn><mprescripts/><mn>5</mn><mn>6</mn></mmultiscripts></math>
<math><mmultiscripts><mn>0</mn><mn>1</mn><mn>2</mn><mprescripts/><mn>3</mn><mn>4</mn><mprescripts/><mn>5</mn><mn>6</mn></mmultiscripts></math>
<math><mmultiscripts><mn>0</mn><mn>1</mn><mn>2</mn><mprescripts/><mn>3</mn><mn>4</mn><mprescripts/><mn>5</mn><mn>6</mn></mmultiscripts></math>
<math><mmultiscripts><mn>0</mn><mn>1</mn><mn>2</mn><mprescripts/><mn>3</mn><mn>4</mn><mprescripts/><mn>5</mn><mn>6</mn></mmultiscripts></math>
<math><mmultiscripts><mn>0</mn><mn>1</mn><mn>2</mn><mprescripts/><mn>3</mn><mn>4</mn><mprescripts/><mn>5</mn><mn>6</mn></mmultiscripts></math>
<math><mmultiscripts><mn>0</mn><mn>1</mn><mn>2</mn><mprescripts/><mn>3</mn><mn>4</mn><mprescripts/><mn>5</mn><mn>6</mn></mmultiscripts></math>
<math><mmultiscripts><mn>0</mn><mn>1</mn><mn>2</mn><mprescripts/><mn>3</mn><mn>4</mn><mprescripts/><mn>5</mn><mn>6</mn></mmultiscripts></math>
<math><mmultiscripts><mn>0</mn><mn>1</mn><mn>2</mn><mprescripts/><mn>3</mn><mn>4</mn><mprescripts/><mn>5</mn><mn>6</mn></mmultiscripts></math>
</div>
<!-- Test 4: insert an <mprescripts> element (different number of consecutive scripts) . -->
<div id="test4">Test 4:
<math><mmultiscripts><mn>0</mn><mprescripts/><mn>1</mn><mprescripts/><mn>2</mn><mn>3</mn><mprescripts/><mn>4</mn><mn>5</mn><mn>6</mn></mmultiscripts></math>
<math><mmultiscripts><mn>0</mn><mprescripts/><mn>1</mn><mprescripts/><mn>2</mn><mn>3</mn><mprescripts/><mn>4</mn><mn>5</mn><mn>6</mn></mmultiscripts></math>
<math><mmultiscripts><mn>0</mn><mprescripts/><mn>1</mn><mprescripts/><mn>2</mn><mn>3</mn><mprescripts/><mn>4</mn><mn>5</mn><mn>6</mn></mmultiscripts></math>
<math><mmultiscripts><mn>0</mn><mprescripts/><mn>1</mn><mprescripts/><mn>2</mn><mn>3</mn><mprescripts/><mn>4</mn><mn>5</mn><mn>6</mn></mmultiscripts></math>
<math><mmultiscripts><mn>0</mn><mprescripts/><mn>1</mn><mprescripts/><mn>2</mn><mn>3</mn><mprescripts/><mn>4</mn><mn>5</mn><mn>6</mn></mmultiscripts></math>
<math><mmultiscripts><mn>0</mn><mprescripts/><mn>1</mn><mprescripts/><mn>2</mn><mn>3</mn><mprescripts/><mn>4</mn><mn>5</mn><mn>6</mn></mmultiscripts></math>
<math><mmultiscripts><mn>0</mn><mprescripts/><mn>1</mn><mprescripts/><mn>2</mn><mn>3</mn><mprescripts/><mn>4</mn><mn>5</mn><mn>6</mn></mmultiscripts></math>
<math><mmultiscripts><mn>0</mn><mprescripts/><mn>1</mn><mprescripts/><mn>2</mn><mn>3</mn><mprescripts/><mn>4</mn><mn>5</mn><mn>6</mn></mmultiscripts></math>
<math><mmultiscripts><mn>0</mn><mprescripts/><mn>1</mn><mprescripts/><mn>2</mn><mn>3</mn><mprescripts/><mn>4</mn><mn>5</mn><mn>6</mn></mmultiscripts></math>
<math><mmultiscripts><mn>0</mn><mprescripts/><mn>1</mn><mprescripts/><mn>2</mn><mn>3</mn><mprescripts/><mn>4</mn><mn>5</mn><mn>6</mn></mmultiscripts></math>
<math><mmultiscripts><mn>0</mn><mprescripts/><mn>1</mn><mprescripts/><mn>2</mn><mn>3</mn><mprescripts/><mn>4</mn><mn>5</mn><mn>6</mn></mmultiscripts></math>
</div>
<!-- Test 5: insert an <mn> element (different number of consecutive scripts) . -->
<div id="test5">Test 5:
<math><mmultiscripts><mn>0</mn><mprescripts/><mn>1</mn><mprescripts/><mn>2</mn><mn>3</mn><mprescripts/><mn>4</mn><mn>5</mn><mn>6</mn></mmultiscripts></math>
<math><mmultiscripts><mn>0</mn><mprescripts/><mn>1</mn><mprescripts/><mn>2</mn><mn>3</mn><mprescripts/><mn>4</mn><mn>5</mn><mn>6</mn></mmultiscripts></math>
<math><mmultiscripts><mn>0</mn><mprescripts/><mn>1</mn><mprescripts/><mn>2</mn><mn>3</mn><mprescripts/><mn>4</mn><mn>5</mn><mn>6</mn></mmultiscripts></math>
<math><mmultiscripts><mn>0</mn><mprescripts/><mn>1</mn><mprescripts/><mn>2</mn><mn>3</mn><mprescripts/><mn>4</mn><mn>5</mn><mn>6</mn></mmultiscripts></math>
<math><mmultiscripts><mn>0</mn><mprescripts/><mn>1</mn><mprescripts/><mn>2</mn><mn>3</mn><mprescripts/><mn>4</mn><mn>5</mn><mn>6</mn></mmultiscripts></math>
<math><mmultiscripts><mn>0</mn><mprescripts/><mn>1</mn><mprescripts/><mn>2</mn><mn>3</mn><mprescripts/><mn>4</mn><mn>5</mn><mn>6</mn></mmultiscripts></math>
<math><mmultiscripts><mn>0</mn><mprescripts/><mn>1</mn><mprescripts/><mn>2</mn><mn>3</mn><mprescripts/><mn>4</mn><mn>5</mn><mn>6</mn></mmultiscripts></math>
<math><mmultiscripts><mn>0</mn><mprescripts/><mn>1</mn><mprescripts/><mn>2</mn><mn>3</mn><mprescripts/><mn>4</mn><mn>5</mn><mn>6</mn></mmultiscripts></math>
<math><mmultiscripts><mn>0</mn><mprescripts/><mn>1</mn><mprescripts/><mn>2</mn><mn>3</mn><mprescripts/><mn>4</mn><mn>5</mn><mn>6</mn></mmultiscripts></math>
<math><mmultiscripts><mn>0</mn><mprescripts/><mn>1</mn><mprescripts/><mn>2</mn><mn>3</mn><mprescripts/><mn>4</mn><mn>5</mn><mn>6</mn></mmultiscripts></math>
<math><mmultiscripts><mn>0</mn><mprescripts/><mn>1</mn><mprescripts/><mn>2</mn><mn>3</mn><mprescripts/><mn>4</mn><mn>5</mn><mn>6</mn></mmultiscripts></math>
</div>
</body>
</html>