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

« back to all changes in this revision

Viewing changes to WebCore/dom/Attr.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 Attr_h
 
26
#define Attr_h
 
27
 
 
28
#include "ContainerNode.h"
 
29
#include "Attribute.h"
 
30
 
 
31
namespace WebCore {
 
32
 
 
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.
 
38
 
 
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.
 
44
 
 
45
class Attr : public ContainerNode {
 
46
    friend class NamedAttrMap;
 
47
 
 
48
public:
 
49
    Attr(Element*, Document*, Attribute*);
 
50
    ~Attr();
 
51
 
 
52
    // Call this after calling the constructor so the
 
53
    // Attr node isn't floating when we append the text node.
 
54
    void createTextChild();
 
55
    
 
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; }
 
60
 
 
61
    String value() const { return m_attribute->value(); }
 
62
    void setValue(const String&, ExceptionCode&);
 
63
 
 
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&);
 
71
 
 
72
    virtual String nodeValue() const;
 
73
    virtual void setNodeValue(const String&, ExceptionCode&);
 
74
    virtual PassRefPtr<Node> cloneNode(bool deep);
 
75
 
 
76
    // Other methods (not part of DOM)
 
77
    virtual bool isAttributeNode() const { return true; }
 
78
    virtual bool childTypeAllowed(NodeType);
 
79
 
 
80
    virtual void childrenChanged();
 
81
    virtual String toString() const;
 
82
 
 
83
    Attribute* attr() const { return m_attribute.get(); }
 
84
    const QualifiedName& qualifiedName() const { return m_attribute->name(); }
 
85
 
 
86
    // An extension to get presentational information for attributes.
 
87
    CSSStyleDeclaration* style() { return m_attribute->style(); }
 
88
 
 
89
    void setSpecified(bool specified) { m_attrWasSpecifiedOrElementHasRareData = specified; }
 
90
 
 
91
private:
 
92
    Element* m_element;
 
93
    RefPtr<Attribute> m_attribute;
 
94
    int m_ignoreChildrenChanged;
 
95
};
 
96
 
 
97
} //namespace
 
98
 
 
99
#endif