Bug 161300 - Move RenderMathMLRoot:RootType and RenderMathMLScripts:ScriptsType to...
authorfred.wang@free.fr <fred.wang@free.fr@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 4 Dec 2017 11:30:10 +0000 (11:30 +0000)
committerfred.wang@free.fr <fred.wang@free.fr@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 4 Dec 2017 11:30:10 +0000 (11:30 +0000)
commitf053719f96e0d981d857d72d82073c5823592d18
tree6b8681128b854f278bd6d4d8d883548c6d8f2fa2
parentaffb635427253bc516911b3b63e6f42f42d20772
Bug 161300 - Move RenderMathMLRoot:RootType and RenderMathMLScripts:ScriptsType to element classes
https://bugs.webkit.org/show_bug.cgi?id=161300

Patch by Frederic Wang <fwang@igalia.com> on 2017-12-04
Reviewed by Darin Adler.

RenderMathMLRoot::m_kind and RenderMathMLScripts::m_scriptType are initialized in the
constructors of the renderer classes from the tag name of the corresponding elements.
This patch moves them into the corresponding element classes and makes them const members
parsed in the constructors. It also introduces a MathMLRootElement class deriving from
MathMLRowElement to store the new member. Finally, the types are redefined as enum classes.

No new tests, behavior unchanged and already covered by existing tests.

* Sources.txt: Add MathMLRootElement files.
* WebCore.xcodeproj/project.pbxproj: Ditto.
* mathml/MathMLAllInOne.cpp: Ditto.
* mathml/MathMLRootElement.cpp:
(WebCore::element): Override this function to downcast to MathMLRootElement.
(WebCore::rootTypeOf): Helper function to parse the root type, moved from RenderMathMLRoot.
(WebCore::MathMLRootElement::MathMLRootElement): Initialize the root type.
(WebCore::MathMLRootElement::create):
(WebCore::MathMLRootElement::createElementRenderer): Moved from MathMLRowElement.
* mathml/MathMLRootElement.h: New class deriving from MathMLRowElement, with a RootType
member exposed to the renderer class.
* mathml/MathMLRowElement.cpp: Remove header for RenderMathMLRoot.h.
(WebCore::MathMLRowElement::createElementRenderer): Moved to MathMLRootElement.
* mathml/MathMLScriptsElement.cpp: Introduce a script type.
(WebCore::scriptTypeOf): Helper function to parse the script type, moved from
RenerMathMLScripts.
(WebCore::MathMLScriptsElement::MathMLScriptsElement): Initialize the script type.
* mathml/MathMLScriptsElement.h: Add new script type member.
(WebCore::MathMLScriptsElement::scriptType const): Expose the script type to the renderer
class.
* mathml/mathtags.in: Map <msqrt> and <mroot> to MathMLRootElement.
* rendering/mathml/RenderMathMLRoot.cpp:
(WebCore::RenderMathMLRoot::RenderMathMLRoot): Use MathMLRootElement and remove parsing of
the root type.
(WebCore::RenderMathMLRoot::rootType const): Helper function to access the root type from
the element class.
(WebCore::RenderMathMLRoot::isValid const): Use rootType() and add prefix for enum class
values.
(WebCore::RenderMathMLRoot::getBase const): Ditto.
(WebCore::RenderMathMLRoot::getIndex const): Ditto.
(WebCore::RenderMathMLRoot::horizontalParameters): Ditto.
(WebCore::RenderMathMLRoot::verticalParameters): Ditto.
(WebCore::RenderMathMLRoot::computePreferredLogicalWidths): Ditto.
(WebCore::RenderMathMLRoot::layoutBlock): Ditto.
(WebCore::RenderMathMLRoot::paint): Ditto.
* rendering/mathml/RenderMathMLRoot.h: Define root type as an enum class, replace
MathMLRowElement with MathMLRootElement, declare and use new rootType() function and remove
the m_kind member.
* rendering/mathml/RenderMathMLScripts.cpp:
(WebCore::RenderMathMLScripts::RenderMathMLScripts): Remove parsing of script type.
(WebCore::RenderMathMLScripts::scriptType const): Helper function to access the script type
from the element class.
(WebCore::RenderMathMLScripts::validateAndGetReferenceChildren): Use scriptType() and add
prefix for enum class values.
(WebCore::RenderMathMLScripts::computePreferredLogicalWidths): Ditto.
(WebCore::RenderMathMLScripts::verticalMetrics): Ditto.
(WebCore::RenderMathMLScripts::layoutBlock): Ditto.
* rendering/mathml/RenderMathMLScripts.h: Define root type as an enum class, declare the
scriptType() function and remove the m_scriptType member.
* rendering/mathml/RenderMathMLUnderOver.cpp:
(WebCore::RenderMathMLUnderOver::isValid const): Use scriptType() and add prefix for enum
class values.
(WebCore::RenderMathMLUnderOver::under const): Ditto.
(WebCore::RenderMathMLUnderOver::over const): Ditto.
(WebCore::RenderMathMLUnderOver::computePreferredLogicalWidths): Ditto.
(WebCore::RenderMathMLUnderOver::hasAccent const): Ditto.
(WebCore::RenderMathMLUnderOver::layoutBlock): Ditto.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@225475 268f45cc-cd09-0410-ab3c-d52691b4dbfc
15 files changed:
Source/WebCore/ChangeLog
Source/WebCore/Sources.txt
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/mathml/MathMLAllInOne.cpp
Source/WebCore/mathml/MathMLRootElement.cpp [new file with mode: 0644]
Source/WebCore/mathml/MathMLRootElement.h [new file with mode: 0644]
Source/WebCore/mathml/MathMLRowElement.cpp
Source/WebCore/mathml/MathMLScriptsElement.cpp
Source/WebCore/mathml/MathMLScriptsElement.h
Source/WebCore/mathml/mathtags.in
Source/WebCore/rendering/mathml/RenderMathMLRoot.cpp
Source/WebCore/rendering/mathml/RenderMathMLRoot.h
Source/WebCore/rendering/mathml/RenderMathMLScripts.cpp
Source/WebCore/rendering/mathml/RenderMathMLScripts.h
Source/WebCore/rendering/mathml/RenderMathMLUnderOver.cpp