OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 26 matching lines...) Expand all Loading... |
37 #include "core/dom/QualifiedName.h" | 37 #include "core/dom/QualifiedName.h" |
38 #include "core/dom/StaticNodeList.h" | 38 #include "core/dom/StaticNodeList.h" |
39 #include "wtf/StdLibExtras.h" | 39 #include "wtf/StdLibExtras.h" |
40 | 40 |
41 namespace WebCore { | 41 namespace WebCore { |
42 | 42 |
43 namespace { | 43 namespace { |
44 | 44 |
45 class ChildListRecord : public MutationRecord { | 45 class ChildListRecord : public MutationRecord { |
46 public: | 46 public: |
47 ChildListRecord(PassRefPtr<Node> target, PassRefPtr<NodeList> added, PassRef
Ptr<NodeList> removed, PassRefPtr<Node> previousSibling, PassRefPtr<Node> nextSi
bling) | 47 ChildListRecord(PassRefPtr<Node> target, PassRefPtrWillBeRawPtr<NodeList> ad
ded, PassRefPtrWillBeRawPtr<NodeList> removed, PassRefPtr<Node> previousSibling,
PassRefPtr<Node> nextSibling) |
48 : m_target(target) | 48 : m_target(target) |
49 , m_addedNodes(added) | 49 , m_addedNodes(added) |
50 , m_removedNodes(removed) | 50 , m_removedNodes(removed) |
51 , m_previousSibling(previousSibling) | 51 , m_previousSibling(previousSibling) |
52 , m_nextSibling(nextSibling) | 52 , m_nextSibling(nextSibling) |
53 { | 53 { |
54 } | 54 } |
55 | 55 |
| 56 virtual void trace(Visitor* visitor) OVERRIDE |
| 57 { |
| 58 visitor->trace(m_target); |
| 59 visitor->trace(m_addedNodes); |
| 60 visitor->trace(m_removedNodes); |
| 61 visitor->trace(m_previousSibling); |
| 62 visitor->trace(m_nextSibling); |
| 63 MutationRecord::trace(visitor); |
| 64 } |
| 65 |
56 private: | 66 private: |
57 virtual const AtomicString& type() OVERRIDE; | 67 virtual const AtomicString& type() OVERRIDE; |
58 virtual Node* target() OVERRIDE { return m_target.get(); } | 68 virtual Node* target() OVERRIDE { return m_target.get(); } |
59 virtual NodeList* addedNodes() OVERRIDE { return m_addedNodes.get(); } | 69 virtual NodeList* addedNodes() OVERRIDE { return m_addedNodes.get(); } |
60 virtual NodeList* removedNodes() OVERRIDE { return m_removedNodes.get(); } | 70 virtual NodeList* removedNodes() OVERRIDE { return m_removedNodes.get(); } |
61 virtual Node* previousSibling() OVERRIDE { return m_previousSibling.get(); } | 71 virtual Node* previousSibling() OVERRIDE { return m_previousSibling.get(); } |
62 virtual Node* nextSibling() OVERRIDE { return m_nextSibling.get(); } | 72 virtual Node* nextSibling() OVERRIDE { return m_nextSibling.get(); } |
63 | 73 |
64 RefPtr<Node> m_target; | 74 RefPtrWillBeMember<Node> m_target; |
65 RefPtr<NodeList> m_addedNodes; | 75 RefPtrWillBeMember<NodeList> m_addedNodes; |
66 RefPtr<NodeList> m_removedNodes; | 76 RefPtrWillBeMember<NodeList> m_removedNodes; |
67 RefPtr<Node> m_previousSibling; | 77 RefPtrWillBeMember<Node> m_previousSibling; |
68 RefPtr<Node> m_nextSibling; | 78 RefPtrWillBeMember<Node> m_nextSibling; |
69 }; | 79 }; |
70 | 80 |
71 class RecordWithEmptyNodeLists : public MutationRecord { | 81 class RecordWithEmptyNodeLists : public MutationRecord { |
72 public: | 82 public: |
73 RecordWithEmptyNodeLists(PassRefPtr<Node> target, const String& oldValue) | 83 RecordWithEmptyNodeLists(PassRefPtr<Node> target, const String& oldValue) |
74 : m_target(target) | 84 : m_target(target) |
75 , m_oldValue(oldValue) | 85 , m_oldValue(oldValue) |
76 { | 86 { |
77 } | 87 } |
78 | 88 |
| 89 virtual void trace(Visitor* visitor) OVERRIDE |
| 90 { |
| 91 visitor->trace(m_target); |
| 92 visitor->trace(m_addedNodes); |
| 93 visitor->trace(m_removedNodes); |
| 94 MutationRecord::trace(visitor); |
| 95 } |
| 96 |
79 private: | 97 private: |
80 virtual Node* target() OVERRIDE { return m_target.get(); } | 98 virtual Node* target() OVERRIDE { return m_target.get(); } |
81 virtual String oldValue() OVERRIDE { return m_oldValue; } | 99 virtual String oldValue() OVERRIDE { return m_oldValue; } |
82 virtual NodeList* addedNodes() OVERRIDE { return lazilyInitializeEmptyNodeLi
st(m_addedNodes); } | 100 virtual NodeList* addedNodes() OVERRIDE { return lazilyInitializeEmptyNodeLi
st(m_addedNodes); } |
83 virtual NodeList* removedNodes() OVERRIDE { return lazilyInitializeEmptyNode
List(m_removedNodes); } | 101 virtual NodeList* removedNodes() OVERRIDE { return lazilyInitializeEmptyNode
List(m_removedNodes); } |
84 | 102 |
85 static NodeList* lazilyInitializeEmptyNodeList(RefPtr<NodeList>& nodeList) | 103 static NodeList* lazilyInitializeEmptyNodeList(RefPtrWillBeMember<NodeList>&
nodeList) |
86 { | 104 { |
87 if (!nodeList) | 105 if (!nodeList) |
88 nodeList = StaticNodeList::createEmpty(); | 106 nodeList = StaticNodeList::createEmpty(); |
89 return nodeList.get(); | 107 return nodeList.get(); |
90 } | 108 } |
91 | 109 |
92 RefPtr<Node> m_target; | 110 RefPtrWillBeMember<Node> m_target; |
93 String m_oldValue; | 111 String m_oldValue; |
94 RefPtr<NodeList> m_addedNodes; | 112 RefPtrWillBeMember<NodeList> m_addedNodes; |
95 RefPtr<NodeList> m_removedNodes; | 113 RefPtrWillBeMember<NodeList> m_removedNodes; |
96 }; | 114 }; |
97 | 115 |
98 class AttributesRecord : public RecordWithEmptyNodeLists { | 116 class AttributesRecord : public RecordWithEmptyNodeLists { |
99 public: | 117 public: |
100 AttributesRecord(PassRefPtr<Node> target, const QualifiedName& name, const A
tomicString& oldValue) | 118 AttributesRecord(PassRefPtr<Node> target, const QualifiedName& name, const A
tomicString& oldValue) |
101 : RecordWithEmptyNodeLists(target, oldValue) | 119 : RecordWithEmptyNodeLists(target, oldValue) |
102 , m_attributeName(name.localName()) | 120 , m_attributeName(name.localName()) |
103 , m_attributeNamespace(name.namespaceURI()) | 121 , m_attributeNamespace(name.namespaceURI()) |
104 { | 122 { |
105 } | 123 } |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 } | 183 } |
166 | 184 |
167 const AtomicString& CharacterDataRecord::type() | 185 const AtomicString& CharacterDataRecord::type() |
168 { | 186 { |
169 DEFINE_STATIC_LOCAL(AtomicString, characterData, ("characterData", AtomicStr
ing::ConstructFromLiteral)); | 187 DEFINE_STATIC_LOCAL(AtomicString, characterData, ("characterData", AtomicStr
ing::ConstructFromLiteral)); |
170 return characterData; | 188 return characterData; |
171 } | 189 } |
172 | 190 |
173 } // namespace | 191 } // namespace |
174 | 192 |
175 PassRefPtrWillBeRawPtr<MutationRecord> MutationRecord::createChildList(PassRefPt
r<Node> target, PassRefPtr<NodeList> added, PassRefPtr<NodeList> removed, PassRe
fPtr<Node> previousSibling, PassRefPtr<Node> nextSibling) | 193 PassRefPtrWillBeRawPtr<MutationRecord> MutationRecord::createChildList(PassRefPt
r<Node> target, PassRefPtrWillBeRawPtr<NodeList> added, PassRefPtrWillBeRawPtr<N
odeList> removed, PassRefPtr<Node> previousSibling, PassRefPtr<Node> nextSibling
) |
176 { | 194 { |
177 return adoptRefWillBeNoop(new ChildListRecord(target, added, removed, previo
usSibling, nextSibling)); | 195 return adoptRefWillBeNoop(new ChildListRecord(target, added, removed, previo
usSibling, nextSibling)); |
178 } | 196 } |
179 | 197 |
180 PassRefPtrWillBeRawPtr<MutationRecord> MutationRecord::createAttributes(PassRefP
tr<Node> target, const QualifiedName& name, const AtomicString& oldValue) | 198 PassRefPtrWillBeRawPtr<MutationRecord> MutationRecord::createAttributes(PassRefP
tr<Node> target, const QualifiedName& name, const AtomicString& oldValue) |
181 { | 199 { |
182 return adoptRefWillBeNoop(new AttributesRecord(target, name, oldValue)); | 200 return adoptRefWillBeNoop(new AttributesRecord(target, name, oldValue)); |
183 } | 201 } |
184 | 202 |
185 PassRefPtrWillBeRawPtr<MutationRecord> MutationRecord::createCharacterData(PassR
efPtr<Node> target, const String& oldValue) | 203 PassRefPtrWillBeRawPtr<MutationRecord> MutationRecord::createCharacterData(PassR
efPtr<Node> target, const String& oldValue) |
186 { | 204 { |
187 return adoptRefWillBeNoop(new CharacterDataRecord(target, oldValue)); | 205 return adoptRefWillBeNoop(new CharacterDataRecord(target, oldValue)); |
188 } | 206 } |
189 | 207 |
190 PassRefPtrWillBeRawPtr<MutationRecord> MutationRecord::createWithNullOldValue(Pa
ssRefPtrWillBeRawPtr<MutationRecord> record) | 208 PassRefPtrWillBeRawPtr<MutationRecord> MutationRecord::createWithNullOldValue(Pa
ssRefPtrWillBeRawPtr<MutationRecord> record) |
191 { | 209 { |
192 return adoptRefWillBeNoop(new MutationRecordWithNullOldValue(record)); | 210 return adoptRefWillBeNoop(new MutationRecordWithNullOldValue(record)); |
193 } | 211 } |
194 | 212 |
195 MutationRecord::~MutationRecord() | 213 MutationRecord::~MutationRecord() |
196 { | 214 { |
197 } | 215 } |
198 | 216 |
199 } // namespace WebCore | 217 } // namespace WebCore |
OLD | NEW |