Increased style sharing for elements with presentation attributes.
authorkling@webkit.org <kling@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 9 Feb 2012 04:41:19 +0000 (04:41 +0000)
committerkling@webkit.org <kling@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 9 Feb 2012 04:41:19 +0000 (04:41 +0000)
commitae03d0a33778539b58a451f9acb6fb69e032336f
tree132916e4fa44c4e398fe535d27a11c91bda5b0c1
parent9f1de07a2d16680c73eafd1b02abe704798d3a5c
Increased style sharing for elements with presentation attributes.
<http://webkit.org/b/78199>

Reviewed by Antti Koivisto.

When determining whether two elements can share style, we can do a lot better.
Instead of comparing the attribute maps for exact equality, do a property-by-property
comparison of the attributeStyle() and the additionalAttributeStyle() (if any.)

This increases our style sharing hit rate and shaves 100ms off of each cycle on
Chromium's "Moz" page cycler test on my machine.

The function that compares attribute styles has O(n^2) runtime in the worst case,
where n is the number of properties in the styles. However, given the low number of
properties found in attribute styles, this should be fine, and it doesn't seem to
heat up in profiles.

* css/CSSStyleSelector.cpp:
(WebCore::attributeStylesEqual):
(WebCore::CSSStyleSelector::canShareStyleWithElement):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@107173 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/WebCore/ChangeLog
Source/WebCore/css/CSSStyleSelector.cpp