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, 2009 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 NamedNodeMap; 41 public: 42 static PassRefPtr<Attr> create(Element*, Document*, PassRefPtr<Attribute>); 43 virtual ~Attr(); 44 name()45 String name() const { return qualifiedName().toString(); } specified()46 bool specified() const { return m_specified; } ownerElement()47 Element* ownerElement() const { return m_element; } 48 value()49 const AtomicString& value() const { return m_attribute->value(); } 50 void setValue(const AtomicString&, ExceptionCode&); 51 void setValue(const AtomicString&); 52 attr()53 Attribute* attr() const { return m_attribute.get(); } qualifiedName()54 const QualifiedName& qualifiedName() const { return m_attribute->name(); } 55 56 bool isId() const; 57 58 // An extension to get presentational information for attributes. style()59 CSSStyleDeclaration* style() { return m_attribute->style(); } 60 setSpecified(bool specified)61 void setSpecified(bool specified) { m_specified = specified; } 62 63 private: 64 Attr(Element*, Document*, PassRefPtr<Attribute>); 65 66 void createTextChild(); 67 68 virtual String nodeName() const; 69 virtual NodeType nodeType() const; 70 71 const AtomicString& localName() const; 72 const AtomicString& namespaceURI() const; 73 const AtomicString& prefix() const; 74 75 virtual void setPrefix(const AtomicString&, ExceptionCode&); 76 77 virtual String nodeValue() const; 78 virtual void setNodeValue(const String&, ExceptionCode&); 79 virtual PassRefPtr<Node> cloneNode(bool deep); 80 isAttributeNode()81 virtual bool isAttributeNode() const { return true; } 82 virtual bool childTypeAllowed(NodeType) const; 83 84 virtual void childrenChanged(bool changedByParser = false, Node* beforeChange = 0, Node* afterChange = 0, int childCountDelta = 0); 85 virtualPrefix()86 virtual const AtomicString& virtualPrefix() const { return prefix(); } virtualLocalName()87 virtual const AtomicString& virtualLocalName() const { return localName(); } virtualNamespaceURI()88 virtual const AtomicString& virtualNamespaceURI() const { return namespaceURI(); } 89 90 Element* m_element; 91 RefPtr<Attribute> m_attribute; 92 unsigned m_ignoreChildrenChanged : 31; 93 bool m_specified : 1; 94 }; 95 96 } // namespace WebCore 97 98 #endif // Attr_h 99