| 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 24 matching lines...) Expand all Loading... |
| 35 #include "core/dom/QualifiedName.h" | 35 #include "core/dom/QualifiedName.h" |
| 36 #include "core/dom/StaticNodeList.h" | 36 #include "core/dom/StaticNodeList.h" |
| 37 #include "wtf/StdLibExtras.h" | 37 #include "wtf/StdLibExtras.h" |
| 38 | 38 |
| 39 namespace blink { | 39 namespace blink { |
| 40 | 40 |
| 41 namespace { | 41 namespace { |
| 42 | 42 |
| 43 class ChildListRecord : public MutationRecord { | 43 class ChildListRecord : public MutationRecord { |
| 44 public: | 44 public: |
| 45 ChildListRecord(PassRefPtrWillBeRawPtr<Node> target, PassRefPtrWillBeRawPtr<
StaticNodeList> added, PassRefPtrWillBeRawPtr<StaticNodeList> removed, PassRefPt
rWillBeRawPtr<Node> previousSibling, PassRefPtrWillBeRawPtr<Node> nextSibling) | 45 ChildListRecord(RawPtr<Node> target, RawPtr<StaticNodeList> added, RawPtr<St
aticNodeList> removed, RawPtr<Node> previousSibling, RawPtr<Node> nextSibling) |
| 46 : m_target(target) | 46 : m_target(target) |
| 47 , m_addedNodes(added) | 47 , m_addedNodes(added) |
| 48 , m_removedNodes(removed) | 48 , m_removedNodes(removed) |
| 49 , m_previousSibling(previousSibling) | 49 , m_previousSibling(previousSibling) |
| 50 , m_nextSibling(nextSibling) | 50 , m_nextSibling(nextSibling) |
| 51 { | 51 { |
| 52 } | 52 } |
| 53 | 53 |
| 54 DEFINE_INLINE_VIRTUAL_TRACE() | 54 DEFINE_INLINE_VIRTUAL_TRACE() |
| 55 { | 55 { |
| 56 visitor->trace(m_target); | 56 visitor->trace(m_target); |
| 57 visitor->trace(m_addedNodes); | 57 visitor->trace(m_addedNodes); |
| 58 visitor->trace(m_removedNodes); | 58 visitor->trace(m_removedNodes); |
| 59 visitor->trace(m_previousSibling); | 59 visitor->trace(m_previousSibling); |
| 60 visitor->trace(m_nextSibling); | 60 visitor->trace(m_nextSibling); |
| 61 MutationRecord::trace(visitor); | 61 MutationRecord::trace(visitor); |
| 62 } | 62 } |
| 63 | 63 |
| 64 private: | 64 private: |
| 65 const AtomicString& type() override; | 65 const AtomicString& type() override; |
| 66 Node* target() override { return m_target.get(); } | 66 Node* target() override { return m_target.get(); } |
| 67 StaticNodeList* addedNodes() override { return m_addedNodes.get(); } | 67 StaticNodeList* addedNodes() override { return m_addedNodes.get(); } |
| 68 StaticNodeList* removedNodes() override { return m_removedNodes.get(); } | 68 StaticNodeList* removedNodes() override { return m_removedNodes.get(); } |
| 69 Node* previousSibling() override { return m_previousSibling.get(); } | 69 Node* previousSibling() override { return m_previousSibling.get(); } |
| 70 Node* nextSibling() override { return m_nextSibling.get(); } | 70 Node* nextSibling() override { return m_nextSibling.get(); } |
| 71 | 71 |
| 72 RefPtrWillBeMember<Node> m_target; | 72 Member<Node> m_target; |
| 73 RefPtrWillBeMember<StaticNodeList> m_addedNodes; | 73 Member<StaticNodeList> m_addedNodes; |
| 74 RefPtrWillBeMember<StaticNodeList> m_removedNodes; | 74 Member<StaticNodeList> m_removedNodes; |
| 75 RefPtrWillBeMember<Node> m_previousSibling; | 75 Member<Node> m_previousSibling; |
| 76 RefPtrWillBeMember<Node> m_nextSibling; | 76 Member<Node> m_nextSibling; |
| 77 }; | 77 }; |
| 78 | 78 |
| 79 class RecordWithEmptyNodeLists : public MutationRecord { | 79 class RecordWithEmptyNodeLists : public MutationRecord { |
| 80 public: | 80 public: |
| 81 RecordWithEmptyNodeLists(PassRefPtrWillBeRawPtr<Node> target, const String&
oldValue) | 81 RecordWithEmptyNodeLists(RawPtr<Node> target, const String& oldValue) |
| 82 : m_target(target) | 82 : m_target(target) |
| 83 , m_oldValue(oldValue) | 83 , m_oldValue(oldValue) |
| 84 { | 84 { |
| 85 } | 85 } |
| 86 | 86 |
| 87 DEFINE_INLINE_VIRTUAL_TRACE() | 87 DEFINE_INLINE_VIRTUAL_TRACE() |
| 88 { | 88 { |
| 89 visitor->trace(m_target); | 89 visitor->trace(m_target); |
| 90 visitor->trace(m_addedNodes); | 90 visitor->trace(m_addedNodes); |
| 91 visitor->trace(m_removedNodes); | 91 visitor->trace(m_removedNodes); |
| 92 MutationRecord::trace(visitor); | 92 MutationRecord::trace(visitor); |
| 93 } | 93 } |
| 94 | 94 |
| 95 private: | 95 private: |
| 96 Node* target() override { return m_target.get(); } | 96 Node* target() override { return m_target.get(); } |
| 97 String oldValue() override { return m_oldValue; } | 97 String oldValue() override { return m_oldValue; } |
| 98 StaticNodeList* addedNodes() override { return lazilyInitializeEmptyNodeList
(m_addedNodes); } | 98 StaticNodeList* addedNodes() override { return lazilyInitializeEmptyNodeList
(m_addedNodes); } |
| 99 StaticNodeList* removedNodes() override { return lazilyInitializeEmptyNodeLi
st(m_removedNodes); } | 99 StaticNodeList* removedNodes() override { return lazilyInitializeEmptyNodeLi
st(m_removedNodes); } |
| 100 | 100 |
| 101 static StaticNodeList* lazilyInitializeEmptyNodeList(RefPtrWillBeMember<Stat
icNodeList>& nodeList) | 101 static StaticNodeList* lazilyInitializeEmptyNodeList(Member<StaticNodeList>&
nodeList) |
| 102 { | 102 { |
| 103 if (!nodeList) | 103 if (!nodeList) |
| 104 nodeList = StaticNodeList::createEmpty(); | 104 nodeList = StaticNodeList::createEmpty(); |
| 105 return nodeList.get(); | 105 return nodeList.get(); |
| 106 } | 106 } |
| 107 | 107 |
| 108 RefPtrWillBeMember<Node> m_target; | 108 Member<Node> m_target; |
| 109 String m_oldValue; | 109 String m_oldValue; |
| 110 RefPtrWillBeMember<StaticNodeList> m_addedNodes; | 110 Member<StaticNodeList> m_addedNodes; |
| 111 RefPtrWillBeMember<StaticNodeList> m_removedNodes; | 111 Member<StaticNodeList> m_removedNodes; |
| 112 }; | 112 }; |
| 113 | 113 |
| 114 class AttributesRecord : public RecordWithEmptyNodeLists { | 114 class AttributesRecord : public RecordWithEmptyNodeLists { |
| 115 public: | 115 public: |
| 116 AttributesRecord(PassRefPtrWillBeRawPtr<Node> target, const QualifiedName& n
ame, const AtomicString& oldValue) | 116 AttributesRecord(RawPtr<Node> target, const QualifiedName& name, const Atomi
cString& oldValue) |
| 117 : RecordWithEmptyNodeLists(target, oldValue) | 117 : RecordWithEmptyNodeLists(target, oldValue) |
| 118 , m_attributeName(name.localName()) | 118 , m_attributeName(name.localName()) |
| 119 , m_attributeNamespace(name.namespaceURI()) | 119 , m_attributeNamespace(name.namespaceURI()) |
| 120 { | 120 { |
| 121 } | 121 } |
| 122 | 122 |
| 123 private: | 123 private: |
| 124 const AtomicString& type() override; | 124 const AtomicString& type() override; |
| 125 const AtomicString& attributeName() override { return m_attributeName; } | 125 const AtomicString& attributeName() override { return m_attributeName; } |
| 126 const AtomicString& attributeNamespace() override { return m_attributeNamesp
ace; } | 126 const AtomicString& attributeNamespace() override { return m_attributeNamesp
ace; } |
| 127 | 127 |
| 128 AtomicString m_attributeName; | 128 AtomicString m_attributeName; |
| 129 AtomicString m_attributeNamespace; | 129 AtomicString m_attributeNamespace; |
| 130 }; | 130 }; |
| 131 | 131 |
| 132 class CharacterDataRecord : public RecordWithEmptyNodeLists { | 132 class CharacterDataRecord : public RecordWithEmptyNodeLists { |
| 133 public: | 133 public: |
| 134 CharacterDataRecord(PassRefPtrWillBeRawPtr<Node> target, const String& oldVa
lue) | 134 CharacterDataRecord(RawPtr<Node> target, const String& oldValue) |
| 135 : RecordWithEmptyNodeLists(target, oldValue) | 135 : RecordWithEmptyNodeLists(target, oldValue) |
| 136 { | 136 { |
| 137 } | 137 } |
| 138 | 138 |
| 139 private: | 139 private: |
| 140 const AtomicString& type() override; | 140 const AtomicString& type() override; |
| 141 }; | 141 }; |
| 142 | 142 |
| 143 class MutationRecordWithNullOldValue : public MutationRecord { | 143 class MutationRecordWithNullOldValue : public MutationRecord { |
| 144 public: | 144 public: |
| 145 MutationRecordWithNullOldValue(PassRefPtrWillBeRawPtr<MutationRecord> record
) | 145 MutationRecordWithNullOldValue(RawPtr<MutationRecord> record) |
| 146 : m_record(record) | 146 : m_record(record) |
| 147 { | 147 { |
| 148 } | 148 } |
| 149 | 149 |
| 150 DEFINE_INLINE_VIRTUAL_TRACE() | 150 DEFINE_INLINE_VIRTUAL_TRACE() |
| 151 { | 151 { |
| 152 visitor->trace(m_record); | 152 visitor->trace(m_record); |
| 153 MutationRecord::trace(visitor); | 153 MutationRecord::trace(visitor); |
| 154 } | 154 } |
| 155 | 155 |
| 156 private: | 156 private: |
| 157 const AtomicString& type() override { return m_record->type(); } | 157 const AtomicString& type() override { return m_record->type(); } |
| 158 Node* target() override { return m_record->target(); } | 158 Node* target() override { return m_record->target(); } |
| 159 StaticNodeList* addedNodes() override { return m_record->addedNodes(); } | 159 StaticNodeList* addedNodes() override { return m_record->addedNodes(); } |
| 160 StaticNodeList* removedNodes() override { return m_record->removedNodes(); } | 160 StaticNodeList* removedNodes() override { return m_record->removedNodes(); } |
| 161 Node* previousSibling() override { return m_record->previousSibling(); } | 161 Node* previousSibling() override { return m_record->previousSibling(); } |
| 162 Node* nextSibling() override { return m_record->nextSibling(); } | 162 Node* nextSibling() override { return m_record->nextSibling(); } |
| 163 const AtomicString& attributeName() override { return m_record->attributeNam
e(); } | 163 const AtomicString& attributeName() override { return m_record->attributeNam
e(); } |
| 164 const AtomicString& attributeNamespace() override { return m_record->attribu
teNamespace(); } | 164 const AtomicString& attributeNamespace() override { return m_record->attribu
teNamespace(); } |
| 165 | 165 |
| 166 String oldValue() override { return String(); } | 166 String oldValue() override { return String(); } |
| 167 | 167 |
| 168 RefPtrWillBeMember<MutationRecord> m_record; | 168 Member<MutationRecord> m_record; |
| 169 }; | 169 }; |
| 170 | 170 |
| 171 const AtomicString& ChildListRecord::type() | 171 const AtomicString& ChildListRecord::type() |
| 172 { | 172 { |
| 173 DEFINE_STATIC_LOCAL(AtomicString, childList, ("childList", AtomicString::Con
structFromLiteral)); | 173 DEFINE_STATIC_LOCAL(AtomicString, childList, ("childList", AtomicString::Con
structFromLiteral)); |
| 174 return childList; | 174 return childList; |
| 175 } | 175 } |
| 176 | 176 |
| 177 const AtomicString& AttributesRecord::type() | 177 const AtomicString& AttributesRecord::type() |
| 178 { | 178 { |
| 179 DEFINE_STATIC_LOCAL(AtomicString, attributes, ("attributes", AtomicString::C
onstructFromLiteral)); | 179 DEFINE_STATIC_LOCAL(AtomicString, attributes, ("attributes", AtomicString::C
onstructFromLiteral)); |
| 180 return attributes; | 180 return attributes; |
| 181 } | 181 } |
| 182 | 182 |
| 183 const AtomicString& CharacterDataRecord::type() | 183 const AtomicString& CharacterDataRecord::type() |
| 184 { | 184 { |
| 185 DEFINE_STATIC_LOCAL(AtomicString, characterData, ("characterData", AtomicStr
ing::ConstructFromLiteral)); | 185 DEFINE_STATIC_LOCAL(AtomicString, characterData, ("characterData", AtomicStr
ing::ConstructFromLiteral)); |
| 186 return characterData; | 186 return characterData; |
| 187 } | 187 } |
| 188 | 188 |
| 189 } // namespace | 189 } // namespace |
| 190 | 190 |
| 191 PassRefPtrWillBeRawPtr<MutationRecord> MutationRecord::createChildList(PassRefPt
rWillBeRawPtr<Node> target, PassRefPtrWillBeRawPtr<StaticNodeList> added, PassRe
fPtrWillBeRawPtr<StaticNodeList> removed, PassRefPtrWillBeRawPtr<Node> previousS
ibling, PassRefPtrWillBeRawPtr<Node> nextSibling) | 191 RawPtr<MutationRecord> MutationRecord::createChildList(RawPtr<Node> target, RawP
tr<StaticNodeList> added, RawPtr<StaticNodeList> removed, RawPtr<Node> previousS
ibling, RawPtr<Node> nextSibling) |
| 192 { | 192 { |
| 193 return adoptRefWillBeNoop(new ChildListRecord(target, added, removed, previo
usSibling, nextSibling)); | 193 return new ChildListRecord(target, added, removed, previousSibling, nextSibl
ing); |
| 194 } | 194 } |
| 195 | 195 |
| 196 PassRefPtrWillBeRawPtr<MutationRecord> MutationRecord::createAttributes(PassRefP
trWillBeRawPtr<Node> target, const QualifiedName& name, const AtomicString& oldV
alue) | 196 RawPtr<MutationRecord> MutationRecord::createAttributes(RawPtr<Node> target, con
st QualifiedName& name, const AtomicString& oldValue) |
| 197 { | 197 { |
| 198 return adoptRefWillBeNoop(new AttributesRecord(target, name, oldValue)); | 198 return new AttributesRecord(target, name, oldValue); |
| 199 } | 199 } |
| 200 | 200 |
| 201 PassRefPtrWillBeRawPtr<MutationRecord> MutationRecord::createCharacterData(PassR
efPtrWillBeRawPtr<Node> target, const String& oldValue) | 201 RawPtr<MutationRecord> MutationRecord::createCharacterData(RawPtr<Node> target,
const String& oldValue) |
| 202 { | 202 { |
| 203 return adoptRefWillBeNoop(new CharacterDataRecord(target, oldValue)); | 203 return new CharacterDataRecord(target, oldValue); |
| 204 } | 204 } |
| 205 | 205 |
| 206 PassRefPtrWillBeRawPtr<MutationRecord> MutationRecord::createWithNullOldValue(Pa
ssRefPtrWillBeRawPtr<MutationRecord> record) | 206 RawPtr<MutationRecord> MutationRecord::createWithNullOldValue(RawPtr<MutationRec
ord> record) |
| 207 { | 207 { |
| 208 return adoptRefWillBeNoop(new MutationRecordWithNullOldValue(record)); | 208 return new MutationRecordWithNullOldValue(record); |
| 209 } | 209 } |
| 210 | 210 |
| 211 MutationRecord::~MutationRecord() | 211 MutationRecord::~MutationRecord() |
| 212 { | 212 { |
| 213 } | 213 } |
| 214 | 214 |
| 215 } // namespace blink | 215 } // namespace blink |
| OLD | NEW |