Review follow-up on #4358: the secondary-click path still selected with cx.hit, which misses a group subordinate lying outside its primary's rectangle and cleared the selection, so the menu offered page actions instead of the comment's. It now uses the group-aware cx.click_hit, as the click does (ISO 32000-2 §12.5.6.2). Double-click editing goes through the same group-aware hit as the click since the rebase onto main, where the press owner comes from the module's hit test; the test covers both.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Pq7HyCfwzyRXj4VfQAVVdv
An ordinary scan stored as JBIG2 was decoded for Group 4 by default, at 0.26 s a page at 300 ppi,
and came out unchanged: Group 4 of a symbol-coded page was 201,132 bytes against 17,291. Over a
500-page scan that is minutes for nothing. Dropping the guard changed no output, as a cost guard
wouldn't, so its test counts the pixels decoded.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AmsdeUCdTaD72jkDw2pJKY
Review on #4358:
- Make Current Properties Default on a Replace Text group selected the
caret, the group's primary, and updated the Insert Text tool. A caret whose
group holds a grouped /IT /StrikeOutTextEdit strikeout now updates the
Replace Text tool; a caret of its own still updates Insert Text.
Test: a_replace_text_group_makes_replace_text_defaults.
- fill_group_text let an empty caret take the primary's slot, so a later caret
with the replacement text was not listed. Only a caret with text lends it.
Test: an_empty_caret_does_not_hide_the_next_carets_text.
Both tests fail with their fix reverted.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Pq7HyCfwzyRXj4VfQAVVdv
A single squashed port of the branch's four commits onto current main, which
split annot's lib.rs (info.rs, modify.rs), render's inspect.rs (model.rs,
annotations.rs, tests.rs), engine's lib.rs (comments.rs, edit/run.rs) and
ui-egui's comments.rs (tools/comments/*). The behaviour and tests are the
branch's (ISO 32000-2 §12.5.6.2):
- a group subordinate is part of its primary's comment: listed, selected,
exported and deleted with it, with the primary's attributes;
- Replace Text writes the caret as the primary and the strikeout as its
subordinate; earlier groups (strikeout primary, text on the caret) still
list their text, through a map;
- deleting a group refuses a locked member, and a subordinate whose primary
is past the depth limit.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Pq7HyCfwzyRXj4VfQAVVdv
Review follow-up on #4378: HiddenInterface::mode_bar skipped the bar only when both the toolbar and the menu bar were hidden. With the native macOS menu bar the bar never draws the menus, so a document setting only HideToolbar (ISO 32000-2 Table 147) left an empty 48 px bar above the page. The bar now goes when the tools are hidden and the menus are hidden or native.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Pq7HyCfwzyRXj4VfQAVVdv
Review on #5010: MAX_TEMPLATE_TEXT allowed for a UTF-16 packet growing
into UTF-8, but not for the other ways a packet's text can grow past its
bytes. Each byte that isn't valid UTF-8 becomes a three-byte replacement
character, and the packets of an array are joined by newlines, so a
document within the 64 MB packet limit could hand parse a template it
refuses. read_packets now checks the text it assembles, each packet and
its newline before they are added, and the text of a single stream,
against MAX_TEMPLATE_TEXT, and refuses past it as too large; a template
it returns always parses.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Pq7HyCfwzyRXj4VfQAVVdv
Review on #3969: for a symbolic TrueType font without an encoding, the
editor overlaid only the codes whose glyph has a name with a Unicode
value on its Standard table. A code whose glyph name has none kept
Standard's reading (0xC4 `tilde`, 0x80 nothing), while extraction falls
back to WinAnsi (vendored hayro-interpret patch (53)): `Ä`, `€`. Such a
code now reads as WinAnsi in the editor as well, so editing and
extraction show the same text.
vendor/README.md: patch (53) names the function it adds,
`EmbeddedKind::symbolic_text`, states the glyph-name rules it shares with
the editor, and lists the pdfcraft-fonts test too.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Pq7HyCfwzyRXj4VfQAVVdv
A single squashed port of the branch's five commits onto current main, which
split ui-egui's lib.rs (app.rs, app/files.rs), canvas.rs (canvas/zoom.rs,
canvas/tests.rs) and control.rs (control/host.rs), replaced the Menu button
with a menu bar and moved the rail and panels into panels/side_panels.rs. The
behaviour and tests are the branch's (ISO 32000-2 Table 147):
- HideToolbar, HideMenubar and HideWindowUI apply in the document's tab, and
F8 (view.toggle_interface) brings them back; on main the toggle is listed in
the View menu beside Full Screen and Read Mode, HideMenubar hides the menu
bar, and HideWindowUI skips the side panels;
- FitWindow measures the spread the view shows, and FitWindow and CenterWindow
wait only while the document is the window's only one;
- a reloaded document keeps its tab's hidden interface; one-page-at-a-time
layouts open at fit page;
- the two strings are in every catalog, fa.tsv (added on main since) too.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Pq7HyCfwzyRXj4VfQAVVdv
main added hayro-interpret patches 51 and 52 (bounded saved graphics
states, /W2 runs past the largest CID), so this branch's patch is now
53 in vendor/README.md; the code comments that cite it follow.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0175FWj4xFhMhSH3UpMU8DSC
CodeRabbit on #3969 (nitpick): Post::glyph_name walks a version 2.0 table's name data
from its start for each glyph, and symbolic_glyph_texts asks for up to 256, so an
untrusted font program (up to 16 MiB) could make opening a document slow. The names the
table spells out are now read once (post_custom_names) and looked up by index
(post_name), giving what Post::glyph_name gives; a test checks that for every glyph of
Inter's version 2.0 table.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
CodeRabbit on #3969: symbolic_glyph_texts read `post` straight from the font, so a
version written with its halves swapped (00 00 00 02 for 2.0, which the renderer
repairs since #2946, vendored hayro-interpret patch (49)) gave the editor no glyph
names while the renderer drew the font. The table is now read as the version it means
first. The test builds the same symbolic font with the swapped version and gets the same
text. Also removes a stray `|` main had left in hayro-interpret's test list, which split
it into a sixth cell.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review follow-up. symbolic_glyph_texts tried each offset across every cmap
subtable, while the renderer reads the records in order, each with its
offsets, and only Windows (3,0)/(3,1) and Macintosh or Unicode-platform
encoding-0 records. A font with a (3,0) and a (3,1) cmap could give the editor
another glyph, and so another name, than the page shows.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review follow-up. The renderer kept only glyph names it could look up whole,
so a variant such as `a.ss01` fell back to WinAnsi while the editor's
glyph_text dropped the suffix and read `a`. The vendored patch now reads names
by the same Adobe Glyph List rules (suffix dropped, `_` components, uniXXXX
groups, uXXXX to uXXXXXX), giving several characters for a ligature, and
checks /Differences itself now that the step sits outside the name chain.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
FrameMaker files distilled with Distiller 3 embed symbolic TrueType subsets
with no /Encoding and no /ToUnicode, whose codes are glyph positions in the
Macintosh order, 29 below ASCII; the font's own cmap maps them to the right
glyphs. Read as WinAnsi (extraction, Word export) or as Standard (the
editor), `Solid` came out as `6ROLG`.
Both readers now take the post-table name of the glyph a code selects, when
that name has a Unicode value, as MuPDF does; the editor's reverse map makes
typing set the same glyphs. Fonts flagged Nonsymbolic, fonts with a named
base encoding, and fonts the editor already treats as Symbol or ZapfDingbats
by name keep their old reading. Vendored hayro-interpret patch (46).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review on #4474: past the text budget every link still resolved and
parsed its whole /QuadPoints array before dropping the result, so many
links sharing one long array cost its length each. Now no array is read
once less than one quadrilateral's bytes is left, and an indirect array
that did not fit is remembered and skipped for later links (the budget
only shrinks). A guard on the budget being exactly zero alone would
rarely trigger, since URIs spend from the same budget.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Pq7HyCfwzyRXj4VfQAVVdv
From a review of the spellings an indexed image can take:
- The palette was read for every 1-bit indexed image, resampled or not, and twice each. Images
share a table, so 1,000 images sharing one with 16 MiB of raw data took 16 to 60 s, none of
them resampled. It is now read only for an image about to be resampled, and a table over
4 KiB is refused before it is copied or decoded, since no palette needs that.
- A colour key can hide the dark sample a tie goes to, so a thin rule of the other was lost: a
white rule on a hidden black went from 255 to the backdrop's 128. An image with a colour key
now keeps its resolution. Grey had this since #5426 and is covered too.
- `/Indexed` by reference, and a base of `[/DeviceRGB]`, are the same colour space and are read
so. `/I`, an inline abbreviation, and a real hival aren't, and such an image is left alone.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AmsdeUCdTaD72jkDw2pJKY
Review on #2539 (nitpick): the README named only the collection limit
and unreadable XMP as fail-closed cases. It now lists all of them (the
run and run-length limits, a removed glyph with unknown text, a form
XObject removed unread past the depth limit or unreadable, the term
limits, the search work limit, oversized or undecodable XMP) and the
metadata the check leaves to Sanitize: XMP on objects other than the
catalog and pages, bookmark titles, and attachments.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Pq7HyCfwzyRXj4VfQAVVdv
comment_edit with one point on a callout whose /CL has six numbers built
the new line from that point and the end only, so the knee was dropped
without a word. An agent moving just the arrow lost the knee.
place_text_box now keeps the old knee when only the arrow point is given;
two points still set both, and a four-number /CL still gains a knee only
when one is sent. The points schema says so.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Pq7HyCfwzyRXj4VfQAVVdv
Review on #4094: resizing a callout's text box moved its frame, but
changing_points had no Resize branch, so no leader line was drawn to the box
until the page was redrawn. A Resize gesture, and the ResizeAnnotation edit
just released, now count as changing the callout: its points stay and its
line is drawn to where the box is going. A box moved alone and released keeps
its knee beside it, as while it was dragged.
Test: a_callout_being_resized_draws_its_leader_line, which fails with the fix
reverted.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Pq7HyCfwzyRXj4VfQAVVdv
A single squashed port of the branch's seven commits onto current main, which
split the files this touched into modules: annot (create.rs, modify.rs,
info.rs), render inspect (model.rs, annotations.rs), engine comments.rs and
ui-egui tools/comments/*. The behaviour and tests are the branch's:
- a callout's arrow point and knee have handles and move on their own; its
line follows the box as Acrobat's does; its text box resizes;
- comment_list gives a callout's points and text box, comment_edit reshapes it;
- /CL is read all or nothing, and a box sent back as f32 still moves or keeps
its line.
On main, select_input's knee cursor moved into point_cursor to stay under the
cognitive-complexity limit.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Pq7HyCfwzyRXj4VfQAVVdv
Once inspection's text budget is spent, a relative URI keeps its raw address, and that is what
the viewer opens. link_list resolved it afresh against /URI /Base and reported an address
nobody opens. It now reads resolved_url from the inspected target, and resolves only for a link
inspection did not list.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Pq7HyCfwzyRXj4VfQAVVdv
The PR's five commits (base URI resolution, QuadPoints hit areas, their budget, the /Rect gate,
zero-area quads, f64 containment), ported onto main, where inspect.rs, canvas.rs and the
comments tool were split into modules: DocInfo::uri_base in inspect.rs, Link::quads and
Link::contains in inspect/model.rs, the reading in inspect/core.rs and inspect/annotations.rs,
their tests in inspect/tests.rs, and PageXform::link_contains in canvas/xform.rs.
ISO 32000-2 §12.6.4.8 Table 211 (/URI /Base) and §12.5.6.5 Table 176 (/QuadPoints).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Pq7HyCfwzyRXj4VfQAVVdv
Two tests wireless89 offered in the #5368 review. Hiding the first, middle,
last or every master widget keeps every master[n] addressable and counted,
live and after save and reopen. With several page areas, a hidden-only
master still counts and a removed page leaves no stale count. Both fail
without 350a41f29 (master count 2 and a TypeError from resolveNode for the
last page; the Cover/master counts in the page-area test).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Pq7HyCfwzyRXj4VfQAVVdv
Each page laying the form out writes names the page area it was made from
(PCXfaArea), and page_area_uses counts those pages, so a page whose only
master field a script hid keeps its master nodes in the script model and a
later script can show them again (review). A file laid out before pages
were named is still read from its generated fields. Adds two tests from
wireless89's review: page-local and shared master values through relayout,
save, reopen and print, and the page whose last master widget is hidden.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Pq7HyCfwzyRXj4VfQAVVdv
apply_overrides walks the body only. Page-master content is now set
page by page: each page made from a page area gets its own copy of the
area's content with the overrides its SOM path (Body[n]...) carries, so
a field a script hides on page 2 is hidden there only after a relayout.
The copies are kept for the whole layout, as the measurement cache keys
on node addresses.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Pq7HyCfwzyRXj4VfQAVVdv
Master-page content repeated on each page shared one SOM path (`master[0]`), so its fields
shared one data node and one script node. Each page's copy is now `master[n]`:
- the layout names it so;
- data binds it per page, except a field bound globally or by explicit ref, which stays shared
(XFA 3.3, "Page Background");
- the live form has one page-area node per page laid out from it, counted from the generated
fields, so a button on page 2 runs its click script as itself.
- an event listed before a script laid the form out again can name an object that is gone (a
page the form no longer fills): it is not run, rather than run with `this` at the form's root,
where `this.presence = "hidden"` hid the whole form.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CBVyQEwtmEw3mS1MoAiwrK
From CodeRabbit's review: default colour spaces apply to an indexed colour space's
device base, so one in force where an annotation's appearance (or a pattern, or
another image's /Alternates) draws the image may change which palette entry is darker,
and the tie a resampled image keeps. Only black-and-white RGB went through
used_elsewhere; indexed images now do too when downsampling is on, and one used beyond
the page and form resources the walk read keeps its resolution, as such RGB keeps its
colour space.
A grey image stays out of this check, since sample 0 stays dark in a grey space, and #5426's rule
for grey is unchanged: the test now has a grey image drawn on the page and in an annotation.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AmsdeUCdTaD72jkDw2pJKY
From CodeRabbit's review of the stack:
- Every JBIG2 image read its /JBIG2Globals afresh, within 32 MiB each but with no
bound across an export or a redaction. A globals stream of the file, not edited since
it was read and with its /DecodeParms direct, now has its filters undone once a
document and is kept for the images that share it (in every clone, which share the
file), up to 64 MiB in all. An edited one, one added in memory, or one with
/DecodeParms by reference (another object, which can change under it) is read each
time as before. This saves the filters only: the decoder reads the segments afresh for
every image, so a real symbol dictionary still costs its decoding once an image.
- view.copy-image dropped "JBIG2 inside other filters" from its missing list on the
strength of Export's test; Copy Image now has its own: a JBIG2 picture behind
ASCIIHexDecode is found under the pointer and copied as its pixels and as a PNG, and
one whose page information is in its globals is read through them.
A JBIG2 image's /Width and /Height are read as given directly; one by reference is an
error rather than an image of no rows.
A /JBIG2Globals reference to no object still reads as no globals: it is a reference
to null (ISO 32000-2 §7.3.10), which an entry may hold for being absent (§7.3.7), and
the renderer draws the page so. An image that needed those globals then mostly fails
to decode; in a probe of twelve pictures that decoded with them, eleven were refused
and one decoded to other pixels.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AmsdeUCdTaD72jkDw2pJKY
Chinese and Japanese text wraps between characters, so the word space
put at each joined line break showed up inside the text. No space is
added now when both sides of the break are Chinese or Japanese
characters, their punctuation or fullwidth forms; Korean, which spaces
its words, still gets one. A line ending in a full-width full stop,
exclamation or question mark (also inside closing corner brackets) now
ends its paragraph like one ending in a full stop.
The new test lines fail without the change. The wrapped sentence test
now checks the Markdown export too, which goes through the same
joining since it was added.
Word and LibreOffice often draw a list's bullet in a symbol font, a
tab stop before the item's text, so each bullet is a block of its own.
Table detection read the bullets and the items as two columns, and
every export wrote the list as a borderless two-column table.
Each bullet is now paired with the text that starts within three times
its size after it on its line. The text runs on from its bullet, and
bullets stay out of table detection, so Word gets one paragraph per
item with the bullet first. The Symbol and Wingdings bullets Word
writes (U+F0B7, U+F0A7) count. A dash or a middle dot counts only when
nothing starts left of it on its line, so a dash that stands for
"none" in a table row stays a cell.
The new export and automation tests fail without the change.
Reading splits a line wherever its style changes, and export joined
those blocks along one line only (#4158). A sentence with a bold name
in one line and an italic name in the next came out of Word, HTML, RTF
and PowerPoint as one paragraph per line.
A paragraph whose last line reaches the right edge of the page's text
now runs on into the line just below it, when that line starts at the
same left edge in the same size. Headings, list items, a line that
ends a sentence, an indented line and a line after paragraph space
keep their break. A slanted run whose box leans into the next word by
up to 0.3 of its size still runs on into it.
The new export and automation tests fail without the change.
The page font prune counted the page content, forms without /Resources
and annotation appearances, but not tiling patterns or soft mask groups
without /Resources. Those draw through the page's resources too, so a
Type 3 font only they selected left the page and their text lost its
font. They are now read as well, only when the page lists a Type 3
font.
Two new tests fail without the change.
Each JBIG2 bitmap was bounded on its own, but a few kilobytes could still exhaust memory:
nothing bounded what a page's segments hold for later ones, or how far one segment could
multiply them. Measured on black-box streams, peak memory before and after:
- intermediate regions, 16 in 774 bytes: 514 MiB, now 98 MiB;
- an 8 MiB symbol exported 1,200 times, a 2,989-byte PDF: killed at 8 GiB, now 79 MB;
- dictionaries of zero-width symbols: 781 MB, now 72 MB;
- dictionaries retaining their coding contexts, 1.1 MB: 2.89 GB, now 71 MB;
- 65,535 references to one dictionary, 78 KB: about 17 GB, now 6 MB;
- a halftone grid of 16,384 cells a side, 98 bytes: 1.1 GB, now 2.4 MB;
- a pattern dictionary of 65,535 patterns, 48 bytes: 539 MB, now 15 MB, and it still draws;
- a custom Huffman table behind nested Flate, a 1,297-byte PDF: killed at 8 GiB, now 278 MB,
which is mostly the decoded stream;
- 11-byte segments behind nested Flate in a stream and its globals, a 4,765-byte PDF: 5 GB, now
602 MB, which is mostly the two decoded streams;
- an Indexed image whose page header claims 2^20 a side, a 743-byte PDF: aborted asking for
137 GB, now 23 MB;
- a chain of 4,000 /JBIG2Globals streams that are JBIG2 themselves, on a 2 MiB stack: overflowed
it and aborted, now 24 MB.
So PageState counts what it stores: regions, pattern and symbol dictionaries and Huffman
tables, with bitmap headers, retained contexts and a charge per item, up to 64 MiB, two square
bitmaps of 16,384 a side. A dictionary's new and exported symbols count against what is left as they are
made, not once it is stored. A segment may refer to at most 2^20 symbols, checked before any are
collected. A halftone grid has at most 2^25 cells. A pattern dictionary keeps at most 16 MiB of
shifted copies, which only speed up drawing, and none that wouldn't fit what the page has left. A custom Huffman table has at most 2^16 lines, and a
stream with its globals at most 2^20 segments and 2^22 references, checked as they are read. A
page past the bounds on a bitmap is refused when the stream is opened, since callers size their
output from its header before the page bitmap is made. And in hayro-syntax, a /JBIG2Globals
stream that is itself JBIG2 isn't decoded: globals are raw segments, so it reads as globals that
can't be decoded.
An image past a bound isn't drawn, as with the other caps, and the rest of the page is. This
bounds memory, not time: decoding work has no total yet.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AmsdeUCdTaD72jkDw2pJKY
rfd 0.17 gives each filter extension to the XDG portal, GTK and Zenity as
the glob `*.<ext>`, which those match case-sensitively, so a "PDF" filter
of `pdf` hid `Report.PDF`. `AddFilterAnyCase::add_filter_any_case` passes
each letter as a bracket class there (`pdf` -> `[pP][dD][fF]`) and the
extension unchanged on Windows, macOS and the web, which already ignore
case. Every picker filter in ui-egui now goes through it; the imports
used only by native pickers are gated off wasm.
Fixes#5481
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SqmHYx8FiWM5PcsoiErgp9