Cleanup CPDF_Form parsing code
This CL folds the StartParse() method of CPDF_Form into the
ParserContent method. The no arguments ParseContent is removed and
ParseContentWithParams renamed to ParseContent. The callsites are
updated to pass the nullptr's.
Bug: chromium:813349
Change-Id: I304b77aef1de1b9aa20e4a3044db5023f5701584
Reviewed-on: https://pdfium-review.googlesource.com/32511
Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
Commit-Queue: dsinclair <dsinclair@chromium.org>
diff --git a/core/fpdfapi/edit/cpdf_pagecontentgenerator_unittest.cpp b/core/fpdfapi/edit/cpdf_pagecontentgenerator_unittest.cpp
index e9b3d15..d97e8ab 100644
--- a/core/fpdfapi/edit/cpdf_pagecontentgenerator_unittest.cpp
+++ b/core/fpdfapi/edit/cpdf_pagecontentgenerator_unittest.cpp
@@ -298,7 +298,7 @@
// Create an empty form.
auto pTestForm =
pdfium::MakeUnique<CPDF_Form>(pDoc.get(), nullptr, pStream.get());
- pTestForm->ParseContent();
+ pTestForm->ParseContent(nullptr, nullptr, nullptr, nullptr);
ASSERT_TRUE(pTestForm->IsParsed());
// The generated stream for the empty form should be an empty string.
@@ -324,7 +324,7 @@
// Create a form with a non-empty stream.
auto pTestForm =
pdfium::MakeUnique<CPDF_Form>(pDoc.get(), nullptr, pStream.get());
- pTestForm->ParseContent();
+ pTestForm->ParseContent(nullptr, nullptr, nullptr, nullptr);
ASSERT_TRUE(pTestForm->IsParsed());
CPDF_PageContentGenerator generator(pTestForm.get());
diff --git a/core/fpdfapi/font/cpdf_type3font.cpp b/core/fpdfapi/font/cpdf_type3font.cpp
index 824d6f4..c321f87 100644
--- a/core/fpdfapi/font/cpdf_type3font.cpp
+++ b/core/fpdfapi/font/cpdf_type3font.cpp
@@ -115,8 +115,7 @@
// can change as a result. Thus after it returns, check the cache again for
// a cache hit.
m_CharLoadingDepth++;
- pNewChar->form()->ParseContentWithParams(nullptr, nullptr, pNewChar.get(),
- nullptr);
+ pNewChar->form()->ParseContent(nullptr, nullptr, pNewChar.get(), nullptr);
m_CharLoadingDepth--;
it = m_CacheMap.find(charcode);
if (it != m_CacheMap.end())
diff --git a/core/fpdfapi/page/cpdf_form.cpp b/core/fpdfapi/page/cpdf_form.cpp
index 3abeff4..a63d3ce 100644
--- a/core/fpdfapi/page/cpdf_form.cpp
+++ b/core/fpdfapi/page/cpdf_form.cpp
@@ -29,12 +29,12 @@
LoadTransInfo();
}
-CPDF_Form::~CPDF_Form() {}
+CPDF_Form::~CPDF_Form() = default;
-void CPDF_Form::StartParse(CPDF_AllStates* pGraphicStates,
- const CFX_Matrix* pParentMatrix,
- CPDF_Type3Char* pType3Char,
- std::set<const uint8_t*>* parsedSet) {
+void CPDF_Form::ParseContent(CPDF_AllStates* pGraphicStates,
+ const CFX_Matrix* pParentMatrix,
+ CPDF_Type3Char* pType3Char,
+ std::set<const uint8_t*>* parsedSet) {
if (m_ParseState == CONTENT_PARSED || m_ParseState == CONTENT_PARSING)
return;
@@ -47,16 +47,6 @@
m_pParser = pdfium::MakeUnique<CPDF_ContentParser>(
this, pGraphicStates, pParentMatrix, pType3Char, parsedSet);
m_ParseState = CONTENT_PARSING;
-}
-void CPDF_Form::ParseContent() {
- ParseContentWithParams(nullptr, nullptr, nullptr, nullptr);
-}
-
-void CPDF_Form::ParseContentWithParams(CPDF_AllStates* pGraphicStates,
- const CFX_Matrix* pParentMatrix,
- CPDF_Type3Char* pType3Char,
- std::set<const uint8_t*>* parsedSet) {
- StartParse(pGraphicStates, pParentMatrix, pType3Char, parsedSet);
ContinueParse(nullptr);
}
diff --git a/core/fpdfapi/page/cpdf_form.h b/core/fpdfapi/page/cpdf_form.h
index c5285a1..9f2987d 100644
--- a/core/fpdfapi/page/cpdf_form.h
+++ b/core/fpdfapi/page/cpdf_form.h
@@ -27,18 +27,12 @@
CPDF_Dictionary* pParentResources = nullptr);
~CPDF_Form() override;
- void ParseContent();
- void ParseContentWithParams(CPDF_AllStates* pGraphicStates,
- const CFX_Matrix* pParentMatrix,
- CPDF_Type3Char* pType3Char,
- std::set<const uint8_t*>* parsedSet);
+ void ParseContent(CPDF_AllStates* pGraphicStates,
+ const CFX_Matrix* pParentMatrix,
+ CPDF_Type3Char* pType3Char,
+ std::set<const uint8_t*>* parsedSet);
private:
- void StartParse(CPDF_AllStates* pGraphicStates,
- const CFX_Matrix* pParentMatrix,
- CPDF_Type3Char* pType3Char,
- std::set<const uint8_t*>* parsedSet);
-
std::unique_ptr<std::set<const uint8_t*>> m_ParsedSet;
};
diff --git a/core/fpdfapi/page/cpdf_pageobjectholder.cpp b/core/fpdfapi/page/cpdf_pageobjectholder.cpp
index 1d39802..87a1aeb 100644
--- a/core/fpdfapi/page/cpdf_pageobjectholder.cpp
+++ b/core/fpdfapi/page/cpdf_pageobjectholder.cpp
@@ -40,6 +40,7 @@
m_ParseState = CONTENT_PARSED;
if (m_pParser->GetCurStates())
m_LastCTM = m_pParser->GetCurStates()->m_CTM;
+
m_pParser.reset();
}
diff --git a/core/fpdfapi/page/cpdf_streamcontentparser.cpp b/core/fpdfapi/page/cpdf_streamcontentparser.cpp
index df69aa4..5f4bdf7 100644
--- a/core/fpdfapi/page/cpdf_streamcontentparser.cpp
+++ b/core/fpdfapi/page/cpdf_streamcontentparser.cpp
@@ -781,7 +781,7 @@
status.m_TextState = m_pCurStates->m_TextState;
auto form = pdfium::MakeUnique<CPDF_Form>(
m_pDocument.Get(), m_pPageResources.Get(), pStream, m_pResources.Get());
- form->ParseContentWithParams(&status, nullptr, nullptr, m_ParsedSet.Get());
+ form->ParseContent(&status, nullptr, nullptr, m_ParsedSet.Get());
CFX_Matrix matrix = m_pCurStates->m_CTM;
matrix.Concat(m_mtContentToUser);
diff --git a/core/fpdfapi/page/cpdf_tilingpattern.cpp b/core/fpdfapi/page/cpdf_tilingpattern.cpp
index 02127b6..5a71baa 100644
--- a/core/fpdfapi/page/cpdf_tilingpattern.cpp
+++ b/core/fpdfapi/page/cpdf_tilingpattern.cpp
@@ -49,7 +49,7 @@
const CFX_Matrix& matrix = parent_matrix();
m_pForm = pdfium::MakeUnique<CPDF_Form>(document(), nullptr, pStream);
- m_pForm->ParseContentWithParams(nullptr, &matrix, nullptr, nullptr);
+ m_pForm->ParseContent(nullptr, &matrix, nullptr, nullptr);
m_BBox = pDict->GetRectFor("BBox");
return true;
}
diff --git a/core/fpdfapi/render/cpdf_renderstatus.cpp b/core/fpdfapi/render/cpdf_renderstatus.cpp
index 6752fd1..f33b304 100644
--- a/core/fpdfapi/render/cpdf_renderstatus.cpp
+++ b/core/fpdfapi/render/cpdf_renderstatus.cpp
@@ -2546,7 +2546,7 @@
CPDF_Form form(m_pContext->GetDocument(), m_pContext->GetPageResources(),
pGroup);
- form.ParseContent();
+ form.ParseContent(nullptr, nullptr, nullptr, nullptr);
CFX_DefaultRenderDevice bitmap_device;
bool bLuminosity =
diff --git a/core/fpdfdoc/cpdf_annot.cpp b/core/fpdfdoc/cpdf_annot.cpp
index 3b84baf..dc2e8ac 100644
--- a/core/fpdfdoc/cpdf_annot.cpp
+++ b/core/fpdfdoc/cpdf_annot.cpp
@@ -198,7 +198,7 @@
auto pNewForm = pdfium::MakeUnique<CPDF_Form>(
m_pDocument.Get(), pPage->m_pResources.Get(), pStream);
- pNewForm->ParseContent();
+ pNewForm->ParseContent(nullptr, nullptr, nullptr, nullptr);
CPDF_Form* pResult = pNewForm.get();
m_APMap[pStream] = std::move(pNewForm);
diff --git a/core/fpdfdoc/cpdf_formcontrol.cpp b/core/fpdfdoc/cpdf_formcontrol.cpp
index a78a24d..2100d4e 100644
--- a/core/fpdfdoc/cpdf_formcontrol.cpp
+++ b/core/fpdfdoc/cpdf_formcontrol.cpp
@@ -180,7 +180,7 @@
matrix.Concat(*pMatrix);
CPDF_Form form(m_pField->GetForm()->GetDocument(),
m_pField->GetForm()->GetFormDict()->GetDictFor("DR"), pStream);
- form.ParseContent();
+ form.ParseContent(nullptr, nullptr, nullptr, nullptr);
CPDF_RenderContext context(pPage);
context.AppendLayer(&form, &matrix);
context.Render(pDevice, pOptions, nullptr);
diff --git a/fpdfsdk/cpdf_annotcontext.cpp b/fpdfsdk/cpdf_annotcontext.cpp
index 20c5fc3..4e01ed6 100644
--- a/fpdfsdk/cpdf_annotcontext.cpp
+++ b/fpdfsdk/cpdf_annotcontext.cpp
@@ -31,5 +31,5 @@
m_pAnnotForm = pdfium::MakeUnique<CPDF_Form>(
m_pPage->GetDocument(), m_pPage->m_pResources.Get(), pStream);
- m_pAnnotForm->ParseContent();
+ m_pAnnotForm->ParseContent(nullptr, nullptr, nullptr, nullptr);
}