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 "Attribute.h"
33
// this has no counterpart in DOM, purely internal
34
// representation of the nodevalue of an Attr.
35
// the actual Attr (Attr) with its value as textchild
36
// is only allocated on demand by the DOM bindings.
37
// Any use of Attr inside khtml should be avoided.
39
// Attr can have Text and EntityReference children
40
// therefore it has to be a fullblown Node. The plan
41
// is to dynamically allocate a textchild and store the
42
// resulting nodevalue in the Attribute upon
43
// destruction. however, this is not yet implemented.
45
class Attr : public ContainerNode {
46
friend class NamedAttrMap;
49
Attr(Element*, Document*, Attribute*);
52
// Call this after calling the constructor so the
53
// Attr node isn't floating when we append the text node.
54
void createTextChild();
56
// DOM methods & attributes for Attr
57
String name() const { return qualifiedName().toString(); }
58
bool specified() const { return m_attrWasSpecifiedOrElementHasRareData; }
59
Element* ownerElement() const { return m_element; }
61
String value() const { return m_attribute->value(); }
62
void setValue(const String&, ExceptionCode&);
64
// DOM methods overridden from parent classes
65
virtual String nodeName() const;
66
virtual NodeType nodeType() const;
67
virtual const AtomicString& localName() const;
68
virtual const AtomicString& namespaceURI() const;
69
virtual const AtomicString& prefix() const;
70
virtual void setPrefix(const AtomicString&, ExceptionCode&);
72
virtual String nodeValue() const;
73
virtual void setNodeValue(const String&, ExceptionCode&);
74
virtual PassRefPtr<Node> cloneNode(bool deep);
76
// Other methods (not part of DOM)
77
virtual bool isAttributeNode() const { return true; }
78
virtual bool childTypeAllowed(NodeType);
80
virtual void childrenChanged();
81
virtual String toString() const;
83
Attribute* attr() const { return m_attribute.get(); }
84
const QualifiedName& qualifiedName() const { return m_attribute->name(); }
86
// An extension to get presentational information for attributes.
87
CSSStyleDeclaration* style() { return m_attribute->style(); }
89
void setSpecified(bool specified) { m_attrWasSpecifiedOrElementHasRareData = specified; }
93
RefPtr<Attribute> m_attribute;
94
int m_ignoreChildrenChanged;