The goal is to be CSS-spec compliant.
After doing changes, always run tests.
When writing code, please first write a test (test driven development), and then try to fix/implement a feature.
When fixing a bug, or adding features, make sure to add tests for these.
When doing changes, please also see if offscreen rendering outputs correct result. cargo run --bin offscreen_render -- ui_demo.html /tmp/render.svg When visual output doesn't match expectations but tests somehow pass, analyze why tests didn't catch the regression/bug.
Layout tests use Chromium baseline comparison (tests/layout_comparison_tests.rs).
This compares SVG output from Graviton against Chromium-rendered baselines.
Important guidelines for layout tests:
-
Do NOT use text content in layout tests - Font rendering is not reliable across platforms. Instead, use
display: inlineelements with explicit dimensions to simulate inline content behavior. -
Test fixtures go in
test_fixtures/directory:*.html- HTML test cases*.svg- Chromium baseline SVGs (generated byscripts/generate_baselines.js)
-
To add a new layout test:
- Create
test_fixtures/your_test.html - Run
cd scripts && npm run generateto generate Chromium baseline - Add test function in
tests/layout_comparison_tests.rs
- Create
-
Text-specific tests (
tests/text_layout_tests.rs) are for testing text preprocessing (word splitting, measurement, ascent) - not layout positioning. Layout positioning of text is validated through the unified inline layout algorithm which is tested via baseline comparison with inline elements.
Graviton provides a CDP-compatible devtools agent for programmatic page inspection.
cargo run --bin devtools_agent -- page.html [width] [height]Reads JSON commands from stdin, writes responses to stdout. Uses standard Chrome DevTools Protocol format.
Supported domains: DOM, CSS, Page, Input, Runtime, Overlay
See: docs/devtools_protocol.md for full reference.