diff options
author | Tom Sepez <tsepez@chromium.org> | 2017-04-26 13:50:33 -0700 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-04-26 21:25:42 +0000 |
commit | 827db14d7f3d0085253b686587717361ffbcad1b (patch) | |
tree | dd2039623b87ba0c40b48f9a0344a463b1f3fb53 /core/fpdfapi/page | |
parent | e47e0c96009b8633294eebbb9eb0e84caf525c57 (diff) | |
download | pdfium-827db14d7f3d0085253b686587717361ffbcad1b.tar.xz |
Remove a few more |new|s.
Change-Id: I8a50ed680c1e101f855644fca8d282dd21470577
Reviewed-on: https://pdfium-review.googlesource.com/4533
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Reviewed-by: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'core/fpdfapi/page')
-rw-r--r-- | core/fpdfapi/page/cpdf_form.cpp | 6 | ||||
-rw-r--r-- | core/fpdfapi/page/cpdf_page.cpp | 10 | ||||
-rw-r--r-- | core/fpdfapi/page/cpdf_pageobjectholder.cpp | 20 | ||||
-rw-r--r-- | core/fpdfapi/page/cpdf_pageobjectholder.h | 2 | ||||
-rw-r--r-- | core/fpdfapi/page/cpdf_streamcontentparser.cpp | 24 |
5 files changed, 30 insertions, 32 deletions
diff --git a/core/fpdfapi/page/cpdf_form.cpp b/core/fpdfapi/page/cpdf_form.cpp index b3f2b372e3..2245f934f6 100644 --- a/core/fpdfapi/page/cpdf_form.cpp +++ b/core/fpdfapi/page/cpdf_form.cpp @@ -17,10 +17,10 @@ CPDF_Form::CPDF_Form(CPDF_Document* pDoc, CPDF_Dictionary* pPageResources, CPDF_Stream* pFormStream, - CPDF_Dictionary* pParentResources) { - m_pDocument = pDoc; + CPDF_Dictionary* pParentResources) + : CPDF_PageObjectHolder(pDoc, + pFormStream ? pFormStream->GetDict() : nullptr) { m_pFormStream = pFormStream; - m_pFormDict = pFormStream ? pFormStream->GetDict() : nullptr; m_pResources = m_pFormDict->GetDictFor("Resources"); m_pPageResources = pPageResources; if (!m_pResources) diff --git a/core/fpdfapi/page/cpdf_page.cpp b/core/fpdfapi/page/cpdf_page.cpp index 314b8acbaa..496ed7cc58 100644 --- a/core/fpdfapi/page/cpdf_page.cpp +++ b/core/fpdfapi/page/cpdf_page.cpp @@ -23,12 +23,12 @@ CPDF_Page::CPDF_Page(CPDF_Document* pDocument, CPDF_Dictionary* pPageDict, bool bPageCache) - : m_PageWidth(100), + : CPDF_PageObjectHolder(pDocument, pPageDict), + m_PageWidth(100), m_PageHeight(100), - m_pView(nullptr), - m_pPageRender(bPageCache ? new CPDF_PageRenderCache(this) : nullptr) { - m_pFormDict = pPageDict; - m_pDocument = pDocument; + m_pView(nullptr) { + if (bPageCache) + m_pPageRender = pdfium::MakeUnique<CPDF_PageRenderCache>(this); if (!pPageDict) return; diff --git a/core/fpdfapi/page/cpdf_pageobjectholder.cpp b/core/fpdfapi/page/cpdf_pageobjectholder.cpp index 5f5597e5ac..1d2b51e959 100644 --- a/core/fpdfapi/page/cpdf_pageobjectholder.cpp +++ b/core/fpdfapi/page/cpdf_pageobjectholder.cpp @@ -13,10 +13,11 @@ #include "core/fpdfapi/page/pageint.h" #include "core/fpdfapi/parser/cpdf_dictionary.h" -CPDF_PageObjectHolder::CPDF_PageObjectHolder() - : m_pFormDict(nullptr), +CPDF_PageObjectHolder::CPDF_PageObjectHolder(CPDF_Document* pDoc, + CPDF_Dictionary* pFormDict) + : m_pFormDict(pFormDict), m_pFormStream(nullptr), - m_pDocument(nullptr), + m_pDocument(pDoc), m_pPageResources(nullptr), m_pResources(nullptr), m_Transparency(0), @@ -26,14 +27,15 @@ CPDF_PageObjectHolder::CPDF_PageObjectHolder() CPDF_PageObjectHolder::~CPDF_PageObjectHolder() {} void CPDF_PageObjectHolder::ContinueParse(IFX_Pause* pPause) { - if (!m_pParser) { + if (!m_pParser) return; - } + m_pParser->Continue(pPause); - if (m_pParser->GetStatus() == CPDF_ContentParser::Done) { - m_ParseState = CONTENT_PARSED; - m_pParser.reset(); - } + if (m_pParser->GetStatus() != CPDF_ContentParser::Done) + return; + + m_ParseState = CONTENT_PARSED; + m_pParser.reset(); } void CPDF_PageObjectHolder::AddImageMaskBoundingBox(const CFX_FloatRect& box) { diff --git a/core/fpdfapi/page/cpdf_pageobjectholder.h b/core/fpdfapi/page/cpdf_pageobjectholder.h index 0b88a86518..f5b60fff9d 100644 --- a/core/fpdfapi/page/cpdf_pageobjectholder.h +++ b/core/fpdfapi/page/cpdf_pageobjectholder.h @@ -26,7 +26,7 @@ class CPDF_ContentParser; class CPDF_PageObjectHolder { public: - CPDF_PageObjectHolder(); + CPDF_PageObjectHolder(CPDF_Document* pDoc, CPDF_Dictionary* pFormDict); virtual ~CPDF_PageObjectHolder(); void ContinueParse(IFX_Pause* pPause); diff --git a/core/fpdfapi/page/cpdf_streamcontentparser.cpp b/core/fpdfapi/page/cpdf_streamcontentparser.cpp index d9f12f121b..3e6e75a53e 100644 --- a/core/fpdfapi/page/cpdf_streamcontentparser.cpp +++ b/core/fpdfapi/page/cpdf_streamcontentparser.cpp @@ -1319,31 +1319,27 @@ void CPDF_StreamContentParser::Handle_ShowText_Positioning() { } return; } - CFX_ByteString* pStrs = new CFX_ByteString[nsegs]; - float* pKerning = FX_Alloc(float, nsegs); + std::vector<CFX_ByteString> strs(nsegs); + std::vector<float> kernings(nsegs); size_t iSegment = 0; float fInitKerning = 0; for (size_t i = 0; i < n; i++) { CPDF_Object* pObj = pArray->GetDirectObjectAt(i); if (pObj->IsString()) { CFX_ByteString str = pObj->GetString(); - if (str.IsEmpty()) { + if (str.IsEmpty()) continue; - } - pStrs[iSegment] = str; - pKerning[iSegment++] = 0; + strs[iSegment] = str; + kernings[iSegment++] = 0; } else { - float num = pObj ? pObj->GetNumber() : 0; - if (iSegment == 0) { + float num = pObj->GetNumber(); + if (iSegment == 0) fInitKerning += num; - } else { - pKerning[iSegment - 1] += num; - } + else + kernings[iSegment - 1] += num; } } - AddTextObject(pStrs, fInitKerning, pKerning, iSegment); - delete[] pStrs; - FX_Free(pKerning); + AddTextObject(strs.data(), fInitKerning, kernings.data(), iSegment); } void CPDF_StreamContentParser::Handle_SetTextLeading() { |