Skip to content

DOM/CSS mapping reference

OpenPencil maps browser-computed DOM/CSS styles into SceneGraph fields through @open-pencil/dom-css. Browser adapters should use native DOM/CSSOM and getComputedStyle() as the source of truth. Headless conversion is an approximation for tests and CLI usage.

Layout

CSSSceneGraphNotes
display: flex / inline-flexlayoutModeflex-direction: row maps to horizontal; column maps to vertical.
justify-contentprimaryAxisAlignSupports start, center, end/flex-end, and space-between.
align-itemscounterAxisAlignSupports start, center, end/flex-end, stretch, and baseline.
align-selflayoutAlignSelfSupports start, center, end/flex-end, stretch, and baseline.
flex-wrap: wraplayoutWrap: WRAPCounter-axis spacing is preserved when gaps are available.
gap, row-gap, column-gapitemSpacing, counterAxisSpacingAxis-aware: row and column gaps swap meaning for column flex direction.
padding-*paddingTop/Right/Bottom/LeftBrowser-computed physical values are preferred.
position: absolute/fixed, left, toplayoutPositioning, x, yRight/bottom constraints are not mapped yet.
overflow: hidden/clipclipsContentOther overflow values are ignored.
width, height, min/max sizesnode size constraintsBrowser-computed pixel values are preferred.
aspect-ratiofallback width/height sizingUsed when one axis is available and the other is auto/missing.

Paint, stroke, and effects

CSSSceneGraphNotes
background-colorsolid fillTransparent values are ignored.
border-color, border-*-colorstroke colorFirst available border color is used.
border-width, border-*-widthstroke weight / independent stroke weightsSide-specific widths set independent stroke weights.
border-style: dashed/dotteddashPatternUnsupported border styles fall back to solid.
border-radius, border-*-radiuscorner radiiIndependent corners are preserved when sides differ.
opacitynode opacityNumeric computed value.
box-shadowdrop shadowFirst simple outer shadow only; complex shadow lists require maintained parser or browser-computed support before mapping.
<img src="data:...">image fillData URL images are stored in the graph image map.
<img src="https://...">preserved source URL metadataExternal URL fetching is not performed; the URL is retained for HTML round-trip.
object-fit: contain/coverimage FIT / FILL scale modescale-down maps to FIT; other object-fit values are not mapped yet.

Text

CSSSceneGraphNotes
colortext fillUses core color parsing.
font-familyfontFamilyUses first family token.
font-sizefontSizePixel/rem-ish numeric values.
font-weightfontWeightNumeric values.
font-style: italicitalicOther styles ignored.
line-heightlineHeightNumeric computed values.
letter-spacingletterSpacingNumeric computed values.
text-alignhorizontal text alignmentSupports center, right, justified; defaults left.
text-decoration-lineunderline / strikethroughDecoration style/thickness are not mapped yet.
text-transformtextCaseUppercase, lowercase, and capitalize map to SceneGraph text case.
white-space: nowrapmaxLines = 1Other white-space values are not mapped yet.
text-shadowdrop shadow effectSimple shadows only.

Browser-oracle but not mapped yet

These values are collected or covered by browser oracle tests but do not yet have a stable SceneGraph mapping:

  • complex gradients
  • CSS filters
  • multi-shadow lists
  • media-query-specific provenance
  • pseudo-elements

Headless limitations

The headless runtime uses maintained parsers for HTML (parse5) and stylesheets/inline declarations (@acemir/cssom), but still has limited approximations for selector matching, shorthand expansion, calc(), and simple shadows. Do not expand those with ad hoc parsers; prefer browser getComputedStyle() oracle coverage or maintained parser dependencies for new CSS behavior.

Released under the MIT License.