Changeset 154751 in webkit
- Timestamp:
- Aug 28, 2013 9:33:49 AM (11 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 1 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r154750 r154751 1 2013-08-28 Antti Koivisto <antti@apple.com> 2 3 Factor descendant iterator assertions into a class. 4 https://bugs.webkit.org/show_bug.cgi?id=120422 5 6 Reviewed by Darin Adler. 7 8 Share the assertions between ChildIterator and DescendantIterator. We can use it for future const iterators too. 9 10 * GNUmakefile.list.am: 11 * Target.pri: 12 * WebCore.vcxproj/WebCore.vcxproj: 13 * WebCore.xcodeproj/project.pbxproj: 14 * dom/ChildIterator.h: 15 (WebCore::::ChildIterator): 16 (WebCore::::operator): 17 (WebCore::=): 18 * dom/DescendantIterator.h: 19 (WebCore::::DescendantIterator): 20 (WebCore::::operator): 21 (WebCore::=): 22 * dom/DescendantIteratorAssertions.h: Added. 23 (WebCore::DescendantIteratorAssertions::DescendantIteratorAssertions): 24 (WebCore::DescendantIteratorAssertions::domTreeHasMutated): 25 (WebCore::DescendantIteratorAssertions::dropEventDispatchAssertion): 26 1 27 2013-08-28 Darin Adler <darin@apple.com> 2 28 -
trunk/Source/WebCore/GNUmakefile.list.am
r154629 r154751 2820 2820 Source/WebCore/dom/default/PlatformMessagePortChannel.h \ 2821 2821 Source/WebCore/dom/DescendantIterator.h \ 2822 Source/WebCore/dom/DescendantIteratorAssertions.h \ 2822 2823 Source/WebCore/dom/DeviceMotionClient.h \ 2823 2824 Source/WebCore/dom/DeviceMotionController.cpp \ -
trunk/Source/WebCore/Target.pri
r154629 r154751 1593 1593 dom/default/PlatformMessagePortChannel.h \ 1594 1594 dom/DescendantIterator.h \ 1595 dom/DescendantIteratorAssertions.h \ 1595 1596 dom/DeviceMotionClient.h \ 1596 1597 dom/DeviceMotionController.h \ -
trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj
r154629 r154751 20239 20239 <ClInclude Include="..\dom\DecodedDataDocumentParser.h" /> 20240 20240 <ClInclude Include="..\dom\DescendantIterator.h" /> 20241 <ClInclude Include="..\dom\DescendantIteratorAssertions.h" /> 20241 20242 <ClInclude Include="..\dom\DeviceMotionClient.h" /> 20242 20243 <ClInclude Include="..\dom\DeviceMotionController.h" /> -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r154647 r154751 5444 5444 E1FF57A30F01255B00891EBB /* ThreadGlobalData.h in Headers */ = {isa = PBXBuildFile; fileRef = E1FF57A20F01255B00891EBB /* ThreadGlobalData.h */; settings = {ATTRIBUTES = (Private, ); }; }; 5445 5445 E1FF57A60F01256B00891EBB /* ThreadGlobalData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E1FF57A50F01256B00891EBB /* ThreadGlobalData.cpp */; }; 5446 E401C27517CE53EC00C41A35 /* DescendantIteratorAssertions.h in Headers */ = {isa = PBXBuildFile; fileRef = E401C27417CE53EC00C41A35 /* DescendantIteratorAssertions.h */; }; 5446 5447 E4295FA412B0614E00D1ACE0 /* ResourceLoadPriority.h in Headers */ = {isa = PBXBuildFile; fileRef = E4295FA312B0614E00D1ACE0 /* ResourceLoadPriority.h */; settings = {ATTRIBUTES = (Private, ); }; }; 5447 5448 E43105B816750F0C00DB2FB8 /* NodeTraversal.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E43105B716750F0C00DB2FB8 /* NodeTraversal.cpp */; }; … … 12220 12221 E1FF57A20F01255B00891EBB /* ThreadGlobalData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ThreadGlobalData.h; sourceTree = "<group>"; }; 12221 12222 E1FF57A50F01256B00891EBB /* ThreadGlobalData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ThreadGlobalData.cpp; sourceTree = "<group>"; }; 12223 E401C27417CE53EC00C41A35 /* DescendantIteratorAssertions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DescendantIteratorAssertions.h; sourceTree = "<group>"; }; 12222 12224 E406F3FB1198307D009D59D6 /* ColorData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ColorData.cpp; sourceTree = "<group>"; }; 12223 12225 E41EA038119836DB00710BC5 /* CSSPropertyNames.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CSSPropertyNames.cpp; sourceTree = "<group>"; }; … … 20153 20155 A8C2289F11D5722E00D5A7D3 /* DecodedDataDocumentParser.h */, 20154 20156 E46A2B1B17CA65B9000DBCD8 /* DescendantIterator.h */, 20157 E401C27417CE53EC00C41A35 /* DescendantIteratorAssertions.h */, 20155 20158 31FB1A4F120A5D0600DC02A0 /* DeviceMotionClient.h */, 20156 20159 31FB1A50120A5D0600DC02A0 /* DeviceMotionController.cpp */, … … 20995 20998 93F199BE08245E59001E9ABC /* BlockExceptions.h in Headers */, 20996 20999 BC5EB5E10E81BE8700B25965 /* BorderData.h in Headers */, 21000 E401C27517CE53EC00C41A35 /* DescendantIteratorAssertions.h in Headers */, 20997 21001 BC5EB5DB0E81B7EA00B25965 /* BorderValue.h in Headers */, 20998 21002 BCEA4855097D93020094C9E4 /* break_lines.h in Headers */, -
trunk/Source/WebCore/dom/ChildIterator.h
r154734 r154751 29 29 #include "ElementTraversal.h" 30 30 31 #if ndef NDEBUG32 #include "D ocument.h"31 #if !ASSERT_DISABLED 32 #include "DescendantIteratorAssertions.h" 33 33 #endif 34 34 … … 48 48 ElementType* m_current; 49 49 50 #ifndef NDEBUG 51 bool domTreeHasMutated() const; 52 OwnPtr<NoEventDispatchAssertion> m_noEventDispatchAssertion; 53 uint64_t m_initialDOMTreeVersion; 50 #if !ASSERT_DISABLED 51 DescendantIteratorAssertions m_assertions; 54 52 #endif 55 53 }; … … 72 70 inline ChildIterator<ElementType>::ChildIterator() 73 71 : m_current(nullptr) 74 #ifndef NDEBUG75 , m_initialDOMTreeVersion(0)76 #endif77 72 { 78 73 } … … 81 76 inline ChildIterator<ElementType>::ChildIterator(ElementType* current) 82 77 : m_current(current) 83 #ifndef NDEBUG 84 , m_noEventDispatchAssertion(adoptPtr(new NoEventDispatchAssertion)) 85 , m_initialDOMTreeVersion(m_current ? m_current->document()->domTreeVersion() : 0) 78 #if !ASSERT_DISABLED 79 , m_assertions(current) 86 80 #endif 87 81 { 88 82 } 89 90 #ifndef NDEBUG91 template <typename ElementType>92 inline bool ChildIterator<ElementType>::domTreeHasMutated() const93 {94 return m_initialDOMTreeVersion && m_current && m_current->document()->domTreeVersion() != m_initialDOMTreeVersion;95 }96 #endif97 83 98 84 template <typename ElementType> … … 100 86 { 101 87 ASSERT(m_current); 102 ASSERT(! domTreeHasMutated());88 ASSERT(!m_assertions.domTreeHasMutated()); 103 89 m_current = Traversal<ElementType>::nextSibling(m_current); 104 #if ndef NDEBUG90 #if !ASSERT_DISABLED 105 91 // Drop the assertion when the iterator reaches the end. 106 92 if (!m_current) 107 m_ noEventDispatchAssertion = nullptr;93 m_assertions.dropEventDispatchAssertion(); 108 94 #endif 109 95 return *this; … … 114 100 { 115 101 ASSERT(m_current); 116 ASSERT(! domTreeHasMutated());102 ASSERT(!m_assertions.domTreeHasMutated()); 117 103 return *m_current; 118 104 } … … 122 108 { 123 109 ASSERT(m_current); 124 ASSERT(! domTreeHasMutated());110 ASSERT(!m_assertions.domTreeHasMutated()); 125 111 return m_current; 126 112 } … … 129 115 inline bool ChildIterator<ElementType>::operator!=(const ChildIterator& other) const 130 116 { 131 ASSERT(! domTreeHasMutated());117 ASSERT(!m_assertions.domTreeHasMutated()); 132 118 return m_current != other.m_current; 133 119 } -
trunk/Source/WebCore/dom/DescendantIterator.h
r154734 r154751 29 29 #include "ElementTraversal.h" 30 30 31 #if ndef NDEBUG32 #include "D ocument.h"31 #if !ASSERT_DISABLED 32 #include "DescendantIteratorAssertions.h" 33 33 #endif 34 34 … … 49 49 ElementType* m_current; 50 50 51 #ifndef NDEBUG 52 bool domTreeHasMutated() const; 53 OwnPtr<NoEventDispatchAssertion> m_noEventDispatchAssertion; 54 uint64_t m_initialDOMTreeVersion; 51 #if !ASSERT_DISABLED 52 DescendantIteratorAssertions m_assertions; 55 53 #endif 56 54 }; … … 74 72 : m_root(root) 75 73 , m_current(nullptr) 76 #ifndef NDEBUG77 , m_initialDOMTreeVersion(0)78 #endif79 74 { 80 75 } … … 84 79 : m_root(root) 85 80 , m_current(current) 86 #ifndef NDEBUG 87 , m_noEventDispatchAssertion(adoptPtr(new NoEventDispatchAssertion)) 88 , m_initialDOMTreeVersion(root->document()->domTreeVersion()) 81 #if !ASSERT_DISABLED 82 , m_assertions(current) 89 83 #endif 90 84 { 91 85 } 92 93 #ifndef NDEBUG94 template <typename ElementType>95 inline bool DescendantIterator<ElementType>::domTreeHasMutated() const96 {97 return m_root->document()->domTreeVersion() != m_initialDOMTreeVersion;98 }99 #endif100 86 101 87 template <typename ElementType> … … 103 89 { 104 90 ASSERT(m_current); 105 ASSERT(! domTreeHasMutated());91 ASSERT(!m_assertions.domTreeHasMutated()); 106 92 m_current = Traversal<ElementType>::next(m_current, m_root); 107 #if ndef NDEBUG93 #if !ASSERT_DISABLED 108 94 // Drop the assertion when the iterator reaches the end. 109 95 if (!m_current) 110 m_ noEventDispatchAssertion = nullptr;96 m_assertions.dropEventDispatchAssertion(); 111 97 #endif 112 98 return *this; … … 117 103 { 118 104 ASSERT(m_current); 119 ASSERT(! domTreeHasMutated());105 ASSERT(!m_assertions.domTreeHasMutated()); 120 106 return *m_current; 121 107 } … … 125 111 { 126 112 ASSERT(m_current); 127 ASSERT(! domTreeHasMutated());113 ASSERT(!m_assertions.domTreeHasMutated()); 128 114 return m_current; 129 115 } … … 133 119 { 134 120 ASSERT(m_root == other.m_root); 135 ASSERT(! domTreeHasMutated());121 ASSERT(!m_assertions.domTreeHasMutated()); 136 122 return m_current != other.m_current; 137 123 }
Note: See TracChangeset
for help on using the changeset viewer.