Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 9797f8d2b2eae7c41f2efb976b7db5dac0999147
      
https://github.com/WebKit/WebKit/commit/9797f8d2b2eae7c41f2efb976b7db5dac0999147
  Author: Chris Dumez <[email protected]>
  Date:   2026-04-05 (Sun, 05 Apr 2026)

  Changed paths:
    M Source/WebCore/style/MatchedDeclarationsCache.cpp
    M Source/WebCore/style/StyleResolver.cpp

  Log Message:
  -----------
  Fix bug and minor inefficiency in MatchedDeclarationsCache
https://bugs.webkit.org/show_bug.cgi?id=311546

Reviewed by Darin Adler.

In applyMatchedProperties(), the isUsableAfterHighPriorityProperties check was
guarded by `cacheResult` instead of `hasUsableEntry`. When an element is not
cacheable (e.g. the document element) but find() returns a cache hit, we skip
using the cache entry but still check its high-priority properties. If that
check fails, we unnecessarily evict a valid cache entry and redundantly
re-apply all matched properties via a recursive call.

Fix by checking `hasUsableEntry` so we only validate and potentially evict
cache entries we actually used.

Also collapse removeAllMatching() from two passes over the HashMap into one.

* Source/WebCore/style/MatchedDeclarationsCache.cpp:
(WebCore::Style::MatchedDeclarationsCache::removeAllMatching):
* Source/WebCore/style/StyleResolver.cpp:
(WebCore::Style::Resolver::applyMatchedProperties):

Canonical link: https://commits.webkit.org/310624@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to