Title: [98803] trunk/Source/WebCore
Revision
98803
Author
an...@apple.com
Date
2011-10-29 02:36:12 -0700 (Sat, 29 Oct 2011)

Log Message

Tighten font change conditions in matched declaration cache
https://bugs.webkit.org/show_bug.cgi?id=71026

Reviewed by Darin Adler.

We currently test if font description has changed to see if all properties need to be applied. However
only a few size related metrics can actually affect other properties. We can just test those, making 
the cache somewhat more effective while also making the equality test faster.
        
* css/CSSStyleSelector.cpp:
(WebCore::fontDifferenceAffectsNonInherited):
(WebCore::CSSStyleSelector::applyMatchedDeclarations):
    
    Test for text computedSize, xHeight and orientation only. Other text properties don't affect computed
    values of non-text CSS properties.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (98802 => 98803)


--- trunk/Source/WebCore/ChangeLog	2011-10-29 09:10:31 UTC (rev 98802)
+++ trunk/Source/WebCore/ChangeLog	2011-10-29 09:36:12 UTC (rev 98803)
@@ -1,3 +1,21 @@
+2011-10-29  Antti Koivisto  <an...@apple.com>
+
+        Tighten font change conditions in matched declaration cache
+        https://bugs.webkit.org/show_bug.cgi?id=71026
+
+        Reviewed by Darin Adler.
+
+        We currently test if font description has changed to see if all properties need to be applied. However
+        only a few size related metrics can actually affect other properties. We can just test those, making 
+        the cache somewhat more effective while also making the equality test faster.
+        
+        * css/CSSStyleSelector.cpp:
+        (WebCore::fontDifferenceAffectsNonInherited):
+        (WebCore::CSSStyleSelector::applyMatchedDeclarations):
+    
+            Test for text computedSize, xHeight and orientation only. Other text properties don't affect computed
+            values of non-text CSS properties.
+
 2011-10-29  Adam Barth  <aba...@webkit.org>
 
         DOMURL should keep its own state rather than storing it on ScriptExecutionContext

Modified: trunk/Source/WebCore/css/CSSStyleSelector.cpp (98802 => 98803)


--- trunk/Source/WebCore/css/CSSStyleSelector.cpp	2011-10-29 09:10:31 UTC (rev 98802)
+++ trunk/Source/WebCore/css/CSSStyleSelector.cpp	2011-10-29 09:36:12 UTC (rev 98803)
@@ -2234,6 +2234,17 @@
     return true;
 }
 
+static bool fontDifferenceAffectsNonInherited(const RenderStyle* style, const RenderStyle* cachedStyle)
+{
+    if (style->fontMetrics().xHeight() != cachedStyle->fontMetrics().xHeight())
+        return true;
+    if (style->fontDescription().computedSize() != cachedStyle->fontDescription().computedSize())
+        return true;
+    if (style->fontDescription().orientation() != cachedStyle->fontDescription().orientation())
+        return true;
+    return false;
+}
+
 void CSSStyleSelector::applyMatchedDeclarations(const MatchResult& matchResult)
 {
     unsigned cacheHash = matchResult.isCacheable ? computeDeclarationHash(m_matchedDecls.data(), m_matchedDecls.size()) : 0;
@@ -2268,8 +2279,8 @@
     if (m_lineHeightValue)
         applyProperty(CSSPropertyLineHeight, m_lineHeightValue);
 
-    // Many properties depend on the font. If it changes we just apply all properties.
-    if (cachedStyle && cachedStyle->fontDescription() != m_style->fontDescription())
+    // Many properties depend on the font size. If it changes we just apply all properties.
+    if (cachedStyle && fontDifferenceAffectsNonInherited(m_style.get(), cachedStyle))
         applyInheritedOnly = false;
 
     // Now do the normal priority UA properties.
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to