Split off CPDF_Form::PareseContentForType3Char() from ParseContent().
-- Also add no-arg form of ParseContent() itself.
Change-Id: Ibd34f63ec1a9bfd95bc2b9a979047d4e1f2b0289
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/57850
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
diff --git a/core/fpdfapi/edit/cpdf_pagecontentgenerator_unittest.cpp b/core/fpdfapi/edit/cpdf_pagecontentgenerator_unittest.cpp
index 5473041..1518e2a 100644
--- a/core/fpdfapi/edit/cpdf_pagecontentgenerator_unittest.cpp
+++ b/core/fpdfapi/edit/cpdf_pagecontentgenerator_unittest.cpp
@@ -379,7 +379,7 @@
// Create an empty form.
auto pTestForm =
pdfium::MakeUnique<CPDF_Form>(pDoc.get(), nullptr, pStream.Get());
- pTestForm->ParseContent(nullptr, nullptr, nullptr, nullptr);
+ pTestForm->ParseContent();
ASSERT_EQ(CPDF_PageObjectHolder::ParseState::kParsed,
pTestForm->GetParseState());
@@ -408,7 +408,7 @@
// Create a form with a non-empty stream.
auto pTestForm =
pdfium::MakeUnique<CPDF_Form>(pDoc.get(), nullptr, pStream.Get());
- pTestForm->ParseContent(nullptr, nullptr, nullptr, nullptr);
+ pTestForm->ParseContent();
ASSERT_EQ(CPDF_PageObjectHolder::ParseState::kParsed,
pTestForm->GetParseState());
diff --git a/core/fpdfapi/font/cpdf_type3font.cpp b/core/fpdfapi/font/cpdf_type3font.cpp
index 97d473e..2c9d815 100644
--- a/core/fpdfapi/font/cpdf_type3font.cpp
+++ b/core/fpdfapi/font/cpdf_type3font.cpp
@@ -121,7 +121,7 @@
{
AutoRestorer<int> restorer(&m_CharLoadingDepth);
m_CharLoadingDepth++;
- pForm->ParseContent(nullptr, nullptr, pNewChar.get(), nullptr);
+ pForm->ParseContentForType3Char(pNewChar.get());
}
it = m_CacheMap.find(charcode);
if (it != m_CacheMap.end())
diff --git a/core/fpdfapi/page/cpdf_contentparser.cpp b/core/fpdfapi/page/cpdf_contentparser.cpp
index 1b313ca..70b9bd4 100644
--- a/core/fpdfapi/page/cpdf_contentparser.cpp
+++ b/core/fpdfapi/page/cpdf_contentparser.cpp
@@ -54,7 +54,7 @@
const CPDF_AllStates* pGraphicStates,
const CFX_Matrix* pParentMatrix,
CPDF_Type3Char* pType3Char,
- std::set<const uint8_t*>* parsedSet)
+ std::set<const uint8_t*>* pParsedSet)
: m_CurrentStage(Stage::kParse),
m_pObjectHolder(pForm),
m_pType3Char(pType3Char) {
@@ -84,7 +84,7 @@
m_pParser = pdfium::MakeUnique<CPDF_StreamContentParser>(
pForm->GetDocument(), pForm->m_pPageResources.Get(),
pForm->m_pResources.Get(), pParentMatrix, pForm, pResources, form_bbox,
- pGraphicStates, parsedSet);
+ pGraphicStates, pParsedSet);
m_pParser->GetCurStates()->m_CTM = form_matrix;
m_pParser->GetCurStates()->m_ParentMatrix = form_matrix;
if (ClipPath.HasRef()) {
@@ -184,12 +184,12 @@
CPDF_ContentParser::Stage CPDF_ContentParser::Parse() {
if (!m_pParser) {
- m_parsedSet = pdfium::MakeUnique<std::set<const uint8_t*>>();
+ m_pParsedSet = pdfium::MakeUnique<std::set<const uint8_t*>>();
m_pParser = pdfium::MakeUnique<CPDF_StreamContentParser>(
m_pObjectHolder->GetDocument(), m_pObjectHolder->m_pPageResources.Get(),
nullptr, nullptr, m_pObjectHolder.Get(),
m_pObjectHolder->m_pResources.Get(), m_pObjectHolder->GetBBox(),
- nullptr, m_parsedSet.get());
+ nullptr, m_pParsedSet.get());
m_pParser->GetCurStates()->m_ColorState.SetDefault();
}
if (m_CurrentOffset >= m_Size)
diff --git a/core/fpdfapi/page/cpdf_contentparser.h b/core/fpdfapi/page/cpdf_contentparser.h
index f87b015..8b83695 100644
--- a/core/fpdfapi/page/cpdf_contentparser.h
+++ b/core/fpdfapi/page/cpdf_contentparser.h
@@ -32,7 +32,7 @@
const CPDF_AllStates* pGraphicStates,
const CFX_Matrix* pParentMatrix,
CPDF_Type3Char* pType3Char,
- std::set<const uint8_t*>* parsedSet);
+ std::set<const uint8_t*>* pParsedSet);
~CPDF_ContentParser();
const CPDF_AllStates* GetCurStates() const {
@@ -71,9 +71,9 @@
uint32_t m_CurrentOffset = 0;
// Only used when parsing pages.
- std::unique_ptr<std::set<const uint8_t*>> m_parsedSet;
+ std::unique_ptr<std::set<const uint8_t*>> m_pParsedSet;
- // |m_pParser| has a reference to |m_parsedSet|, so must be below and thus
+ // |m_pParser| has a reference to |m_pParsedSet|, so must be below and thus
// destroyed first.
std::unique_ptr<CPDF_StreamContentParser> m_pParser;
};
diff --git a/core/fpdfapi/page/cpdf_form.cpp b/core/fpdfapi/page/cpdf_form.cpp
index 72c90a8..cef03d0 100644
--- a/core/fpdfapi/page/cpdf_form.cpp
+++ b/core/fpdfapi/page/cpdf_form.cpp
@@ -48,21 +48,35 @@
CPDF_Form::~CPDF_Form() = default;
+void CPDF_Form::ParseContent() {
+ ParseContentInternal(nullptr, nullptr, nullptr, nullptr);
+}
+
void CPDF_Form::ParseContent(const CPDF_AllStates* pGraphicStates,
const CFX_Matrix* pParentMatrix,
- CPDF_Type3Char* pType3Char,
- std::set<const uint8_t*>* parsedSet) {
+ std::set<const uint8_t*>* pParsedSet) {
+ ParseContentInternal(pGraphicStates, pParentMatrix, nullptr, pParsedSet);
+}
+
+void CPDF_Form::ParseContentForType3Char(CPDF_Type3Char* pType3Char) {
+ ParseContentInternal(nullptr, nullptr, pType3Char, nullptr);
+}
+
+void CPDF_Form::ParseContentInternal(const CPDF_AllStates* pGraphicStates,
+ const CFX_Matrix* pParentMatrix,
+ CPDF_Type3Char* pType3Char,
+ std::set<const uint8_t*>* pParsedSet) {
if (GetParseState() == ParseState::kParsed)
return;
if (GetParseState() == ParseState::kNotParsed) {
- if (!parsedSet) {
+ if (!pParsedSet) {
if (!m_ParsedSet)
m_ParsedSet = pdfium::MakeUnique<std::set<const uint8_t*>>();
- parsedSet = m_ParsedSet.get();
+ pParsedSet = m_ParsedSet.get();
}
StartParse(pdfium::MakeUnique<CPDF_ContentParser>(
- this, pGraphicStates, pParentMatrix, pType3Char, parsedSet));
+ this, pGraphicStates, pParentMatrix, pType3Char, pParsedSet));
}
ASSERT(GetParseState() == ParseState::kParsing);
diff --git a/core/fpdfapi/page/cpdf_form.h b/core/fpdfapi/page/cpdf_form.h
index 69bac7d..68f92d5 100644
--- a/core/fpdfapi/page/cpdf_form.h
+++ b/core/fpdfapi/page/cpdf_form.h
@@ -36,10 +36,11 @@
CPDF_Dictionary* pParentResources);
~CPDF_Form() override;
+ void ParseContent();
void ParseContent(const CPDF_AllStates* pGraphicStates,
const CFX_Matrix* pParentMatrix,
- CPDF_Type3Char* pType3Char,
- std::set<const uint8_t*>* parsedSet);
+ std::set<const uint8_t*>* pParsedSet);
+ void ParseContentForType3Char(CPDF_Type3Char* pType3Char);
CFX_FloatRect CalcBoundingBox() const;
const CPDF_Stream* GetStream() const;
@@ -48,6 +49,11 @@
const CPDF_ImageObject* GetSoleImageOfForm() const;
private:
+ void ParseContentInternal(const CPDF_AllStates* pGraphicStates,
+ const CFX_Matrix* pParentMatrix,
+ CPDF_Type3Char* pType3Char,
+ std::set<const uint8_t*>* pParsedSet);
+
std::unique_ptr<std::set<const uint8_t*>> m_ParsedSet;
RetainPtr<CPDF_Stream> const m_pFormStream;
};
diff --git a/core/fpdfapi/page/cpdf_streamcontentparser.cpp b/core/fpdfapi/page/cpdf_streamcontentparser.cpp
index 6eba6dd..c4021d8 100644
--- a/core/fpdfapi/page/cpdf_streamcontentparser.cpp
+++ b/core/fpdfapi/page/cpdf_streamcontentparser.cpp
@@ -256,7 +256,7 @@
CPDF_Dictionary* pResources,
const CFX_FloatRect& rcBBox,
const CPDF_AllStates* pStates,
- std::set<const uint8_t*>* parsedSet)
+ std::set<const uint8_t*>* pParsedSet)
: m_pDocument(pDocument),
m_pPageResources(pPageResources),
m_pParentResources(pParentResources),
@@ -264,7 +264,7 @@
pParentResources,
pPageResources)),
m_pObjectHolder(pObjHolder),
- m_ParsedSet(parsedSet),
+ m_ParsedSet(pParsedSet),
m_BBox(rcBBox),
m_ParamStartPos(0),
m_ParamCount(0),
@@ -784,7 +784,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->ParseContent(&status, nullptr, nullptr, m_ParsedSet.Get());
+ form->ParseContent(&status, nullptr, m_ParsedSet.Get());
CFX_Matrix matrix = m_pCurStates->m_CTM * m_mtContentToUser;
diff --git a/core/fpdfapi/page/cpdf_streamcontentparser.h b/core/fpdfapi/page/cpdf_streamcontentparser.h
index 6e4b46f..a20dbe1 100644
--- a/core/fpdfapi/page/cpdf_streamcontentparser.h
+++ b/core/fpdfapi/page/cpdf_streamcontentparser.h
@@ -44,7 +44,7 @@
CPDF_Dictionary* pResources,
const CFX_FloatRect& rcBBox,
const CPDF_AllStates* pStates,
- std::set<const uint8_t*>* parsedSet);
+ std::set<const uint8_t*>* pParsedSet);
~CPDF_StreamContentParser();
uint32_t Parse(const uint8_t* pData,
diff --git a/core/fpdfapi/page/cpdf_tilingpattern.cpp b/core/fpdfapi/page/cpdf_tilingpattern.cpp
index eca6478d..46a59db 100644
--- a/core/fpdfapi/page/cpdf_tilingpattern.cpp
+++ b/core/fpdfapi/page/cpdf_tilingpattern.cpp
@@ -47,7 +47,7 @@
allStates.m_GraphState.Emplace();
allStates.m_TextState.Emplace();
allStates.m_GeneralState = pPageObj->m_GeneralState;
- form->ParseContent(&allStates, &matrix, nullptr, nullptr);
+ form->ParseContent(&allStates, &matrix, nullptr);
m_BBox = pDict->GetRectFor("BBox");
return form;
}
diff --git a/core/fpdfapi/render/cpdf_renderstatus.cpp b/core/fpdfapi/render/cpdf_renderstatus.cpp
index ec3af9e..b32c995 100644
--- a/core/fpdfapi/render/cpdf_renderstatus.cpp
+++ b/core/fpdfapi/render/cpdf_renderstatus.cpp
@@ -2530,7 +2530,7 @@
CPDF_Form form(m_pContext->GetDocument(), m_pContext->GetPageResources(),
pGroup);
- form.ParseContent(nullptr, nullptr, nullptr, nullptr);
+ form.ParseContent();
CFX_DefaultRenderDevice bitmap_device;
bool bLuminosity =
diff --git a/core/fpdfdoc/cpdf_annot.cpp b/core/fpdfdoc/cpdf_annot.cpp
index b74d699..6d542ee 100644
--- a/core/fpdfdoc/cpdf_annot.cpp
+++ b/core/fpdfdoc/cpdf_annot.cpp
@@ -199,7 +199,7 @@
auto pNewForm = pdfium::MakeUnique<CPDF_Form>(
m_pDocument.Get(), pPage->m_pResources.Get(), pStream);
- pNewForm->ParseContent(nullptr, nullptr, nullptr, nullptr);
+ pNewForm->ParseContent();
CPDF_Form* pResult = pNewForm.get();
m_APMap[pStream] = std::move(pNewForm);
diff --git a/fpdfsdk/cpdf_annotcontext.cpp b/fpdfsdk/cpdf_annotcontext.cpp
index 0beebe1..f363ef2 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(nullptr, nullptr, nullptr, nullptr);
+ m_pAnnotForm->ParseContent();
}