summaryrefslogtreecommitdiff
path: root/fpdfsdk/src/javascript/Document.cpp
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2016-02-17 16:46:26 -0800
committerTom Sepez <tsepez@chromium.org>2016-02-17 16:46:26 -0800
commit2398d8938277a2492b411f8f807bf1935918ccae (patch)
tree0f8c13509e23d6a0ea80d461ab803fae62a4638f /fpdfsdk/src/javascript/Document.cpp
parentefbc1912f10f5a53e7df3a24ebfd6b78412f0bba (diff)
downloadpdfium-2398d8938277a2492b411f8f807bf1935918ccae.tar.xz
Remove CFX_PtrList from renderer main loop.
Exposes an iterator over the object list, but not the object holder, since pages and forms inherit from object holder, and we don't want to imply that there's only one thing that might be iterated over for those classes. R=thestig@chromium.org Review URL: https://codereview.chromium.org/1700183002 .
Diffstat (limited to 'fpdfsdk/src/javascript/Document.cpp')
-rw-r--r--fpdfsdk/src/javascript/Document.cpp33
1 files changed, 11 insertions, 22 deletions
diff --git a/fpdfsdk/src/javascript/Document.cpp b/fpdfsdk/src/javascript/Document.cpp
index c2638d012d..733384a154 100644
--- a/fpdfsdk/src/javascript/Document.cpp
+++ b/fpdfsdk/src/javascript/Document.cpp
@@ -1382,20 +1382,15 @@ FX_BOOL Document::getPageNthWord(IJS_Context* cc,
int nWords = 0;
CFX_WideString swRet;
- FX_POSITION pos = page.GetPageObjectList()->GetHeadPosition();
- while (pos) {
- if (CPDF_PageObject* pPageObj =
- page.GetPageObjectList()->GetNextObject(pos)) {
- if (pPageObj->m_Type == CPDF_PageObject::TEXT) {
- int nObjWords = CountWords((CPDF_TextObject*)pPageObj);
-
- if (nWords + nObjWords >= nWordNo) {
- swRet = GetObjWordStr((CPDF_TextObject*)pPageObj, nWordNo - nWords);
- break;
- }
-
- nWords += nObjWords;
+ for (auto& pPageObj : *page.GetPageObjectList()) {
+ if (pPageObj->m_Type == CPDF_PageObject::TEXT) {
+ CPDF_TextObject* pTextObj = static_cast<CPDF_TextObject*>(pPageObj.get());
+ int nObjWords = CountWords(pTextObj);
+ if (nWords + nObjWords >= nWordNo) {
+ swRet = GetObjWordStr(pTextObj, nWordNo - nWords);
+ break;
}
+ nWords += nObjWords;
}
}
@@ -1442,15 +1437,9 @@ FX_BOOL Document::getPageNumWords(IJS_Context* cc,
page.ParseContent(nullptr);
int nWords = 0;
- FX_POSITION pos = page.GetPageObjectList()->GetHeadPosition();
- while (pos) {
- if (CPDF_PageObject* pPageObj =
- page.GetPageObjectList()->GetNextObject(pos)) {
- if (pPageObj->m_Type == CPDF_PageObject::TEXT) {
- CPDF_TextObject* pTextObj = (CPDF_TextObject*)pPageObj;
- nWords += CountWords(pTextObj);
- }
- }
+ for (auto& pPageObj : *page.GetPageObjectList()) {
+ if (pPageObj->m_Type == CPDF_PageObject::TEXT)
+ nWords += CountWords(static_cast<CPDF_TextObject*>(pPageObj.get()));
}
vRet = nWords;