From f0d9d28a034fe3650c3c2d662090c1e8687ddb16 Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Wed, 30 May 2018 16:40:00 +0000 Subject: Make CPDF_Document cache CPDF_Pages We cache pages not by page number, which can bounce around as pages are inserted or removed, but by page dictionary's object number. Since the page may be created under one function and used under another, we can't take the shortcut of not instantiating a render cache nor not parsing the page. Change-Id: I9a325cda8b3141153544ac53e78a51a44e6b411a Reviewed-on: https://pdfium-review.googlesource.com/32830 Commit-Queue: Tom Sepez Reviewed-by: dsinclair --- fxjs/cjs_document.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'fxjs') diff --git a/fxjs/cjs_document.cpp b/fxjs/cjs_document.cpp index 66577062a6..3a4ca2763f 100644 --- a/fxjs/cjs_document.cpp +++ b/fxjs/cjs_document.cpp @@ -1256,8 +1256,7 @@ CJS_Return CJS_Document::getPageNthWord( if (!pPageDict) return CJS_Return(false); - auto page = pdfium::MakeRetain(pDocument, pPageDict, true); - page->ParseContent(); + RetainPtr page = pDocument->GetOrCreatePDFPage(pPageDict); int nWords = 0; WideString swRet; @@ -1305,8 +1304,7 @@ CJS_Return CJS_Document::getPageNumWords( if (!pPageDict) return CJS_Return(false); - auto page = pdfium::MakeRetain(pDocument, pPageDict, true); - page->ParseContent(); + RetainPtr page = pDocument->GetOrCreatePDFPage(pPageDict); int nWords = 0; for (auto& pPageObj : *page->GetPageObjectList()) { -- cgit v1.2.3