Repository navigation
Conversation
… too ISO 32000-1 12.5.2 reads an annotation's border from /BS when it has one, and then /Border is not read at all; else from /Border [h v w [dash]]; else the border is solid and 1 wide. Free text has followed that since pull requests 118 and 121. The rule was then written four times, and two places did not follow it. Every form field drawer read /BS alone: text field, combo box, list box, push button, check box, radio button and the signature box. A field with /Border [0 0 5 [4 2]] and no /BS was drawn 1 wide and solid, and one with /Border [0 0 0] was drawn 1 wide, while EPDFAnnot_GetBorderStyle read 5 and dashed, and 0: what the API read and what a redraw drew did not agree. On an annotation whose border is only in /Border, EPDFAnnot_SetBorderDashPattern made a /BS holding only /D, so the width fell to 1, and with no pattern it changed nothing. EPDFAnnot_SetBorderStyle left the old /Border in the file, where a reader that looks at /Border first (PDFium's form filler does) went on showing the old border. fpdfdoc::ReadAnnotBorder (core/fpdfdoc/cpdf_annot_border) now reads the width, the style and the stored dash pattern by the rule. The generator's GetAnnotBorderStyleInfo, GetBorderWidth and GetDashPatternString, and the C API's EPDFAnnot_GetBorderStyle and dash pattern readers, take the border from it. The reader of a bare /BS dictionary is gone, so a drawer can't read /BS alone again; the form field drawers and the link's style read call GetAnnotBorderStyleInfo. Before a setter changes an annotation that has no /BS, its /Border is written into a new /BS as it reads: its width, and a dashed style with its pattern when the array has one. The setter then changes the part it sets, as it does on any /BS, so the dash setter leaves the style alone there too, and /Border is removed. EPDFAnnot_SetBorderStyle refuses a style that is none before it writes anything. With one reading, three inputs ISO does not define read alike everywhere. A /BS /S that is none of its five names is solid: the form fields, the plain free text box and the link took its first letter. A /Border with more than four entries has no dash for the API either. A /BS /S written as a string is the style for the API too. Tests: CPDFGenerateAPTest.BorderArrayDrawsAsBorderStyleForEveryKind draws all seventeen kinds that have a border from /BS and from /Border and compares the streams. CPDFAnnotBorderTest covers the reader. Three EPDFAnnotEmbedderTest cases cover the setters and one a text field through the C API; the four are listed as layer-mode writers.
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
ISO 32000-1 12.5.2 reads an annotation's border from
/BSwhen it has one, and then/Borderis not read at all; else from/Border [h v w [dash]]; else the border is solid and 1 wide. #118 and #121 made free text follow that. The rule was then written four times (three readers in the generator's common file, and the C API getters), and two places did not follow it./BSalone: text field, combo box, list box, push button, check box, radio button and the signature box. A field with/Border [0 0 5 [4 2]]and no/BSwas drawn 1 wide and solid, and one with/Border [0 0 0]was drawn 1 wide, whileEPDFAnnot_GetBorderStyleread 5 and dashed, and 0. What the API read and what a redraw drew did not agree./Border:EPDFAnnot_SetBorderDashPatternwith a pattern made a/BSholding only/D, so the width fell from the array's to 1.EPDFAnnot_SetBorderDashPatternwith no pattern changed nothing: the array's dash stayed.EPDFAnnot_SetBorderStylewrote/BSand left the old/Borderin the file. A reader that looks at/Borderfirst (PDFium's form filler does) went on showing the old border, and the array's dash pattern was lost to every reader that follows ISO.Change
fpdfdoc::ReadAnnotBorder(core/fpdfdoc/cpdf_annot_border.{h,cpp}) reads the width, the style and the stored dash pattern by the rule.GetAnnotBorderStyleInfo,GetBorderWidthandGetDashPatternStringin the generator, andEPDFAnnot_GetBorderStyleand the two dash pattern readers in the C API, all take the border from it. The reader of a bare/BSdictionary is gone, so a drawer can't read/BSalone again.GetAnnotBorderStyleInfo(annot_dict).EPDFAnnot_SetBorderStyleorEPDFAnnot_SetBorderDashPatternchanges an annotation that has no/BS, its/Borderis written into a new/BSas it reads: its width, and a dashed style with its pattern when the array has one. The setter then changes the part it sets, as it does on any/BS, and/Borderis removed (also when it stood beside a/BS). So the dash setter changes the pattern and leaves the style alone there too: a pattern set on a solid/Borderis stored and the border stays solid, and a pattern removed from a dashed one leaves a dashed border that draws the default dash.EPDFAnnot_SetBorderStylerefuses a style that is none before it writes anything.own-appearance-generator. The comments of the getter and both setters inpublic/epdf_annot.hsay what they do with a/Border.What each kind draws:
/BS, both keys, or neither key/BorderThree readings changed so that every reader agrees, all on input ISO does not define:
/BS /Sthat is none of ISO's five names (/Dashed,/Underline) is solid everywhere. The form fields, the plain free text box and the link took its first letter, so/S /Unknowndrew an underline while the API read solid./Borderwith more than four entries has no dash for the API either; it had none for the drawing./BS /Swritten as a string is the style for the API too, as it was for the drawing.Tests
CPDFGenerateAPTest.BorderArrayDrawsAsBorderStyleForEveryKind: for all seventeen kinds, the stream drawn from/Borderequals the stream drawn from/BSat width 5, with dash[4 2]and at width 0; neither key draws as/BS /W 1;/BSwins when both are there.CPDFAnnotBorderTest.*, five tests of the reader.EPDFAnnotEmbedderTest.SettingADashOnABorderArrayKeepsItsWidth,RemovingTheDashOfABorderArrayKeepsItsWidthandSettingABorderStyleRemovesTheBorderArray: the setters, read back through the API and drawn.EPDFAnnotEmbedderTest.AFormFieldDrawsTheBorderItReads: a text field through the C API.Checked
/Bordercomparisons, and the setter and widget tests fail./BS, both keys or neither, nothing differs for ISO's style names; with only/Border, only the seven form field kinds differ.check-fork-tags.py --strict,check-c-api.py(600 functions),check-globals.pyon the macOS and Linux libraries./Borderwhen there is no/BS, as the generator now does.Left
/Borderand no/BS./BSreader inGenerateIconButtonAP. Whichever of the two merges second takes the one-line change toGetAnnotBorderStyleInfo(annot_dict), and the icon button gets a row in the table test.