#pragma once
#include "Node.h"
#include "QualifiedName.h"
namespace WebCore {
class Attribute;
class CSSStyleDeclaration;
class MutableStyleProperties;
class Attr final : public Node {
WTF_MAKE_ISO_ALLOCATED(Attr);
public:
static Ref<Attr> create(Element&, const QualifiedName&);
static Ref<Attr> create(Document&, const QualifiedName&, const AtomString& value);
virtual ~Attr();
String name() const { return qualifiedName().toString(); }
bool specified() const { return true; }
Element* ownerElement() const { return m_element; }
WEBCORE_EXPORT const AtomString& value() const;
WEBCORE_EXPORT void setValue(const AtomString&);
const QualifiedName& qualifiedName() const { return m_name; }
WEBCORE_EXPORT CSSStyleDeclaration* style();
void attachToElement(Element&);
void detachFromElementWithValue(const AtomString&);
const AtomString& namespaceURI() const final { return m_name.namespaceURI(); }
const AtomString& localName() const final { return m_name.localName(); }
const AtomString& prefix() const final { return m_name.prefix(); }
private:
Attr(Element&, const QualifiedName&);
Attr(Document&, const QualifiedName&, const AtomString& value);
String nodeName() const final { return name(); }
NodeType nodeType() const final { return ATTRIBUTE_NODE; }
String nodeValue() const final { return value(); }
ExceptionOr<void> setNodeValue(const String&) final;
ExceptionOr<void> setPrefix(const AtomString&) final;
Ref<Node> cloneNodeInternal(Document&, CloningOperation) final;
bool isAttributeNode() const final { return true; }
Attribute& elementAttribute();
Element* m_element { nullptr };
QualifiedName m_name;
AtomString m_standaloneValue;
RefPtr<MutableStyleProperties> m_style;
};
}
SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::Attr)
static bool isType(const WebCore::Node& node) { return node.isAttributeNode(); }
SPECIALIZE_TYPE_TRAITS_END()