Automatically generate isRendererOfType in RENDER_OBJECT_TYPE_CASTS
authordarin@apple.com <darin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 10 Feb 2014 17:58:18 +0000 (17:58 +0000)
committerdarin@apple.com <darin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 10 Feb 2014 17:58:18 +0000 (17:58 +0000)
https://bugs.webkit.org/show_bug.cgi?id=128520

Reviewed by Andreas Kling.

* rendering/RenderObject.h: Updated the RENDER_OBJECT_TYPE_CASTS macro so
that it generates isRendererOfType specializations as well as type casts
and also have the type casts use the isRendererOfType function. The macro
also now uses an argument name of "renderer" and allows for a predicate
that is more than just a single function call (see RenderTextFragment.h).

* rendering/RenderBlock.h:
* rendering/RenderBlockFlow.h:
* rendering/RenderBox.h:
* rendering/RenderBoxModelObject.h:
* rendering/RenderCounter.h:
* rendering/RenderElement.h:
* rendering/RenderFrameSet.h:
* rendering/RenderLayerModelObject.h:
* rendering/RenderMenuList.h:
* rendering/RenderNamedFlowThread.h:
* rendering/RenderRubyRun.h:
* rendering/RenderTableSection.h:
* rendering/RenderText.h:
* rendering/mathml/RenderMathMLBlock.h:
* rendering/mathml/RenderMathMLOperator.h:
* rendering/mathml/RenderMathMLToken.h:
* rendering/svg/RenderSVGRoot.h:
* rendering/svg/RenderSVGText.h:
Removed specialization of isRendererOfType, since the RENDER_OBJECT_TYPE_CASTS
macro handles that now. Also removed some unneeded semicolons.

* rendering/RenderTextFragment.h: Use RENDER_OBJECT_TYPE_CASTS instead of
hand written casts, now that it can handle a non-trivial predicate.

* rendering/RenderCombineText.h:
* rendering/RenderDetailsMarker.h:
* rendering/RenderListMarker.h:
* rendering/RenderVideo.h:
* rendering/RenderView.h:
* rendering/mathml/RenderMathMLFraction.h:
* rendering/mathml/RenderMathMLScripts.h:
* rendering/mathml/RenderMathMLSpace.h:
Removed unneeded semicolons.

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

29 files changed:
Source/WebCore/ChangeLog
Source/WebCore/rendering/RenderBlock.h
Source/WebCore/rendering/RenderBlockFlow.h
Source/WebCore/rendering/RenderBox.h
Source/WebCore/rendering/RenderBoxModelObject.h
Source/WebCore/rendering/RenderCombineText.h
Source/WebCore/rendering/RenderCounter.h
Source/WebCore/rendering/RenderDetailsMarker.h
Source/WebCore/rendering/RenderElement.h
Source/WebCore/rendering/RenderFrameSet.h
Source/WebCore/rendering/RenderLayerModelObject.h
Source/WebCore/rendering/RenderListMarker.h
Source/WebCore/rendering/RenderMenuList.h
Source/WebCore/rendering/RenderNamedFlowThread.h
Source/WebCore/rendering/RenderObject.h
Source/WebCore/rendering/RenderRubyRun.h
Source/WebCore/rendering/RenderTableSection.h
Source/WebCore/rendering/RenderText.h
Source/WebCore/rendering/RenderTextFragment.h
Source/WebCore/rendering/RenderVideo.h
Source/WebCore/rendering/RenderView.h
Source/WebCore/rendering/mathml/RenderMathMLBlock.h
Source/WebCore/rendering/mathml/RenderMathMLFraction.h
Source/WebCore/rendering/mathml/RenderMathMLOperator.h
Source/WebCore/rendering/mathml/RenderMathMLScripts.h
Source/WebCore/rendering/mathml/RenderMathMLSpace.h
Source/WebCore/rendering/mathml/RenderMathMLToken.h
Source/WebCore/rendering/svg/RenderSVGRoot.h
Source/WebCore/rendering/svg/RenderSVGText.h

index cf9dd1b..a5c8036 100644 (file)
@@ -1,5 +1,52 @@
 2014-02-10  Darin Adler  <darin@apple.com>
 
+        Automatically generate isRendererOfType in RENDER_OBJECT_TYPE_CASTS
+        https://bugs.webkit.org/show_bug.cgi?id=128520
+
+        Reviewed by Andreas Kling.
+
+        * rendering/RenderObject.h: Updated the RENDER_OBJECT_TYPE_CASTS macro so
+        that it generates isRendererOfType specializations as well as type casts
+        and also have the type casts use the isRendererOfType function. The macro
+        also now uses an argument name of "renderer" and allows for a predicate
+        that is more than just a single function call (see RenderTextFragment.h).
+
+        * rendering/RenderBlock.h:
+        * rendering/RenderBlockFlow.h:
+        * rendering/RenderBox.h:
+        * rendering/RenderBoxModelObject.h:
+        * rendering/RenderCounter.h:
+        * rendering/RenderElement.h:
+        * rendering/RenderFrameSet.h:
+        * rendering/RenderLayerModelObject.h:
+        * rendering/RenderMenuList.h:
+        * rendering/RenderNamedFlowThread.h:
+        * rendering/RenderRubyRun.h:
+        * rendering/RenderTableSection.h:
+        * rendering/RenderText.h:
+        * rendering/mathml/RenderMathMLBlock.h:
+        * rendering/mathml/RenderMathMLOperator.h:
+        * rendering/mathml/RenderMathMLToken.h:
+        * rendering/svg/RenderSVGRoot.h:
+        * rendering/svg/RenderSVGText.h:
+        Removed specialization of isRendererOfType, since the RENDER_OBJECT_TYPE_CASTS
+        macro handles that now. Also removed some unneeded semicolons.
+
+        * rendering/RenderTextFragment.h: Use RENDER_OBJECT_TYPE_CASTS instead of
+        hand written casts, now that it can handle a non-trivial predicate.
+
+        * rendering/RenderCombineText.h:
+        * rendering/RenderDetailsMarker.h:
+        * rendering/RenderListMarker.h:
+        * rendering/RenderVideo.h:
+        * rendering/RenderView.h:
+        * rendering/mathml/RenderMathMLFraction.h:
+        * rendering/mathml/RenderMathMLScripts.h:
+        * rendering/mathml/RenderMathMLSpace.h:
+        Removed unneeded semicolons.
+
+2014-02-10  Darin Adler  <darin@apple.com>
+
         Stop using String::deprecatedCharacters to call WTF::Collator
         https://bugs.webkit.org/show_bug.cgi?id=128517
 
index 84a9ff5..dd12416 100644 (file)
@@ -620,7 +620,6 @@ private:
     static bool s_canPropagateFloatIntoSibling;
 };
 
-template<> inline bool isRendererOfType<const RenderBlock>(const RenderObject& renderer) { return renderer.isRenderBlock(); }
 RENDER_OBJECT_TYPE_CASTS(RenderBlock, isRenderBlock())
 
 LayoutUnit blockDirectionOffset(RenderBlock& rootBlock, const LayoutSize& offsetFromRootBlock);
index 0b66ff4..33b90d3 100644 (file)
@@ -604,7 +604,6 @@ protected:
     friend class LineWidth; // Needs to know FloatingObject
 };
 
-template<> inline bool isRendererOfType<const RenderBlockFlow>(const RenderObject& renderer) { return renderer.isRenderBlockFlow(); }
 RENDER_OBJECT_TYPE_CASTS(RenderBlockFlow, isRenderBlockFlow())
 
 inline bool RenderElement::isRenderNamedFlowFragmentContainer() const
index 6703e96..8a7fda7 100644 (file)
@@ -719,7 +719,6 @@ private:
     static bool s_hadOverflowClip;
 };
 
-template<> inline bool isRendererOfType<const RenderBox>(const RenderObject& renderer) { return renderer.isBox(); }
 RENDER_OBJECT_TYPE_CASTS(RenderBox, isBox())
 
 inline RenderBox* RenderBox::previousSiblingBox() const
index 352434b..9a166cc 100644 (file)
@@ -341,8 +341,6 @@ private:
     void paintMaskForTextFillBox(ImageBuffer*, const IntRect&, InlineFlowBox*, const LayoutRect&, RenderRegion*);
 };
 
-template <> inline bool isRendererOfType<const RenderBoxModelObject>(const RenderObject& renderer) { return renderer.isBoxModelObject(); }
-
 RENDER_OBJECT_TYPE_CASTS(RenderBoxModelObject, isBoxModelObject())
 
 } // namespace WebCore
index 184190f..cbbab16 100644 (file)
@@ -57,7 +57,7 @@ private:
     bool m_needsFontUpdate : 1;
 };
 
-RENDER_OBJECT_TYPE_CASTS(RenderCombineText, isCombineText());
+RENDER_OBJECT_TYPE_CASTS(RenderCombineText, isCombineText())
 
 } // namespace WebCore
 
index b21db05..c77727d 100644 (file)
@@ -62,7 +62,6 @@ private:
     friend class CounterNode;
 };
 
-template<> inline bool isRendererOfType<const RenderCounter>(const RenderObject& renderer) { return renderer.isCounter(); }
 RENDER_OBJECT_TYPE_CASTS(RenderCounter, isCounter())
 
 } // namespace WebCore
index d1c0e14..833f2a6 100644 (file)
@@ -45,7 +45,7 @@ private:
     Path getPath(const LayoutPoint& origin) const;
 };
 
-RENDER_OBJECT_TYPE_CASTS(RenderDetailsMarker, isDetailsMarker());
+RENDER_OBJECT_TYPE_CASTS(RenderDetailsMarker, isDetailsMarker())
 
 }
 
index 31dc734..839f56e 100644 (file)
@@ -216,7 +216,7 @@ private:
     static bool s_noLongerAffectsParentBlock;
 };
 
-template <> inline bool isRendererOfType<const RenderElement>(const RenderObject& renderer) { return renderer.isRenderElement(); }
+RENDER_OBJECT_TYPE_CASTS(RenderElement, isRenderElement())
 
 inline RenderStyle& RenderElement::firstLineStyle() const
 {
@@ -280,8 +280,6 @@ inline bool RenderElement::isRenderInline() const
     return m_baseTypeFlags & RenderInlineFlag;
 }
 
-RENDER_OBJECT_TYPE_CASTS(RenderElement, isRenderElement())
-
 inline Element* RenderElement::generatingElement() const
 {
     if (parent() && isRenderNamedFlowFragment())
index a1838e7..898293a 100644 (file)
@@ -126,7 +126,6 @@ private:
     bool m_isChildResizing;
 };
 
-template<> inline bool isRendererOfType<const RenderFrameSet>(const RenderObject& renderer) { return renderer.isFrameSet(); }
 RENDER_OBJECT_TYPE_CASTS(RenderFrameSet, isFrameSet())
 
 } // namespace WebCore
index ef0c53c..6fb5f39 100644 (file)
@@ -67,8 +67,6 @@ private:
     static bool s_layerWasSelfPainting;
 };
 
-template <> inline bool isRendererOfType<const RenderLayerModelObject>(const RenderObject& renderer) { return renderer.isRenderLayerModelObject(); }
-
 RENDER_OBJECT_TYPE_CASTS(RenderLayerModelObject, isRenderLayerModelObject())
 
 } // namespace WebCore
index 143764a..243da07 100644 (file)
@@ -85,7 +85,7 @@ private:
     RenderListItem& m_listItem;
 };
 
-RENDER_OBJECT_TYPE_CASTS(RenderListMarker, isListMarker());
+RENDER_OBJECT_TYPE_CASTS(RenderListMarker, isListMarker())
 
 } // namespace WebCore
 
index efcbb4d..a67f0cf 100644 (file)
@@ -152,7 +152,6 @@ private:
 #endif
 };
 
-template<> inline bool isRendererOfType<const RenderMenuList>(const RenderObject& renderer) { return renderer.isMenuList(); }
 RENDER_OBJECT_TYPE_CASTS(RenderMenuList, isMenuList())
 
 }
index 84110dc..b2d91ce 100644 (file)
@@ -145,7 +145,6 @@ private:
     Timer<RenderNamedFlowThread> m_regionOversetChangeEventTimer;
 };
 
-template<> inline bool isRendererOfType<const RenderNamedFlowThread>(const RenderObject& renderer) { return renderer.isRenderNamedFlowThread(); }
 RENDER_OBJECT_TYPE_CASTS(RenderNamedFlowThread, isRenderNamedFlowThread())
 
 } // namespace WebCore
index 808d2fa..2624715 100644 (file)
@@ -1130,7 +1130,8 @@ inline bool RenderObject::backgroundIsKnownToBeObscured()
 }
 
 #define RENDER_OBJECT_TYPE_CASTS(ToValueTypeName, predicate) \
-    TYPE_CASTS_BASE(ToValueTypeName, RenderObject, object, object->predicate, object.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))
 
 } // namespace WebCore
 
index 1fe2082..ce87fdb 100644 (file)
@@ -77,8 +77,6 @@ private:
     virtual void removeLeftoverAnonymousBlock(RenderBlock*) { }
 };
 
-template<> inline bool isRendererOfType<const RenderRubyRun>(const RenderObject& renderer) { return renderer.isRubyRun(); }
-
 RENDER_OBJECT_TYPE_CASTS(RenderRubyRun, isRubyRun())
 
 } // namespace WebCore
index 5ad1187..f544cff 100644 (file)
@@ -309,7 +309,6 @@ private:
     HashMap<std::pair<const RenderTableCell*, int>, CollapsedBorderValue > m_cellsCollapsedBorders;
 };
 
-template<> inline bool isRendererOfType<const RenderTableSection>(const RenderObject& renderer) { return renderer.isTableSection(); }
 RENDER_OBJECT_TYPE_CASTS(RenderTableSection, isTableSection())
 
 } // namespace WebCore
index 7aa80da..e01c9ca 100644 (file)
@@ -218,6 +218,8 @@ private:
     RenderTextLineBoxes m_lineBoxes;
 };
 
+RENDER_OBJECT_TYPE_CASTS(RenderText, isText())
+
 inline UChar RenderText::uncheckedCharacterAt(unsigned i) const
 {
     ASSERT_WITH_SECURITY_IMPLICATION(i < textLength());
@@ -232,9 +234,6 @@ inline UChar RenderText::characterAt(unsigned i) const
     return uncheckedCharacterAt(i);
 }
 
-template <> inline bool isRendererOfType<const RenderText>(const RenderObject& renderer) { return renderer.isText(); }
-RENDER_OBJECT_TYPE_CASTS(RenderText, isText())
-
 inline RenderStyle& RenderText::style() const
 {
     return parent()->style();
index 1c70a05..d997412 100644 (file)
@@ -71,20 +71,7 @@ private:
     RenderBoxModelObject* m_firstLetter;
 };
 
-inline RenderTextFragment* toRenderTextFragment(RenderObject* object)
-{ 
-    ASSERT_WITH_SECURITY_IMPLICATION(!object || toRenderText(object)->isTextFragment());
-    return static_cast<RenderTextFragment*>(object);
-}
-
-inline const RenderTextFragment* toRenderTextFragment(const RenderObject* object)
-{ 
-    ASSERT_WITH_SECURITY_IMPLICATION(!object || toRenderText(object)->isTextFragment());
-    return static_cast<const RenderTextFragment*>(object);
-}
-
-// This will catch anyone doing an unnecessary cast.
-void toRenderTextFragment(const RenderTextFragment*);
+RENDER_OBJECT_TYPE_CASTS(RenderTextFragment, isText() && toRenderText(renderer).isTextFragment())
 
 } // namespace WebCore
 
index 4160a65..0f9db17 100644 (file)
@@ -90,7 +90,7 @@ private:
     LayoutSize m_cachedImageSize;
 };
 
-RENDER_OBJECT_TYPE_CASTS(RenderVideo, isVideo());
+RENDER_OBJECT_TYPE_CASTS(RenderVideo, isVideo())
 
 } // namespace WebCore
 
index 6435b2f..6941fb1 100644 (file)
@@ -342,7 +342,7 @@ private:
 #endif
 };
 
-RENDER_OBJECT_TYPE_CASTS(RenderView, isRenderView());
+RENDER_OBJECT_TYPE_CASTS(RenderView, isRenderView())
 
 // Stack-based class to assist with LayoutState push/pop
 class LayoutStateMaintainer {
index b1b44c9..0115b0e 100644 (file)
@@ -74,7 +74,6 @@ private:
     bool m_ignoreInAccessibilityTree;
 };
 
-template<> inline bool isRendererOfType<const RenderMathMLBlock>(const RenderObject& renderer) { return renderer.isRenderMathMLBlock(); }
 RENDER_OBJECT_TYPE_CASTS(RenderMathMLBlock, isRenderMathMLBlock())
 
 class RenderMathMLTable final : public RenderTable {
index 9c21d9c..6922d29 100644 (file)
@@ -58,7 +58,7 @@ private:
     LayoutUnit m_lineThickness;
 };
 
-RENDER_OBJECT_TYPE_CASTS(RenderMathMLFraction, isRenderMathMLFraction());
+RENDER_OBJECT_TYPE_CASTS(RenderMathMLFraction, isRenderMathMLFraction())
 
 }
 
index 5052771..99d374b 100644 (file)
@@ -97,9 +97,7 @@ private:
     StretchyCharacter* m_stretchyCharacter;
 };
 
-RENDER_OBJECT_TYPE_CASTS(RenderMathMLOperator, isRenderMathMLOperator());
-
-template<> inline bool isRendererOfType<const RenderMathMLOperator>(const RenderObject& renderer) { return renderer.isRenderMathMLOperator(); }
+RENDER_OBJECT_TYPE_CASTS(RenderMathMLOperator, isRenderMathMLOperator())
 
 inline UChar convertHyphenMinusToMinusSign(UChar glyph)
 {
index e3225b8..09497db 100644 (file)
@@ -65,7 +65,7 @@ private:
     WrapperType m_kind;
 };
 
-RENDER_OBJECT_TYPE_CASTS(RenderMathMLScriptsWrapper, isRenderMathMLScriptsWrapper());
+RENDER_OBJECT_TYPE_CASTS(RenderMathMLScriptsWrapper, isRenderMathMLScriptsWrapper())
 
 // Render a base with scripts.
 class RenderMathMLScripts : public RenderMathMLBlock {
@@ -105,7 +105,7 @@ private:
     RenderMathMLScriptsWrapper* m_baseWrapper;
 };
 
-RENDER_OBJECT_TYPE_CASTS(RenderMathMLScripts, isRenderMathMLScripts());
+RENDER_OBJECT_TYPE_CASTS(RenderMathMLScripts, isRenderMathMLScripts())
 
 }
 
index 48a4e2f..138204a 100644 (file)
@@ -54,7 +54,7 @@ private:
     LayoutUnit m_depth;
 };
 
-RENDER_OBJECT_TYPE_CASTS(RenderMathMLSpace, isRenderMathMLSpace());
+RENDER_OBJECT_TYPE_CASTS(RenderMathMLSpace, isRenderMathMLSpace())
 
 }
 
index e2f37e9..29fb171 100644 (file)
@@ -56,7 +56,6 @@ private:
     virtual void updateStyle();
 };
 
-template<> inline bool isRendererOfType<const RenderMathMLToken>(const RenderObject& renderer) { return renderer.isRenderMathMLToken(); }
 RENDER_OBJECT_TYPE_CASTS(RenderMathMLToken, isRenderMathMLToken())
 
 }
index 03341d9..285c882 100644 (file)
@@ -121,7 +121,6 @@ private:
     bool m_hasSVGShadow : 1;
 };
 
-template<> inline bool isRendererOfType<const RenderSVGRoot>(const RenderObject& renderer) { return renderer.isSVGRoot(); }
 RENDER_OBJECT_TYPE_CASTS(RenderSVGRoot, isSVGRoot())
 
 } // namespace WebCore
index f5b293a..fd33b57 100644 (file)
@@ -105,7 +105,6 @@ private:
     Vector<SVGTextLayoutAttributes*> m_layoutAttributes;
 };
 
-template<> inline bool isRendererOfType<const RenderSVGText>(const RenderObject& renderer) { return renderer.isSVGText(); }
 RENDER_OBJECT_TYPE_CASTS(RenderSVGText, isSVGText())
 
 }