Diff
Modified: trunk/Source/WebCore/ChangeLog (159008 => 159009)
--- trunk/Source/WebCore/ChangeLog 2013-11-10 04:20:21 UTC (rev 159008)
+++ trunk/Source/WebCore/ChangeLog 2013-11-10 05:08:43 UTC (rev 159009)
@@ -1,3 +1,21 @@
+2013-11-09 Andreas Kling <[email protected]>
+
+ Move MathML type checking virtuals to RenderObject.
+ <https://webkit.org/b/124111>
+
+ Previously, checking the type of a MathML renderer would require
+ that you first check if it's a RenderMathMLBlock, and then casting
+ to that type to access the check you really wanted.
+
+ This change moves all the isRenderMathMLFoo() virtual functions
+ to RenderObject. I also made sure all the overloads were private
+ and marked them OVERRIDE/FINAL as appropriate.
+
+ Finally I replaced all the hand-written casting functions with
+ autogenerated ones using RENDER_OBJECT_TYPE_CASTS.
+
+ Reviewed by Anders Carlsson.
+
2013-11-09 Martin Robinson <[email protected]>
[MathML] Poor spacing around delimiters in MathML Torture Test 14
Modified: trunk/Source/WebCore/accessibility/AccessibilityRenderObject.cpp (159008 => 159009)
--- trunk/Source/WebCore/accessibility/AccessibilityRenderObject.cpp 2013-11-10 04:20:21 UTC (rev 159008)
+++ trunk/Source/WebCore/accessibility/AccessibilityRenderObject.cpp 2013-11-10 05:08:43 UTC (rev 159009)
@@ -3409,96 +3409,64 @@
bool AccessibilityRenderObject::isMathFraction() const
{
- if (!m_renderer || !m_renderer->isRenderMathMLBlock())
- return false;
-
- return toRenderMathMLBlock(m_renderer)->isRenderMathMLFraction();
+ return m_renderer && m_renderer->isRenderMathMLFraction();
}
bool AccessibilityRenderObject::isMathFenced() const
{
- if (!m_renderer || !m_renderer->isRenderMathMLBlock())
- return false;
-
- return toRenderMathMLBlock(m_renderer)->isRenderMathMLFenced();
+ return m_renderer && m_renderer->isRenderMathMLFenced();
}
bool AccessibilityRenderObject::isMathSubscriptSuperscript() const
{
- if (!m_renderer || !m_renderer->isRenderMathMLBlock())
- return false;
-
- return toRenderMathMLBlock(m_renderer)->isRenderMathMLScripts() && !isMathMultiscript();
+ return m_renderer && m_renderer->isRenderMathMLScripts() && !isMathMultiscript();
}
bool AccessibilityRenderObject::isMathRow() const
{
- if (!m_renderer || !m_renderer->isRenderMathMLBlock())
- return false;
-
- return toRenderMathMLBlock(m_renderer)->isRenderMathMLRow();
+ return m_renderer && m_renderer->isRenderMathMLRow();
}
bool AccessibilityRenderObject::isMathUnderOver() const
{
- if (!m_renderer || !m_renderer->isRenderMathMLBlock())
- return false;
-
- return toRenderMathMLBlock(m_renderer)->isRenderMathMLUnderOver();
+ return m_renderer && m_renderer->isRenderMathMLUnderOver();
}
bool AccessibilityRenderObject::isMathSquareRoot() const
{
- if (!m_renderer || !m_renderer->isRenderMathMLBlock())
- return false;
-
- return toRenderMathMLBlock(m_renderer)->isRenderMathMLSquareRoot();
+ return m_renderer && m_renderer->isRenderMathMLSquareRoot();
}
bool AccessibilityRenderObject::isMathRoot() const
{
- if (!m_renderer || !m_renderer->isRenderMathMLBlock())
- return false;
-
- return toRenderMathMLBlock(m_renderer)->isRenderMathMLRoot();
+ return m_renderer && m_renderer->isRenderMathMLRoot();
}
bool AccessibilityRenderObject::isMathOperator() const
{
- if (!m_renderer || !m_renderer->isRenderMathMLBlock())
+ if (!m_renderer || !m_renderer->isRenderMathMLOperator())
return false;
-
+
// Ensure that this is actually a render MathML operator because
// MathML will create MathMLBlocks and use the original node as the node
// of this new block that is not tied to the DOM.
- if (!toRenderMathMLBlock(m_renderer)->isRenderMathMLOperator())
- return false;
-
return isMathElement() && node()->hasTagName(MathMLNames::moTag);
}
bool AccessibilityRenderObject::isMathFenceOperator() const
{
- if (!m_renderer || !m_renderer->isRenderMathMLBlock())
+ if (!m_renderer || !m_renderer->isRenderMathMLOperator())
return false;
-
- if (!toRenderMathMLBlock(m_renderer)->isRenderMathMLOperator())
- return false;
-
- RenderMathMLOperator* mathOperator = toRenderMathMLOperator(toRenderMathMLBlock(m_renderer));
- return mathOperator->operatorType() == RenderMathMLOperator::Fence;
+
+ return toRenderMathMLOperator(*m_renderer).operatorType() == RenderMathMLOperator::Fence;
}
bool AccessibilityRenderObject::isMathSeparatorOperator() const
{
- if (!m_renderer || !m_renderer->isRenderMathMLBlock())
+ if (!m_renderer || !m_renderer->isRenderMathMLOperator())
return false;
-
- if (!toRenderMathMLBlock(m_renderer)->isRenderMathMLOperator())
- return false;
-
- RenderMathMLOperator* mathOperator = toRenderMathMLOperator(toRenderMathMLBlock(m_renderer));
- return mathOperator->operatorType() == RenderMathMLOperator::Separator;
+
+ return toRenderMathMLOperator(*m_renderer).operatorType() == RenderMathMLOperator::Separator;
}
bool AccessibilityRenderObject::isMathText() const
Modified: trunk/Source/WebCore/rendering/RenderObject.h (159008 => 159009)
--- trunk/Source/WebCore/rendering/RenderObject.h 2013-11-10 04:20:21 UTC (rev 159008)
+++ trunk/Source/WebCore/rendering/RenderObject.h 2013-11-10 05:08:43 UTC (rev 159009)
@@ -407,6 +407,17 @@
#if ENABLE(MATHML)
virtual bool isRenderMathMLBlock() const { return false; }
+ virtual bool isRenderMathMLOperator() const { return false; }
+ virtual bool isRenderMathMLRow() const { return false; }
+ virtual bool isRenderMathMLMath() const { return false; }
+ virtual bool isRenderMathMLFenced() const { return false; }
+ virtual bool isRenderMathMLFraction() const { return false; }
+ virtual bool isRenderMathMLRoot() const { return false; }
+ virtual bool isRenderMathMLSpace() const { return false; }
+ virtual bool isRenderMathMLSquareRoot() const { return false; }
+ virtual bool isRenderMathMLScripts() const { return false; }
+ virtual bool isRenderMathMLScriptsWrapper() const { return false; }
+ virtual bool isRenderMathMLUnderOver() const { return false; }
#endif // ENABLE(MATHML)
#if ENABLE(SVG)
Modified: trunk/Source/WebCore/rendering/mathml/RenderMathMLBlock.h (159008 => 159009)
--- trunk/Source/WebCore/rendering/mathml/RenderMathMLBlock.h 2013-11-10 04:20:21 UTC (rev 159008)
+++ trunk/Source/WebCore/rendering/mathml/RenderMathMLBlock.h 2013-11-10 05:08:43 UTC (rev 159009)
@@ -46,19 +46,6 @@
virtual bool isChildAllowed(const RenderObject&, const RenderStyle&) const OVERRIDE;
- virtual bool isRenderMathMLBlock() const OVERRIDE { return true; }
- virtual bool isRenderMathMLOperator() const { return false; }
- virtual bool isRenderMathMLRow() const { return false; }
- virtual bool isRenderMathMLMath() const { return false; }
- virtual bool isRenderMathMLFenced() const { return false; }
- virtual bool isRenderMathMLFraction() const { return false; }
- virtual bool isRenderMathMLRoot() const { return false; }
- virtual bool isRenderMathMLSpace() const { return false; }
- virtual bool isRenderMathMLSquareRoot() const { return false; }
- virtual bool isRenderMathMLScripts() const { return false; }
- virtual bool isRenderMathMLScriptsWrapper() const { return false; }
- virtual bool isRenderMathMLUnderOver() const { return false; }
-
// MathML defines an "embellished operator" as roughly an <mo> that may have subscripts,
// superscripts, underscripts, overscripts, or a denominator (as in d/dx, where "d" is some
// differential operator). The padding, precedence, and stretchiness of the base <mo> should
@@ -81,7 +68,9 @@
bool ignoreInAccessibilityTree() const { return m_ignoreInAccessibilityTree; }
private:
+ virtual bool isRenderMathMLBlock() const OVERRIDE FINAL { return true; }
virtual const char* renderName() const OVERRIDE;
+
bool m_ignoreInAccessibilityTree;
};
Modified: trunk/Source/WebCore/rendering/mathml/RenderMathMLFraction.h (159008 => 159009)
--- trunk/Source/WebCore/rendering/mathml/RenderMathMLFraction.h 2013-11-10 04:20:21 UTC (rev 159008)
+++ trunk/Source/WebCore/rendering/mathml/RenderMathMLFraction.h 2013-11-10 05:08:43 UTC (rev 159009)
@@ -57,18 +57,8 @@
LayoutUnit m_lineThickness;
};
-
-inline RenderMathMLFraction* toRenderMathMLFraction(RenderObject* object)
-{
- ASSERT_WITH_SECURITY_IMPLICATION(!object || (object->isRenderMathMLBlock() && toRenderMathMLBlock(object)->isRenderMathMLFraction()));
- return static_cast<RenderMathMLFraction*>(object);
-}
-inline const RenderMathMLFraction* toRenderMathMLFraction(const RenderObject* object)
-{
- ASSERT_WITH_SECURITY_IMPLICATION(!object || (object->isRenderMathMLBlock() && toRenderMathMLBlock(object)->isRenderMathMLFraction()));
- return static_cast<const RenderMathMLFraction*>(object);
-}
+RENDER_OBJECT_TYPE_CASTS(RenderMathMLFraction, isRenderMathMLFraction());
}
Modified: trunk/Source/WebCore/rendering/mathml/RenderMathMLMath.h (159008 => 159009)
--- trunk/Source/WebCore/rendering/mathml/RenderMathMLMath.h 2013-11-10 04:20:21 UTC (rev 159008)
+++ trunk/Source/WebCore/rendering/mathml/RenderMathMLMath.h 2013-11-10 05:08:43 UTC (rev 159009)
@@ -32,13 +32,13 @@
namespace WebCore {
-class RenderMathMLMath : public RenderMathMLRow {
+class RenderMathMLMath FINAL : public RenderMathMLRow {
public:
RenderMathMLMath(Element&, PassRef<RenderStyle>);
- virtual bool isRenderMathMLMath() const { return true; }
private:
- virtual const char* renderName() const { return "RenderMathMLMath"; }
+ virtual bool isRenderMathMLMath() const OVERRIDE { return true; }
+ virtual const char* renderName() const OVERRIDE { return "RenderMathMLMath"; }
};
}
Modified: trunk/Source/WebCore/rendering/mathml/RenderMathMLOperator.h (159008 => 159009)
--- trunk/Source/WebCore/rendering/mathml/RenderMathMLOperator.h 2013-11-10 04:20:21 UTC (rev 159008)
+++ trunk/Source/WebCore/rendering/mathml/RenderMathMLOperator.h 2013-11-10 05:08:43 UTC (rev 159009)
@@ -97,23 +97,10 @@
StretchyCharacter* m_stretchyCharacter;
};
-inline RenderMathMLOperator* toRenderMathMLOperator(RenderMathMLBlock* block)
-{
- ASSERT_WITH_SECURITY_IMPLICATION(!block || block->isRenderMathMLOperator());
- return static_cast<RenderMathMLOperator*>(block);
-}
+RENDER_OBJECT_TYPE_CASTS(RenderMathMLOperator, isRenderMathMLOperator());
-inline const RenderMathMLOperator* toRenderMathMLOperator(const RenderMathMLBlock* block)
-{
- ASSERT_WITH_SECURITY_IMPLICATION(!block || block->isRenderMathMLOperator());
- return static_cast<const RenderMathMLOperator*>(block);
-}
+template<> inline bool isRendererOfType<const RenderMathMLOperator>(const RenderObject& renderer) { return renderer.isRenderMathMLOperator(); }
-// This will catch anyone doing an unnecessary cast.
-void toRenderMathMLOperator(const RenderMathMLOperator*);
-
-template<> inline bool isRendererOfType<const RenderMathMLOperator>(const RenderObject& renderer) { return renderer.isRenderMathMLBlock() && toRenderMathMLBlock(&renderer)->isRenderMathMLOperator(); }
-
inline UChar convertHyphenMinusToMinusSign(UChar glyph)
{
// When rendered as a mathematical operator, minus glyph should be larger.
Modified: trunk/Source/WebCore/rendering/mathml/RenderMathMLRoot.h (159008 => 159009)
--- trunk/Source/WebCore/rendering/mathml/RenderMathMLRoot.h 2013-11-10 04:20:21 UTC (rev 159008)
+++ trunk/Source/WebCore/rendering/mathml/RenderMathMLRoot.h 2013-11-10 05:08:43 UTC (rev 159009)
@@ -54,8 +54,8 @@
virtual void paint(PaintInfo&, const LayoutPoint&) OVERRIDE;
private:
- virtual bool isRenderMathMLRoot() const { return true; }
- virtual const char* renderName() const { return "RenderMathMLRoot"; }
+ virtual bool isRenderMathMLRoot() const OVERRIDE FINAL { return true; }
+ virtual const char* renderName() const OVERRIDE { return "RenderMathMLRoot"; }
// This may return 0 for a non-MathML index (which won't occur in valid MathML).
RenderBox* index() const;
Modified: trunk/Source/WebCore/rendering/mathml/RenderMathMLRow.h (159008 => 159009)
--- trunk/Source/WebCore/rendering/mathml/RenderMathMLRow.h 2013-11-10 04:20:21 UTC (rev 159008)
+++ trunk/Source/WebCore/rendering/mathml/RenderMathMLRow.h 2013-11-10 05:08:43 UTC (rev 159009)
@@ -38,14 +38,13 @@
RenderMathMLRow(Document&, PassRef<RenderStyle>);
static RenderMathMLRow* createAnonymousWithParentRenderer(const RenderObject*);
-
- virtual bool isRenderMathMLRow() const { return true; }
-
+
protected:
virtual void layout();
private:
- virtual const char* renderName() const { return isAnonymous() ? "RenderMathMLRow (anonymous)" : "RenderMathMLRow"; }
+ virtual bool isRenderMathMLRow() const OVERRIDE FINAL { return true; }
+ virtual const char* renderName() const OVERRIDE { return isAnonymous() ? "RenderMathMLRow (anonymous)" : "RenderMathMLRow"; }
};
}
Modified: trunk/Source/WebCore/rendering/mathml/RenderMathMLScripts.h (159008 => 159009)
--- trunk/Source/WebCore/rendering/mathml/RenderMathMLScripts.h 2013-11-10 04:20:21 UTC (rev 159008)
+++ trunk/Source/WebCore/rendering/mathml/RenderMathMLScripts.h 2013-11-10 05:08:43 UTC (rev 159009)
@@ -57,8 +57,7 @@
void addChildInternal(bool normalInsertion, RenderObject* child, RenderObject* beforeChild = 0);
void removeChildInternal(bool normalRemoval, RenderObject& child);
- virtual const char* renderName() const { return m_kind == Base ? "Base Wrapper" : "SubSupPair Wrapper"; }
-
+ virtual const char* renderName() const OVERRIDE { return m_kind == Base ? "Base Wrapper" : "SubSupPair Wrapper"; }
virtual bool isRenderMathMLScriptsWrapper() const OVERRIDE FINAL { return true; }
RenderMathMLScripts* parentMathMLScripts();
@@ -66,31 +65,8 @@
WrapperType m_kind;
};
-inline RenderMathMLScriptsWrapper* toRenderMathMLScriptsWrapper(RenderMathMLBlock* block)
-{
- ASSERT_WITH_SECURITY_IMPLICATION(!block || block->isRenderMathMLScriptsWrapper());
- return static_cast<RenderMathMLScriptsWrapper*>(block);
-}
+RENDER_OBJECT_TYPE_CASTS(RenderMathMLScriptsWrapper, isRenderMathMLScriptsWrapper());
-inline const RenderMathMLScriptsWrapper* toRenderMathMLScriptsWrapper(const RenderMathMLBlock* block)
-{
- ASSERT_WITH_SECURITY_IMPLICATION(!block || block->isRenderMathMLScriptsWrapper());
- return static_cast<const RenderMathMLScriptsWrapper*>(block);
-}
-
-inline RenderMathMLScriptsWrapper* toRenderMathMLScriptsWrapper(RenderObject* object)
-{
- return toRenderMathMLScriptsWrapper(toRenderMathMLBlock(object));
-}
-
-inline const RenderMathMLScriptsWrapper* toRenderMathMLScriptsWrapper(const RenderObject* object)
-{
- return toRenderMathMLScriptsWrapper(toRenderMathMLBlock(object));
-}
-
-// This will catch anyone doing an unnecessary cast.
-void toRenderMathMLScriptsWrapper(const RenderMathMLScriptsWrapper*);
-
// Render a base with scripts.
class RenderMathMLScripts : public RenderMathMLBlock {
@@ -111,14 +87,14 @@
void addChildInternal(bool normalInsertion, RenderObject* child, RenderObject* beforeChild = 0);
void removeChildInternal(bool normalRemoval, RenderObject& child);
- virtual bool isRenderMathMLScripts() const OVERRIDE { return true; }
+ virtual bool isRenderMathMLScripts() const OVERRIDE FINAL { return true; }
+ virtual const char* renderName() const OVERRIDE { return "RenderMathMLScripts"; }
+
void fixAnonymousStyleForSubSupPair(RenderObject* subSupPair, bool isPostScript);
void fixAnonymousStyles();
virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle) OVERRIDE;
- virtual const char* renderName() const { return "RenderMathMLScripts"; }
-
// Omit our subscript and/or superscript. This may return 0 for a non-MathML base (which
// won't occur in valid MathML).
RenderBoxModelObject* base() const;
@@ -129,33 +105,10 @@
RenderMathMLScriptsWrapper* m_baseWrapper;
};
-inline RenderMathMLScripts* toRenderMathMLScripts(RenderMathMLBlock* block)
-{
- ASSERT_WITH_SECURITY_IMPLICATION(!block || block->isRenderMathMLScripts());
- return static_cast<RenderMathMLScripts*>(block);
-}
+RENDER_OBJECT_TYPE_CASTS(RenderMathMLScripts, isRenderMathMLScripts());
-inline const RenderMathMLScripts* toRenderMathMLScripts(const RenderMathMLBlock* block)
-{
- ASSERT_WITH_SECURITY_IMPLICATION(!block || block->isRenderMathMLScripts());
- return static_cast<const RenderMathMLScripts*>(block);
}
-inline RenderMathMLScripts* toRenderMathMLScripts(RenderObject* object)
-{
- return toRenderMathMLScripts(toRenderMathMLBlock(object));
-}
-
-inline const RenderMathMLScripts* toRenderMathMLScripts(const RenderObject* object)
-{
- return toRenderMathMLScripts(toRenderMathMLBlock(object));
-}
-
-// This will catch anyone doing an unnecessary cast.
-void toRenderMathMLScripts(const RenderMathMLScripts*);
-
-}
-
#endif // ENABLE(MATHML)
#endif // RenderMathMLScripts_h
Modified: trunk/Source/WebCore/rendering/mathml/RenderMathMLSpace.h (159008 => 159009)
--- trunk/Source/WebCore/rendering/mathml/RenderMathMLSpace.h 2013-11-10 04:20:21 UTC (rev 159008)
+++ trunk/Source/WebCore/rendering/mathml/RenderMathMLSpace.h 2013-11-10 05:08:43 UTC (rev 159009)
@@ -54,21 +54,9 @@
LayoutUnit m_depth;
};
-inline RenderMathMLSpace* toRenderMathMLSpace(RenderMathMLBlock* block)
-{
- ASSERT_WITH_SECURITY_IMPLICATION(!block || block->isRenderMathMLSpace());
- return static_cast<RenderMathMLSpace*>(block);
-}
+RENDER_OBJECT_TYPE_CASTS(RenderMathMLSpace, isRenderMathMLSpace());
-inline const RenderMathMLSpace* toRenderMathMLSpace(const RenderMathMLBlock* block)
-{
- ASSERT_WITH_SECURITY_IMPLICATION(!block || block->isRenderMathMLSpace());
- return static_cast<const RenderMathMLSpace*>(block);
}
-// This will catch anyone doing an unnecessary cast.
-void toRenderMathMLSpace(const RenderMathMLSpace*);
-}
-
#endif // ENABLE(MATHML)
#endif // RenderMathMLSpace_h
Modified: trunk/Source/WebCore/rendering/mathml/RenderMathMLSquareRoot.h (159008 => 159009)
--- trunk/Source/WebCore/rendering/mathml/RenderMathMLSquareRoot.h 2013-11-10 04:20:21 UTC (rev 159008)
+++ trunk/Source/WebCore/rendering/mathml/RenderMathMLSquareRoot.h 2013-11-10 05:08:43 UTC (rev 159009)
@@ -33,13 +33,13 @@
namespace WebCore {
// Render sqrt(base), using radical notation.
-class RenderMathMLSquareRoot : public RenderMathMLRoot {
+class RenderMathMLSquareRoot FINAL : public RenderMathMLRoot {
public:
RenderMathMLSquareRoot(Element&, PassRef<RenderStyle>);
private:
- virtual bool isRenderMathMLSquareRoot() const { return true; }
- virtual const char* renderName() const { return "RenderMathMLSquareRoot"; }
+ virtual bool isRenderMathMLSquareRoot() const OVERRIDE { return true; }
+ virtual const char* renderName() const OVERRIDE { return "RenderMathMLSquareRoot"; }
};
}
Modified: trunk/Source/WebCore/rendering/mathml/RenderMathMLUnderOver.h (159008 => 159009)
--- trunk/Source/WebCore/rendering/mathml/RenderMathMLUnderOver.h 2013-11-10 04:20:21 UTC (rev 159008)
+++ trunk/Source/WebCore/rendering/mathml/RenderMathMLUnderOver.h 2013-11-10 05:08:43 UTC (rev 159009)
@@ -41,8 +41,8 @@
virtual int firstLineBaseline() const OVERRIDE;
private:
- virtual bool isRenderMathMLUnderOver() const { return true; }
- virtual const char* renderName() const { return "RenderMathMLUnderOver"; }
+ virtual bool isRenderMathMLUnderOver() const OVERRIDE { return true; }
+ virtual const char* renderName() const OVERRIDE { return "RenderMathMLUnderOver"; }
enum UnderOverType { Under, Over, UnderOver };
UnderOverType m_kind;