Chromium Code Reviews| Index: Source/core/css/SelectorChecker.cpp |
| diff --git a/Source/core/css/SelectorChecker.cpp b/Source/core/css/SelectorChecker.cpp |
| index cde161331e076fd622ec972a06ee67b4f66e1a85..7195749877c54d0d4caa259ea4cfdef63f0d6c79 100644 |
| --- a/Source/core/css/SelectorChecker.cpp |
| +++ b/Source/core/css/SelectorChecker.cpp |
| @@ -494,7 +494,8 @@ bool SelectorChecker::checkOne(const SelectorCheckingContext& context, const Sib |
| if (!selector->parseNth()) |
| break; |
| if (Element* parentElement = element->parentElement()) { |
| - int count = 1 + siblingTraversalStrategy.countElementsBefore(element); |
| + // FIXME: We should always have the index passed in to avoid needing countElementsBefore. |
| + int count = context.childIndex ? context.childIndex : 1 + siblingTraversalStrategy.countElementsBefore(element); |
|
esprehn
2013/06/05 00:12:26
This global is so gross. :(
|
| if (m_mode == ResolvingStyle) { |
| RenderStyle* childStyle = context.elementStyle ? context.elementStyle : element->renderStyle(); |
| element->setChildIndex(count); |
| @@ -527,7 +528,8 @@ bool SelectorChecker::checkOne(const SelectorCheckingContext& context, const Sib |
| parentElement->setChildrenAffectedByBackwardPositionalRules(); |
| if (!parentElement->isFinishedParsingChildren()) |
| return false; |
| - int count = 1 + siblingTraversalStrategy.countElementsAfter(element); |
| + // FIXME: We should always have the index passed in to avoid needing countElementsAfter. |
| + int count = context.childIndex ? context.childIndex : 1 + siblingTraversalStrategy.countElementsAfter(element); |
| if (selector->matchNth(count)) |
| return true; |
| } |