Version: (using KDE KDE 3.3.0) Installed from: Unspecified Just adding the bug for record-keeping This is the same bug that creates false results for :only-child and :nth-last-child. It happens because elements in lists are styled one at a time, and at the time their style is determined, they are all the currently the last element. I propably happens for other structures than lists, but I think lists demonstrates it most easily. A possible fix could be too add an extra late restyling run for structures that have been optimized this way. During the first run :last structures would return false, and mark the container as last-child-dirty to indicate a late restyling is needed.
Created attachment 8691 [details] Test case
yes, there are other instances of that, see e.g #89249 Maybe restyling from a Renderer's ::close() method would be the easier way, since (I believe?) this can only happen while parsing.
(but then maybe the element's style should be marked as somehow uncertain by the pseudo class selection process)
Can't it unmark the previous one? This would solve the problem for :last-child, but I doubt it would work for :nth-*.
I'm speaking about marking the parent node, not the child ; it's because a container has not been entirely parsed (and its associated renderer closed) that new childs can get a too early pseudo-class selection.
Bug #89249 means :empty as well. Still no CSS2 pseudo-classes. I think the safe choice is to start by returning false on uncertain classes, and then restyle them completely later. The parent is marked and the element itself is marked. I hadn't thought about Renderer close(), I thought it would be more logical for the code to belong under html/. The two places in htmlparser.cpp where closeRenderer is called looks promising.
Created attachment 8701 [details] Proposed patch Fixed all the current problems, but a few issues remain. First of all tables or other structures where :last-child already work shouldn't be restyled late. Second I discovered the selector test css3-modsel-d4.html. It seems :first-child and :last-child are supposed to be dynamically updated, if the ECMAscript are used to move elements around. We don't do that.
CVS commit by carewolf: Fix structural pseudo-classes that needs to know the object or parents full extent (:empty, :last-child, :only-child and :nth-last-child) BUG: 89249, 95266 M +12 -0 ChangeLog 1.356 M +42 -12 css/cssstyleselector.cpp 1.338 M +4 -3 html/htmlparser.cpp 1.353 M +26 -0 xml/dom_elementimpl.cpp 1.203 M +9 -0 xml/dom_elementimpl.h 1.119 M +7 -0 xml/dom_nodeimpl.cpp 1.245 M +7 -0 xml/dom_nodeimpl.h 1.164 M +1 -1 xml/xml_tokenizer.cpp 1.60