Index: Source/core/css/SiblingTraversalStrategies.h |
=================================================================== |
--- Source/core/css/SiblingTraversalStrategies.h (revision 159683) |
+++ Source/core/css/SiblingTraversalStrategies.h (working copy) |
@@ -78,14 +78,8 @@ |
inline int DOMSiblingTraversalStrategy::countElementsBefore(Element* element) const |
{ |
int count = 0; |
- for (const Element* sibling = element->previousElementSibling(); sibling; sibling = sibling->previousElementSibling()) { |
- unsigned index = sibling->childIndex(); |
- if (index) { |
- count += index; |
- break; |
- } |
+ for (const Element* sibling = element->previousElementSibling(); sibling; sibling = sibling->previousElementSibling()) |
count++; |
- } |
return count; |
} |
@@ -104,8 +98,14 @@ |
inline int DOMSiblingTraversalStrategy::countElementsAfter(Element* element) const |
{ |
int count = 0; |
- for (const Element* sibling = element->nextElementSibling(); sibling; sibling = sibling->nextElementSibling()) |
+ for (const Element* sibling = element->nextElementSibling(); sibling; sibling = sibling->nextElementSibling()) { |
+ unsigned index = sibling->childIndex(); |
+ if (index) { |
+ count += index; |
+ break; |
+ } |
++count; |
+ } |
return count; |
} |