LibWeb: Add method for whether tree-counting function is allowed

Some contexts (e.g. descriptors, media conditions) don't allow tree
counting functions, this commit adds an easy way to check if the current
value context is one of those.
This commit is contained in:
Callum Law 2025-09-30 15:12:52 +13:00 committed by Tim Ledbetter
commit fd31fbd84b
Notes: github-actions[bot] 2025-10-20 15:13:55 +00:00
5 changed files with 27 additions and 1 deletions

View file

@ -458,6 +458,8 @@ Optional<MediaFeatureValue> Parser::parse_media_feature_value(MediaFeatureID med
{
auto transaction = tokens.begin_transaction();
auto value = [this](MediaFeatureID media_feature, TokenStream<ComponentValue>& tokens) -> Optional<MediaFeatureValue> {
auto context_guard = push_temporary_value_parsing_context(SpecialContext::MediaCondition);
// One branch for each member of the MediaFeatureValueType enum:
// Identifiers
if (tokens.next_token().is(Token::Type::Ident)) {