Skip to content

Add CSSThemeCompiler and fix MutableResource typo with tests#4575

Merged
shai-almog merged 2 commits intomasterfrom
codex/port-css-compiler-to-codename-one-api
Feb 26, 2026
Merged

Add CSSThemeCompiler and fix MutableResource typo with tests#4575
shai-almog merged 2 commits intomasterfrom
codex/port-css-compiler-to-codename-one-api

Conversation

@shai-almog
Copy link
Collaborator

Motivation

  • Provide a lightweight compiler to convert a subset of Codename One CSS into theme properties stored in a mutable resource.
  • Replace the historical typo class MutableResouce with a correct MutableResource implementation and keep a deprecated, backward-compatible MutableResouce wrapper.
  • Enable programmatic editing and serialization of resources (IMAGE/DATA/L10N) in non-designer environments and support generating ephemeral mutable images from CSS.

Description

  • Introduces com.codename1.ui.css.CSSThemeCompiler, which parses a constrained subset of CSS (selectors, declarations, :root constants, @constants) and emits theme properties into a MutableResource, including color/box normalization, var() resolution, border aggregation, and cn1-mutable-image handling.
  • Adds com.codename1.ui.util.MutableResource as the proper mutable resources class with loading/saving, setters (setImage, setData, setTheme, setL10N), restricted type checks, and deterministic save semantics.
  • Adds a deprecated wrapper MutableResouce that extends MutableResource to preserve backward compatibility with the previous typo-named API.
  • Updates and adds unit tests: CSSThemeCompilerTest to validate CSS compilation into themes and generated mutable images, and renames/updates MutableResouceTest -> MutableResourceTest to exercise the mutable resource API and serialization.

Testing

  • Ran the new unit tests CSSThemeCompilerTest and MutableResourceTest from maven/core-unittests and they passed.
  • Ran the editable save/load round-trip in MutableResourceTest which successfully saved and reloaded IMAGE/DATA/L10N entries via the Resources reader.
  • Asserted compilation outcomes in CSSThemeCompilerTest, including theme keys, derived values, generated mutable image presence, and border type, all of which succeeded.

Codex Task

@shai-almog
Copy link
Collaborator Author

shai-almog commented Feb 26, 2026

Android screenshot updates

Compared 32 screenshots: 31 matched, 1 error.

  • kotlin — comparison error. Comparison error: PNG chunk truncated before CRC while processing: /home/runner/work/_temp/cn1ss-hxcRKB/kotlin.png

    No preview available for this screenshot.
    Full-resolution PNG saved as kotlin.png in workflow artifacts.

Native Android coverage

  • 📊 Line coverage: 7.30% (3714/50867 lines covered) [HTML preview] (artifact android-coverage-report, jacocoAndroidReport/html/index.html)
    • Other counters: instruction 5.70% (18250/320093), branch 2.74% (853/31113), complexity 3.41% (1014/29746), method 6.01% (833/13858), class 9.83% (180/1831)
    • Lowest covered classes
      • kotlin.collections.kotlin.collections.ArraysKt___ArraysKt – 0.00% (0/6327 lines covered)
      • kotlin.collections.unsigned.kotlin.collections.unsigned.UArraysKt___UArraysKt – 0.00% (0/2384 lines covered)
      • org.jacoco.agent.rt.internal_b6258fc.asm.org.jacoco.agent.rt.internal_b6258fc.asm.ClassReader – 0.00% (0/1519 lines covered)
      • kotlin.collections.kotlin.collections.CollectionsKt___CollectionsKt – 0.00% (0/1148 lines covered)
      • org.jacoco.agent.rt.internal_b6258fc.asm.org.jacoco.agent.rt.internal_b6258fc.asm.MethodWriter – 0.00% (0/923 lines covered)
      • kotlin.sequences.kotlin.sequences.SequencesKt___SequencesKt – 0.00% (0/712 lines covered)
      • kotlin.text.kotlin.text.StringsKt___StringsKt – 0.00% (0/623 lines covered)
      • org.jacoco.agent.rt.internal_b6258fc.asm.org.jacoco.agent.rt.internal_b6258fc.asm.Frame – 0.00% (0/564 lines covered)
      • kotlin.collections.kotlin.collections.ArraysKt___ArraysJvmKt – 0.00% (0/495 lines covered)
      • kotlinx.coroutines.kotlinx.coroutines.JobSupport – 0.00% (0/423 lines covered)

@TonGalaxy
Copy link

TonGalaxy commented Feb 26, 2026 via email

@codenameone codenameone deleted a comment from TonGalaxy Feb 26, 2026
@github-actions
Copy link

✅ Continuous Quality Report

Test & Coverage

Static Analysis

Generated automatically by the PR CI workflow.

@shai-almog
Copy link
Collaborator Author

shai-almog commented Feb 26, 2026

Compared 32 screenshots: 32 matched.
✅ Native iOS screenshot tests passed.

Benchmark Results

  • VM Translation Time: 325 seconds
  • Compilation Time: 270 seconds

Detailed Performance Metrics

Metric Duration
Build Time Statistics
Setup & Unzip 25431 ms
Extract Extensions 21 ms
Google Services Setup 2 ms
Scan Classes 610 ms
Extract Libs 1115 ms
Inject Build Hints 44 ms
Generate Unit Tests 4 ms
Generate Stubs 1014 ms
Compile Stubs 2334 ms
Generate Icons 987 ms
Prepare ParparVM 188 ms
ParparVM Execution 208330 ms
Post-VM Setup 244 ms
CocoaPods 5153 ms
Finalize 19 ms
Total Time 245497 msMaven Overhead : 80000 ms
CocoaPods Install (Script) 2000 ms
Simulator Boot 73000 ms
Simulator Boot (Run) 7000 ms
App Install 16000 ms
App Launch 10000 ms
Test Execution 150000 ms

@shai-almog shai-almog merged commit a6e47b5 into master Feb 26, 2026
16 of 17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants