Form XObject vòng 2: rút object khỏi form thật sự — sửa trong form mới được LƯU
Build Windows portable / build (push) Canceled after 0s

CI vòng 1 bắt đúng lỗi thiết kế: FPDFText_SetText trên con trong form KHÔNG
đánh dấu dirty_streams của form (chỉ RemovePageObject/InsertPageObjectAtIndex
mới làm — xem cpdf_pageobjectholder.cpp) nên mọi sửa in-place trong form
không bao giờ được ghi ra file. Test canary fail chính xác ở điểm này.

- Đổi feature pdfium-render pdfium_latest(7543) -> pdfium_7350 (cả ff-engine
  lẫn app): mở remove_object cho Form XObject qua blanket impl
  PdfPageObjectsCommon (wrapper 0.8.37 sót gate 7543 dù binding có đủ);
  API 7350 là subset của DLL bblanchon mới, đã quét 0 hàm 7543-only.
- Mọi sửa/xoá con trong form = RÚT THẬT khỏi form (FPDFFormObj_RemoveObject,
  thứ tự path sâu trước + cùng cha con lớn trước) -> form dirty -> ProcessForm
  regenerate stream khi lưu. SetText con trong form = SetTextMode mới
  NestedRecreate: rút khỏi form + tạo lại ở cấp trang giữ font gốc qua token
  (probe như tầng 0 reflow; thiếu glyph -> nhúng lại bytes/cùng họ), matrix
  đã compose.
- CI test thêm --test-threads=1: PDFium serialize qua 1 mutex toàn cục,
  1 test panic khi giữ lock poison mutex làm 17 test song song chết oan.
Docs cập nhật theo (12-phase4-summary.md Iteration 4).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
2026-08-08 02:00:10 +07:00
co-authored by Claude Fable 5
parent e66252681c
commit fd731255ac
6 changed files with 183 additions and 77 deletions
+19 -12
View File
@@ -23,18 +23,25 @@ Type0/CID nhúng), trong khi `list_objects` chỉ duyệt object cấp trang.
thị nhân `mat_vscale(acc)` (độ dài ảnh vector đơn vị Y).
- **ObjectInfo thêm `nested`** (con trong form — sửa text OK, kéo/resize chưa)
**+ `expanded`** (form đã liệt kê con — UI bỏ khung form để khỏi che con).
- **Áp op cho con trong form**: SetText in-place resolve theo path (đổi cỡ:
so cỡ theo KHÔNG GIAN TRANG — target × vscale); SetText-substitute và
ReflowText tạo object mới ở CẤP TRANG với matrix/toạ độ đã compose;
**"xoá" con trong form = `set_text("")`** (glyph biến mất) vì
`FPDFFormObj_RemoveObject` chưa mở ở wrapper cho pdfium_7543 — làm TRƯỚC
khi xoá object cấp trang để path còn đúng. Transform (kéo/resize) con
trong form: bỏ qua, UI chặn kéo.
- **Điểm sống còn đã xác minh trước khi code**: PDFium (bản mới, bblanchon
latest) REGENERATE content stream của form khi con bị sửa —
`CPDF_PageContentGenerator::ProcessForm` → `HasDirtyStreams` → chạy
generator đệ quy cho form. Không có cái này thì sửa xong lưu ra vẫn thấy
chữ cũ.
- **Áp op cho con trong form — bài học đắt giá từ CI vòng 1**: `dirty_streams_`
của form CHỈ được đánh dấu bởi `RemovePageObject`/`InsertPageObjectAtIndex`
trên CHÍNH form (xem cpdf_pageobjectholder.cpp) — **`FPDFText_SetText` trên
con KHÔNG làm form dirty → sửa in-place trong form không bao giờ được ghi
ra file** (test canary bắt được đúng lỗi này: extract sau lưu vẫn thấy text
cũ). Cách làm đúng: mọi sửa/xoá con trong form = **RÚT THẬT khỏi form qua
`FPDFFormObj_RemoveObject`** (đánh dấu dirty → `ProcessForm` regenerate
stream form khi lưu) **+ với SetText thì tạo lại ở CẤP TRANG** giữ font gốc
qua token (probe như tầng 0 reflow; thiếu glyph → nhúng lại bytes/cùng họ)
với matrix đã compose (`SetTextMode::NestedRecreate`). Thứ tự rút: path sâu
trước, cùng cha con lớn trước (rút làm tụt index các em). Transform
(kéo/resize) con trong form: bỏ qua, UI chặn kéo.
- **Đổi feature pdfium-render `pdfium_latest`(7543) → `pdfium_7350`** (cả
ff-engine lẫn app): wrapper 0.8.37 gate `remove_object` của form chỉ mở cho
7350/future dù binding có đủ cho 7543 (sót gate upstream); API 7350 là
subset của DLL bblanchon mới → không mất gì (đã quét: 0 hàm 7543-only).
- CI test chạy `--test-threads=1`: PDFium serialize qua 1 mutex toàn cục —
1 test panic khi giữ lock sẽ poison mutex, 17 test song song chết oan
(đã dính ở CI vòng 1).
- Vá kèm: đọc source crate pdfium-render tải từ crates.io để chốt API vì máy
dev không compile được Rust (xem mục CI bên dưới).