Skip to content
Permalink
Browse files
Use auto* for MathML elements and renderers when possible
https://bugs.webkit.org/show_bug.cgi?id=159090

Patch by Frederic Wang <fwang@igalia.com> on 2016-06-24
Reviewed by Alex Christensen.

No new tests, behavior is unchanged.

* mathml/MathMLElement.cpp:
(WebCore::MathMLElement::attributeChanged):
* mathml/MathMLSelectElement.cpp:
(WebCore::MathMLSelectElement::getSelectedActionChildAndIndex):
(WebCore::MathMLSelectElement::getSelectedActionChild):
(WebCore::MathMLSelectElement::getSelectedSemanticsChild):
(WebCore::MathMLSelectElement::updateSelectedChild):
* rendering/mathml/RenderMathMLFraction.cpp:
(WebCore::RenderMathMLFraction::isValid):
* rendering/mathml/RenderMathMLMenclose.cpp:
(WebCore::RenderMathMLMenclose::layoutBlock):
* rendering/mathml/RenderMathMLRoot.cpp:
(WebCore::RenderMathMLRoot::isValid):
* rendering/mathml/RenderMathMLRow.cpp:
(WebCore::RenderMathMLRow::firstLineBaseline):
(WebCore::RenderMathMLRow::computeLineVerticalStretch):
(WebCore::RenderMathMLRow::computePreferredLogicalWidths):
(WebCore::RenderMathMLRow::layoutRowItems):
* rendering/mathml/RenderMathMLScripts.cpp:
(WebCore::RenderMathMLScripts::unembellishedOperator):
(WebCore::RenderMathMLScripts::getBaseAndScripts):
(WebCore::RenderMathMLScripts::computePreferredLogicalWidths):
(WebCore::RenderMathMLScripts::getScriptMetricsAndLayoutIfNeeded):
(WebCore::RenderMathMLScripts::layoutBlock):
(WebCore::RenderMathMLScripts::firstLineBaseline):
* rendering/mathml/RenderMathMLUnderOver.cpp:
(WebCore::RenderMathMLUnderOver::firstLineBaseline):
(WebCore::RenderMathMLUnderOver::isValid):
(WebCore::RenderMathMLUnderOver::over):

Canonical link: https://commits.webkit.org/177200@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@202441 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
fred-wang committed Jun 24, 2016
1 parent a658bb6 commit 0e935facfd4ad3fbb14d1d7351db71d6dcd2c8f1
Showing 9 changed files with 67 additions and 28 deletions.
@@ -1,3 +1,42 @@
2016-06-24 Frederic Wang <fwang@igalia.com>

Use auto* for MathML elements and renderers when possible
https://bugs.webkit.org/show_bug.cgi?id=159090

Reviewed by Alex Christensen.

No new tests, behavior is unchanged.

* mathml/MathMLElement.cpp:
(WebCore::MathMLElement::attributeChanged):
* mathml/MathMLSelectElement.cpp:
(WebCore::MathMLSelectElement::getSelectedActionChildAndIndex):
(WebCore::MathMLSelectElement::getSelectedActionChild):
(WebCore::MathMLSelectElement::getSelectedSemanticsChild):
(WebCore::MathMLSelectElement::updateSelectedChild):
* rendering/mathml/RenderMathMLFraction.cpp:
(WebCore::RenderMathMLFraction::isValid):
* rendering/mathml/RenderMathMLMenclose.cpp:
(WebCore::RenderMathMLMenclose::layoutBlock):
* rendering/mathml/RenderMathMLRoot.cpp:
(WebCore::RenderMathMLRoot::isValid):
* rendering/mathml/RenderMathMLRow.cpp:
(WebCore::RenderMathMLRow::firstLineBaseline):
(WebCore::RenderMathMLRow::computeLineVerticalStretch):
(WebCore::RenderMathMLRow::computePreferredLogicalWidths):
(WebCore::RenderMathMLRow::layoutRowItems):
* rendering/mathml/RenderMathMLScripts.cpp:
(WebCore::RenderMathMLScripts::unembellishedOperator):
(WebCore::RenderMathMLScripts::getBaseAndScripts):
(WebCore::RenderMathMLScripts::computePreferredLogicalWidths):
(WebCore::RenderMathMLScripts::getScriptMetricsAndLayoutIfNeeded):
(WebCore::RenderMathMLScripts::layoutBlock):
(WebCore::RenderMathMLScripts::firstLineBaseline):
* rendering/mathml/RenderMathMLUnderOver.cpp:
(WebCore::RenderMathMLUnderOver::firstLineBaseline):
(WebCore::RenderMathMLUnderOver::isValid):
(WebCore::RenderMathMLUnderOver::over):

2016-06-24 Joseph Pecoraro <pecoraro@apple.com>

Remove unused and static return value from InspectorStyle::populateAllProperties
@@ -298,7 +298,7 @@ bool MathMLElement::childShouldCreateRenderer(const Node& child) const
void MathMLElement::attributeChanged(const QualifiedName& name, const AtomicString& oldValue, const AtomicString& newValue, AttributeModificationReason reason)
{
if (isSemanticAnnotation() && (name == MathMLNames::srcAttr || name == MathMLNames::encodingAttr)) {
Element* parent = parentElement();
auto* parent = parentElement();
if (is<MathMLElement>(parent) && parent->hasTagName(semanticsTag))
downcast<MathMLElement>(*parent).updateSelectedChild();
}
@@ -118,7 +118,7 @@ int MathMLSelectElement::getSelectedActionChildAndIndex(Element*& selectedChild)
int selection = fastGetAttribute(MathMLNames::selectionAttr).toInt();
int i;
for (i = 1; i < selection; i++) {
Element* nextChild = selectedChild->nextElementSibling();
auto* nextChild = selectedChild->nextElementSibling();
if (!nextChild)
break;
selectedChild = nextChild;
@@ -131,7 +131,7 @@ Element* MathMLSelectElement::getSelectedActionChild()
{
ASSERT(hasTagName(mactionTag));

Element* child = firstElementChild();
auto* child = firstElementChild();
if (!child)
return child;

@@ -155,7 +155,7 @@ Element* MathMLSelectElement::getSelectedSemanticsChild()
{
ASSERT(hasTagName(semanticsTag));

Element* child = firstElementChild();
auto* child = firstElementChild();
if (!child)
return nullptr;

@@ -197,7 +197,7 @@ Element* MathMLSelectElement::getSelectedSemanticsChild()

void MathMLSelectElement::updateSelectedChild()
{
Element* newSelectedChild = hasTagName(mactionTag) ? getSelectedActionChild() : getSelectedSemanticsChild();
auto* newSelectedChild = hasTagName(mactionTag) ? getSelectedActionChild() : getSelectedSemanticsChild();

if (m_selectedChild == newSelectedChild)
return;
@@ -71,7 +71,7 @@ bool RenderMathMLFraction::isValid() const
{
// Verify whether the list of children is valid:
// <mfrac> numerator denominator </mfrac>
RenderBox* child = firstChildBox();
auto* child = firstChildBox();
if (!child)
return false;
child = child->nextSiblingBox();
@@ -178,7 +178,7 @@ void RenderMathMLMenclose::layoutBlock(bool relayoutChildren, LayoutUnit)
m_ascent = topSpace + contentAscent;
LayoutUnit descent = contentDescent + bottomSpace;
LayoutPoint contentLocation(leftSpace, m_ascent - contentAscent);
for (RenderBox* child = firstChildBox(); child; child = child->nextSiblingBox())
for (auto* child = firstChildBox(); child; child = child->nextSiblingBox())
child->setLocation(child->location() + contentLocation);

setLogicalHeight(m_ascent + descent);
@@ -64,7 +64,7 @@ bool RenderMathMLRoot::isValid() const
return true;

ASSERT(m_kind == RootWithIndex);
RenderBox* child = firstChildBox();
auto* child = firstChildBox();
if (!child)
return false;
child = child->nextSiblingBox();
@@ -63,7 +63,7 @@ void RenderMathMLRow::updateOperatorProperties()

Optional<int> RenderMathMLRow::firstLineBaseline() const
{
RenderBox* baselineChild = firstChildBox();
auto* baselineChild = firstChildBox();
if (!baselineChild)
return Optional<int>();

@@ -72,7 +72,7 @@ Optional<int> RenderMathMLRow::firstLineBaseline() const

void RenderMathMLRow::computeLineVerticalStretch(LayoutUnit& ascent, LayoutUnit& descent)
{
for (RenderBox* child = firstChildBox(); child; child = child->nextSiblingBox()) {
for (auto* child = firstChildBox(); child; child = child->nextSiblingBox()) {
if (is<RenderMathMLBlock>(child)) {
auto* renderOperator = downcast<RenderMathMLBlock>(child)->unembellishedOperator();
if (renderOperator && renderOperator->hasOperatorFlag(MathMLOperatorDictionary::Stretchy))
@@ -102,7 +102,7 @@ void RenderMathMLRow::computePreferredLogicalWidths()
m_minPreferredLogicalWidth = m_maxPreferredLogicalWidth = 0;

LayoutUnit preferredWidth = 0;
for (RenderBox* child = firstChildBox(); child; child = child->nextSiblingBox())
for (auto* child = firstChildBox(); child; child = child->nextSiblingBox())
preferredWidth += child->maxPreferredLogicalWidth() + child->marginLogicalWidth();

m_minPreferredLogicalWidth = m_maxPreferredLogicalWidth = preferredWidth + borderAndPaddingLogicalWidth();
@@ -115,7 +115,7 @@ void RenderMathMLRow::layoutRowItems(LayoutUnit& ascent, LayoutUnit& descent)
// We first stretch the vertical operators.
// For inline formulas, we can then calculate the logical width.
LayoutUnit width = borderAndPaddingStart();
for (RenderBox* child = firstChildBox(); child; child = child->nextSiblingBox()) {
for (auto* child = firstChildBox(); child; child = child->nextSiblingBox()) {
if (child->isOutOfFlowPositioned())
continue;

@@ -138,7 +138,7 @@ void RenderMathMLRow::layoutRowItems(LayoutUnit& ascent, LayoutUnit& descent)
LayoutUnit maxAscent = 0, maxDescent = 0; // Used baseline alignment.
LayoutUnit horizontalOffset = borderAndPaddingStart();
bool shouldFlipHorizontal = !style().isLeftToRightDirection();
for (RenderBox* child = firstChildBox(); child; child = child->nextSiblingBox()) {
for (auto* child = firstChildBox(); child; child = child->nextSiblingBox()) {
if (child->isOutOfFlowPositioned()) {
child->containingBlock()->insertPositionedObject(*child);
continue;
@@ -168,7 +168,7 @@ void RenderMathMLRow::layoutRowItems(LayoutUnit& ascent, LayoutUnit& descent)
if (shouldFlipHorizontal && centerBlockOffset > 0)
centerBlockOffset = -centerBlockOffset;

for (RenderBox* child = firstChildBox(); child; child = child->nextSiblingBox()) {
for (auto* child = firstChildBox(); child; child = child->nextSiblingBox()) {
LayoutUnit ascent = ascentForChild(*child);
LayoutUnit startOffset = maxAscent - ascent;
child->setLocation(child->location() + LayoutPoint(centerBlockOffset, startOffset));
@@ -61,7 +61,7 @@ RenderMathMLScripts::RenderMathMLScripts(Element& element, RenderStyle&& style)

RenderMathMLOperator* RenderMathMLScripts::unembellishedOperator()
{
RenderBox* base = firstChildBox();
auto base = firstChildBox();
if (!is<RenderMathMLBlock>(base))
return nullptr;
return downcast<RenderMathMLBlock>(base)->unembellishedOperator();
@@ -93,7 +93,7 @@ bool RenderMathMLScripts::getBaseAndScripts(RenderBox*& base, RenderBox*& firstP
firstPostScript = base->nextSiblingBox();
if (!firstPostScript || isPrescriptDelimiter(*firstPostScript))
return false;
RenderBox* superScript = firstPostScript->nextSiblingBox();
auto superScript = firstPostScript->nextSiblingBox();
return superScript && !isPrescriptDelimiter(*superScript) && !superScript->nextSiblingBox();
}
case Multiscripts: {
@@ -118,7 +118,7 @@ bool RenderMathMLScripts::getBaseAndScripts(RenderBox*& base, RenderBox*& firstP
// b) That the list of prescripts can be grouped into pairs of subscript/superscript.
// c) That there is at most one <mprescripts/>.
bool numberOfScriptIsEven = true;
for (RenderBox* script = base->nextSiblingBox(); script; script = script->nextSiblingBox()) {
for (auto script = base->nextSiblingBox(); script; script = script->nextSiblingBox()) {
if (isPrescriptDelimiter(*script)) {
// This is a <mprescripts/>. Let's check 2a) and 2c).
if (!numberOfScriptIsEven || firstPreScript)
@@ -179,14 +179,14 @@ void RenderMathMLScripts::computePreferredLogicalWidths()
case SubSup:
case Multiscripts: {
RenderBox* supScript;
for (RenderBox* subScript = firstPreScript; subScript; subScript = supScript->nextSiblingBox()) {
for (auto* subScript = firstPreScript; subScript; subScript = supScript->nextSiblingBox()) {
supScript = subScript->nextSiblingBox();
ASSERT(supScript);
LayoutUnit subSupPairWidth = std::max(subScript->maxPreferredLogicalWidth(), supScript->maxPreferredLogicalWidth());
m_maxPreferredLogicalWidth += subSupPairWidth + space;
}
m_maxPreferredLogicalWidth += base->maxPreferredLogicalWidth();
for (RenderBox* subScript = firstPostScript; subScript && !isPrescriptDelimiter(*subScript); subScript = supScript->nextSiblingBox()) {
for (auto* subScript = firstPostScript; subScript && !isPrescriptDelimiter(*subScript); subScript = supScript->nextSiblingBox()) {
supScript = subScript->nextSiblingBox();
ASSERT(supScript);
LayoutUnit subSupPairWidth = std::max(std::max(LayoutUnit(0), subScript->maxPreferredLogicalWidth() - baseItalicCorrection), supScript->maxPreferredLogicalWidth());
@@ -266,7 +266,7 @@ void RenderMathMLScripts::getScriptMetricsAndLayoutIfNeeded(RenderBox* base, Ren
case SubSup:
case Multiscripts: {
RenderBox* supScript;
for (RenderBox* subScript = script; subScript && !isPrescriptDelimiter(*subScript); subScript = supScript->nextSiblingBox()) {
for (auto* subScript = script; subScript && !isPrescriptDelimiter(*subScript); subScript = supScript->nextSiblingBox()) {
supScript = subScript->nextSiblingBox();
ASSERT(supScript);
subScript->layoutIfNeeded();
@@ -368,22 +368,22 @@ void RenderMathMLScripts::layoutBlock(bool relayoutChildren, LayoutUnit)

// Calculate the logical width.
LayoutUnit logicalWidth = 0;
for (RenderBox* subScript = firstPreScript; subScript; subScript = supScript->nextSiblingBox()) {
for (auto* subScript = firstPreScript; subScript; subScript = supScript->nextSiblingBox()) {
supScript = subScript->nextSiblingBox();
ASSERT(supScript);
LayoutUnit subSupPairWidth = std::max(subScript->logicalWidth(), supScript->logicalWidth());
logicalWidth += subSupPairWidth + space;
}
logicalWidth += base->logicalWidth();
for (RenderBox* subScript = firstPostScript; subScript && !isPrescriptDelimiter(*subScript); subScript = supScript->nextSiblingBox()) {
for (auto* subScript = firstPostScript; subScript && !isPrescriptDelimiter(*subScript); subScript = supScript->nextSiblingBox()) {
supScript = subScript->nextSiblingBox();
ASSERT(supScript);
LayoutUnit subSupPairWidth = std::max(std::max(LayoutUnit(0), subScript->logicalWidth() - baseItalicCorrection), supScript->logicalWidth());
logicalWidth += subSupPairWidth + space;
}
setLogicalWidth(logicalWidth);

for (RenderBox* subScript = firstPreScript; subScript; subScript = supScript->nextSiblingBox()) {
for (auto* subScript = firstPreScript; subScript; subScript = supScript->nextSiblingBox()) {
supScript = subScript->nextSiblingBox();
ASSERT(supScript);
LayoutUnit subSupPairWidth = std::max(subScript->logicalWidth(), supScript->logicalWidth());
@@ -398,7 +398,7 @@ void RenderMathMLScripts::layoutBlock(bool relayoutChildren, LayoutUnit)
LayoutPoint baseLocation(mirrorIfNeeded(horizontalOffset, *base), ascent - baseAscent);
base->setLocation(baseLocation);
horizontalOffset += base->logicalWidth();
for (RenderBox* subScript = firstPostScript; subScript && !isPrescriptDelimiter(*subScript); subScript = supScript->nextSiblingBox()) {
for (auto* subScript = firstPostScript; subScript && !isPrescriptDelimiter(*subScript); subScript = supScript->nextSiblingBox()) {
supScript = subScript->nextSiblingBox();
ASSERT(supScript);
LayoutUnit subAscent = ascentForChild(*subScript);
@@ -420,7 +420,7 @@ void RenderMathMLScripts::layoutBlock(bool relayoutChildren, LayoutUnit)
Optional<int> RenderMathMLScripts::firstLineBaseline() const
{
ASSERT(!needsLayout());
RenderBox* base = firstChildBox();
auto* base = firstChildBox();
if (!base)
return Optional<int>();
return Optional<int>(static_cast<int>(lroundf(ascentForChild(*base) + base->logicalTop())));
@@ -63,7 +63,7 @@ RenderMathMLOperator* RenderMathMLUnderOver::unembellishedOperator()

Optional<int> RenderMathMLUnderOver::firstLineBaseline() const
{
RenderBox* base = firstChildBox();
auto* base = firstChildBox();
if (!base)
return Optional<int>();

@@ -105,7 +105,7 @@ bool RenderMathMLUnderOver::isValid() const
// <munder> base under </munder>
// <mover> base over </mover>
// <munderover> base under over </munderover>
RenderBox* child = firstChildBox();
auto* child = firstChildBox();
if (!child)
return false;
child = child->nextSiblingBox();
@@ -141,7 +141,7 @@ RenderBox& RenderMathMLUnderOver::over() const
{
ASSERT(isValid());
ASSERT(m_scriptType == Over || m_scriptType == UnderOver);
RenderBox* secondChild = firstChildBox()->nextSiblingBox();
auto* secondChild = firstChildBox()->nextSiblingBox();
return m_scriptType == Over ? *secondChild : *secondChild->nextSiblingBox();
}

0 comments on commit 0e935fa

Please sign in to comment.