Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(819)

Side by Side Diff: Source/core/dom/Attr.h

Issue 1158433004: Remove Attr child nodes (making Attr a Node, not a ContainerNode) (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: address feedback Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
11 * version 2 of the License, or (at your option) any later version. 11 * version 2 of the License, or (at your option) any later version.
12 * 12 *
13 * This library is distributed in the hope that it will be useful, 13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Library General Public License for more details. 16 * Library General Public License for more details.
17 * 17 *
18 * You should have received a copy of the GNU Library General Public License 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 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, 20 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 * Boston, MA 02110-1301, USA. 21 * Boston, MA 02110-1301, USA.
22 * 22 *
23 */ 23 */
24 24
25 #ifndef Attr_h 25 #ifndef Attr_h
26 #define Attr_h 26 #define Attr_h
27 27
28 #include "core/dom/ContainerNode.h" 28 #include "core/dom/Node.h"
29 #include "core/dom/QualifiedName.h" 29 #include "core/dom/QualifiedName.h"
30 30
31 namespace blink { 31 namespace blink {
32 32
33 // Attr can have Text children 33 class Attr final : public Node {
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 final : public ContainerNode {
40 DEFINE_WRAPPERTYPEINFO(); 34 DEFINE_WRAPPERTYPEINFO();
41 public: 35 public:
42 static PassRefPtrWillBeRawPtr<Attr> create(Element&, const QualifiedName&); 36 static PassRefPtrWillBeRawPtr<Attr> create(Element&, const QualifiedName&);
43 static PassRefPtrWillBeRawPtr<Attr> create(Document&, const QualifiedName&, const AtomicString& value); 37 static PassRefPtrWillBeRawPtr<Attr> create(Document&, const QualifiedName&, const AtomicString& value);
44 virtual ~Attr(); 38 virtual ~Attr();
45 39
46 String name() const { return m_name.toString(); } 40 String name() const { return m_name.toString(); }
47 bool specified() const { return true; } 41 bool specified() const { return true; }
48 Element* ownerElement() const { return m_element; } 42 Element* ownerElement() const { return m_element; }
49 43
(...skipping 13 matching lines...) Expand all
63 const AtomicString& prefix() const { return m_name.prefix(); } 57 const AtomicString& prefix() const { return m_name.prefix(); }
64 58
65 DECLARE_VIRTUAL_TRACE(); 59 DECLARE_VIRTUAL_TRACE();
66 60
67 private: 61 private:
68 Attr(Element&, const QualifiedName&); 62 Attr(Element&, const QualifiedName&);
69 Attr(Document&, const QualifiedName&, const AtomicString& value); 63 Attr(Document&, const QualifiedName&, const AtomicString& value);
70 64
71 bool isElementNode() const = delete; // This will catch anyone doing an unne cessary check. 65 bool isElementNode() const = delete; // This will catch anyone doing an unne cessary check.
72 66
73 void createTextChild();
74
75 void setValueInternal(const AtomicString&);
76
77 virtual String nodeName() const override { return name(); } 67 virtual String nodeName() const override { return name(); }
78 virtual NodeType nodeType() const override { return ATTRIBUTE_NODE; } 68 virtual NodeType nodeType() const override { return ATTRIBUTE_NODE; }
79 69
80 virtual String nodeValue() const override { return value(); } 70 virtual String nodeValue() const override { return value(); }
81 virtual void setNodeValue(const String&) override; 71 virtual void setNodeValue(const String&) override;
82 virtual PassRefPtrWillBeRawPtr<Node> cloneNode(bool deep = true) override; 72 virtual PassRefPtrWillBeRawPtr<Node> cloneNode(bool deep = true) override;
83 73
84 virtual bool isAttributeNode() const override { return true; } 74 virtual bool isAttributeNode() const override { return true; }
85 virtual bool childTypeAllowed(NodeType) const override;
86
87 virtual void childrenChanged(const ChildrenChange&) override;
88
89 void updateElementAttribute(const AtomicString&);
90 75
91 // Attr wraps either an element/name, or a name/value pair (when it's a stan dalone Node.) 76 // Attr wraps either an element/name, or a name/value pair (when it's a stan dalone Node.)
92 // Note that m_name is always set, but m_element/m_standaloneValue may be nu ll. 77 // Note that m_name is always set, but m_element/m_standaloneValue may be nu ll.
93 RawPtrWillBeMember<Element> m_element; 78 RawPtrWillBeMember<Element> m_element;
94 QualifiedName m_name; 79 QualifiedName m_name;
95 // Holds the value if it is a standalone Node, or the local name of the 80 // Holds the value if it is a standalone Node, or the local name of the
96 // attribute it is attached to on an Element. The latter may (letter case) 81 // attribute it is attached to on an Element. The latter may (letter case)
97 // differ from m_name's local name. As these two modes are non-overlapping, 82 // differ from m_name's local name. As these two modes are non-overlapping,
98 // use a single field. 83 // use a single field.
99 AtomicString m_standaloneValueOrAttachedLocalName; 84 AtomicString m_standaloneValueOrAttachedLocalName;
100 unsigned m_ignoreChildrenChanged;
101 }; 85 };
102 86
103 DEFINE_NODE_TYPE_CASTS(Attr, isAttributeNode()); 87 DEFINE_NODE_TYPE_CASTS(Attr, isAttributeNode());
104 88
105 } // namespace blink 89 } // namespace blink
106 90
107 #endif // Attr_h 91 #endif // Attr_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698