87 Commits
Author SHA1 Message Date
Liu 08778d8bf6 fix(yutil): strlist_sorted_add should not leave a dangling list
realloc() may move the array before the duplicate check returns
early, leaving *strlist pointing at freed memory. Assign the new
pointer before inspecting entries.

Refs GHSA-v42w-m2h7-fm23.
2026-11-24 21:49:21 +08:00
Liu ec5cd503fa fix(css): oversized selectors should not overflow parser buffers
- Cap the token buffer position across chunked input so a selector
  spanning 511-byte reads cannot write past css_parser_t::buffer.
- Reject selector names longer than MAX_NAME_LEN in
  css_selector_create() instead of writing past name[].
- Bound selector name composition in css_selector_collect_name()
  with explicit length checks.
- Fix trim-left in css_parser_commit() reading buffer[pos] instead
  of buffer[i] and moving the wrong number of bytes.

Fixes GHSA-v42w-m2h7-fm23.
2026-11-24 21:24:49 +08:00
Liu 64ea750885 feat(css): allow unloading style rules by source
- track rules by the source name passed to the loader
- add css_remove_style_rules() and ui_unload_css_string()
- refresh computed styles after removal and cover it with a test
2026-11-21 22:23:12 +08:00
Liu a9de756541 test(css): identify properties and cursor values in assertions 2026-11-21 15:58:52 +08:00
Liu 279eacd3ad fix(css): report unsupported declarations at debug level
Tailwind-generated doc-viewer CSS contains standard values LCUI does not implement (fixed, sticky, grid, table, ...). Skipping them is expected fallback behavior, so log the property or value at debug level instead of error.
2026-11-21 13:42:01 +08:00
Liu edf192475d test(css): identify properties in inheritance assertions
The shorthand and default-inheritance checks reused one fixed description inside loops, so the log showed identical lines with no property context. Include the selector and property name in each assertion name.
2026-11-19 23:38:27 +08:00
Liu 464eed1402 build: centralize package versions and standardize on C11
versions.json is now the single source of truth; scripts/sync-versions.mjs keeps xmake descriptors, tracked version headers and package.json in sync. Sub-library versions are aligned with the published 1.0.0 packages. C11 is set at the project level, and _GNU_SOURCE is defined on POSIX so strict C11 still exposes clock_gettime, strdup and recursive pthread mutexes.
2026-11-19 22:03:59 +08:00
Liu 9f1cb8a6e1 test: stabilize layout tests for Linux font metrics
Use Linux-specific expected heights for Ubuntu Mono wrapping, relax the auto-size width bound, and fix selector/style leaks in the CSS text decoration tests.
2026-11-19 22:03:59 +08:00
Liu a5444668ac test: unused helpers should be removed and footer initialized
Drop ad_count_children and count_by_type, which no longer have any callers, and initialize footer to NULL before scanning dialog children to silence GCC's -Wmaybe-uninitialized in release builds.
2026-11-19 01:19:58 +08:00
Liu e92a4d3906 fix(css): property table coverage should compare int values
GCC reports -Werror=enum-compare because CSS_PROP_TABLE_COUNT is an anonymous enum while STYLE_KEY_TOTAL belongs to css_prop_key_t. Cast both operands to int so the compile-time coverage check also builds with GCC.
2026-11-19 01:19:58 +08:00
Liu 18b74cc9f1 fix(ui): make fit-content width and tooltip reveal deterministic
Initialize the fit-content width during CSS cascade instead of leaving a
stack-garbage value, and apply tooltip visibility in the reveal frame so the
behavior no longer depends on an extra layout pass.
2026-11-16 00:03:50 +08:00
Liu 855855263b feat(css): add align-self support for flex items
- register align-self and resolve auto against the container align-items
- apply per-item alignment to measuring, cross-axis layout and static positions
- align item media icons with the first title line
2026-11-14 00:31:15 +08:00
Liu 1f46778893 fix(ui): stabilize layout measurement and style refresh
- restore intrinsic sizes before measuring flex and block children
- resolve percentage widths against indefinite parents as auto
- reflow parents when child content changes and refresh background geometry
- ignore hidden flex items in gap insertion and use spec static positions
- keep text paint size in sync with the current capture scale
2026-11-13 21:56:39 +08:00
Liu 20b3221cfd fix(ui): stabilize flex layout and add layout contract tests
- merge own sizehint with child layout extent; keep sizehint callable
- support cross-axis auto margins and flex-basis content/percentage
- fix space-evenly gap, canvas destroy, breadcrumb intrinsic width and dynamic text intrinsic refresh
- add flex contract, sizehint, empty layout and field layout suites
- move empty/field scenarios to theme-independent test fixtures
- document layout coverage and known gaps
2026-11-08 00:20:31 +08:00
Liu 844802374d feat(css): support cursor property with standard keyword values
Register the `cursor` property (36 standard keywords, no url() images),
add css_cursor_t, a 6-bit type_bits field and the 34 new keywords, and
implement css_cascade_cursor(). Defaults to `auto`.
2026-10-17 21:16:46 +08:00
Liu 604e9226e8 feat(css): add CSS property inheritance support 2026-10-17 21:16:44 +08:00
Liu 812391f1f5 feat(css): support CSS Color 4 rgb alpha syntax 2026-10-17 21:16:41 +08:00
Liu ae5b7d2ed9 feat(css): add text-decoration property 2026-10-17 21:16:41 +08:00
Liu eb793c5959 fix(css): destroy temporary parsed style values 2026-10-17 21:16:38 +08:00
Liu 3801fdc10f refactor(yutil): rename public APIs and migrate timer to ptk
- charset module renamed to encoding (decode/encode kept)
- time: get_time_ms → y_gettime, sleep_ms → y_sleep
- time: delete get_time_us, get_time_delta, sleep_s
- string: strdup2 → y_strdup, wcsdup2 → y_wcsdup
- string: strtolower → y_strlower, strtrim → y_strtrim
- string: wcstrim → y_wcstrim, strhash → y_strhash
- string: strreplace → y_strreplace, strsplit → y_strsplit
- string: delete wcsreplace, cmdsplit
- math: delete y_iround, y_pow2
- timer module migrated from yutil to ptk as internal timer_scheduler
- WinMain simplified to use __argc/__argv instead of cmdsplit

BREAKING CHANGE: all renamed yutil public APIs require downstream
  to update function names. Deleted APIs require code changes:
  - get_time_us: use y_gettime() for ms timestamps
  - get_time_delta: use y_gettime() - start instead
  - sleep_s: use y_sleep(ms) with millisecond argument
  - wcsreplace: no replacement, had zero callers
  - cmdsplit: WinMain now uses __argc/__argv from CRT
  - timer_list_*: migrated to ptk timer_scheduler_*;
    ptk_reset_timer still available for external use
2026-08-05 22:42:26 +08:00
Liu 6cd01b468e chore: update copyright comment 2026-08-05 22:42:22 +08:00
Liu 7f9f52b904 chore: update copyright and email 2026-08-05 22:42:16 +08:00
Liu f54cd12539 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.
2026-08-05 22:41:30 +08:00
Liu 3d2a8dc35a fix(css): reset parse target on '}' to avoid stale property name
When parsing a value-less declaration that ended with '}' (e.g. inside
`.gap-2 { gap: 8px }` where `gap` is not yet a supported property),
the parser stayed in CSS_PARSER_TARGET_VALUE state. The next rule was
then fed into the value parser with style_parser.property already
cleared, producing misleading "unsupported property" errors and
corrupting subsequent parsing.

Switch target to CSS_PARSER_TARGET_NONE on '}' and to
CSS_PARSER_TARGET_KEY on ';' inside the switch, mirroring the
end-of-block / end-of-declaration semantics. Add an assert to catch any
future regression where css_parser_commit is reached without a
property name.
2026-08-05 22:41:30 +08:00
Liu 3a867040d1 build(xmake): fix package name, target naming and example install
- Remove per-lib set_project() calls that overrode the global lcui
  project name; xmake show now correctly reports the project as lcui.
- Move per-lib set_version() into the corresponding target() block so
  each sub-library keeps an independent version usable for standalone
  packaging.
- Add set_default(false) and set_group(examples) to all pandagl
  examples so they are no longer picked up by xmake package.
- Rename targets to use dashes for consistency:
    pandagl_cairo_example  -> pandagl-cairo-example
    preview_block_layout   -> preview-block-layout
    preview_flex_layout    -> preview-flex-layout
    preview_scrollbar      -> preview-scrollbar
    preview_widget_opacity -> preview-widget-opacity
- Bump yutil submodule to drop its set_project() call as well.
2026-08-05 22:41:23 +08:00
Liu 75dbca815d test: reorganize test suite with xmake test integration
Restructure the test infrastructure with these changes:

* Extend libctest with ctest_suite_t, ctest_parse_args, ctest_run_suites and CTEST_MAIN macro to standardize test entry points; support --grep / --grep= / --list / --interactive flags; add ctest-tests for self-tests.

* Regroup tests by lib boundary: sink unit tests into lib/<name>/tests/ with <lib>_<topic> entry function names, move fixtures into lib/<name>/tests/fixtures/, rename top-level tests/cases/ to tests/integration/ for cross-lib integration tests.

* Add tests/scenes/ for reusable widget tree builders shared by integration cases and visual preview binaries; add tests/previews/ with 4 diagnostic binaries (flex_layout, block_layout, widget_opacity, scrollbar).

* Rewrite all describe/equal description strings using 'should ...' style or noun topic names; drop redundant lcui_quit/lcui_main calls from integration cases.

* Integrate xmake test via add_tests(\default\) and a shared tests.runnable rule defined in the root xmake.lua; the rule wraps the test binary with drmemory (Windows) or valgrind (Linux) when option memcheck=y.

* Drop the lcui-tests aggregation: lcui-tests now contains only integration cases and scenes, not the union of lib tests. Use xmake test to run everything across libs.

* Fix .clang-format: InsertNewlineAtEndOfFile -> InsertNewlineAtEOF (correct key for clang-format 16+).

* Update AGENTS.md with the new test layout, naming rules, description style and run commands.

* Update CI to use xmake test and xmake f --memcheck=y instead of per-lib runs.
2026-08-05 22:41:12 +08:00
OrbisAI Security 259c6ad696 fix(css): stack buffer overflow in selector fullname construction
Multiple unbounded strcpy() calls in lib/css/src/selector
2026-08-05 22:41:08 +08:00
Liu f07b06d154 refactor(css): const css_propdef_t * 2026-03-31 21:20:28 +08:00
rewine 8f205eca97 fix: format-overflow error in gcc 14
log:
format-overflow 从 gcc 14 开始被视为`错误`而非`警告`
> error: lib/css/src/library.c:448:41: 错误:‘sprintf’ may write a terminating nul past the end of the destination [-Werror=format-overflow=]
>  448 |                 sprintf(fullname, "%s %s", link->group->name, selector);
>      |

参考:
https://stackoverflow.com/questions/73769693/how-to-fix-warning-sprintf-swriting-a-termination-nul-past-the-end-ot-the-dest
2025-03-04 10:27:13 +08:00
Liu 940a0fc33a chore: update copyright 2025-01-05 23:29:56 +08:00
Liu 24f3192b9a refactor: update LCUI's dependencies on ui-widgets and ui-router 2024-12-29 23:37:24 +08:00
Liu cfa605110e style: add BOM header 2024-12-23 00:02:48 +08:00
Liu 5a866286c5 style: clear uninitialized warnings 2024-12-22 23:17:11 +08:00
Liu 6851e9aef3 refactor: change type naming style 2024-12-22 23:14:13 +08:00
Liu d1493e315d feat: new layout process 2024-12-22 23:14:13 +08:00
Liu fcff153784 fix(ui): correct width calculation 2024-12-07 13:30:30 +08:00
Liu 1f35451526 feat(ui): add css background-clip property 2024-12-07 13:30:30 +08:00
Liu 85c34e6c31 feat(css): support selector containing escape characters 2024-12-07 13:30:30 +08:00
Liu c15d7a605e fix(css): destroy strpool after destroying the style rules 2024-12-07 13:30:29 +08:00
Liu 5efe7f3ae9 fix(ui): the class change of ancestor widgets did not trigger style refresh 2024-12-07 13:30:29 +08:00
Liu e37dffa510 fix(css): the space property in the style declaration is not set correctly 2024-12-07 13:30:28 +08:00
Liu 375e03bd36 feat: replace custom bool type with bool type in stdbool.h 2024-12-07 13:30:28 +08:00
Liu 68a0f0d828 feat: DPI awareness 2024-09-19 00:06:05 +08:00
Liu 6e5dac2a00 fix(css): incorrect percentage width computed value 2024-09-19 00:06:05 +08:00
Liu e4b0eb4d8d feat: DPI awareness 2024-09-19 00:06:04 +08:00
Liu bc3a910512 refactor(css): libcss_bool_t -> bool 2024-09-19 00:06:00 +08:00
Liu 4b72d14763 fix(css): incorrect percentage width computed value 2024-07-28 22:02:52 +08:00
Liu a6dea4de1a fix(css): CONVER -> COVER 2024-05-13 22:49:22 +08:00
Liu d60ec9227d chore: update copyright year 2024-05-13 22:49:22 +08:00
Liu 185b726108 fix(css): the left property is not cascaded 2024-05-13 22:49:21 +08:00