Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(513)

Unified Diff: Source/core/css/CSSValue.cpp

Issue 27183005: Use DEFINE_CSS_VALUE_TYPE_CASTS() for SVGColor, SVGPaint, and TextCloneCSSValue (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/css/CSSValue.h ('k') | Source/core/svg/SVGColor.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/css/CSSValue.cpp
diff --git a/Source/core/css/CSSValue.cpp b/Source/core/css/CSSValue.cpp
index cd6970f776a2f293a024f7471e9973a50b5579cc..f1e37a8a8c8f0c8a5164716f668fa4e665567532 100644
--- a/Source/core/css/CSSValue.cpp
+++ b/Source/core/css/CSSValue.cpp
@@ -85,6 +85,21 @@ private:
String m_cssText;
};
+// This will catch anyone doing an unnecessary cast.
+void toTextCloneCSSValue(const TextCloneCSSValue*);
esprehn 2013/10/15 01:17:41 We should just fix the macros. DEFINE_NODE_TYPE_CA
gyuyoung-inactive 2013/10/15 01:46:27 Yes, good idea. It looks we can change DEFINE_NODE
gyuyoung-inactive 2013/10/15 03:36:49 I upload a patch for this. https://chromiumcoderev
+
+inline TextCloneCSSValue* toTextCloneCSSValue(CSSValue* value)
+{
+ ASSERT_WITH_SECURITY_IMPLICATION(!value || value->isTextCloneCSSValue());
+ return static_cast<TextCloneCSSValue*>(value);
+}
+
+inline const TextCloneCSSValue* toTextCloneCSSValue(const CSSValue* value)
+{
+ ASSERT_WITH_SECURITY_IMPLICATION(!value || value->isTextCloneCSSValue());
+ return static_cast<const TextCloneCSSValue*>(value);
+}
+
bool CSSValue::isImplicitInitialValue() const
{
return m_classType == InitialClass && toCSSInitialValue(this)->isImplicit();
@@ -147,7 +162,7 @@ bool CSSValue::equals(const CSSValue& other) const
{
if (m_isTextClone) {
ASSERT(isCSSOMSafe());
- return static_cast<const TextCloneCSSValue*>(this)->cssText() == other.cssText();
+ return toTextCloneCSSValue(this)->cssText() == other.cssText();
}
if (m_classType == other.m_classType) {
@@ -234,8 +249,8 @@ bool CSSValue::equals(const CSSValue& other) const
String CSSValue::cssText() const
{
if (m_isTextClone) {
- ASSERT(isCSSOMSafe());
- return static_cast<const TextCloneCSSValue*>(this)->cssText();
+ ASSERT(isCSSOMSafe());
+ return toTextCloneCSSValue(this)->cssText();
}
ASSERT(!isCSSOMSafe() || isSubtypeExposedToCSSOM());
@@ -333,7 +348,7 @@ void CSSValue::destroy()
{
if (m_isTextClone) {
ASSERT(isCSSOMSafe());
- delete static_cast<TextCloneCSSValue*>(this);
+ delete toTextCloneCSSValue(this);
return;
}
ASSERT(!isCSSOMSafe() || isSubtypeExposedToCSSOM());
« no previous file with comments | « Source/core/css/CSSValue.h ('k') | Source/core/svg/SVGColor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698