Title: [111751] trunk/Source/WebCore
- Revision
- 111751
- Author
- jchaffr...@webkit.org
- Date
- 2012-03-22 13:36:34 -0700 (Thu, 22 Mar 2012)
Log Message
Enable style sharing for elements with a style attribute
https://bugs.webkit.org/show_bug.cgi?id=81523
Reviewed by Antti Koivisto.
Memory improvement change only.
Overall, this is a performance wash (some benchmarks may regress a bit due to the increase in time taken
by CSSStyleSelector::locateSharedStyle as we try more nodes, others increase their performance due to style sharing).
Instrumenting our style sharing, this should give us some nice memory shavings on some benchmarks:
- HTML5 isn't impacted as it doesn't use much inline style
- page cyclers' intl1 showed a 6% increase in style sharing.
* css/CSSStyleSelector.cpp:
(WebCore::CSSStyleSelector::canShareStyleWithElement):
This method now handles inline style like presentation attributes on the element.
(WebCore::CSSStyleSelector::collectMatchingRulesForList):
(WebCore::CSSStyleSelector::locateSharedStyle):
Don't bail out for an element with an inline style declaration.
(WebCore::CSSStyleSelector::stylesEqual):
Generalized attributeStylesEqual to share the logic between attribute and
inline style property set. This means that attribute checks are actually
doing a little extra more work but that didn't impact our benchmarks.
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (111750 => 111751)
--- trunk/Source/WebCore/ChangeLog 2012-03-22 20:29:22 UTC (rev 111750)
+++ trunk/Source/WebCore/ChangeLog 2012-03-22 20:36:34 UTC (rev 111751)
@@ -1,3 +1,32 @@
+2012-03-22 Julien Chaffraix <jchaffr...@webkit.org>
+
+ Enable style sharing for elements with a style attribute
+ https://bugs.webkit.org/show_bug.cgi?id=81523
+
+ Reviewed by Antti Koivisto.
+
+ Memory improvement change only.
+
+ Overall, this is a performance wash (some benchmarks may regress a bit due to the increase in time taken
+ by CSSStyleSelector::locateSharedStyle as we try more nodes, others increase their performance due to style sharing).
+
+ Instrumenting our style sharing, this should give us some nice memory shavings on some benchmarks:
+ - HTML5 isn't impacted as it doesn't use much inline style
+ - page cyclers' intl1 showed a 6% increase in style sharing.
+
+ * css/CSSStyleSelector.cpp:
+ (WebCore::CSSStyleSelector::canShareStyleWithElement):
+ This method now handles inline style like presentation attributes on the element.
+
+ (WebCore::CSSStyleSelector::collectMatchingRulesForList):
+ (WebCore::CSSStyleSelector::locateSharedStyle):
+ Don't bail out for an element with an inline style declaration.
+
+ (WebCore::CSSStyleSelector::stylesEqual):
+ Generalized attributeStylesEqual to share the logic between attribute and
+ inline style property set. This means that attribute checks are actually
+ doing a little extra more work but that didn't impact our benchmarks.
+
2012-03-22 Kevin Ollivier <kev...@theolliviers.com>
[wx] Unreviewed. WebDOM build fix after array type changes.
Modified: trunk/Source/WebCore/css/CSSStyleSelector.cpp (111750 => 111751)
--- trunk/Source/WebCore/css/CSSStyleSelector.cpp 2012-03-22 20:29:22 UTC (rev 111750)
+++ trunk/Source/WebCore/css/CSSStyleSelector.cpp 2012-03-22 20:36:34 UTC (rev 111751)
@@ -1160,8 +1160,6 @@
return 0;
#endif
StyledElement* p = static_cast<StyledElement*>(parent);
- if (p->inlineStyle())
- return 0;
#if ENABLE(SVG)
if (p->isSVGElement() && static_cast<SVGElement*>(p)->animatedSMILStyleProperties())
return 0;
@@ -1253,8 +1251,7 @@
return true;
}
-// This function makes some assumptions that only make sense for attribute styles (we only compare CSSProperty::id() and CSSProperty::value().)
-static inline bool attributeStylesEqual(StylePropertySet* a, StylePropertySet* b)
+static inline bool stylesEqual(const StylePropertySet* a, const StylePropertySet* b)
{
if (a == b)
return true;
@@ -1268,9 +1265,16 @@
const CSSProperty& bProperty = b->propertyAt(j);
if (aProperty.id() != bProperty.id())
continue;
+
+ // We don't check the short-hand property because long-hand vs short-hand is handled by checking the property set's count above.
+ if (aProperty.isImportant() != bProperty.isImportant()
+ || aProperty.isInherited() != bProperty.isInherited() || aProperty.isImplicit() != bProperty.isImplicit())
+ return false;
+
// We could get a few more hits by comparing cssText() here, but that gets expensive quickly.
if (aProperty.value() != bProperty.value())
return false;
+
break;
}
if (j == propertyCount)
@@ -1296,14 +1300,15 @@
return false;
if (element->hasClass() != m_element->hasClass())
return false;
- if (element->inlineStyle())
- return false;
#if ENABLE(SVG)
if (element->isSVGElement() && static_cast<SVGElement*>(element)->animatedSMILStyleProperties())
return false;
#endif
if (!!element->attributeStyle() != !!m_styledElement->attributeStyle())
return false;
+ if (!!element->inlineStyle() != !!m_styledElement->inlineStyle())
+ return false;
+
StylePropertySet* additionalAttributeStyleA = element->additionalAttributeStyle();
StylePropertySet* additionalAttributeStyleB = m_styledElement->additionalAttributeStyle();
if (!additionalAttributeStyleA != !additionalAttributeStyleB)
@@ -1387,12 +1392,15 @@
if (element->hasClass() && m_element->getAttribute(classAttr) != element->getAttribute(classAttr))
return false;
- if (element->attributeStyle() && !attributeStylesEqual(element->attributeStyle(), m_styledElement->attributeStyle()))
+ if (element->attributeStyle() && !stylesEqual(element->attributeStyle(), m_styledElement->attributeStyle()))
return false;
- if (additionalAttributeStyleA && !attributeStylesEqual(additionalAttributeStyleA, additionalAttributeStyleB))
+ if (additionalAttributeStyleA && !stylesEqual(additionalAttributeStyleA, additionalAttributeStyleB))
return false;
+ if (element->inlineStyle() && !stylesEqual(element->inlineStyle(), m_styledElement->inlineStyle()))
+ return false;
+
if (element->isLink() && m_elementLinkState != style->insideLink())
return false;
@@ -1424,9 +1432,7 @@
{
if (!m_styledElement || !m_parentStyle)
return 0;
- // If the element has inline style it is probably unique.
- if (m_styledElement->inlineStyle())
- return 0;
+
#if ENABLE(SVG)
if (m_styledElement->isSVGElement() && static_cast<SVGElement*>(m_styledElement)->animatedSMILStyleProperties())
return 0;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes