summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordsinclair <dsinclair@chromium.org>2016-08-16 11:43:23 -0700
committerCommit bot <commit-bot@chromium.org>2016-08-16 11:43:24 -0700
commitf85e7e2ea29179dfe4ddc25ab410f8898391999c (patch)
treed32f70e74fd0f39aa5b1051d0e7366fb586d2d06
parent4540fbaa718b0b06e076321e0e1a61e80a161499 (diff)
downloadpdfium-f85e7e2ea29179dfe4ddc25ab410f8898391999c.tar.xz
Rename async to linearized when parsing
The parser and document refer to async loading and parsing. The code isn't actually async but loading a linearized PDF. This Cl renames the methods to clarify what the code is doing. The LoadDoc() and LoadLinearizedDoc() methods have been refactored to share a common LoadDocInternal() method. Review-Url: https://codereview.chromium.org/2250163002
-rw-r--r--core/fpdfapi/fpdf_parser/cpdf_document.cpp46
-rw-r--r--core/fpdfapi/fpdf_parser/cpdf_parser.cpp6
-rw-r--r--core/fpdfapi/fpdf_parser/include/cpdf_document.h5
-rw-r--r--core/fpdfapi/fpdf_parser/include/cpdf_parser.h4
-rw-r--r--fpdfsdk/fpdf_dataavail.cpp2
5 files changed, 29 insertions, 34 deletions
diff --git a/core/fpdfapi/fpdf_parser/cpdf_document.cpp b/core/fpdfapi/fpdf_parser/cpdf_document.cpp
index 7f69295675..bf1f93f887 100644
--- a/core/fpdfapi/fpdf_parser/cpdf_document.cpp
+++ b/core/fpdfapi/fpdf_parser/cpdf_document.cpp
@@ -496,54 +496,46 @@ CPDF_Document::~CPDF_Document() {
CPDF_ModuleMgr::Get()->GetPageModule()->ClearStockFont(this);
}
-void CPDF_Document::LoadDoc() {
+void CPDF_Document::LoadDocInternal() {
m_LastObjNum = m_pParser->GetLastObjNum();
+
CPDF_Object* pRootObj = GetIndirectObject(m_pParser->GetRootObjNum());
- if (!pRootObj) {
+ if (!pRootObj)
return;
- }
+
m_pRootDict = pRootObj->GetDict();
- if (!m_pRootDict) {
+ if (!m_pRootDict)
return;
- }
+
CPDF_Object* pInfoObj = GetIndirectObject(m_pParser->GetInfoObjNum());
- if (pInfoObj) {
+ if (pInfoObj)
m_pInfoDict = pInfoObj->GetDict();
- }
- CPDF_Array* pIDArray = m_pParser->GetIDArray();
- if (pIDArray) {
+ if (CPDF_Array* pIDArray = m_pParser->GetIDArray()) {
m_ID1 = pIDArray->GetStringAt(0);
m_ID2 = pIDArray->GetStringAt(1);
}
+}
+
+void CPDF_Document::LoadDoc() {
+ LoadDocInternal();
m_PageList.SetSize(RetrievePageCount());
}
-void CPDF_Document::LoadAsynDoc(CPDF_Dictionary* pLinearized) {
+void CPDF_Document::LoadLinearizedDoc(CPDF_Dictionary* pLinearizationParams) {
m_bLinearized = true;
- m_LastObjNum = m_pParser->GetLastObjNum();
- CPDF_Object* pIndirectObj = GetIndirectObject(m_pParser->GetRootObjNum());
- m_pRootDict = pIndirectObj ? pIndirectObj->GetDict() : nullptr;
- if (!m_pRootDict) {
- return;
- }
- pIndirectObj = GetIndirectObject(m_pParser->GetInfoObjNum());
- m_pInfoDict = pIndirectObj ? pIndirectObj->GetDict() : nullptr;
- CPDF_Array* pIDArray = m_pParser->GetIDArray();
- if (pIDArray) {
- m_ID1 = pIDArray->GetStringAt(0);
- m_ID2 = pIDArray->GetStringAt(1);
- }
+ LoadDocInternal();
+
uint32_t dwPageCount = 0;
- CPDF_Object* pCount = pLinearized->GetObjectBy("N");
+ CPDF_Object* pCount = pLinearizationParams->GetObjectBy("N");
if (ToNumber(pCount))
dwPageCount = pCount->GetInteger();
-
m_PageList.SetSize(dwPageCount);
- CPDF_Object* pNo = pLinearized->GetObjectBy("P");
+
+ CPDF_Object* pNo = pLinearizationParams->GetObjectBy("P");
if (ToNumber(pNo))
m_iFirstPageNo = pNo->GetInteger();
- CPDF_Object* pObjNum = pLinearized->GetObjectBy("O");
+ CPDF_Object* pObjNum = pLinearizationParams->GetObjectBy("O");
if (ToNumber(pObjNum))
m_dwFirstPageObjNum = pObjNum->GetInteger();
}
diff --git a/core/fpdfapi/fpdf_parser/cpdf_parser.cpp b/core/fpdfapi/fpdf_parser/cpdf_parser.cpp
index 7bcbf392d6..b2f1a4be3f 100644
--- a/core/fpdfapi/fpdf_parser/cpdf_parser.cpp
+++ b/core/fpdfapi/fpdf_parser/cpdf_parser.cpp
@@ -1545,7 +1545,7 @@ FX_BOOL CPDF_Parser::IsLinearizedFile(IFX_FileRead* pFileAccess,
return FALSE;
}
-CPDF_Parser::Error CPDF_Parser::StartAsyncParse(
+CPDF_Parser::Error CPDF_Parser::StartLinearizedParse(
IFX_FileRead* pFileAccess,
std::unique_ptr<CPDF_Document> pDocument) {
CloseParser();
@@ -1589,7 +1589,7 @@ CPDF_Parser::Error CPDF_Parser::StartAsyncParse(
if (eRet != SUCCESS)
return eRet;
- m_pDocument->LoadAsynDoc(m_pLinearized->GetDict());
+ m_pDocument->LoadLinearizedDoc(m_pLinearized->GetDict());
if (!m_pDocument->GetRoot() || m_pDocument->GetPageCount() == 0) {
if (bXRefRebuilt)
return FORMAT_ERROR;
@@ -1602,7 +1602,7 @@ CPDF_Parser::Error CPDF_Parser::StartAsyncParse(
if (eRet != SUCCESS)
return eRet;
- m_pDocument->LoadAsynDoc(m_pLinearized->GetDict());
+ m_pDocument->LoadLinearizedDoc(m_pLinearized->GetDict());
if (!m_pDocument->GetRoot())
return FORMAT_ERROR;
}
diff --git a/core/fpdfapi/fpdf_parser/include/cpdf_document.h b/core/fpdfapi/fpdf_parser/include/cpdf_document.h
index 3cece1c0a8..4a12ea97dc 100644
--- a/core/fpdfapi/fpdf_parser/include/cpdf_document.h
+++ b/core/fpdfapi/fpdf_parser/include/cpdf_document.h
@@ -84,7 +84,7 @@ class CPDF_Document : public CPDF_IndirectObjectHolder {
CPDF_IccProfile* LoadIccProfile(CPDF_Stream* pStream);
void LoadDoc();
- void LoadAsynDoc(CPDF_Dictionary* pLinearized);
+ void LoadLinearizedDoc(CPDF_Dictionary* pLinearizationParams);
void LoadPages();
// Editing methods.
@@ -139,6 +139,9 @@ class CPDF_Document : public CPDF_IndirectObjectHolder {
std::unique_ptr<CPDF_DocRenderData> m_pDocRender;
std::unique_ptr<JBig2_DocumentContext> m_pCodecContext;
std::unique_ptr<CPDF_LinkList> m_pLinksContext;
+
+ private:
+ void LoadDocInternal();
};
#endif // CORE_FPDFAPI_FPDF_PARSER_INCLUDE_CPDF_DOCUMENT_H_
diff --git a/core/fpdfapi/fpdf_parser/include/cpdf_parser.h b/core/fpdfapi/fpdf_parser/include/cpdf_parser.h
index 3ad3b867df..29807b9060 100644
--- a/core/fpdfapi/fpdf_parser/include/cpdf_parser.h
+++ b/core/fpdfapi/fpdf_parser/include/cpdf_parser.h
@@ -40,8 +40,8 @@ class CPDF_Parser {
Error StartParse(IFX_FileRead* pFile,
std::unique_ptr<CPDF_Document> pDocument);
- Error StartAsyncParse(IFX_FileRead* pFile,
- std::unique_ptr<CPDF_Document> pDocument);
+ Error StartLinearizedParse(IFX_FileRead* pFile,
+ std::unique_ptr<CPDF_Document> pDocument);
void SetPassword(const FX_CHAR* password) { m_Password = password; }
CFX_ByteString GetPassword() { return m_Password; }
diff --git a/fpdfsdk/fpdf_dataavail.cpp b/fpdfsdk/fpdf_dataavail.cpp
index 3cc7fc0347..5dd42402ed 100644
--- a/fpdfsdk/fpdf_dataavail.cpp
+++ b/fpdfsdk/fpdf_dataavail.cpp
@@ -140,7 +140,7 @@ FPDFAvail_GetDocument(FPDF_AVAIL avail, FPDF_BYTESTRING password) {
pParser->SetPassword(password);
std::unique_ptr<CPDF_Document> pDocument(new CPDF_Document(pParser.get()));
- CPDF_Parser::Error error = pParser->StartAsyncParse(
+ CPDF_Parser::Error error = pParser->StartLinearizedParse(
pDataAvail->m_pDataAvail->GetFileRead(), std::move(pDocument));
if (error != CPDF_Parser::SUCCESS) {
ProcessParseError(error);