NamedMappedAttrMap.cpp [plain text]
#include "config.h"
#include "NamedMappedAttrMap.h"
#include "Document.h"
#include "Element.h"
namespace WebCore {
NamedMappedAttrMap::NamedMappedAttrMap(Element *e)
: NamedAttrMap(e)
, m_mappedAttributeCount(0)
{
}
void NamedMappedAttrMap::clearAttributes()
{
m_classNames.clear();
m_mappedAttributeCount = 0;
NamedAttrMap::clearAttributes();
}
bool NamedMappedAttrMap::isMappedAttributeMap() const
{
return true;
}
int NamedMappedAttrMap::declCount() const
{
int result = 0;
for (unsigned i = 0; i < length(); i++) {
Attribute* attr = attributeItem(i);
if (attr->isMappedAttribute() &&
static_cast<MappedAttribute*>(attr)->decl())
result++;
}
return result;
}
bool NamedMappedAttrMap::mapsEquivalent(const NamedMappedAttrMap* otherMap) const
{
if (declCount() != otherMap->declCount())
return false;
for (unsigned i = 0; i < length(); i++) {
Attribute* attr = attributeItem(i);
if (attr->isMappedAttribute() &&
static_cast<MappedAttribute*>(attr)->decl()) {
Attribute* otherAttr = otherMap->getAttributeItem(attr->name());
if (!otherAttr || (attr->value() != otherAttr->value()))
return false;
}
}
return true;
}
void NamedMappedAttrMap::parseClassAttribute(const String& classStr)
{
if (!element->hasClass()) {
m_classNames.clear();
return;
}
m_classNames.parseClassAttribute(classStr, element->document()->inCompatMode());
}
}