mirror of
https://github.com/lightpanda-io/browser.git
synced 2026-07-31 09:46:05 -04:00
Builds ontop of https://github.com/lightpanda-io/browser/pull/2719 and adds the missing layer-priority. This can be broken down into two parts. The first is the hot read path. This code is unchanged...same buckets and same u64 priority comparison. What has changed is the build/rebuild step and how / what the VisibilityRule.priority means. priority used to be 32bits for specificity and 32bits for doc order (specificity tie-breaker). Priority is now 12bits for layer rank, 30bits for specificity and 22bits for doc order. Specificity was only using 30bits, and the smaller doc order means we can now only represent 4 million rules (Facebook, which has _a lot_ of rules, has ~50K and like 95% of those are not visibility rules..so we have plenty of space still). But layer ordering is complicated because you need to parse everything before you know the final order. So our build now accumulates intermediary results and does a final iteration through the VisibilityRule to |= the rank_layer bits of their priority. This is no-op if there are no layers (common case for now). Because of this intermediary work, I've added a build_arena that is build/ rebuild specific. Possibly overkill since we don't expect sites to have thousands of layers, but it's cheap to add (except now you need to think: should I use the build_arena or self.arena).