diff options
author | Simon Hausmann <simon.hausmann@nokia.com> | 2012-09-10 19:10:20 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@nokia.com> | 2012-09-10 19:10:20 +0200 |
commit | 284837daa07b29d6a63a748544a90b1f5842ac5c (patch) | |
tree | ecd258180bde91fe741e0cfd2638beb3c6da7e8e /Source/WebCore/dom/ElementAttributeData.cpp | |
parent | 2e2ba8ff45915f40ed3e014101269c175f2a89a0 (diff) | |
download | qtwebkit-284837daa07b29d6a63a748544a90b1f5842ac5c.tar.gz |
Imported WebKit commit 68645295d2e3e09af2c942f092556f06aa5f8b0d (http://svn.webkit.org/repository/webkit/trunk@128073)
New snapshot
Diffstat (limited to 'Source/WebCore/dom/ElementAttributeData.cpp')
-rw-r--r-- | Source/WebCore/dom/ElementAttributeData.cpp | 33 |
1 files changed, 12 insertions, 21 deletions
diff --git a/Source/WebCore/dom/ElementAttributeData.cpp b/Source/WebCore/dom/ElementAttributeData.cpp index 471e519e0..1db20f954 100644 --- a/Source/WebCore/dom/ElementAttributeData.cpp +++ b/Source/WebCore/dom/ElementAttributeData.cpp @@ -29,8 +29,8 @@ #include "Attr.h" #include "CSSParser.h" #include "CSSStyleSheet.h" -#include "MemoryInstrumentation.h" #include "StyledElement.h" +#include "WebCoreMemoryInstrumentation.h" namespace WebCore { @@ -39,10 +39,10 @@ static size_t immutableElementAttributeDataSize(unsigned count) return sizeof(ElementAttributeData) - sizeof(void*) + sizeof(Attribute) * count; } -PassOwnPtr<ElementAttributeData> ElementAttributeData::createImmutable(const Vector<Attribute>& attributes) +PassRefPtr<ElementAttributeData> ElementAttributeData::createImmutable(const Vector<Attribute>& attributes) { void* slot = WTF::fastMalloc(immutableElementAttributeDataSize(attributes.size())); - return adoptPtr(new (slot) ElementAttributeData(attributes)); + return adoptRef(new (slot) ElementAttributeData(attributes)); } ElementAttributeData::ElementAttributeData() @@ -62,17 +62,21 @@ ElementAttributeData::ElementAttributeData(const Vector<Attribute>& attributes) } ElementAttributeData::ElementAttributeData(const ElementAttributeData& other) - : m_inlineStyleDecl(other.m_inlineStyleDecl) + : RefCounted<ElementAttributeData>() + , m_isMutable(true) + , m_arraySize(0) + , m_inlineStyleDecl(other.m_inlineStyleDecl) , m_attributeStyle(other.m_attributeStyle) , m_classNames(other.m_classNames) , m_idForStyleResolution(other.m_idForStyleResolution) - , m_isMutable(true) - , m_arraySize(0) , m_mutableAttributeVector(new Vector<Attribute, 4>) { // This copy constructor should only be used by makeMutable() to go from immutable to mutable. ASSERT(!other.m_isMutable); + // An immutable ElementAttributeData should never have a mutable inline StylePropertySet attached. + ASSERT(!other.m_inlineStyleDecl || !other.m_inlineStyleDecl->isMutable()); + const Attribute* otherBuffer = reinterpret_cast<const Attribute*>(&other.m_attributes); for (unsigned i = 0; i < other.m_arraySize; ++i) m_mutableAttributeVector->append(otherBuffer[i]); @@ -294,7 +298,7 @@ void ElementAttributeData::detachAttrObjectsFromElement(Element* element) const void ElementAttributeData::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const { size_t actualSize = m_isMutable ? sizeof(ElementAttributeData) : immutableElementAttributeDataSize(m_arraySize); - MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::DOM, actualSize); + MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::DOM, actualSize); info.addInstrumentedMember(m_inlineStyleDecl); info.addInstrumentedMember(m_attributeStyle); info.addMember(m_classNames); @@ -363,9 +367,7 @@ void ElementAttributeData::cloneDataFrom(const ElementAttributeData& sourceData, } if (targetElement.isStyledElement() && sourceData.m_inlineStyleDecl) { - StylePropertySet* inlineStyle = ensureMutableInlineStyle(static_cast<StyledElement*>(&targetElement)); - inlineStyle->copyPropertiesFrom(*sourceData.m_inlineStyleDecl); - inlineStyle->setCSSParserMode(sourceData.m_inlineStyleDecl->cssParserMode()); + m_inlineStyleDecl = sourceData.m_inlineStyleDecl->immutableCopyIfNeeded(); targetElement.setIsStyleAttributeValid(sourceElement.isStyleAttributeValid()); } } @@ -381,17 +383,6 @@ void ElementAttributeData::clearAttributes(Element* element) m_mutableAttributeVector->clear(); } -void ElementAttributeData::replaceAttribute(size_t index, const Attribute& attribute, Element* element) -{ - ASSERT(isMutable()); - ASSERT(element); - ASSERT(index < length()); - - element->willModifyAttribute(attribute.name(), m_mutableAttributeVector->at(index).value(), attribute.value()); - (*m_mutableAttributeVector)[index] = attribute; - element->didModifyAttribute(attribute); -} - PassRefPtr<Attr> ElementAttributeData::getAttributeNode(const String& name, bool shouldIgnoreAttributeCase, Element* element) const { ASSERT(element); |