mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-26 01:35:08 +02:00
LibWeb: Make :hover invalidation logic reusable for all pseudo classes
We achieve this by keeping track of all checked pseudo class selectors in the SelectorEngine code. We also give StyleComputer per-pseudo-class rule caches.
This commit is contained in:
committed by
Andreas Kling
parent
ed35f9e7c2
commit
e1777f6e79
Notes:
github-actions[bot]
2025-04-17 17:47:22 +00:00
Author: https://github.com/awesomekling Commit: https://github.com/LadybirdBrowser/ladybird/commit/e1777f6e79a Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4388
45
Libraries/LibWeb/CSS/PseudoClassBitmap.h
Normal file
45
Libraries/LibWeb/CSS/PseudoClassBitmap.h
Normal file
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright (c) 2025, Andreas Kling <andreas@ladybird.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LibWeb/CSS/PseudoClass.h>
|
||||
|
||||
namespace Web::CSS {
|
||||
|
||||
class PseudoClassBitmap {
|
||||
public:
|
||||
PseudoClassBitmap() = default;
|
||||
~PseudoClassBitmap() = default;
|
||||
|
||||
void set(PseudoClass pseudo_class, bool bit)
|
||||
{
|
||||
size_t const index = to_underlying(pseudo_class);
|
||||
if (bit)
|
||||
m_bits |= 1LLU << index;
|
||||
else
|
||||
m_bits &= ~(1LLU << index);
|
||||
}
|
||||
|
||||
bool get(PseudoClass pseudo_class) const
|
||||
{
|
||||
size_t const index = to_underlying(pseudo_class);
|
||||
return (m_bits & (1LLU << index)) != 0;
|
||||
}
|
||||
|
||||
void operator|=(PseudoClassBitmap const& other)
|
||||
{
|
||||
m_bits |= other.m_bits;
|
||||
}
|
||||
|
||||
private:
|
||||
u64 m_bits { 0 };
|
||||
};
|
||||
|
||||
// NOTE: If this changes, we'll have to tweak PseudoClassBitmap a little bit :)
|
||||
static_assert(to_underlying(PseudoClass::__Count) <= 64);
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user