]> git.saurik.com Git - iphone-api.git/blob - WebCore/Attr.h
Adding the WebCore headers (for Cydget).
[iphone-api.git] / WebCore / Attr.h
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, 2008 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., 51 Franklin Street, Fifth Floor,
21 * Boston, MA 02110-1301, USA.
22 *
23 */
24
25 #ifndef Attr_h
26 #define Attr_h
27
28 #include "ContainerNode.h"
29 #include "Attribute.h"
30
31 namespace WebCore {
32
33 // Attr can have Text and EntityReference children
34 // therefore it has to be a fullblown Node. The plan
35 // is to dynamically allocate a textchild and store the
36 // resulting nodevalue in the Attribute upon
37 // destruction. however, this is not yet implemented.
38
39 class Attr : public ContainerNode {
40 friend class NamedAttrMap;
41 public:
42 Attr(Element*, Document*, PassRefPtr<Attribute>);
43 ~Attr();
44
45 // Call this after calling the constructor so the
46 // Attr node isn't floating when we append the text node.
47 void createTextChild();
48
49 // DOM methods & attributes for Attr
50 String name() const { return qualifiedName().toString(); }
51 bool specified() const { return m_specified; }
52 Element* ownerElement() const { return m_element; }
53
54 String value() const { return m_attribute->value(); }
55 void setValue(const String&, ExceptionCode&);
56
57 // DOM methods overridden from parent classes
58 virtual String nodeName() const;
59 virtual NodeType nodeType() const;
60 const AtomicString& localName() const;
61 const AtomicString& namespaceURI() const;
62 const AtomicString& prefix() const;
63 virtual void setPrefix(const AtomicString&, ExceptionCode&);
64
65 virtual String nodeValue() const;
66 virtual void setNodeValue(const String&, ExceptionCode&);
67 virtual PassRefPtr<Node> cloneNode(bool deep);
68
69 // Other methods (not part of DOM)
70 virtual bool isAttributeNode() const { return true; }
71 virtual bool childTypeAllowed(NodeType);
72
73 virtual void childrenChanged(bool changedByParser = false, Node* beforeChange = 0, Node* afterChange = 0, int childCountDelta = 0);
74
75 Attribute* attr() const { return m_attribute.get(); }
76 const QualifiedName& qualifiedName() const { return m_attribute->name(); }
77
78 // An extension to get presentational information for attributes.
79 CSSStyleDeclaration* style() { return m_attribute->style(); }
80
81 void setSpecified(bool specified) { m_specified = specified; }
82
83 private:
84 virtual const AtomicString& virtualPrefix() const { return prefix(); }
85 virtual const AtomicString& virtualLocalName() const { return localName(); }
86 virtual const AtomicString& virtualNamespaceURI() const { return namespaceURI(); }
87
88 Element* m_element;
89 RefPtr<Attribute> m_attribute;
90 unsigned m_ignoreChildrenChanged : 31;
91 bool m_specified : 1;
92 };
93
94 } // namespace WebCore
95
96 #endif // Attr_h