Skip to main content

Crate sk_css

Crate sk_css 

Source
Expand description

sk-css: lightningcss parses stylesheets, parcel_selectors matches them against the retained tree, and the cascade folds matched rules into per-state gpui::StyleRefinements that the renderer installs into gpui’s state ladder (base / focus / focus-visible / hover / active).

  • The cascade runs once per tree mutation, never inside gpui’s per-frame style computation; interaction states never round-trip through JS.
  • :disabled / :checked are not ladder states: the element property is the state, so they fold into the base bucket.
  • Selectors the matcher cannot run (:has(), unflattened nesting, :nth-child(.. of S)) panic inside parcel_selectors, so they are probed and rejected at compile time with a diagnostic. Selectors it can run but could only answer “no” for (:visited, …) are reported by [audit_selector], never compiled into a rule that silently never matches.

Modules§

catalog
What CSS Skathi supports, property by property: the one list CSS.supports, @supports and the docs answer from. Each entry’s sample values run through the mapper in the tests below, so an entry that disagrees with what the mapper does fails the build.
container
@container conditions and the container query length units (cqw … cqmax), answered from the query containers above the element being cascaded and the content-box sizes the host’s last layout gave them.
perf
Counters for what the cascade does: selectors the matcher ran, and how compute_node’s time divides between matching, custom properties and folding. Accumulated per compute_node call and drained by the host’s phase reporter.
snap
CSS Scroll Snap: scroll-snap-type, scroll-snap-align, scroll-snap-stop, scroll-padding and scroll-margin, carried to the renderer (sk_tree::snap) that applies them. Writing mode is always horizontal-tb, left to right: block is y, inline is x.
view_transition
View transition pseudo-elements as selectors over stand-in elements. A rule for ::view-transition-old(card) is rewritten to match an element sk-vt-old[sk-vt-name="card"] under sk-vt-image-pair, sk-vt-group and sk-vt, whose parent is the document element; the renderer builds those elements while a transition runs (MatchDom::is_view_transition_pseudo).

Structs§

AnimEvent
AnimationPatch
animation-* longhands without a list: a lone animation-play-state: paused or animation-fill-mode: forwards (reka-ui’s Presence writes it) must not delete the animation the sheet started, so it applies as a patch over the winning list.
AnimationSpec
Animator
BackgroundLayer
BackgroundUrl
ComputedStates
ControlPseudo
CurrentColorTargets
Delay
A signed transition-delay / animation-delay: a negative one starts the timeline that far in.
DynamicRangeLimit
The computed dynamic-range-limit: the weights of standard, constrained and no-limit, summing to 1. The initial value is no-limit.
Engine
Env
Extras
FontRelativeMetrics
GroupFocus
InheritedRadii
InlineMotion
InlinePriority
InlineStyle
Keyframe
Keyframes
MaskPatch
The mask-* longhands Skathi paints, cascaded apart and folded into layers after the cascade as the background-* ones are.
MaskStack
The layers of a mask, bottom first, and whether they mask by luminance.
MatchedRule
PseudoBox
QueryResult
RadiusInherit
Which corners’ border-*-radius is inherit, in cascade order. border-radius does not inherit, so inherit asks for the PARENT’s computed radius, which the mapper cannot know. The high four bits are the corners’ corner-*-shape.
ScriptClock
ScriptFrame
ScriptKeyframeNotes
ScriptSample
ScriptTiming
TransitionSpec
Vars
Eq matters: Rc<T> equality short-circuits on pointer identity for T: Eq, and a node with no custom properties shares its parent’s Rc, keeping the change test O(1).

Enums§

AnimEventKind
AnimationDirection
BackgroundSize
DisplayMode
Easing
FillMode
Interaction
ListMarker
MaskClips
MaskCompositing
MaskImages
ObjectFit
CSS object-fit. A local mirror of gpui::ObjectFit (which derives neither Clone nor PartialEq); the initial value is fill while gpui’s image default is Contain, so the renderer must state Fill explicitly.
OverscrollBehavior
PaintLayer
PlayState
PseudoElement
ScrollbarWidth
StepPosition
SvgPaint
TextFill
TextTransform
TileLength
TransitionProperty
UserSelect
WhiteSpaceMode
WindowControl
CSS --window-control: tells Windows 11 which element is the maximize button (snap layouts). A custom property because a browser ignores those, while an unknown value of a known property would drop and fall back to the inherited move.
WindowDrag
The CSSWG resolved on 2026-01-21 to standardise Electron’s -webkit-app-region as window-drag: none | move, and separately that the property is INHERITED.

Constants§

ANIMATABLE_COUNT
COLOR_SCHEME
The name color-scheme is carried under among the inherited custom properties.
CONSTRAINED_HEADROOM
The headroom constrained allows: one stop above SDR white.
INITIAL_REM_BASIS
INITIAL_VIEWPORT_BASIS
Must be non-zero: 0 would collapse every vh before the first set_env.

Traits§

MatchDom

Functions§

accepts_declaration
Does the engine apply name: value? What CSS.supports, @supports and the :style array form answer.
color_scheme
An element’s used color scheme from its computed color-scheme (inherited in vars): None under normal, else whether it is dark, the environment’s preference winning when both are listed.
corner_shape_css
A shape as CSS: its keyword when it has one.
covered
match_media
Err is the reason a prelude was rejected; a browser treats an invalid media list as not all, so callers report matches: false with the advisory.
parse_easing
None for anything animation-timing-function would not take either, including linear(...), which the lightningcss in use does not parse.
parse_inline
parse_inline_full
parse_inline_style
parse_inline_with_transitions
query_all
An unsupported selector is Err(advisory), not a silent empty match. Takes candidates because MatchDom has no child accessor; a scoped querySelector uses query_all_in.
query_all_in
scope is the :scope root; without it :scope > div would ask about the document root. None matches the document element, as in the cascade.
rem_basis
resolve_inherited_radii
script_keyframes
set_capture_rule_text
Turns rule-text capture on (or off) for every sheet compiled AFTER this call — the sheet already installed keeps whatever it was compiled with.
set_composed_font_families
set_font_metric_source
Installs the host’s font metrics. Replacing the source invalidates cached folds, so a style computed before host setup cannot retain fallback widths.
set_font_source
Read lazily on the first font-family: enumerating installed families is costly. Without a source every named family counts as installed.
set_rem_basis
Sets the px value of 1rem, reporting a change. rem is flattened at parse time, so already-compiled sheets do not move; out-of-range values (0.0 during boot) are refused.
set_viewport_basis
set_web_font_families
spec_for
strip_transitioned
supports_condition_text
CSS.supports(conditionText): a @supports condition, or a bare declaration as browsers also take.
take_font_misses
take_unreached_fonts
text_shadow_css
A text-shadow list as getComputedStyle writes it: colour first, every length, none when empty.
transform_css
used_dark
Whether light-dark() takes its dark half: normal is light, as in a browser.
uses_viewport_units
viewport_basis

Type Aliases§

Decls
(name, raw value text) pairs for what cannot be mapped at sheet-compile time: --x declarations and known properties whose value used var(), both resolved per element.