JIT Compile simple cases of :nth-last-child()
https://bugs.webkit.org/show_bug.cgi?id=141053

Reviewed by Andreas Kling.

Source/WebCore:

This patch adds the code generator for :nth-last-child(), skipping
any :nth-last-child(An+B of selector list).

The code generator is boring here, nothing fancy.
There is no optimization opportunity here so it is basically the same
speed as the code generated by Clang when the simple selector is alone.

The only reason to JIT compile this is to avoid going to slow-path
for every selector that contain :nth-last-child().

* cssjit/SelectorCompiler.cpp:
(WebCore::SelectorCompiler::addNthChildType):
The code creating the intermediate representation of :nth-child() is exactly
the same as what we need for :nth-last-child(). I extracted the code from addPseudoClassType()
and share it for both simple selectors.

(WebCore::SelectorCompiler::addPseudoClassType):
I fail :nth-last-child(An+B of selector list). Let's add it later.

(WebCore::SelectorCompiler::minimumRegisterRequirements):
Oops, there was a bug with nthChildOfFilters.

(WebCore::SelectorCompiler::hasAnyCombinators):
(WebCore::SelectorCompiler::computeBacktrackingMemoryRequirements):
(WebCore::SelectorCompiler::computeBacktrackingInformation):
(WebCore::SelectorCompiler::SelectorCodeGenerator::generateElementMatching):
(WebCore::SelectorCompiler::setChildrenAffectedByBackwardPositionalRules):
(WebCore::SelectorCompiler::SelectorCodeGenerator::generateElementIsNthLastChild):

LayoutTests:

There was almost no test coverage for :nth-last-child(). I copied the main tests
from :nth-child() and updated the expected results.

This is not ideal because we should have style update tests targetting
backward invalidation... Still better than nothing :)

* fast/selectors/nth-last-child-as-first-simple-selector-style-update-expected.txt: Added.
* fast/selectors/nth-last-child-as-first-simple-selector-style-update.html: Added.
* fast/selectors/nth-last-child-basics-expected.txt: Added.
* fast/selectors/nth-last-child-basics.html: Added.
* fast/selectors/nth-last-child-bounds-expected.txt: Added.
* fast/selectors/nth-last-child-bounds.html: Added.
* fast/selectors/nth-last-child-chained-expected.txt: Added.
* fast/selectors/nth-last-child-chained.html: Added.
* fast/selectors/nth-last-child-on-root-expected.txt: Added.
* fast/selectors/nth-last-child-on-root.html: Added.
* fast/selectors/nth-last-child-style-update-expected.txt: Added.
* fast/selectors/nth-last-child-style-update.html: Added.
* fast/selectors/nth-last-child-with-backtracking-expected.txt: Added.
* fast/selectors/nth-last-child-with-backtracking.html: Added.
* fast/selectors/several-nth-last-child-expected.txt: Added.
* fast/selectors/several-nth-last-child.html: Added.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@179535 268f45cc-cd09-0410-ab3c-d52691b4dbfc
19 files changed