Add is<>() / downcast<>() support for RenderObject subclasses
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 7 Oct 2014 00:26:25 +0000 (00:26 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 7 Oct 2014 00:26:25 +0000 (00:26 +0000)
https://bugs.webkit.org/show_bug.cgi?id=137424

Reviewed by Benjamin Poulain.

Source/WebCore:

Add is<>() / downcast<>() support for RenderObject subclasses, and
get rid of IsRendererOfType traits struct as we can now rely on the
TypeCastsTraits instead.

toRender*() is still supported for most render objects because I did
not want to remove all usages in this patch, to keep the size small.
For now, only the MathML render objects were ported over to using
is<>() / downcast<>(). Other render objects will be taken care of in
follow-up patches and I will drop support for toRender*()
incrementally.

No new tests, no behavior change.

* accessibility/AccessibilityRenderObject.cpp:
(WebCore::AccessibilityRenderObject::isMathFenceOperator):
(WebCore::AccessibilityRenderObject::isMathSeparatorOperator):
(WebCore::AccessibilityRenderObject::mathLineThickness):
* dom/make_names.pl:
(printTypeHelpers):
* mathml/MathMLInlineContainerElement.cpp:
(WebCore::MathMLInlineContainerElement::childrenChanged):
* mathml/MathMLTextElement.cpp:
(WebCore::MathMLTextElement::didAttachRenderers):
(WebCore::MathMLTextElement::childrenChanged):
* rendering/RenderAncestorIterator.h:
(WebCore::lineageOfType):
* rendering/RenderBlock.h:
* rendering/RenderBlockFlow.h:
* rendering/RenderBox.h:
* rendering/RenderBoxModelObject.h:
* rendering/RenderButton.h:
* rendering/RenderCombineText.h:
* rendering/RenderCounter.h:
* rendering/RenderDetailsMarker.h:
* rendering/RenderElement.h:
* rendering/RenderEmbeddedObject.h:
* rendering/RenderFieldset.h:
* rendering/RenderFileUploadControl.h:
* rendering/RenderFlexibleBox.h:
* rendering/RenderFlowThread.h:
* rendering/RenderFrame.h:
* rendering/RenderFrameSet.h:
* rendering/RenderFullScreen.h:
* rendering/RenderGrid.h:
* rendering/RenderHTMLCanvas.h:
* rendering/RenderIFrame.h:
* rendering/RenderImage.h:
* rendering/RenderInline.h:
* rendering/RenderIterator.h:
(WebCore::isRendererOfType):
(WebCore::RenderTraversal::firstChild):
(WebCore::RenderTraversal::lastChild):
(WebCore::RenderTraversal::nextSibling):
(WebCore::RenderTraversal::previousSibling):
(WebCore::RenderTraversal::findAncestorOfType):
* rendering/RenderLayerModelObject.h:
* rendering/RenderLineBreak.h:
* rendering/RenderListBox.h:
* rendering/RenderListItem.h:
* rendering/RenderListMarker.h:
* rendering/RenderMedia.h:
* rendering/RenderMenuList.h:
* rendering/RenderMeter.h:
* rendering/RenderMultiColumnFlowThread.h:
* rendering/RenderMultiColumnSet.h:
* rendering/RenderMultiColumnSpannerPlaceholder.h:
* rendering/RenderNamedFlowFragment.h:
* rendering/RenderNamedFlowThread.h:
* rendering/RenderObject.h:
(WebCore::RenderObject>): Deleted.
* rendering/RenderProgress.h:
* rendering/RenderQuote.h:
* rendering/RenderRegion.h:
* rendering/RenderReplaced.h:
* rendering/RenderRubyRun.h:
* rendering/RenderScrollbarPart.h:
* rendering/RenderSearchField.h:
* rendering/RenderSlider.h:
* rendering/RenderSnapshottedPlugIn.h:
* rendering/RenderTable.h:
* rendering/RenderTableCaption.h:
* rendering/RenderTableCell.h:
* rendering/RenderTableCol.h:
* rendering/RenderTableRow.h:
* rendering/RenderTableSection.h:
* rendering/RenderText.h:
* rendering/RenderTextControl.h:
* rendering/RenderTextControlMultiLine.h:
* rendering/RenderTextControlSingleLine.h:
* rendering/RenderTextFragment.h:
* rendering/RenderVideo.h:
* rendering/RenderView.h:
* rendering/RenderWidget.h:
* rendering/mathml/RenderMathMLBlock.h:
* rendering/mathml/RenderMathMLFenced.cpp:
(WebCore::RenderMathMLFenced::updateFromElement):
* rendering/mathml/RenderMathMLFraction.cpp:
(WebCore::RenderMathMLFraction::unembellishedOperator):
* rendering/mathml/RenderMathMLFraction.h:
* rendering/mathml/RenderMathMLOperator.h:
* rendering/mathml/RenderMathMLRadicalOperator.h:
* rendering/mathml/RenderMathMLRoot.cpp:
(WebCore::RenderMathMLRoot::baseWrapper):
(WebCore::RenderMathMLRoot::radicalWrapper):
(WebCore::RenderMathMLRoot::indexWrapper):
(WebCore::RenderMathMLRoot::radicalOperator):
(WebCore::RenderMathMLRootWrapper::removeChild):
* rendering/mathml/RenderMathMLRoot.h:
* rendering/mathml/RenderMathMLRow.cpp:
(WebCore::RenderMathMLRow::updateOperatorProperties):
(WebCore::RenderMathMLRow::layout):
* rendering/mathml/RenderMathMLRow.h:
* rendering/mathml/RenderMathMLScripts.cpp:
(WebCore::RenderMathMLScripts::addChildInternal):
(WebCore::RenderMathMLScripts::removeChildInternal):
(WebCore::RenderMathMLScripts::unembellishedOperator):
(WebCore::RenderMathMLScripts::layout):
(WebCore::RenderMathMLScriptsWrapper::addChildInternal):
(WebCore::RenderMathMLScriptsWrapper::addChild):
(WebCore::RenderMathMLScriptsWrapper::removeChildInternal):
(WebCore::RenderMathMLScriptsWrapper::removeChild):
* rendering/mathml/RenderMathMLScripts.h:
* rendering/mathml/RenderMathMLSpace.h:
* rendering/mathml/RenderMathMLSquareRoot.h:
* rendering/mathml/RenderMathMLToken.h:
* rendering/mathml/RenderMathMLUnderOver.cpp:
(WebCore::RenderMathMLUnderOver::unembellishedOperator):
* rendering/svg/RenderSVGContainer.h:
* rendering/svg/RenderSVGGradientStop.h:
* rendering/svg/RenderSVGImage.h:
* rendering/svg/RenderSVGInlineText.h:
* rendering/svg/RenderSVGModelObject.h:
* rendering/svg/RenderSVGPath.h:
* rendering/svg/RenderSVGResourceContainer.h:
* rendering/svg/RenderSVGResourceFilter.h:
* rendering/svg/RenderSVGRoot.h:
* rendering/svg/RenderSVGShape.h:
* rendering/svg/RenderSVGText.h:
* rendering/svg/RenderSVGTextPath.h:
* rendering/svg/RenderSVGViewportContainer.h:

Source/WTF:

Handle correctly calling TypeCastTraits<ExpectedType, ArgType>::isOfType(ArgType&)
with ExpectedType being a base class of ArgType (or the same as ArgType). The
previous template specialization was only meant to support the case where
ExpectedType is the same as ArgType but even that wasn't working as the compiler
would complain about ambiguous partial specializations. Since this is needed by
RenderTraversal functions, this patch adds an extra isBaseType template parameter
to TypeCastTraits to resolve the ambiguity and relies on std::is_base_of for the
detection.

* wtf/TypeCasts.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@174375 268f45cc-cd09-0410-ab3c-d52691b4dbfc

97 files changed:
Source/WTF/ChangeLog
Source/WTF/wtf/TypeCasts.h
Source/WebCore/ChangeLog
Source/WebCore/accessibility/AccessibilityRenderObject.cpp
Source/WebCore/dom/make_names.pl
Source/WebCore/mathml/MathMLInlineContainerElement.cpp
Source/WebCore/mathml/MathMLTextElement.cpp
Source/WebCore/rendering/RenderAncestorIterator.h
Source/WebCore/rendering/RenderBlock.h
Source/WebCore/rendering/RenderBlockFlow.h
Source/WebCore/rendering/RenderBox.h
Source/WebCore/rendering/RenderBoxModelObject.h
Source/WebCore/rendering/RenderButton.h
Source/WebCore/rendering/RenderCombineText.h
Source/WebCore/rendering/RenderCounter.h
Source/WebCore/rendering/RenderDetailsMarker.h
Source/WebCore/rendering/RenderElement.h
Source/WebCore/rendering/RenderEmbeddedObject.h
Source/WebCore/rendering/RenderFieldset.h
Source/WebCore/rendering/RenderFileUploadControl.h
Source/WebCore/rendering/RenderFlexibleBox.h
Source/WebCore/rendering/RenderFlowThread.h
Source/WebCore/rendering/RenderFrame.h
Source/WebCore/rendering/RenderFrameSet.h
Source/WebCore/rendering/RenderFullScreen.h
Source/WebCore/rendering/RenderGrid.h
Source/WebCore/rendering/RenderHTMLCanvas.h
Source/WebCore/rendering/RenderIFrame.h
Source/WebCore/rendering/RenderImage.h
Source/WebCore/rendering/RenderInline.h
Source/WebCore/rendering/RenderIterator.h
Source/WebCore/rendering/RenderLayerModelObject.h
Source/WebCore/rendering/RenderLineBreak.h
Source/WebCore/rendering/RenderListBox.h
Source/WebCore/rendering/RenderListItem.h
Source/WebCore/rendering/RenderListMarker.h
Source/WebCore/rendering/RenderMedia.h
Source/WebCore/rendering/RenderMenuList.h
Source/WebCore/rendering/RenderMeter.h
Source/WebCore/rendering/RenderMultiColumnFlowThread.h
Source/WebCore/rendering/RenderMultiColumnSet.h
Source/WebCore/rendering/RenderMultiColumnSpannerPlaceholder.h
Source/WebCore/rendering/RenderNamedFlowFragment.h
Source/WebCore/rendering/RenderNamedFlowThread.h
Source/WebCore/rendering/RenderObject.h
Source/WebCore/rendering/RenderProgress.h
Source/WebCore/rendering/RenderQuote.h
Source/WebCore/rendering/RenderRegion.h
Source/WebCore/rendering/RenderReplaced.h
Source/WebCore/rendering/RenderRubyRun.h
Source/WebCore/rendering/RenderScrollbarPart.h
Source/WebCore/rendering/RenderSearchField.h
Source/WebCore/rendering/RenderSlider.h
Source/WebCore/rendering/RenderSnapshottedPlugIn.h
Source/WebCore/rendering/RenderTable.h
Source/WebCore/rendering/RenderTableCaption.h
Source/WebCore/rendering/RenderTableCell.h
Source/WebCore/rendering/RenderTableCol.h
Source/WebCore/rendering/RenderTableRow.h
Source/WebCore/rendering/RenderTableSection.h
Source/WebCore/rendering/RenderText.h
Source/WebCore/rendering/RenderTextControl.h
Source/WebCore/rendering/RenderTextControlMultiLine.h
Source/WebCore/rendering/RenderTextControlSingleLine.h
Source/WebCore/rendering/RenderTextFragment.h
Source/WebCore/rendering/RenderVideo.h
Source/WebCore/rendering/RenderView.h
Source/WebCore/rendering/RenderWidget.h
Source/WebCore/rendering/mathml/RenderMathMLBlock.h
Source/WebCore/rendering/mathml/RenderMathMLFenced.cpp
Source/WebCore/rendering/mathml/RenderMathMLFraction.cpp
Source/WebCore/rendering/mathml/RenderMathMLFraction.h
Source/WebCore/rendering/mathml/RenderMathMLOperator.h
Source/WebCore/rendering/mathml/RenderMathMLRadicalOperator.h
Source/WebCore/rendering/mathml/RenderMathMLRoot.cpp
Source/WebCore/rendering/mathml/RenderMathMLRoot.h
Source/WebCore/rendering/mathml/RenderMathMLRow.cpp
Source/WebCore/rendering/mathml/RenderMathMLRow.h
Source/WebCore/rendering/mathml/RenderMathMLScripts.cpp
Source/WebCore/rendering/mathml/RenderMathMLScripts.h
Source/WebCore/rendering/mathml/RenderMathMLSpace.h
Source/WebCore/rendering/mathml/RenderMathMLSquareRoot.h
Source/WebCore/rendering/mathml/RenderMathMLToken.h
Source/WebCore/rendering/mathml/RenderMathMLUnderOver.cpp
Source/WebCore/rendering/svg/RenderSVGContainer.h
Source/WebCore/rendering/svg/RenderSVGGradientStop.h
Source/WebCore/rendering/svg/RenderSVGImage.h
Source/WebCore/rendering/svg/RenderSVGInlineText.h
Source/WebCore/rendering/svg/RenderSVGModelObject.h
Source/WebCore/rendering/svg/RenderSVGPath.h
Source/WebCore/rendering/svg/RenderSVGResourceContainer.h
Source/WebCore/rendering/svg/RenderSVGResourceFilter.h
Source/WebCore/rendering/svg/RenderSVGRoot.h
Source/WebCore/rendering/svg/RenderSVGShape.h
Source/WebCore/rendering/svg/RenderSVGText.h
Source/WebCore/rendering/svg/RenderSVGTextPath.h
Source/WebCore/rendering/svg/RenderSVGViewportContainer.h

index a895ef5..78e5e00 100644 (file)
@@ -1,3 +1,21 @@
+2014-10-06  Christophe Dumez  <cdumez@apple.com>
+
+        Add is<>() / downcast<>() support for RenderObject subclasses
+        https://bugs.webkit.org/show_bug.cgi?id=137424
+
+        Reviewed by Benjamin Poulain.
+
+        Handle correctly calling TypeCastTraits<ExpectedType, ArgType>::isOfType(ArgType&)
+        with ExpectedType being a base class of ArgType (or the same as ArgType). The
+        previous template specialization was only meant to support the case where
+        ExpectedType is the same as ArgType but even that wasn't working as the compiler
+        would complain about ambiguous partial specializations. Since this is needed by
+        RenderTraversal functions, this patch adds an extra isBaseType template parameter
+        to TypeCastTraits to resolve the ambiguity and relies on std::is_base_of for the
+        detection.
+
+        * wtf/TypeCasts.h:
+
 2014-10-06  Brent Fulgham  <bfulgham@apple.com>
 
         [Win] Project file gardening.
index 3c20341..c0ab925 100644 (file)
@@ -30,7 +30,7 @@
 
 namespace WTF {
 
-template <typename ExpectedType, typename ArgType>
+template <typename ExpectedType, typename ArgType, bool isBaseType = std::is_base_of<ExpectedType, ArgType>::value>
 struct TypeCastTraits {
     static bool isOfType(ArgType&)
     {
@@ -44,9 +44,11 @@ struct TypeCastTraits {
     }
 };
 
-template <typename ExpectedType>
-struct TypeCastTraits<ExpectedType, ExpectedType> {
-    static bool isOfType(ExpectedType&) { return true; }
+// Template specialization for the case where ExpectedType is a base of ArgType,
+// so we can return return true unconditionally.
+template <typename ExpectedType, typename ArgType>
+struct TypeCastTraits<ExpectedType, ArgType, true /* isBaseType */> {
+    static bool isOfType(ArgType&) { return true; }
 };
 
 // Type checking function, to use before casting with downcast<>().
@@ -83,7 +85,7 @@ template<typename Target, typename Source> inline typename std::conditional<std:
 #define SPECIALIZE_TYPE_TRAITS_BEGIN(ClassName) \
 namespace WTF { \
 template <typename ArgType> \
-class TypeCastTraits<const ClassName, ArgType> { \
+class TypeCastTraits<const ClassName, ArgType, false /* isBaseType */> { \
 public: \
     static bool isOfType(ArgType& source) { return isType(source); } \
 private:
@@ -94,6 +96,7 @@ private:
 
 } // namespace WTF
 
+using WTF::TypeCastTraits;
 using WTF::is;
 using WTF::downcast;
 
index 5183d8b..1fc8ba7 100644 (file)
@@ -1,5 +1,153 @@
 2014-10-06  Christophe Dumez  <cdumez@apple.com>
 
+        Add is<>() / downcast<>() support for RenderObject subclasses
+        https://bugs.webkit.org/show_bug.cgi?id=137424
+
+        Reviewed by Benjamin Poulain.
+
+        Add is<>() / downcast<>() support for RenderObject subclasses, and
+        get rid of IsRendererOfType traits struct as we can now rely on the
+        TypeCastsTraits instead.
+
+        toRender*() is still supported for most render objects because I did
+        not want to remove all usages in this patch, to keep the size small.
+        For now, only the MathML render objects were ported over to using
+        is<>() / downcast<>(). Other render objects will be taken care of in
+        follow-up patches and I will drop support for toRender*()
+        incrementally.
+
+        No new tests, no behavior change.
+
+        * accessibility/AccessibilityRenderObject.cpp:
+        (WebCore::AccessibilityRenderObject::isMathFenceOperator):
+        (WebCore::AccessibilityRenderObject::isMathSeparatorOperator):
+        (WebCore::AccessibilityRenderObject::mathLineThickness):
+        * dom/make_names.pl:
+        (printTypeHelpers):
+        * mathml/MathMLInlineContainerElement.cpp:
+        (WebCore::MathMLInlineContainerElement::childrenChanged):
+        * mathml/MathMLTextElement.cpp:
+        (WebCore::MathMLTextElement::didAttachRenderers):
+        (WebCore::MathMLTextElement::childrenChanged):
+        * rendering/RenderAncestorIterator.h:
+        (WebCore::lineageOfType):
+        * rendering/RenderBlock.h:
+        * rendering/RenderBlockFlow.h:
+        * rendering/RenderBox.h:
+        * rendering/RenderBoxModelObject.h:
+        * rendering/RenderButton.h:
+        * rendering/RenderCombineText.h:
+        * rendering/RenderCounter.h:
+        * rendering/RenderDetailsMarker.h:
+        * rendering/RenderElement.h:
+        * rendering/RenderEmbeddedObject.h:
+        * rendering/RenderFieldset.h:
+        * rendering/RenderFileUploadControl.h:
+        * rendering/RenderFlexibleBox.h:
+        * rendering/RenderFlowThread.h:
+        * rendering/RenderFrame.h:
+        * rendering/RenderFrameSet.h:
+        * rendering/RenderFullScreen.h:
+        * rendering/RenderGrid.h:
+        * rendering/RenderHTMLCanvas.h:
+        * rendering/RenderIFrame.h:
+        * rendering/RenderImage.h:
+        * rendering/RenderInline.h:
+        * rendering/RenderIterator.h:
+        (WebCore::isRendererOfType):
+        (WebCore::RenderTraversal::firstChild):
+        (WebCore::RenderTraversal::lastChild):
+        (WebCore::RenderTraversal::nextSibling):
+        (WebCore::RenderTraversal::previousSibling):
+        (WebCore::RenderTraversal::findAncestorOfType):
+        * rendering/RenderLayerModelObject.h:
+        * rendering/RenderLineBreak.h:
+        * rendering/RenderListBox.h:
+        * rendering/RenderListItem.h:
+        * rendering/RenderListMarker.h:
+        * rendering/RenderMedia.h:
+        * rendering/RenderMenuList.h:
+        * rendering/RenderMeter.h:
+        * rendering/RenderMultiColumnFlowThread.h:
+        * rendering/RenderMultiColumnSet.h:
+        * rendering/RenderMultiColumnSpannerPlaceholder.h:
+        * rendering/RenderNamedFlowFragment.h:
+        * rendering/RenderNamedFlowThread.h:
+        * rendering/RenderObject.h:
+        (WebCore::RenderObject>): Deleted.
+        * rendering/RenderProgress.h:
+        * rendering/RenderQuote.h:
+        * rendering/RenderRegion.h:
+        * rendering/RenderReplaced.h:
+        * rendering/RenderRubyRun.h:
+        * rendering/RenderScrollbarPart.h:
+        * rendering/RenderSearchField.h:
+        * rendering/RenderSlider.h:
+        * rendering/RenderSnapshottedPlugIn.h:
+        * rendering/RenderTable.h:
+        * rendering/RenderTableCaption.h:
+        * rendering/RenderTableCell.h:
+        * rendering/RenderTableCol.h:
+        * rendering/RenderTableRow.h:
+        * rendering/RenderTableSection.h:
+        * rendering/RenderText.h:
+        * rendering/RenderTextControl.h:
+        * rendering/RenderTextControlMultiLine.h:
+        * rendering/RenderTextControlSingleLine.h:
+        * rendering/RenderTextFragment.h:
+        * rendering/RenderVideo.h:
+        * rendering/RenderView.h:
+        * rendering/RenderWidget.h:
+        * rendering/mathml/RenderMathMLBlock.h:
+        * rendering/mathml/RenderMathMLFenced.cpp:
+        (WebCore::RenderMathMLFenced::updateFromElement):
+        * rendering/mathml/RenderMathMLFraction.cpp:
+        (WebCore::RenderMathMLFraction::unembellishedOperator):
+        * rendering/mathml/RenderMathMLFraction.h:
+        * rendering/mathml/RenderMathMLOperator.h:
+        * rendering/mathml/RenderMathMLRadicalOperator.h:
+        * rendering/mathml/RenderMathMLRoot.cpp:
+        (WebCore::RenderMathMLRoot::baseWrapper):
+        (WebCore::RenderMathMLRoot::radicalWrapper):
+        (WebCore::RenderMathMLRoot::indexWrapper):
+        (WebCore::RenderMathMLRoot::radicalOperator):
+        (WebCore::RenderMathMLRootWrapper::removeChild):
+        * rendering/mathml/RenderMathMLRoot.h:
+        * rendering/mathml/RenderMathMLRow.cpp:
+        (WebCore::RenderMathMLRow::updateOperatorProperties):
+        (WebCore::RenderMathMLRow::layout):
+        * rendering/mathml/RenderMathMLRow.h:
+        * rendering/mathml/RenderMathMLScripts.cpp:
+        (WebCore::RenderMathMLScripts::addChildInternal):
+        (WebCore::RenderMathMLScripts::removeChildInternal):
+        (WebCore::RenderMathMLScripts::unembellishedOperator):
+        (WebCore::RenderMathMLScripts::layout):
+        (WebCore::RenderMathMLScriptsWrapper::addChildInternal):
+        (WebCore::RenderMathMLScriptsWrapper::addChild):
+        (WebCore::RenderMathMLScriptsWrapper::removeChildInternal):
+        (WebCore::RenderMathMLScriptsWrapper::removeChild):
+        * rendering/mathml/RenderMathMLScripts.h:
+        * rendering/mathml/RenderMathMLSpace.h:
+        * rendering/mathml/RenderMathMLSquareRoot.h:
+        * rendering/mathml/RenderMathMLToken.h:
+        * rendering/mathml/RenderMathMLUnderOver.cpp:
+        (WebCore::RenderMathMLUnderOver::unembellishedOperator):
+        * rendering/svg/RenderSVGContainer.h:
+        * rendering/svg/RenderSVGGradientStop.h:
+        * rendering/svg/RenderSVGImage.h:
+        * rendering/svg/RenderSVGInlineText.h:
+        * rendering/svg/RenderSVGModelObject.h:
+        * rendering/svg/RenderSVGPath.h:
+        * rendering/svg/RenderSVGResourceContainer.h:
+        * rendering/svg/RenderSVGResourceFilter.h:
+        * rendering/svg/RenderSVGRoot.h:
+        * rendering/svg/RenderSVGShape.h:
+        * rendering/svg/RenderSVGText.h:
+        * rendering/svg/RenderSVGTextPath.h:
+        * rendering/svg/RenderSVGViewportContainer.h:
+
+2014-10-06  Christophe Dumez  <cdumez@apple.com>
+
         Use is<>() / downcast<>() for ScrollingTreeNode subclasses
         https://bugs.webkit.org/show_bug.cgi?id=137451
 
index 4505655..4e22f5f 100644 (file)
@@ -3536,18 +3536,18 @@ bool AccessibilityRenderObject::isMathOperator() const
 
 bool AccessibilityRenderObject::isMathFenceOperator() const
 {
-    if (!m_renderer || !m_renderer->isRenderMathMLOperator())
+    if (!is<RenderMathMLOperator>(m_renderer))
         return false;
 
-    return toRenderMathMLOperator(*m_renderer).hasOperatorFlag(MathMLOperatorDictionary::Fence);
+    return downcast<RenderMathMLOperator>(*m_renderer).hasOperatorFlag(MathMLOperatorDictionary::Fence);
 }
 
 bool AccessibilityRenderObject::isMathSeparatorOperator() const
 {
-    if (!m_renderer || !m_renderer->isRenderMathMLOperator())
+    if (!is<RenderMathMLOperator>(m_renderer))
         return false;
 
-    return toRenderMathMLOperator(*m_renderer).hasOperatorFlag(MathMLOperatorDictionary::Separator);
+    return downcast<RenderMathMLOperator>(*m_renderer).hasOperatorFlag(MathMLOperatorDictionary::Separator);
 }
     
 bool AccessibilityRenderObject::isMathText() const
@@ -3823,10 +3823,10 @@ void AccessibilityRenderObject::mathPostscripts(AccessibilityMathMultiscriptPair
 
 int AccessibilityRenderObject::mathLineThickness() const
 {
-    if (!isMathFraction())
+    if (!is<RenderMathMLFraction>(m_renderer))
         return -1;
     
-    return toRenderMathMLFraction(m_renderer)->lineThickness();
+    return downcast<RenderMathMLFraction>(*m_renderer).lineThickness();
 }
 
 #endif
index 522e7df..6799294 100755 (executable)
@@ -644,7 +644,7 @@ class $class;
 }
 namespace WTF {
 template <typename ArgType>
-class TypeCastTraits<const WebCore::$class, ArgType> {
+class TypeCastTraits<const WebCore::$class, ArgType, false /* isBaseType */> {
 public:
     static bool isOfType(ArgType& node) { return checkTagName(node); }
 private:
index e583035..bdb6bf6 100644 (file)
@@ -58,12 +58,12 @@ PassRefPtr<MathMLInlineContainerElement> MathMLInlineContainerElement::create(co
 void MathMLInlineContainerElement::childrenChanged(const ChildChange& change)
 {
     if (renderer()) {
-        if (renderer()->isRenderMathMLRow())
-            toRenderMathMLRow(renderer())->updateOperatorProperties();
+        if (is<RenderMathMLRow>(*renderer()))
+            downcast<RenderMathMLRow>(*renderer()).updateOperatorProperties();
         else if (hasTagName(mathTag) || hasTagName(msqrtTag)) {
-            auto childRenderer = renderer()->firstChild();
-            if (childRenderer && childRenderer->isRenderMathMLRow())
-                toRenderMathMLRow(childRenderer)->updateOperatorProperties();
+            auto* childRenderer = renderer()->firstChild();
+            if (is<RenderMathMLRow>(childRenderer))
+                downcast<RenderMathMLRow>(*childRenderer).updateOperatorProperties();
         }
     }
     MathMLElement::childrenChanged(change);
index 22383c0..08e5edd 100644 (file)
@@ -53,15 +53,15 @@ PassRefPtr<MathMLTextElement> MathMLTextElement::create(const QualifiedName& tag
 void MathMLTextElement::didAttachRenderers()
 {
     MathMLElement::didAttachRenderers();
-    if (renderer() && renderer()->isRenderMathMLToken())
-        toRenderMathMLToken(renderer())->updateTokenContent();
+    if (is<RenderMathMLToken>(renderer()))
+        downcast<RenderMathMLToken>(*renderer()).updateTokenContent();
 }
 
 void MathMLTextElement::childrenChanged(const ChildChange& change)
 {
     MathMLElement::childrenChanged(change);
-    if (renderer() && renderer()->isRenderMathMLToken())
-        toRenderMathMLToken(renderer())->updateTokenContent();
+    if (is<RenderMathMLToken>(renderer()))
+        downcast<RenderMathMLToken>(*renderer()).updateTokenContent();
 }
 
 RenderPtr<RenderElement> MathMLTextElement::createElementRenderer(PassRef<RenderStyle> style)
index 39dd05e..8e8d88e 100644 (file)
@@ -186,7 +186,7 @@ inline RenderAncestorConstIteratorAdapter<T> ancestorsOfType(const RenderObject&
 template <typename T>
 inline RenderAncestorIteratorAdapter<T> lineageOfType(RenderObject& first)
 {
-    if (isRendererOfType<const T>(first))
+    if (isRendererOfType<T>(first))
         return RenderAncestorIteratorAdapter<T>(static_cast<T*>(&first));
     return ancestorsOfType<T>(first);
 }
@@ -194,7 +194,7 @@ inline RenderAncestorIteratorAdapter<T> lineageOfType(RenderObject& first)
 template <typename T>
 inline RenderAncestorConstIteratorAdapter<T> lineageOfType(const RenderObject& first)
 {
-    if (isRendererOfType<const T>(first))
+    if (isRendererOfType<T>(first))
         return RenderAncestorConstIteratorAdapter<T>(static_cast<const T*>(&first));
     return ancestorsOfType<T>(first);
 }
index 9a4cf88..6400db6 100644 (file)
@@ -538,4 +538,6 @@ VisiblePosition positionForPointRespectingEditingBoundaries(RenderBlock&, Render
 
 } // namespace WebCore
 
+SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderBlock, isRenderBlock())
+
 #endif // RenderBlock_h
index 2079bbf..3aafae2 100644 (file)
@@ -636,4 +636,6 @@ inline const SimpleLineLayout::Layout* RenderBlockFlow::simpleLineLayout() const
 
 } // namespace WebCore
 
+SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderBlockFlow, isRenderBlockFlow())
+
 #endif // RenderBlockFlow_h
index b8266a3..9c75462 100644 (file)
@@ -767,4 +767,6 @@ inline void RenderBox::setInlineBoxWrapper(InlineElementBox* boxWrapper)
 
 } // namespace WebCore
 
+SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderBox, isBox())
+
 #endif // RenderBox_h
index ace8885..71b993e 100644 (file)
@@ -343,4 +343,6 @@ RENDER_OBJECT_TYPE_CASTS(RenderBoxModelObject, isBoxModelObject())
 
 } // namespace WebCore
 
+SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderBoxModelObject, isBoxModelObject())
+
 #endif // RenderBoxModelObject_h
index acd69b2..a1a6520 100644 (file)
@@ -87,4 +87,6 @@ RENDER_OBJECT_TYPE_CASTS(RenderButton, isRenderButton())
 
 } // namespace WebCore
 
+SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderButton, isRenderButton())
+
 #endif // RenderButton_h
index 3963b30..d429329 100644 (file)
@@ -61,4 +61,6 @@ RENDER_OBJECT_TYPE_CASTS(RenderCombineText, isCombineText())
 
 } // namespace WebCore
 
+SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderCombineText, isCombineText())
+
 #endif // RenderCombineText_h
index c6f86db..8c3816c 100644 (file)
@@ -66,6 +66,8 @@ RENDER_OBJECT_TYPE_CASTS(RenderCounter, isCounter())
 
 } // namespace WebCore
 
+SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderCounter, isCounter())
+
 #ifndef NDEBUG
 // Outside the WebCore namespace for ease of invocation from gdb.
 void showCounterRendererTree(const WebCore::RenderObject*, const char* counterName = 0);
index 833f2a6..1c4aaf0 100644 (file)
@@ -47,9 +47,11 @@ private:
 
 RENDER_OBJECT_TYPE_CASTS(RenderDetailsMarker, isDetailsMarker())
 
-}
+} // namespace WebCore
 
-#endif
+SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderDetailsMarker, isDetailsMarker())
+
+#endif // ENABLE(DETAILS_ELEMENT)
 
 #endif // RenderDetailsMarker_h
 
index 05ce794..ed04876 100644 (file)
@@ -380,4 +380,6 @@ inline LayoutUnit adjustLayoutUnitForAbsoluteZoom(LayoutUnit value, const Render
 
 } // namespace WebCore
 
+SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderElement, isRenderElement())
+
 #endif // RenderElement_h
index 2bfbec1..83c7c37 100644 (file)
@@ -105,4 +105,6 @@ RENDER_OBJECT_TYPE_CASTS(RenderEmbeddedObject, isEmbeddedObject())
 
 } // namespace WebCore
 
+SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderEmbeddedObject, isEmbeddedObject())
+
 #endif // RenderEmbeddedObject_h
index 9f672d7..44a8374 100644 (file)
@@ -59,4 +59,6 @@ RENDER_OBJECT_TYPE_CASTS(RenderFieldset, isFieldset())
 
 } // namespace WebCore
 
+SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderFieldset, isFieldset())
+
 #endif // RenderFieldset_h
index 1d5a4cf..ce4abad 100644 (file)
@@ -68,4 +68,6 @@ RENDER_OBJECT_TYPE_CASTS(RenderFileUploadControl, isFileUploadControl())
 
 } // namespace WebCore
 
+SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderFileUploadControl, isFileUploadControl())
+
 #endif // RenderFileUploadControl_h
index 35852c9..1f13620 100644 (file)
@@ -165,4 +165,6 @@ RENDER_OBJECT_TYPE_CASTS(RenderFlexibleBox, isFlexibleBox())
 
 } // namespace WebCore
 
+SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderFlexibleBox, isFlexibleBox())
+
 #endif // RenderFlexibleBox_h
index d373280..b9ed3b4 100644 (file)
@@ -410,4 +410,6 @@ template <> struct ValueToString<RenderRegion*> {
 
 } // namespace WebCore
 
+SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderFlowThread, isRenderFlowThread())
+
 #endif // RenderFlowThread_h
index 03f5a4f..dde9b6b 100644 (file)
@@ -50,4 +50,6 @@ RENDER_OBJECT_TYPE_CASTS(RenderFrame, isFrame())
 
 } // namespace WebCore
 
+SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderFrame, isFrame())
+
 #endif // RenderFrame_h
index 898293a..e9b8a1e 100644 (file)
@@ -130,4 +130,6 @@ RENDER_OBJECT_TYPE_CASTS(RenderFrameSet, isFrameSet())
 
 } // namespace WebCore
 
+SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderFrameSet, isFrameSet())
+
 #endif // RenderFrameSet_h
index c942fc5..525e0e9 100644 (file)
@@ -55,8 +55,10 @@ protected:
 
 RENDER_OBJECT_TYPE_CASTS(RenderFullScreen, isRenderFullScreen())
 
-}
+} // namespace WebCore
 
-#endif
+SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderFullScreen, isRenderFullScreen())
 
-#endif
+#endif // ENABLE(FULLSCREEN_API)
+
+#endif // RenderFullScreen_h
index 9194610..13563eb 100644 (file)
@@ -135,6 +135,8 @@ RENDER_OBJECT_TYPE_CASTS(RenderGrid, isRenderGrid())
 
 } // namespace WebCore
 
+SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderGrid, isRenderGrid())
+
 #endif /* ENABLE(CSS_GRID_LAYOUT) */
 
 #endif // RenderGrid_h
index a05a1e1..a71edab 100644 (file)
@@ -53,4 +53,6 @@ RENDER_OBJECT_TYPE_CASTS(RenderHTMLCanvas, isCanvas())
 
 } // namespace WebCore
 
+SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderHTMLCanvas, isCanvas())
+
 #endif // RenderHTMLCanvas_h
index 7cc0331..686c6b2 100644 (file)
@@ -66,4 +66,6 @@ RENDER_OBJECT_TYPE_CASTS(RenderIFrame, isRenderIFrame())
 
 } // namespace WebCore
 
+SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderIFrame, isRenderIFrame())
+
 #endif // RenderIFrame_h
index 46370a9..c5aea05 100644 (file)
@@ -132,4 +132,6 @@ RENDER_OBJECT_TYPE_CASTS(RenderImage, isRenderImage())
 
 } // namespace WebCore
 
+SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderImage, isRenderImage())
+
 #endif // RenderImage_h
index 49ae0cf..6281117 100644 (file)
@@ -184,4 +184,6 @@ RENDER_OBJECT_TYPE_CASTS(RenderInline, isRenderInline())
 
 } // namespace WebCore
 
+SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderInline, isRenderInline())
+
 #endif // RenderInline_h
index 5c51947..9832b4f 100644 (file)
@@ -72,6 +72,10 @@ private:
     const T* m_current;
 };
 
+// Similar to WTF::is<>() but without the static_assert() making sure the check is necessary.
+template <typename T, typename U>
+inline bool isRendererOfType(const U& renderer) { return TypeCastTraits<const T, const U>::isOfType(renderer); }
+
 // Traversal helpers
 
 namespace RenderTraversal {
@@ -80,7 +84,7 @@ template <typename T, typename U>
 inline T* firstChild(U& current)
 {
     RenderObject* object = current.firstChild();
-    while (object && !isRendererOfType<const T>(*object))
+    while (object && !isRendererOfType<T>(*object))
         object = object->nextSibling();
     return static_cast<T*>(object);
 }
@@ -89,7 +93,7 @@ template <typename T, typename U>
 inline T* lastChild(U& current)
 {
     RenderObject* object = current.lastChild();
-    while (object && !isRendererOfType<const T>(*object))
+    while (object && !isRendererOfType<T>(*object))
         object = object->previousSibling();
     return static_cast<T*>(object);
 }
@@ -98,7 +102,7 @@ template <typename T, typename U>
 inline T* nextSibling(U& current)
 {
     RenderObject* object = current.nextSibling();
-    while (object && !isRendererOfType<const T>(*object))
+    while (object && !isRendererOfType<T>(*object))
         object = object->nextSibling();
     return static_cast<T*>(object);
 }
@@ -107,7 +111,7 @@ template <typename T, typename U>
 inline T* previousSibling(U& current)
 {
     RenderObject* object = current.previousSibling();
-    while (object && !isRendererOfType<const T>(*object))
+    while (object && !isRendererOfType<T>(*object))
         object = object->previousSibling();
     return static_cast<T*>(object);
 }
@@ -115,8 +119,8 @@ inline T* previousSibling(U& current)
 template <typename T>
 inline T* findAncestorOfType(const RenderObject& current)
 {
-    for (auto ancestor = current.parent(); ancestor; ancestor = ancestor->parent()) {
-        if (isRendererOfType<const T>(*ancestor))
+    for (auto* ancestor = current.parent(); ancestor; ancestor = ancestor->parent()) {
+        if (isRendererOfType<T>(*ancestor))
             return static_cast<T*>(ancestor);
     }
     return nullptr;
index 6c1a874..2099042 100644 (file)
@@ -73,4 +73,6 @@ RENDER_OBJECT_TYPE_CASTS(RenderLayerModelObject, isRenderLayerModelObject())
 
 } // namespace WebCore
 
+SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderLayerModelObject, isRenderLayerModelObject())
+
 #endif // RenderLayerModelObject_h
index c394e86..e8ec5ef 100644 (file)
@@ -97,4 +97,6 @@ RENDER_OBJECT_TYPE_CASTS(RenderLineBreak, isLineBreak())
 
 } // namespace WebCore
 
+SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderLineBreak, isLineBreak())
+
 #endif // RenderLineBreak_h
index 3b6db76..5220b82 100644 (file)
@@ -165,4 +165,6 @@ RENDER_OBJECT_TYPE_CASTS(RenderListBox, isListBox())
 
 } // namepace WebCore
 
+SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderListBox, isListBox())
+
 #endif // RenderListBox_h
index 795de3a..0a81a38 100644 (file)
@@ -97,4 +97,6 @@ RENDER_OBJECT_TYPE_CASTS(RenderListItem, isListItem())
 
 } // namespace WebCore
 
+SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderListItem, isListItem())
+
 #endif // RenderListItem_h
index 243da07..ea8d32f 100644 (file)
@@ -89,4 +89,6 @@ RENDER_OBJECT_TYPE_CASTS(RenderListMarker, isListMarker())
 
 } // namespace WebCore
 
+SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderListMarker, isListMarker())
+
 #endif // RenderListMarker_h
index e959e24..cf4e65d 100644 (file)
@@ -60,6 +60,8 @@ RENDER_OBJECT_TYPE_CASTS(RenderMedia, isMedia())
 
 } // namespace WebCore
 
-#endif
+SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderMedia, isMedia())
+
+#endif // ENABLE(VIDEO)
 
 #endif // RenderMedia_h
index 4f0cd36..93e6bb2 100644 (file)
@@ -154,6 +154,8 @@ private:
 
 RENDER_OBJECT_TYPE_CASTS(RenderMenuList, isMenuList())
 
-}
+} // namespace WebCore
+
+SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderMenuList, isMenuList())
 
 #endif
index 80f333f..a63250e 100644 (file)
@@ -51,7 +51,9 @@ RENDER_OBJECT_TYPE_CASTS(RenderMeter, isMeter())
 
 } // namespace WebCore
 
-#endif
+SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderMeter, isMeter())
+
+#endif // ENABLE(METER_ELEMENT)
 
 #endif // RenderMeter_h
 
index 8806582..7f74e72 100644 (file)
@@ -163,5 +163,7 @@ RENDER_OBJECT_TYPE_CASTS(RenderMultiColumnFlowThread, isRenderMultiColumnFlowThr
 
 } // namespace WebCore
 
+SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderMultiColumnFlowThread, isRenderMultiColumnFlowThread())
+
 #endif // RenderMultiColumnFlowThread_h
 
index efedb91..750d5cc 100644 (file)
@@ -229,5 +229,7 @@ RENDER_OBJECT_TYPE_CASTS(RenderMultiColumnSet, isRenderMultiColumnSet())
 
 } // namespace WebCore
 
+SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderMultiColumnSet, isRenderMultiColumnSet())
+
 #endif // RenderMultiColumnSet_h
 
index 10a5ca4..caac2e7 100644 (file)
@@ -59,4 +59,6 @@ RENDER_OBJECT_TYPE_CASTS(RenderMultiColumnSpannerPlaceholder, isRenderMultiColum
 
 } // namespace WebCore
 
+SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderMultiColumnSpannerPlaceholder, isRenderMultiColumnSpannerPlaceholder())
+
 #endif // RenderMultiColumnSpannerPlaceholder_h
index 9995e3a..f6ce2fa 100644 (file)
@@ -167,4 +167,6 @@ RENDER_OBJECT_TYPE_CASTS(RenderNamedFlowFragment, isRenderNamedFlowFragment())
 
 } // namespace WebCore
 
+SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderNamedFlowFragment, isRenderNamedFlowFragment())
+
 #endif // RenderNamedFlowFragment_h
index ede9c07..d82713a 100644 (file)
@@ -163,4 +163,6 @@ RENDER_OBJECT_TYPE_CASTS(RenderNamedFlowThread, isRenderNamedFlowThread())
 
 } // namespace WebCore
 
+SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderNamedFlowThread, isRenderNamedFlowThread())
+
 #endif // RenderNamedFlowThread_h
index b1a81c9..44232fa 100644 (file)
@@ -38,6 +38,7 @@
 #include "StyleInheritedData.h"
 #include "TextAffinity.h"
 #include <wtf/HashSet.h>
+#include <wtf/TypeCasts.h>
 
 namespace WebCore {
 
@@ -1030,9 +1031,6 @@ private:
     void setEverHadLayout(bool b) { m_bitfields.setEverHadLayout(b); }
 };
 
-template <typename Type> bool isRendererOfType(const RenderObject&);
-template <> inline bool isRendererOfType<const RenderObject>(const RenderObject&) { return true; }
-
 inline Frame& RenderObject::frame() const
 {
     return *document().frame();
@@ -1128,12 +1126,17 @@ inline bool RenderObject::backgroundIsKnownToBeObscured()
     return m_bitfields.boxDecorationState() == HasBoxDecorationsAndBackgroundIsKnownToBeObscured;
 }
 
+// FIXME: Remove this macro and use SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT() instead.
 #define RENDER_OBJECT_TYPE_CASTS(ToValueTypeName, predicate) \
-    template <> inline bool isRendererOfType<const ToValueTypeName>(const RenderObject& renderer) { return renderer.predicate; } \
-    TYPE_CASTS_BASE(ToValueTypeName, RenderObject, renderer, isRendererOfType<const ToValueTypeName>(*renderer), isRendererOfType<const ToValueTypeName>(renderer))
+    TYPE_CASTS_BASE(ToValueTypeName, RenderObject, renderer, is<ToValueTypeName>(*renderer), is<ToValueTypeName>(renderer))
 
 } // namespace WebCore
 
+#define SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(ToValueTypeName, predicate) \
+SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::ToValueTypeName) \
+    static bool isType(const WebCore::RenderObject& renderer) { return renderer.predicate; } \
+SPECIALIZE_TYPE_TRAITS_END()
+
 #ifndef NDEBUG
 // Outside the WebCore namespace for ease of invocation from gdb.
 void showNodeTree(const WebCore::RenderObject*);
index 3cb4d25..86e8765 100644 (file)
@@ -62,5 +62,7 @@ RENDER_OBJECT_TYPE_CASTS(RenderProgress, isProgress())
 
 } // namespace WebCore
 
+SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderProgress, isProgress())
+
 #endif // RenderProgress_h
 
index ea2a83c..ab9b8ca 100644 (file)
@@ -59,4 +59,6 @@ RENDER_OBJECT_TYPE_CASTS(RenderQuote, isQuote())
 
 } // namespace WebCore
 
+SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderQuote, isQuote())
+
 #endif // RenderQuote_h
index 3acec0a..01e674c 100644 (file)
@@ -179,8 +179,6 @@ private:
     bool m_isValid : 1;
 };
 
-RENDER_OBJECT_TYPE_CASTS(RenderRegion, isRenderRegion())
-
 class CurrentRenderRegionMaintainer {
     WTF_MAKE_NONCOPYABLE(CurrentRenderRegionMaintainer);
 public:
@@ -194,4 +192,6 @@ private:
 
 } // namespace WebCore
 
+SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderRegion, isRenderRegion())
+
 #endif // RenderRegion_h
index d2ab7b8..a859372 100644 (file)
@@ -91,6 +91,8 @@ private:
 
 RENDER_OBJECT_TYPE_CASTS(RenderReplaced, isRenderReplaced())
 
-}
+} // namespace WebCore
+
+SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderReplaced, isRenderReplaced())
 
 #endif
index 2fe15b9..a0adafb 100644 (file)
@@ -81,4 +81,6 @@ RENDER_OBJECT_TYPE_CASTS(RenderRubyRun, isRubyRun())
 
 } // namespace WebCore
 
+SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderRubyRun, isRubyRun())
+
 #endif // RenderRubyRun_h
index 0d38d6f..0cb670b 100644 (file)
@@ -77,4 +77,6 @@ RENDER_OBJECT_TYPE_CASTS(RenderScrollbarPart, isRenderScrollbarPart())
 
 } // namespace WebCore
 
+SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderScrollbarPart, isRenderScrollbarPart())
+
 #endif // RenderScrollbarPart_h
index 436561c..0a06633 100644 (file)
@@ -92,6 +92,8 @@ private:
 
 RENDER_OBJECT_TYPE_CASTS(RenderSearchField, isTextField())
 
-}
+} // namespace WebCore
+
+SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderSearchField, isTextField())
 
 #endif
index 96572ef..da8ac7a 100644 (file)
@@ -55,4 +55,6 @@ RENDER_OBJECT_TYPE_CASTS(RenderSlider, isSlider())
 
 } // namespace WebCore
 
+SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderSlider, isSlider())
+
 #endif // RenderSlider_h
index edf5751..092c50f 100644 (file)
@@ -67,4 +67,6 @@ RENDER_OBJECT_TYPE_CASTS(RenderSnapshottedPlugIn, isSnapshottedPlugIn())
 
 } // namespace WebCore
 
+SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderSnapshottedPlugIn, isSnapshottedPlugIn())
+
 #endif // RenderSnapshottedPlugIn_h
index 3f4bb8a..d9d1ee8 100644 (file)
@@ -385,4 +385,6 @@ RENDER_OBJECT_TYPE_CASTS(RenderTable, isTable())
 
 } // namespace WebCore
 
+SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderTable, isTable())
+
 #endif // RenderTable_h
index 14ba9d2..963b181 100644 (file)
@@ -48,4 +48,6 @@ RENDER_OBJECT_TYPE_CASTS(RenderTableCaption, isTableCaption())
 
 } // namespace WebCore
 
+SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderTableCaption, isTableCaption())
+
 #endif // RenderTableCaption_h
index 8a5bf2a..77c92b9 100644 (file)
@@ -318,4 +318,6 @@ inline RenderTableCell* RenderTableRow::lastCell() const
 
 } // namespace WebCore
 
+SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderTableCell, isTableCell())
+
 #endif // RenderTableCell_h
index 9dd9356..b79d2c3 100644 (file)
@@ -102,6 +102,8 @@ private:
 
 RENDER_OBJECT_TYPE_CASTS(RenderTableCol, isRenderTableCol())
 
-}
+} // namespace WebCore
 
-#endif
+SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderTableCol, isRenderTableCol())
+
+#endif // RenderTableCol_h
index 6470e6f..75becb5 100644 (file)
@@ -143,4 +143,6 @@ inline RenderTableRow* RenderTableRow::previousRow() const
 
 } // namespace WebCore
 
+SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderTableRow, isTableRow())
+
 #endif // RenderTableRow_h
index ee23309..b4b30c1 100644 (file)
@@ -351,4 +351,6 @@ RENDER_OBJECT_TYPE_CASTS(RenderTableSection, isTableSection())
 
 } // namespace WebCore
 
+SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderTableSection, isTableSection())
+
 #endif // RenderTableSection_h
index 84115a3..0eb233c 100644 (file)
@@ -259,4 +259,6 @@ inline RenderText* Text::renderer() const
 
 } // namespace WebCore
 
+SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderText, isText())
+
 #endif // RenderText_h
index 2150840..b9c2a37 100644 (file)
@@ -109,7 +109,8 @@ public:
 
 };
 
-
 } // namespace WebCore
 
+SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderTextControl, isTextControl())
+
 #endif // RenderTextControl_h
index 84ab228..6455c10 100644 (file)
@@ -53,6 +53,8 @@ private:
 
 RENDER_OBJECT_TYPE_CASTS(RenderTextControlMultiLine, isTextArea())
 
-}
+} // namespace WebCore
 
-#endif
+SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderTextControlMultiLine, isTextArea())
+
+#endif // RenderTextControlMultiLine_h
index feb8051..61c07d6 100644 (file)
@@ -115,6 +115,9 @@ private:
 
 RENDER_OBJECT_TYPE_CASTS(RenderTextControlInnerBlock, isTextControlInnerBlock())
 
-}
+} // namespace WebCore
+
+SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderTextControlSingleLine, isTextField())
+SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderTextControlInnerBlock, isTextControlInnerBlock())
 
-#endif
+#endif // RenderTextControlSingleLine_h
index b03d462..6c2af2b 100644 (file)
@@ -76,4 +76,6 @@ RENDER_OBJECT_TYPE_CASTS(RenderTextFragment, isText() && toRenderText(renderer).
 
 } // namespace WebCore
 
+SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderTextFragment, isText() && toRenderText(renderer).isTextFragment())
+
 #endif // RenderTextFragment_h
index 47b5015..54ae3f0 100644 (file)
@@ -94,5 +94,7 @@ RENDER_OBJECT_TYPE_CASTS(RenderVideo, isVideo())
 
 } // namespace WebCore
 
-#endif
+SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderVideo, isVideo())
+
+#endif // ENABLE(VIDEO)
 #endif // RenderVideo_h
index d2ce07d..567c53f 100644 (file)
@@ -456,4 +456,6 @@ private:
 
 } // namespace WebCore
 
+SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderView, isRenderView())
+
 #endif // RenderView_h
index 15781f6..b27ae9a 100644 (file)
@@ -108,4 +108,6 @@ RENDER_OBJECT_TYPE_CASTS(RenderWidget, isWidget())
 
 } // namespace WebCore
 
+SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderWidget, isWidget())
+
 #endif // RenderWidget_h
index f41500e..c94a21d 100644 (file)
@@ -69,8 +69,6 @@ private:
     virtual const char* renderName() const override;
 };
 
-RENDER_OBJECT_TYPE_CASTS(RenderMathMLBlock, isRenderMathMLBlock())
-
 class RenderMathMLTable final : public RenderTable {
 public:
     explicit RenderMathMLTable(Element& element, PassRef<RenderStyle> style)
@@ -85,12 +83,14 @@ private:
     virtual const char* renderName() const override { return "RenderMathMLTable"; }
 };
 
-RENDER_OBJECT_TYPE_CASTS(RenderMathMLTable, isRenderMathMLTable())
-
 // Parsing functions for MathML Length values
 bool parseMathMLLength(const String&, LayoutUnit&, const RenderStyle*, bool allowNegative = true);
 bool parseMathMLNamedSpace(const String&, LayoutUnit&, const RenderStyle*, bool allowNegative = true);
-}
+
+} // namespace WebCore
+
+SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderMathMLBlock, isRenderMathMLBlock())
+SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderMathMLTable, isRenderMathMLTable())
 
 #endif // ENABLE(MATHML)
 #endif // RenderMathMLBlock_h
index 31deff1..a84935a 100644 (file)
@@ -78,7 +78,7 @@ void RenderMathMLFenced::updateFromElement()
         makeFences();
     else {
         // FIXME: The mfenced element fails to update dynamically when its open, close and separators attributes are changed (https://bugs.webkit.org/show_bug.cgi?id=57696).
-        toRenderMathMLOperator(firstChild())->updateTokenContent(m_open);
+        downcast<RenderMathMLOperator>(*firstChild()).updateTokenContent(m_open);
         m_closeFenceRenderer->updateTokenContent(m_close);
     }
 }
index ccec41e..b5ef27f 100644 (file)
@@ -120,11 +120,11 @@ RenderMathMLOperator* RenderMathMLFraction::unembellishedOperator()
 {
     RenderObject* numeratorWrapper = firstChild();
     if (!numeratorWrapper)
-        return 0;
+        return nullptr;
     RenderObject* numerator = numeratorWrapper->firstChildSlow();
-    if (!numerator || !numerator->isRenderMathMLBlock())
-        return 0;
-    return toRenderMathMLBlock(numerator)->unembellishedOperator();
+    if (!is<RenderMathMLBlock>(numerator))
+        return nullptr;
+    return downcast<RenderMathMLBlock>(*numerator).unembellishedOperator();
 }
 
 void RenderMathMLFraction::layout()
index 6922d29..8f2c717 100644 (file)
@@ -58,9 +58,9 @@ private:
     LayoutUnit m_lineThickness;
 };
 
-RENDER_OBJECT_TYPE_CASTS(RenderMathMLFraction, isRenderMathMLFraction())
+} // namespace WebCore
 
-}
+SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderMathMLFraction, isRenderMathMLFraction())
 
 #endif // ENABLE(MATHML)
 
index c209878..5361bf4 100644 (file)
@@ -189,9 +189,9 @@ protected:
     virtual void SetOperatorProperties();
 };
 
-RENDER_OBJECT_TYPE_CASTS(RenderMathMLOperator, isRenderMathMLOperator())
+} // namespace WebCore
 
-}
+SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderMathMLOperator, isRenderMathMLOperator())
 
 #endif // ENABLE(MATHML)
 #endif // RenderMathMLOperator_h
index 40aa9f8..bc3b4be 100644 (file)
@@ -48,9 +48,9 @@ private:
     void SetOperatorProperties() override;
 };
 
-RENDER_OBJECT_TYPE_CASTS(RenderMathMLRadicalOperator, isRenderMathMLRadicalOperator())
+} // namespace WebCore
 
-}
+SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderMathMLRadicalOperator, isRenderMathMLRadicalOperator())
 
 #endif // ENABLE(MATHML)
 #endif // RenderMathMLRadicalOperator_h
index 2756349..2806390 100644 (file)
@@ -35,6 +35,7 @@
 #include "PaintInfo.h"
 #include "RenderIterator.h"
 #include "RenderMathMLRadicalOperator.h"
+#include "RenderMathMLSquareRoot.h"
 
 namespace WebCore {
     
@@ -67,25 +68,25 @@ RenderMathMLRoot::RenderMathMLRoot(Document& document, PassRef<RenderStyle> styl
 RenderMathMLRootWrapper* RenderMathMLRoot::baseWrapper() const
 {
     ASSERT(!isEmpty());
-    return toRenderMathMLRootWrapper(lastChild());
+    return downcast<RenderMathMLRootWrapper>(lastChild());
 }
 
 RenderMathMLBlock* RenderMathMLRoot::radicalWrapper() const
 {
     ASSERT(!isEmpty());
-    return toRenderMathMLBlock(lastChild()->previousSibling());
+    return downcast<RenderMathMLBlock>(lastChild()->previousSibling());
 }
 
 RenderMathMLRootWrapper* RenderMathMLRoot::indexWrapper() const
 {
     ASSERT(!isEmpty());
-    return isRenderMathMLSquareRoot() ? nullptr : toRenderMathMLRootWrapper(firstChild());
+    return is<RenderMathMLSquareRoot>(*this) ? nullptr : downcast<RenderMathMLRootWrapper>(firstChild());
 }
 
 RenderMathMLRadicalOperator* RenderMathMLRoot::radicalOperator() const
 {
     ASSERT(!isEmpty());
-    return toRenderMathMLRadicalOperator(radicalWrapper()->firstChild());
+    return downcast<RenderMathMLRadicalOperator>(radicalWrapper()->firstChild());
 }
 
 void RenderMathMLRoot::restructureWrappers()
@@ -358,7 +359,7 @@ RenderObject* RenderMathMLRootWrapper::removeChild(RenderObject& child)
     RenderObject* next = RenderMathMLBlock::removeChild(child);
 
     if (!(beingDestroyed() || documentBeingDestroyed()))
-        toRenderMathMLRoot(parent())->restructureWrappers();
+        downcast<RenderMathMLRoot>(*parent()).restructureWrappers();
 
     return next;
 }
index fe93dee..af000a7 100644 (file)
@@ -71,8 +71,6 @@ private:
     LayoutUnit m_extraAscender;
     float m_degreeBottomRaisePercent;
 };
-    
-RENDER_OBJECT_TYPE_CASTS(RenderMathMLRoot, isRenderMathMLRoot())
 
 // These are specific wrappers for the index and base, that ask the parent to restructure the renderers after child removal.
 class RenderMathMLRootWrapper : public RenderMathMLRow {
@@ -91,9 +89,10 @@ private:
     virtual const char* renderName() const override { return "RenderMathMLRootWrapper"; }
 };
 
-RENDER_OBJECT_TYPE_CASTS(RenderMathMLRootWrapper, isRenderMathMLRootWrapper())
+} // namespace WebCore
 
-}
+SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderMathMLRoot, isRenderMathMLRoot())
+SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderMathMLRootWrapper, isRenderMathMLRootWrapper())
 
 #endif // ENABLE(MATHML)
 
index 3e83378..cf049ad 100644 (file)
@@ -58,8 +58,8 @@ RenderPtr<RenderMathMLRow> RenderMathMLRow::createAnonymousWithParentRenderer(Re
 void RenderMathMLRow::updateOperatorProperties()
 {
     for (RenderObject* child = firstChild(); child; child = child->nextSibling()) {
-        if (child->isRenderMathMLBlock()) {
-            if (auto renderOperator = toRenderMathMLBlock(child)->unembellishedOperator())
+        if (is<RenderMathMLBlock>(*child)) {
+            if (auto* renderOperator = downcast<RenderMathMLBlock>(*child).unembellishedOperator())
                 renderOperator->updateOperatorProperties();
         }
     }
@@ -71,26 +71,26 @@ void RenderMathMLRow::layout()
     int stretchHeightAboveBaseline = 0, stretchDepthBelowBaseline = 0;
     for (RenderObject* child = firstChild(); child; child = child->nextSibling()) {
         if (child->needsLayout())
-            toRenderElement(child)->layout();
-        if (child->isRenderMathMLBlock()) {
+            downcast<RenderElement>(*child).layout();
+        if (is<RenderMathMLBlock>(*child)) {
             // We skip the stretchy operators as they must not be included in the computation of the stretch size.
-            auto renderOperator = toRenderMathMLBlock(child)->unembellishedOperator();
+            auto* renderOperator = downcast<RenderMathMLBlock>(*child).unembellishedOperator();
             if (renderOperator && renderOperator->hasOperatorFlag(MathMLOperatorDictionary::Stretchy))
                 continue;
         }
         LayoutUnit childHeightAboveBaseline = 0, childDepthBelowBaseline = 0;
-        if (child->isRenderMathMLBlock()) {
-            RenderMathMLBlock* mathmlChild = toRenderMathMLBlock(child);
-            childHeightAboveBaseline = mathmlChild->firstLineBaseline();
+        if (is<RenderMathMLBlock>(*child)) {
+            RenderMathMLBlock& mathmlChild = downcast<RenderMathMLBlock>(*child);
+            childHeightAboveBaseline = mathmlChild.firstLineBaseline();
             if (childHeightAboveBaseline == -1)
-                childHeightAboveBaseline = mathmlChild->logicalHeight();
-            childDepthBelowBaseline = mathmlChild->logicalHeight() - childHeightAboveBaseline;
-        } else if (child->isRenderMathMLTable()) {
-            RenderMathMLTable* tableChild = toRenderMathMLTable(child);
-            childHeightAboveBaseline = tableChild->firstLineBaseline();
-            childDepthBelowBaseline = tableChild->logicalHeight() - childHeightAboveBaseline;
-        } else if (child->isBox()) {
-            childHeightAboveBaseline = toRenderBox(child)->logicalHeight();
+                childHeightAboveBaseline = mathmlChild.logicalHeight();
+            childDepthBelowBaseline = mathmlChild.logicalHeight() - childHeightAboveBaseline;
+        } else if (is<RenderMathMLTable>(*child)) {
+            RenderMathMLTable& tableChild = downcast<RenderMathMLTable>(*child);
+            childHeightAboveBaseline = tableChild.firstLineBaseline();
+            childDepthBelowBaseline = tableChild.logicalHeight() - childHeightAboveBaseline;
+        } else if (is<RenderBox>(*child)) {
+            childHeightAboveBaseline = downcast<RenderBox>(*child).logicalHeight();
             childDepthBelowBaseline = 0;
         }
         stretchHeightAboveBaseline = std::max<LayoutUnit>(stretchHeightAboveBaseline, childHeightAboveBaseline);
index 5732ec1..ba5df88 100644 (file)
@@ -50,9 +50,9 @@ private:
     virtual const char* renderName() const override { return isAnonymous() ? "RenderMathMLRow (anonymous)" : "RenderMathMLRow"; }
 };
 
-RENDER_OBJECT_TYPE_CASTS(RenderMathMLRow, isRenderMathMLRow())
+} // namespace WebCore
 
-}
+SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderMathMLRow, isRenderMathMLRow())
 
 #endif // ENABLE(MATHML)
 #endif // RenderMathMLRow_h
index 0c4cb1b..1c9c4ab 100644 (file)
@@ -153,10 +153,10 @@ void RenderMathMLScripts::addChildInternal(bool doNotRestructure, RenderObject*
         // beforeChild may be a grandchild, so we call the addChild function of the corresponding wrapper instead.
         RenderObject* parent = beforeChild->parent();
         if (parent != this) {
-            RenderMathMLBlock* parentBlock = toRenderMathMLBlock(parent);
-            if (parentBlock->isRenderMathMLScriptsWrapper()) {
-                RenderMathMLScriptsWrapper* wrapper = toRenderMathMLScriptsWrapper(parentBlock);
-                wrapper->addChildInternal(false, child, beforeChild);
+            RenderMathMLBlock& parentBlock = downcast<RenderMathMLBlock>(*parent);
+            if (is<RenderMathMLScriptsWrapper>(parentBlock)) {
+                RenderMathMLScriptsWrapper& wrapper = downcast<RenderMathMLScriptsWrapper>(parentBlock);
+                wrapper.addChildInternal(false, child, beforeChild);
                 return;
             }
         }
@@ -176,12 +176,12 @@ void RenderMathMLScripts::addChildInternal(bool doNotRestructure, RenderObject*
 
     if (!beforeChild || isPrescript(beforeChild)) {
         // We are at the end of a sequence of subSup pairs.
-        RenderMathMLBlock* previousSibling = toRenderMathMLBlock(beforeChild ? beforeChild->previousSibling() : lastChild());
-        if (previousSibling && previousSibling->isRenderMathMLScriptsWrapper()) {
-            RenderMathMLScriptsWrapper* wrapper = toRenderMathMLScriptsWrapper(previousSibling);
-            if ((wrapper->m_kind == RenderMathMLScriptsWrapper::Base && wrapper->isEmpty()) || (wrapper->m_kind == RenderMathMLScriptsWrapper::SubSupPair && !wrapper->firstChild()->nextSibling())) {
+        RenderMathMLBlock* previousSibling = downcast<RenderMathMLBlock>(beforeChild ? beforeChild->previousSibling() : lastChild());
+        if (is<RenderMathMLScriptsWrapper>(previousSibling)) {
+            RenderMathMLScriptsWrapper& wrapper = downcast<RenderMathMLScriptsWrapper>(*previousSibling);
+            if ((wrapper.m_kind == RenderMathMLScriptsWrapper::Base && wrapper.isEmpty()) || (wrapper.m_kind == RenderMathMLScriptsWrapper::SubSupPair && !wrapper.firstChild()->nextSibling())) {
                 // The previous sibling is either an empty base or a SubSup pair with a single child so we can insert the new child into that wrapper.
-                wrapper->addChildInternal(true, child);
+                wrapper.addChildInternal(true, child);
                 return;
             }
         }
@@ -193,10 +193,10 @@ void RenderMathMLScripts::addChildInternal(bool doNotRestructure, RenderObject*
     }
 
     // beforeChild is a subSup pair. This is like inserting the new child at the beginning of the subSup wrapper.
-    RenderMathMLScriptsWrapper* wrapper = toRenderMathMLScriptsWrapper(beforeChild);
-    ASSERT(wrapper->m_kind == RenderMathMLScriptsWrapper::SubSupPair);
+    RenderMathMLScriptsWrapper& wrapper = downcast<RenderMathMLScriptsWrapper>(*beforeChild);
+    ASSERT(wrapper.m_kind == RenderMathMLScriptsWrapper::SubSupPair);
     ASSERT(!(m_baseWrapper->isEmpty() && m_baseWrapper->nextSibling() == beforeChild));
-    wrapper->addChildInternal(false, child, wrapper->firstChild());
+    wrapper.addChildInternal(false, child, wrapper.firstChild());
 }
 
 RenderObject* RenderMathMLScripts::removeChildInternal(bool doNotRestructure, RenderObject& child)
@@ -211,13 +211,13 @@ RenderObject* RenderMathMLScripts::removeChildInternal(bool doNotRestructure, Re
     ASSERT(previousSibling);
 
     if (nextSibling && !isPrescript(previousSibling) && !isPrescript(nextSibling)) {
-        RenderMathMLScriptsWrapper* previousWrapper = toRenderMathMLScriptsWrapper(previousSibling);
-        RenderMathMLScriptsWrapper* nextWrapper = toRenderMathMLScriptsWrapper(nextSibling);
-        ASSERT(nextWrapper->m_kind == RenderMathMLScriptsWrapper::SubSupPair && !nextWrapper->isEmpty());
-        if ((previousWrapper->m_kind == RenderMathMLScriptsWrapper::Base && previousWrapper->isEmpty()) || (previousWrapper->m_kind == RenderMathMLScriptsWrapper::SubSupPair && !previousWrapper->firstChild()->nextSibling())) {
-            RenderObject* script = nextWrapper->firstChild();
-            nextWrapper->removeChildInternal(false, *script);
-            previousWrapper->addChildInternal(true, script);
+        RenderMathMLScriptsWrapper& previousWrapper = downcast<RenderMathMLScriptsWrapper>(*previousSibling);
+        RenderMathMLScriptsWrapper& nextWrapper = downcast<RenderMathMLScriptsWrapper>(*nextSibling);
+        ASSERT(nextWrapper.m_kind == RenderMathMLScriptsWrapper::SubSupPair && !nextWrapper.isEmpty());
+        if ((previousWrapper.m_kind == RenderMathMLScriptsWrapper::Base && previousWrapper.isEmpty()) || (previousWrapper.m_kind == RenderMathMLScriptsWrapper::SubSupPair && !previousWrapper.firstChild()->nextSibling())) {
+            RenderObject* script = nextWrapper.firstChild();
+            nextWrapper.removeChildInternal(false, *script);
+            previousWrapper.addChildInternal(true, script);
         }
     }
 
@@ -261,9 +261,9 @@ void RenderMathMLScripts::styleDidChange(StyleDifference diff, const RenderStyle
 RenderMathMLOperator* RenderMathMLScripts::unembellishedOperator()
 {
     RenderBoxModelObject* base = this->base();
-    if (!base || !base->isRenderMathMLBlock())
-        return 0;
-    return toRenderMathMLBlock(base)->unembellishedOperator();
+    if (!is<RenderMathMLBlock>(base))
+        return nullptr;
+    return downcast<RenderMathMLBlock>(*base).unembellishedOperator();
 }
 
 void RenderMathMLScripts::layout()
@@ -302,8 +302,8 @@ void RenderMathMLScripts::layout()
         parseMathMLLength(scriptElement->fastGetAttribute(MathMLNames::superscriptshiftAttr), superscriptShiftValue, &style(), false);
 
     bool isPostScript = true;
-    RenderMathMLBlock* subSupPair = toRenderMathMLBlock(m_baseWrapper->nextSibling());
-    for (; subSupPair; subSupPair = toRenderMathMLBlock(subSupPair->nextSibling())) {
+    RenderMathMLBlock* subSupPair = downcast<RenderMathMLBlock>(m_baseWrapper->nextSibling());
+    for (; subSupPair; subSupPair = downcast<RenderMathMLBlock>(subSupPair->nextSibling())) {
 
         // We skip the base and <mprescripts/> elements.
         if (isPrescript(subSupPair)) {
@@ -381,7 +381,7 @@ void RenderMathMLScriptsWrapper::addChildInternal(bool doNotRestructure, RenderO
         return;
     }
 
-    RenderMathMLScripts* parentNode = toRenderMathMLScripts(parent());
+    RenderMathMLScripts* parentNode = downcast<RenderMathMLScripts>(parent());
 
     if (m_kind == Base) {
         RenderObject* sibling = nextSibling();
@@ -432,7 +432,7 @@ void RenderMathMLScriptsWrapper::addChildInternal(bool doNotRestructure, RenderO
     // We first move to the last subSup pair in the curent sequence of scripts.
     RenderMathMLScriptsWrapper* subSupPair = this;
     while (subSupPair->nextSibling() && !isPrescript(subSupPair->nextSibling()))
-        subSupPair = toRenderMathMLScriptsWrapper(subSupPair->nextSibling());
+        subSupPair = downcast<RenderMathMLScriptsWrapper>(subSupPair->nextSibling());
     if (subSupPair->firstChild()->nextSibling()) {
         // The last pair has two children so we need to create a new pair to leave room for the new child.
         RenderMathMLScriptsWrapper* newPair = createAnonymousWrapper(parentNode, RenderMathMLScriptsWrapper::SubSupPair);
@@ -442,20 +442,20 @@ void RenderMathMLScriptsWrapper::addChildInternal(bool doNotRestructure, RenderO
 
     // We shift the successors in the current sequence of scripts.
     for (RenderObject* previousSibling = subSupPair->previousSibling(); subSupPair != this; previousSibling = previousSibling->previousSibling()) {
-        RenderMathMLScriptsWrapper* previousSubSupPair = toRenderMathMLScriptsWrapper(previousSibling);
-        RenderObject* script = previousSubSupPair->lastChild();
-        previousSubSupPair->removeChildInternal(true, *script);
+        RenderMathMLScriptsWrapper& previousSubSupPair = downcast<RenderMathMLScriptsWrapper>(*previousSibling);
+        RenderObject* script = previousSubSupPair.lastChild();
+        previousSubSupPair.removeChildInternal(true, *script);
         subSupPair->addChildInternal(true, script, subSupPair->firstChild());
-        subSupPair = toRenderMathMLScriptsWrapper(previousSibling);
+        subSupPair = downcast<RenderMathMLScriptsWrapper>(previousSibling);
     }
 
     // This subSup pair now contain one element which is either beforeChild or the script that was before. Hence we can insert the new child before of after that element.
-    RenderMathMLBlock::addChild(child, firstChild() == beforeChild ? beforeChild : 0);
+    RenderMathMLBlock::addChild(child, firstChild() == beforeChild ? beforeChild : nullptr);
 }
 
 void RenderMathMLScriptsWrapper::addChild(RenderObject* child, RenderObject* beforeChild)
 {
-    RenderMathMLScripts* parentNode = toRenderMathMLScripts(parent());
+    RenderMathMLScripts* parentNode = downcast<RenderMathMLScripts>(parent());
 
     addChildInternal(false, child, beforeChild);
 
@@ -467,7 +467,7 @@ RenderObject* RenderMathMLScriptsWrapper::removeChildInternal(bool doNotRestruct
     if (doNotRestructure)
         return RenderMathMLBlock::removeChild(child);
 
-    RenderMathMLScripts* parentNode = toRenderMathMLScripts(parent());
+    RenderMathMLScripts* parentNode = downcast<RenderMathMLScripts>(parent());
 
     if (m_kind == Base) {
         // We remove the child from the base wrapper.
@@ -475,9 +475,9 @@ RenderObject* RenderMathMLScriptsWrapper::removeChildInternal(bool doNotRestruct
         RenderMathMLBlock::removeChild(child);
         if (sibling && !isPrescript(sibling)) {
             // If there are postscripts, the first one becomes the base.
-            RenderMathMLScriptsWrapper* wrapper = toRenderMathMLScriptsWrapper(sibling);
-            RenderObject* script = wrapper->firstChild();
-            wrapper->removeChildInternal(false, *script);
+            RenderMathMLScriptsWrapper& wrapper = downcast<RenderMathMLScriptsWrapper>(*sibling);
+            RenderObject* script = wrapper.firstChild();
+            wrapper.removeChildInternal(false, *script);
             RenderMathMLBlock::addChild(script);
         }
         return sibling;
@@ -487,11 +487,11 @@ RenderObject* RenderMathMLScriptsWrapper::removeChildInternal(bool doNotRestruct
     RenderObject* next = RenderMathMLBlock::removeChild(child);
     RenderMathMLScriptsWrapper* subSupPair = this;
     for (RenderObject* nextSibling = subSupPair->nextSibling(); nextSibling && !isPrescript(nextSibling); nextSibling = nextSibling->nextSibling()) {
-        RenderMathMLScriptsWrapper* nextSubSupPair = toRenderMathMLScriptsWrapper(nextSibling);
-        RenderObject* script = nextSubSupPair->firstChild();
-        nextSubSupPair->removeChildInternal(true, *script);
+        RenderMathMLScriptsWrapper& nextSubSupPair = downcast<RenderMathMLScriptsWrapper>(*nextSibling);
+        RenderObject* script = nextSubSupPair.firstChild();
+        nextSubSupPair.removeChildInternal(true, *script);
         subSupPair->addChildInternal(true, script);
-        subSupPair = toRenderMathMLScriptsWrapper(nextSibling);
+        subSupPair = downcast<RenderMathMLScriptsWrapper>(nextSibling);
     }
 
     // We remove the last subSup pair if it became empty.
@@ -510,7 +510,7 @@ RenderObject* RenderMathMLScriptsWrapper::removeChild(RenderObject& child)
         return RenderMathMLBlock::removeChild(child);
     }
 
-    RenderMathMLScripts* parentNode = toRenderMathMLScripts(parent());
+    RenderMathMLScripts* parentNode = downcast<RenderMathMLScripts>(parent());
     RenderObject* next = removeChildInternal(false, child);
     parentNode->fixAnonymousStyles();
     return next;
index dc1d6a6..7542678 100644 (file)
@@ -65,8 +65,6 @@ private:
     WrapperType m_kind;
 };
 
-RENDER_OBJECT_TYPE_CASTS(RenderMathMLScriptsWrapper, isRenderMathMLScriptsWrapper())
-
 // Render a base with scripts.
 class RenderMathMLScripts : public RenderMathMLBlock {
 
@@ -105,9 +103,10 @@ private:
     RenderMathMLScriptsWrapper* m_baseWrapper;
 };
 
-RENDER_OBJECT_TYPE_CASTS(RenderMathMLScripts, isRenderMathMLScripts())
+} // namespace WebCore
 
-}
+SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderMathMLScriptsWrapper, isRenderMathMLScriptsWrapper())
+SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderMathMLScripts, isRenderMathMLScripts())
 
 #endif // ENABLE(MATHML)
 
index 138204a..cdfc571 100644 (file)
@@ -54,9 +54,9 @@ private:
     LayoutUnit m_depth;
 };
 
-RENDER_OBJECT_TYPE_CASTS(RenderMathMLSpace, isRenderMathMLSpace())
+} // namespace WebCore
 
-}
+SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderMathMLSpace, isRenderMathMLSpace())
 
 #endif // ENABLE(MATHML)
 #endif // RenderMathMLSpace_h
index a9e3cff..6140058 100644 (file)
@@ -47,7 +47,9 @@ private:
     virtual const char* renderName() const override { return "RenderMathMLSquareRoot"; }
 };
     
-}
+} // namespace WebCore
+
+SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderMathMLSquareRoot, isRenderMathMLSquareRoot())
 
 #endif // ENABLE(MATHML)
 
index 9a71f4f..f5ad5bb 100644 (file)
@@ -59,9 +59,9 @@ private:
     bool m_containsElement;
 };
 
-RENDER_OBJECT_TYPE_CASTS(RenderMathMLToken, isRenderMathMLToken())
+} // namespace WebCore
 
-}
+SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderMathMLToken, isRenderMathMLToken())
 
 #endif // ENABLE(MATHML)
 #endif // RenderMathMLToken_h
index 1032ee1..a26cf13 100644 (file)
@@ -55,9 +55,9 @@ RenderMathMLUnderOver::RenderMathMLUnderOver(Element& element, PassRef<RenderSty
 RenderMathMLOperator* RenderMathMLUnderOver::unembellishedOperator()
 {
     RenderObject* base = firstChild();
-    if (!base || !base->isRenderMathMLBlock())
-        return 0;
-    return toRenderMathMLBlock(base)->unembellishedOperator();
+    if (!is<RenderMathMLBlock>(base))
+        return nullptr;
+    return downcast<RenderMathMLBlock>(*base).unembellishedOperator();
 }
 
 int RenderMathMLUnderOver::firstLineBaseline() const
index ed27b3f..95b0d70 100644 (file)
@@ -84,4 +84,6 @@ RENDER_OBJECT_TYPE_CASTS(RenderSVGContainer, isSVGContainer())
 
 } // namespace WebCore
 
+SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderSVGContainer, isSVGContainer())
+
 #endif // RenderSVGContainer_h
index b8de285..8023645 100644 (file)
@@ -62,6 +62,8 @@ private:
 
 RENDER_OBJECT_TYPE_CASTS(RenderSVGGradientStop, isSVGGradientStop())
 
-}
+} // namespace WebCore
+
+SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderSVGGradientStop, isSVGGradientStop())
 
 #endif // RenderSVGGradientStop_h
index 5832960..18916cb 100644 (file)
@@ -94,4 +94,6 @@ RENDER_OBJECT_TYPE_CASTS(RenderSVGImage, isSVGImage())
 
 } // namespace WebCore
 
+SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderSVGImage, isSVGImage())
+
 #endif // RenderSVGImage_h
index ba0d492..9153aaa 100644 (file)
@@ -71,6 +71,8 @@ private:
 
 RENDER_OBJECT_TYPE_CASTS(RenderSVGInlineText, isSVGInlineText())
 
-}
+} // namespace WebCore
+
+SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderSVGInlineText, isSVGInlineText())
 
 #endif // RenderSVGInlineText_h
index 87f8378..1da6695 100644 (file)
@@ -80,8 +80,10 @@ private:
     bool m_hasSVGShadow;
 };
 
-RENDER_OBJECT_TYPE_CASTS(RenderSVGModelObject, isRenderSVGModelObject());
+RENDER_OBJECT_TYPE_CASTS(RenderSVGModelObject, isRenderSVGModelObject())
 
-}
+} // namespace WebCore
+
+SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderSVGModelObject, isRenderSVGModelObject())
 
 #endif
index 89e9500..887daab 100644 (file)
@@ -57,6 +57,8 @@ private:
 
 RENDER_OBJECT_TYPE_CASTS(RenderSVGPath, isSVGPath())
 
-}
+} // namespace WebCore
 
-#endif
+SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderSVGPath, isSVGPath())
+
+#endif // RenderSVGPath_h
index a3806e6..9f3649a 100644 (file)
@@ -97,6 +97,8 @@ Renderer* getRenderSVGResourceById(Document& document, const AtomicString& id)
     return nullptr;
 }
 
-}
+} // namespace WebCore
+
+SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderSVGResourceContainer, isSVGResourceContainer())
 
-#endif
+#endif // RenderSVGResourceContainer_h
index eeb1498..ceb4678 100644 (file)
@@ -99,6 +99,8 @@ private:
 
 RENDER_OBJECT_TYPE_CASTS(RenderSVGResourceFilter, isSVGResourceFilter())
 
-}
+} // namespace WebCore
 
-#endif
+SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderSVGResourceFilter, isSVGResourceFilter())
+
+#endif // RenderSVGResourceFilter_h
index 3d09b14..5503643 100644 (file)
@@ -126,4 +126,6 @@ RENDER_OBJECT_TYPE_CASTS(RenderSVGRoot, isSVGRoot())
 
 } // namespace WebCore
 
+SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderSVGRoot, isSVGRoot())
+
 #endif // RenderSVGRoot_h
index 5ef48b0..9b3fd7a 100644 (file)
@@ -135,6 +135,8 @@ private:
 
 RENDER_OBJECT_TYPE_CASTS(RenderSVGShape, isSVGShape())
 
-}
+} // namespace WebCore
 
-#endif
+SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderSVGShape, isSVGShape())
+
+#endif // RenderSVGShape_h
index 37d13d6..bc639fe 100644 (file)
@@ -107,6 +107,8 @@ private:
 
 RENDER_OBJECT_TYPE_CASTS(RenderSVGText, isSVGText())
 
-}
+} // namespace WebCore
 
-#endif
+SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderSVGText, isSVGText())
+
+#endif // RenderSVGText_h
index b214442..803280a 100644 (file)
@@ -47,6 +47,8 @@ private:
 
 RENDER_OBJECT_TYPE_CASTS(RenderSVGTextPath, isSVGTextPath())
 
-}
+} // namespace WebCore
+
+SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderSVGTextPath, isSVGTextPath())
 
 #endif // RenderSVGTextPath_h
index b440408..521244b 100644 (file)
@@ -71,4 +71,6 @@ RENDER_OBJECT_TYPE_CASTS(RenderSVGViewportContainer, isSVGViewportContainer())
 
 } // namespace WebCore
 
+SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderSVGViewportContainer, isSVGViewportContainer())
+
 #endif // RenderSVGViewportContainer_h