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

Unified Diff: fpdfsdk/javascript/Document.cpp

Issue 2626073005: Use observed pointers in CPDFSDK_AnnotIterator. (Closed)
Patch Set: remove local Created 3 years, 11 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 | « fpdfsdk/cpdfsdk_pageview.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: fpdfsdk/javascript/Document.cpp
diff --git a/fpdfsdk/javascript/Document.cpp b/fpdfsdk/javascript/Document.cpp
index 7e4dc260f2b4e130f6a12a8345a209164cb02279..79d68ec3a78e3772373f369a72faebe9634b4723 100644
--- a/fpdfsdk/javascript/Document.cpp
+++ b/fpdfsdk/javascript/Document.cpp
@@ -17,7 +17,7 @@
#include "core/fpdfapi/parser/fpdf_parser_decode.h"
#include "core/fpdfdoc/cpdf_interform.h"
#include "core/fpdfdoc/cpdf_nametree.h"
-#include "fpdfsdk/cpdfsdk_annotiterator.h"
+#include "fpdfsdk/cpdfsdk_annotiteration.h"
#include "fpdfsdk/cpdfsdk_formfillenvironment.h"
#include "fpdfsdk/cpdfsdk_interform.h"
#include "fpdfsdk/cpdfsdk_pageview.h"
@@ -1112,16 +1112,16 @@ bool Document::getAnnot(IJS_Context* cc,
if (!pPageView)
return false;
- CPDFSDK_AnnotIterator annotIterator(pPageView, false);
+ CPDFSDK_AnnotIteration annotIteration(pPageView, false);
CPDFSDK_BAAnnot* pSDKBAAnnot = nullptr;
- while (CPDFSDK_Annot* pSDKAnnotCur = annotIterator.Next()) {
- CPDFSDK_BAAnnot* pBAAnnot = static_cast<CPDFSDK_BAAnnot*>(pSDKAnnotCur);
+ for (const auto& pSDKAnnotCur : annotIteration) {
+ CPDFSDK_BAAnnot* pBAAnnot =
+ static_cast<CPDFSDK_BAAnnot*>(pSDKAnnotCur.Get());
if (pBAAnnot && pBAAnnot->GetAnnotName() == swAnnotName) {
pSDKBAAnnot = pBAAnnot;
break;
}
}
-
if (!pSDKBAAnnot)
return false;
@@ -1140,7 +1140,6 @@ bool Document::getAnnot(IJS_Context* cc,
return false;
pAnnot->SetSDKAnnot(pSDKBAAnnot);
-
vRet = CJS_Value(pRuntime, pJS_Annot);
return true;
}
@@ -1167,13 +1166,12 @@ bool Document::getAnnots(IJS_Context* cc,
if (!pPageView)
return false;
- CPDFSDK_AnnotIterator annotIterator(pPageView, false);
- while (CPDFSDK_Annot* pSDKAnnotCur = annotIterator.Next()) {
- CPDFSDK_BAAnnot* pSDKBAAnnot =
- static_cast<CPDFSDK_BAAnnot*>(pSDKAnnotCur);
- if (!pSDKBAAnnot)
+ CPDFSDK_AnnotIteration annotIteration(pPageView, false);
+ for (const auto& pSDKAnnotCur : annotIteration) {
+ if (!pSDKAnnotCur) {
+ sError = JSGetStringFromID(IDS_STRING_JSBADOBJECT);
return false;
-
+ }
v8::Local<v8::Object> pObj =
pRuntime->NewFxDynamicObj(CJS_Annot::g_nObjDefnID);
if (pObj.IsEmpty())
@@ -1188,11 +1186,10 @@ bool Document::getAnnots(IJS_Context* cc,
if (!pAnnot)
return false;
- pAnnot->SetSDKAnnot(pSDKBAAnnot);
+ pAnnot->SetSDKAnnot(static_cast<CPDFSDK_BAAnnot*>(pSDKAnnotCur.Get()));
annots.SetElement(pRuntime, i, CJS_Value(pRuntime, pJS_Annot));
}
}
-
vRet = CJS_Value(pRuntime, annots);
return true;
}
« no previous file with comments | « fpdfsdk/cpdfsdk_pageview.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698