| 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(PassRefPtrWillBeRawPtr<Node> target, PassRefPtrWillBeRawPtr<
NodeList> added, PassRefPtrWillBeRawPtr<NodeList> removed, PassRefPtrWillBeRawPt
r<Node> previousSibling, PassRefPtrWillBeRawPtr<Node> nextSibling) | 47 ChildListRecord(PassRefPtrWillBeRawPtr<Node> target, PassRefPtrWillBeRawPtr<
StaticNodeList> added, PassRefPtrWillBeRawPtr<StaticNodeList> removed, PassRefPt
rWillBeRawPtr<Node> previousSibling, PassRefPtrWillBeRawPtr<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 | 56 virtual void trace(Visitor* visitor) OVERRIDE |
| 57 { | 57 { |
| 58 visitor->trace(m_target); | 58 visitor->trace(m_target); |
| 59 visitor->trace(m_addedNodes); | 59 visitor->trace(m_addedNodes); |
| 60 visitor->trace(m_removedNodes); | 60 visitor->trace(m_removedNodes); |
| 61 visitor->trace(m_previousSibling); | 61 visitor->trace(m_previousSibling); |
| 62 visitor->trace(m_nextSibling); | 62 visitor->trace(m_nextSibling); |
| 63 MutationRecord::trace(visitor); | 63 MutationRecord::trace(visitor); |
| 64 } | 64 } |
| 65 | 65 |
| 66 private: | 66 private: |
| 67 virtual const AtomicString& type() OVERRIDE; | 67 virtual const AtomicString& type() OVERRIDE; |
| 68 virtual Node* target() OVERRIDE { return m_target.get(); } | 68 virtual Node* target() OVERRIDE { return m_target.get(); } |
| 69 virtual NodeList* addedNodes() OVERRIDE { return m_addedNodes.get(); } | 69 virtual StaticNodeList* addedNodes() OVERRIDE { return m_addedNodes.get(); } |
| 70 virtual NodeList* removedNodes() OVERRIDE { return m_removedNodes.get(); } | 70 virtual StaticNodeList* removedNodes() OVERRIDE { return m_removedNodes.get(
); } |
| 71 virtual Node* previousSibling() OVERRIDE { return m_previousSibling.get(); } | 71 virtual Node* previousSibling() OVERRIDE { return m_previousSibling.get(); } |
| 72 virtual Node* nextSibling() OVERRIDE { return m_nextSibling.get(); } | 72 virtual Node* nextSibling() OVERRIDE { return m_nextSibling.get(); } |
| 73 | 73 |
| 74 RefPtrWillBeMember<Node> m_target; | 74 RefPtrWillBeMember<Node> m_target; |
| 75 RefPtrWillBeMember<NodeList> m_addedNodes; | 75 RefPtrWillBeMember<StaticNodeList> m_addedNodes; |
| 76 RefPtrWillBeMember<NodeList> m_removedNodes; | 76 RefPtrWillBeMember<StaticNodeList> m_removedNodes; |
| 77 RefPtrWillBeMember<Node> m_previousSibling; | 77 RefPtrWillBeMember<Node> m_previousSibling; |
| 78 RefPtrWillBeMember<Node> m_nextSibling; | 78 RefPtrWillBeMember<Node> m_nextSibling; |
| 79 }; | 79 }; |
| 80 | 80 |
| 81 class RecordWithEmptyNodeLists : public MutationRecord { | 81 class RecordWithEmptyNodeLists : public MutationRecord { |
| 82 public: | 82 public: |
| 83 RecordWithEmptyNodeLists(PassRefPtrWillBeRawPtr<Node> target, const String&
oldValue) | 83 RecordWithEmptyNodeLists(PassRefPtrWillBeRawPtr<Node> target, const String&
oldValue) |
| 84 : m_target(target) | 84 : m_target(target) |
| 85 , m_oldValue(oldValue) | 85 , m_oldValue(oldValue) |
| 86 { | 86 { |
| 87 } | 87 } |
| 88 | 88 |
| 89 virtual void trace(Visitor* visitor) OVERRIDE | 89 virtual void trace(Visitor* visitor) OVERRIDE |
| 90 { | 90 { |
| 91 visitor->trace(m_target); | 91 visitor->trace(m_target); |
| 92 visitor->trace(m_addedNodes); | 92 visitor->trace(m_addedNodes); |
| 93 visitor->trace(m_removedNodes); | 93 visitor->trace(m_removedNodes); |
| 94 MutationRecord::trace(visitor); | 94 MutationRecord::trace(visitor); |
| 95 } | 95 } |
| 96 | 96 |
| 97 private: | 97 private: |
| 98 virtual Node* target() OVERRIDE { return m_target.get(); } | 98 virtual Node* target() OVERRIDE { return m_target.get(); } |
| 99 virtual String oldValue() OVERRIDE { return m_oldValue; } | 99 virtual String oldValue() OVERRIDE { return m_oldValue; } |
| 100 virtual NodeList* addedNodes() OVERRIDE { return lazilyInitializeEmptyNodeLi
st(m_addedNodes); } | 100 virtual StaticNodeList* addedNodes() OVERRIDE { return lazilyInitializeEmpty
NodeList(m_addedNodes); } |
| 101 virtual NodeList* removedNodes() OVERRIDE { return lazilyInitializeEmptyNode
List(m_removedNodes); } | 101 virtual StaticNodeList* removedNodes() OVERRIDE { return lazilyInitializeEmp
tyNodeList(m_removedNodes); } |
| 102 | 102 |
| 103 static NodeList* lazilyInitializeEmptyNodeList(RefPtrWillBeMember<NodeList>&
nodeList) | 103 static StaticNodeList* lazilyInitializeEmptyNodeList(RefPtrWillBeMember<Stat
icNodeList>& nodeList) |
| 104 { | 104 { |
| 105 if (!nodeList) | 105 if (!nodeList) |
| 106 nodeList = StaticNodeList::createEmpty(); | 106 nodeList = StaticNodeList::createEmpty(); |
| 107 return nodeList.get(); | 107 return nodeList.get(); |
| 108 } | 108 } |
| 109 | 109 |
| 110 RefPtrWillBeMember<Node> m_target; | 110 RefPtrWillBeMember<Node> m_target; |
| 111 String m_oldValue; | 111 String m_oldValue; |
| 112 RefPtrWillBeMember<NodeList> m_addedNodes; | 112 RefPtrWillBeMember<StaticNodeList> m_addedNodes; |
| 113 RefPtrWillBeMember<NodeList> m_removedNodes; | 113 RefPtrWillBeMember<StaticNodeList> m_removedNodes; |
| 114 }; | 114 }; |
| 115 | 115 |
| 116 class AttributesRecord : public RecordWithEmptyNodeLists { | 116 class AttributesRecord : public RecordWithEmptyNodeLists { |
| 117 public: | 117 public: |
| 118 AttributesRecord(PassRefPtrWillBeRawPtr<Node> target, const QualifiedName& n
ame, const AtomicString& oldValue) | 118 AttributesRecord(PassRefPtrWillBeRawPtr<Node> target, const QualifiedName& n
ame, const AtomicString& oldValue) |
| 119 : RecordWithEmptyNodeLists(target, oldValue) | 119 : RecordWithEmptyNodeLists(target, oldValue) |
| 120 , m_attributeName(name.localName()) | 120 , m_attributeName(name.localName()) |
| 121 , m_attributeNamespace(name.namespaceURI()) | 121 , m_attributeNamespace(name.namespaceURI()) |
| 122 { | 122 { |
| 123 } | 123 } |
| (...skipping 27 matching lines...) Expand all Loading... |
| 151 | 151 |
| 152 virtual void trace(Visitor* visitor) OVERRIDE | 152 virtual void trace(Visitor* visitor) OVERRIDE |
| 153 { | 153 { |
| 154 visitor->trace(m_record); | 154 visitor->trace(m_record); |
| 155 MutationRecord::trace(visitor); | 155 MutationRecord::trace(visitor); |
| 156 } | 156 } |
| 157 | 157 |
| 158 private: | 158 private: |
| 159 virtual const AtomicString& type() OVERRIDE { return m_record->type(); } | 159 virtual const AtomicString& type() OVERRIDE { return m_record->type(); } |
| 160 virtual Node* target() OVERRIDE { return m_record->target(); } | 160 virtual Node* target() OVERRIDE { return m_record->target(); } |
| 161 virtual NodeList* addedNodes() OVERRIDE { return m_record->addedNodes(); } | 161 virtual StaticNodeList* addedNodes() OVERRIDE { return m_record->addedNodes(
); } |
| 162 virtual NodeList* removedNodes() OVERRIDE { return m_record->removedNodes();
} | 162 virtual StaticNodeList* removedNodes() OVERRIDE { return m_record->removedNo
des(); } |
| 163 virtual Node* previousSibling() OVERRIDE { return m_record->previousSibling(
); } | 163 virtual Node* previousSibling() OVERRIDE { return m_record->previousSibling(
); } |
| 164 virtual Node* nextSibling() OVERRIDE { return m_record->nextSibling(); } | 164 virtual Node* nextSibling() OVERRIDE { return m_record->nextSibling(); } |
| 165 virtual const AtomicString& attributeName() OVERRIDE { return m_record->attr
ibuteName(); } | 165 virtual const AtomicString& attributeName() OVERRIDE { return m_record->attr
ibuteName(); } |
| 166 virtual const AtomicString& attributeNamespace() OVERRIDE { return m_record-
>attributeNamespace(); } | 166 virtual const AtomicString& attributeNamespace() OVERRIDE { return m_record-
>attributeNamespace(); } |
| 167 | 167 |
| 168 virtual String oldValue() OVERRIDE { return String(); } | 168 virtual String oldValue() OVERRIDE { return String(); } |
| 169 | 169 |
| 170 RefPtrWillBeMember<MutationRecord> m_record; | 170 RefPtrWillBeMember<MutationRecord> m_record; |
| 171 }; | 171 }; |
| 172 | 172 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 183 } | 183 } |
| 184 | 184 |
| 185 const AtomicString& CharacterDataRecord::type() | 185 const AtomicString& CharacterDataRecord::type() |
| 186 { | 186 { |
| 187 DEFINE_STATIC_LOCAL(AtomicString, characterData, ("characterData", AtomicStr
ing::ConstructFromLiteral)); | 187 DEFINE_STATIC_LOCAL(AtomicString, characterData, ("characterData", AtomicStr
ing::ConstructFromLiteral)); |
| 188 return characterData; | 188 return characterData; |
| 189 } | 189 } |
| 190 | 190 |
| 191 } // namespace | 191 } // namespace |
| 192 | 192 |
| 193 PassRefPtrWillBeRawPtr<MutationRecord> MutationRecord::createChildList(PassRefPt
rWillBeRawPtr<Node> target, PassRefPtrWillBeRawPtr<NodeList> added, PassRefPtrWi
llBeRawPtr<NodeList> removed, PassRefPtrWillBeRawPtr<Node> previousSibling, Pass
RefPtrWillBeRawPtr<Node> nextSibling) | 193 PassRefPtrWillBeRawPtr<MutationRecord> MutationRecord::createChildList(PassRefPt
rWillBeRawPtr<Node> target, PassRefPtrWillBeRawPtr<StaticNodeList> added, PassRe
fPtrWillBeRawPtr<StaticNodeList> removed, PassRefPtrWillBeRawPtr<Node> previousS
ibling, PassRefPtrWillBeRawPtr<Node> nextSibling) |
| 194 { | 194 { |
| 195 return adoptRefWillBeNoop(new ChildListRecord(target, added, removed, previo
usSibling, nextSibling)); | 195 return adoptRefWillBeNoop(new ChildListRecord(target, added, removed, previo
usSibling, nextSibling)); |
| 196 } | 196 } |
| 197 | 197 |
| 198 PassRefPtrWillBeRawPtr<MutationRecord> MutationRecord::createAttributes(PassRefP
trWillBeRawPtr<Node> target, const QualifiedName& name, const AtomicString& oldV
alue) | 198 PassRefPtrWillBeRawPtr<MutationRecord> MutationRecord::createAttributes(PassRefP
trWillBeRawPtr<Node> target, const QualifiedName& name, const AtomicString& oldV
alue) |
| 199 { | 199 { |
| 200 return adoptRefWillBeNoop(new AttributesRecord(target, name, oldValue)); | 200 return adoptRefWillBeNoop(new AttributesRecord(target, name, oldValue)); |
| 201 } | 201 } |
| 202 | 202 |
| 203 PassRefPtrWillBeRawPtr<MutationRecord> MutationRecord::createCharacterData(PassR
efPtrWillBeRawPtr<Node> target, const String& oldValue) | 203 PassRefPtrWillBeRawPtr<MutationRecord> MutationRecord::createCharacterData(PassR
efPtrWillBeRawPtr<Node> target, const String& oldValue) |
| 204 { | 204 { |
| 205 return adoptRefWillBeNoop(new CharacterDataRecord(target, oldValue)); | 205 return adoptRefWillBeNoop(new CharacterDataRecord(target, oldValue)); |
| 206 } | 206 } |
| 207 | 207 |
| 208 PassRefPtrWillBeRawPtr<MutationRecord> MutationRecord::createWithNullOldValue(Pa
ssRefPtrWillBeRawPtr<MutationRecord> record) | 208 PassRefPtrWillBeRawPtr<MutationRecord> MutationRecord::createWithNullOldValue(Pa
ssRefPtrWillBeRawPtr<MutationRecord> record) |
| 209 { | 209 { |
| 210 return adoptRefWillBeNoop(new MutationRecordWithNullOldValue(record)); | 210 return adoptRefWillBeNoop(new MutationRecordWithNullOldValue(record)); |
| 211 } | 211 } |
| 212 | 212 |
| 213 MutationRecord::~MutationRecord() | 213 MutationRecord::~MutationRecord() |
| 214 { | 214 { |
| 215 } | 215 } |
| 216 | 216 |
| 217 } // namespace WebCore | 217 } // namespace WebCore |
| OLD | NEW |