Skip to content

Give a widget joining a group its /Opt value, and read which groups have the list - #139

Merged
bobsingor merged 3 commits into
embedpdf/mainfrom
embedpdf/fix/attach-widget-opt
Dec 1, 2026
Merged

bobsingor merged 3 commits into
embedpdf/mainfrom
embedpdf/fix/attach-widget-opt

Conversation

@bobsingor

Copy link
Copy Markdown
Contributor

Cause

A checkbox or radio group may name its values in a list in the field (/Opt), as Acrobat writes
values that repeat or aren't plain names: a widget's value is the list's entry at its place among
the field's widgets, and its on-state name (/0, /1) only a key. EPDFForm_AttachWidget
appended the new widget to /Kids but wrote no entry, so it read back Yes and never went on with
its value (embedpdf/embed-pdf-viewer#1190, review finding 2). EPDFForm_DetachWidget left the
list as it was, so every widget after the one that left read the value of the widget before it.

Change

  • EPDFForm_AttachWidget takes FPDF_WIDESTRING export_value before split_objnum (NULL: the
    on-state name). When the field has a list, its own or a parent's, the field gets a direct list of
    its own with the value at the new widget's place; a place the list lacked before it gets that
    widget's on-state name, its value without a list. A list that is an object of its own, or a
    parent's, is copied, never written. Without a list, a value other than the on-state is refused,
    and nothing is written; a value for a field that isn't a checkbox or radio group is refused.
  • EPDFForm_DetachWidget takes the widget's entry out of the list.
  • Places are counted as CPDF_InteractiveForm counts a field's controls (/Kids entries that are
    widget dictionaries). A list that is already the field's own is written in place.
  • EPDFForm_HasFieldValuesList(model, field_index): the form model records whether a checkbox or
    radio group has such a list (its own or a parent's). The engine could only guess before, from a
    widget's value differing from its on-state name, which misses a list that repeats the names
    (/Opt [(0) (1)]) or names Yes (/Opt [(Yes)]).

The new widget's on-state name is the caller's: the engine keeps a repeated widget's source name,
so widgets of one value share it and go on together (RadiosInUnison).

Tests

Eight new EPDFFormEmbedderTest cases, the first seven on testing/resources/toggle_values_list.in (an
Acrobat-style group /Opt [(pick-a) (pick-b)] with states /0 /1, a unison group whose list is
an object of its own, a merged checkbox whose value is not Latin):

  • AWidgetJoiningAListedGroupGetsItsValue, AListThatIsAnObjectStaysAsItIs,
    AShortListIsFilledBeforeTheNewPlace, AFieldWithoutAListTakesNoOtherValue,
    AListedMergedCheckboxSplitsAndKeepsItsValue, ADetachedWidgetTakesItsListEntry;
  • AFormFillerSwitchesANewListedButtonInUnison: the saved file in PDFium's own form filler; a
    click on the new button turns on all three buttons of its value.
  • ModelTellsAGroupWhoseValuesAListNames: listed groups (own list, a list that is an object of its
    own, a merged checkbox, a list that repeats the on-state names) read true; a plain radio group
    and a combo box's options read false.

The first seven fail with the writes switched off (signature kept). Every other attach in the tests
passes nullptr for the value.

Checked

  • macOS: unit 1416 passed; embedder 1905 passed, with the 12 failures that fail on the base too
    (8 FPDFProgressiveRenderEmbedderTest, EPDFMeasureEmbedderTest.CaptionAppearanceGolden,
    FPDFEditEmbedderTest.SetTextRenderMode, FPDFViewEmbedderTest.RenderBug664284WithNoNativeText,
    RenderHelloWorldWithFlags).
  • Linux x64 (release image): unit 1423 passed, embedder 1919 passed, none failed (the final sources: the digest of the diff is the same before and after the run).
  • Layer mode: the eight new tests pass; listed in testing/embedpdf_layer_mode_writers.txt.
  • Save tests with the independent save checker: 91 passed, 49 saved PDFs checked.
  • Pixel runner (macOS): 224 run, 147 pass, 26 suppressed, 2 surprises, 51 failures, the same counts
    as before the change.
  • check-fork-tags.py clean; check-c-api.py 605 functions.
  • Through the engine on both runtimes (local build of this branch): a listed radio group repeated as
    boxes reads pick-a/pick-b on every page and switches in unison; undo and redo put the list
    back; the saved file reopens the same.
  • Acrobat 26.002 on that saved file: pick-b is on on every page. A click on a new button switches every page.
    Acrobat reads the group's value as pick-a/pick-b and its widgets' export values as
    pick-a, pick-b three times. Every widget of a repeated checkbox whose list names Ja ✓ exports
    Ja ✓.

Left

  • Release, and the pin in embed-pdf-viewer: the attach signature changed, so the pin commit
    regenerates the bindings and carries the engine's use of the new argument.

…ave the list

A checkbox or radio group may name its values in a list in the field
(/Opt), as Acrobat writes values that repeat or aren't plain names: a
widget's value is the list's entry at its place among the field's
widgets, and its on-state name (/0, /1) only a key.
EPDFForm_AttachWidget appended the new widget to /Kids but wrote no
entry, so it read back Yes and never went on with its value.
EPDFForm_DetachWidget left the list as it was, so every widget after the
one that left read the value of the widget before it.

EPDFForm_AttachWidget takes an export value before split_objnum (NULL:
the on-state name). When the field has a list, its own or a parent's,
the field gets a direct list of its own with the value at the new
widget's place; a place the list lacked before it gets that widget's
on-state name, its value without a list. A list that is an object of
its own, or a parent's, is copied, never written. Without a list, a
value other than the on-state is refused and nothing is written; a value
for a field that isn't a checkbox or radio group is refused.
EPDFForm_DetachWidget takes the widget's entry out of the list. Places
are counted as CPDF_InteractiveForm counts a field's controls (/Kids
entries that are widget dictionaries).

EPDFForm_HasFieldValuesList(model, field_index): the form model records
whether a checkbox or radio group has such a list. The engine could only
guess before, from a widget's value differing from its on-state name,
which misses a list that repeats the names (/Opt [(0) (1)]) or names
Yes (/Opt [(Yes)]).

Tests: eight new EPDFFormEmbedderTest cases on
testing/resources/toggle_values_list.in (a group /Opt [(pick-a)
(pick-b)] with states /0 /1, a unison group whose list is an object of
its own, a merged checkbox whose value is not Latin), one of them in
PDFium's own form filler on the saved file. The seven attach and detach
tests fail with the writes switched off. All eight are in the layer-mode
writers list. Every other attach in the tests passes nullptr.
A review of pull request 139 found two things in the attach.

An empty export value was written as () in the field's list. An empty
entry reads back as another value (PDFium's GetExportValue() gives Yes),
so the widget never had the value asked for. EPDFForm_AttachWidget now
refuses an empty export value before it writes anything. NULL still
means the on-state name.

A list may have fewer entries than the field has widgets. The attach
fills each place the list lacks with that widget's on-state name.
Acrobat reads a widget the list has no entry for by its on-state name
(checked in Acrobat 26.002: a group cut to /Opt [(pick-a)] reads its
second button as 1), as the fork's value transactions do, so the value
Acrobat shows stays the same. GetExportValue() reads Yes there, which
is why the review saw the value change; filling with Yes would change
it in Acrobat instead. The comment and the header now say so.

Tests: AWidgetJoiningAListedGroupGetsItsValue refuses an empty value
and checks nothing was written. AShortListIsFilledBeforeTheNewPlace
checks that the button that is on stays on with its value, after the
attach and after the new widget leaves again.
AWidgetJoiningAListedGroupGetsItsValue makes one more widget for the
refused empty value, so it leaves 12 objects in the layer, not 11.
@bobsingor
bobsingor merged commit 42f70f6 into embedpdf/main Dec 1, 2026
1 check passed
@bobsingor
bobsingor deleted the embedpdf/fix/attach-widget-opt branch December 1, 2026 10:11
bobsingor added a commit to embedpdf/embed-pdf-viewer that referenced this pull request Dec 1, 2026
The release adds one runtime change to a0b1daa34: a widget joining a
checkbox or radio group whose values /Opt names gets its entry, a
widget that leaves takes its entry along, and the form model says
which groups have the list (embedpdf/runtime#139). The previous
commit uses all three.

The bindings generated from the release's headers are the ones the
previous commit carries. runtime-src moves to the pin. The pin file's
nine checksums are the ones the release's assets carry.
roanutil pushed a commit to MFB-Technologies-Inc/embed-pdf-viewer that referenced this pull request Dec 1, 2026
A checkbox or radio group may name its values in a list in the field
(/Opt), as Acrobat writes values that repeat or aren't plain names. A
new button in such a group read back Yes, so form.repeat() refused the
group and addWidget() gave the wrong value. The runtime's attach now
writes the new button's entry (embedpdf/runtime#139), and the engine
uses it.

- The fact: hasValuesList on CheckboxField and RadioField, read from
  the runtime's form model (EPDFForm_HasFieldValuesList). The wire
  member is required; an older server's group reads false. A created
  group predicts false. PR 1190's guess (valuesNamedByList) is gone.
- addedToggleStates() picks each new button's on-state name: a
  repeat's source name, else the name of the field's buttons with that
  value, else the value itself, or for a listed group the lowest number
  no button uses.
- FormMutator.addWidgets() passes each button's value to the attach;
  a repeat keeps its source's name, so copies switch with it. The add
  step keeps the values, so its redo writes the entries back.
- formRepeat no longer refuses a listed group.

Conformance (repeat suite, both engines): a listed group repeats with
its values and switches in unison; undo and redo of a repeat and of an
addWidget put the saved list back; a list that repeats the on-state
names (/Opt [(0) (1)]); a checkbox and a one-button group whose list
names Yes, by repeat and by addWidget.

Contract, SDK, docs and api reports follow. The bindings carry the
attach's new argument and the new getter: until the runtime pin, the
calls into the runtime fail.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant