mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-26 01:35:08 +02:00
Replace per-element OrderedHashMap storage for custom properties with a RefCounted chain (CustomPropertyData) that enables structural sharing. Each chain node stores only the properties declared directly on its element, with a parent pointer to the inherited chain. Elements that don't override any custom properties share the parent's data directly (just a RefPtr copy). During cascade, only entries that actually differ from the parent are stored in own_values - the rest are inherited through the chain. During var() resolution, resolved values are compared against the parent's and matching entries are dropped, enabling further sharing. The chain uses a depth limit (max 32) with flattening, plus absorption of small parent nodes (threshold 8) to keep lookups fast. This reduces custom property memory from ~79 MB to ~5.7 MB on cloudflare.com.
40 lines
830 B
Plaintext
40 lines
830 B
Plaintext
=== Basic inheritance ===
|
|
root --color: green
|
|
parent --color: green
|
|
child --color: green
|
|
grandchild --color: green
|
|
=== Root property inheritance ===
|
|
parent --font: serif
|
|
child --font: serif
|
|
grandchild --font: serif
|
|
=== Override at middle ===
|
|
parent --size: 10px
|
|
child --size: 20px
|
|
grandchild --size: 20px
|
|
=== Parent-only property ===
|
|
parent --extra: hello
|
|
child --extra: hello
|
|
grandchild --extra: hello
|
|
=== Deep chain ===
|
|
deep --a: 1
|
|
deep --b: 2
|
|
deep --c: 3
|
|
deep --d: 4
|
|
deep --e: 5
|
|
deep --f: 6
|
|
deep --color: red
|
|
=== Shadowing ===
|
|
shadow-parent --x: parent
|
|
shadow-child --x: child
|
|
shadow-child --y: parent
|
|
=== Pseudo-elements ===
|
|
pseudo::before --pseudo-var: from-pseudo
|
|
pseudo::before --inherited-var: from-element
|
|
=== Dynamic update ===
|
|
before: (empty)
|
|
after:
|
|
changed:
|
|
removed: (empty)
|
|
=== Nonexistent ===
|
|
nonexistent: (empty)
|