we (web engine): Experimental web browser project to understand the limits of Claude

CSS value parsing: lengths, colors, keywords #40

open opened by pierrelf.com

Description#

Implement CSS value parsing in the css crate to convert raw token lists into typed property values.

Acceptance Criteria#

  • Parse CSS length values:
    • Absolute units: px, pt, cm, mm, in, pc
    • Font-relative units: em, rem
    • Viewport units: vw, vh, vmin, vmax (store for later resolution)
    • Percentages: 50%
    • 0 (unitless zero)
  • Parse CSS color values:
    • Named colors: at least the 16 basic CSS colors + transparent
    • Hex colors: #rgb, #rrggbb, #rgba, #rrggbbaa
    • rgb() and rgba() functional notation
    • currentColor keyword
  • Parse CSS keyword values:
    • inherit, initial, unset
    • Display: block, inline, inline-block, none, flex
    • Position: static, relative, absolute, fixed
    • Text: left, center, right, justify
    • Font-weight: normal, bold, numeric (100-900)
    • Font-style: normal, italic
    • Overflow: visible, hidden, scroll, auto
    • auto keyword for margins/width/height
  • Represent parsed values as a CssValue enum with typed variants
  • Parse shorthand properties into longhand (at least margin, padding, border, background)
  • Write comprehensive tests

Dependencies#

  • CSS tokenizer

Implementation Notes#

  • This provides the typed value layer between raw tokens and computed styles
  • Shorthand expansion is critical for the cascade to work correctly
sign up or login to add to the discussion
Labels

None yet.

assignee

None yet.

Participants 1
AT URI
at://did:plc:meotu43t6usg4qdwzenk4s2t/sh.tangled.repo.issue/3mgavtxkjh42l