#ifndef Attribute_h
#define Attribute_h
#include "CSSMappedAttributeDeclaration.h"
#include "QualifiedName.h"
namespace WebCore {
class Attr;
class CSSStyleDeclaration;
class Element;
class NamedNodeMap;
class Attribute : public RefCounted<Attribute> {
friend class Attr;
friend class NamedNodeMap;
public:
static PassRefPtr<Attribute> create(const QualifiedName& name, const AtomicString& value)
{
return adoptRef(new Attribute(name, value, false, 0));
}
const AtomicString& value() const { return m_value; }
const AtomicString& prefix() const { return m_name.prefix(); }
const AtomicString& localName() const { return m_name.localName(); }
const AtomicString& namespaceURI() const { return m_name.namespaceURI(); }
const QualifiedName& name() const { return m_name; }
Attr* attr() const;
PassRefPtr<Attr> createAttrIfNeeded(Element*);
bool isNull() const { return m_value.isNull(); }
bool isEmpty() const { return m_value.isEmpty(); }
PassRefPtr<Attribute> clone() const;
CSSStyleDeclaration* style() const { return m_styleDecl.get(); }
CSSMappedAttributeDeclaration* decl() const { return m_styleDecl.get(); }
void setDecl(PassRefPtr<CSSMappedAttributeDeclaration> decl) { m_styleDecl = decl; }
void setValue(const AtomicString& value) { m_value = value; }
void setPrefix(const AtomicString& prefix) { m_name.setPrefix(prefix); }
bool isMappedAttribute() { return m_isMappedAttribute; }
protected:
Attribute(const QualifiedName& name, const AtomicString& value, bool isMappedAttribute, CSSMappedAttributeDeclaration* styleDecl)
: m_isMappedAttribute(isMappedAttribute)
, m_hasAttr(false)
, m_name(name)
, m_value(value)
, m_styleDecl(styleDecl)
{
}
Attribute(const AtomicString& name, const AtomicString& value, bool isMappedAttribute, CSSMappedAttributeDeclaration* styleDecl)
: m_isMappedAttribute(isMappedAttribute)
, m_hasAttr(false)
, m_name(nullAtom, name, nullAtom)
, m_value(value)
, m_styleDecl(styleDecl)
{
}
private:
void bindAttr(Attr*);
void unbindAttr(Attr*);
bool m_isMappedAttribute;
bool m_hasAttr;
QualifiedName m_name;
AtomicString m_value;
RefPtr<CSSMappedAttributeDeclaration> m_styleDecl;
};
}
#endif // Attribute_h