From a7ff4dc7c27c7940daec9cf740f4b7e7638a45ec Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Mon, 14 May 2018 20:13:40 +0000 Subject: 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 Commit-Queue: dsinclair --- core/fpdfapi/page/cpdf_form.cpp | 20 +++++--------------- core/fpdfapi/page/cpdf_form.h | 14 ++++---------- core/fpdfapi/page/cpdf_pageobjectholder.cpp | 1 + core/fpdfapi/page/cpdf_streamcontentparser.cpp | 2 +- core/fpdfapi/page/cpdf_tilingpattern.cpp | 2 +- 5 files changed, 12 insertions(+), 27 deletions(-) (limited to 'core/fpdfapi/page') diff --git a/core/fpdfapi/page/cpdf_form.cpp b/core/fpdfapi/page/cpdf_form.cpp index 3abeff4829..a63d3ce96d 100644 --- a/core/fpdfapi/page/cpdf_form.cpp +++ b/core/fpdfapi/page/cpdf_form.cpp @@ -29,12 +29,12 @@ CPDF_Form::CPDF_Form(CPDF_Document* pDoc, 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* parsedSet) { +void CPDF_Form::ParseContent(CPDF_AllStates* pGraphicStates, + const CFX_Matrix* pParentMatrix, + CPDF_Type3Char* pType3Char, + std::set* parsedSet) { if (m_ParseState == CONTENT_PARSED || m_ParseState == CONTENT_PARSING) return; @@ -47,16 +47,6 @@ void CPDF_Form::StartParse(CPDF_AllStates* pGraphicStates, m_pParser = pdfium::MakeUnique( 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* 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 c5285a1d01..9f2987ddb6 100644 --- a/core/fpdfapi/page/cpdf_form.h +++ b/core/fpdfapi/page/cpdf_form.h @@ -27,18 +27,12 @@ class CPDF_Form : public CPDF_PageObjectHolder { CPDF_Dictionary* pParentResources = nullptr); ~CPDF_Form() override; - void ParseContent(); - void ParseContentWithParams(CPDF_AllStates* pGraphicStates, - const CFX_Matrix* pParentMatrix, - CPDF_Type3Char* pType3Char, - std::set* parsedSet); + void ParseContent(CPDF_AllStates* pGraphicStates, + const CFX_Matrix* pParentMatrix, + CPDF_Type3Char* pType3Char, + std::set* parsedSet); private: - void StartParse(CPDF_AllStates* pGraphicStates, - const CFX_Matrix* pParentMatrix, - CPDF_Type3Char* pType3Char, - std::set* parsedSet); - std::unique_ptr> m_ParsedSet; }; diff --git a/core/fpdfapi/page/cpdf_pageobjectholder.cpp b/core/fpdfapi/page/cpdf_pageobjectholder.cpp index 1d39802658..87a1aebaab 100644 --- a/core/fpdfapi/page/cpdf_pageobjectholder.cpp +++ b/core/fpdfapi/page/cpdf_pageobjectholder.cpp @@ -40,6 +40,7 @@ void CPDF_PageObjectHolder::ContinueParse(PauseIndicatorIface* pPause) { 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 df69aa43b9..5f4bdf794d 100644 --- a/core/fpdfapi/page/cpdf_streamcontentparser.cpp +++ b/core/fpdfapi/page/cpdf_streamcontentparser.cpp @@ -781,7 +781,7 @@ void CPDF_StreamContentParser::AddForm(CPDF_Stream* pStream) { status.m_TextState = m_pCurStates->m_TextState; auto form = pdfium::MakeUnique( 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 02127b6368..5a71baaf7b 100644 --- a/core/fpdfapi/page/cpdf_tilingpattern.cpp +++ b/core/fpdfapi/page/cpdf_tilingpattern.cpp @@ -49,7 +49,7 @@ bool CPDF_TilingPattern::Load() { const CFX_Matrix& matrix = parent_matrix(); m_pForm = pdfium::MakeUnique(document(), nullptr, pStream); - m_pForm->ParseContentWithParams(nullptr, &matrix, nullptr, nullptr); + m_pForm->ParseContent(nullptr, &matrix, nullptr, nullptr); m_BBox = pDict->GetRectFor("BBox"); return true; } -- cgit v1.2.3