2
* Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3
* (C) 1999 Antti Koivisto (koivisto@kde.org)
4
* (C) 2001 Peter Kelly (pmk@post.com)
5
* (C) 2001 Dirk Mueller (mueller@kde.org)
6
* Copyright (C) 2003, 2004, 2005, 2006, 2007 Apple Inc. All rights reserved.
8
* This library is free software; you can redistribute it and/or
9
* modify it under the terms of the GNU Library General Public
10
* License as published by the Free Software Foundation; either
11
* version 2 of the License, or (at your option) any later version.
13
* This library is distributed in the hope that it will be useful,
14
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16
* Library General Public License for more details.
18
* You should have received a copy of the GNU Library General Public License
19
* along with this library; see the file COPYING.LIB. If not, write to
20
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21
* Boston, MA 02111-1307, USA.
28
#include "ContainerNode.h"
29
#include "QualifiedName.h"
30
#include "ScrollTypes.h"
34
class AtomicStringList;
37
class CSSStyleDeclaration;
38
class ElementRareData;
41
class Element : public ContainerNode {
43
Element(const QualifiedName&, Document*);
46
// Used to quickly determine whether or not an element has a given CSS class.
47
virtual const AtomicStringList* getClassList() const;
48
const AtomicString& getIDAttribute() const;
49
bool hasAttribute(const QualifiedName&) const;
50
const AtomicString& getAttribute(const QualifiedName&) const;
51
void setAttribute(const QualifiedName&, StringImpl* value, ExceptionCode&);
52
void removeAttribute(const QualifiedName&, ExceptionCode&);
54
bool hasAttributes() const;
56
bool hasAttribute(const String& name) const;
57
bool hasAttributeNS(const String& namespaceURI, const String& localName) const;
59
const AtomicString& getAttribute(const String& name) const;
60
const AtomicString& getAttributeNS(const String& namespaceURI, const String& localName) const;
62
void setAttribute(const String& name, const String& value, ExceptionCode&);
63
void setAttributeNS(const String& namespaceURI, const String& qualifiedName, const String& value, ExceptionCode&);
65
void scrollIntoView (bool alignToTop = true);
66
void scrollIntoViewIfNeeded(bool centerIfNeeded = true);
68
void scrollByUnits(int units, ScrollGranularity);
69
void scrollByLines(int lines);
70
void scrollByPages(int pages);
76
Element* offsetParent();
83
void setScrollLeft(int);
84
void setScrollTop(int);
88
void removeAttribute(const String& name, ExceptionCode&);
89
void removeAttributeNS(const String& namespaceURI, const String& localName, ExceptionCode&);
91
PassRefPtr<Attr> getAttributeNode(const String& name);
92
PassRefPtr<Attr> getAttributeNodeNS(const String& namespaceURI, const String& localName);
93
PassRefPtr<Attr> setAttributeNode(Attr*, ExceptionCode&);
94
PassRefPtr<Attr> setAttributeNodeNS(Attr*, ExceptionCode&);
95
PassRefPtr<Attr> removeAttributeNode(Attr*, ExceptionCode&);
97
virtual CSSStyleDeclaration* style();
99
const QualifiedName& tagQName() const { return m_tagName; }
100
String tagName() const { return nodeName(); }
101
virtual bool hasTagName(const QualifiedName& tagName) const { return m_tagName.matches(tagName); }
103
// A fast function for checking the local name against another atomic string.
104
bool hasLocalName(const AtomicString& other) const { return m_tagName.localName() == other; }
105
bool hasLocalName(const QualifiedName& other) const { return m_tagName.localName() == other.localName(); }
107
virtual const AtomicString& localName() const { return m_tagName.localName(); }
108
virtual const AtomicString& prefix() const { return m_tagName.prefix(); }
109
virtual void setPrefix(const AtomicString &_prefix, ExceptionCode&);
110
virtual const AtomicString& namespaceURI() const { return m_tagName.namespaceURI(); }
112
virtual String baseURI() const;
114
// DOM methods overridden from parent classes
115
virtual NodeType nodeType() const;
116
virtual PassRefPtr<Node> cloneNode(bool deep);
117
virtual String nodeName() const;
118
virtual bool isElementNode() const { return true; }
119
virtual void insertedIntoDocument();
120
virtual void removedFromDocument();
122
String nodeNamePreservingCase() const;
124
// convenience methods which ignore exceptions
125
void setAttribute(const QualifiedName&, const String& value);
127
virtual NamedAttrMap* attributes() const;
128
NamedAttrMap* attributes(bool readonly) const;
130
// This method is called whenever an attribute is added, changed or removed.
131
virtual void attributeChanged(Attribute*, bool preserveDecls = false) {}
133
// not part of the DOM
134
void setAttributeMap(NamedAttrMap*);
136
virtual void copyNonAttributeProperties(const Element* source) {}
138
virtual void attach();
139
virtual void detach();
140
virtual RenderStyle* styleForRenderer(RenderObject* parent);
141
virtual RenderObject* createRenderer(RenderArena*, RenderStyle*);
142
virtual void recalcStyle(StyleChange = NoChange);
144
virtual RenderStyle* computedStyle();
146
virtual bool childTypeAllowed(NodeType);
148
virtual Attribute* createAttribute(const QualifiedName& name, StringImpl* value);
150
void dispatchAttrRemovalEvent(Attribute*);
151
void dispatchAttrAdditionEvent(Attribute*);
153
virtual void accessKeyAction(bool sendToAnyEvent) { }
155
virtual String toString() const;
157
virtual bool isURLAttribute(Attribute*) const;
158
virtual String target() const { return String(); }
160
virtual void focus(bool restorePreviousSelection = true);
161
virtual void updateFocusAppearance(bool restorePreviousSelection);
165
virtual void dump(TextStream* , DeprecatedString ind = "") const;
166
virtual void formatForDebugger(char* buffer, unsigned length) const;
169
Node* insertAdjacentElement(const String& where, Node* newChild, ExceptionCode&);
170
bool contains(const Node*) const;
172
String innerText() const;
173
String outerText() const;
175
virtual String title() const;
177
String openTagStartToString() const;
179
void updateId(const AtomicString& oldId, const AtomicString& newId);
181
IntSize minimumSizeForResizing() const;
182
void setMinimumSizeForResizing(const IntSize&);
184
// The following method is called when a Document is restored from the page cache
185
// and the element has registered itself with the Document via registerForDidRestorePageCallback()
186
virtual void didRestoreFromCache() { }
189
ElementRareData* rareData();
190
const ElementRareData* rareData() const;
191
ElementRareData* createRareData();
193
virtual void createAttributeMap() const;
195
virtual void updateStyleAttributeIfNeeded() const {}
197
void updateFocusAppearanceSoonAfterAttach();
198
void cancelFocusAppearanceUpdate();
201
mutable RefPtr<NamedAttrMap> namedAttrMap;
204
QualifiedName m_tagName;