mozilla/servo — pull request #1971 by Constellation (2014-03-22 17:50:20+00:00)
Title: Selector matching quickly fails depending on next selector matching status

Introducing 3 fail types, FailedLocally, FailedGlobally and FailedSibling.
And depending on next selector matching status, selector matching should
quickly fails.

For example, when the selector "d1 d2 a" is provided and we cannot find
an appropriate ancestor node for d1, this selector failed globally since
even if d2 is moved to more upper node, the candidates for d1 becomes less
than before and d1 always fails.
And another example is siblings. when the selector "b1 + b2 ~ d1 a" is
providied and we cannot find an appropriate brother node for b1, stacked
sibling checks of this selector fails ("b1 + b2 ~") and we should
restart d1 from matching.