Changeset 136996 in webkit
- Timestamp:
- Dec 7, 2012 3:43:48 PM (11 years ago)
- Location:
- trunk
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r136994 r136996 1 2012-12-07 Adam Klein <adamk@chromium.org> 2 3 MutationRecord addedNodes/removedNodes should never be null 4 https://bugs.webkit.org/show_bug.cgi?id=98921 5 6 Reviewed by Ryosuke Niwa. 7 8 Updated nullity test to check for empty nodelists. 9 10 * fast/mutation/mutation-record-nullity-expected.txt: 11 * fast/mutation/mutation-record-nullity.html: 12 1 13 2012-12-07 Emil A Eklund <eae@chromium.org> 2 14 -
trunk/LayoutTests/fast/mutation/mutation-record-nullity-expected.txt
r130442 r136996 1 Non-relevant properties on mutation records should be null 1 Non-relevant properties on mutation records should be null, except for NodeLists, which should be empty 2 2 3 3 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". … … 8 8 PASS record.attributeNamespace is null 9 9 PASS record.oldValue is null 10 PASS record.addedNodes is null11 PASS record.removedNodes is null12 10 PASS record.previousSibling is null 13 11 PASS record.nextSibling is null 12 PASS record.addedNodes.length is 0 13 PASS record.removedNodes.length is 0 14 14 15 15 childList record: … … 21 21 PASS record.attributeNamespace is null 22 22 PASS record.oldValue is null 23 PASS record.addedNodes is null24 PASS record.removedNodes is null25 23 PASS record.previousSibling is null 26 24 PASS record.nextSibling is null 25 PASS record.addedNodes.length is 0 26 PASS record.removedNodes.length is 0 27 27 PASS successfullyParsed is true 28 28 -
trunk/LayoutTests/fast/mutation/mutation-record-nullity.html
r130442 r136996 2 2 <script src="../js/resources/js-test-pre.js"></script> 3 3 <script> 4 description('Non-relevant properties on mutation records should be null ');4 description('Non-relevant properties on mutation records should be null, except for NodeLists, which should be empty'); 5 5 var observer = new WebKitMutationObserver(function() {}); 6 6 … … 13 13 shouldBeNull('record.attributeNamespace'); 14 14 shouldBeNull('record.oldValue'); 15 shouldBeNull('record.addedNodes');16 shouldBeNull('record.removedNodes');17 15 shouldBeNull('record.previousSibling'); 18 16 shouldBeNull('record.nextSibling'); 17 shouldBe('record.addedNodes.length', '0'); 18 shouldBe('record.removedNodes.length', '0'); 19 19 20 20 var div = document.createElement('div'); … … 33 33 shouldBeNull('record.attributeNamespace'); 34 34 shouldBeNull('record.oldValue'); 35 shouldBeNull('record.addedNodes');36 shouldBeNull('record.removedNodes');37 35 shouldBeNull('record.previousSibling'); 38 36 shouldBeNull('record.nextSibling'); 37 shouldBe('record.addedNodes.length', '0'); 38 shouldBe('record.removedNodes.length', '0'); 39 39 </script> 40 40 <script src="../js/resources/js-test-post.js"></script> -
trunk/Source/WebCore/ChangeLog
r136995 r136996 1 2012-12-07 Adam Klein <adamk@chromium.org> 2 3 MutationRecord addedNodes/removedNodes should never be null 4 https://bugs.webkit.org/show_bug.cgi?id=98921 5 6 Reviewed by Ryosuke Niwa. 7 8 Per an update to the DOM4 spec that matches Gecko's behavior, 9 addedNodes/removedNodes should be empty NodeLists on 'attributes' 10 and 'characterData' records, rather than null. 11 12 This is accomplished with lazy initialization of addedNodes/removedNodes 13 attributes on 'attributes'/'characterData' records and the 14 addition of a new StaticNodeList::createEmpty() factory method. 15 16 * dom/MutationRecord.cpp: 17 * dom/MutationRecord.h: 18 (MutationRecord): 19 * dom/StaticNodeList.h: 20 (WebCore::StaticNodeList::adopt): 21 (StaticNodeList): 22 (WebCore::StaticNodeList::createEmpty): 23 (WebCore::StaticNodeList::StaticNodeList): 24 1 25 2012-12-07 Brent Fulgham <bfulgham@webkit.org> 2 26 -
trunk/Source/WebCore/dom/MutationRecord.cpp
r133976 r136996 38 38 #include "NodeList.h" 39 39 #include "QualifiedName.h" 40 #include "StaticNodeList.h" 40 41 #include <wtf/Assertions.h> 41 42 #include <wtf/StdLibExtras.h> … … 71 72 }; 72 73 73 class AttributesRecord: public MutationRecord {74 class RecordWithEmptyNodeLists : public MutationRecord { 74 75 public: 75 AttributesRecord(PassRefPtr<Node> target, const QualifiedName& name, const AtomicString& oldValue) 76 : m_target(target) 77 , m_attributeName(name.localName()) 78 , m_attributeNamespace(name.namespaceURI()) 79 , m_oldValue(oldValue) 80 { 81 } 82 83 private: 84 virtual const AtomicString& type() OVERRIDE; 85 virtual Node* target() OVERRIDE { return m_target.get(); } 86 virtual const AtomicString& attributeName() OVERRIDE { return m_attributeName; } 87 virtual const AtomicString& attributeNamespace() OVERRIDE { return m_attributeNamespace; } 88 virtual String oldValue() OVERRIDE { return m_oldValue; } 89 90 RefPtr<Node> m_target; 91 AtomicString m_attributeName; 92 AtomicString m_attributeNamespace; 93 AtomicString m_oldValue; 94 }; 95 96 class CharacterDataRecord : public MutationRecord { 97 public: 98 CharacterDataRecord(PassRefPtr<Node> target, const String& oldValue) 76 RecordWithEmptyNodeLists(PassRefPtr<Node> target, const String& oldValue) 99 77 : m_target(target) 100 78 , m_oldValue(oldValue) … … 103 81 104 82 private: 105 virtual const AtomicString& type() OVERRIDE;106 83 virtual Node* target() OVERRIDE { return m_target.get(); } 107 84 virtual String oldValue() OVERRIDE { return m_oldValue; } 85 virtual NodeList* addedNodes() OVERRIDE { return lazilyInitializeEmptyNodeList(m_addedNodes); } 86 virtual NodeList* removedNodes() OVERRIDE { return lazilyInitializeEmptyNodeList(m_removedNodes); } 87 88 static NodeList* lazilyInitializeEmptyNodeList(RefPtr<NodeList>& nodeList) 89 { 90 if (!nodeList) 91 nodeList = StaticNodeList::createEmpty(); 92 return nodeList.get(); 93 } 108 94 109 95 RefPtr<Node> m_target; 110 96 String m_oldValue; 97 RefPtr<NodeList> m_addedNodes; 98 RefPtr<NodeList> m_removedNodes; 99 }; 100 101 class AttributesRecord : public RecordWithEmptyNodeLists { 102 public: 103 AttributesRecord(PassRefPtr<Node> target, const QualifiedName& name, const AtomicString& oldValue) 104 : RecordWithEmptyNodeLists(target, oldValue) 105 , m_attributeName(name.localName()) 106 , m_attributeNamespace(name.namespaceURI()) 107 { 108 } 109 110 private: 111 virtual const AtomicString& type() OVERRIDE; 112 virtual const AtomicString& attributeName() OVERRIDE { return m_attributeName; } 113 virtual const AtomicString& attributeNamespace() OVERRIDE { return m_attributeNamespace; } 114 115 AtomicString m_attributeName; 116 AtomicString m_attributeNamespace; 117 }; 118 119 class CharacterDataRecord : public RecordWithEmptyNodeLists { 120 public: 121 CharacterDataRecord(PassRefPtr<Node> target, const String& oldValue) 122 : RecordWithEmptyNodeLists(target, oldValue) 123 { 124 } 125 126 private: 127 virtual const AtomicString& type() OVERRIDE; 111 128 }; 112 129 -
trunk/Source/WebCore/dom/MutationRecord.h
r127757 r136996 58 58 virtual Node* target() = 0; 59 59 60 virtual NodeList* addedNodes() { return 0; }61 virtual NodeList* removedNodes() { return 0; }60 virtual NodeList* addedNodes() = 0; 61 virtual NodeList* removedNodes() = 0; 62 62 virtual Node* previousSibling() { return 0; } 63 63 virtual Node* nextSibling() { return 0; } -
trunk/Source/WebCore/dom/StaticNodeList.h
r135667 r136996 41 41 class StaticNodeList : public NodeList { 42 42 public: 43 // Adopts the contents of the nodes vector.44 43 static PassRefPtr<StaticNodeList> adopt(Vector<RefPtr<Node> >& nodes) 45 44 { 46 return adoptRef(new StaticNodeList(nodes)); 45 RefPtr<StaticNodeList> nodeList = adoptRef(new StaticNodeList); 46 nodeList->m_nodes.swap(nodes); 47 return nodeList.release(); 48 } 49 50 static PassRefPtr<StaticNodeList> createEmpty() 51 { 52 return adoptRef(new StaticNodeList); 47 53 } 48 54 … … 52 58 53 59 private: 54 explicit StaticNodeList(Vector<RefPtr<Node> >& nodes) 55 { 56 m_nodes.swap(nodes); 57 } 60 StaticNodeList() { } 61 58 62 Vector<RefPtr<Node> > m_nodes; 59 63 };
Note: See TracChangeset
for help on using the changeset viewer.