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

Side by Side Diff: third_party/WebKit/Source/core/dom/ElementData.cpp

Issue 1686483002: Oilpan: Remove most WillBe types from the code base (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 18 matching lines...) Expand all
29 */ 29 */
30 30
31 #include "core/dom/ElementData.h" 31 #include "core/dom/ElementData.h"
32 32
33 #include "core/css/StylePropertySet.h" 33 #include "core/css/StylePropertySet.h"
34 #include "core/dom/QualifiedName.h" 34 #include "core/dom/QualifiedName.h"
35 #include "wtf/Vector.h" 35 #include "wtf/Vector.h"
36 36
37 namespace blink { 37 namespace blink {
38 38
39 struct SameSizeAsElementData : public RefCountedWillBeGarbageCollectedFinalized< SameSizeAsElementData> { 39 struct SameSizeAsElementData : public GarbageCollectedFinalized<SameSizeAsElemen tData> {
40 unsigned bitfield; 40 unsigned bitfield;
41 RawPtrWillBeMember<void*> willbeMember; 41 Member<void*> willbeMember;
42 void* pointers[2]; 42 void* pointers[2];
43 }; 43 };
44 44
45 static_assert(sizeof(ElementData) == sizeof(SameSizeAsElementData), "ElementData should stay small"); 45 static_assert(sizeof(ElementData) == sizeof(SameSizeAsElementData), "ElementData should stay small");
46 46
47 static size_t sizeForShareableElementDataWithAttributeCount(unsigned count) 47 static size_t sizeForShareableElementDataWithAttributeCount(unsigned count)
48 { 48 {
49 return sizeof(ShareableElementData) + sizeof(Attribute) * count; 49 return sizeof(ShareableElementData) + sizeof(Attribute) * count;
50 } 50 }
51 51
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 #else 90 #else
91 void ElementData::destroy() 91 void ElementData::destroy()
92 { 92 {
93 if (m_isUnique) 93 if (m_isUnique)
94 delete toUniqueElementData(this); 94 delete toUniqueElementData(this);
95 else 95 else
96 delete toShareableElementData(this); 96 delete toShareableElementData(this);
97 } 97 }
98 #endif 98 #endif
99 99
100 PassRefPtrWillBeRawPtr<UniqueElementData> ElementData::makeUniqueCopy() const 100 RawPtr<UniqueElementData> ElementData::makeUniqueCopy() const
101 { 101 {
102 if (isUnique()) 102 if (isUnique())
103 return adoptRefWillBeNoop(new UniqueElementData(toUniqueElementData(*thi s))); 103 return new UniqueElementData(toUniqueElementData(*this));
104 return adoptRefWillBeNoop(new UniqueElementData(toShareableElementData(*this ))); 104 return new UniqueElementData(toShareableElementData(*this));
105 } 105 }
106 106
107 bool ElementData::isEquivalent(const ElementData* other) const 107 bool ElementData::isEquivalent(const ElementData* other) const
108 { 108 {
109 AttributeCollection attributes = this->attributes(); 109 AttributeCollection attributes = this->attributes();
110 if (!other) 110 if (!other)
111 return attributes.isEmpty(); 111 return attributes.isEmpty();
112 112
113 AttributeCollection otherAttributes = other->attributes(); 113 AttributeCollection otherAttributes = other->attributes();
114 if (attributes.size() != otherAttributes.size()) 114 if (attributes.size() != otherAttributes.size())
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 ASSERT(!other.m_presentationAttributeStyle); 154 ASSERT(!other.m_presentationAttributeStyle);
155 155
156 if (other.m_inlineStyle) { 156 if (other.m_inlineStyle) {
157 m_inlineStyle = other.m_inlineStyle->immutableCopyIfNeeded(); 157 m_inlineStyle = other.m_inlineStyle->immutableCopyIfNeeded();
158 } 158 }
159 159
160 for (unsigned i = 0; i < m_arraySize; ++i) 160 for (unsigned i = 0; i < m_arraySize; ++i)
161 new (&m_attributeArray[i]) Attribute(other.m_attributeVector.at(i)); 161 new (&m_attributeArray[i]) Attribute(other.m_attributeVector.at(i));
162 } 162 }
163 163
164 PassRefPtrWillBeRawPtr<ShareableElementData> ShareableElementData::createWithAtt ributes(const Vector<Attribute>& attributes) 164 RawPtr<ShareableElementData> ShareableElementData::createWithAttributes(const Ve ctor<Attribute>& attributes)
165 { 165 {
166 #if ENABLE(OILPAN) 166 #if ENABLE(OILPAN)
167 void* slot = Heap::allocate<ElementData>(sizeForShareableElementDataWithAttr ibuteCount(attributes.size())); 167 void* slot = Heap::allocate<ElementData>(sizeForShareableElementDataWithAttr ibuteCount(attributes.size()));
168 #else 168 #else
169 void* slot = WTF::Partitions::fastMalloc(sizeForShareableElementDataWithAttr ibuteCount(attributes.size()), WTF_HEAP_PROFILER_TYPE_NAME(ShareableElementData) ); 169 void* slot = WTF::Partitions::fastMalloc(sizeForShareableElementDataWithAttr ibuteCount(attributes.size()), WTF_HEAP_PROFILER_TYPE_NAME(ShareableElementData) );
170 #endif 170 #endif
171 return adoptRefWillBeNoop(new (slot) ShareableElementData(attributes)); 171 return adoptRefWillBeNoop(new (slot) ShareableElementData(attributes));
172 } 172 }
173 173
174 UniqueElementData::UniqueElementData() 174 UniqueElementData::UniqueElementData()
(...skipping 14 matching lines...) Expand all
189 // An ShareableElementData should never have a mutable inline StylePropertyS et attached. 189 // An ShareableElementData should never have a mutable inline StylePropertyS et attached.
190 ASSERT(!other.m_inlineStyle || !other.m_inlineStyle->isMutable()); 190 ASSERT(!other.m_inlineStyle || !other.m_inlineStyle->isMutable());
191 m_inlineStyle = other.m_inlineStyle; 191 m_inlineStyle = other.m_inlineStyle;
192 192
193 unsigned length = other.attributes().size(); 193 unsigned length = other.attributes().size();
194 m_attributeVector.reserveCapacity(length); 194 m_attributeVector.reserveCapacity(length);
195 for (unsigned i = 0; i < length; ++i) 195 for (unsigned i = 0; i < length; ++i)
196 m_attributeVector.uncheckedAppend(other.m_attributeArray[i]); 196 m_attributeVector.uncheckedAppend(other.m_attributeArray[i]);
197 } 197 }
198 198
199 PassRefPtrWillBeRawPtr<UniqueElementData> UniqueElementData::create() 199 RawPtr<UniqueElementData> UniqueElementData::create()
200 { 200 {
201 return adoptRefWillBeNoop(new UniqueElementData); 201 return adoptRefWillBeNoop(new UniqueElementData);
202 } 202 }
203 203
204 PassRefPtrWillBeRawPtr<ShareableElementData> UniqueElementData::makeShareableCop y() const 204 RawPtr<ShareableElementData> UniqueElementData::makeShareableCopy() const
205 { 205 {
206 #if ENABLE(OILPAN) 206 #if ENABLE(OILPAN)
207 void* slot = Heap::allocate<ElementData>(sizeForShareableElementDataWithAttr ibuteCount(m_attributeVector.size())); 207 void* slot = Heap::allocate<ElementData>(sizeForShareableElementDataWithAttr ibuteCount(m_attributeVector.size()));
208 #else 208 #else
209 void* slot = WTF::Partitions::fastMalloc(sizeForShareableElementDataWithAttr ibuteCount(m_attributeVector.size()), WTF_HEAP_PROFILER_TYPE_NAME(ShareableEleme ntData)); 209 void* slot = WTF::Partitions::fastMalloc(sizeForShareableElementDataWithAttr ibuteCount(m_attributeVector.size()), WTF_HEAP_PROFILER_TYPE_NAME(ShareableEleme ntData));
210 #endif 210 #endif
211 return adoptRefWillBeNoop(new (slot) ShareableElementData(*this)); 211 return adoptRefWillBeNoop(new (slot) ShareableElementData(*this));
212 } 212 }
213 213
214 DEFINE_TRACE_AFTER_DISPATCH(UniqueElementData) 214 DEFINE_TRACE_AFTER_DISPATCH(UniqueElementData)
215 { 215 {
216 visitor->trace(m_presentationAttributeStyle); 216 visitor->trace(m_presentationAttributeStyle);
217 ElementData::traceAfterDispatch(visitor); 217 ElementData::traceAfterDispatch(visitor);
218 } 218 }
219 219
220 } // namespace blink 220 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/ElementData.h ('k') | third_party/WebKit/Source/core/dom/ElementDataCache.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698