summaryrefslogtreecommitdiff
path: root/Source/WebCore/dom/ElementAttributeData.cpp
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@nokia.com>2012-05-18 14:03:11 +0200
committerSimon Hausmann <simon.hausmann@nokia.com>2012-05-18 14:03:11 +0200
commit8d473cf9743f1d30a16a27114e93bd5af5648d23 (patch)
treecdca40d0353886b3ca52f33a2d7b8f1c0011aafc /Source/WebCore/dom/ElementAttributeData.cpp
parent1b914638db989aaa98631a1c1e02c7b2d44805d8 (diff)
downloadqtwebkit-8d473cf9743f1d30a16a27114e93bd5af5648d23.tar.gz
Imported WebKit commit 1350e72f7345ced9da2bd9980deeeb5a8d62fab4 (http://svn.webkit.org/repository/webkit/trunk@117578)
Weekly snapshot
Diffstat (limited to 'Source/WebCore/dom/ElementAttributeData.cpp')
-rw-r--r--Source/WebCore/dom/ElementAttributeData.cpp44
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