From b0d3160afa3ee0190b497d0eced5f5de1fdc8fbb Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Wed, 1 Mar 2017 15:58:32 -0500 Subject: Change CreateBreak to return a unique_ptr MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The value is always set into a unique_ptr, so return one and assign. Change-Id: Ieda649c8f86caf1344ca2ce342a141c3ab70aa0f Reviewed-on: https://pdfium-review.googlesource.com/2883 Commit-Queue: dsinclair Reviewed-by: Nicolás Peña Reviewed-by: Tom Sepez --- xfa/fxfa/app/cxfa_textlayout.cpp | 10 +++++----- xfa/fxfa/app/cxfa_textlayout.h | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/xfa/fxfa/app/cxfa_textlayout.cpp b/xfa/fxfa/app/cxfa_textlayout.cpp index 715dbb32dd..06cbfe0c70 100644 --- a/xfa/fxfa/app/cxfa_textlayout.cpp +++ b/xfa/fxfa/app/cxfa_textlayout.cpp @@ -89,12 +89,12 @@ CFDE_XMLNode* CXFA_TextLayout::GetXMLContainerNode() { return pXMLContainer; } -CFX_RTFBreak* CXFA_TextLayout::CreateBreak(bool bDefault) { +std::unique_ptr CXFA_TextLayout::CreateBreak(bool bDefault) { uint32_t dwStyle = FX_RTFLAYOUTSTYLE_ExpandTab; if (!bDefault) dwStyle |= FX_RTFLAYOUTSTYLE_Pagination; - CFX_RTFBreak* pBreak = new CFX_RTFBreak(dwStyle); + auto pBreak = pdfium::MakeUnique(dwStyle); pBreak->SetLineBreakTolerance(1); pBreak->SetFont(m_textParser.GetFont(m_pTextProvider, nullptr)); pBreak->SetFontSize(m_textParser.GetFontSize(m_pTextProvider, nullptr)); @@ -391,7 +391,7 @@ bool CXFA_TextLayout::CalcSize(const CFX_SizeF& minSize, if (defaultSize.width < 1) defaultSize.width = 0xFFFF; - m_pBreak.reset(CreateBreak(false)); + m_pBreak = CreateBreak(false); FX_FLOAT fLinePos = 0; m_iLines = 0; m_fMaxWidth = 0; @@ -409,7 +409,7 @@ bool CXFA_TextLayout::Layout(const CFX_SizeF& size, FX_FLOAT* fHeight) { return false; Unload(); - m_pBreak.reset(CreateBreak(true)); + m_pBreak = CreateBreak(true); if (m_pLoader) { m_pLoader->m_iTotalLines = -1; m_pLoader->m_iChar = 0; @@ -444,7 +444,7 @@ bool CXFA_TextLayout::Layout(int32_t iBlock) { return true; if (iBlock == iBlocksHeightCount) { Unload(); - m_pBreak.reset(CreateBreak(true)); + m_pBreak = CreateBreak(true); fLinePos = m_pLoader->m_fStartLineOffset; for (int32_t i = 0; i < iBlocksHeightCount; i++) fLinePos -= m_pLoader->m_BlocksHeight[i * 2 + 1]; diff --git a/xfa/fxfa/app/cxfa_textlayout.h b/xfa/fxfa/app/cxfa_textlayout.h index cbc7160c28..d4d60cf81e 100644 --- a/xfa/fxfa/app/cxfa_textlayout.h +++ b/xfa/fxfa/app/cxfa_textlayout.h @@ -65,7 +65,7 @@ class CXFA_TextLayout { private: void GetTextDataNode(); CFDE_XMLNode* GetXMLContainerNode(); - CFX_RTFBreak* CreateBreak(bool bDefault); + std::unique_ptr CreateBreak(bool bDefault); void InitBreak(FX_FLOAT fLineWidth); void InitBreak(CFDE_CSSComputedStyle* pStyle, FDE_CSSDisplay eDisplay, -- cgit v1.2.3