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

Side by Side Diff: fpdfsdk/src/javascript/Document.cpp

Issue 1700183002: Remove CFX_PtrList from renderer main loop. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Nits. Created 4 years, 10 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 unified diff | Download patch
« no previous file with comments | « fpdfsdk/src/fxedit/fxet_pageobjs.cpp ('k') | fpdfsdk/src/pdfwindow/PWL_Edit.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include "fpdfsdk/src/javascript/Document.h" 7 #include "fpdfsdk/src/javascript/Document.h"
8 8
9 #include "fpdfsdk/include/fsdk_mgr.h" // For CPDFDoc_Environment. 9 #include "fpdfsdk/include/fsdk_mgr.h" // For CPDFDoc_Environment.
10 #include "fpdfsdk/include/javascript/IJavaScript.h" 10 #include "fpdfsdk/include/javascript/IJavaScript.h"
(...skipping 1364 matching lines...) Expand 10 before | Expand all | Expand 10 after
1375 CPDF_Dictionary* pPageDict = pDocument->GetPage(nPageNo); 1375 CPDF_Dictionary* pPageDict = pDocument->GetPage(nPageNo);
1376 if (!pPageDict) 1376 if (!pPageDict)
1377 return FALSE; 1377 return FALSE;
1378 1378
1379 CPDF_Page page; 1379 CPDF_Page page;
1380 page.Load(pDocument, pPageDict); 1380 page.Load(pDocument, pPageDict);
1381 page.ParseContent(nullptr); 1381 page.ParseContent(nullptr);
1382 1382
1383 int nWords = 0; 1383 int nWords = 0;
1384 CFX_WideString swRet; 1384 CFX_WideString swRet;
1385 FX_POSITION pos = page.GetPageObjectList()->GetHeadPosition(); 1385 for (auto& pPageObj : *page.GetPageObjectList()) {
1386 while (pos) { 1386 if (pPageObj->m_Type == CPDF_PageObject::TEXT) {
1387 if (CPDF_PageObject* pPageObj = 1387 CPDF_TextObject* pTextObj = static_cast<CPDF_TextObject*>(pPageObj.get());
1388 page.GetPageObjectList()->GetNextObject(pos)) { 1388 int nObjWords = CountWords(pTextObj);
1389 if (pPageObj->m_Type == CPDF_PageObject::TEXT) { 1389 if (nWords + nObjWords >= nWordNo) {
1390 int nObjWords = CountWords((CPDF_TextObject*)pPageObj); 1390 swRet = GetObjWordStr(pTextObj, nWordNo - nWords);
1391 1391 break;
1392 if (nWords + nObjWords >= nWordNo) {
1393 swRet = GetObjWordStr((CPDF_TextObject*)pPageObj, nWordNo - nWords);
1394 break;
1395 }
1396
1397 nWords += nObjWords;
1398 } 1392 }
1393 nWords += nObjWords;
1399 } 1394 }
1400 } 1395 }
1401 1396
1402 if (bStrip) { 1397 if (bStrip) {
1403 swRet.TrimLeft(); 1398 swRet.TrimLeft();
1404 swRet.TrimRight(); 1399 swRet.TrimRight();
1405 } 1400 }
1406 1401
1407 vRet = swRet.c_str(); 1402 vRet = swRet.c_str();
1408 return TRUE; 1403 return TRUE;
(...skipping 26 matching lines...) Expand all
1435 1430
1436 CPDF_Dictionary* pPageDict = pDocument->GetPage(nPageNo); 1431 CPDF_Dictionary* pPageDict = pDocument->GetPage(nPageNo);
1437 if (!pPageDict) 1432 if (!pPageDict)
1438 return FALSE; 1433 return FALSE;
1439 1434
1440 CPDF_Page page; 1435 CPDF_Page page;
1441 page.Load(pDocument, pPageDict); 1436 page.Load(pDocument, pPageDict);
1442 page.ParseContent(nullptr); 1437 page.ParseContent(nullptr);
1443 1438
1444 int nWords = 0; 1439 int nWords = 0;
1445 FX_POSITION pos = page.GetPageObjectList()->GetHeadPosition(); 1440 for (auto& pPageObj : *page.GetPageObjectList()) {
1446 while (pos) { 1441 if (pPageObj->m_Type == CPDF_PageObject::TEXT)
1447 if (CPDF_PageObject* pPageObj = 1442 nWords += CountWords(static_cast<CPDF_TextObject*>(pPageObj.get()));
1448 page.GetPageObjectList()->GetNextObject(pos)) {
1449 if (pPageObj->m_Type == CPDF_PageObject::TEXT) {
1450 CPDF_TextObject* pTextObj = (CPDF_TextObject*)pPageObj;
1451 nWords += CountWords(pTextObj);
1452 }
1453 }
1454 } 1443 }
1455 1444
1456 vRet = nWords; 1445 vRet = nWords;
1457 return TRUE; 1446 return TRUE;
1458 } 1447 }
1459 1448
1460 FX_BOOL Document::getPrintParams(IJS_Context* cc, 1449 FX_BOOL Document::getPrintParams(IJS_Context* cc,
1461 const std::vector<CJS_Value>& params, 1450 const std::vector<CJS_Value>& params,
1462 CJS_Value& vRet, 1451 CJS_Value& vRet,
1463 CFX_WideString& sError) { 1452 CFX_WideString& sError) {
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
1635 CJS_DelayData* pData = DelayDataForFieldAndControlIndex.GetAt(i); 1624 CJS_DelayData* pData = DelayDataForFieldAndControlIndex.GetAt(i);
1636 Field::DoDelay(m_pDocument, pData); 1625 Field::DoDelay(m_pDocument, pData);
1637 DelayDataForFieldAndControlIndex.SetAt(i, NULL); 1626 DelayDataForFieldAndControlIndex.SetAt(i, NULL);
1638 delete pData; 1627 delete pData;
1639 } 1628 }
1640 } 1629 }
1641 1630
1642 CJS_Document* Document::GetCJSDoc() const { 1631 CJS_Document* Document::GetCJSDoc() const {
1643 return static_cast<CJS_Document*>(m_pJSObject); 1632 return static_cast<CJS_Document*>(m_pJSObject);
1644 } 1633 }
OLDNEW
« no previous file with comments | « fpdfsdk/src/fxedit/fxet_pageobjs.cpp ('k') | fpdfsdk/src/pdfwindow/PWL_Edit.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698