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

Unified Diff: Source/core/dom/ElementData.h

Issue 405923002: Introduce DEFINE_ELEMENT_DATA_TYPE_CASTS, and use it (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 5 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/dom/Element.cpp ('k') | Source/core/dom/ElementData.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/dom/ElementData.h
diff --git a/Source/core/dom/ElementData.h b/Source/core/dom/ElementData.h
index f7f4a07996c6b120ea9dc68fa6fa1ba45abd22b0..c911969f05390263815e59b56bc9a34448e5e870 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, pointerPredicate, referencePredicate) \
+ template<typename T> inline thisType* to##thisType(const RefPtr<T>& data) { return to##thisType(data.get()); } \
+ DEFINE_TYPE_CASTS(thisType, ElementData, data, pointerPredicate, referencePredicate)
+
#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, !data->isUnique(), !data.isUnique());
+
#if COMPILER(MSVC)
#pragma warning(pop)
#endif
@@ -183,6 +189,8 @@ public:
Vector<Attribute, 4> m_attributeVector;
};
+DEFINE_ELEMENT_DATA_TYPE_CASTS(UniqueElementData, data->isUnique(), data.isUnique());
+
#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
« no previous file with comments | « Source/core/dom/Element.cpp ('k') | Source/core/dom/ElementData.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698