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

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..2eb84fb67049b0ba46438837b5a3f633ed3b94de 100644
--- a/Source/core/dom/ElementData.h
+++ b/Source/core/dom/ElementData.h
@@ -78,6 +78,7 @@ public:
bool isEquivalent(const ElementData* other) const;
bool isUnique() const { return m_isUnique; }
+ bool isShareable() const { return !m_isUnique; }
void traceAfterDispatch(Visitor*);
void trace(Visitor*);
@@ -111,6 +112,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()); } \
Inactive 2014/07/21 19:37:47 Sorry, I thought the macro was doing this for us a
gyuyoung-inactive 2014/07/22 00:20:32 I removed .get() in issue 401553002 as well. I wou
Inactive 2014/07/22 00:44:29 Ok, I see tkent's comment on the other CL, fine th
tkent 2014/07/22 00:57:12 I agree with Chris. Adding the intermediate macro
+ 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 +150,8 @@ public:
Attribute m_attributeArray[0];
};
+DEFINE_ELEMENT_DATA_TYPE_CASTS(ShareableElementData, isShareable());
+
#if COMPILER(MSVC)
#pragma warning(pop)
#endif
@@ -183,6 +190,8 @@ public:
Vector<Attribute, 4> m_attributeVector;
};
+DEFINE_ELEMENT_DATA_TYPE_CASTS(UniqueElementData, isUnique());
+
#if !ENABLE(OILPAN)
inline void ElementData::deref()
{
@@ -196,14 +205,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