haikuwebkit/LayoutTests/fast/css/nth-last-child-of-style-sha...

14 lines
371 B
HTML
Raw Permalink Normal View History

Implement the matching for :nth-last-child(An+B of selector-list) https://bugs.webkit.org/show_bug.cgi?id=138650 Patch by Benjamin Poulain <bpoulain@apple.com> on 2014-11-13 Reviewed by Andreas Kling. Source/WebCore: Matching is trivial based on the existing CSS4 infrastructure. The tricky part is style invalidation. In the cases of the old :nth-last-child() and :nth-last-of-type(), we were using the flag ChildrenAffectedByBackwardPositionalRules. The problem with ChildrenAffectedByBackwardPositionalRules is that it only invalidate subtrees when nodes are being added or removed. It is a valuable optimization by itself since tree updates are less common than property updates. For the case of property updates, I have added the new flag "ChildrenAffectedByPropertyBasedBackwardPositionalRules". It pretty much work the same way but invalidates subtree on style recalc. Tests: fast/css/nth-child-and-nth-last-child.html fast/css/nth-last-child-of-classname.html fast/css/nth-last-child-of-complex-selector.html fast/css/nth-last-child-of-compound-selector.html fast/css/nth-last-child-of-style-sharing-1.html fast/css/nth-last-child-of-style-sharing-2.html fast/css/nth-last-child-of-style-update-optimization.html fast/css/nth-last-child-of-tagname.html fast/selectors/nth-last-child-of-class-style-update.html * css/SelectorChecker.cpp: (WebCore::SelectorChecker::checkOne): * dom/Element.cpp: (WebCore::Element::setChildrenAffectedByPropertyBasedBackwardPositionalRules): (WebCore::Element::hasFlagsSetDuringStylingOfChildren): (WebCore::Element::rareDataChildrenAffectedByPropertyBasedBackwardPositionalRules): * dom/Element.h: (WebCore::Element::childrenAffectedByPropertyBasedBackwardPositionalRules): * dom/ElementRareData.h: (WebCore::ElementRareData::childrenAffectedByPropertyBasedBackwardPositionalRules): (WebCore::ElementRareData::setChildrenAffectedByPropertyBasedBackwardPositionalRules): (WebCore::ElementRareData::ElementRareData): (WebCore::ElementRareData::resetDynamicRestyleObservations): * dom/Node.cpp: (WebCore::Node::updateAncestorsForStyleRecalc): (WebCore::Node::setNeedsStyleRecalc): (WebCore::markAncestorsWithChildNeedsStyleRecalc): Deleted. * dom/Node.h: Unlike the other marking steps, ChildrenAffectedByPropertyBasedBackwardPositionalRules can only really affect one level (because we don't have a parent-selectors). It is quite easy to mark large trees with ChildrenAffectedByPropertyBasedBackwardPositionalRules by using a selector list that is a bit too generic. When that happen, we must be careful not invalidating everything, just the affected subtree. LayoutTests: * fast/selectors/nth-last-child-of-class-style-update-expected.txt: Added. * fast/selectors/nth-last-child-of-class-style-update.html: Added. Verify simple cases of style update. * fast/css/nth-last-child-of-style-update-optimization-expected.txt: Added. * fast/css/nth-last-child-of-style-update-optimization.html: Added. Verify that style invalidation stays reasonable. * fast/css/nth-last-child-of-style-sharing-1-expected.html: Added. * fast/css/nth-last-child-of-style-sharing-1.html: Added. * fast/css/nth-last-child-of-style-sharing-2-expected.html: Added. * fast/css/nth-last-child-of-style-sharing-2.html: Added. Check that style sharing is disabled for elements matching :nth-last-child(). * fast/css/nth-child-and-nth-last-child-expected.html: Added. * fast/css/nth-child-and-nth-last-child.html: Added. Test uniqueness testing by combining :nth-child() and :nth-last-child(). * fast/css/nth-last-child-of-classname-expected.html: Added. * fast/css/nth-last-child-of-classname.html: Added. * fast/css/nth-last-child-of-complex-selector-expected.html: Added. * fast/css/nth-last-child-of-complex-selector.html: Added. * fast/css/nth-last-child-of-compound-selector-expected.html: Added. * fast/css/nth-last-child-of-compound-selector.html: Added. * fast/css/nth-last-child-of-tagname-expected.html: Added. * fast/css/nth-last-child-of-tagname.html: Added. Test matching, those are the "last-child" counterpart of the existing "nth-child-of" tests. Canonical link: https://commits.webkit.org/156549@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@176084 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2014-11-13 21:00:33 +00:00
<!doctype html>
<html>
<body>
<p>Test that style-sharing does not ignore cases matching :nth-last-child(An+B of selector list).</p>
<p style="background-color: lime">Target</p>
<p>Target</p>
<p>Target</p>
<p style="background-color: lime">Target</p>
<p>Target</p>
<p>Target</p>
<p style="background-color: lime">Target</p>
</body>
</html>