Skip to documentation
SLOP

tiny.css.match

Reference tiny.css match

Defined in tiny.css.

Selector matching over an element interface, plus the rule bucket index.

API (11)

Actions

Public operations.

Types and contracts

Public types and contracts.

Values and defaults

Public values and defaults.

No direct callersNo direct callstiny.cssmatch
Static calls · unresolved targets: unknown · external targets: unknown.

Source

Source: lib/css/src/match/engine.zig:42

zig
/// The sheet side tables a compound test reads.pub const Context = struct {    classes: []const u32,    nths: []const selector.nth.Nth,};

Source: lib/css/src/match/engine.zig:29

zig
/// The tree interface the matcher runs against. `ui` and `browser` fill it/// over their own node storage, which is how one matcher serves both.////// `parent` and `previous` return the node's own index when it has no parent/// or no preceding sibling. `sibling_index` packs the one based index in the/// low sixteen bits and the sibling count in the high sixteen, because/// `:nth-last-child` needs the count and the call returns one word.////// `classes` writes at most `capacity` atoms and returns how many the element/// has. Reporting more than `capacity` is a programmer error and is asserted.pub const Element = extern struct {    context: ?*anyopaque,    parent: *const fn (?*anyopaque, u32) callconv(.c) u32,    previous: *const fn (?*anyopaque, u32) callconv(.c) u32,    kind: *const fn (?*anyopaque, u32) callconv(.c) u16,    role: *const fn (?*anyopaque, u32) callconv(.c) u16,    identifier: *const fn (?*anyopaque, u32) callconv(.c) u32,    classes: *const fn (?*anyopaque, u32, [*]u32, u32) callconv(.c) u32,    pseudo: *const fn (?*anyopaque, u32) callconv(.c) u32,    sibling_index: *const fn (?*anyopaque, u32, bool) callconv(.c) u32,};

Source: lib/css/src/match/engine.zig:48

zig
/// One selector that matched an element, carried to the cascade.pub const Match = struct {    rule: u32,    selector: u32,    specificity: Specificity,    order: u32,};

Source: lib/css/src/match/engine.zig:148

zig
/// Whether one compound matches one node.pub fn matchCompound(    context: Context,    compound: Compound,    element: Element,    node: u32,) bool {    if (compound.flags & selector.unmatchable != 0) return false;    if (compound.kind != 0 and element.kind(element.context, node) != compound.kind) return false;    if (compound.role != 0 and element.role(element.context, node) != compound.role) return false;    if (compound.id != 0 and element.identifier(element.context, node) != compound.id) return false;    if (compound.pseudo != 0) {        const state = element.pseudo(element.context, node);        if (state & compound.pseudo != compound.pseudo) return false;    }    if (compound.class_count > 0 and !matchClasses(context, compound, element, node)) return false;    if (compound.nth != 0 and !matchNth(context, compound.nth, element, node)) return false;    return true;}
Called byCallsprivate sourcelib.css.src.match.enginematchChainmatchmatchesprivate sourcelib.css.src.match.enginematchClassesprivate sourcelib.css.src.match.enginematchNthmatchmatchCompound
Static calls · unresolved targets: 0 · external targets: 4.

Source: lib/css/src/match/engine.zig:74

zig
/// Whether `item` matches `node`. The rightmost compound is tested first, then/// the chain walks leftwards with backtracking at the two loose combinators.pub fn matches(context: Context, item: Selector, element: Element, node: u32) bool {    std.debug.assert(item.compounds.len > 0);    std.debug.assert(item.compounds.len <= max_compounds);    std.debug.assert(item.combinators.len + 1 == item.compounds.len);    if (!matchCompound(context, item.rightmost(), element, node)) return false;    return matchChain(context, item, element, node);}
Called byCallsNo direct callersprivate sourcelib.css.src.match.enginematchChainmatchmatchCompoundmatchmatches
Static calls · unresolved targets: 0 · external targets: 1.

Source: lib/css/src/match/engine.zig:14

zig
/// The most compounds one selector may carry.pub const max_compounds: usize = 32;

Source: lib/css/src/match/engine.zig:11

zig
/// The deepest ancestor chain a combinator walk crosses. It is the depth bound/// the layout solver already declares, so a descendant match is bounded work.pub const max_depth: u32 = 64;

Source: lib/css/src/match/engine.zig:56

zig
/// Packs a one based sibling index and a sibling count into one word.pub fn packSibling(index: u32, count: u32) u32 {    std.debug.assert(index <= 0xFFFF);    std.debug.assert(count <= 0xFFFF);    return (count << 16) | index;}
Called byCallsNo direct callsprivate sourcelib.css.src.match.fixture.treesiblingOftest sourcelib.css.src.match.testtest: the sibling word round trips it...matchpackSibling
Static calls · unresolved targets: 0 · external targets: 0.

Source: lib/css/src/match/engine.zig:68

zig
/// The sibling count inside a packed sibling word.pub fn siblingCount(word: u32) u32 {    return word >> 16;}
Called byCallsNo direct callsprivate sourcelib.css.src.match.enginematchNthtest sourcelib.css.src.match.testtest: the sibling word round trips it...matchsiblingCount
Static calls · unresolved targets: 0 · external targets: 0.

Source: lib/css/src/match/engine.zig:63

zig
/// The one based sibling index inside a packed sibling word.pub fn siblingIndex(word: u32) u32 {    return word & 0xFFFF;}
Called byCallsNo direct callsprivate sourcelib.css.src.match.enginematchNthtest sourcelib.css.src.match.testtest: the sibling word round trips it...matchsiblingIndex
Static calls · unresolved targets: 0 · external targets: 0.

Source: lib/css/src/match/root.zig

zig
//! Selector matching over an element interface, plus the rule bucket index.//!//! The matcher is parameterized by `Element`, a vtable a consumer fills over//! its own node storage, so `ui` and `browser` share one implementation and//! `css` imports neither.//!//! Matching runs right to left. The rightmost compound is tested first, and the//! chain then walks leftwards with backtracking at the descendant and//! subsequent sibling combinators, bounded by `max_depth`.const engine = @import("engine.zig");pub const Context = engine.Context;pub const Element = engine.Element;pub const Match = engine.Match;pub const matchCompound = engine.matchCompound;pub const matches = engine.matches;pub const max_compounds = engine.max_compounds;pub const max_depth = engine.max_depth;pub const max_element_classes = engine.max_element_classes;pub const packSibling = engine.packSibling;pub const siblingCount = engine.siblingCount;pub const siblingIndex = engine.siblingIndex;

Source: lib/css/src/root.zig:38

zig
pub const match = @import("match/root.zig");

Audit

Definitions11
Public names11
Members15
Version26.7.0
Revisiondaab053ee433