summaryrefslogtreecommitdiff
path: root/fpdfsdk/javascript
diff options
context:
space:
mode:
authortsepez <tsepez@chromium.org>2017-01-11 14:03:54 -0800
committerCommit bot <commit-bot@chromium.org>2017-01-11 14:03:54 -0800
commitd805eec52f6ac574918748c4270873e7e5cde596 (patch)
tree3dec3245638de8600bd9a213887be92cc53a1d76 /fpdfsdk/javascript
parent5e3121beff936df1b0af3749447eeda1666d5d76 (diff)
downloadpdfium-d805eec52f6ac574918748c4270873e7e5cde596.tar.xz
Use observed pointers in CPDFSDK_AnnotIterator.chromium/2979
Rename to CPDFSDK_AnnotIteration, as it is now an ordered set of annots, and not the iterator itself. Review-Url: https://codereview.chromium.org/2626073005
Diffstat (limited to 'fpdfsdk/javascript')
-rw-r--r--fpdfsdk/javascript/Document.cpp25
1 files changed, 11 insertions, 14 deletions
diff --git a/fpdfsdk/javascript/Document.cpp b/fpdfsdk/javascript/Document.cpp
index 7e4dc260f2..79d68ec3a7 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;
}