feat(css): add gap, row-gap and column-gap support

Add the CSS gap shorthand and its row-gap/column-gap longhands for flex
containers.

- Register row-gap/column-gap as longhand properties and gap as a
  shorthand accepting [ normal | <length-percentage> ]{1,2}.
- Add css_gap_t (CSS_GAP_INHERIT/SET/NORMAL) and corresponding
  type/unit/value fields on css_computed_style_t.
- Implement cascade logic in lib/css/src/properties/gap.c, resolving
  normal to zero and rejecting auto.
- Apply gaps in ui_flexbox_layout: main-axis gap participates in line
  size, wrap detection, justify-content space and per-item positioning;
  cross-axis gap participates in cross-size accumulation and line
  positioning. The last item/line never gets a trailing gap. Percentage
  gaps resolve against the container content-box on the corresponding
  axis.
- Cover gap parsing/cascading in lib/css/tests (single/two values,
  axis-only, normal, percentage) and add a flex layout integration test
  exercising column-gap, row-gap, wrapped two-value gap and normal.
This commit is contained in:
Liu
2026-08-05 22:41:30 +08:00
parent 3d2a8dc35a
commit f54cd12539
7 changed files with 1129 additions and 596 deletions
+26
View File
@@ -34,3 +34,29 @@
.w-\[360px\] {
width: 360px;
}
.flex-gap {
display: flex;
gap: 12px;
}
.flex-gap-two-values {
display: flex;
gap: 8px 16px;
}
.flex-gap-axis {
display: flex;
row-gap: 4px;
column-gap: 20px;
}
.flex-gap-normal {
display: flex;
gap: normal;
}
.flex-gap-percentage {
display: flex;
gap: 25% 50%;
}