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

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
Index: Source/core/dom/ElementData.h
diff --git a/Source/core/dom/ElementData.h b/Source/core/dom/ElementData.h
index f7f4a07996c6b120ea9dc68fa6fa1ba45abd22b0..b34a07e52de91b9e89accf6036f58b0e60ffb6dc 100644
--- a/Source/core/dom/ElementData.h
+++ b/Source/core/dom/ElementData.h
@@ -111,6 +111,9 @@ private:
PassRefPtrWillBeRawPtr<UniqueElementData> makeUniqueCopy() const;
};
+#define DEFINE_ELEMENT_DATA_TYPE_CASTS(thisType, predicate) \
+ DEFINE_TYPE_CASTS(thisType, ElementData, data, data->isUnique() == predicate, data.isUnique() == predicate)
+
#if COMPILER(MSVC)
#pragma warning(push)
#pragma warning(disable: 4200) // Disable "zero-sized array in struct/union" warning
@@ -145,6 +148,8 @@ public:
Attribute m_attributeArray[0];
};
+DEFINE_ELEMENT_DATA_TYPE_CASTS(ShareableElementData, false);
Inactive 2014/07/21 12:14:00 nit: I would have introduced a "isShareable()" met
+
#if COMPILER(MSVC)
#pragma warning(pop)
#endif
@@ -183,6 +188,8 @@ public:
Vector<Attribute, 4> m_attributeVector;
};
+DEFINE_ELEMENT_DATA_TYPE_CASTS(UniqueElementData, true);
Inactive 2014/07/21 12:14:00 ditto: s/true/isUnique
+
#if !ENABLE(OILPAN)
inline void ElementData::deref()
{
@@ -196,14 +203,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

Powered by Google App Engine
This is Rietveld 408576698