From 354ed202ccd4d6b9d408789a30517ebb1633570b Mon Sep 17 00:00:00 2001 From: Henrique Nakashima Date: Tue, 5 Jun 2018 18:56:52 +0000 Subject: Revert "Create m_ContentStream field in CPDF_PageObject." This reverts commit d3d8287e143daf12a602a919c120b4e0c656abf8. Reason for revert: Need to revert https://pdfium-review.googlesource.com/c/pdfium/+/33595 that this depends on. Original change's description: > Create m_ContentStream field in CPDF_PageObject. > > Content streams are now split and can set nonzero values to identify > each parsed content stream. > > Bug: pdfium:1051 > Change-Id: Ia2cb1e0997db5264d468043af31f9b41e8d0d349 > Reviewed-on: https://pdfium-review.googlesource.com/33591 > Commit-Queue: Henrique Nakashima > Reviewed-by: Ryan Harrison TBR=thestig@chromium.org,hnakashima@chromium.org,rharrison@chromium.org Change-Id: I5046b6a76508fccc0ff04cb7393cae6485dd091f No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: pdfium:1051 Reviewed-on: https://pdfium-review.googlesource.com/33990 Reviewed-by: Henrique Nakashima Commit-Queue: Henrique Nakashima --- core/fpdfapi/page/cpdf_contentparser.cpp | 2 +- core/fpdfapi/page/cpdf_formobject.cpp | 7 ++----- core/fpdfapi/page/cpdf_formobject.h | 4 +--- core/fpdfapi/page/cpdf_imageobject.cpp | 3 +-- core/fpdfapi/page/cpdf_imageobject.h | 2 +- core/fpdfapi/page/cpdf_pageobject.cpp | 3 +-- core/fpdfapi/page/cpdf_pageobject.h | 4 +--- core/fpdfapi/page/cpdf_pathobject.cpp | 3 +-- core/fpdfapi/page/cpdf_pathobject.h | 2 +- core/fpdfapi/page/cpdf_shadingobject.cpp | 5 ++--- core/fpdfapi/page/cpdf_shadingobject.h | 4 +--- core/fpdfapi/page/cpdf_streamcontentparser.cpp | 21 ++++++++------------- core/fpdfapi/page/cpdf_streamcontentparser.h | 6 +----- core/fpdfapi/page/cpdf_textobject.cpp | 5 ++--- core/fpdfapi/page/cpdf_textobject.h | 2 +- 15 files changed, 25 insertions(+), 48 deletions(-) (limited to 'core/fpdfapi/page') diff --git a/core/fpdfapi/page/cpdf_contentparser.cpp b/core/fpdfapi/page/cpdf_contentparser.cpp index c079f99cbf..471e707322 100644 --- a/core/fpdfapi/page/cpdf_contentparser.cpp +++ b/core/fpdfapi/page/cpdf_contentparser.cpp @@ -170,7 +170,7 @@ CPDF_ContentParser::Stage CPDF_ContentParser::Parse() { m_CurrentOffset += m_pParser->Parse( m_StreamArray[m_CurrentStream]->GetData() + m_CurrentOffset, m_StreamArray[m_CurrentStream]->GetSize() - m_CurrentOffset, - PARSE_STEP_LIMIT, m_CurrentStream); + PARSE_STEP_LIMIT); if (m_CurrentOffset >= m_StreamArray[m_CurrentStream]->GetSize()) { m_CurrentOffset = 0; diff --git a/core/fpdfapi/page/cpdf_formobject.cpp b/core/fpdfapi/page/cpdf_formobject.cpp index 22ac0d3823..eca92ca0ff 100644 --- a/core/fpdfapi/page/cpdf_formobject.cpp +++ b/core/fpdfapi/page/cpdf_formobject.cpp @@ -10,12 +10,9 @@ #include "core/fpdfapi/page/cpdf_form.h" -CPDF_FormObject::CPDF_FormObject(int32_t content_stream, - std::unique_ptr pForm, +CPDF_FormObject::CPDF_FormObject(std::unique_ptr pForm, const CFX_Matrix& matrix) - : CPDF_PageObject(content_stream), - m_pForm(std::move(pForm)), - m_FormMatrix(matrix) {} + : m_pForm(std::move(pForm)), m_FormMatrix(matrix) {} CPDF_FormObject::~CPDF_FormObject() {} diff --git a/core/fpdfapi/page/cpdf_formobject.h b/core/fpdfapi/page/cpdf_formobject.h index b229dce444..c723cc0eaf 100644 --- a/core/fpdfapi/page/cpdf_formobject.h +++ b/core/fpdfapi/page/cpdf_formobject.h @@ -16,9 +16,7 @@ class CPDF_Form; class CPDF_FormObject : public CPDF_PageObject { public: - CPDF_FormObject(int32_t content_stream, - std::unique_ptr pForm, - const CFX_Matrix& matrix); + CPDF_FormObject(std::unique_ptr pForm, const CFX_Matrix& matrix); ~CPDF_FormObject() override; // CPDF_PageObject: diff --git a/core/fpdfapi/page/cpdf_imageobject.cpp b/core/fpdfapi/page/cpdf_imageobject.cpp index 7826742276..3b5a740155 100644 --- a/core/fpdfapi/page/cpdf_imageobject.cpp +++ b/core/fpdfapi/page/cpdf_imageobject.cpp @@ -12,8 +12,7 @@ #include "core/fpdfapi/page/cpdf_image.h" #include "core/fpdfapi/parser/cpdf_document.h" -CPDF_ImageObject::CPDF_ImageObject(int32_t content_stream) - : CPDF_PageObject(content_stream) {} +CPDF_ImageObject::CPDF_ImageObject() {} CPDF_ImageObject::~CPDF_ImageObject() { MaybePurgeCache(); diff --git a/core/fpdfapi/page/cpdf_imageobject.h b/core/fpdfapi/page/cpdf_imageobject.h index 465b1628ed..16a506e537 100644 --- a/core/fpdfapi/page/cpdf_imageobject.h +++ b/core/fpdfapi/page/cpdf_imageobject.h @@ -16,7 +16,7 @@ class CPDF_Image; class CPDF_ImageObject : public CPDF_PageObject { public: - explicit CPDF_ImageObject(int32_t content_stream); + CPDF_ImageObject(); ~CPDF_ImageObject() override; // CPDF_PageObject diff --git a/core/fpdfapi/page/cpdf_pageobject.cpp b/core/fpdfapi/page/cpdf_pageobject.cpp index 582b9fff57..8bb5bf5978 100644 --- a/core/fpdfapi/page/cpdf_pageobject.cpp +++ b/core/fpdfapi/page/cpdf_pageobject.cpp @@ -6,8 +6,7 @@ #include "core/fpdfapi/page/cpdf_pageobject.h" -CPDF_PageObject::CPDF_PageObject(int32_t content_stream) - : m_bDirty(false), m_ContentStream(content_stream) {} +CPDF_PageObject::CPDF_PageObject() : m_bDirty(false) {} CPDF_PageObject::~CPDF_PageObject() {} diff --git a/core/fpdfapi/page/cpdf_pageobject.h b/core/fpdfapi/page/cpdf_pageobject.h index b7cc5996c9..d23cd971f8 100644 --- a/core/fpdfapi/page/cpdf_pageobject.h +++ b/core/fpdfapi/page/cpdf_pageobject.h @@ -28,7 +28,7 @@ class CPDF_PageObject : public CPDF_GraphicStates { FORM, }; - explicit CPDF_PageObject(int32_t content_stream); + CPDF_PageObject(); ~CPDF_PageObject() override; virtual Type GetType() const = 0; @@ -58,7 +58,6 @@ class CPDF_PageObject : public CPDF_GraphicStates { return CFX_FloatRect(m_Left, m_Bottom, m_Right, m_Top); } FX_RECT GetBBox(const CFX_Matrix* pMatrix) const; - int32_t GetContentStream() const { return m_ContentStream; } float m_Left; float m_Right; @@ -74,7 +73,6 @@ class CPDF_PageObject : public CPDF_GraphicStates { void operator=(const CPDF_PageObject& src) = delete; bool m_bDirty; - int32_t m_ContentStream; }; #endif // CORE_FPDFAPI_PAGE_CPDF_PAGEOBJECT_H_ diff --git a/core/fpdfapi/page/cpdf_pathobject.cpp b/core/fpdfapi/page/cpdf_pathobject.cpp index 39ab134c92..d8c2cb8741 100644 --- a/core/fpdfapi/page/cpdf_pathobject.cpp +++ b/core/fpdfapi/page/cpdf_pathobject.cpp @@ -6,8 +6,7 @@ #include "core/fpdfapi/page/cpdf_pathobject.h" -CPDF_PathObject::CPDF_PathObject(int32_t content_stream) - : CPDF_PageObject(content_stream), m_FillType(0), m_bStroke(false) {} +CPDF_PathObject::CPDF_PathObject() : m_FillType(0), m_bStroke(false) {} CPDF_PathObject::~CPDF_PathObject() {} diff --git a/core/fpdfapi/page/cpdf_pathobject.h b/core/fpdfapi/page/cpdf_pathobject.h index d4843d2fb6..58499b5a53 100644 --- a/core/fpdfapi/page/cpdf_pathobject.h +++ b/core/fpdfapi/page/cpdf_pathobject.h @@ -14,7 +14,7 @@ class CPDF_PathObject : public CPDF_PageObject { public: - explicit CPDF_PathObject(int32_t content_stream); + CPDF_PathObject(); ~CPDF_PathObject() override; // CPDF_PageObject diff --git a/core/fpdfapi/page/cpdf_shadingobject.cpp b/core/fpdfapi/page/cpdf_shadingobject.cpp index 725e2e4591..1b16ac4862 100644 --- a/core/fpdfapi/page/cpdf_shadingobject.cpp +++ b/core/fpdfapi/page/cpdf_shadingobject.cpp @@ -9,10 +9,9 @@ #include "core/fpdfapi/page/cpdf_shadingpattern.h" #include "core/fpdfapi/parser/cpdf_document.h" -CPDF_ShadingObject::CPDF_ShadingObject(int32_t content_stream, - CPDF_ShadingPattern* pattern, +CPDF_ShadingObject::CPDF_ShadingObject(CPDF_ShadingPattern* pattern, const CFX_Matrix& matrix) - : CPDF_PageObject(content_stream), m_pShading(pattern), m_Matrix(matrix) {} + : m_pShading(pattern), m_Matrix(matrix) {} CPDF_ShadingObject::~CPDF_ShadingObject() {} diff --git a/core/fpdfapi/page/cpdf_shadingobject.h b/core/fpdfapi/page/cpdf_shadingobject.h index 69b606749d..80e062c729 100644 --- a/core/fpdfapi/page/cpdf_shadingobject.h +++ b/core/fpdfapi/page/cpdf_shadingobject.h @@ -15,9 +15,7 @@ class CPDF_ShadingPattern; class CPDF_ShadingObject : public CPDF_PageObject { public: - CPDF_ShadingObject(int32_t content_stream, - CPDF_ShadingPattern* pattern, - const CFX_Matrix& matrix); + CPDF_ShadingObject(CPDF_ShadingPattern* pattern, const CFX_Matrix& matrix); ~CPDF_ShadingObject() override; // CPDF_PageObject: diff --git a/core/fpdfapi/page/cpdf_streamcontentparser.cpp b/core/fpdfapi/page/cpdf_streamcontentparser.cpp index 051d79ad1d..7e7c337d96 100644 --- a/core/fpdfapi/page/cpdf_streamcontentparser.cpp +++ b/core/fpdfapi/page/cpdf_streamcontentparser.cpp @@ -786,8 +786,7 @@ void CPDF_StreamContentParser::AddForm(CPDF_Stream* pStream) { CFX_Matrix matrix = m_pCurStates->m_CTM; matrix.Concat(m_mtContentToUser); - auto pFormObj = pdfium::MakeUnique(m_CurrentContentStream, - std::move(form), matrix); + auto pFormObj = pdfium::MakeUnique(std::move(form), matrix); if (!m_pObjectHolder->BackgroundAlphaNeeded() && pFormObj->form()->BackgroundAlphaNeeded()) { m_pObjectHolder->SetBackgroundAlphaNeeded(true); @@ -802,14 +801,14 @@ CPDF_ImageObject* CPDF_StreamContentParser::AddImage( if (!pStream) return nullptr; - auto pImageObj = pdfium::MakeUnique(m_CurrentContentStream); + auto pImageObj = pdfium::MakeUnique(); pImageObj->SetImage( pdfium::MakeRetain(m_pDocument.Get(), std::move(pStream))); return AddImageObject(std::move(pImageObj)); } CPDF_ImageObject* CPDF_StreamContentParser::AddImage(uint32_t streamObjNum) { - auto pImageObj = pdfium::MakeUnique(m_CurrentContentStream); + auto pImageObj = pdfium::MakeUnique(); pImageObj->SetImage(m_pDocument->LoadImageFromPageData(streamObjNum)); return AddImageObject(std::move(pImageObj)); } @@ -819,7 +818,7 @@ CPDF_ImageObject* CPDF_StreamContentParser::AddImage( if (!pImage) return nullptr; - auto pImageObj = pdfium::MakeUnique(m_CurrentContentStream); + auto pImageObj = pdfium::MakeUnique(); pImageObj->SetImage( m_pDocument->GetPageData()->GetImage(pImage->GetStream()->GetObjNum())); @@ -1086,8 +1085,7 @@ void CPDF_StreamContentParser::Handle_ShadeFill() { CFX_Matrix matrix = m_pCurStates->m_CTM; matrix.Concat(m_mtContentToUser); - auto pObj = pdfium::MakeUnique(m_CurrentContentStream, - pShading, matrix); + auto pObj = pdfium::MakeUnique(pShading, matrix); SetGraphicStates(pObj.get(), false, false, false); CFX_FloatRect bbox = pObj->m_ClipPath.HasRef() ? pObj->m_ClipPath.GetClipBox() : m_BBox; @@ -1222,7 +1220,7 @@ void CPDF_StreamContentParser::AddTextObject(ByteString* pStrs, pFont->IsType3Font() ? TextRenderingMode::MODE_FILL : m_pCurStates->m_TextState.GetTextMode(); { - auto pText = pdfium::MakeUnique(m_CurrentContentStream); + auto pText = pdfium::MakeUnique(); m_pLastTextObject = pText.get(); SetGraphicStates(m_pLastTextObject.Get(), true, true, true); if (TextRenderingModeIsStrokeMode(text_mode)) { @@ -1459,7 +1457,7 @@ void CPDF_StreamContentParser::AddPathObject(int FillType, bool bStroke) { CFX_Matrix matrix = m_pCurStates->m_CTM; matrix.Concat(m_mtContentToUser); if (bStroke || FillType) { - auto pPathObj = pdfium::MakeUnique(m_CurrentContentStream); + auto pPathObj = pdfium::MakeUnique(); pPathObj->m_bStroke = bStroke; pPathObj->m_FillType = FillType; pPathObj->m_Path = Path; @@ -1479,10 +1477,7 @@ void CPDF_StreamContentParser::AddPathObject(int FillType, bool bStroke) { uint32_t CPDF_StreamContentParser::Parse(const uint8_t* pData, uint32_t dwSize, - uint32_t max_cost, - uint32_t content_stream) { - m_CurrentContentStream = content_stream; - + uint32_t max_cost) { if (m_ParsedSet->size() > kMaxFormLevel || pdfium::ContainsKey(*m_ParsedSet, pData)) return dwSize; diff --git a/core/fpdfapi/page/cpdf_streamcontentparser.h b/core/fpdfapi/page/cpdf_streamcontentparser.h index 4c593998fd..438be024cc 100644 --- a/core/fpdfapi/page/cpdf_streamcontentparser.h +++ b/core/fpdfapi/page/cpdf_streamcontentparser.h @@ -43,10 +43,7 @@ class CPDF_StreamContentParser { std::set* parsedSet); ~CPDF_StreamContentParser(); - uint32_t Parse(const uint8_t* pData, - uint32_t dwSize, - uint32_t max_cost, - uint32_t content_stream); + uint32_t Parse(const uint8_t* pData, uint32_t dwSize, uint32_t max_cost); CPDF_PageObjectHolder* GetPageObjectHolder() const { return m_pObjectHolder.Get(); } @@ -233,7 +230,6 @@ class CPDF_StreamContentParser { std::vector> m_StateStack; float m_Type3Data[6]; ContentParam m_ParamBuf[kParamBufSize]; - uint32_t m_CurrentContentStream; }; #endif // CORE_FPDFAPI_PAGE_CPDF_STREAMCONTENTPARSER_H_ diff --git a/core/fpdfapi/page/cpdf_textobject.cpp b/core/fpdfapi/page/cpdf_textobject.cpp index 68d20b6598..36a4722773 100644 --- a/core/fpdfapi/page/cpdf_textobject.cpp +++ b/core/fpdfapi/page/cpdf_textobject.cpp @@ -18,8 +18,7 @@ CPDF_TextObjectItem::CPDF_TextObjectItem() : m_CharCode(0) {} CPDF_TextObjectItem::~CPDF_TextObjectItem() = default; -CPDF_TextObject::CPDF_TextObject(int32_t content_stream) - : CPDF_PageObject(content_stream) {} +CPDF_TextObject::CPDF_TextObject() {} CPDF_TextObject::~CPDF_TextObject() { // Move m_CharCodes to a local variable so it will be captured in crash dumps, @@ -101,7 +100,7 @@ void CPDF_TextObject::GetCharInfo(size_t index, } std::unique_ptr CPDF_TextObject::Clone() const { - auto obj = pdfium::MakeUnique(-1); + auto obj = pdfium::MakeUnique(); obj->CopyData(this); obj->m_CharCodes = m_CharCodes; obj->m_CharPos = m_CharPos; diff --git a/core/fpdfapi/page/cpdf_textobject.h b/core/fpdfapi/page/cpdf_textobject.h index 3faccfdfe7..a6fc62369c 100644 --- a/core/fpdfapi/page/cpdf_textobject.h +++ b/core/fpdfapi/page/cpdf_textobject.h @@ -25,7 +25,7 @@ class CPDF_TextObjectItem { class CPDF_TextObject : public CPDF_PageObject { public: - explicit CPDF_TextObject(int32_t content_stream); + CPDF_TextObject(); ~CPDF_TextObject() override; // CPDF_PageObject -- cgit v1.2.3