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

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

Issue 273843003: [Oilpan]: Make StylePropertySet fully garbage collected. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: review feedback Created 6 years, 6 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 0a8cc6202a0caad1b355b8b817cfb96887f007a9..99aa0123d074c0ec6182030440abc15403adbd73 100644
--- a/Source/core/dom/ElementData.h
+++ b/Source/core/dom/ElementData.h
@@ -34,6 +34,7 @@
#include "core/dom/Attribute.h"
#include "core/dom/SpaceSplitString.h"
+#include "platform/heap/Handle.h"
#include "wtf/text/AtomicString.h"
namespace WebCore {
@@ -64,12 +65,18 @@ private:
// ElementData represents very common, but not necessarily unique to an element,
// data such as attributes, inline style, and parsed class names and ids.
-class ElementData : public RefCounted<ElementData> {
- WTF_MAKE_FAST_ALLOCATED;
+class ElementData : public RefCountedWillBeGarbageCollectedFinalized<ElementData> {
+ WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED;
public:
+#if ENABLE(OILPAN)
+ // Override GarbageCollectedFinalized's finalizeGarbageCollectedObject to
+ // dispatch to the correct subclass destructor.
+ void finalizeGarbageCollectedObject();
+#else
// Override RefCounted's deref() to ensure operator delete is called on
// the appropriate subclass type.
void deref();
+#endif
void clearClass() const { m_classNames.clear(); }
void setClass(const AtomicString& className, bool shouldFoldCase) const { m_classNames.set(className, shouldFoldCase); }
@@ -101,6 +108,9 @@ public:
bool isUnique() const { return m_isUnique; }
+ void traceAfterDispatch(Visitor*);
+ void trace(Visitor*);
+
protected:
ElementData();
explicit ElementData(unsigned arraySize);
@@ -113,7 +123,7 @@ protected:
mutable unsigned m_styleAttributeIsDirty : 1;
mutable unsigned m_animatedSVGAttributesAreDirty : 1;
- mutable RefPtr<StylePropertySet> m_inlineStyle;
+ mutable RefPtrWillBeMember<StylePropertySet> m_inlineStyle;
mutable SpaceSplitString m_classNames;
mutable AtomicString m_idForStyleResolution;
@@ -123,13 +133,15 @@ private:
friend class UniqueElementData;
friend class SVGElement;
+#if !ENABLE(OILPAN)
void destroy();
+#endif
const Attribute* attributeBase() const;
const Attribute* findAttributeByName(const AtomicString& name, bool shouldIgnoreAttributeCase) const;
size_t findAttributeIndexByNameSlowCase(const AtomicString& name, bool shouldIgnoreAttributeCase) const;
- PassRefPtr<UniqueElementData> makeUniqueCopy() const;
+ PassRefPtrWillBeRawPtr<UniqueElementData> makeUniqueCopy() const;
};
#if COMPILER(MSVC)
@@ -143,12 +155,24 @@ private:
// duplicate sets of attributes (ex. the same classes).
class ShareableElementData FINAL : public ElementData {
public:
- static PassRefPtr<ShareableElementData> createWithAttributes(const Vector<Attribute>&);
+ static PassRefPtrWillBeRawPtr<ShareableElementData> createWithAttributes(const Vector<Attribute>&);
explicit ShareableElementData(const Vector<Attribute>&);
explicit ShareableElementData(const UniqueElementData&);
~ShareableElementData();
+ void traceAfterDispatch(Visitor* visitor) { ElementData::traceAfterDispatch(visitor); }
+
+ // Add support for placement new as ShareableElementData is not allocated
+ // with a fixed size. Instead the allocated memory size is computed based on
+ // the number of attributes. This requires us to use Heap::allocate directly
+ // with the computed size and subsequently call placement new with the
+ // allocated memory address.
+ void* operator new(std::size_t, void* location)
+ {
+ return location;
+ }
+
Attribute m_attributeArray[0];
};
@@ -164,8 +188,8 @@ public:
// attribute will have the same inline style.
class UniqueElementData FINAL : public ElementData {
public:
- static PassRefPtr<UniqueElementData> create();
- PassRefPtr<ShareableElementData> makeShareableCopy() const;
+ static PassRefPtrWillBeRawPtr<UniqueElementData> create();
+ PassRefPtrWillBeRawPtr<ShareableElementData> makeShareableCopy() const;
// These functions do no error/duplicate checking.
void appendAttribute(const QualifiedName&, const AtomicString&);
@@ -178,20 +202,24 @@ public:
explicit UniqueElementData(const ShareableElementData&);
explicit UniqueElementData(const UniqueElementData&);
+ void traceAfterDispatch(Visitor*);
+
// FIXME: We might want to support sharing element data for elements with
// presentation attribute style. Lots of table cells likely have the same
// attributes. Most modern pages don't use presentation attributes though
// so this might not make sense.
- mutable RefPtr<StylePropertySet> m_presentationAttributeStyle;
+ mutable RefPtrWillBeMember<StylePropertySet> m_presentationAttributeStyle;
Vector<Attribute, 4> m_attributeVector;
};
+#if !ENABLE(OILPAN)
inline void ElementData::deref()
{
if (!derefBase())
return;
destroy();
}
+#endif
inline size_t ElementData::attributeCount() 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