Changeset 154926 in webkit


Ignore:
Timestamp:
Aug 31, 2013, 6:04:33 AM (11 years ago)
Author:
Antti Koivisto
Message:

Add common base for element iterators
https://bugs.webkit.org/show_bug.cgi?id=120557

Reviewed by Andreas Kling.

Add ElementIterator and use it as the base for child and descendant iterators. The only difference is the definition of operator++.

Also renamed DescendantIteratorAssertions to ElementIteratorAssertions.

  • GNUmakefile.list.am:
  • Target.pri:
  • WebCore.vcxproj/WebCore.vcxproj:
  • WebCore.xcodeproj/project.pbxproj:
  • dom/ChildIterator.h:

(WebCore::::ChildIterator):
(WebCore::::operator):
(WebCore::::ChildConstIterator):
(WebCore::::begin):
(WebCore::::end):

  • dom/DescendantIterator.h:

(WebCore::::DescendantIterator):
(WebCore::::operator):
(WebCore::::DescendantConstIterator):

  • dom/DescendantIteratorAssertions.h: Removed.
  • dom/ElementIterator.h: Added.

(WebCore::::ElementIterator):
(WebCore::::traverseNext):
(WebCore::::traversePrevious):
(WebCore::::traverseNextSibling):
(WebCore::::traversePreviousSibling):
(WebCore::::operator):
(WebCore::=):
(WebCore::::ElementConstIterator):

  • dom/ElementIteratorAssertions.h: Copied from Source/WebCore/dom/DescendantIteratorAssertions.h.

(WebCore::ElementIteratorAssertions::ElementIteratorAssertions):
(WebCore::ElementIteratorAssertions::domTreeHasMutated):
(WebCore::ElementIteratorAssertions::dropEventDispatchAssertion):

Location:
trunk/Source/WebCore
Files:
1 added
7 edited
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r154924 r154926  
     12013-08-31  Antti Koivisto  <antti@apple.com>
     2
     3        Add common base for element iterators
     4        https://bugs.webkit.org/show_bug.cgi?id=120557
     5
     6        Reviewed by Andreas Kling.
     7
     8        Add ElementIterator and use it as the base for child and descendant iterators. The only difference is the definition of operator++.
     9       
     10        Also renamed DescendantIteratorAssertions to ElementIteratorAssertions.
     11
     12        * GNUmakefile.list.am:
     13        * Target.pri:
     14        * WebCore.vcxproj/WebCore.vcxproj:
     15        * WebCore.xcodeproj/project.pbxproj:
     16        * dom/ChildIterator.h:
     17        (WebCore::::ChildIterator):
     18        (WebCore::::operator):
     19        (WebCore::::ChildConstIterator):
     20        (WebCore::::begin):
     21        (WebCore::::end):
     22        * dom/DescendantIterator.h:
     23        (WebCore::::DescendantIterator):
     24        (WebCore::::operator):
     25        (WebCore::::DescendantConstIterator):
     26        * dom/DescendantIteratorAssertions.h: Removed.
     27        * dom/ElementIterator.h: Added.
     28        (WebCore::::ElementIterator):
     29        (WebCore::::traverseNext):
     30        (WebCore::::traversePrevious):
     31        (WebCore::::traverseNextSibling):
     32        (WebCore::::traversePreviousSibling):
     33        (WebCore::::operator):
     34        (WebCore::=):
     35        (WebCore::::ElementConstIterator):
     36        * dom/ElementIteratorAssertions.h: Copied from Source/WebCore/dom/DescendantIteratorAssertions.h.
     37        (WebCore::ElementIteratorAssertions::ElementIteratorAssertions):
     38        (WebCore::ElementIteratorAssertions::domTreeHasMutated):
     39        (WebCore::ElementIteratorAssertions::dropEventDispatchAssertion):
     40
    1412013-08-30  Brent Fulgham  <bfulgham@apple.com>
    242
  • trunk/Source/WebCore/GNUmakefile.list.am

    r154908 r154926  
    28222822        Source/WebCore/dom/default/PlatformMessagePortChannel.h \
    28232823        Source/WebCore/dom/DescendantIterator.h \
    2824         Source/WebCore/dom/DescendantIteratorAssertions.h \
    28252824        Source/WebCore/dom/DeviceMotionClient.h \
    28262825        Source/WebCore/dom/DeviceMotionController.cpp \
     
    28752874        Source/WebCore/dom/ElementData.cpp \
    28762875        Source/WebCore/dom/ElementData.h \
     2876        Source/WebCore/dom/ElementIterator.h \
     2877        Source/WebCore/dom/ElementIteratorAssertions.h \
    28772878        Source/WebCore/dom/ElementRareData.cpp \
    28782879        Source/WebCore/dom/ElementRareData.h \
  • trunk/Source/WebCore/Target.pri

    r154908 r154926  
    15901590    dom/default/PlatformMessagePortChannel.h \
    15911591    dom/DescendantIterator.h \
    1592     dom/DescendantIteratorAssertions.h \
    15931592    dom/DeviceMotionClient.h \
    15941593    dom/DeviceMotionController.h \
     
    16151614    dom/Element.h \
    16161615    dom/ElementData.h \
     1616    dom/ElementIterator.h \
     1617    dom/ElementIteratorAssertions.h \
    16171618    dom/ElementTraversal.h \
    16181619    dom/Entity.h \
  • trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj

    r154908 r154926  
    2023920239    <ClInclude Include="..\dom\DecodedDataDocumentParser.h" />
    2024020240    <ClInclude Include="..\dom\DescendantIterator.h" />
    20241     <ClInclude Include="..\dom\DescendantIteratorAssertions.h" />
    2024220241    <ClInclude Include="..\dom\DeviceMotionClient.h" />
    2024320242    <ClInclude Include="..\dom\DeviceMotionController.h" />
     
    2026720266    <ClInclude Include="..\dom\Element.h" />
    2026820267    <ClInclude Include="..\dom\ElementData.h" />
     20268    <ClInclude Include="..\dom\ElementIterator.h" />
     20269    <ClInclude Include="..\dom\ElementIteratorAssertions.h" />
    2026920270    <ClInclude Include="..\dom\ElementTraversal.h" />
    2027020271    <ClInclude Include="..\dom\Entity.h" />
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r154908 r154926  
    54465446                E1FF57A30F01255B00891EBB /* ThreadGlobalData.h in Headers */ = {isa = PBXBuildFile; fileRef = E1FF57A20F01255B00891EBB /* ThreadGlobalData.h */; settings = {ATTRIBUTES = (Private, ); }; };
    54475447                E1FF57A60F01256B00891EBB /* ThreadGlobalData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E1FF57A50F01256B00891EBB /* ThreadGlobalData.cpp */; };
    5448                 E401C27517CE53EC00C41A35 /* DescendantIteratorAssertions.h in Headers */ = {isa = PBXBuildFile; fileRef = E401C27417CE53EC00C41A35 /* DescendantIteratorAssertions.h */; };
     5448                E401C27517CE53EC00C41A35 /* ElementIteratorAssertions.h in Headers */ = {isa = PBXBuildFile; fileRef = E401C27417CE53EC00C41A35 /* ElementIteratorAssertions.h */; };
    54495449                E4295FA412B0614E00D1ACE0 /* ResourceLoadPriority.h in Headers */ = {isa = PBXBuildFile; fileRef = E4295FA312B0614E00D1ACE0 /* ResourceLoadPriority.h */; settings = {ATTRIBUTES = (Private, ); }; };
    54505450                E43105B816750F0C00DB2FB8 /* NodeTraversal.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E43105B716750F0C00DB2FB8 /* NodeTraversal.cpp */; };
     
    55065506                E49BD9FA131FD2ED003C56F0 /* CSSValuePool.h in Headers */ = {isa = PBXBuildFile; fileRef = E49BD9F9131FD2ED003C56F0 /* CSSValuePool.h */; settings = {ATTRIBUTES = (Private, ); }; };
    55075507                E49BDA0B131FD3E5003C56F0 /* CSSValuePool.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E49BDA0A131FD3E5003C56F0 /* CSSValuePool.cpp */; };
     5508                E4AE7C1617D1BB950009FB31 /* ElementIterator.h in Headers */ = {isa = PBXBuildFile; fileRef = E4AE7C1517D1BB950009FB31 /* ElementIterator.h */; };
    55085509                E4AFCFA50DAF29A300F5F55C /* UnitBezier.h in Headers */ = {isa = PBXBuildFile; fileRef = E4AFCFA40DAF29A300F5F55C /* UnitBezier.h */; };
    55095510                E4AFD00B0DAF335400F5F55C /* SMILTime.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E4AFD0050DAF335400F5F55C /* SMILTime.cpp */; };
     
    1222412225                E1FF57A20F01255B00891EBB /* ThreadGlobalData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ThreadGlobalData.h; sourceTree = "<group>"; };
    1222512226                E1FF57A50F01256B00891EBB /* ThreadGlobalData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ThreadGlobalData.cpp; sourceTree = "<group>"; };
    12226                 E401C27417CE53EC00C41A35 /* DescendantIteratorAssertions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DescendantIteratorAssertions.h; sourceTree = "<group>"; };
     12227                E401C27417CE53EC00C41A35 /* ElementIteratorAssertions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ElementIteratorAssertions.h; sourceTree = "<group>"; };
    1222712228                E406F3FB1198307D009D59D6 /* ColorData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ColorData.cpp; sourceTree = "<group>"; };
    1222812229                E41EA038119836DB00710BC5 /* CSSPropertyNames.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CSSPropertyNames.cpp; sourceTree = "<group>"; };
     
    1227912280                E49BD9F9131FD2ED003C56F0 /* CSSValuePool.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSSValuePool.h; sourceTree = "<group>"; };
    1228012281                E49BDA0A131FD3E5003C56F0 /* CSSValuePool.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CSSValuePool.cpp; sourceTree = "<group>"; };
     12282                E4AE7C1517D1BB950009FB31 /* ElementIterator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ElementIterator.h; sourceTree = "<group>"; };
    1228112283                E4AFCFA40DAF29A300F5F55C /* UnitBezier.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UnitBezier.h; sourceTree = "<group>"; };
    1228212284                E4AFD0050DAF335400F5F55C /* SMILTime.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SMILTime.cpp; sourceTree = "<group>"; };
     
    2016120163                                A8C2289F11D5722E00D5A7D3 /* DecodedDataDocumentParser.h */,
    2016220164                                E46A2B1B17CA65B9000DBCD8 /* DescendantIterator.h */,
    20163                                 E401C27417CE53EC00C41A35 /* DescendantIteratorAssertions.h */,
    2016420165                                31FB1A4F120A5D0600DC02A0 /* DeviceMotionClient.h */,
    2016520166                                31FB1A50120A5D0600DC02A0 /* DeviceMotionController.cpp */,
     
    2022920230                                4FAB48641643A66D00F70C07 /* ElementRareData.cpp */,
    2023020231                                637B7ADE0E8767B800E32194 /* ElementRareData.h */,
     20232                                E4AE7C1517D1BB950009FB31 /* ElementIterator.h */,
     20233                                E401C27417CE53EC00C41A35 /* ElementIteratorAssertions.h */,
    2023120234                                E4D58EBA17B8F12800CBDCA8 /* ElementTraversal.h */,
    2023220235                                A8EA7EBA0A1945D000A8EF5F /* Entity.h */,
     
    2100121004                                93F199BE08245E59001E9ABC /* BlockExceptions.h in Headers */,
    2100221005                                BC5EB5E10E81BE8700B25965 /* BorderData.h in Headers */,
    21003                                 E401C27517CE53EC00C41A35 /* DescendantIteratorAssertions.h in Headers */,
     21006                                E401C27517CE53EC00C41A35 /* ElementIteratorAssertions.h in Headers */,
    2100421007                                BC5EB5DB0E81B7EA00B25965 /* BorderValue.h in Headers */,
    2100521008                                BCEA4855097D93020094C9E4 /* break_lines.h in Headers */,
     
    2353323536                                650FBF2B0D9AF047008FC292 /* SVGHKernElement.h in Headers */,
    2353423537                                B25599A40D00D8BA00BB825C /* SVGImage.h in Headers */,
     23538                                E4AE7C1617D1BB950009FB31 /* ElementIterator.h in Headers */,
    2353523539                                08F859D51463F9CD0067D933 /* SVGImageCache.h in Headers */,
    2353623540                                AAC08CEF15F933D600F1E188 /* SVGImageChromeClient.h in Headers */,
  • trunk/Source/WebCore/dom/ChildIterator.h

    r154769 r154926  
    2727#define ChildIterator_h
    2828
    29 #include "ElementTraversal.h"
    30 
    31 #if !ASSERT_DISABLED
    32 #include "DescendantIteratorAssertions.h"
    33 #endif
     29#include "ElementIterator.h"
    3430
    3531namespace WebCore {
    3632
    3733template <typename ElementType>
    38 class ChildIterator {
     34class ChildIterator : public ElementIterator<ElementType> {
    3935public:
    40     ChildIterator();
    41     ChildIterator(ElementType* current);
     36    ChildIterator(const ContainerNode* root);
     37    ChildIterator(const ContainerNode* root, ElementType* current);
    4238    ChildIterator& operator++();
    43     ElementType& operator*();
    44     ElementType* operator->();
    45     bool operator!=(const ChildIterator& other) const;
    46 
    47 private:
    48     ElementType* m_current;
    49 
    50 #if !ASSERT_DISABLED
    51     DescendantIteratorAssertions m_assertions;
    52 #endif
    5339};
    5440
    5541template <typename ElementType>
    56 class ChildConstIterator {
     42class ChildConstIterator : public ElementConstIterator<ElementType> {
    5743public:
    58     ChildConstIterator();
    59     ChildConstIterator(const ElementType* current);
     44    ChildConstIterator(const ContainerNode* root);
     45    ChildConstIterator(const ContainerNode* root, const ElementType* current);
    6046    ChildConstIterator& operator++();
    61     const ElementType& operator*() const;
    62     const ElementType* operator->() const;
    63     bool operator!=(const ChildConstIterator& other) const;
    64 
    65 private:
    66     const ElementType* m_current;
    67 
    68 #if !ASSERT_DISABLED
    69     DescendantIteratorAssertions m_assertions;
    70 #endif
    7147};
    7248
     
    10177
    10278template <typename ElementType>
    103 inline ChildIterator<ElementType>::ChildIterator()
    104     : m_current(nullptr)
     79inline ChildIterator<ElementType>::ChildIterator(const ContainerNode* root)
     80    : ElementIterator<ElementType>(root)
    10581{
    10682}
    10783
    10884template <typename ElementType>
    109 inline ChildIterator<ElementType>::ChildIterator(ElementType* current)
    110     : m_current(current)
    111 #if !ASSERT_DISABLED
    112     , m_assertions(current)
    113 #endif
     85inline ChildIterator<ElementType>::ChildIterator(const ContainerNode* root, ElementType* current)
     86    : ElementIterator<ElementType>(root, current)
    11487{
    11588}
     
    11891inline ChildIterator<ElementType>& ChildIterator<ElementType>::operator++()
    11992{
    120     ASSERT(m_current);
    121     ASSERT(!m_assertions.domTreeHasMutated());
    122     m_current = Traversal<ElementType>::nextSibling(m_current);
    123 #if !ASSERT_DISABLED
    124     // Drop the assertion when the iterator reaches the end.
    125     if (!m_current)
    126         m_assertions.dropEventDispatchAssertion();
    127 #endif
    128     return *this;
    129 }
    130 
    131 template <typename ElementType>
    132 inline ElementType& ChildIterator<ElementType>::operator*()
    133 {
    134     ASSERT(m_current);
    135     ASSERT(!m_assertions.domTreeHasMutated());
    136     return *m_current;
    137 }
    138 
    139 template <typename ElementType>
    140 inline ElementType* ChildIterator<ElementType>::operator->()
    141 {
    142     ASSERT(m_current);
    143     ASSERT(!m_assertions.domTreeHasMutated());
    144     return m_current;
    145 }
    146 
    147 template <typename ElementType>
    148 inline bool ChildIterator<ElementType>::operator!=(const ChildIterator& other) const
    149 {
    150     ASSERT(!m_assertions.domTreeHasMutated());
    151     return m_current != other.m_current;
     93    return static_cast<ChildIterator<ElementType>&>(ElementIterator<ElementType>::traverseNextSibling());
    15294}
    15395
     
    15597
    15698template <typename ElementType>
    157 inline ChildConstIterator<ElementType>::ChildConstIterator()
    158     : m_current(nullptr)
     99inline ChildConstIterator<ElementType>::ChildConstIterator(const ContainerNode* root)
     100    : ElementConstIterator<ElementType>(root)
    159101{
    160102}
    161103
    162104template <typename ElementType>
    163 inline ChildConstIterator<ElementType>::ChildConstIterator(const ElementType* current)
    164     : m_current(current)
    165 #if !ASSERT_DISABLED
    166     , m_assertions(current)
    167 #endif
     105inline ChildConstIterator<ElementType>::ChildConstIterator(const ContainerNode* root, const ElementType* current)
     106    : ElementConstIterator<ElementType>(root, current)
    168107{
    169108}
     
    172111inline ChildConstIterator<ElementType>& ChildConstIterator<ElementType>::operator++()
    173112{
    174     ASSERT(m_current);
    175     ASSERT(!m_assertions.domTreeHasMutated());
    176     m_current = Traversal<ElementType>::nextSibling(m_current);
    177 #if !ASSERT_DISABLED
    178     // Drop the assertion when the iterator reaches the end.
    179     if (!m_current)
    180         m_assertions.dropEventDispatchAssertion();
    181 #endif
    182     return *this;
    183 }
    184 
    185 template <typename ElementType>
    186 inline const ElementType& ChildConstIterator<ElementType>::operator*() const
    187 {
    188     ASSERT(m_current);
    189     ASSERT(!m_assertions.domTreeHasMutated());
    190     return *m_current;
    191 }
    192 
    193 template <typename ElementType>
    194 inline const ElementType* ChildConstIterator<ElementType>::operator->() const
    195 {
    196     ASSERT(m_current);
    197     ASSERT(!m_assertions.domTreeHasMutated());
    198     return m_current;
    199 }
    200 
    201 template <typename ElementType>
    202 inline bool ChildConstIterator<ElementType>::operator!=(const ChildConstIterator& other) const
    203 {
    204     ASSERT(!m_assertions.domTreeHasMutated());
    205     return m_current != other.m_current;
     113    return static_cast<ChildConstIterator<ElementType>&>(ElementConstIterator<ElementType>::traverseNextSibling());
    206114}
    207115
     
    217125inline ChildIterator<ElementType> ChildIteratorAdapter<ElementType>::begin()
    218126{
    219     return ChildIterator<ElementType>(Traversal<ElementType>::firstChild(m_root));
     127    return ChildIterator<ElementType>(m_root, Traversal<ElementType>::firstChild(m_root));
    220128}
    221129
     
    223131inline ChildIterator<ElementType> ChildIteratorAdapter<ElementType>::end()
    224132{
    225     return ChildIterator<ElementType>();
     133    return ChildIterator<ElementType>(m_root);
    226134}
    227135
     
    237145inline ChildConstIterator<ElementType> ChildConstIteratorAdapter<ElementType>::begin() const
    238146{
    239     return ChildConstIterator<ElementType>(Traversal<ElementType>::firstChild(m_root));
     147    return ChildConstIterator<ElementType>(m_root, Traversal<ElementType>::firstChild(m_root));
    240148}
    241149
     
    243151inline ChildConstIterator<ElementType> ChildConstIteratorAdapter<ElementType>::end() const
    244152{
    245     return ChildConstIterator<ElementType>();
     153    return ChildConstIterator<ElementType>(m_root);
    246154}
    247155
  • trunk/Source/WebCore/dom/DescendantIterator.h

    r154769 r154926  
    2727#define DescendantIterator_h
    2828
    29 #include "ElementTraversal.h"
    30 
    31 #if !ASSERT_DISABLED
    32 #include "DescendantIteratorAssertions.h"
    33 #endif
     29#include "ElementIterator.h"
    3430
    3531namespace WebCore {
    3632
    3733template <typename ElementType>
    38 class DescendantIterator {
     34class DescendantIterator : public ElementIterator<ElementType> {
    3935public:
    4036    DescendantIterator(const ContainerNode* root);
    4137    DescendantIterator(const ContainerNode* root, ElementType* current);
    4238    DescendantIterator& operator++();
    43     ElementType& operator*();
    44     ElementType* operator->();
    45     bool operator!=(const DescendantIterator& other) const;
    46 
    47 private:
    48     const ContainerNode* m_root;
    49     ElementType* m_current;
    50 
    51 #if !ASSERT_DISABLED
    52     DescendantIteratorAssertions m_assertions;
    53 #endif
    5439};
    5540
    5641template <typename ElementType>
    57 class DescendantConstIterator {
     42class DescendantConstIterator : public ElementConstIterator<ElementType>  {
    5843public:
    5944    DescendantConstIterator(const ContainerNode* root);
    6045    DescendantConstIterator(const ContainerNode* root, const ElementType* current);
    6146    DescendantConstIterator& operator++();
    62     const ElementType& operator*() const;
    63     const ElementType* operator->() const;
    64     bool operator!=(const DescendantConstIterator& other) const;
    65 
    66 private:
    67     const ContainerNode* m_root;
    68     const ElementType* m_current;
    69 
    70 #if !ASSERT_DISABLED
    71     DescendantIteratorAssertions m_assertions;
    72 #endif
    7347};
    7448
     
    10478template <typename ElementType>
    10579inline DescendantIterator<ElementType>::DescendantIterator(const ContainerNode* root)
    106     : m_root(root)
    107     , m_current(nullptr)
     80    : ElementIterator<ElementType>(root)
    10881{
    10982}
     
    11184template <typename ElementType>
    11285inline DescendantIterator<ElementType>::DescendantIterator(const ContainerNode* root, ElementType* current)
    113     : m_root(root)
    114     , m_current(current)
    115 #if !ASSERT_DISABLED
    116     , m_assertions(current)
    117 #endif
     86    : ElementIterator<ElementType>(root, current)
    11887{
    11988}
     
    12291inline DescendantIterator<ElementType>& DescendantIterator<ElementType>::operator++()
    12392{
    124     ASSERT(m_current);
    125     ASSERT(!m_assertions.domTreeHasMutated());
    126     m_current = Traversal<ElementType>::next(m_current, m_root);
    127 #if !ASSERT_DISABLED
    128     // Drop the assertion when the iterator reaches the end.
    129     if (!m_current)
    130         m_assertions.dropEventDispatchAssertion();
    131 #endif
    132     return *this;
    133 }
    134 
    135 template <typename ElementType>
    136 inline ElementType& DescendantIterator<ElementType>::operator*()
    137 {
    138     ASSERT(m_current);
    139     ASSERT(!m_assertions.domTreeHasMutated());
    140     return *m_current;
    141 }
    142 
    143 template <typename ElementType>
    144 inline ElementType* DescendantIterator<ElementType>::operator->()
    145 {
    146     ASSERT(m_current);
    147     ASSERT(!m_assertions.domTreeHasMutated());
    148     return m_current;
    149 }
    150 
    151 template <typename ElementType>
    152 inline bool DescendantIterator<ElementType>::operator!=(const DescendantIterator& other) const
    153 {
    154     ASSERT(m_root == other.m_root);
    155     ASSERT(!m_assertions.domTreeHasMutated());
    156     return m_current != other.m_current;
     93    return static_cast<DescendantIterator<ElementType>&>(ElementIterator<ElementType>::traverseNext());
    15794}
    15895
     
    16198template <typename ElementType>
    16299inline DescendantConstIterator<ElementType>::DescendantConstIterator(const ContainerNode* root)
    163     : m_root(root)
    164     , m_current(nullptr)
     100    : ElementConstIterator<ElementType>(root)
     101
    165102{
    166103}
     
    168105template <typename ElementType>
    169106inline DescendantConstIterator<ElementType>::DescendantConstIterator(const ContainerNode* root, const ElementType* current)
    170     : m_root(root)
    171     , m_current(current)
    172 #if !ASSERT_DISABLED
    173     , m_assertions(current)
    174 #endif
     107    : ElementConstIterator<ElementType>(root, current)
    175108{
    176109}
     
    179112inline DescendantConstIterator<ElementType>& DescendantConstIterator<ElementType>::operator++()
    180113{
    181     ASSERT(m_current);
    182     ASSERT(!m_assertions.domTreeHasMutated());
    183     m_current = Traversal<ElementType>::next(m_current, m_root);
    184 #if !ASSERT_DISABLED
    185     // Drop the assertion when the iterator reaches the end.
    186     if (!m_current)
    187         m_assertions.dropEventDispatchAssertion();
    188 #endif
    189     return *this;
    190 }
    191 
    192 template <typename ElementType>
    193 inline const ElementType& DescendantConstIterator<ElementType>::operator*() const
    194 {
    195     ASSERT(m_current);
    196     ASSERT(!m_assertions.domTreeHasMutated());
    197     return *m_current;
    198 }
    199 
    200 template <typename ElementType>
    201 inline const ElementType* DescendantConstIterator<ElementType>::operator->() const
    202 {
    203     ASSERT(m_current);
    204     ASSERT(!m_assertions.domTreeHasMutated());
    205     return m_current;
    206 }
    207 
    208 template <typename ElementType>
    209 inline bool DescendantConstIterator<ElementType>::operator!=(const DescendantConstIterator& other) const
    210 {
    211     ASSERT(m_root == other.m_root);
    212     ASSERT(!m_assertions.domTreeHasMutated());
    213     return m_current != other.m_current;
     114    return static_cast<DescendantConstIterator<ElementType>&>(ElementConstIterator<ElementType>::traverseNext());
    214115}
    215116
  • trunk/Source/WebCore/dom/ElementIteratorAssertions.h

    r154925 r154926  
    2424 */
    2525
    26 #ifndef DescendantIteratorAssertions_h
    27 #define DescendantIteratorAssertions_h
     26#ifndef ElementIteratorAssertions_h
     27#define ElementIteratorAssertions_h
    2828
    2929#include "Document.h"
     
    3232namespace WebCore {
    3333
    34 class DescendantIteratorAssertions {
     34class ElementIteratorAssertions {
    3535public:
    36     DescendantIteratorAssertions();
    37     DescendantIteratorAssertions(const Element* first);
     36    ElementIteratorAssertions();
     37    ElementIteratorAssertions(const Element* first);
    3838    bool domTreeHasMutated() const;
    3939    void dropEventDispatchAssertion();
     
    4545};
    4646
    47 inline DescendantIteratorAssertions::DescendantIteratorAssertions()
     47inline ElementIteratorAssertions::ElementIteratorAssertions()
    4848    : m_document(nullptr)
    4949    , m_initialDOMTreeVersion(0)
     
    5151}
    5252
    53 inline DescendantIteratorAssertions::DescendantIteratorAssertions(const Element* first)
     53inline ElementIteratorAssertions::ElementIteratorAssertions(const Element* first)
    5454    : m_document(first ? &first->document() : nullptr)
    5555    , m_initialDOMTreeVersion(m_document ? m_document->domTreeVersion() : 0)
     
    5858}
    5959
    60 inline bool DescendantIteratorAssertions::domTreeHasMutated() const
     60inline bool ElementIteratorAssertions::domTreeHasMutated() const
    6161{
    6262    return m_initialDOMTreeVersion && m_document && m_document->domTreeVersion() != m_initialDOMTreeVersion;
    6363}
    6464
    65 inline void DescendantIteratorAssertions::dropEventDispatchAssertion()
     65inline void ElementIteratorAssertions::dropEventDispatchAssertion()
    6666{
    6767    m_noEventDispatchAssertion = nullptr;
Note: See TracChangeset for help on using the changeset viewer.