Repository navigation
Conversation
An undo of a form write puts the field's and its widgets' dictionaries back from a capture taken before the write. An import never replaces an object the layer holds a version of, since that version may be newer. So a widget gets the appearance it had back only when the write left that stream as it read. A text field, a combo box and a list box were drawn into the stream the widget already named. After a second value, a reset, a shown text or a restyle, the undo put /V and the widget's keys back, and the widget still named the same stream, which drew what the write had drawn: the page and a saved file showed the undone value. The stream was also written into when the file held it, or when another widget named it too. GenerateFormAPToTarget now makes a new stream for every kind, as it did for a push button and as the check box, radio button and box drawers do, under an /AP of the widget's own (OwnAppearanceDict). The old stream is not opened for writing, so nothing of it is copied into a layer, and a save writes only what the document still reaches. Tests: EPDFCaptureEmbedderTest.RedrawnFieldComesBackWithItsAppearance and RedrawnFieldLeavesTheFilesAppearanceAlone, EPDFFormEmbedderTest.RedrawIsANewStreamEveryTime and RedrawLeavesASharedAppearanceAlone. All four fail without the change. The two form tests are listed as layer-mode writers, and 21 tests that redraw a text or choice field leave one to six more objects in a layer, one for each redraw.
A review of pull request 135 found two things a new stream lost, which a redraw into the old stream had kept for a text field, a combo box and a list box. The kinds that got new streams before had lost them already. A stream may say which layer it shows in (/OC). The new stream said nothing, so a field whose appearance is in a layer that is off showed its value after a fill, in a reader that goes by the entry. A widget's rollover and pressed appearances (/R, /D) may be its normal one. They went on naming the old stream, with the old value. NameNormalAppearance now names the new appearance for every drawer. A new stream takes the /OC of the stream it replaces, the one of its state for a check box or a radio button. An /R or a /D that named the replaced stream, for the widget or for a state, names the new one, and one made apart stays as it is. A dictionary of states that is an indirect object is copied onto the widget first, as /AP is: another widget may name it. A capture taken before the redraw still brings everything back, since it puts the widget's /AP back whole. Tests: EPDFWidgetDrawingEmbedderTest.ARedrawKeepsTheLayerAndTheSameAppearances, over a text field, a combo box, a list box, a push button with a caption and one without, a signature box, a check box and a radio button, and EPDFCaptureEmbedderTest.RedrawnFieldComesBackWithItsSameAppearances. Both fail without the change, the first for every kind. The first is listed as a layer-mode writer.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Cause
The engine undoes a form write by putting the field's and its widgets' dictionaries back with
EPDFDoc_ImportDictRaw(), from a capture taken before the write (EPDFDoc_ExportDictRawToOwnedBuffer()with the deep keysAP MK). An import puts an object back only where the layer holds no version of its number (InstallObjects, guarded byEPDFCaptureEmbedderTest.ImportNeverReplacesAVersionTheLayerHolds). So a widget gets the appearance it had back only when the write left the stream it named as it read.GenerateFormAPToTargetdrew a text field, a combo box and a list box into the stream the widget already named. A push button, a check box, a radio button and a box got a new stream on every redraw.So after a value written over an appearance, a reset, an appearance text (
EPDFForm_SetFieldAppearanceText()) or a restyle, the import put/Vand the widget's keys back, and the widget still named the same stream, which drew what the undone write had drawn. The page showed the undone value, and a saved file held/V (hello)under a stream that draws(hello world). One fill and its undo is enough. It has been so since captures exist.Two more things followed from writing in place:
/AP, that two widgets name was written into for both.Change
GenerateFormAPToTargetmakes a new stream for every kind and names it in an/APof the widget's own (OwnAppearanceDict). The stream the widget had is not opened for writing, so nothing of it is copied into a layer, and a save writes only what the document still reaches./Type,/Subtype,/Matrix,/BBoxand/Resourceswith the fonts. Other keys the old stream's dictionary held are not carried over. What is drawn does not change.own-appearance-generatorrule and the comment ofEPDFAnnot_GenerateFormFieldAP()state the rule for every kind.Tests
EPDFCaptureEmbedderTest.RedrawnFieldComesBackWithItsAppearance: a field filled in twice, with a capture before the second fill. The second fill names a new stream and leaves the first as it read; the import brings the widget back naming the first, with its bytes, also after a save and reopen dropped it.EPDFCaptureEmbedderTest.RedrawnFieldLeavesTheFilesAppearanceAlone: a widget that names a stream of the file, which a square names too. After a fill the layer holds no version of it, the square still names it, and the import brings the widget back naming it.EPDFFormEmbedderTest.RedrawIsANewStreamEveryTime: a text field, a combo box and a list box each get another stream on a second redraw, and the first still draws what it drew.EPDFFormEmbedderTest.RedrawLeavesASharedAppearanceAlone: two widgets naming one indirect/APand one stream each get an/APand a stream of their own, and the shared two stay as they were.Checked
check-fork-tags.py --strict,check-c-api.py(604 functions),check-globals.pyon the macOS library./Vand stream agree.Left
fix/undo-restores-field-appearancethere and fail until the pin.own-appearance-generatorparagraph, and Make an inline form font an object of its own before an appearance names it #134 in that paragraph and in the writers list. Whichever comes second also needs its new tests' counts in the writers list taken again.check-globals.py, and Acrobat on a file filled in after a signature. The engine's signature tests pass on this runtime.EPDFAnnot_GetDrawingRect()takes the annotation's dictionary withGetMutableAnnotDict(), so asking where an annotation without an appearance draws copies its dictionary into the layer, againstreads-dont-write. The engine then leaves the redo of a page's delete alone when the page's pictures were first read after the undo.fpdf_view.cppreads the same thing const.