Created attachment 527885 [details] [diff] [review] patch Either bz pointed out this bug during reviews of some of the :visited work (bug 147777, etc.), or I noticed it while addressing comments. I wrote a patch to fix it ages ago, but never got around to writing a test, which I just did. In any case, when a style change on the root element includes a change only to the link visitedness or to link-ness, the style change doesn't take effect correctly because it's defeated by an incorrect check in the style context sharing code. This patch fixes it. I confirmed that the test fails without the patch and passes with it.
Comment on attachment 527885 [details] [diff] [review] patch I'm pretty sure I didn't point this out, but it certainly makes sense! r=me
I wonder whether we can widen this optimization, by the way. Seems like it should be valid any time oldContext and newContext have the same parent, whether that parent is null or not. Though I don't know how often this situation arises.....
We already have the optimization for the other cases through sibling sharing, as long as we haven't blown past the cache length (currently 10). See nsStyleContext::FindChildWithRules.
Oh, right. OK, then!