Add an MathMLSelectElement class to implement <maction> and <semantics>.

<https://webkit.org/b/120058>

Patch by Frédéric Wang <fred.wang@free.fr> on 2013-12-03
Reviewed by Chris Fleizach.

Source/WebCore:

Tests: mathml/presentation/maction-dynamic.html
       mathml/presentation/maction.html
       mathml/presentation/semantics.html

This adds a new MathMLSelectElement class to prepare the implementation
of the <maction> and <semantics> elements, for which only one "selected"
child is visible. We now simply display the first child of the
<semantics> element instead of hiding the annotations and this allows to
handle the use case of SVG-in-MathML as generated by Instiki when
bug 124128 is fixed ; Gecko's selection algorithm will be implemented
later (bug 100626). We now also rely on the @actiontype and @selection
attributes to select the visible <maction> child ; It remains to deal
with the user interaction (bug 85734).

* CMakeLists.txt: add the new files.
* GNUmakefile.list.am: ditto
* Target.pri: ditto
* WebCore.vcxproj/WebCore.vcxproj: ditto
* WebCore.vcxproj/WebCore.vcxproj.filters: ditto
* WebCore.xcodeproj/project.pbxproj: ditto
* css/mathml.css: remove the CSS rule for annotation/annotation-xml.
* mathml/MathMLAllInOne.cpp: add the new cpp file.
* mathml/MathMLSelectElement.cpp: Added.
(WebCore::MathMLSelectElement::MathMLSelectElement):
(WebCore::MathMLSelectElement::create):
(WebCore::MathMLSelectElement::createRenderer):
(WebCore::MathMLSelectElement::childShouldCreateRenderer):
(WebCore::MathMLSelectElement::finishParsingChildren):
(WebCore::MathMLSelectElement::childrenChanged):
(WebCore::MathMLSelectElement::attributeChanged):
(WebCore::MathMLSelectElement::updateSelectedChild): basic implementation for maction, semantics, maction@actiontype and maction@selection.
* mathml/MathMLSelectElement.h: Added.
* mathml/mathattrs.in: add actiontype and selection attributes.
* mathml/mathtags.in: set element classes for maction, semantics, annotation and annotation-xml.

LayoutTests:

New tests for the selection of the visible child in the <maction> and <semantics> elements.

* mathml/presentation/maction-dynamic-expected.html: Added.
* mathml/presentation/maction-dynamic.html: Added.
* mathml/presentation/maction-expected.html: Added.
* mathml/presentation/maction.html: Added.
* mathml/presentation/semantics-expected.html: Added.
* mathml/presentation/semantics.html: Added.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@160005 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 7c765ec6
2013-12-03 Frédéric Wang <fred.wang@free.fr>
Add an MathMLSelectElement class to implement <maction> and <semantics>.
<https://webkit.org/b/120058>
Reviewed by Chris Fleizach.
New tests for the selection of the visible child in the <maction> and <semantics> elements.
* mathml/presentation/maction-dynamic-expected.html: Added.
* mathml/presentation/maction-dynamic.html: Added.
* mathml/presentation/maction-expected.html: Added.
* mathml/presentation/maction.html: Added.
* mathml/presentation/semantics-expected.html: Added.
* mathml/presentation/semantics.html: Added.
2013-12-02 Samuel White <samuel_white@apple.com>
AX: Add AXUIElementCountForSearchPredicate parameterized attribute.
......
......@@ -21,6 +21,9 @@ webkit.org/b/99618 mathml/presentation/roots.xhtml [ Failure ]
webkit.org/b/57700 mathml/presentation/row.xhtml [ Failure ]
webkit.org/b/57700 mathml/presentation/mo.xhtml [ Failure ]
# MathML regression with foreign objects
webkit.org/b/124128 mathml/presentation/semantics.html [ Skip ]
# These conformace tests are no longer in sync with the latest specification
# and expect compareDocumentPosition() to return:
# DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC | DOCUMENT_POSITION_DISCONNECTED
......
<!doctype html>
<html>
<head>
<title>maction</title>
</head>
<body>
<math>
<maction selection="3" actiontype="tooltip">
<mn>1</mn><mn>2</mn><mn>3</mn><mn>4</mn>
</maction>
</math>
<math>
<maction actiontype="tooltip" selection="3">
<mn>1</mn><mn>2</mn><mn>3</mn><mn>4</mn>
</maction>
</math>
<math>
<maction actiontype="statusline" selection="3">
<mn>1</mn><mn>2</mn><mn>3</mn><mn>4</mn>
</maction>
</math>
<math>
<maction selection="3">
<mn>1</mn><mn>2</mn><mn>3</mn><mn>4</mn>
</maction>
</math>
<math>
<maction actiontype="toggle" selection="2">
<mn>1</mn><mn>2</mn><mn>3</mn><mn>4</mn>
</maction>
</math>
<math>
<maction actiontype="toggle" selection="4">
<mn>1</mn><mn>2</mn><mn>3</mn><mn>4</mn>
</maction>
</math>
<math>
<maction actiontype="toggle">
<mn>1</mn><mn>2</mn><mn>3</mn><mn>4</mn>
</maction>
</math>
<math>
<maction actiontype="toggle" selection="3">
<mn>2</mn><mn>3</mn><mn>4</mn>
</maction>
</math>
<math>
<maction actiontype="toggle" selection="3">
<mn>1</mn><mn>1</mn><mn>2</mn><mn>3</mn><mn>4</mn>
</maction>
</math>
</body>
</html>
<!doctype html>
<html>
<head>
<title>maction</title>
<script type="text/javascript">
var mathmlNS = "http://www.w3.org/1998/Math/MathML";
function test()
{
var maction = document.getElementsByTagNameNS(mathmlNS, "maction");
// Setting the actiontype attribute
maction[0].setAttribute("actiontype", "tooltip");
maction[1].setAttribute("actiontype", "tooltip");
maction[2].setAttribute("actiontype", "statusline");
maction[3].removeAttribute("actiontype");
// Setting the selection attribute
maction[4].setAttribute("selection", "2");
maction[5].setAttribute("selection", "4");
maction[6].removeAttribute("selection");
// Setting the child list
maction[7].removeChild(maction[7].firstElementChild);
var e = maction[8].firstElementChild;
maction[8].insertBefore(e.cloneNode(true), e);
}
</script>
</head>
<body onload="test()">
<!-- This test verifies which child of the maction element is selected after a DOM change. The page should render the same as the static version. -->
<math>
<maction selection="3">
<mn>1</mn><mn>2</mn><mn>3</mn><mn>4</mn>
</maction>
</math>
<math>
<maction actiontype="toggle" selection="3">
<mn>1</mn><mn>2</mn><mn>3</mn><mn>4</mn>
</maction>
</math>
<math>
<maction actiontype="toggle" selection="3">
<mn>1</mn><mn>2</mn><mn>3</mn><mn>4</mn>
</maction>
</math>
<math>
<maction actiontype="statusline" selection="3">
<mn>1</mn><mn>2</mn><mn>3</mn><mn>4</mn>
</maction>
</math>
<math>
<maction actiontype="toggle">
<mn>1</mn><mn>2</mn><mn>3</mn><mn>4</mn>
</maction>
</math>
<math>
<maction actiontype="toggle" selection="3">
<mn>1</mn><mn>2</mn><mn>3</mn><mn>4</mn>
</maction>
</math>
<math>
<maction actiontype="toggle" selection="3">
<mn>1</mn><mn>2</mn><mn>3</mn><mn>4</mn>
</maction>
</math>
<math>
<maction actiontype="toggle" selection="3">
<mn>1</mn><mn>2</mn><mn>3</mn><mn>4</mn>
</maction>
</math>
<math>
<maction actiontype="toggle" selection="3">
<mn>1</mn><mn>2</mn><mn>3</mn><mn>4</mn>
</maction>
</math>
</body>
</html>
<!doctype html>
<html>
<head>
<title>maction</title>
</head>
<body>
<p>
<math>
<mrow>
<mn>1</mn>
</mrow>
</math>
<math>
<mrow>
<mn>1</mn>
</mrow>
</math>
</p>
<p>
<math>
<mrow>
<mn>1</mn>
</mrow>
</math>
<math>
<mrow>
<mn>1</mn>
</mrow>
</math>
</p>
<p>
<math>
<mrow>
<mn>1</mn>
</mrow>
</math>
<math>
<mrow>
<mn>3</mn>
</mrow>
</math>
</p>
<p>
<math>
<mrow>
<mn>1</mn>
</mrow>
</math>
<math>
<mrow>
<mn>3</mn>
</mrow>
</math>
</p>
<p>
<math>
<mrow>
<mn>2</mn>
</mrow>
</math>
</p>
<p>
<math>
<mrow>
<mn>3</mn>
</mrow>
</math>
<math>
<mrow>
<mn>4</mn>
</maction>
</math>
<math>
<mrow>
<mn>1</mn>
</mrow>
</math>
<math>
<mrow>
<mn>1</mn>
</mrow>
</math>
<math>
<mrow>
<mn>1</mn>
</mrow>
</math>
<math>
<mrow>
<mn>2</mn>
</mrow>
</math>
<math>
<mrow>
<mn>4</mn>
</mrow>
</math>
<math>
<mrow>
<mn>4</mn>
</mrow>
</math>
<math>
<mrow>
</mrow>
</math>
</p>
</body>
</html>
<!doctype html>
<html>
<head>
<title>maction</title>
</head>
<body>
<!-- This test verifies which child of the maction element is selected. -->
<!-- For the statusline action type, the first child should be visible and the selection attribute should be ignored. -->
<p>
<math>
<maction actiontype="statusline">
<mn>1</mn>
<mn>2</mn>
</maction>
</math>
<math>
<maction actiontype="statusline" selection="3">
<mn>1</mn>
<mn>2</mn>
<mn>3</mn>
<mn>4</mn>
</maction>
</math>
</p>
<!-- For the tooltip action type, the first child should be visible and the selection attribute should be ignored. -->
<p>
<math>
<maction actiontype="tooltip">
<mn>1</mn>
<mn>2</mn>
</maction>
</math>
<math>
<maction actiontype="tooltip" selection="3">
<mn>1</mn>
<mn>2</mn>
<mn>3</mn>
<mn>4</mn>
</maction>
</math>
</p>
<!-- For the toggle action type, we use the selection attribute to determine the selected child. -->
<p>
<math>
<maction actiontype="toggle">
<mn>1</mn>
<mn>2</mn>
</maction>
</math>
<math>
<maction actiontype="toggle" selection="3">
<mn>1</mn>
<mn>2</mn>
<mn>3</mn>
<mn>4</mn>
</maction>
</math>
</p>
<!-- For any unknown action type, we use the selection attribute to determine the selected child. -->
<p>
<math>
<maction actiontype="unknown">
<mn>1</mn>
<mn>2</mn>
<mn>3</mn>
<mn>4</mn>
</maction>
</math>
<math>
<maction actiontype="unknown" selection="3">
<mn>1</mn>
<mn>2</mn>
<mn>3</mn>
<mn>4</mn>
</maction>
</math>
</p>
<!-- actiontype is case-sensitive, TOOLTIP is treated as unknown -->
<p>
<math>
<maction actiontype="TOOLTIP" selection="2">
<mn>1</mn>
<mn>2</mn>
</maction>
</math>
</p>
<!-- Testing a couple of special values for the "selection" attribute -->
<p>
<!-- The selection attribute has data type xsd:positiveInteger
http://www.w3.org/TR/xmlschema-2/#positiveInteger -->
<math>
<maction actiontype="toggle" selection="+0003">
<mn>1</mn>
<mn>2</mn>
<mn>3</mn>
<mn>4</mn>
</maction>
</math>
<!-- The MathML spec discourages the use of leading and trailing
whitespace, but they are not strictly prohibited. -->
<math>
<maction actiontype="toggle" selection="&#x20;&#x9;&#xD;&#xA;4&#x20;&#x9;&#xD;&#xA;">
<mn>1</mn>
<mn>2</mn>
<mn>3</mn>
<mn>4</mn>
</maction>
</math>
<!-- The MathML spec suggests to rounded up or down to the closest value
within the allowed subset -->
<math>
<maction actiontype="toggle" selection="-5">
<mn>1</mn>
<mn>2</mn>
<mn>3</mn>
<mn>4</mn>
</maction>
</math>
<math>
<maction actiontype="toggle" selection="-1">
<mn>1</mn>
<mn>2</mn>
<mn>3</mn>
<mn>4</mn>
</maction>
</math>
<math>
<maction actiontype="toggle" selection="0">
<mn>1</mn>
<mn>2</mn>
<mn>3</mn>
<mn>4</mn>
</maction>
</math>
<math>
<maction actiontype="toggle" selection="2.25">
<mn>1</mn>
<mn>2</mn>
<mn>3</mn>
<mn>4</mn>
</maction>
</math>
<math>
<maction actiontype="toggle" selection="5">
<mn>1</mn>
<mn>2</mn>
<mn>3</mn>
<mn>4</mn>
</maction>
</math>
<math>
<maction actiontype="toggle" selection="8">
<mn>1</mn>
<mn>2</mn>
<mn>3</mn>
<mn>4</mn>
</maction>
</math>
<math>
<maction actiontype="toggle" selection="1">
</maction>
</math>
</p>
</body>
</html>
<!doctype html>
<html>
<head>
<title>semantics</title>
</head>
<body>
<math>
<mrow>
<mi>x</mi>
</mrow>
</math>
<math>
<mrow>
<mspace width="20px" height="20px" mathbackground="red"/>
</mrow>
</math>
</body>
</html>
<!doctype html>
<html>
<head>
<title>semantics</title>
</head>
<body>
<!-- This verifies that annotations are not visible. -->
<math>
<semantics>
<mi>x</mi>
<annotation encoding="TeX">x</annotation>
<annotation encoding="StarMath 5.0">x</annotation>
<annotation-xml encoding="MathML-Content"><ci>x</ci></annotation-xml>
</semantics>
</math>
<!-- This is not valid MathML but has become a standard hack to include SVG in MathML because of Gecko's initial implementation. -->
<math>
<semantics>
<annotation-xml encoding="SVG1.1">
<svg width="20px" height="20px">
<rect width="20px" height="20px" fill="red" stroke="none"/>
</svg>
</annotation-xml>
</semantics>
</math>
</body>
</html>
......@@ -1704,6 +1704,7 @@ set(WebCore_SOURCES
mathml/MathMLElement.cpp
mathml/MathMLInlineContainerElement.cpp
mathml/MathMLMathElement.cpp
mathml/MathMLSelectElement.cpp
mathml/MathMLTextElement.cpp
page/AutoscrollController.cpp
......
2013-12-03 Frédéric Wang <fred.wang@free.fr>
Add an MathMLSelectElement class to implement <maction> and <semantics>.
<https://webkit.org/b/120058>
Reviewed by Chris Fleizach.
Tests: mathml/presentation/maction-dynamic.html
mathml/presentation/maction.html
mathml/presentation/semantics.html
This adds a new MathMLSelectElement class to prepare the implementation
of the <maction> and <semantics> elements, for which only one "selected"
child is visible. We now simply display the first child of the
<semantics> element instead of hiding the annotations and this allows to
handle the use case of SVG-in-MathML as generated by Instiki when
bug 124128 is fixed ; Gecko's selection algorithm will be implemented
later (bug 100626). We now also rely on the @actiontype and @selection
attributes to select the visible <maction> child ; It remains to deal
with the user interaction (bug 85734).
* CMakeLists.txt: add the new files.
* GNUmakefile.list.am: ditto
* Target.pri: ditto
* WebCore.vcxproj/WebCore.vcxproj: ditto
* WebCore.vcxproj/WebCore.vcxproj.filters: ditto
* WebCore.xcodeproj/project.pbxproj: ditto
* css/mathml.css: remove the CSS rule for annotation/annotation-xml.
* mathml/MathMLAllInOne.cpp: add the new cpp file.
* mathml/MathMLSelectElement.cpp: Added.
(WebCore::MathMLSelectElement::MathMLSelectElement):
(WebCore::MathMLSelectElement::create):
(WebCore::MathMLSelectElement::createRenderer):
(WebCore::MathMLSelectElement::childShouldCreateRenderer):
(WebCore::MathMLSelectElement::finishParsingChildren):
(WebCore::MathMLSelectElement::childrenChanged):
(WebCore::MathMLSelectElement::attributeChanged):
(WebCore::MathMLSelectElement::updateSelectedChild): basic implementation for maction, semantics, maction@actiontype and maction@selection.
* mathml/MathMLSelectElement.h: Added.
* mathml/mathattrs.in: add actiontype and selection attributes.
* mathml/mathtags.in: set element classes for maction, semantics, annotation and annotation-xml.
2013-12-03 Thiago de Barros Lacerda <thiago.lacerda@openbossa.org>
Nix Upstream: Adding missing nix new files to WebCore
......@@ -4050,6 +4050,8 @@ webcore_sources += \
Source/WebCore/mathml/MathMLInlineContainerElement.h \
Source/WebCore/mathml/MathMLMathElement.cpp \
Source/WebCore/mathml/MathMLMathElement.h \
Source/WebCore/mathml/MathMLSelectElement.cpp \
Source/WebCore/mathml/MathMLSelectElement.h \
Source/WebCore/mathml/MathMLTextElement.cpp \
Source/WebCore/mathml/MathMLTextElement.h \
Source/WebCore/page/animation/AnimationBase.cpp \
......
......@@ -18040,6 +18040,14 @@
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\mathml\MathMLSelectElement.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release_WinCairo|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release_WinCairo|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\mathml\MathMLTextElement.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
......@@ -20976,6 +20984,7 @@
<ClInclude Include="..\mathml\MathMLElement.h" />
<ClInclude Include="..\mathml\MathMLInlineContainerElement.h" />
<ClInclude Include="..\mathml\MathMLMathElement.h" />
<ClInclude Include="..\mathml\MathMLSelectElement.h" />
<ClInclude Include="..\mathml\MathMLTextElement.h" />
<ClInclude Include="..\editing\AlternativeTextController.h" />
<ClInclude Include="..\config.h" />
......@@ -4977,6 +4977,9 @@
<ClCompile Include="..\mathml\MathMLMathElement.cpp">
<Filter>rendering\mathml</Filter>
</ClCompile>
<ClCompile Include="..\mathml\MathMLSelectElement.cpp">
<Filter>rendering\mathml</Filter>
</ClCompile>
<ClCompile Include="..\mathml\MathMLTextElement.cpp">
<Filter>rendering\mathml</Filter>
</ClCompile>
......@@ -12549,6 +12552,9 @@
<ClInclude Include="..\mathml\MathMLMathElement.h">
<Filter>rendering\mathml</Filter>
</ClInclude>
<ClInclude Include="..\mathml\MathMLSelectElement.h">
<Filter>rendering\mathml</Filter>
</ClInclude>
<ClInclude Include="..\mathml\MathMLTextElement.h">
<Filter>rendering\mathml</Filter>
</ClInclude>
......
......@@ -6310,6 +6310,7 @@
FEBC5F3116BD0CC300659BD3 /* DatabaseBase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FEBC5F2F16BD0CC300659BD3 /* DatabaseBase.cpp */; };
FEBC5F3216BD0CC300659BD3 /* DatabaseBase.h in Headers */ = {isa = PBXBuildFile; fileRef = FEBC5F3016BD0CC300659BD3 /* DatabaseBase.h */; settings = {ATTRIBUTES = (Private, ); }; };
FED13D3A0CEA934600D89466 /* EditorIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = FED13D390CEA934600D89466 /* EditorIOS.mm */; };
FED48390CED66C3255F72C59 /* MathMLSelectElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F75A059AF170D8FAA5B8CABE /* MathMLSelectElement.cpp */; };
FEDBFF16182B7A8D0017FA64 /* BreakpointID.h in Headers */ = {isa = PBXBuildFile; fileRef = FEDBFF14182B7A8D0017FA64 /* BreakpointID.h */; settings = {ATTRIBUTES = (Private, ); }; };
FEDEF84116797108000E444A /* DatabaseStrategy.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FEDEF83F16797108000E444A /* DatabaseStrategy.cpp */; };
FEDEF84216797108000E444A /* DatabaseStrategy.h in Headers */ = {isa = PBXBuildFile; fileRef = FEDEF84016797108000E444A /* DatabaseStrategy.h */; settings = {ATTRIBUTES = (Private, ); }; };
......@@ -8654,6 +8655,7 @@