CSS JIT: add support for :last-child and :only-child
authorbenjamin@webkit.org <benjamin@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 7 Apr 2014 02:25:19 +0000 (02:25 +0000)
committerbenjamin@webkit.org <benjamin@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 7 Apr 2014 02:25:19 +0000 (02:25 +0000)
commite6b43e3503ef58d64ddd5565612002dd0cb421a3
tree580d0be3ec14f50f657a28023c13049da2334e28
parent45826436fe3340c861620e77699d4dc10e40cd02
CSS JIT: add support for :last-child and :only-child
https://bugs.webkit.org/show_bug.cgi?id=131283

Reviewed by Andreas Kling.

This is the straightforward implementation of :last-child and :only-child.

Both are extremely similar to :first-child. There are only minor differences:
-:last-child has an additional check for the flag IsParsingChildrenFinished.
-:only-child is like :first-child + :last-child but with combined marking.

* cssjit/SelectorCompiler.cpp:
(WebCore::SelectorCompiler::addPseudoType):
(WebCore::SelectorCompiler::SelectorCodeGenerator::generateWalkToNextAdjacentElement):
(WebCore::SelectorCompiler::SelectorCodeGenerator::generateElementMatching):
(WebCore::SelectorCompiler::SelectorCodeGenerator::jumpIfNoPreviousAdjacentElement):
(WebCore::SelectorCompiler::SelectorCodeGenerator::generateElementIsFirstChild):
(WebCore::SelectorCompiler::SelectorCodeGenerator::jumpIfNoNextAdjacentElement):
(WebCore::SelectorCompiler::markElementWithSetChildrenAffectedByLastChildRules):
(WebCore::SelectorCompiler::setLastChildState):
(WebCore::SelectorCompiler::SelectorCodeGenerator::generateElementIsLastChild):
(WebCore::SelectorCompiler::markElementWithSetChildrenAffectedByFirstChildAndLastChildRules):
(WebCore::SelectorCompiler::setOnlyChildState):
(WebCore::SelectorCompiler::SelectorCodeGenerator::generateElementIsOnlyChild):
* dom/Node.h:
(WebCore::Node::nextSiblingMemoryOffset):
(WebCore::Node::flagIsParsingChildrenFinished):
* rendering/style/RenderStyle.h:
Removed the unused flags, I will add them back later as needed.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@166862 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/WebCore/ChangeLog
Source/WebCore/cssjit/SelectorCompiler.cpp
Source/WebCore/dom/Node.h
Source/WebCore/rendering/style/RenderStyle.h