Changeset 107173 in webkit
- Timestamp:
- Feb 8, 2012 8:41:19 PM (12 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r107172 r107173 1 2012-02-08 Andreas Kling <awesomekling@apple.com> 2 3 Increased style sharing for elements with presentation attributes. 4 <http://webkit.org/b/78199> 5 6 Reviewed by Antti Koivisto. 7 8 When determining whether two elements can share style, we can do a lot better. 9 Instead of comparing the attribute maps for exact equality, do a property-by-property 10 comparison of the attributeStyle() and the additionalAttributeStyle() (if any.) 11 12 This increases our style sharing hit rate and shaves 100ms off of each cycle on 13 Chromium's "Moz" page cycler test on my machine. 14 15 The function that compares attribute styles has O(n^2) runtime in the worst case, 16 where n is the number of properties in the styles. However, given the low number of 17 properties found in attribute styles, this should be fine, and it doesn't seem to 18 heat up in profiles. 19 20 * css/CSSStyleSelector.cpp: 21 (WebCore::attributeStylesEqual): 22 (WebCore::CSSStyleSelector::canShareStyleWithElement): 23 1 24 2012-02-08 Raymond Liu <raymond.liu@intel.com> 2 25 -
trunk/Source/WebCore/css/CSSStyleSelector.cpp
r107162 r107173 1195 1195 } 1196 1196 1197 // This function makes some assumptions that only make sense for attribute styles (we only compare CSSProperty::id() and CSSProperty::value().) 1198 static inline bool attributeStylesEqual(StylePropertySet* a, StylePropertySet* b) 1199 { 1200 if (a == b) 1201 return true; 1202 if (a->propertyCount() != b->propertyCount()) 1203 return false; 1204 unsigned propertyCount = a->propertyCount(); 1205 for (unsigned i = 0; i < propertyCount; ++i) { 1206 const CSSProperty& aProperty = a->propertyAt(i); 1207 unsigned j; 1208 for (j = 0; j < propertyCount; ++j) { 1209 const CSSProperty& bProperty = b->propertyAt(j); 1210 if (aProperty.id() != bProperty.id()) 1211 continue; 1212 // We could get a few more hits by comparing cssText() here, but that gets expensive quickly. 1213 if (aProperty.value() != bProperty.value()) 1214 return false; 1215 break; 1216 } 1217 if (j == propertyCount) 1218 return false; 1219 } 1220 return true; 1221 } 1222 1197 1223 bool CSSStyleSelector::canShareStyleWithElement(StyledElement* element) const 1198 1224 { … … 1210 1236 return false; 1211 1237 if (!!element->attributeStyle() != !!m_styledElement->attributeStyle()) 1238 return false; 1239 StylePropertySet* additionalAttributeStyleA = element->additionalAttributeStyle().get(); 1240 StylePropertySet* additionalAttributeStyleB = m_styledElement->additionalAttributeStyle().get(); 1241 if (!additionalAttributeStyleA != !additionalAttributeStyleB) 1212 1242 return false; 1213 1243 if (element->isLink() != m_element->isLink()) … … 1275 1305 return false; 1276 1306 1277 if (element->attributeStyle() && !element->attributeMap()->mapsEquivalent(m_styledElement->attributeMap())) 1307 if (element->attributeStyle() && !attributeStylesEqual(element->attributeStyle(), m_styledElement->attributeStyle())) 1308 return false; 1309 1310 if (additionalAttributeStyleA && !attributeStylesEqual(additionalAttributeStyleA, additionalAttributeStyleB)) 1278 1311 return false; 1279 1312
Note: See TracChangeset
for help on using the changeset viewer.