From 7dc1bf27e05e9f504dc447dee6947816c08d0d8e Mon Sep 17 00:00:00 2001 From: Viktor Vaczi Date: Fri, 12 Jun 2026 10:18:16 +0200 Subject: [PATCH] =?UTF-8?q?refactor:=20collapse=20dual-mode=20plumbing=20?= =?UTF-8?q?=E2=80=94=20the=20DOM=20port=20is=20the=20only=20WASM=20build?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The canvas (wxUniversal) mode is gone (wxwidgets submodule); remove every piece of side-by-side plumbing so there is exactly one build and one test flow: - scripts/build-wxuniversal-wasm.sh -> scripts/build-wx-wasm.sh; no --dom/--enable-universal; builds into build-wasm/wxwidgets - build-wasm-test.sh: no DOM_BUILD / apps-dom rsync mirror / PORT=dom; apps build straight into tests/apps (Makefile.wasm PORT conditionals collapsed; wx.js + wx-dom.js always pre-js) - docker/build.sh, build-kicad-target.sh, env.sh: WX_PORT / -dom / -universal suffixes removed; kicad builds to kicad-, outputs to output/; wx.js/wx-dom.js copied from the real source path (/workspace/wxwidgets/build/wasm — the old build-wasm path never existed and silently failed) - setup-kicad-wasm.sh: single target dir; the perl wx-dom.js injection is gone — the 7 checked-in kicad pages now reference wx-dom.js directly - playwright configs serve apps/; fixtures drop the test-results/dom and logs/wxwidgets/dom namespacing; boot.spec asserts wxDomPort unconditionally; pcbnew.spec uses one reference image; appearance.spec assertions unconditional - compare/update-baseline-screenshots.sh: --port removed - tests/gal-regression/wasm/Makefile: links build-wasm/wxwidgets and carries wx-dom.js as a second pre-js — the gal-webgl suite (30 specs) now actually builds and runs here (it needed host-side boost+glm via scripts/deps; the bundle had been missing, timing the whole spec out) - tests: clickCanvas() dispatches via page.mouse (DOM widgets legitimately cover the canvas; locator actionability refused the click); the comprehensive spec drives wxChoice through its native `, menus → popup divs) -instead of wxUniversal pixels on a canvas. Goals: styleable modern UI, -native text input/IME, accessibility, crisp rendering — while the existing -canvas port keeps working unchanged from the same source tree. +instead of pixels on a canvas. Goals: styleable modern UI, native text +input/IME, accessibility, crisp rendering. -Status: COMPLETE (Phases 0–7). wxWidgets-side port done, both wx e2e -suites green from one tree, and all six KiCad apps (pcbnew, eeschema, -calculator, pl_editor, symbol_editor, gerbview) build and run on the DOM -port — full kicad e2e suite green under `WX_PORT=dom` (28/0, 1 flaky, -2 skipped). Build with `WX_PORT=dom docker/build.sh ` (outputs in -`output/dom/`); test with `WX_PORT=dom npm run test:kicad`. Work -intentionally stays on `feature/wx-dom-port` (root + wxwidgets + kicad) — -not merged to `main`/`wasm-port`. +Status: COMPLETE and consolidated (2026-06-12). The original canvas +(wxUniversal) mode and all dual-build plumbing have been **removed** — +`--with-wasm` builds the DOM port, full stop. All `src/univ/` + +`include/wx/univ/` modifications were reverted to upstream v3.2.6, so the +wxwidgets fork is upstream + new `src/wasm/` + `include/wx/wasm/` + +`build/wasm/` files + thin hooks. All six KiCad apps (pcbnew, eeschema, +calculator, pl_editor, symbol_editor, gerbview) build and run on it. + +Build: `docker/build.sh ` (outputs in `output/`), wx standalone via +`scripts/build-wx-wasm.sh`, test apps via `scripts/build-wasm-test.sh`. +Test: `npm test` / `npm run test:kicad` from `tests/` (no env vars). +Work intentionally stays on `feature/wx-dom-port` (root + wxwidgets + +kicad) — not merged to `main`/`wasm-port`. ## Architecture in one page -- **One toolkit, two modes.** `--with-wasm --enable-universal` = canvas - (untouched); `--with-wasm` alone = DOM. Selection is file-level via the - build system: `src/univ/` only in canvas builds, `WASM_SRC` (native - controls) only under `WXUNIV_0`. Source of truth is - `build/bakefiles/files.bkl` → dockerized bakefile regenerates - `Makefile.in`/`autoconf_inc.m4` → autoconf regenerates `configure` - (`scripts/build-wxuniversal-wasm.sh` auto-detects each stage's - staleness; `--dom` flag selects the mode). - **C++ owns state; the DOM is a projection.** Controls call `WasmCreateDomNode("type")` once in `Create()`; the shared `wxWindowWasm` machinery then syncs geometry (TLW-relative absolute - positioning, recursing into descendants), visibility - (`IsShownOnScreen`, whole subtree), enabled/font/focus/destruction. - DOM-native state (typed text, checked, selection) syncs back through - events into C++ caches so getters stay synchronous. + positioning, recursing into descendants; ancestor-viewport clipping via + `clip-path`), visibility (`IsShownOnScreen`, whole subtree), + enabled/font/focus/destruction. DOM-native state (typed text, checked, + selection) syncs back through events into C++ caches so getters stay + synchronous. NB: `GetScreenPosition()` is the CLIENT-AREA origin + (`ClientToScreen(0,0)`), not the top-left — the projection subtracts + `GetClientAreaOrigin()` (matters for wxNotebook's tab strip). - **Layout is wx sizers, not CSS.** DOM contributes intrinsic measurement only (clone-based, in an offscreen always-rendered host — sizers run before `Show()`); positions are written as absolute `left/top/w/h`. - **Events** flow element listener → `ccall('wx_dom_event')` → `domevents.cpp` routing table → virtual `wxWindowWasm::OnDomEvent` — the same direct-dispatch pattern as the port's mouse callbacks (proven - against Asyncify-suspended modals). Keyboard arbitration: keystrokes go - untouched to focused DOM editables (Escape excepted). + against Asyncify-suspended modals). Document-level listeners forward + mouse activity over DOM children into the wx hit-test pipeline + (`wx_dom_mouse`); wheel events walk up the window hierarchy. Keyboard + arbitration: keystrokes go untouched to focused DOM editables (Escape + excepted). - **Canvas islands.** Owner-drawn/generic widgets (wxGrid, listctrl, tree, AUI, STC, calendar...) keep painting via the shared `dc.cpp` - Canvas2D path inside per-window canvases; they render near-pixel-equal - to the canvas port. + Canvas2D path inside per-window canvases — the same architecture native + ports use for owner-drawn widgets. - **Menus/toolbars** serialize C++→JS as JSON; popups are DOM divs; - command ids route back via `wxDOM_EVENT_MENU`/`TOOL`. Menu titles, - items, and tools register as rendered elements with the same - type strings the canvas port uses, so registry-based e2e utilities work - identically on both ports. + command ids route back via `wxDOM_EVENT_MENU`/`TOOL`. The DOM-native + wxNotebook renders a real tab strip (`