Changeset 128115 in webkit
- Timestamp:
- Sep 10, 2012 3:18:40 PM (12 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r128114 r128115 1 2012-09-10 Sheriff Bot <webkit.review.bot@gmail.com> 2 3 Unreviewed, rolling out r128109. 4 http://trac.webkit.org/changeset/128109 5 https://bugs.webkit.org/show_bug.cgi?id=96326 6 7 broke win and lion builds (Requested by kling on #webkit). 8 9 * WebCore.exp.in: 10 * dom/Element.cpp: 11 (WebCore::Element::createMutableAttributeData): 12 * dom/ElementAttributeData.cpp: 13 (WebCore::immutableElementAttributeDataSize): 14 (WebCore::ElementAttributeData::createImmutable): 15 (WebCore::ElementAttributeData::ElementAttributeData): 16 (WebCore::ElementAttributeData::~ElementAttributeData): 17 (WebCore::ElementAttributeData::addAttribute): 18 (WebCore::ElementAttributeData::removeAttribute): 19 (WebCore::ElementAttributeData::reportMemoryUsage): 20 (WebCore::ElementAttributeData::cloneDataFrom): 21 (WebCore::ElementAttributeData::clearAttributes): 22 * dom/ElementAttributeData.h: 23 (WebCore): 24 (WebCore::ElementAttributeData::create): 25 (ElementAttributeData): 26 (WebCore::ElementAttributeData::isMutable): 27 (WebCore::ElementAttributeData::makeMutable): 28 (WebCore::ElementAttributeData::length): 29 (WebCore::ElementAttributeData::attributeItem): 30 1 31 2012-09-10 Chris Fleizach <cfleizach@apple.com> 2 32 -
trunk/Source/WebCore/WebCore.exp.in
r128109 r128115 231 231 __ZN7WebCore13toHTMLElementEPNS_21FormAssociatedElementE 232 232 __ZN7WebCore13toJSDOMWindowEN3JSC7JSValueE 233 __ZN7WebCore13QualifiedNameD1Ev234 233 __ZN7WebCore14CachedResource12removeClientEPNS_20CachedResourceClientE 235 234 __ZN7WebCore14CachedResource16unregisterHandleEPNS_24CachedResourceHandleBaseE … … 540 539 __ZN7WebCore20makeRGBA32FromFloatsEffff 541 540 __ZN7WebCore20protocolIsJavaScriptERKN3WTF6StringE 542 __ZN7WebCore20SpaceSplitStringDataD1Ev543 541 __ZN7WebCore21BackForwardController11itemAtIndexEi 544 542 __ZN7WebCore21MemoryPressureHandler7installEv -
trunk/Source/WebCore/dom/Element.cpp
r128109 r128115 2247 2247 m_attributeData = ElementAttributeData::create(); 2248 2248 else 2249 m_attributeData = m_attributeData->makeMutable Copy();2249 m_attributeData = m_attributeData->makeMutable(); 2250 2250 } 2251 2251 -
trunk/Source/WebCore/dom/ElementAttributeData.cpp
r128109 r128115 37 37 static size_t immutableElementAttributeDataSize(unsigned count) 38 38 { 39 return sizeof( ImmutableElementAttributeData) + sizeof(Attribute) * count;39 return sizeof(ElementAttributeData) - sizeof(void*) + sizeof(Attribute) * count; 40 40 } 41 41 … … 43 43 { 44 44 void* slot = WTF::fastMalloc(immutableElementAttributeDataSize(attributes.size())); 45 return adoptRef(new (slot) ImmutableElementAttributeData(attributes)); 46 } 47 48 PassRefPtr<ElementAttributeData> ElementAttributeData::create() 49 { 50 return adoptRef(new MutableElementAttributeData); 51 } 52 53 ImmutableElementAttributeData::ImmutableElementAttributeData(const Vector<Attribute>& attributes) 54 : ElementAttributeData(attributes.size()) 55 { 56 for (unsigned i = 0; i < m_arraySize; ++i) 57 new (&m_attributeArray[i]) Attribute(attributes[i]); 58 } 59 60 MutableElementAttributeData::MutableElementAttributeData(const ImmutableElementAttributeData& other) 61 { 62 const ElementAttributeData& baseOther = static_cast<const ElementAttributeData&>(other); 63 64 m_inlineStyleDecl = baseOther.m_inlineStyleDecl; 65 m_attributeStyle = baseOther.m_attributeStyle; 66 m_classNames = baseOther.m_classNames; 67 m_idForStyleResolution = baseOther.m_idForStyleResolution; 68 69 // An ImmutableElementAttributeData should never have a mutable inline StylePropertySet attached. 70 ASSERT(!baseOther.m_inlineStyleDecl || !baseOther.m_inlineStyleDecl->isMutable()); 71 72 m_attributeVector.reserveCapacity(baseOther.m_arraySize); 73 for (unsigned i = 0; i < baseOther.m_arraySize; ++i) 74 m_attributeVector.uncheckedAppend(other.m_attributeArray[i]); 75 } 76 77 ImmutableElementAttributeData::~ImmutableElementAttributeData() 78 { 79 for (unsigned i = 0; i < m_arraySize; ++i) 80 m_attributeArray[i].~Attribute(); 81 } 82 83 PassRefPtr<ElementAttributeData> ElementAttributeData::makeMutableCopy() const 84 { 85 ASSERT(!isMutable()); 86 return adoptRef(new MutableElementAttributeData(static_cast<const ImmutableElementAttributeData&>(*this))); 45 return adoptRef(new (slot) ElementAttributeData(attributes)); 46 } 47 48 ElementAttributeData::ElementAttributeData() 49 : m_isMutable(true) 50 , m_arraySize(0) 51 , m_mutableAttributeVector(new Vector<Attribute, 4>) 52 { 53 } 54 55 ElementAttributeData::ElementAttributeData(const Vector<Attribute>& attributes) 56 : m_isMutable(false) 57 , m_arraySize(attributes.size()) 58 { 59 Attribute* buffer = reinterpret_cast<Attribute*>(&m_attributes); 60 for (unsigned i = 0; i < attributes.size(); ++i) 61 new (&buffer[i]) Attribute(attributes[i]); 62 } 63 64 ElementAttributeData::ElementAttributeData(const ElementAttributeData& other) 65 : RefCounted<ElementAttributeData>() 66 , m_isMutable(true) 67 , m_arraySize(0) 68 , m_inlineStyleDecl(other.m_inlineStyleDecl) 69 , m_attributeStyle(other.m_attributeStyle) 70 , m_classNames(other.m_classNames) 71 , m_idForStyleResolution(other.m_idForStyleResolution) 72 , m_mutableAttributeVector(new Vector<Attribute, 4>) 73 { 74 // This copy constructor should only be used by makeMutable() to go from immutable to mutable. 75 ASSERT(!other.m_isMutable); 76 77 // An immutable ElementAttributeData should never have a mutable inline StylePropertySet attached. 78 ASSERT(!other.m_inlineStyleDecl || !other.m_inlineStyleDecl->isMutable()); 79 80 const Attribute* otherBuffer = reinterpret_cast<const Attribute*>(&other.m_attributes); 81 for (unsigned i = 0; i < other.m_arraySize; ++i) 82 m_mutableAttributeVector->append(otherBuffer[i]); 83 } 84 85 ElementAttributeData::~ElementAttributeData() 86 { 87 if (isMutable()) { 88 ASSERT(!m_arraySize); 89 delete m_mutableAttributeVector; 90 } else { 91 Attribute* buffer = reinterpret_cast<Attribute*>(&m_attributes); 92 for (unsigned i = 0; i < m_arraySize; ++i) 93 buffer[i].~Attribute(); 94 } 87 95 } 88 96 … … 229 237 element->willModifyAttribute(attribute.name(), nullAtom, attribute.value()); 230 238 231 m utableAttributeVector().append(attribute);239 m_mutableAttributeVector->append(attribute); 232 240 233 241 if (element && inSynchronizationOfLazyAttribute == NotInSynchronizationOfLazyAttribute) … … 240 248 ASSERT(index < length()); 241 249 242 Attribute& attribute = m utableAttributeVector().at(index);250 Attribute& attribute = m_mutableAttributeVector->at(index); 243 251 QualifiedName name = attribute.name(); 244 252 … … 249 257 attr->detachFromElementWithValue(attribute.value()); 250 258 251 m utableAttributeVector().remove(index);259 m_mutableAttributeVector->remove(index); 252 260 253 261 if (element && inSynchronizationOfLazyAttribute == NotInSynchronizationOfLazyAttribute) … … 297 305 info.addInstrumentedMember(m_idForStyleResolution); 298 306 if (m_isMutable) 299 info.addVector (mutableAttributeVector());307 info.addVectorPtr(m_mutableAttributeVector); 300 308 for (unsigned i = 0, len = length(); i < len; i++) 301 309 info.addInstrumentedMember(*attributeItem(i)); … … 341 349 342 350 if (sourceData.isMutable()) 343 mutableAttributeVector() = sourceData.mutableAttributeVector();351 *m_mutableAttributeVector = *sourceData.m_mutableAttributeVector; 344 352 else { 345 mutableAttributeVector().reserveInitialCapacity(sourceData.m_arraySize); 353 ASSERT(m_mutableAttributeVector->isEmpty()); 354 m_mutableAttributeVector->reserveInitialCapacity(sourceData.m_arraySize); 355 const Attribute* sourceBuffer = reinterpret_cast<const Attribute*>(&sourceData.m_attributes); 346 356 for (unsigned i = 0; i < sourceData.m_arraySize; ++i) 347 m utableAttributeVector().uncheckedAppend(sourceData.immutableAttributeArray()[i]);357 m_mutableAttributeVector->uncheckedAppend(sourceBuffer[i]); 348 358 } 349 359 350 360 for (unsigned i = 0; i < length(); ++i) { 351 const Attribute& attribute = m utableAttributeVector().at(i);361 const Attribute& attribute = m_mutableAttributeVector->at(i); 352 362 if (targetElement.isStyledElement() && attribute.name() == HTMLNames::styleAttr) { 353 363 static_cast<StyledElement&>(targetElement).styleAttributeChanged(attribute.value(), StyledElement::DoNotReparseStyleAttribute); … … 371 381 372 382 clearClass(); 373 m utableAttributeVector().clear();383 m_mutableAttributeVector->clear(); 374 384 } 375 385 -
trunk/Source/WebCore/dom/ElementAttributeData.h
r128109 r128115 36 36 class Attr; 37 37 class Element; 38 class ImmutableElementAttributeData;39 38 class MemoryObjectInfo; 40 class MutableElementAttributeData;41 39 42 40 enum SynchronizationOfLazyAttribute { NotInSynchronizationOfLazyAttribute, InSynchronizationOfLazyAttribute }; … … 45 43 WTF_MAKE_FAST_ALLOCATED; 46 44 public: 47 static PassRefPtr<ElementAttributeData> create() ;45 static PassRefPtr<ElementAttributeData> create() { return adoptRef(new ElementAttributeData); } 48 46 static PassRefPtr<ElementAttributeData> createImmutable(const Vector<Attribute>&); 47 ~ElementAttributeData(); 49 48 50 49 void clearClass() { m_classNames.clear(); } … … 97 96 void reportMemoryUsage(MemoryObjectInfo*) const; 98 97 99 bool isMutable() const { return m_isMutable; }100 101 protected:102 ElementAttributeData()103 : m_isMutable(true)104 , m_arraySize(0)105 { }106 107 ElementAttributeData(unsigned arraySize)108 : m_isMutable(false)109 , m_arraySize(arraySize)110 { }111 112 mutable RefPtr<StylePropertySet> m_inlineStyleDecl;113 mutable RefPtr<StylePropertySet> m_attributeStyle;114 mutable SpaceSplitString m_classNames;115 mutable AtomicString m_idForStyleResolution;116 117 unsigned m_isMutable : 1;118 unsigned m_arraySize : 31;119 120 98 private: 121 99 friend class Element; 122 100 friend class HTMLConstructionSite; 123 friend class ImmutableElementAttributeData; 124 friend class MutableElementAttributeData; 101 102 ElementAttributeData(); 103 ElementAttributeData(const ElementAttributeData&); 104 ElementAttributeData(const Vector<Attribute>&); 125 105 126 106 Attribute* getAttributeItem(const AtomicString& name, bool shouldIgnoreAttributeCase); … … 130 110 void clearAttributes(Element*); 131 111 132 PassRefPtr<ElementAttributeData> makeMutableCopy() const; 133 134 Vector<Attribute, 4>& mutableAttributeVector(); 135 const Vector<Attribute, 4>& mutableAttributeVector() const; 136 const Attribute* immutableAttributeArray() const; 112 bool isMutable() const { return m_isMutable; } 113 PassRefPtr<ElementAttributeData> makeMutable() const { return adoptRef(new ElementAttributeData(*this)); } 114 115 unsigned m_isMutable : 1; 116 unsigned m_arraySize : 31; 117 118 mutable RefPtr<StylePropertySet> m_inlineStyleDecl; 119 mutable RefPtr<StylePropertySet> m_attributeStyle; 120 mutable SpaceSplitString m_classNames; 121 mutable AtomicString m_idForStyleResolution; 122 123 union { 124 Vector<Attribute, 4>* m_mutableAttributeVector; 125 void* m_attributes; 126 }; 137 127 }; 138 128 139 class ImmutableElementAttributeData : public ElementAttributeData {140 public:141 ImmutableElementAttributeData(const Vector<Attribute>&);142 ~ImmutableElementAttributeData();143 144 Attribute m_attributeArray[0];145 };146 147 class MutableElementAttributeData : public ElementAttributeData {148 public:149 MutableElementAttributeData() { }150 MutableElementAttributeData(const ImmutableElementAttributeData&);151 152 Vector<Attribute, 4> m_attributeVector;153 };154 155 inline Vector<Attribute, 4>& ElementAttributeData::mutableAttributeVector()156 {157 ASSERT(m_isMutable);158 return static_cast<MutableElementAttributeData*>(this)->m_attributeVector;159 }160 161 inline const Vector<Attribute, 4>& ElementAttributeData::mutableAttributeVector() const162 {163 ASSERT(m_isMutable);164 return static_cast<const MutableElementAttributeData*>(this)->m_attributeVector;165 }166 167 inline const Attribute* ElementAttributeData::immutableAttributeArray() const168 {169 ASSERT(!m_isMutable);170 return static_cast<const ImmutableElementAttributeData*>(this)->m_attributeArray;171 }172 173 129 inline size_t ElementAttributeData::length() const 174 130 { 175 131 if (isMutable()) 176 return m utableAttributeVector().size();132 return m_mutableAttributeVector->size(); 177 133 return m_arraySize; 178 134 } … … 246 202 { 247 203 ASSERT(index < length()); 248 if (m_isMutable) 249 return &mutableAttributeVector().at(index); 250 return &immutableAttributeArray()[index]; 204 if (isMutable()) 205 return &m_mutableAttributeVector->at(index); 206 const Attribute* buffer = reinterpret_cast<const Attribute*>(&m_attributes); 207 return &buffer[index]; 251 208 } 252 209 253 210 inline Attribute* ElementAttributeData::attributeItem(unsigned index) 254 211 { 212 ASSERT(isMutable()); 255 213 ASSERT(index < length()); 256 return &mutableAttributeVector().at(index); 257 } 258 259 } 260 261 namespace WTF { 262 263 template <> inline void deleteOwnedPtr<WebCore::ElementAttributeData>(WebCore::ElementAttributeData* ptr) 264 { 265 if (!ptr) 266 return; 267 if (ptr->isMutable()) 268 delete static_cast<WebCore::MutableElementAttributeData*>(ptr); 269 else 270 delete static_cast<WebCore::ImmutableElementAttributeData*>(ptr); 214 return &m_mutableAttributeVector->at(index); 271 215 } 272 216
Note: See TracChangeset
for help on using the changeset viewer.