fix(cv): wait for usable layout before preview pagination

This commit is contained in:
cesnimda
2026-10-10 21:55:01 +02:00
parent 57054349ef
commit c22f3fc753
2 changed files with 17 additions and 0 deletions
@@ -9,3 +9,13 @@ Two additional native Chromium regressions in `e2e/cv-pagination.spec.ts` reprod
The injected one-shot script measures `.page` before its display:none ancestor becomes visible, constructs permanent zero-width column flow and announces a settled layout. Fonts/images readiness does not establish usable geometry. Correction must await actual layout without altering PDF, page dimensions, print spacing, fonts or existing fidelity tolerances.
PRES-C06 is FAIL at this reproduction checkpoint; C09/C12 retain independently passing PDF evidence and incomplete acceptance. This record makes no repair/full-suite claim. Screen-reader, real-device and production font/photo qualifications remain incomplete.
## Repair successor — GO for the bounded lifecycle repair
`previewDocumentHtml` now waits for a nonzero `.page` width using a ResizeObserver only when initial layout is hidden. It disconnects immediately when usable geometry is available, then uses the unchanged physical measurement/print fragmentation path. Visible documents take the original path directly. No PDF, geometry, typography, margin, splitting rule, save or revision behaviour is changed.
Fresh native results: all four pagination cases pass (two existing plus two new hidden-initial cases). The unchanged owned mobile Edit→Preview/API PDF case passes against a rebuilt frontend. Standard native exports pass **16/16,36preview=36PDF**; settings exports pass **8/8,24=24**, with unchanged0.5mm dimensions/2mm positions/0.5pt fonts/1/255 RGB/exact page count+membership tolerances. The associated seven readiness/settings browser cases pass, including independent-client conflicts and stale draft download/reload. Frontend498/498, TypeScript/lint/build and revision5/5 pass.
Performance: the observer exists only for a hidden initial frame and is disconnected after its first usable layout. Hide/show, orientation and external scale changes in the regression produce no additional ready event/pagination work; no per-keystroke polling, extra preview remount or continuous reflow loop is introduced. Duration includes any time spent intentionally hidden, so it is not an isolated CPU timing benchmark. Production hardware throughput is not qualified by local Windows measurements.
PRES-C06 can return FAIL→PARTIAL for this corrected lifecycle; full human/device/font/photo acceptance remains open. The original02 report stays historical NO-GO until its other P1 repair and successor matrix are reconciled. Production remains NO-GO.
+7
View File
@@ -6,6 +6,13 @@ export function previewDocumentHtml(html: string, fallbackHeightPx: number, page
const page=document.querySelector('.page');if(!page)return;
await document.fonts.ready;
await Promise.all(Array.from(document.images).map(image=>image.decode().catch(()=>{})));
// Visible-page frames can start inside the compact editor's hidden pane.
if(!page.getBoundingClientRect().width)await new Promise(resolve=>{
const observer=new ResizeObserver(()=>{
if(page.getBoundingClientRect().width){observer.disconnect();resolve();}
});
observer.observe(page);
});
const width=page.getBoundingClientRect().width;
const height=parseFloat(getComputedStyle(page).minHeight)||${fallbackHeightPx};
const margin=parseFloat(getComputedStyle(document.documentElement).getPropertyValue('--cv-page-margin'))*96/25.4;