Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion core/fpdfdoc/cpdf_appearancegenerator.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ using fxge::BlendMode;
class CPDF_AppearanceGenerator {
public:
// kPushButton: the button's background and border, and its caption (/MK
// /CA) centred in the /DA font and colour.
// /CA) centred in the /DA font and colour. One that shows its icon alone
// (/MK /TP 1) draws the normal icon (/MK /I) inside the border, fitted as
// /MK /IF says, and no caption. One that shows both (/MK /TP 2 to 6)
// draws both, each in its part of the button.
enum FormType { kTextField, kComboBox, kListBox, kPushButton };

static void GenerateFormAP(CPDF_Document* doc,
Expand Down
508 changes: 455 additions & 53 deletions core/fpdfdoc/cpdf_appearancegenerator_forms.cpp

Large diffs are not rendered by default.

52 changes: 44 additions & 8 deletions docs/embedpdf/fork-ledger.md
Original file line number Diff line number Diff line change
Expand Up @@ -340,13 +340,39 @@ measurement, redaction overlays, form fields. Mixed into upstream's file, it was
file. Apart, upstream's file merges cleanly.
**Where.** `cpdf_appearancegenerator*` and its unit test; the calls in `cpdf_annot.cpp`,
upstream's `FPDFAnnot_AppendObject` and `FPDFAnnot_SetFontColor` in `fpdf_annot.cpp`,
`epdf_annot.cpp`, `epdf_form.cpp`, `epdf_redact.cpp` and the rich text writer.
`epdf_annot.cpp`, `epdf_form.cpp`, `epdf_redact.cpp` and the rich text writer. A push button's
icon (`/MK /I`) is drawn in every layout that shows one. Alone (`/MK /TP 1`, an image field, and
any layout 2 to 6 without a caption) `GenerateIconButtonAP` draws it. With the caption (`/MK /TP`
2 to 6) `GeneratePushButtonFormAP` draws both, and shares the button between them by the rule of
upstream's form filler (`SplitButton`, after `GetPushButtonAppStream` in
`fpdfsdk/cpdfsdk_appstream.cpp`, which stays unchanged), so a button looks the same whichever drew
it. The engine writes layouts 0 and 1 only, a caption or an image field, so layouts 2 to 6 are
met only in buttons other apps made. Either way the icon fit (`/MK /IF`) is read through
upstream's `CPDF_IconFit` and the icon is placed by our own `IconPlacement`, by ISO 32000-2 Table
250: upstream's own placement (`CPDF_IconFit::GetScale` and `GetImageOffset`, used by its form
filler) puts an icon whose fit names no `/A` at the bottom left, where the table's default is the
middle, and reads an icon narrower than one unit as one unit wide. A push button's appearance is
a new stream on every redraw, as a check box's are: the stream it had may be another widget's or
a picture the button showed, so it is never written into, and the icon its resources named goes
with it. Before a form drawer replaces an appearance, a widget whose `/AP` is an indirect object
gets a copy of its own (`OwnAppearanceDict`), and `epdf_annot.cpp` does the same for `/MK` before
a setter writes it (`OwnMKForWriting`): another widget may name the same dictionary. A colour is
set as a new array, never written into the one the entry named, which may be an object another
`/MK` names too. An `/MK` setter that changes nothing writes nothing, and it changes nothing only
when the entry is well formed and reads as the value (three numbers from 0 to 1, a string, an
integer): a malformed entry that reads the same is written anew. An icon is a form XObject
everywhere (`ButtonIconOf`, `MKIconForm`).
**Guarded by.** `check-fork-tags.py` fails when upstream's files differ from upstream
(`fork-pristine.txt`); `upstream-preview.py` lists new upstream callers of `CPDF_GenerateAP::`, and
upstream's commits to its generator.
upstream's commits to its generator. `epdf_widget_drawing_embeddertest.cpp` for a button's icon;
its `AButtonIsSharedAsTheFormFillerSharesIt` runs upstream's form filler on the same buttons and
compares the two.
**When upstream touches this.** A commit to `cpdf_generateap.*`: port it to ours or skip it, with
the reason in the sync report. A new upstream caller of `CPDF_GenerateAP::`: route it to ours, or
accept it in the report.
accept it in the report. A change to what `CPDF_IconFit`'s readers return (`GetScaleMethod`,
`IsProportionalScale`, `GetIconBottomLeftPosition`, `GetFittingBounds`): `IconPlacement` reads the
file through them. A change to how `GetPushButtonAppStream` shares a button: `SplitButton`
follows it, and the comparing test fails until it does.

## Text

Expand Down Expand Up @@ -374,11 +400,21 @@ calls FreeType.

### annot-appearance
**Rule.** Our appearance model: appearance states, box kinds drawn in a frame they measure, dashes,
note icons, canonical stamp drawings, widget rendering, and the hooks into our appearance
generator.
**Why.** Annotations look the same in every viewer and survive edits.
**Where.** `cpdf_annot.cpp`, `cpdf_annotlist.cpp`, `cpdf_annotcontext.cpp`.
**Guarded by.** `epdf_appearance_state_embeddertest.cpp`, the annotation embedder tests.
note icons, canonical drawings, widget rendering, and the hooks into our appearance generator. A
drawing is a picture the document holds once: a form XObject, known by the digest of its canonical
bytes. A stamp's artwork and a mark in a widget each place it with a wrapper of their own, and a
push button's `/MK` names it as an icon, so one drawing serves all three. A drawing is never
written after it is made: placing one only reads it.
**Why.** Annotations look the same in every viewer and survive edits. A picture shown in many
places is in the file once, and a place added after a signature leaves the drawing the signature
covers as it was.
**Where.** `cpdf_annot.cpp`, `cpdf_annotlist.cpp`, `cpdf_annotcontext.cpp`; the drawing calls in
`epdf_annot.cpp` (`EPDFDoc_CanonicalDrawing`, `EPDFDoc_ImportDrawing`, `EPDFDoc_ExportDrawing`,
`EPDFDoc_GetDrawings`, `EPDFAnnot_SetDrawing`, `EPDFAnnot_GetDrawing`, `EPDFAnnot_SetMKIcon`,
`EPDFAnnot_GetMKIcon`) and the wrapper in `epdf_wrapped_appearance.{h,cpp}`.
**Guarded by.** `epdf_appearance_state_embeddertest.cpp`, the annotation embedder tests,
`epdf_widget_drawing_embeddertest.cpp`, and
`EPDFSignatureEmbedderTest.PlacingADrawingAgainLeavesTheSignedRevisionAlone`.
**When upstream touches this.** Annotation drawing and appearance lookup.

### forms-model
Expand Down
4 changes: 4 additions & 0 deletions fpdfsdk/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,10 @@ pdfium_embeddertest_source_set("embeddertests") {
# EmbedPDF: covers annotation calls that read a page's dictionaries
# without loading the page.
"epdf_annot_raw_embeddertest.cpp",
# EmbedPDF: covers drawings in widgets (public/epdf_annot.h): a push
# button's icons and the appearance drawn from the normal one, a mark a
# wrapper places, and one drawing shared with stamps.
"epdf_widget_drawing_embeddertest.cpp",
# EmbedPDF: helpers for tests that compare a document before and after
# writes.
"epdf_edit_test_util.cpp",
Expand Down
Loading