Skip to content

Commit

Permalink
[CSS] Fix nested at-rules highlighting (#3831)
Browse files Browse the repository at this point in the history
* [CSS] Fix nested at-rule property-lists

Fixes #3820

This commit...

1. adds separate contexts for nested at-rules.

   Global at-rules push blocks of stylesheets while 
   nested at-rules push blocks of property-lists (style rules).

2. refactors at-rules to make use of multi-push statements so more general
   purpose contexts can be created and re-used more often, which reduces syntax
   cache size and should limit amount of special purpose contexts,
   which might need to be addressed by inheriting 3rd-party syntaxes.

3. replaces `at-rule-end` by `else-pop` to follow a fail as early as possible
   approach, which may help to bail-out from statements more reliably.

   e.g. at-rules with missing semi-colon suffered leaking into following
   at-rules or selectors, before.

* [CSS] Re-use existing contexts

This commit applies lazier parsing of various at-rules' property-lists in order
to reduce complexity/special casing and increase re-using existing contexts.

While it doesn't improve performance, syntax cache size is reduced and re-using
existing contexts is increased.

* [CSS] Fix at-keyframes

This commit refactors @Keyframe rules to

1. align it with the other at-rule context structures, 
   which have been modified before
2. fix only one keyframe identifier being valid.

It ...

1. introduces multi-push to implement the fail as early as possible strategy.
2. restricts to single keyframe identifier
3. adds some `meta_include_prototype: false` to ensure prototypes are injected
   into identifiers only. Required for PHP, Less, ...

* [CSS] Refactor at-counter-style contexts

This commit...

1. aligns context structure with the other at-rules by using multi-push to apply
   the fail as early as possible strategy.

2. implements as generic as possible CSS `<declaration-list>` production for
   counter-style rules, without relying on predefined lists of known/supported
   property names. Only those properties with special values are maintained.

* [CSS] Rename style-block production

Apply context name from CSS `<style-block>` production.

see: https://www.w3.org/TR/css-syntax-3/#declaration-rule-list

* [CSS] Add nested at-rule tests

* [CSS] Restrict legacy at-document to top-level

This commit restricts @document at-rule to top-level only, as it is no longer
supported by browsers and kept for backward compatibility only.
  • Loading branch information
deathaxe authored Oct 19, 2023
1 parent 92b4c0b commit 3125fdd
Show file tree
Hide file tree
Showing 2 changed files with 639 additions and 274 deletions.
Loading

0 comments on commit 3125fdd

Please sign in to comment.