OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
4 * (C) 2001 Peter Kelly (pmk@post.com) | 4 * (C) 2001 Peter Kelly (pmk@post.com) |
5 * (C) 2001 Dirk Mueller (mueller@kde.org) | 5 * (C) 2001 Dirk Mueller (mueller@kde.org) |
6 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights
reserved. | 6 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights
reserved. |
7 * | 7 * |
8 * This library is free software; you can redistribute it and/or | 8 * This library is free software; you can redistribute it and/or |
9 * modify it under the terms of the GNU Library General Public | 9 * modify it under the terms of the GNU Library General Public |
10 * License as published by the Free Software Foundation; either | 10 * License as published by the Free Software Foundation; either |
(...skipping 18 matching lines...) Expand all Loading... |
29 #include "core/dom/Node.h" | 29 #include "core/dom/Node.h" |
30 #include "core/dom/QualifiedName.h" | 30 #include "core/dom/QualifiedName.h" |
31 | 31 |
32 namespace blink { | 32 namespace blink { |
33 | 33 |
34 class CORE_EXPORT Attr final : public Node { | 34 class CORE_EXPORT Attr final : public Node { |
35 DEFINE_WRAPPERTYPEINFO(); | 35 DEFINE_WRAPPERTYPEINFO(); |
36 public: | 36 public: |
37 static PassRefPtrWillBeRawPtr<Attr> create(Element&, const QualifiedName&); | 37 static PassRefPtrWillBeRawPtr<Attr> create(Element&, const QualifiedName&); |
38 static PassRefPtrWillBeRawPtr<Attr> create(Document&, const QualifiedName&,
const AtomicString& value); | 38 static PassRefPtrWillBeRawPtr<Attr> create(Document&, const QualifiedName&,
const AtomicString& value); |
39 virtual ~Attr(); | 39 ~Attr() override; |
40 | 40 |
41 String name() const { return m_name.toString(); } | 41 String name() const { return m_name.toString(); } |
42 bool specified() const { return true; } | 42 bool specified() const { return true; } |
43 Element* ownerElement() const { return m_element; } | 43 Element* ownerElement() const { return m_element; } |
44 | 44 |
45 const AtomicString& value() const; | 45 const AtomicString& value() const; |
46 void setValue(const AtomicString&); | 46 void setValue(const AtomicString&); |
47 | 47 |
48 const AtomicString& valueForBindings() const; | 48 const AtomicString& valueForBindings() const; |
49 void setValueForBindings(const AtomicString&); | 49 void setValueForBindings(const AtomicString&); |
50 | 50 |
51 const QualifiedName qualifiedName() const; | 51 const QualifiedName qualifiedName() const; |
52 | 52 |
53 void attachToElement(Element*, const AtomicString&); | 53 void attachToElement(Element*, const AtomicString&); |
54 void detachFromElementWithValue(const AtomicString&); | 54 void detachFromElementWithValue(const AtomicString&); |
55 | 55 |
56 virtual const AtomicString& localName() const override { return m_name.local
Name(); } | 56 const AtomicString& localName() const override { return m_name.localName();
} |
57 virtual const AtomicString& namespaceURI() const override { return m_name.na
mespaceURI(); } | 57 const AtomicString& namespaceURI() const override { return m_name.namespaceU
RI(); } |
58 const AtomicString& prefix() const { return m_name.prefix(); } | 58 const AtomicString& prefix() const { return m_name.prefix(); } |
59 | 59 |
60 DECLARE_VIRTUAL_TRACE(); | 60 DECLARE_VIRTUAL_TRACE(); |
61 | 61 |
62 private: | 62 private: |
63 Attr(Element&, const QualifiedName&); | 63 Attr(Element&, const QualifiedName&); |
64 Attr(Document&, const QualifiedName&, const AtomicString& value); | 64 Attr(Document&, const QualifiedName&, const AtomicString& value); |
65 | 65 |
66 bool isElementNode() const = delete; // This will catch anyone doing an unne
cessary check. | 66 bool isElementNode() const = delete; // This will catch anyone doing an unne
cessary check. |
67 | 67 |
68 virtual String nodeName() const override { return name(); } | 68 String nodeName() const override { return name(); } |
69 virtual NodeType nodeType() const override { return ATTRIBUTE_NODE; } | 69 NodeType nodeType() const override { return ATTRIBUTE_NODE; } |
70 | 70 |
71 virtual String nodeValue() const override { return value(); } | 71 String nodeValue() const override { return value(); } |
72 virtual void setNodeValue(const String&) override; | 72 void setNodeValue(const String&) override; |
73 virtual PassRefPtrWillBeRawPtr<Node> cloneNode(bool deep = true) override; | 73 PassRefPtrWillBeRawPtr<Node> cloneNode(bool deep = true) override; |
74 | 74 |
75 virtual bool isAttributeNode() const override { return true; } | 75 bool isAttributeNode() const override { return true; } |
76 | 76 |
77 // Attr wraps either an element/name, or a name/value pair (when it's a stan
dalone Node.) | 77 // Attr wraps either an element/name, or a name/value pair (when it's a stan
dalone Node.) |
78 // Note that m_name is always set, but m_element/m_standaloneValue may be nu
ll. | 78 // Note that m_name is always set, but m_element/m_standaloneValue may be nu
ll. |
79 RawPtrWillBeMember<Element> m_element; | 79 RawPtrWillBeMember<Element> m_element; |
80 QualifiedName m_name; | 80 QualifiedName m_name; |
81 // Holds the value if it is a standalone Node, or the local name of the | 81 // Holds the value if it is a standalone Node, or the local name of the |
82 // attribute it is attached to on an Element. The latter may (letter case) | 82 // attribute it is attached to on an Element. The latter may (letter case) |
83 // differ from m_name's local name. As these two modes are non-overlapping, | 83 // differ from m_name's local name. As these two modes are non-overlapping, |
84 // use a single field. | 84 // use a single field. |
85 AtomicString m_standaloneValueOrAttachedLocalName; | 85 AtomicString m_standaloneValueOrAttachedLocalName; |
86 }; | 86 }; |
87 | 87 |
88 DEFINE_NODE_TYPE_CASTS(Attr, isAttributeNode()); | 88 DEFINE_NODE_TYPE_CASTS(Attr, isAttributeNode()); |
89 | 89 |
90 } // namespace blink | 90 } // namespace blink |
91 | 91 |
92 #endif // Attr_h | 92 #endif // Attr_h |
OLD | NEW |