~ubuntu-branches/ubuntu/maverick/webkit/maverick

« back to all changes in this revision

Viewing changes to WebCore/dom/Element.h

  • Committer: Bazaar Package Importer
  • Author(s): Mike Hommey
  • Date: 2007-08-19 15:54:12 UTC
  • Revision ID: james.westby@ubuntu.com-20070819155412-uxxg1h9plpghmtbi
Tags: upstream-0~svn25144
ImportĀ upstreamĀ versionĀ 0~svn25144

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
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.
 
7
 *
 
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.
 
12
 *
 
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.
 
17
 *
 
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.
 
22
 *
 
23
 */
 
24
 
 
25
#ifndef Element_h
 
26
#define Element_h
 
27
 
 
28
#include "ContainerNode.h"
 
29
#include "QualifiedName.h"
 
30
#include "ScrollTypes.h"
 
31
 
 
32
namespace WebCore {
 
33
 
 
34
class AtomicStringList;
 
35
class Attr;
 
36
class Attribute;
 
37
class CSSStyleDeclaration;
 
38
class ElementRareData;
 
39
class IntSize;
 
40
 
 
41
class Element : public ContainerNode {
 
42
public:
 
43
    Element(const QualifiedName&, Document*);
 
44
    ~Element();
 
45
 
 
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&);
 
53
 
 
54
    bool hasAttributes() const;
 
55
 
 
56
    bool hasAttribute(const String& name) const;
 
57
    bool hasAttributeNS(const String& namespaceURI, const String& localName) const;
 
58
 
 
59
    const AtomicString& getAttribute(const String& name) const;
 
60
    const AtomicString& getAttributeNS(const String& namespaceURI, const String& localName) const;
 
61
 
 
62
    void setAttribute(const String& name, const String& value, ExceptionCode&);
 
63
    void setAttributeNS(const String& namespaceURI, const String& qualifiedName, const String& value, ExceptionCode&);
 
64
 
 
65
    void scrollIntoView (bool alignToTop = true);
 
66
    void scrollIntoViewIfNeeded(bool centerIfNeeded = true);
 
67
 
 
68
    void scrollByUnits(int units, ScrollGranularity);
 
69
    void scrollByLines(int lines);
 
70
    void scrollByPages(int pages);
 
71
 
 
72
    int offsetLeft();
 
73
    int offsetTop();
 
74
    int offsetWidth();
 
75
    int offsetHeight();
 
76
    Element* offsetParent();
 
77
    int clientLeft();
 
78
    int clientTop();
 
79
    int clientWidth();
 
80
    int clientHeight();
 
81
    int scrollLeft();
 
82
    int scrollTop();
 
83
    void setScrollLeft(int);
 
84
    void setScrollTop(int);
 
85
    int scrollWidth();
 
86
    int scrollHeight();
 
87
 
 
88
    void removeAttribute(const String& name, ExceptionCode&);
 
89
    void removeAttributeNS(const String& namespaceURI, const String& localName, ExceptionCode&);
 
90
 
 
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&);
 
96
    
 
97
    virtual CSSStyleDeclaration* style();
 
98
 
 
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); }
 
102
    
 
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(); }
 
106
 
 
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(); }
 
111
 
 
112
    virtual String baseURI() const;
 
113
 
 
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();
 
121
 
 
122
    String nodeNamePreservingCase() const;
 
123
 
 
124
    // convenience methods which ignore exceptions
 
125
    void setAttribute(const QualifiedName&, const String& value);
 
126
 
 
127
    virtual NamedAttrMap* attributes() const;
 
128
    NamedAttrMap* attributes(bool readonly) const;
 
129
 
 
130
    // This method is called whenever an attribute is added, changed or removed.
 
131
    virtual void attributeChanged(Attribute*, bool preserveDecls = false) {}
 
132
 
 
133
    // not part of the DOM
 
134
    void setAttributeMap(NamedAttrMap*);
 
135
 
 
136
    virtual void copyNonAttributeProperties(const Element* source) {}
 
137
 
 
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);
 
143
 
 
144
    virtual RenderStyle* computedStyle();
 
145
 
 
146
    virtual bool childTypeAllowed(NodeType);
 
147
 
 
148
    virtual Attribute* createAttribute(const QualifiedName& name, StringImpl* value);
 
149
    
 
150
    void dispatchAttrRemovalEvent(Attribute*);
 
151
    void dispatchAttrAdditionEvent(Attribute*);
 
152
 
 
153
    virtual void accessKeyAction(bool sendToAnyEvent) { }
 
154
 
 
155
    virtual String toString() const;
 
156
 
 
157
    virtual bool isURLAttribute(Attribute*) const;
 
158
    virtual String target() const { return String(); }
 
159
        
 
160
    virtual void focus(bool restorePreviousSelection = true);
 
161
    virtual void updateFocusAppearance(bool restorePreviousSelection);
 
162
    void blur();
 
163
 
 
164
#ifndef NDEBUG
 
165
    virtual void dump(TextStream* , DeprecatedString ind = "") const;
 
166
    virtual void formatForDebugger(char* buffer, unsigned length) const;
 
167
#endif
 
168
 
 
169
    Node* insertAdjacentElement(const String& where, Node* newChild, ExceptionCode&);
 
170
    bool contains(const Node*) const;
 
171
 
 
172
    String innerText() const;
 
173
    String outerText() const;
 
174
 
 
175
    virtual String title() const;
 
176
 
 
177
    String openTagStartToString() const;
 
178
 
 
179
    void updateId(const AtomicString& oldId, const AtomicString& newId);
 
180
 
 
181
    IntSize minimumSizeForResizing() const;
 
182
    void setMinimumSizeForResizing(const IntSize&);
 
183
 
 
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() { }
 
187
    
 
188
private:
 
189
    ElementRareData* rareData();
 
190
    const ElementRareData* rareData() const;
 
191
    ElementRareData* createRareData();
 
192
 
 
193
    virtual void createAttributeMap() const;
 
194
 
 
195
    virtual void updateStyleAttributeIfNeeded() const {}
 
196
    
 
197
    void updateFocusAppearanceSoonAfterAttach();
 
198
    void cancelFocusAppearanceUpdate();
 
199
 
 
200
protected:
 
201
    mutable RefPtr<NamedAttrMap> namedAttrMap;
 
202
 
 
203
private:
 
204
    QualifiedName m_tagName;
 
205
};
 
206
 
 
207
} //namespace
 
208
 
 
209
#endif