Title: [252370] trunk/Source/WebCore
Revision
252370
Author
[email protected]
Date
2019-11-12 11:32:28 -0800 (Tue, 12 Nov 2019)

Log Message

Skip matched declarations cache only for length resolution affecting font properties
https://bugs.webkit.org/show_bug.cgi?id=204098

Reviewed by Zalan Bujtas.

* css/CSSPrimitiveValue.cpp:
(WebCore::CSSPrimitiveValue::equalForLengthResolution):

Put this next to the length resolution function, hopefully helping to keep them in sync.

* css/CSSPrimitiveValue.h:
* css/StyleResolver.cpp:
(WebCore::StyleResolver::applyMatchedProperties):

Replace test for font declaration change with a narrower test that only looks for those properties that affect length resolution.

* style/MatchedDeclarationsCache.cpp:
(WebCore::Style::MatchedDeclarationsCache::Entry::isUsableAfterHighPriorityProperties const):

Factor into function.

* style/MatchedDeclarationsCache.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (252369 => 252370)


--- trunk/Source/WebCore/ChangeLog	2019-11-12 19:07:41 UTC (rev 252369)
+++ trunk/Source/WebCore/ChangeLog	2019-11-12 19:32:28 UTC (rev 252370)
@@ -1,3 +1,28 @@
+2019-11-12  Antti Koivisto  <[email protected]>
+
+        Skip matched declarations cache only for length resolution affecting font properties
+        https://bugs.webkit.org/show_bug.cgi?id=204098
+
+        Reviewed by Zalan Bujtas.
+
+        * css/CSSPrimitiveValue.cpp:
+        (WebCore::CSSPrimitiveValue::equalForLengthResolution):
+
+        Put this next to the length resolution function, hopefully helping to keep them in sync.
+
+        * css/CSSPrimitiveValue.h:
+        * css/StyleResolver.cpp:
+        (WebCore::StyleResolver::applyMatchedProperties):
+
+        Replace test for font declaration change with a narrower test that only looks for those properties that affect length resolution.
+
+        * style/MatchedDeclarationsCache.cpp:
+        (WebCore::Style::MatchedDeclarationsCache::Entry::isUsableAfterHighPriorityProperties const):
+
+        Factor into function.
+
+        * style/MatchedDeclarationsCache.h:
+
 2019-11-12  Peng Liu  <[email protected]>
 
         Picture-in-Picture events are not fired if we switch the Picture-in-Picture mode through modern media controls

Modified: trunk/Source/WebCore/css/CSSPrimitiveValue.cpp (252369 => 252370)


--- trunk/Source/WebCore/css/CSSPrimitiveValue.cpp	2019-11-12 19:07:41 UTC (rev 252369)
+++ trunk/Source/WebCore/css/CSSPrimitiveValue.cpp	2019-11-12 19:32:28 UTC (rev 252370)
@@ -705,6 +705,25 @@
     return result;
 }
 
+bool CSSPrimitiveValue::equalForLengthResolution(const RenderStyle& styleA, const RenderStyle& styleB)
+{
+    // These properties affect results of computeNonCalcLengthDouble above.
+    if (styleA.fontDescription().computedSize() != styleB.fontDescription().computedSize())
+        return false;
+    if (styleA.fontDescription().specifiedSize() != styleB.fontDescription().specifiedSize())
+        return false;
+
+    if (styleA.fontMetrics().xHeight() != styleB.fontMetrics().xHeight())
+        return false;
+    if (styleA.fontMetrics().zeroWidth() != styleB.fontMetrics().zeroWidth())
+        return false;
+
+    if (styleA.zoom() != styleB.zoom())
+        return false;
+
+    return true;
+}
+
 ExceptionOr<void> CSSPrimitiveValue::setFloatValue(unsigned short, double)
 {
     // Keeping values immutable makes optimizations easier and allows sharing of the primitive value objects.

Modified: trunk/Source/WebCore/css/CSSPrimitiveValue.h (252369 => 252370)


--- trunk/Source/WebCore/css/CSSPrimitiveValue.h	2019-11-12 19:07:41 UTC (rev 252369)
+++ trunk/Source/WebCore/css/CSSPrimitiveValue.h	2019-11-12 19:32:28 UTC (rev 252370)
@@ -278,6 +278,8 @@
     static double conversionToCanonicalUnitsScaleFactor(UnitType);
 
     static double computeNonCalcLengthDouble(const CSSToLengthConversionData&, UnitType, double value);
+    // True if computeNonCalcLengthDouble would produce identical results when resolved against both these styles.
+    static bool equalForLengthResolution(const RenderStyle&, const RenderStyle&);
 
     Ref<DeprecatedCSSOMPrimitiveValue> createDeprecatedCSSOMPrimitiveWrapper(CSSStyleDeclaration&) const;
 

Modified: trunk/Source/WebCore/css/StyleResolver.cpp (252369 => 252370)


--- trunk/Source/WebCore/css/StyleResolver.cpp	2019-11-12 19:07:41 UTC (rev 252369)
+++ trunk/Source/WebCore/css/StyleResolver.cpp	2019-11-12 19:32:28 UTC (rev 252370)
@@ -584,14 +584,12 @@
     // High priority properties may affect resolution of other properties (they are mostly font related).
     builder.applyHighPriorityProperties();
 
-    // If the effective zoom value changes, we can't use the matched properties cache. Start over.
-    if (cacheEntry && cacheEntry->renderStyle->effectiveZoom() != style.effectiveZoom())
-        return applyMatchedProperties(state, matchResult, UseMatchedDeclarationsCache::No);
+    if (cacheEntry && !cacheEntry->isUsableAfterHighPriorityProperties(style)) {
+        // We need to resolve all properties without caching.
+        applyMatchedProperties(state, matchResult, UseMatchedDeclarationsCache::No);
+        return;
+    }
 
-    // If the font changed, we can't use the matched properties cache. Start over.
-    if (cacheEntry && cacheEntry->renderStyle->fontDescription() != style.fontDescription())
-        return applyMatchedProperties(state, matchResult, UseMatchedDeclarationsCache::No);
-
     builder.applyLowPriorityProperties();
 
     for (auto& contentAttribute : builder.state().registeredContentAttributes())

Modified: trunk/Source/WebCore/style/MatchedDeclarationsCache.cpp (252369 => 252370)


--- trunk/Source/WebCore/style/MatchedDeclarationsCache.cpp	2019-11-12 19:07:41 UTC (rev 252369)
+++ trunk/Source/WebCore/style/MatchedDeclarationsCache.cpp	2019-11-12 19:32:28 UTC (rev 252370)
@@ -64,6 +64,14 @@
     return true;
 }
 
+bool MatchedDeclarationsCache::Entry::isUsableAfterHighPriorityProperties(const RenderStyle& style) const
+{
+    if (style.effectiveZoom() != renderStyle->effectiveZoom())
+        return false;
+
+    return CSSPrimitiveValue::equalForLengthResolution(style, *renderStyle);
+}
+
 unsigned MatchedDeclarationsCache::computeHash(const MatchResult& matchResult)
 {
     if (!matchResult.isCacheable)

Modified: trunk/Source/WebCore/style/MatchedDeclarationsCache.h (252369 => 252370)


--- trunk/Source/WebCore/style/MatchedDeclarationsCache.h	2019-11-12 19:07:41 UTC (rev 252369)
+++ trunk/Source/WebCore/style/MatchedDeclarationsCache.h	2019-11-12 19:32:28 UTC (rev 252370)
@@ -46,6 +46,8 @@
         MatchResult matchResult;
         std::unique_ptr<const RenderStyle> renderStyle;
         std::unique_ptr<const RenderStyle> parentRenderStyle;
+
+        bool isUsableAfterHighPriorityProperties(const RenderStyle&) const;
     };
 
     const Entry* find(unsigned hash, const MatchResult&);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to