diff options
author | jaepark <jaepark@google.com> | 2016-09-09 15:39:09 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-09-09 15:39:09 -0700 |
commit | 75f84a56fed36111ece82d0ac96e87289622b093 (patch) | |
tree | a1e1dc33250b3ec31032a2550298cd4af36c3211 /core/fpdfdoc | |
parent | 55a1eb01db6ceadf9c180931b2663338b8cbc2fd (diff) | |
download | pdfium-75f84a56fed36111ece82d0ac96e87289622b093.tar.xz |
Define behaviors of FPDF_RenderPageBitmap_Retail and FPDF_FFLDraw.chromium/2858chromium/2857chromium/2856
Previously, PDFium only supported widget annotations to draw forms. As
we've implemented other annotations, the behavior of
FPDF_RenderPageBitmap_Retail and FPDF_FFLDraw changed. So, this CL
clearly defines what needs to be done in FPDF_RenderPageBitmap_Retail
and FPDF_FFLDraw.
This CL first assumes that PDFium users will always call
FPDF_RenderPageBitmap_Retail and FPDF_FFLDraw to render PDF pages,
because otherwise they are not able to support PDF forms.
FPDF_RenderPageBitmap_Retail should only deal with non-widget
annotations, such as highlight, underline, text, etc. If
FPDF_ANNOT flag is passed, non-widget annotations are drawn. Otherwise,
they are hidden.
FPDF_FFLDraw should only deal with annotations that requires
user-interaction, such as widget annotations and popup annotation. Since
popup annotation is associated with non-widget annotation, they should
not be drawn if the associated annotation is hidden. Thus, if FPDF_ANNOT
flag is passed, popup annotations are drawn. Otherwise, they are hidden.
Widget annotations should be always drawn regardless of FPDF_ANNOT flag
since they need to be always displayed for PDF forms.
Also, roll DEPS for testing/corpus to 8485b30.
BUG=pdfium:594
Review-Url: https://codereview.chromium.org/2323203002
Diffstat (limited to 'core/fpdfdoc')
-rw-r--r-- | core/fpdfdoc/cpdf_annot.cpp | 25 | ||||
-rw-r--r-- | core/fpdfdoc/include/cpdf_annot.h | 1 |
2 files changed, 22 insertions, 4 deletions
diff --git a/core/fpdfdoc/cpdf_annot.cpp b/core/fpdfdoc/cpdf_annot.cpp index 4e0b04e9b6..0cc3596a4d 100644 --- a/core/fpdfdoc/cpdf_annot.cpp +++ b/core/fpdfdoc/cpdf_annot.cpp @@ -73,6 +73,16 @@ void CPDF_Annot::GenerateAPIfNeeded() { CPVT_GenerateAP::GenerateUnderlineAP(m_pDocument, m_pAnnotDict); } +bool CPDF_Annot::ShouldDrawAnnotation() { + if (IsAnnotationHidden(m_pAnnotDict)) + return false; + + if (m_nSubtype == CPDF_Annot::Subtype::POPUP && !m_bOpenState) + return false; + + return true; +} + void CPDF_Annot::ClearCachedAP() { m_APMap.clear(); } @@ -294,10 +304,7 @@ FX_BOOL CPDF_Annot::DrawAppearance(CPDF_Page* pPage, const CFX_Matrix* pUser2Device, AppearanceMode mode, const CPDF_RenderOptions* pOptions) { - if (IsAnnotationHidden(m_pAnnotDict)) - return FALSE; - - if (m_nSubtype == CPDF_Annot::Subtype::POPUP && !m_bOpenState) + if (!ShouldDrawAnnotation()) return FALSE; // It might happen that by the time this annotation instance was created, @@ -322,6 +329,16 @@ FX_BOOL CPDF_Annot::DrawInContext(const CPDF_Page* pPage, CPDF_RenderContext* pContext, const CFX_Matrix* pUser2Device, AppearanceMode mode) { + if (!ShouldDrawAnnotation()) + return FALSE; + + // It might happen that by the time this annotation instance was created, + // it was flagged as "hidden" (e.g. /F 2), and hence CPVT_GenerateAP decided + // to not "generate" its AP. + // If for a reason the object is no longer hidden, but still does not have + // its "AP" generated, generate it now. + GenerateAPIfNeeded(); + CFX_Matrix matrix; CPDF_Form* pForm = FPDFDOC_Annot_GetMatrix(pPage, this, mode, pUser2Device, matrix); diff --git a/core/fpdfdoc/include/cpdf_annot.h b/core/fpdfdoc/include/cpdf_annot.h index eb9f02a717..c16decc7d6 100644 --- a/core/fpdfdoc/include/cpdf_annot.h +++ b/core/fpdfdoc/include/cpdf_annot.h @@ -100,6 +100,7 @@ class CPDF_Annot { private: void GenerateAPIfNeeded(); + bool ShouldDrawAnnotation(); // For regular annotations, |m_pAnnotDict| is not owned. For // our artificially created popup annotations, |m_pAnnotDict| |