PassRefPtr<Node> NamedNodeMap::removeNamedItemNS(const String& namespaceURI, const String& localName, ExceptionCode& ec) { ElementAttributeData* attributeData = m_element->attributeData(); size_t index = attributeData->getAttributeItemIndex(QualifiedName(nullAtom, localName, namespaceURI)); if (index == notFound) { ec = NOT_FOUND_ERR; return 0; } return attributeData->takeAttribute(index, m_element); }
PassRefPtr<Node> NamedNodeMap::removeNamedItem(const String& name, ExceptionCode& ec) { ElementAttributeData* attributeData = m_element->attributeData(); size_t index = attributeData->getAttributeItemIndex(name, shouldIgnoreAttributeCase(m_element)); if (index == notFound) { ec = NOT_FOUND_ERR; return 0; } return attributeData->takeAttribute(index, m_element); }
void HTMLConstructionSite::mergeAttributesFromTokenIntoElement(AtomicHTMLToken* token, Element* element) { if (token->attributes().isEmpty()) return; ElementAttributeData* elementAttributeData = element->mutableAttributeData(); for (unsigned i = 0; i < token->attributes().size(); ++i) { const Attribute& tokenAttribute = token->attributes().at(i); if (!elementAttributeData->getAttributeItem(tokenAttribute.name())) element->setAttribute(tokenAttribute.name(), tokenAttribute.value()); } }
ElementAttributeData::ElementAttributeData(const ElementAttributeData& other, bool isMutable) : m_isMutable(isMutable) , m_arraySize(isMutable ? 0 : other.length()) , m_presentationAttributeStyle(other.m_presentationAttributeStyle) , m_classNames(other.m_classNames) , m_idForStyleResolution(other.m_idForStyleResolution) { // NOTE: The inline style is copied by the subclass copy constructor since we don't know what to do with it here. }
void ElementAttributeData::cloneDataFrom(const ElementAttributeData& sourceData, const Element& sourceElement, Element& targetElement) { // FIXME: Cloned elements could start out with immutable attribute data. ASSERT(isMutable()); const AtomicString& oldID = targetElement.getIdAttribute(); const AtomicString& newID = sourceElement.getIdAttribute(); if (!oldID.isNull() || !newID.isNull()) targetElement.updateId(oldID, newID); const AtomicString& oldName = targetElement.getNameAttribute(); const AtomicString& newName = sourceElement.getNameAttribute(); if (!oldName.isNull() || !newName.isNull()) targetElement.updateName(oldName, newName); clearAttributes(); if (sourceData.isMutable()) mutableAttributeVector() = sourceData.mutableAttributeVector(); else { mutableAttributeVector().reserveInitialCapacity(sourceData.m_arraySize); for (unsigned i = 0; i < sourceData.m_arraySize; ++i) mutableAttributeVector().uncheckedAppend(sourceData.immutableAttributeArray()[i]); } for (unsigned i = 0; i < length(); ++i) { const Attribute& attribute = mutableAttributeVector().at(i); if (targetElement.isStyledElement() && attribute.name() == HTMLNames::styleAttr) { static_cast<StyledElement&>(targetElement).styleAttributeChanged(attribute.value(), StyledElement::DoNotReparseStyleAttribute); continue; } targetElement.attributeChanged(attribute.name(), attribute.value()); } if (targetElement.isStyledElement() && sourceData.m_inlineStyleDecl) { m_inlineStyleDecl = sourceData.m_inlineStyleDecl->immutableCopyIfNeeded(); targetElement.setIsStyleAttributeValid(sourceElement.isStyleAttributeValid()); } }
ElementAttributeData::ElementAttributeData(const ElementAttributeData& other, bool isMutable) : m_isMutable(isMutable) , m_arraySize(isMutable ? 0 : other.length()) , m_presentationAttributeStyleIsDirty(other.m_presentationAttributeStyleIsDirty) , m_styleAttributeIsDirty(other.m_styleAttributeIsDirty) #if ENABLE(SVG) , m_animatedSVGAttributesAreDirty(other.m_animatedSVGAttributesAreDirty) #endif , m_classNames(other.m_classNames) , m_idForStyleResolution(other.m_idForStyleResolution) { // NOTE: The inline style is copied by the subclass copy constructor since we don't know what to do with it here. }
void ElementAttributeData::setAttributes(const ElementAttributeData& other, Element* element) { ASSERT(element); // 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 || newId) element->updateId(oldId ? oldId->value() : nullAtom, newId ? newId->value() : nullAtom); Attribute* oldName = getAttributeItem(HTMLNames::nameAttr); Attribute* newName = other.getAttributeItem(HTMLNames::nameAttr); if (oldName || newName) element->updateName(oldName ? oldName->value() : nullAtom, newName ? newName->value() : nullAtom); clearAttributes(element); m_attributes = other.m_attributes; for (unsigned i = 0; i < m_attributes.size(); ++i) element->attributeChanged(&m_attributes[i]); }