Index: Source/core/css/SiblingTraversalStrategies.h |
diff --git a/Source/core/css/SiblingTraversalStrategies.h b/Source/core/css/SiblingTraversalStrategies.h |
index 8751e94a2cad4010993af6d0fc0a4d1d9b7a728f..65885c93549f52c416dcee7237b34c627ae21a06 100644 |
--- a/Source/core/css/SiblingTraversalStrategies.h |
+++ b/Source/core/css/SiblingTraversalStrategies.h |
@@ -78,14 +78,8 @@ inline bool DOMSiblingTraversalStrategy::isLastOfType(Element* element, const Qu |
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::countElementsOfTypeBefore(Element* eleme |
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; |
} |