README

Milky2018/css/computed does not have a README file

#
ComputeContext

pub(all) struct ComputeContext {
parent_style :
Style
?
root_font_size : Double
font_size : Double
viewport_width : Double
viewport_height : Double
custom_properties : Map[String, String]
}

Computed values context for resolving relative units

#
ComputeContext::new

#
ComputeContext::with_parent

#
ComputeContext::with_parent_and_vars

fn ComputeContext::with_parent_and_vars(parent :
Style
, parent_vars : Map[String, String]) -> ComputeContext

Create context with parent style and inherited custom properties

#
ComputeContext::with_viewport

fn ComputeContext::with_viewport(viewport_width : Double, viewport_height : Double) -> ComputeContext

Create context with custom viewport dimensions

#
CssColorValue

pub(all) enum CssColorValue {
Resolved(
Color
)
CurrentColor
Inherit
Invalid
}

Result of parsing a CSS color value

#
CssColorValue::get_color

#
CssColorValue::is_resolved

fn CssColorValue::is_resolved(self : CssColorValue) -> Bool

#
CssColorValue::or_default

#
apply_property_direct

fn apply_property_direct(style :
Style
, property : String, value : String, ctx : ComputeContext) ->
Style

Apply a single CSS property to an existing style directly This skips the CSS string parsing step for better performance

#
compute

Compute a Style from cascaded values

#
compute_inline

fn compute_inline(inline_css : String, ctx : ComputeContext) ->
Style

Compute style from inline style string This is the standard function that applies box-sizing adjustment.

#
compute_inline_raw

fn compute_inline_raw(inline_css : String, ctx : ComputeContext) ->
Style

Compute style from inline style string (raw, without box-sizing adjustment) Use this when merging individual properties into an existing style. The caller is responsible for calling adjust_for_box_sizing on the final result.

#
compute_with_vars

Compute a Style and return updated custom properties Used when building a style tree to pass custom properties to children

#
default_background_color

fn default_background_color() ->
Color

Default color for background (transparent)

#
default_color

fn default_color() ->
Color

Default color for text (black)

#
extract_border_width

fn extract_border_width(value : String) ->
Dimension

Extract border width from shorthand value Handles formats like "3px", "solid 3px", "1px solid red", "none", etc.

#
find_grid_named_line

fn find_grid_named_line(name : String, line_names : Array[Array[String]]) -> Int?

Find the 1-based grid line number where name is first declared in the given line-name table (table index 0 = grid line 1). Returns None if the name is not present.

#
find_grid_named_line_nth

fn find_grid_named_line_nth(name : String, n : Int, line_names : Array[Array[String]]) -> Int?

Find the 1-based grid line number of the n-th line named name. Positive n counts occurrences from the start (n=1 is the first); negative n counts from the end (n=-1 is the last). Returns None if there is no such line.

#
initial_value

fn initial_value(property : String) -> String

Get the initial value for a property as a string

#
is_grid_area_name

fn is_grid_area_name(value : String) -> Bool

Check if a value is a named grid area identifier (not a number, auto, or span keyword)

#
is_inherited

fn is_inherited(property : String) -> Bool

Whether a property is inherited by default

#
parse_align_self

fn parse_align_self(value : String) ->
AlignSelf

Parse align-self value

#
parse_alignment

fn parse_alignment(value : String) ->
Alignment

#
parse_alignment_with_overflow

fn parse_alignment_with_overflow(value : String) -> (
Alignment
, Bool)

Parse alignment value (justify-content, align-items, align-content) Note: flex-start/flex-end are flex-relative (affected by wrap-reverse) start/end are physical/logical (not affected by wrap-reverse)

#
parse_aspect_ratio

fn parse_aspect_ratio(value : String) -> Double?

Parse aspect-ratio value

#
parse_clear

fn parse_clear(value : String) ->
Clear

Parse clear value

#
parse_clear_with_direction

fn parse_clear_with_direction(value : String, direction :
Direction
) ->
Clear

#
parse_clip

fn parse_clip(value : String) ->
ClipRect

Parse CSS clip property value Supports: auto, rect(top, right, bottom, left) Note: This is a deprecated property but widely used for accessibility

#
parse_clip_path

fn parse_clip_path(value : String) ->
ClipPath

Parse the supported subset of CSS clip-path. Supports: none, inset( ), circle( at ).

#
parse_color

fn parse_color(value : String) -> CssColorValue

Parse a CSS color value (legacy - uses fallback only for var())

#
parse_color_with_ctx

fn parse_color_with_ctx(value : String, ctx : ComputeContext) -> CssColorValue

Parse a CSS color value with context for proper var() resolution

#
parse_dimension

fn parse_dimension(value : String) ->
Dimension

Parse a dimension value from string

#
parse_direction

fn parse_direction(value : String) ->
Direction

Parse direction value (ltr/rtl)

#
parse_display

fn parse_display(value : String) ->
Display

Parse display value

#
parse_flex_direction

fn parse_flex_direction(value : String) ->
FlexDirection

Parse flex-direction value

#
parse_flex_wrap

fn parse_flex_wrap(value : String) ->
FlexWrap

Parse flex-wrap value

#
parse_float

fn parse_float(value : String) ->
Float

Parse float value

#
parse_float_with_direction

fn parse_float_with_direction(value : String, direction :
Direction
) ->
Float

#
parse_grid_auto_flow

fn parse_grid_auto_flow(value : String) ->
GridAutoFlow

Parse grid-auto-flow value

#
parse_grid_autoflow_form

Parse the grid shorthand auto-flow form. Returns (auto-flow, template-rows, row-names, template-cols, col-names, auto-rows, auto-cols) or None when neither side has auto-flow.

#
parse_grid_line_shorthand

Parse grid-column or grid-row shorthand Formats: , / , / span

#
parse_grid_placement

fn parse_grid_placement(value : String) ->
GridPlacement

Parse a grid placement value (for grid-column-start, grid-row-end, etc.). Supports the full <grid-line> grammar: auto -> Named && ? -> Line / NamedLine (order-independent) span && ? && ? -> Span / SpanNamed

#
parse_grid_template_areas_form

Parse the grid-template / grid areas form. Returns (areas, rows, row_line_names, cols, col_line_names) or None.

#
parse_grid_template_areas_value

fn parse_grid_template_areas_value(value : String) -> Array[String]

Parse grid-template-areas CSS property value. The value is a series of quoted strings like: "header header" "sidebar main" "footer footer"

#
parse_grid_template_axis

Parse one grid template axis, detecting subgrid/masonry. Returns the axis kind, the explicit track sizing functions, and the line names.

#
parse_grid_template_shorthand

Parse grid-template shorthand: <rows> / <columns>

#
parse_grid_template_shorthand_with_names

Parse grid-template shorthand <rows> / <columns>, preserving named lines. Returns (rows, row_line_names, cols, col_line_names).

#
parse_grid_template_track_list

fn parse_grid_template_track_list(value : String) -> (Array[
TrackSizingFunction
], Array[Array[String]])

Parse grid-template-columns or grid-template-rows value, returning both the track sizing functions and the named lines (index = grid line, length = tracks + 1).

#
parse_grid_template_tracks

fn parse_grid_template_tracks(value : String) -> Array[
TrackSizingFunction
]

Parse grid-template-columns or grid-template-rows value Delegate to the full parser to support minmax() and repeat().

#
parse_integer

fn parse_integer(value : String) -> Int

Parse an integer value

#
parse_linear_gradient

fn parse_linear_gradient(value : String) ->
BackgroundImage

Parse a linear-gradient() value into a LinearGradient

#
parse_number

fn parse_number(value : String) -> Double

Parse a number value

#
parse_overflow

fn parse_overflow(value : String) ->
Overflow

Parse overflow value

#
parse_place_content

Parse place-content shorthand. Returns (align_content, justify_content).

#
parse_place_content_with_overflow

fn parse_place_content_with_overflow(value : String) -> ((
Alignment
, Bool), (
Alignment
, Bool))?

Parse place-content shorthand. Returns (align_content, justify_content).

#
parse_place_items

Parse place-items shorthand: <'align-items'> <'justify-items'>?. A single component is duplicated to both axes. Returns (align_items, justify_items).

#
parse_place_self

Parse place-self shorthand: <'align-self'> <'justify-self'>?. A single component is duplicated to both axes. Returns (align_self, justify_self).

#
parse_position

fn parse_position(value : String) ->
Position

Parse position value

#
parse_scroll_snap_align

Parse scroll-snap-align value as (inline, block). Supports keywords: none | start | end | center.

#
parse_scroll_snap_type

fn parse_scroll_snap_type(value : String) ->
ScrollSnapType

Parse scroll-snap-type value Supports a minimal subset: none | x mandatory | y mandatory | both mandatory.

#
parse_text_align

fn parse_text_align(value : String) ->
TextAlign

Parse text-align value

#
parse_white_space

fn parse_white_space(value : String) ->
WhiteSpace

Parse white-space value

#
parse_writing_mode

fn parse_writing_mode(value : String) ->
WritingMode

Parse writing-mode value

#
resolve_current_color

fn resolve_current_color(value : CssColorValue, parent_color :
Color
) ->
Color

Resolve currentColor using parent's color

#
resolve_custom_property_value

fn resolve_custom_property_value(value : String, custom_properties : Map[String, String]) -> String?

Resolve custom properties in an arbitrary CSS property value.

Returns None when the value contains malformed var() syntax, refers to a missing property without a fallback, or reaches a custom-property cycle.

#
resolve_grid_line_placement

fn resolve_grid_line_placement(start :
GridPlacement
, end :
GridPlacement
, line_names : Array[Array[String]]) -> (Int?, Int?)

Resolve a grid item's start/end placement against a grid template's named lines (as captured in grid_template_column_line_names / grid_template_row_line_names). Returns concrete 1-based line numbers where resolvable. Line(n) passes through; Named resolves against the table (with implicit-area expansion); Auto / Span and unresolved names yield None, leaving auto/span placement to the layout engine.

#
resolve_length_dimension

fn resolve_length_dimension(value : String, ctx : ComputeContext) ->
Dimension
?

Resolve an authored CSS length-percentage against the unit environment while preserving any percentage component for the caller's property-specific basis. Intrinsic sizing keywords and invalid values are rejected.

Powered by MoonBit

Site sourceReport issuePackagesBuild queueSkillsStatistics

© 2026 mooncakes.io