Diff
Modified: branches/safari-613-branch/Source/WebCore/style/MatchedDeclarationsCache.cpp (292338 => 292339)
--- branches/safari-613-branch/Source/WebCore/style/MatchedDeclarationsCache.cpp 2022-04-04 21:56:10 UTC (rev 292338)
+++ branches/safari-613-branch/Source/WebCore/style/MatchedDeclarationsCache.cpp 2022-04-04 21:56:12 UTC (rev 292339)
@@ -54,8 +54,6 @@
// content:attr() value depends on the element it is being applied to.
if (style.hasAttrContent() || (style.styleType() != PseudoId::None && parentStyle.hasAttrContent()))
return false;
- if (style.hasEffectiveAppearance())
- return false;
if (style.zoom() != RenderStyle::initialZoom())
return false;
if (style.writingMode() != RenderStyle::initialWritingMode() || style.direction() != RenderStyle::initialDirection())
@@ -107,7 +105,7 @@
return &entry;
}
-void MatchedDeclarationsCache::add(const RenderStyle& style, const RenderStyle& parentStyle, unsigned hash, const MatchResult& matchResult)
+void MatchedDeclarationsCache::add(const RenderStyle& style, const RenderStyle& parentStyle, const RenderStyle* userAgentAppearanceStyle, unsigned hash, const MatchResult& matchResult)
{
constexpr unsigned additionsBetweenSweeps = 100;
if (++m_additionsSinceLastSweep >= additionsBetweenSweeps && !m_sweepTimer.isActive()) {
@@ -115,12 +113,23 @@
m_sweepTimer.startOneShot(sweepDelay);
}
+ auto userAgentAppearanceStyleCopy = [&]() -> std::unique_ptr<RenderStyle> {
+ if (userAgentAppearanceStyle)
+ return RenderStyle::clonePtr(*userAgentAppearanceStyle);
+ return { };
+ };
+
ASSERT(hash);
// Note that we don't cache the original RenderStyle instance. It may be further modified.
// The RenderStyle in the cache is really just a holder for the substructures and never used as-is.
- m_entries.add(hash, Entry { matchResult, RenderStyle::clonePtr(style), RenderStyle::clonePtr(parentStyle) });
+ m_entries.add(hash, Entry { matchResult, RenderStyle::clonePtr(style), RenderStyle::clonePtr(parentStyle), userAgentAppearanceStyleCopy() });
}
+void MatchedDeclarationsCache::remove(unsigned hash)
+{
+ m_entries.remove(hash);
+}
+
void MatchedDeclarationsCache::invalidate()
{
m_entries.clear();
Modified: branches/safari-613-branch/Source/WebCore/style/MatchedDeclarationsCache.h (292338 => 292339)
--- branches/safari-613-branch/Source/WebCore/style/MatchedDeclarationsCache.h 2022-04-04 21:56:10 UTC (rev 292338)
+++ branches/safari-613-branch/Source/WebCore/style/MatchedDeclarationsCache.h 2022-04-04 21:56:12 UTC (rev 292339)
@@ -46,12 +46,14 @@
MatchResult matchResult;
std::unique_ptr<const RenderStyle> renderStyle;
std::unique_ptr<const RenderStyle> parentRenderStyle;
+ std::unique_ptr<const RenderStyle> userAgentAppearanceStyle;
bool isUsableAfterHighPriorityProperties(const RenderStyle&) const;
};
const Entry* find(unsigned hash, const MatchResult&);
- void add(const RenderStyle&, const RenderStyle& parentStyle, unsigned hash, const MatchResult&);
+ void add(const RenderStyle&, const RenderStyle& parentStyle, const RenderStyle* userAgentAppearanceStyle, unsigned hash, const MatchResult&);
+ void remove(unsigned hash);
// Every N additions to the matched declaration cache trigger a sweep where entries holding
// the last reference to a style declaration are garbage collected.
Modified: branches/safari-613-branch/Source/WebCore/style/StyleResolver.cpp (292338 => 292339)
--- branches/safari-613-branch/Source/WebCore/style/StyleResolver.cpp 2022-04-04 21:56:10 UTC (rev 292338)
+++ branches/safari-613-branch/Source/WebCore/style/StyleResolver.cpp 2022-04-04 21:56:12 UTC (rev 292339)
@@ -541,9 +541,9 @@
m_matchedDeclarationsCache.clearEntriesAffectedByViewportUnits();
}
-void Resolver::applyMatchedProperties(State& state, const MatchResult& matchResult, UseMatchedDeclarationsCache useMatchedDeclarationsCache)
+void Resolver::applyMatchedProperties(State& state, const MatchResult& matchResult)
{
- unsigned cacheHash = useMatchedDeclarationsCache == UseMatchedDeclarationsCache::Yes ? MatchedDeclarationsCache::computeHash(matchResult) : 0;
+ unsigned cacheHash = MatchedDeclarationsCache::computeHash(matchResult);
auto includedProperties = PropertyCascade::IncludedProperties::All;
auto& style = *state.style();
@@ -565,9 +565,13 @@
// Unfortunately the link status is treated like an inherited property. We need to explicitly restore it.
style.setInsideLink(linkStatus);
+
+ if (cacheEntry->userAgentAppearanceStyle && elementTypeHasAppearanceFromUAStyle(element))
+ state.setUserAgentAppearanceStyle(RenderStyle::clonePtr(*cacheEntry->userAgentAppearanceStyle));
+
return;
}
-
+
includedProperties = PropertyCascade::IncludedProperties::InheritedOnly;
}
@@ -588,8 +592,9 @@
builder.applyHighPriorityProperties();
if (cacheEntry && !cacheEntry->isUsableAfterHighPriorityProperties(style)) {
- // We need to resolve all properties without caching.
- applyMatchedProperties(state, matchResult, UseMatchedDeclarationsCache::No);
+ // High-priority properties may affect resolution of other properties. Kick out the existing cache entry and try again.
+ m_matchedDeclarationsCache.remove(cacheHash);
+ applyMatchedProperties(state, matchResult);
return;
}
@@ -602,7 +607,7 @@
return;
if (MatchedDeclarationsCache::isCacheable(element, style, parentStyle))
- m_matchedDeclarationsCache.add(style, parentStyle, cacheHash, matchResult);
+ m_matchedDeclarationsCache.add(style, parentStyle, state.userAgentAppearanceStyle(), cacheHash, matchResult);
}
bool Resolver::hasViewportDependentMediaQueries() const
Modified: branches/safari-613-branch/Source/WebCore/style/StyleResolver.h (292338 => 292339)
--- branches/safari-613-branch/Source/WebCore/style/StyleResolver.h 2022-04-04 21:56:10 UTC (rev 292338)
+++ branches/safari-613-branch/Source/WebCore/style/StyleResolver.h 2022-04-04 21:56:12 UTC (rev 292339)
@@ -159,8 +159,7 @@
BuilderContext builderContext(const State&);
- enum class UseMatchedDeclarationsCache { Yes, No };
- void applyMatchedProperties(State&, const MatchResult&, UseMatchedDeclarationsCache = UseMatchedDeclarationsCache::Yes);
+ void applyMatchedProperties(State&, const MatchResult&);
ScopeRuleSets m_ruleSets;