Use TYPE_CASTS_BASE for CSS_VALUE_TYPE_CASTS
authorgyuyoung.kim@samsung.com <gyuyoung.kim@samsung.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 22 Oct 2013 01:25:20 +0000 (01:25 +0000)
committergyuyoung.kim@samsung.com <gyuyoung.kim@samsung.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 22 Oct 2013 01:25:20 +0000 (01:25 +0000)
https://bugs.webkit.org/show_bug.cgi?id=123126

Reviewed by Andreas Kling.

TYPE_CASTS_BASE was moved to common place to be used by all toFoo().
CSS_VALUE_TYPE_CASTS starts to use it for CSS child value. This change
generates plenty more helper functions for toCSSFooValue().

Additionally, this use support that toWebKitCSSFooValue, which couldn't
use CSS_VALUE_TYPE_CASTS macro.

No new tests, no behavior change.

* css/CSSAspectRatioValue.h:
* css/CSSBorderImageSliceValue.h:
* css/CSSCalculationValue.h:
* css/CSSCanvasValue.h:
* css/CSSCrossfadeValue.h:
* css/CSSCursorImageValue.h:
* css/CSSFilterImageValue.h:
* css/CSSFontFaceSrcValue.h:
* css/CSSFontFeatureValue.h:
* css/CSSFontValue.h:
* css/CSSFunctionValue.h:
* css/CSSGradientValue.h:
* css/CSSGridTemplateValue.h:
* css/CSSImageSetValue.h:
* css/CSSImageValue.h:
* css/CSSInheritedValue.h:
* css/CSSInitialValue.h:
* css/CSSLineBoxContainValue.h:
* css/CSSPrimitiveValue.h:
* css/CSSReflectValue.h:
* css/CSSShadowValue.h:
* css/CSSTimingFunctionValue.h:
* css/CSSUnicodeRangeValue.h:
* css/CSSValue.h:
* css/CSSValueList.h:
* css/CSSVariableValue.h:
* css/WebKitCSSArrayFunctionValue.h:
* css/WebKitCSSFilterValue.h:
* css/WebKitCSSMatFunctionValue.h:
* css/WebKitCSSMixFunctionValue.h:
* css/WebKitCSSSVGDocumentValue.h:
* css/WebKitCSSShaderValue.h:

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

33 files changed:
Source/WebCore/ChangeLog
Source/WebCore/css/CSSAspectRatioValue.h
Source/WebCore/css/CSSBorderImageSliceValue.h
Source/WebCore/css/CSSCalculationValue.h
Source/WebCore/css/CSSCanvasValue.h
Source/WebCore/css/CSSCrossfadeValue.h
Source/WebCore/css/CSSCursorImageValue.h
Source/WebCore/css/CSSFilterImageValue.h
Source/WebCore/css/CSSFontFaceSrcValue.h
Source/WebCore/css/CSSFontFeatureValue.h
Source/WebCore/css/CSSFontValue.h
Source/WebCore/css/CSSFunctionValue.h
Source/WebCore/css/CSSGradientValue.h
Source/WebCore/css/CSSGridTemplateValue.h
Source/WebCore/css/CSSImageSetValue.h
Source/WebCore/css/CSSImageValue.h
Source/WebCore/css/CSSInheritedValue.h
Source/WebCore/css/CSSInitialValue.h
Source/WebCore/css/CSSLineBoxContainValue.h
Source/WebCore/css/CSSPrimitiveValue.h
Source/WebCore/css/CSSReflectValue.h
Source/WebCore/css/CSSShadowValue.h
Source/WebCore/css/CSSTimingFunctionValue.h
Source/WebCore/css/CSSUnicodeRangeValue.h
Source/WebCore/css/CSSValue.h
Source/WebCore/css/CSSValueList.h
Source/WebCore/css/CSSVariableValue.h
Source/WebCore/css/WebKitCSSArrayFunctionValue.h
Source/WebCore/css/WebKitCSSFilterValue.h
Source/WebCore/css/WebKitCSSMatFunctionValue.h
Source/WebCore/css/WebKitCSSMixFunctionValue.h
Source/WebCore/css/WebKitCSSSVGDocumentValue.h
Source/WebCore/css/WebKitCSSShaderValue.h

index da12767..028520e 100644 (file)
@@ -1,3 +1,52 @@
+2013-10-21  Gyuyoung Kim  <gyuyoung.kim@samsung.com>
+
+        Use TYPE_CASTS_BASE for CSS_VALUE_TYPE_CASTS
+        https://bugs.webkit.org/show_bug.cgi?id=123126
+
+        Reviewed by Andreas Kling.
+
+        TYPE_CASTS_BASE was moved to common place to be used by all toFoo().
+        CSS_VALUE_TYPE_CASTS starts to use it for CSS child value. This change
+        generates plenty more helper functions for toCSSFooValue().
+
+        Additionally, this use support that toWebKitCSSFooValue, which couldn't
+        use CSS_VALUE_TYPE_CASTS macro.
+
+        No new tests, no behavior change.
+
+        * css/CSSAspectRatioValue.h:
+        * css/CSSBorderImageSliceValue.h:
+        * css/CSSCalculationValue.h:
+        * css/CSSCanvasValue.h:
+        * css/CSSCrossfadeValue.h:
+        * css/CSSCursorImageValue.h:
+        * css/CSSFilterImageValue.h:
+        * css/CSSFontFaceSrcValue.h:
+        * css/CSSFontFeatureValue.h:
+        * css/CSSFontValue.h:
+        * css/CSSFunctionValue.h:
+        * css/CSSGradientValue.h:
+        * css/CSSGridTemplateValue.h:
+        * css/CSSImageSetValue.h:
+        * css/CSSImageValue.h:
+        * css/CSSInheritedValue.h:
+        * css/CSSInitialValue.h:
+        * css/CSSLineBoxContainValue.h:
+        * css/CSSPrimitiveValue.h:
+        * css/CSSReflectValue.h:
+        * css/CSSShadowValue.h:
+        * css/CSSTimingFunctionValue.h:
+        * css/CSSUnicodeRangeValue.h:
+        * css/CSSValue.h:
+        * css/CSSValueList.h:
+        * css/CSSVariableValue.h:
+        * css/WebKitCSSArrayFunctionValue.h:
+        * css/WebKitCSSFilterValue.h:
+        * css/WebKitCSSMatFunctionValue.h:
+        * css/WebKitCSSMixFunctionValue.h:
+        * css/WebKitCSSSVGDocumentValue.h:
+        * css/WebKitCSSShaderValue.h:
+
 2013-10-21  Joone Hur  <joone.hur@intel.com>
 
         Bad cast with toRenderBoxModelObject in RenderBlock::updateFirstLetter()
index d8a39af..a2781f6 100644 (file)
@@ -60,7 +60,7 @@ private:
     float m_denominatorValue;
 };
 
-CSS_VALUE_TYPE_CASTS(AspectRatioValue)
+CSS_VALUE_TYPE_CASTS(CSSAspectRatioValue, isAspectRatioValue())
 
 }
 
index 4b8a34b..ab7700b 100644 (file)
@@ -56,7 +56,7 @@ private:
     CSSBorderImageSliceValue(PassRefPtr<CSSPrimitiveValue> slices, bool fill);
 };
 
-CSS_VALUE_TYPE_CASTS(BorderImageSliceValue)
+CSS_VALUE_TYPE_CASTS(CSSBorderImageSliceValue, isBorderImageSliceValue())
 
 } // namespace WebCore
 
index 1009b5f..0858056 100644 (file)
@@ -145,7 +145,7 @@ private:
     const bool m_nonNegative;
 };
 
-CSS_VALUE_TYPE_CASTS(CalcValue)
+CSS_VALUE_TYPE_CASTS(CSSCalcValue, isCalcValue())
 
 } // namespace WebCore
 
index 97d5c34..d301817 100644 (file)
@@ -94,7 +94,7 @@ private:
     HTMLCanvasElement* m_element;
 };
 
-CSS_VALUE_TYPE_CASTS(CanvasValue)
+CSS_VALUE_TYPE_CASTS(CSSCanvasValue, isCanvasValue())
 
 } // namespace WebCore
 
index 4cf5c8a..3b0571a 100644 (file)
@@ -110,7 +110,7 @@ private:
     CrossfadeSubimageObserverProxy m_crossfadeSubimageObserver;
 };
 
-CSS_VALUE_TYPE_CASTS(CrossfadeValue)
+CSS_VALUE_TYPE_CASTS(CSSCrossfadeValue, isCrossfadeValue())
 
 } // namespace WebCore
 
index 9fb04f1..84e6af4 100644 (file)
@@ -82,7 +82,7 @@ private:
 #endif
 };
 
-CSS_VALUE_TYPE_CASTS(CursorImageValue)
+CSS_VALUE_TYPE_CASTS(CSSCursorImageValue, isCursorImageValue())
 
 } // namespace WebCore
 
index 22e083b..f6cc37f 100644 (file)
@@ -119,7 +119,7 @@ private:
     FilterSubimageObserverProxy m_filterSubimageObserver;
 };
 
-CSS_VALUE_TYPE_CASTS(FilterImageValue)
+CSS_VALUE_TYPE_CASTS(CSSFilterImageValue, isFilterImageValue())
 
 } // namespace WebCore
 
index 8733928..148a3d4 100644 (file)
@@ -95,7 +95,7 @@ private:
 #endif
 };
 
-CSS_VALUE_TYPE_CASTS(FontFaceSrcValue)
+CSS_VALUE_TYPE_CASTS(CSSFontFaceSrcValue, isFontFaceSrcValue())
 
 }
 
index 26127ec..496152e 100644 (file)
@@ -51,7 +51,7 @@ private:
     const int m_value;
 };
 
-CSS_VALUE_TYPE_CASTS(FontFeatureValue)
+CSS_VALUE_TYPE_CASTS(CSSFontFeatureValue, isFontFeatureValue())
 
 } // namespace
 
index 5272bdc..8a29af0 100644 (file)
@@ -55,7 +55,7 @@ private:
     }
 };
 
-CSS_VALUE_TYPE_CASTS(FontValue)
+CSS_VALUE_TYPE_CASTS(CSSFontValue, isFontValue())
 
 } // namespace
 
index da5a610..0d49351 100644 (file)
@@ -57,7 +57,7 @@ private:
     RefPtr<CSSValueList> m_args;
 };
 
-CSS_VALUE_TYPE_CASTS(FunctionValue)
+CSS_VALUE_TYPE_CASTS(CSSFunctionValue, isFunctionValue())
 
 }
 #endif
index 7e8a430..43e1b4d 100644 (file)
@@ -130,7 +130,7 @@ protected:
     bool m_repeating;
 };
 
-CSS_VALUE_TYPE_CASTS(GradientValue)
+CSS_VALUE_TYPE_CASTS(CSSGradientValue, isGradientValue())
 
 class CSSLinearGradientValue : public CSSGradientValue {
 public:
@@ -169,7 +169,7 @@ private:
     RefPtr<CSSPrimitiveValue> m_angle; // may be null.
 };
 
-CSS_VALUE_TYPE_CASTS(LinearGradientValue)
+CSS_VALUE_TYPE_CASTS(CSSLinearGradientValue, isLinearGradientValue())
 
 class CSSRadialGradientValue : public CSSGradientValue {
 public:
@@ -232,7 +232,7 @@ private:
     RefPtr<CSSPrimitiveValue> m_endVerticalSize;
 };
 
-CSS_VALUE_TYPE_CASTS(RadialGradientValue)
+CSS_VALUE_TYPE_CASTS(CSSRadialGradientValue, isRadialGradientValue())
 
 } // namespace WebCore
 
index 6f4e70c..e68c202 100644 (file)
@@ -56,7 +56,7 @@ private:
     size_t m_columnCount;
 };
 
-CSS_VALUE_TYPE_CASTS(GridTemplateValue)
+CSS_VALUE_TYPE_CASTS(CSSGridTemplateValue, isGridTemplateValue())
 
 } // namespace WebCore
 
index 21c6590..f783d77 100644 (file)
@@ -84,7 +84,7 @@ private:
     Vector<ImageWithScale> m_imagesInSet;
 };
 
-CSS_VALUE_TYPE_CASTS(ImageSetValue)
+CSS_VALUE_TYPE_CASTS(CSSImageSetValue, isImageSetValue())
 
 } // namespace WebCore
 
index 5db2043..11e691a 100644 (file)
@@ -68,7 +68,7 @@ private:
     AtomicString m_initiatorName;
 };
 
-CSS_VALUE_TYPE_CASTS(ImageValue)
+CSS_VALUE_TYPE_CASTS(CSSImageValue, isImageValue())
 
 } // namespace WebCore
 
index aaf6151..c2c601e 100644 (file)
@@ -44,7 +44,7 @@ private:
     }
 };
 
-CSS_VALUE_TYPE_CASTS(InheritedValue)
+CSS_VALUE_TYPE_CASTS(CSSInheritedValue, isInheritedValue())
 
 } // namespace WebCore
 
index 035ea55..43e2c16 100644 (file)
@@ -53,7 +53,7 @@ private:
     bool m_isImplicit;
 };
 
-CSS_VALUE_TYPE_CASTS(InitialValue)
+CSS_VALUE_TYPE_CASTS(CSSInitialValue, isInitialValue())
 
 } // namespace WebCore
 
index 13e88d8..b93af0f 100644 (file)
@@ -57,7 +57,7 @@ private:
     CSSLineBoxContainValue(LineBoxContain);
 };
 
-CSS_VALUE_TYPE_CASTS(LineBoxContainValue)
+CSS_VALUE_TYPE_CASTS(CSSLineBoxContainValue, isLineBoxContainValue())
 
 } // namespace
 
index 800d3bc..875a42e 100644 (file)
@@ -403,8 +403,7 @@ private:
     } m_value;
 };
 
-CSS_VALUE_TYPE_CASTS(PrimitiveValue)
-
+CSS_VALUE_TYPE_CASTS(CSSPrimitiveValue, isPrimitiveValue())
 
 } // namespace WebCore
 
index 81fbe9f..ee3187e 100644 (file)
@@ -70,7 +70,7 @@ private:
     RefPtr<CSSValue> m_mask;
 };
 
-CSS_VALUE_TYPE_CASTS(ReflectValue)
+CSS_VALUE_TYPE_CASTS(CSSReflectValue, isReflectValue())
 
 } // namespace WebCore
 
index 38eb8e0..6c3f362 100644 (file)
@@ -62,7 +62,7 @@ private:
         PassRefPtr<CSSPrimitiveValue> color);
 };
 
-CSS_VALUE_TYPE_CASTS(ShadowValue)
+CSS_VALUE_TYPE_CASTS(CSSShadowValue, isShadowValue())
 
 } // namespace
 
index ef5263d..eb630be 100644 (file)
@@ -63,7 +63,7 @@ private:
     double m_y2;
 };
 
-CSS_VALUE_TYPE_CASTS(CubicBezierTimingFunctionValue)
+CSS_VALUE_TYPE_CASTS(CSSCubicBezierTimingFunctionValue, isCubicBezierTimingFunctionValue())
 
 class CSSStepsTimingFunctionValue : public CSSValue {
 public:
@@ -91,7 +91,7 @@ private:
     bool m_stepAtStart;
 };
 
-CSS_VALUE_TYPE_CASTS(StepsTimingFunctionValue)
+CSS_VALUE_TYPE_CASTS(CSSStepsTimingFunctionValue, isStepsTimingFunctionValue())
 
 } // namespace
 
index 8623bb7..856f976 100644 (file)
@@ -58,7 +58,7 @@ private:
     UChar32 m_to;
 };
 
-CSS_VALUE_TYPE_CASTS(UnicodeRangeValue)
+CSS_VALUE_TYPE_CASTS(CSSUnicodeRangeValue, isUnicodeRangeValue())
 
 } // namespace WebCore
 
index 968f195..88af52e 100644 (file)
@@ -272,19 +272,8 @@ inline bool compareCSSValuePtr(const RefPtr<CSSValueType>& first, const RefPtr<C
     return first ? second && first->equals(*second) : !second;
 }
 
-#define CSS_VALUE_TYPE_CASTS(ValueTypeName) \
-inline const CSS##ValueTypeName* toCSS##ValueTypeName(const CSSValue* value) \
-{ \
-    ASSERT_WITH_SECURITY_IMPLICATION(!value || value->is##ValueTypeName()); \
-    return static_cast<const CSS##ValueTypeName*>(value); \
-} \
-inline CSS##ValueTypeName* toCSS##ValueTypeName(CSSValue* value) \
-{ \
-    ASSERT_WITH_SECURITY_IMPLICATION(!value || value->is##ValueTypeName()); \
-    return static_cast<CSS##ValueTypeName*>(value); \
-} \
-void toCSS##ValueTypeName(const CSS##ValueTypeName*); \
-void toCSS##ValueTypeName(const CSS##ValueTypeName&);
+#define CSS_VALUE_TYPE_CASTS(ToValueTypeName, predicate) \
+    TYPE_CASTS_BASE(ToValueTypeName, CSSValue, value, value->predicate, value.predicate)
 
 } // namespace WebCore
 
index 3fa41a5..74ac29e 100644 (file)
@@ -83,7 +83,7 @@ private:
     Vector<RefPtr<CSSValue>, 4> m_values;
 };
 
-CSS_VALUE_TYPE_CASTS(ValueList)
+CSS_VALUE_TYPE_CASTS(CSSValueList, isValueList())
 
 // Objects of this class are intended to be stack-allocated and scoped to a single function.
 // Please take care not to pass these around as they do hold onto a raw pointer.
index e94103a..81ac6d9 100644 (file)
@@ -61,7 +61,7 @@ private:
     const String m_value;
 };
 
-CSS_VALUE_TYPE_CASTS(VariableValue)
+CSS_VALUE_TYPE_CASTS(CSSVariableValue, isVariableValue())
 
 }
 
index d40d76e..a52869c 100644 (file)
@@ -55,17 +55,7 @@ private:
     WebKitCSSArrayFunctionValue(const WebKitCSSArrayFunctionValue& cloneFrom);
 };
 
-inline WebKitCSSArrayFunctionValue* toWebKitCSSArrayFunctionValue(CSSValue* value)
-{
-    ASSERT_WITH_SECURITY_IMPLICATION(!value || value->isWebKitCSSArrayFunctionValue());
-    return static_cast<WebKitCSSArrayFunctionValue*>(value);
-}
-
-inline const WebKitCSSArrayFunctionValue* toWebKitCSSArrayFunctionValue(const CSSValue* value)
-{
-    ASSERT_WITH_SECURITY_IMPLICATION(!value || value->isWebKitCSSArrayFunctionValue());
-    return static_cast<const WebKitCSSArrayFunctionValue*>(value);
-}
+CSS_VALUE_TYPE_CASTS(WebKitCSSArrayFunctionValue, isWebKitCSSArrayFunctionValue())
 
 } // namespace WebCore
 
index e0a5b5e..32ead5b 100644 (file)
@@ -77,17 +77,7 @@ private:
     FilterOperationType m_type;
 };
 
-inline WebKitCSSFilterValue* toWebKitCSSFilterValue(CSSValue* value)
-{
-    ASSERT_WITH_SECURITY_IMPLICATION(!value || value->isWebKitCSSFilterValue());
-    return static_cast<WebKitCSSFilterValue*>(value);
-}
-
-inline const WebKitCSSFilterValue* toWebKitCSSFilterValue(const CSSValue* value)
-{
-    ASSERT_WITH_SECURITY_IMPLICATION(!value || value->isWebKitCSSFilterValue());
-    return static_cast<const WebKitCSSFilterValue*>(value);
-}
+CSS_VALUE_TYPE_CASTS(WebKitCSSFilterValue, isWebKitCSSFilterValue())
 
 }
 
index ef34d7a..6899d38 100644 (file)
@@ -55,17 +55,7 @@ private:
     WebKitCSSMatFunctionValue(const WebKitCSSMatFunctionValue& cloneFrom);
 };
 
-inline WebKitCSSMatFunctionValue* toWebKitCSSMatFunctionValue(CSSValue* value)
-{
-    ASSERT_WITH_SECURITY_IMPLICATION(!value || value->isWebKitCSSMatFunctionValue());
-    return static_cast<WebKitCSSMatFunctionValue*>(value);
-}
-
-inline const WebKitCSSMatFunctionValue* toWebKitCSSMatFunctionValue(const CSSValue* value)
-{
-    ASSERT_WITH_SECURITY_IMPLICATION(!value || value->isWebKitCSSMatFunctionValue());
-    return static_cast<const WebKitCSSMatFunctionValue*>(value);
-}
+CSS_VALUE_TYPE_CASTS(WebKitCSSMatFunctionValue, isWebKitCSSMatFunctionValue())
 
 } // namespace WebCore
 
index 5b70fde..215e026 100644 (file)
@@ -55,17 +55,7 @@ private:
     WebKitCSSMixFunctionValue(const WebKitCSSMixFunctionValue& cloneFrom);
 };
 
-inline WebKitCSSMixFunctionValue* toWebKitCSSMixFunctionValue(CSSValue* value)
-{
-    ASSERT_WITH_SECURITY_IMPLICATION(!value || value->isWebKitCSSMixFunctionValue());
-    return static_cast<WebKitCSSMixFunctionValue*>(value);
-}
-
-inline const WebKitCSSMixFunctionValue* toWebKitCSSMixFunctionValue(const CSSValue* value)
-{
-    ASSERT_WITH_SECURITY_IMPLICATION(!value || value->isWebKitCSSMixFunctionValue());
-    return static_cast<const WebKitCSSMixFunctionValue*>(value);
-}
+CSS_VALUE_TYPE_CASTS(WebKitCSSMixFunctionValue, isWebKitCSSMixFunctionValue())
 
 } // namespace WebCore
 
index 2185007..5909809 100644 (file)
@@ -54,17 +54,7 @@ private:
     bool m_loadRequested;
 };
 
-inline WebKitCSSSVGDocumentValue* toWebKitCSSSVGDocumentValue(CSSValue* value)
-{
-    ASSERT_WITH_SECURITY_IMPLICATION(!value || value->isWebKitCSSSVGDocumentValue());
-    return static_cast<WebKitCSSSVGDocumentValue*>(value);
-}
-
-inline const WebKitCSSSVGDocumentValue* toWebKitCSSSVGDocumentValue(const CSSValue* value)
-{
-    ASSERT_WITH_SECURITY_IMPLICATION(!value || value->isWebKitCSSSVGDocumentValue());
-    return static_cast<const WebKitCSSSVGDocumentValue*>(value);
-}
+CSS_VALUE_TYPE_CASTS(WebKitCSSSVGDocumentValue, isWebKitCSSSVGDocumentValue())
 
 } // namespace WebCore
 
index 59962a9..4c36ad8 100644 (file)
@@ -66,20 +66,7 @@ private:
     bool m_accessedShader;
 };
 
-// This will catch anyone doing an unnecessary cast.
-WebKitCSSShaderValue* toWebKitCSSShaderValue(const WebKitCSSShaderValue*);
-
-inline WebKitCSSShaderValue* toWebKitCSSShaderValue(CSSValue* value)
-{
-    ASSERT_WITH_SECURITY_IMPLICATION(!value || value->isWebKitCSSShaderValue());
-    return static_cast<WebKitCSSShaderValue*>(value);
-}
-
-inline const WebKitCSSShaderValue* toWebKitCSSShaderValue(const CSSValue* value)
-{
-    ASSERT_WITH_SECURITY_IMPLICATION(!value || value->isWebKitCSSShaderValue());
-    return static_cast<const WebKitCSSShaderValue*>(value);
-}
+CSS_VALUE_TYPE_CASTS(WebKitCSSShaderValue, isWebKitCSSShaderValue())
 
 } // namespace WebCore