From b33dc77e309610363d3aadf2143357b2819f5caa Mon Sep 17 00:00:00 2001 From: Andreas Stefl Date: Wed, 26 Aug 2026 22:11:20 +0200 Subject: [PATCH] feat(pdf): skip laying out and painting an off-screen page A body zoom relaid out every page at every step. On a file whose pages hold tens of thousands of svg paths that is ~340ms a step; `content-visibility:auto` takes it to ~50ms and halves the time to open. The page box states its own width and height, so it needs no `contain-intrinsic-size` and the scroll geometry is unchanged. Render-neutral: the 255-page raster comparison scores identically, and print still emits every page. Co-Authored-By: Claude Opus 5 (1M context) Claude-Session: https://claude.ai/code/session_0169dUoxqhqfi7ZU5ei8b9ov --- CHANGELOG.md | 3 +++ src/odr/internal/html/pdf_file.cpp | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7a5c1958c..c8816c32c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -84,6 +84,9 @@ The release run heads these entries with the version and opens a fresh - Text in a pdf can be selected, searched and copied where it came out as CJK before. A simple font's codes are one byte each, whatever codespace its `ToUnicode` map declares, and producers routinely declare two. +- A pdf page that is off screen is no longer laid out or painted. On a drawing- + heavy file this halves the time to open and takes a zoom step from ~340ms to + ~50ms. ## v6.10.1 - 2026-08-21 diff --git a/src/odr/internal/html/pdf_file.cpp b/src/odr/internal/html/pdf_file.cpp index e79be122b..2cb8acd66 100644 --- a/src/odr/internal/html/pdf_file.cpp +++ b/src/odr/internal/html/pdf_file.cpp @@ -2599,7 +2599,9 @@ class HtmlServiceImpl final : public HtmlService { "width:max-content;min-width:100%}"; // `overflow:hidden` clips to the crop box, as a viewer does: content may // sit outside it (a bleed, or an InDesign spread's other page). - out.out() << ".p{position:relative;" + // `content-visibility` skips an off-screen page; the box states its own + // size, so no `contain-intrinsic-size` and no scroll geometry change. + out.out() << ".p{content-visibility:auto;position:relative;" "margin:0 max(16px,var(--odr-min-margin-right,0px)) 0 " "max(16px,var(--odr-min-margin-left,0px));background:#fff;" "overflow:hidden;box-shadow:0 1px 4px rgba(0,0,0,.5)}";