OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
3 * Copyright (C) 2014 Apple Inc. All rights reserved. | 3 * Copyright (C) 2014 Apple Inc. All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
7 * met: | 7 * met: |
8 * | 8 * |
9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
72 | 72 |
73 AttributeCollection attributes() const; | 73 AttributeCollection attributes() const; |
74 | 74 |
75 bool hasID() const { return !m_idForStyleResolution.isNull(); } | 75 bool hasID() const { return !m_idForStyleResolution.isNull(); } |
76 bool hasClass() const { return !m_classNames.isNull(); } | 76 bool hasClass() const { return !m_classNames.isNull(); } |
77 | 77 |
78 bool isEquivalent(const ElementData* other) const; | 78 bool isEquivalent(const ElementData* other) const; |
79 | 79 |
80 bool isUnique() const { return m_isUnique; } | 80 bool isUnique() const { return m_isUnique; } |
81 | 81 |
82 void traceAfterDispatch(Visitor*); | 82 DECLARE_TRACE_AFTER_DISPATCH(); |
haraken
2015/02/24 09:18:36
Add a comment on why we need traceAfterDispatch.
| |
83 void trace(Visitor*); | 83 DECLARE_TRACE(); |
84 | 84 |
85 protected: | 85 protected: |
86 ElementData(); | 86 ElementData(); |
87 explicit ElementData(unsigned arraySize); | 87 explicit ElementData(unsigned arraySize); |
88 ElementData(const ElementData&, bool isUnique); | 88 ElementData(const ElementData&, bool isUnique); |
89 | 89 |
90 // Keep the type in a bitfield instead of using virtual destructors to avoid adding a vtable. | 90 // Keep the type in a bitfield instead of using virtual destructors to avoid adding a vtable. |
91 unsigned m_isUnique : 1; | 91 unsigned m_isUnique : 1; |
92 unsigned m_arraySize : 28; | 92 unsigned m_arraySize : 28; |
93 mutable unsigned m_presentationAttributeStyleIsDirty : 1; | 93 mutable unsigned m_presentationAttributeStyleIsDirty : 1; |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
125 // is a memory optimization since it's very common for many elements to have | 125 // is a memory optimization since it's very common for many elements to have |
126 // duplicate sets of attributes (ex. the same classes). | 126 // duplicate sets of attributes (ex. the same classes). |
127 class ShareableElementData final : public ElementData { | 127 class ShareableElementData final : public ElementData { |
128 public: | 128 public: |
129 static PassRefPtrWillBeRawPtr<ShareableElementData> createWithAttributes(con st Vector<Attribute>&); | 129 static PassRefPtrWillBeRawPtr<ShareableElementData> createWithAttributes(con st Vector<Attribute>&); |
130 | 130 |
131 explicit ShareableElementData(const Vector<Attribute>&); | 131 explicit ShareableElementData(const Vector<Attribute>&); |
132 explicit ShareableElementData(const UniqueElementData&); | 132 explicit ShareableElementData(const UniqueElementData&); |
133 ~ShareableElementData(); | 133 ~ShareableElementData(); |
134 | 134 |
135 void traceAfterDispatch(Visitor* visitor) { ElementData::traceAfterDispatch( visitor); } | 135 DEFINE_INLINE_TRACE_AFTER_DISPATCH() { ElementData::traceAfterDispatch(visit or); } |
136 | 136 |
137 // Add support for placement new as ShareableElementData is not allocated | 137 // Add support for placement new as ShareableElementData is not allocated |
138 // with a fixed size. Instead the allocated memory size is computed based on | 138 // with a fixed size. Instead the allocated memory size is computed based on |
139 // the number of attributes. This requires us to use Heap::allocate directly | 139 // the number of attributes. This requires us to use Heap::allocate directly |
140 // with the computed size and subsequently call placement new with the | 140 // with the computed size and subsequently call placement new with the |
141 // allocated memory address. | 141 // allocated memory address. |
142 void* operator new(std::size_t, void* location) | 142 void* operator new(std::size_t, void* location) |
143 { | 143 { |
144 return location; | 144 return location; |
145 } | 145 } |
(...skipping 20 matching lines...) Expand all Loading... | |
166 static PassRefPtrWillBeRawPtr<UniqueElementData> create(); | 166 static PassRefPtrWillBeRawPtr<UniqueElementData> create(); |
167 PassRefPtrWillBeRawPtr<ShareableElementData> makeShareableCopy() const; | 167 PassRefPtrWillBeRawPtr<ShareableElementData> makeShareableCopy() const; |
168 | 168 |
169 MutableAttributeCollection attributes(); | 169 MutableAttributeCollection attributes(); |
170 AttributeCollection attributes() const; | 170 AttributeCollection attributes() const; |
171 | 171 |
172 UniqueElementData(); | 172 UniqueElementData(); |
173 explicit UniqueElementData(const ShareableElementData&); | 173 explicit UniqueElementData(const ShareableElementData&); |
174 explicit UniqueElementData(const UniqueElementData&); | 174 explicit UniqueElementData(const UniqueElementData&); |
175 | 175 |
176 void traceAfterDispatch(Visitor*); | 176 DECLARE_TRACE_AFTER_DISPATCH(); |
177 | 177 |
178 // FIXME: We might want to support sharing element data for elements with | 178 // FIXME: We might want to support sharing element data for elements with |
179 // presentation attribute style. Lots of table cells likely have the same | 179 // presentation attribute style. Lots of table cells likely have the same |
180 // attributes. Most modern pages don't use presentation attributes though | 180 // attributes. Most modern pages don't use presentation attributes though |
181 // so this might not make sense. | 181 // so this might not make sense. |
182 mutable RefPtrWillBeMember<StylePropertySet> m_presentationAttributeStyle; | 182 mutable RefPtrWillBeMember<StylePropertySet> m_presentationAttributeStyle; |
183 AttributeVector m_attributeVector; | 183 AttributeVector m_attributeVector; |
184 }; | 184 }; |
185 | 185 |
186 DEFINE_ELEMENT_DATA_TYPE_CASTS(UniqueElementData, data->isUnique(), data.isUniqu e()); | 186 DEFINE_ELEMENT_DATA_TYPE_CASTS(UniqueElementData, data->isUnique(), data.isUniqu e()); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
219 } | 219 } |
220 | 220 |
221 inline MutableAttributeCollection UniqueElementData::attributes() | 221 inline MutableAttributeCollection UniqueElementData::attributes() |
222 { | 222 { |
223 return MutableAttributeCollection(m_attributeVector); | 223 return MutableAttributeCollection(m_attributeVector); |
224 } | 224 } |
225 | 225 |
226 } // namespace blink | 226 } // namespace blink |
227 | 227 |
228 #endif // ElementData_h | 228 #endif // ElementData_h |
OLD | NEW |