Commit Graph
6348 Commits
Author SHA1 Message Date
alehelandClaude Opus 5.5 3c0ac1f77c test(ui): wait_for_cursor waits with step_until
It hovered fifty times with a 10 ms sleep between, so a busy runner
could run out of tries before the page's text or paragraph boxes
arrived from their worker threads. It now steps frames with
`support::step_until`, as the other waits for background work do,
until the cursor is the one wanted or 30 seconds pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-04 19:37:47 +01:00
alehelandClaude Opus 5.5 0378eee687 test(ui): page modules never read the router; the compiler holds it
With the Edit text group, the text layer and link following told what
the press is to their page, only the page view reads the router.

- The router's methods and `DocView.router` are `pub(in crate::canvas)`:
  outside `canvas` the compiler refuses a read or a write, aliases
  included, which the guard's text match could miss. `ROUTER_READERS`
  keeps only the page view's dispatcher (`page_tool_input`).
- Rule (f): no function in a page module is named with "grabs" or
  "owns", which decide for themselves whether a press is theirs.
- CLAUDE.md's "Page presses" rule says so: modules never read the
  router; they are told.

Each rule seen failing against a violation planted in `#[cfg(any())]`
code (a `router.keeps_drag()` read in `content_ui`, a `fn fill_grabs` in
`fill_sign`), and a real router read from `content_ui` no longer
compiles.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-04 19:37:46 +01:00
alehelandClaude Opus 5.5 b3509dc629 fix(ui): a comment's move, resize or reshape ends once its button is up
A comment's gesture ended only on egui's `drag_stopped()`. When the pages
missed its release (the button let go where they didn't see it), the
gesture stayed live: it kept the page's frames from Fill & Sign and the
shape tools, and the next drag that stopped on the page committed it,
taking the comment there.

It now ends, as the other page gestures do, on `drag_stopped()` or once
the primary button is up, where the pointer is.

Two tests planted a live move with the button up to check that a live
move keeps its page's presses (`main`'s
`active_comment_gesture_keeps_highlighted_link_click` and 4a's
`a_fill_and_sign_click_places_nothing_while_a_mark_is_moved`). That
state now ends at once, so both hold the press through the planted move
instead: the intent stands, and each still fails with the live-move
guard taken out.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-04 19:37:46 +01:00
alehelandClaude Opus 5.5 85fbcc436b refactor(ui): the text layer, image pick and link following are told the press
The text layer asked the router whether the press's owner kept its drag,
link following asked it which link held the press, and the Link tool
started a new link from a press any link held, since the router kept a
declined drag's capture.

- `PageRouter::drag_started`: a drag the owner declines (text markup;
  with the Link tool, a link) is nobody's once it starts, on the page it
  began on. The Link tool draws a new link only from a drag nobody
  holds.
- `PageInput` carries the press (`PagePress`) and whether its drag is the
  page's text's (`text_drag`): the text layer and link following read
  them, and `PageRouter::owner` goes. Only the page view reads the
  router now.
- Image pick acts on a press nobody holds: a link's click follows the
  link only, and picks no picture under it (the user's ruling).
- The I-beam drops over a link only where a press would go to it, the
  top hit under the pointer (the user's ruling): the tools that select a
  link's text show it there.
- `PageText::glyph_at` is the one test for the text under a point, for
  the text layer and Redact's boxes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-04 19:37:46 +01:00
alehelandClaude Opus 5.5 a9f592fd64 fix(ui): Edit text's drags end when its input is blocked
Edit text ignores input while a dialog, the palette, another window or
another tab has it. Only a drag of the objects selected together ended
then; a paragraph's move or rewrap, a picture's move, resize, turn or
crop and added content's move waited, and once the input came back with
the button up they landed wherever the pointer was.

While Edit text's input is blocked, `DocView::cancel_edit_text_gestures`
abandons them all, as the objects' already was.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-04 19:37:46 +01:00
alehelandClaude Opus 5.5 607635c157 fix(ui): the page menu is the menu of what the right-click went to
The page's menu chose its entries from the selections, in a fixed order:
a selected Prepare field's menu, then a link's, then the picture's, then
a comment's. A selection left from before outranked what was just
right-clicked, so with a field selected, a right-click on the empty page
(or on a comment) opened the field's menu.

The right-click remembers what it went to (`DocView.menu_for`, from the
routed hits), and the menu shows that owner's entries when it has a
menu, or else the page's (the user's ruling). Add text's right-click is
the page's, as before; while a press is held only a link takes its menu.
The picture menu's flag and its geometric test go with it.

#5900's menu check (no image menu over the picture being cropped, #5835)
is the routed owner's too: a right-click that went to the crop (its
picture, box or grips) opens no menu, and `crop_contains_point` and
`crop_controls_contain`, its second point test, go.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-04 19:37:46 +01:00
alehelandClaude Opus 5.5 cbcf79acc7 refactor(ui): tell Edit text, Add text, pictures and added content whether the press is theirs
The Edit text group still asked the router for itself and passed answers
from one module to the next: `others_own_pointer`, `text_used`,
`over_source`, `source_blocked` and the pictures' `allow_interaction`
decided who acted, so what the pointer happened to be over at the release,
or an earlier module's answer, could take a click from the module its
press was on.

- Paragraphs (`ParagraphCx`), pictures (`ImageCx`) and added content
  (`ContentCx`) are told the press (`PagePress`) and Edit text's gate (its
  input blocked by a dialog, the palette, another window or tab, as
  before), and act on their own presses; the paragraph outline comes from
  the top hit under the pointer (`hovered`), hidden while the objects
  selected together or added content being moved hold the page. The flags
  go, and the three modules no longer read the router.
- Add text acts on the paragraph its press was on, or the one under the
  pointer; its click on a paragraph refuses a blocked draft and finishes
  the one being typed in the paragraph's own act.
- Clicks act where they were pressed (the user's ruling): a paragraph
  opens though the button came up just past its box, added text is
  selected, and opened for typing, by the item its press was on, and Add
  text's new box starts where it was pressed (a press beside a paragraph
  released inside it starts a box; it placed nothing).
- The picture's grips and rotate knob lose their egui widgets: a drag
  takes what the press was on. A press past a page's edge is the page's
  that has something under it there (the knob of a picture filling its
  page), so the knob still turns the picture there.
- Edit text's right-click goes to what lies on top under it, as every
  tool's does (ruling C): a picture is selected for its menu through
  `edit_text_ui::picture_context`, and a comment over a paragraph or a
  picture gets its own menu. The page view's own picture scan goes.
- #5900's part of that scan (a right-click on the picture being cropped,
  its box or its grips keeps crop mode, over a picture on top of it too)
  is the crop hit's: `CropPart::Cut`, the picture outside the box kept,
  shown or cut away, joins the grips and the box, so a right-click there
  keeps crop mode. Its menu check stays for now (the menu commit takes
  it). Test: `a_right_click_on_the_part_a_crop_cuts_away_keeps_crop_mode`,
  seen failing without `Cut`.
- With the Edit panel open, the tools that don't pick added content up
  still select added text by its own test at the pointer, as before: a
  press-time hit would take the press from the stamps and the other tools
  that place on any press.
- `main`'s press-handler check guards nothing now, and goes; rule (e)
  (`ROUTER_READERS`) keeps the modules from reading the router again.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-04 19:37:46 +01:00
alehelandClaude Opus 5.5 6789b25956 refactor(ui): a press with Shift or ⌘ in Edit text is the objects', by their hit
`object_ui` took a Shift- or ⌘-press before anyone else, whoever owned it,
through its own inventory test at the press point, and declined a plain
press where that test found an object the router didn't (just outside a
picture's edge), so such a press started nothing at all.

- The page view reads the press's modifiers from `PagePointer`
  (`modifiers`: those held at the frame's first primary press). With
  Edit text, a press that adds (Shift, Ctrl or ⌘) is the objects' whole:
  `object_ui::modified_hit` gives `Objects { Toggle(target) }` for the
  object under it, or none (an area selection that adds), `Held` while
  text being typed is open, and `Refused` on a page whose objects can't
  be selected together. Only the press asks: hover and cursors are as
  before.
- `object_ui` is told what the press is to its page (`PagePress`) and acts
  on its own parts; a press nobody holds starts the area selection. The
  inventory test and its decline go, and so does `blocked_page`: the held
  press keeps the editor open until the button is up through its capture.
- A plain press beside a picture, within the 2 px the objects are found
  in but outside the picture, now starts an area selection.
- The guard: `object_ui::input` no longer reads the router.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-04 19:37:46 +01:00
alehelandClaude Opus 5.5 97094a1c86 refactor(ui): crop mode is a hit of its picture, and the picture's keys are the app's
Crop mode held every press on its page through a hit with no point test,
so its claim won the cursor on every visible page (its Default arrow over
the next page's paragraphs), and its own grip test at the drag's start and
its cursor test used different reaches (10 and 8 px).

- `edit_text_ui::crop_hit` says what of the picture being cropped lies
  under a point: a grip of the box kept, the box itself, or the rest of
  its page (`PicturePart::Crop`, on `Layer::Editor`), and the hand over
  its Done, Cancel and Remove Crop controls, past the page's edge too.
  A drag takes what its press was on (`ImageCx.press`), and the cursor is
  the hit's: one reach for both.
- Delete and Backspace on a selected picture, and crop mode's Enter and
  Escape, move to the app's key handling (`edit_text_ui::picture_keys`),
  which no key reaches under a dialog. Delete works wherever the pointer
  is (the user's ruling: before, it did nothing over a paragraph).
  Escape while a button is down is still the press's: it cancels a crop
  drag, and crop mode stays.

- #5900's `crop_controls_contain` (the right-click check for #5835)
  measures with `crop_frames` and the grips' reach, so the crop's frame
  and reach have one source; its `crop_bounds` was `crop_frames`' frame.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-04 19:37:46 +01:00
mtlcl410 4f58d57f8e Merge remote-tracking branch 'upstream/main' into HEAD 2026-11-05 02:35:13 +08:00
mtlcl410 e7683c4619 Merge remote-tracking branch 'upstream/main' into HEAD 2026-11-05 02:35:11 +08:00
mtlcl410 9ae58b3f54 Merge remote-tracking branch 'upstream/main' into HEAD 2026-11-05 02:35:09 +08:00
mtlcl410 fd4d2df058 Merge remote-tracking branch 'upstream/main' into HEAD 2026-11-05 02:35:07 +08:00
FredApps 60894af44d Merge pull request #6125 from KenM76/feat/bookmark-clipboard
feat(ui): cut, copy and paste bookmark subtrees (#3994)
2026-11-04 19:33:28 +01:00
Andrew 2afd62082b Merge remote-tracking branch 'origin/main' into fix/fill-sign-quick-bar-controls 2026-11-04 11:22:09 -07:00
mtlcl410 0d7c0d63bc Merge remote-tracking branch 'upstream/main' into fix/pdfa-unused-fonts 2026-11-05 02:15:16 +08:00
FredApps 9070431ed3 Merge pull request #5250 from KenM76/fix/cleared-max-len-stays-cleared
fix(forms): clearing a field's length limit leaves it with none, not its parent field's
2026-11-04 19:08:06 +01:00
KenM76andClaude Opus 5.5 34426ebd9e Merge origin/main (3788af11) into feat/unreadable-object-report
Keeps both new cos document tests side by side.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SqmHYx8FiWM5PcsoiErgp9
2026-11-04 13:05:10 -05:00
FredApps 3788af11d3 Merge pull request #5808 from KenM76/feat/3d-embed
M12: add a 3D model (U3D or PRC) to a page with a poster (#1297)
2026-11-04 18:53:39 +01:00
FredApps 83cbf8f89f Merge pull request #5476 from KenM76/fix/xfa-check-button-width
M12: an XFA check box without a width is as wide as its box and caption
2026-11-04 18:53:31 +01:00
FredApps 5bf6b63910 Merge pull request #5487 from KenM76/fix/file-dialog-extension-case
fix(ui): list X.PDF in file pickers on Linux and the BSDs (#5481)
2026-11-04 18:53:24 +01:00
FredApps 0429b23ea9 Merge storytold/main into feat/prc-render 2026-11-04 18:51:49 +01:00
FredApps 8d7eb74ff7 Merge remote-tracking branch 'upstream/main' into pk-6125m 2026-11-04 18:50:24 +01:00
FredApps 7d17aea92c Merge pull request #5786 from KenM76/feat/prc-reader
M12: PRC reader crate (`pdfcraft-prc`) (#1297)
2026-11-04 18:50:09 +01:00
Andrew 54a524acc2 Merge remote-tracking branch 'origin/main' into fix/fill-sign-quick-bar-controls
# Conflicts:
#	ATTRIBUTION.md
#	crates/ui-egui/tests/it/fill_sign.rs
2026-11-04 10:50:03 -07:00
Andrew e36d6be2f0 Merge remote-tracking branch 'origin/main' into feat/fill-sign-rail-default
# Conflicts:
#	crates/ui-egui/tests/it/fill_sign.rs
2026-11-04 10:50:01 -07:00
FredApps 899f3806b1 Merge pull request #5432 from KenM76/perf/png-predictor-bytes
perf(render): undo PNG predictors a byte row at a time (#5430)
2026-11-04 18:44:45 +01:00
FredApps 61b80cb646 Merge pull request #6115 from KenM76/feat/outline-io
feat(organize): export, import and copy bookmark trees (#6018)
2026-11-04 18:44:33 +01:00
mtlcl410andClaude Opus 5.5 abb409bac6 M11: a font named through a chain of references is the font PDF/A checks
A /Font entry can point at an object that is nothing but a reference to
another (ISO 32000-1 7.3.10). The fonts something draws with were
recorded by the entry's own reference, so the font dictionary at the end
of such a chain went unchecked. Follow the chain, as resolve does, up to
32 references. (CodeRabbit review on #6172.)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Pq7HyDBXygTf7jcqdsjcfn
2026-11-05 01:25:45 +08:00
Perchenko Anton 11421e19e7 Merge main and resolve conflicts for PR #2778 2026-11-04 19:06:54 +02:00
mtlcl410andClaude Opus 5.5 2cf0554b4a M11: PDF/A verify asks only the fonts something draws with to be embedded
A font that only the interactive form's default resources hold
(/AcroForm /DR, ISO 32000-1 12.7.2) draws nothing, yet Verify PDF/A
reported it as not embedded, so a compliant form failed PDF/A-2b and 3b
on clause 6.2.11.4. Only the fonts a resource dictionary names (a page's,
a form XObject's or appearance stream's, a pattern's or a Type 3 font's)
are now checked; an appearance stream that draws with a /DR font names
it in its own /Resources and still has to embed it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Pq7HyDBXygTf7jcqdsjcfn
2026-11-05 01:05:37 +08:00
KenM76andClaude Opus 5.5 352355ab77 M10: copy keeps formatting as HTML (Copy with formatting)
Copying selected page text now also puts an HTML fragment on the system
clipboard, so a paste into a word processor or mail client keeps
paragraphs, bold, italic, size, colour and font family. The plain text
is unchanged and stays on the clipboard as the alternative.

- export: clip.rs, the clipboard model (ClipText of paragraphs of
  styled spans), its builder with caps (20 000 spans, 2 MiB of text,
  16 MiB of HTML), font_family (subset tag and style suffixes off,
  camel case spaced) and clip_html. Family names are reduced to
  letters, digits, space, '-', '_' and '.', so a font name cannot leave
  the CSS string; text goes through esc, which drops control
  characters.
- engine: Document::rich_copy(page, text, glyphs). Glyphs (view space)
  take the style of the reading block their centre lies in; blocks are
  style-homogeneous. A line wrap inside a block is a space (none after
  a hyphen), a change of block a new paragraph. Refused when the
  document does not allow copying. compare.rs's display unit and
  weight/slant inference are shared, not duplicated.
- automation: text_extract takes format "text" (default) or "html";
  html adds each page's html and styles_incomplete, for the whole page
  or only what rect takes. Other values are InvalidArgs.
- ui-egui: Copy of a run or column selection writes HTML plus the
  plain text in one arboard set (desktop only); the web build and
  Select All of the whole document stay plain text. last_copied_html
  records what was produced, for tests.
- parity: view.copy-with-layout is partial; notes list what is missing
  (RTF, underline/strike-through, tables, Select All, web, glyphs
  outside reading blocks).

Formatting inference and the HTML serialiser are adapted from pdfcer
(MIT, same author) at 540b00ef1a405d1baa67c92f3858535037c7cde8.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SqmHYx8FiWM5PcsoiErgp9
2026-11-04 11:58:06 -05:00
mtlcl410 3574370365 Merge remote-tracking branch 'upstream/main' into HEAD
# Conflicts:
#	crates/ui-egui/src/canvas/page_pointer/tests.rs
#	crates/ui-egui/src/tools/comments/paint.rs
2026-11-05 00:41:50 +08:00
mtlcl410 b96b7e6f77 Merge remote-tracking branch 'upstream/main' into HEAD
# Conflicts:
#	crates/ui-egui/src/tools/comments/geometry.rs
#	crates/ui-egui/src/tools/comments/input.rs
#	crates/ui-egui/src/tools/comments/paint.rs
2026-11-05 00:21:08 +08:00
mtlcl410 b50a6f3096 Merge remote-tracking branch 'upstream/main' into HEAD
# Conflicts:
#	crates/ui-egui/src/tools/comments/input.rs
#	crates/ui-egui/src/tools/comments/tests.rs
2026-11-05 00:18:12 +08:00
mtlcl410 7a54e4518e Merge remote-tracking branch 'upstream/main' into HEAD
# Conflicts:
#	crates/ui-egui/src/tools/forms_ui.rs
2026-11-05 00:14:45 +08:00
mtlcl410 010f1e7340 Merge remote-tracking branch 'upstream/main' into HEAD
# Conflicts:
#	crates/ui-egui/src/tools/forms_ui.rs
2026-11-05 00:13:20 +08:00
mtlcl410 a6cec91a47 Merge remote-tracking branch 'upstream/main' into HEAD
# Conflicts:
#	crates/ui-egui/src/canvas.rs
2026-11-05 00:12:36 +08:00
mtlcl410 2f0b233ee1 Merge remote-tracking branch 'upstream/main' into HEAD
# Conflicts:
#	crates/ui-egui/src/canvas.rs
2026-11-05 00:11:26 +08:00
mtlcl410 ce34743f92 Merge remote-tracking branch 'upstream/main' into HEAD
# Conflicts:
#	crates/ui-egui/src/canvas.rs
#	crates/ui-egui/src/tools/comments/input.rs
2026-11-05 00:07:28 +08:00
KenM76andClaude Opus 5.5 7971fb73f2 fix(cos): a clone's edited objects don't use up its unreadable-object allowance
The unreadable list is shared by clones, and each one hides the entries
it has edited. The 100-entry cap counted the whole shared list, so a clone
that edited every listed object recorded none of its own failures and
listed only "more objects could not be read". The cap now counts the
entries the asking document still shows. Each document still lists at
most 100 entries, then the "more" line.

Test: objects_a_clone_edited_do_not_use_up_its_unreadable_allowance. It
was seen failing with each half reverted (left: 1, right: 10; then
left: 110, right: 101).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SqmHYx8FiWM5PcsoiErgp9
2026-11-04 11:04:00 -05:00
mtlcl410 eaf20fe6d2 Merge remote-tracking branch 'upstream/main' into HEAD
# Conflicts:
#	crates/engine/src/tests.rs
#	crates/forms/src/values.rs
2026-11-05 00:00:29 +08:00
mtlcl410 1aeb1eb775 Merge remote-tracking branch 'upstream/main' into HEAD
# Conflicts:
#	crates/forms/src/read.rs
2026-11-04 23:59:46 +08:00
KenM76andClaude Opus 5.5 02dbc21207 Merge main into feat/unreadable-object-report
Brings the branch up to date with main (8717a085), which added the
follow budget, the remembered object-search misses and held_bytes
(#5548) to Document::try_get.

The one conflict was the load at the end of try_get in
crates/cos/src/document/objects.rs. The resolution keeps both sides:
main's FollowScope guard around the load, and this branch's record of
a load failure in the unreadable-object list (a poisoned lock is still
not recorded, since it says nothing about the object). The held_bytes
caching after a successful load is main's, unchanged. Every other file
merged cleanly.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SqmHYx8FiWM5PcsoiErgp9
2026-11-04 10:12:41 -05:00
KenM76andClaude Opus 5.5 5d2f92c6a7 Merge origin/main into perf/failed-object-cache
Resolves the conflict with #5548 in crates/cos/src/document/objects.rs,
keeping both sides:

- try_get enters main's FollowScope, then loads and caches the load result
  as this branch does: a failure is kept too, except a Poisoned error or a
  load that read this document's unsaved edits (overlay_reads). The bytes a
  success holds are measured by held_bytes through loaded_bytes.
- scan_for keeps main's `unfound` set and counts with main's
  tests::FILE_SCANS. This branch's OBJECT_SEARCHES counter is removed and
  its test uses FILE_SCANS.

Main's `unfound` now remembers a whole-file search that found nothing,
which was this branch's original case. What the failure cache still adds:
a failure that is not a scan miss. A member of an object stream that can't
be decoded decoded the whole stream again on every read, because only
decoded streams are kept. New test
a_member_of_an_undecodable_object_stream_is_decoded_once counts those
decodes with a test-only OBJSTM_DECODES counter: 1 with the fix, 12 with
failures not cached.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SqmHYx8FiWM5PcsoiErgp9
2026-11-04 08:53:46 -05:00
KenM76andClaude Opus 5.5 69f4d0a8fe Merge origin/main into perf/png-predictor-bytes
Resolves vendor/README.md: main's hayro-syntax row, with this branch's
patch (35) and its tests appended.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SqmHYx8FiWM5PcsoiErgp9
2026-11-04 08:33:14 -05:00
FredAppsandClaude Opus 5.5 dddb38d6c2 engine: say why the test looks in the stream's own dictionary
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-04 13:52:33 +01:00
FredAppsandClaude Opus 5.5 8eb962d37b engine: the shared-JBIG2 redaction test looks for the key itself
This branch removes Document::jbig2_globals_ref, which #5910's test
used. The test now counts streams whose dictionary holds JBIG2Globals in
any spelling, which also covers the arrays and references the old
helper didn't read.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-04 13:52:22 +01:00
8717a085ff M2: a JBIG2 refinement reads a reference right of it from its first column (#6048)
A refinement whose reference is offset right of it (GRREFERENCEDX above
0, which a refined text instance has from a wider bitmap, ISO/IEC 14492
Table 12, and a refined symbol from an RDX above 0, Table 18) read the
reference's first 32 columns as 0. hayro-jbig2 emptied its buffers of
the reference left of it and, at its first column, didn't load them
again, so the refinement decoded to other pixels than were coded, or
failed and lost the page.

Vendored patch 15 (13 is #5999, 14 #6016): left of the reference the
buffers keep the words of its first column each row starts with. With
an offset of 0 or less nothing changes.


Claude-Session: https://claude.ai/code/session_01AmsdeUCdTaD72jkDw2pJKY

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: FredApps <153173854+FredApps@users.noreply.github.com>
2026-11-04 13:51:47 +01:00
c0cd40f2e1 M6: forms decodes field values, renamed calculations and detected pages within shared budgets (#6132)
* M6: forms decodes values, renamed calculations and detected pages within shared budgets

Part of #5755: the forms crate's four unbudgeted stream reads go through a
`DecodeBudget`, so an operation's decoding is bounded however often the file
names the same stream.

- A reading of the form decodes its fields' value streams (/V, /DV) within one
  64 MiB budget, as it already does their scripts. Each field got a fresh
  1 GiB allowance, so 300 fields naming one stream decoded it 300 times.
- Renaming a field rewrites the calculations that read it within one script
  budget; past it, a calculation is left as it is, like one that won't decode.
- Field detection reads a page's content within one page's allowance
  (`DecodeBudget::page`), as the content walks do, however often /Contents
  lists a stream.
- The PDF/A declaration is read from at most 8 MiB of XMP, as preflight's
  Standards panel reads it, and only once /NeedAppearances isn't already set.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AmsdeUCdTaD72jkDw2pJKY

* M6: the forms README says which metadata declares PDF/A

declares_pdfa reads pdfaid:part from XMP metadata that decodes within
8 MiB, as preflight's Standards panel reads it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AmsdeUCdTaD72jkDw2pJKY

* M6: a test pins that metadata without pdfaid:part declares no PDF/A

cargo-mutants found `==` turned to `!=` in declares_pdfa's search unpinned:
no case had metadata within the cap that declares nothing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AmsdeUCdTaD72jkDw2pJKY

* M6: field detection reads operators one at a time; the PDF/A check reads XMP as preflight does

From the Resources review of 66415d737:
- page_shapes collected every parsed operator, about 80 bytes for each
  decoded byte of dense content, so a page within its 256 MiB allowance
  could take some 20 GB. It now reads them one at a time
  (pdfcraft_content::ops) and drops the pieces once joined.
- declares_pdfa decoded through a DecodeBudget, which counts every filter
  stage against the 8 MiB cap, so XMP stored through a chain of filters
  stopped declaring PDF/A while preflight's Standards panel, which caps
  each stage, still read it. It reads the metadata as preflight does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AmsdeUCdTaD72jkDw2pJKY

* M6: say what declares PDF/A to forms, and why its metadata read stays direct

From the Legal-forms review of c00e3d2fb: the README and doc comments said
forms reads the declaration "as preflight's Standards panel reads it". The
two share the 8 MiB cap, applied to each filter stage, but forms matches the
bytes pdfaid:part and preflight the identifier by its namespace, as on main.
The sweep's direct-/DecodeParms hit is answered at the site: preflight and
organize read metadata the same way, and the readers move together.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AmsdeUCdTaD72jkDw2pJKY

* forms: rename a shared calculation once; keep unread defaults on Clear form; cap q in detection

- A Calculate action that several fields share by reference is read and
  rewritten once, in place, so every calculation reads the new name and
  the script is decoded once, not skipped past the budget.
- Clear form leaves a field alone when its /DV is a stream the value
  budget didn't reach, instead of emptying it.
- Field detection keeps at most 256 saved graphics states; deeper q are
  counted so each Q still restores its own.
- The dense-content test checks that the budget is spent; exhausted() was
  true from the start with no form visits.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* forms: restore the matrix past the save cap; reset a value that wasn't read

- Field detection keeps the matrix of the first save past MAX_SAVES and
  restores it when the last of them closes. A shape painted after a Q
  that would have undone a cm inside those saves is dropped, as the
  matrix there isn't known, instead of being reported scaled.
- Clear form skips a field only when its value is known: one whose /V
  is a stream the value budget didn't reach is reset, not kept as if it
  equalled an empty default.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* forms: keep detection's saved states in a Saves type

shapes_within went past clippy's cognitive complexity limit (32/30) with
the save-cap tracking inline. The same logic now lives in Saves (save,
restore, moved, unknown).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: FredApps <153173854+FredApps@users.noreply.github.com>
2026-11-04 13:51:40 +01:00