Summary: | :nth-child() is not re-evaluated when adding or removing children | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Product: | WebKit | Reporter: | Simon Fraser (smfr) <simon.fraser> | ||||||||
Component: | CSS | Assignee: | Dave Hyatt <hyatt> | ||||||||
Status: | RESOLVED FIXED | ||||||||||
Severity: | Normal | CC: | hyatt | ||||||||
Priority: | P2 | ||||||||||
Version: | 528+ (Nightly build) | ||||||||||
Hardware: | Mac | ||||||||||
OS: | OS X 10.5 | ||||||||||
URL: | http://www.quirksmode.org/css/nthchild.html | ||||||||||
Bug Depends on: | |||||||||||
Bug Blocks: | 9610 | ||||||||||
Attachments: |
|
Description
Simon Fraser (smfr)
2009-06-12 17:44:53 PDT
Created attachment 31265 [details]
Patch, testcase, changelog
Comment on attachment 31265 [details] Patch, testcase, changelog > -Node::StyleChange Node::diff( RenderStyle *s1, RenderStyle *s2 ) > +Node::StyleChange Node::diff(RenderStyle *s1, RenderStyle *s2) Since you're touching this line to tweak style, please move the "*" characters next to the type name too. > + bool pseudoClassStateEquivalent(const RenderStyle* style) > + { > + return m_affectedByEmpty == style->affectedByEmpty() && > + (!m_affectedByEmpty || m_emptyState == style->emptyState()) && > + m_firstChildState == style->firstChildState() && > + m_lastChildState == style->lastChildState() && > + m_childIndex == style->childIndex(); > + } The WebKit coding style (and my person preference) put the operators on the starts of lines, not the ends of lines. Like this: return m_affectedByEmpty == style->affectedByEmpty() && (!m_affectedByEmpty || m_emptyState == style->emptyState()) && m_firstChildState == style->firstChildState() && m_lastChildState == style->lastChildState() && m_childIndex == style->childIndex(); r=me Landed with a little extra const cleanup: http://trac.webkit.org/changeset/44671 I'd like to talk about this bug further. I don't think this was the right approach. Reopening, as I'd like this to be revisited. See checkForSiblingStyleChanges in Element.cpp, which should have handled this situation without resorting to destroying the render tree and recreating it. I assume there is a bug in that method that needs to be investigated. Your solution, though, is needlessly destroying the render objects now on child changes, which should not be necessary and is bad for performance. Created attachment 31271 [details]
Patch
Minusing this as it will cause inefficiency when nested positional rules are used, e.g., nth-child inside of nth-child. Rather than dirtying for style recalc, I should just patch the check that does the internal update. Created attachment 31272 [details]
Better patch
Comment on attachment 31272 [details]
Better patch
r=me
Fixed in r44673. |