#ifndef Element_h
#define Element_h
#include "Attr.h"
#include "ScrollBar.h"
#include "Timer.h"
#include "RenderStyle.h"
namespace WebCore {
class AtomicStringList;
class Attribute;
class Element : public ContainerNode {
friend class Document;
friend class NamedAttrMap;
friend class Attr;
friend class Node;
friend class CSSStyleSelector;
public:
Element(const QualifiedName&, Document*);
~Element();
virtual const AtomicStringList* getClassList() const;
const AtomicString& getIDAttribute() const;
bool hasAttribute(const QualifiedName& name) const;
const AtomicString& getAttribute(const QualifiedName& name) const;
void setAttribute(const QualifiedName& name, StringImpl* value, ExceptionCode&);
void removeAttribute(const QualifiedName& name, ExceptionCode&);
bool hasAttributes() const;
bool hasAttribute(const String& name) const;
bool hasAttributeNS(const String& namespaceURI, const String& localName) const;
const AtomicString& getAttribute(const String& name) const;
const AtomicString& getAttributeNS(const String& namespaceURI, const String& localName) const;
void setAttribute(const String& name, const String& value, ExceptionCode&);
void setAttributeNS(const String& namespaceURI, const String& qualifiedName, const String& value, ExceptionCode&);
void scrollIntoView (bool alignToTop);
void scrollIntoViewIfNeeded(bool centerIfNeeded);
void scrollByUnits(int units, ScrollGranularity granularity);
void scrollByLines(int lines);
void scrollByPages(int pages);
int offsetLeft();
int offsetTop();
int offsetWidth();
int offsetHeight();
Element* offsetParent();
int clientWidth();
int clientHeight();
int scrollLeft();
int scrollTop();
void setScrollLeft(int);
void setScrollTop(int);
int scrollWidth();
int scrollHeight();
void removeAttribute(const String &name, ExceptionCode& ec);
void removeAttributeNS(const String &namespaceURI, const String& localName, ExceptionCode&);
PassRefPtr<Attr> getAttributeNode(const String& name);
PassRefPtr<Attr> getAttributeNodeNS(const String& namespaceURI, const String& localName);
PassRefPtr<Attr> setAttributeNode(Attr*, ExceptionCode&);
PassRefPtr<Attr> setAttributeNodeNS(Attr* newAttr, ExceptionCode& ec) { return setAttributeNode(newAttr, ec); }
PassRefPtr<Attr> removeAttributeNode(Attr*, ExceptionCode&);
virtual CSSStyleDeclaration *style();
const QualifiedName& tagQName() const { return m_tagName; }
String tagName() const { return nodeName(); }
virtual bool hasTagName(const QualifiedName& tagName) const { return m_tagName.matches(tagName); }
bool hasLocalName(const AtomicString& other) const { return m_tagName.localName() == other; }
bool hasLocalName(const QualifiedName& other) const { return m_tagName.localName() == other.localName(); }
virtual const AtomicString& localName() const { return m_tagName.localName(); }
virtual const AtomicString& prefix() const { return m_tagName.prefix(); }
virtual void setPrefix(const AtomicString &_prefix, ExceptionCode&);
virtual const AtomicString& namespaceURI() const { return m_tagName.namespaceURI(); }
virtual NodeType nodeType() const;
virtual PassRefPtr<Node> cloneNode(bool deep);
virtual String nodeName() const;
virtual bool isElementNode() const { return true; }
virtual void insertedIntoDocument();
virtual void removedFromDocument();
String nodeNamePreservingCase() const;
void setAttribute(const QualifiedName& name, const String& value);
virtual NamedAttrMap *attributes() const;
NamedAttrMap* attributes(bool readonly) const;
virtual void attributeChanged(Attribute* attr, bool preserveDecls = false) {}
void setAttributeMap(NamedAttrMap*);
virtual void copyNonAttributeProperties(const Element *source) {}
virtual void attach();
virtual void detach();
virtual RenderStyle *styleForRenderer(RenderObject *parent);
virtual RenderObject *createRenderer(RenderArena *, RenderStyle *);
virtual void recalcStyle( StyleChange = NoChange );
virtual bool childTypeAllowed(NodeType);
virtual Attribute* createAttribute(const QualifiedName& name, StringImpl* value);
void dispatchAttrRemovalEvent(Attribute *attr);
void dispatchAttrAdditionEvent(Attribute *attr);
virtual void accessKeyAction(bool sendToAnyEvent) { }
virtual String toString() const;
virtual bool isURLAttribute(Attribute *attr) const;
virtual void focus();
virtual void updateFocusAppearance();
void blur();
bool needsFocusAppearanceUpdate() const { return m_needsFocusAppearanceUpdate; }
void setNeedsFocusAppearanceUpdate(bool b) { m_needsFocusAppearanceUpdate = b; }
#if !NDEBUG
virtual void dump(TextStream *stream, DeprecatedString ind = "") const;
virtual void formatForDebugger(char *buffer, unsigned length) const;
#endif
Node* insertAdjacentElement(const String& where, Node* newChild, int& exception);
bool contains(const Element*) const;
EVisibility implicitVisibility();
protected:
virtual void createAttributeMap() const;
String openTagStartToString() const;
virtual void didRestoreFromCache() { }
private:
void updateId(const AtomicString& oldId, const AtomicString& newId);
virtual void updateStyleAttributeIfNeeded() const {}
void updateFocusAppearanceTimerFired(Timer<Element>*);
void stopUpdateFocusAppearanceTimer();
Timer<Element> m_updateFocusAppearanceTimer;
bool m_needsFocusAppearanceUpdate;
protected: mutable RefPtr<NamedAttrMap> namedAttrMap;
QualifiedName m_tagName;
};
}
#endif