|
1 /* |
|
2 * This file is part of the DOM implementation for KDE. |
|
3 * |
|
4 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
|
5 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
|
6 * (C) 2001 Peter Kelly (pmk@post.com) |
|
7 * (C) 2001 Dirk Mueller (mueller@kde.org) |
|
8 * Copyright (C) 2003, 2004, 2005, 2006 Apple Computer, Inc. |
|
9 * |
|
10 * This library is free software; you can redistribute it and/or |
|
11 * modify it under the terms of the GNU Library General Public |
|
12 * License as published by the Free Software Foundation; either |
|
13 * version 2 of the License, or (at your option) any later version. |
|
14 * |
|
15 * This library is distributed in the hope that it will be useful, |
|
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
18 * Library General Public License for more details. |
|
19 * |
|
20 * You should have received a copy of the GNU Library General Public License |
|
21 * along with this library; see the file COPYING.LIB. If not, write to |
|
22 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
|
23 * Boston, MA 02110-1301, USA. |
|
24 * |
|
25 */ |
|
26 |
|
27 #ifndef NamedAttrMap_h |
|
28 #define NamedAttrMap_h |
|
29 |
|
30 #include "Attribute.h" |
|
31 #include "NamedNodeMap.h" |
|
32 |
|
33 #ifdef __OBJC__ |
|
34 #define id id_AVOID_KEYWORD |
|
35 #endif |
|
36 |
|
37 namespace WebCore { |
|
38 |
|
39 // the map of attributes of an element |
|
40 class NamedAttrMap : public NamedNodeMap { |
|
41 friend class Element; |
|
42 public: |
|
43 NamedAttrMap(Element*); |
|
44 virtual ~NamedAttrMap(); |
|
45 NamedAttrMap(const NamedAttrMap&); |
|
46 NamedAttrMap &operator =(const NamedAttrMap &other); |
|
47 |
|
48 // DOM methods & attributes for NamedNodeMap |
|
49 |
|
50 virtual PassRefPtr<Node> getNamedItem(const String& name) const; |
|
51 virtual PassRefPtr<Node> removeNamedItem(const String& name, ExceptionCode&); |
|
52 |
|
53 virtual PassRefPtr<Node> getNamedItemNS(const String& namespaceURI, const String& localName) const; |
|
54 virtual PassRefPtr<Node> removeNamedItemNS(const String& namespaceURI, const String& localName, ExceptionCode&); |
|
55 |
|
56 virtual PassRefPtr<Node> getNamedItem(const QualifiedName& name) const; |
|
57 virtual PassRefPtr<Node> removeNamedItem(const QualifiedName& name, ExceptionCode&); |
|
58 virtual PassRefPtr<Node> setNamedItem(Node* arg, ExceptionCode&); |
|
59 |
|
60 virtual PassRefPtr<Node> item(unsigned index) const; |
|
61 unsigned length() const { return len; } |
|
62 |
|
63 // Other methods (not part of DOM) |
|
64 Attribute* attributeItem(unsigned index) const { return attrs[index]; } |
|
65 Attribute* getAttributeItem(const QualifiedName& name) const; |
|
66 Attribute* getAttributeItem(const String& name) const; |
|
67 virtual bool isReadOnlyNode(); |
|
68 |
|
69 // used during parsing: only inserts if not already there |
|
70 // no error checking! |
|
71 void insertAttribute(Attribute* newAttribute, bool allowDuplicates) { |
|
72 ASSERT(!element); |
|
73 if (allowDuplicates || !getAttributeItem(newAttribute->name())) |
|
74 addAttribute(newAttribute); |
|
75 else |
|
76 newAttribute->deref(); |
|
77 } |
|
78 |
|
79 virtual bool isMappedAttributeMap() const; |
|
80 |
|
81 const AtomicString& id() const { return m_id; } |
|
82 void setID(const AtomicString& _id) { m_id = _id; } |
|
83 |
|
84 bool mapsEquivalent(const NamedAttrMap* otherMap) const; |
|
85 |
|
86 protected: |
|
87 // this method is internal, does no error checking at all |
|
88 void addAttribute(Attribute* newAttribute); |
|
89 // this method is internal, does no error checking at all |
|
90 void removeAttribute(const QualifiedName& name); |
|
91 virtual void clearAttributes(); |
|
92 void detachFromElement(); |
|
93 |
|
94 Element *element; |
|
95 Attribute **attrs; |
|
96 unsigned len; |
|
97 AtomicString m_id; |
|
98 }; |
|
99 |
|
100 } //namespace |
|
101 |
|
102 #undef id |
|
103 |
|
104 #endif |