These 2 methods go back and forth between element siblings a lot. Their implementation could be simplified by using Element::previous/nextElementSibling, which would also improve readability.
Incidentally, while looking at those functions: there are several places in the pseudo-class implementation code, where the code is allowed to break out, fall all the way through and return the default 'true' if some initial criterion is not met. Some of those cases seem questionable to me, such as with "if (!sel->parseNth())" (?).
Created attachment 125222 [details] Patch
Comment on attachment 125222 [details] Patch Looks great!
Comment on attachment 125222 [details] Patch Rejecting attachment 125222 [details] from commit-queue. Failed to run "['/mnt/git/webkit-commit-queue/Tools/Scripts/webkit-patch', '--status-host=queues.webkit.org', '-..." exit_code: 2 Last 500 characters of output: angeLog Hunk #1 succeeded at 1 with fuzz 3. patching file Source/WebCore/css/SelectorChecker.cpp patching file Source/WebCore/dom/Element.cpp Hunk #1 succeeded at 1740 (offset 6 lines). patching file Source/WebCore/dom/Element.h Hunk #1 FAILED at 499. 1 out of 1 hunk FAILED -- saving rejects to file Source/WebCore/dom/Element.h.rej Failed to run "[u'/mnt/git/webkit-commit-queue/Tools/Scripts/svn-apply', u'--force', u'--reviewer', u'Andreas Kl..." exit_code: 1 cwd: /mnt/git/webkit-commit-queue/ Full output: http://queues.webkit.org/results/11420113
Committed r106626: <http://trac.webkit.org/changeset/106626>