inline bool nsNthIndexCache::IndexDeterminedFromPreviousSibling(nsIContent* aSibling, Element* aChild, bool aIsOfType, bool aIsFromEnd, const Cache& aCache, int32_t& aResult) { if (SiblingMatchesElement(aSibling, aChild, aIsOfType)) { Cache::Ptr siblingEntry = aCache.lookup(aSibling); if (siblingEntry) { int32_t siblingIndex = siblingEntry->value; NS_ASSERTION(siblingIndex != 0, "How can a non-anonymous node have an anonymous sibling?"); if (siblingIndex > 0) { // At this point, aResult is a count of how many elements matching // aChild we have seen after aSibling, including aChild itself. // |siblingIndex| is the index of aSibling. // So if aIsFromEnd, we want |aResult = siblingIndex - aResult| and // otherwise we want |aResult = siblingIndex + aResult|. NS_ABORT_IF_FALSE(aIsFromEnd == 0 || aIsFromEnd == 1, "Bogus bool value"); aResult = siblingIndex + aResult * (1 - 2 * aIsFromEnd); return true; } } ++aResult; } return false; }