diff options
Diffstat (limited to 'Source/WebCore/dom/ElementAttributeData.cpp')
-rw-r--r-- | Source/WebCore/dom/ElementAttributeData.cpp | 44 |
1 files changed, 26 insertions, 18 deletions
diff --git a/Source/WebCore/dom/ElementAttributeData.cpp b/Source/WebCore/dom/ElementAttributeData.cpp index 6527cf90a..da848159b 100644 --- a/Source/WebCore/dom/ElementAttributeData.cpp +++ b/Source/WebCore/dom/ElementAttributeData.cpp @@ -180,7 +180,7 @@ void ElementAttributeData::addAttribute(const Attribute& attribute, Element* ele m_attributes.append(attribute); if (element && inUpdateStyleAttribute == NotInUpdateStyleAttribute) - element->didAddAttribute(const_cast<Attribute*>(&attribute)); + element->didAddAttribute(attribute); } void ElementAttributeData::removeAttribute(size_t index, Element* element, EInUpdateStyleAttribute inUpdateStyleAttribute) @@ -252,28 +252,36 @@ size_t ElementAttributeData::getAttributeItemIndexSlowCase(const String& name, b return notFound; } -void ElementAttributeData::setAttributes(const ElementAttributeData& other, Element* element) +void ElementAttributeData::cloneDataFrom(const ElementAttributeData& sourceData, const Element& sourceElement, Element& targetElement) { - ASSERT(element); + const AtomicString& oldID = targetElement.getIdAttribute(); + const AtomicString& newID = sourceElement.getIdAttribute(); - // If assigning the map changes the id attribute, we need to call - // updateId. - Attribute* oldId = getAttributeItem(element->document()->idAttributeName()); - Attribute* newId = other.getAttributeItem(element->document()->idAttributeName()); + if (!oldID.isNull() || !newID.isNull()) + targetElement.updateId(oldID, newID); - if (oldId || newId) - element->updateId(oldId ? oldId->value() : nullAtom, newId ? newId->value() : nullAtom); + const AtomicString& oldName = targetElement.getNameAttribute(); + const AtomicString& newName = sourceElement.getNameAttribute(); - Attribute* oldName = getAttributeItem(HTMLNames::nameAttr); - Attribute* newName = other.getAttributeItem(HTMLNames::nameAttr); + if (!oldName.isNull() || !newName.isNull()) + targetElement.updateName(oldName, newName); - if (oldName || newName) - element->updateName(oldName ? oldName->value() : nullAtom, newName ? newName->value() : nullAtom); + clearAttributes(&targetElement); + m_attributes = sourceData.m_attributes; + for (unsigned i = 0; i < m_attributes.size(); ++i) { + if (targetElement.isStyledElement() && m_attributes[i].name() == HTMLNames::styleAttr) { + static_cast<StyledElement&>(targetElement).styleAttributeChanged(m_attributes[i].value(), StyledElement::DoNotReparseStyleAttribute); + continue; + } + targetElement.attributeChanged(m_attributes[i]); + } - clearAttributes(element); - m_attributes = other.m_attributes; - for (unsigned i = 0; i < m_attributes.size(); ++i) - element->attributeChanged(&m_attributes[i]); + if (targetElement.isStyledElement() && sourceData.m_inlineStyleDecl) { + StylePropertySet* inlineStyle = ensureMutableInlineStyle(static_cast<StyledElement*>(&targetElement)); + inlineStyle->copyPropertiesFrom(*sourceData.m_inlineStyleDecl); + inlineStyle->setCSSParserMode(sourceData.m_inlineStyleDecl->cssParserMode()); + targetElement.setIsStyleAttributeValid(sourceElement.isStyleAttributeValid()); + } } void ElementAttributeData::clearAttributes(Element* element) @@ -290,7 +298,7 @@ void ElementAttributeData::replaceAttribute(size_t index, const Attribute& attri element->willModifyAttribute(attribute.name(), m_attributes[index].value(), attribute.value()); m_attributes[index] = attribute; - element->didModifyAttribute(const_cast<Attribute*>(&attribute)); + element->didModifyAttribute(attribute); } PassRefPtr<Attr> ElementAttributeData::getAttributeNode(const String& name, bool shouldIgnoreAttributeCase, Element* element) const |