Repository navigation
Read an annotation's dictionary const when asking where it draws - #136
Merged
Merged
Conversation
EPDFAnnot_GetDrawingRect() took the annotation's dictionary with GetMutableAnnotDict() to build the CPDF_Annot it asks. On a layer that copies the dictionary in, outside any transaction, though the call only reads: an appearance that is missing is drawn in memory, and nothing is written. The engine asks where an annotation or a widget without a stored appearance draws before it renders it. So the first render of a page left a copy of each such annotation of the file in the layer. The engine tells whether a page changed by what the layer holds of it: after a page's delete was undone and the page was rendered for the first time, it took the page for a changed one and left the redo of the delete alone. The dictionary is now read const, as a render (fpdf_view.cpp) and the flattener read it for the same drawing. Test: EPDFAnnotEmbedderTest.AskingWhereAMarkDrawsLeavesALayerAlone. It fails without the change: the layer holds one object after the call. It leaves nothing in a layer, so the list of layer-mode writers stays as it is.
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
EPDFAnnot_GetDrawingRect()took the annotation's dictionary withGetMutableAnnotDict()to build theCPDF_Annotit asks. The call only reads: a missing appearance is drawn in memory (MissingAppearance::kGenerateWhenDrawn) and nothing is written. But on a layer a dictionary taken for writing is copied in, and here outside any transaction, againstreads-dont-write.The engine asks where an annotation or a widget without a stored appearance draws before it renders it. So the first render of a page left a copy of each such annotation of the file in the layer.
What that broke: the engine tells whether a page changed by what the layer holds of it. A page is deleted, the delete is undone, the page is rendered for the first time, and the redo of the delete finds a page that reads as changed and leaves it. It shows when nothing drew the page before the delete in the same layer session, which is every time through the server. It is in the released runtime too.
A render (
fpdf_view.cpp) and the flattener (epdf_flatten.cpp) read the same dictionary const for the same drawing. This was the one reader that didn't.Change
EPDFAnnot_GetDrawingRect()reads the dictionary const, as those two do.reads-dont-writerule names the function and its guard.I went through every exported function of
fpdfsdk/epdf_*.cppwhose name reads (Get,Has,Is,Count,Render,Exportand the like) for aGetMutable*call in its own body. Besides this one,EPDFAnnot_ExportAppearance()andEPDFPage_ExportAnnotationsAsDocument()have one, on the copy they build and not on the source. A mutable getter behind a helper is not covered by that search.Tests
EPDFAnnotEmbedderTest.AskingWhereAMarkDrawsLeavesALayerAlone: on a layer overredact_annot.pdf, asking where the mark without an appearance draws gives its box and leaves the layer holding nothing.Checked
check-fork-tags.py --strict,check-c-api.py(604 functions).check-globals.pyon a macOS library built from this branch merged with Give every redrawn form field a new appearance stream #135.Left
fix/page-redo-after-picture-readthere, on top of the tests for Give every redrawn form field a new appearance stream #135.check-globals.py, and the saved-file checker (the change writes nothing).