Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(689)

Unified Diff: core/fpdfdoc/cpdf_annot.cpp

Issue 2265313002: Lazy generate an "AP" when an Annot's hidden state changes (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Some minor clean ups. Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | core/fpdfdoc/include/cpdf_annot.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: core/fpdfdoc/cpdf_annot.cpp
diff --git a/core/fpdfdoc/cpdf_annot.cpp b/core/fpdfdoc/cpdf_annot.cpp
index df12e9a82ef7428c7800f109e41eb89b973bc68f..76d3f9c6d4855b08f2e109b307627b3b27a297aa 100644
--- a/core/fpdfdoc/cpdf_annot.cpp
+++ b/core/fpdfdoc/cpdf_annot.cpp
@@ -22,6 +22,14 @@ CPDF_Annot::CPDF_Annot(CPDF_Dictionary* pDict, CPDF_Document* pDocument)
: m_pAnnotDict(pDict),
m_pDocument(pDocument),
m_sSubtype(m_pAnnotDict->GetStringBy("Subtype")) {
+ GenerateAPIfNeeded();
+}
+
+CPDF_Annot::~CPDF_Annot() {
+ ClearCachedAP();
+}
+
+void CPDF_Annot::GenerateAPIfNeeded() {
if (m_sSubtype == "Circle")
CPVT_GenerateAP::GenerateCircleAP(m_pDocument, m_pAnnotDict);
else if (m_sSubtype == "Highlight")
@@ -40,10 +48,6 @@ CPDF_Annot::CPDF_Annot(CPDF_Dictionary* pDict, CPDF_Document* pDocument)
CPVT_GenerateAP::GenerateUnderlineAP(m_pDocument, m_pAnnotDict);
}
-CPDF_Annot::~CPDF_Annot() {
- ClearCachedAP();
-}
-
void CPDF_Annot::ClearCachedAP() {
m_APMap.clear();
}
@@ -149,6 +153,13 @@ FX_BOOL CPDF_Annot::DrawAppearance(CPDF_Page* pPage,
if (IsAnnotationHidden(m_pAnnotDict))
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);
« no previous file with comments | « no previous file | core/fpdfdoc/include/cpdf_annot.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698