Index: Source/core/dom/ElementData.h |
diff --git a/Source/core/dom/ElementData.h b/Source/core/dom/ElementData.h |
index f7f4a07996c6b120ea9dc68fa6fa1ba45abd22b0..31f0c4d9e491776515bdecbe271f10445da8c059 100644 |
--- a/Source/core/dom/ElementData.h |
+++ b/Source/core/dom/ElementData.h |
@@ -111,6 +111,10 @@ private: |
PassRefPtrWillBeRawPtr<UniqueElementData> makeUniqueCopy() const; |
}; |
+#define DEFINE_ELEMENT_DATA_TYPE_CASTS(thisType, predicate) \ |
+ template<typename T> inline thisType* to##thisType(const RefPtr<T>& data) { return to##thisType(data.get()); } \ |
+ DEFINE_TYPE_CASTS(thisType, ElementData, data, data->predicate, data.predicate) |
+ |
#if COMPILER(MSVC) |
#pragma warning(push) |
#pragma warning(disable: 4200) // Disable "zero-sized array in struct/union" warning |
@@ -145,6 +149,8 @@ public: |
Attribute m_attributeArray[0]; |
}; |
+DEFINE_ELEMENT_DATA_TYPE_CASTS(ShareableElementData, isUnique() == 0); |
gyuyoung-inactive
2014/07/22 02:09:52
Ok, what do you guys think about this style ?
tkent
2014/07/22 03:19:31
It looks weird.
I like:
#define DEFINE_ELEMENT_D
gyuyoung-inactive
2014/07/22 03:46:19
Done.
|
+ |
#if COMPILER(MSVC) |
#pragma warning(pop) |
#endif |
@@ -183,6 +189,8 @@ public: |
Vector<Attribute, 4> m_attributeVector; |
}; |
+DEFINE_ELEMENT_DATA_TYPE_CASTS(UniqueElementData, isUnique() == 1); |
+ |
#if !ENABLE(OILPAN) |
inline void ElementData::deref() |
{ |
@@ -196,14 +204,14 @@ inline const StylePropertySet* ElementData::presentationAttributeStyle() const |
{ |
if (!m_isUnique) |
return 0; |
- return static_cast<const UniqueElementData*>(this)->m_presentationAttributeStyle.get(); |
+ return toUniqueElementData(this)->m_presentationAttributeStyle.get(); |
} |
inline AttributeCollection ElementData::attributes() const |
{ |
if (isUnique()) |
- return static_cast<const UniqueElementData*>(this)->attributes(); |
- return static_cast<const ShareableElementData*>(this)->attributes(); |
+ return toUniqueElementData(this)->attributes(); |
+ return toShareableElementData(this)->attributes(); |
} |
inline AttributeCollection ShareableElementData::attributes() const |