mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-12-07 21:59:54 +00:00
Before this change, we've been maintaining various StyleComputer caches at the document level. This made sense for old-school documents without shadow trees, since all the style information was document-wide anyway. However, documents with many shadow trees ended up suffering since any time you mutated a style sheet inside a shadow tree, *all* style caches for the entire document would get invalidated. This was particularly expensive on Reddit, which has tons of shadow trees with their own style elements. Every time we'd create one of their custom elements, we'd invalidate the document-level "rule cache" and have to rebuild it, taking about ~60ms each time (ouch). This commit introduces a new object called StyleScope. Every Document and ShadowRoot has its own StyleScope. Rule caches etc are moved from StyleComputer to StyleScope. Rule cache invalidation now happens at StyleScope level. As an example, rule cache rebuilds now take ~1ms on Reddit instead of ~60ms. This is largely a mechanical change, moving things around, but there's one key detail to be aware of: due to the :host selector, which works across the shadow DOM boundary and reaches from inside a shadow tree out into the light tree, there are various places where we have to check both the shadow tree's StyleScope *and* the document-level StyleScope in order to get all rules that may apply. |
||
|---|---|---|
| .. | ||
| LibCompress | ||
| LibCore | ||
| LibCrypto | ||
| LibDatabase | ||
| LibDevTools | ||
| LibDiff | ||
| LibDNS | ||
| LibFileSystem | ||
| LibGC | ||
| LibGfx | ||
| LibHTTP | ||
| LibIDL | ||
| LibImageDecoderClient | ||
| LibIPC | ||
| LibJS | ||
| LibLine | ||
| LibMain | ||
| LibMedia | ||
| LibRegex | ||
| LibRequests | ||
| LibSyntax | ||
| LibTest | ||
| LibTextCodec | ||
| LibThreading | ||
| LibTLS | ||
| LibUnicode | ||
| LibURL | ||
| LibWasm | ||
| LibWeb | ||
| LibWebSocket | ||
| LibWebView | ||
| LibXML | ||
| CMakeLists.txt | ||