Skip to content

Truly independent web browser

LibWeb: Use smaller generation stamps for selector invalidation

Shannon Booth9749855a1e98
diff --git a/Libraries/LibWeb/Rust/src/css/style/pipeline/live.rs b/Libraries/LibWeb/Rust/src/css/style/pipeline/live.rs
index 6d128e04e5f..e6ffd79eabe 100644
--- a/Libraries/LibWeb/Rust/src/css/style/pipeline/live.rs
+++ b/Libraries/LibWeb/Rust/src/css/style/pipeline/live.rs
@@ -2610,10 +2610,10 @@ struct FollowScratch {
struct CompoundMemo {
/// The stamp of the element whose answers each slot holds: starting the next element is a new
/// stamp, not a clearing.
- stamps: Vec<u32>,
+ stamps: Vec<u16>,
/// The answers of each slot, two bits per kind: none yet, unknown, false or true.
answers: Vec<u8>,
- stamp: u32,
+ stamp: u16,
}
/// What a memo answer of a compound is: of the element on its own or from it leftwards, after or
@@ -4617,6 +4617,19 @@ mod tests {
const SIBLINGS: u32 = 1000;
+ #[test]
+ fn compound_memo_forgets_answers_when_the_stamp_wraps() {
+ let mut memo = CompoundMemo::default();
+ let kind = MemoKind::Own { before: false };
+ memo.start(1);
+ memo.stamp = 1;
+ memo.set(0, kind, Some(true));
+
+ memo.stamp = u16::MAX;
+ memo.start(1);
+ assert!(matches!(memo.get(0, kind), MemoAnswer::Unasked));
+ }
+
fn next_of(steps: &Cell<u32>) -> impl Fn(StyleNodeID) -> Option<StyleNodeID> + '_ {
|node| {
steps.set(steps.get() + 1);