summaryrefslogtreecommitdiff
path: root/xfa/fde
diff options
context:
space:
mode:
authortsepez <tsepez@chromium.org>2016-12-14 05:57:10 -0800
committerCommit bot <commit-bot@chromium.org>2016-12-14 05:57:10 -0800
commita9caab94c1f16929e5acf2676117224617d80f53 (patch)
treed71ff9a82fae6e6080deb76375f43056127b3ee2 /xfa/fde
parent992ecf7c189e5cabf43e5ad862511cf63d030966 (diff)
downloadpdfium-a9caab94c1f16929e5acf2676117224617d80f53.tar.xz
Avoid the ptr.reset(new XXX()) anti-pattern
Be suspicious of |new|. This removes some of the easy cases. Review-Url: https://codereview.chromium.org/2571913002
Diffstat (limited to 'xfa/fde')
-rw-r--r--xfa/fde/cfde_txtedtengine.cpp2
-rw-r--r--xfa/fde/cfde_txtedtpage.cpp3
-rw-r--r--xfa/fde/cfx_wordbreak.cpp3
-rw-r--r--xfa/fde/css/fde_cssstyleselector.cpp3
-rw-r--r--xfa/fde/fde_render.cpp5
-rw-r--r--xfa/fde/tto/fde_textout.cpp5
6 files changed, 13 insertions, 8 deletions
diff --git a/xfa/fde/cfde_txtedtengine.cpp b/xfa/fde/cfde_txtedtengine.cpp
index ced5bdca52..7df4e0fb96 100644
--- a/xfa/fde/cfde_txtedtengine.cpp
+++ b/xfa/fde/cfde_txtedtengine.cpp
@@ -82,7 +82,7 @@ CFDE_TxtEdtEngine::~CFDE_TxtEdtEngine() {
void CFDE_TxtEdtEngine::SetEditParams(const FDE_TXTEDTPARAMS& params) {
if (!m_pTextBreak)
- m_pTextBreak.reset(new CFX_TxtBreak(FX_TXTBREAKPOLICY_None));
+ m_pTextBreak = pdfium::MakeUnique<CFX_TxtBreak>(FX_TXTBREAKPOLICY_None);
FXSYS_memcpy(&m_Param, &params, sizeof(FDE_TXTEDTPARAMS));
m_wLineEnd = params.wLineBreakChar;
diff --git a/xfa/fde/cfde_txtedtpage.cpp b/xfa/fde/cfde_txtedtpage.cpp
index 0abb1d69f3..51621dae1c 100644
--- a/xfa/fde/cfde_txtedtpage.cpp
+++ b/xfa/fde/cfde_txtedtpage.cpp
@@ -8,6 +8,7 @@
#include <algorithm>
+#include "third_party/base/ptr_util.h"
#include "xfa/fde/cfde_txtedtbuf.h"
#include "xfa/fde/cfde_txtedtbufiter.h"
#include "xfa/fde/cfde_txtedtengine.h"
@@ -303,7 +304,7 @@ int32_t CFDE_TxtEdtPage::LoadPage(const CFX_RectF* pClipBox,
(bVertial && bLineReserve) ? (-pParams->fLineSpace) : pParams->fLineSpace;
FX_FLOAT fLinePos = fLineStart;
if (!m_pTextSet)
- m_pTextSet.reset(new CFDE_TxtEdtTextSet(this));
+ m_pTextSet = pdfium::MakeUnique<CFDE_TxtEdtTextSet>(this);
m_PieceMassArr.RemoveAll(true);
uint32_t dwBreakStatus = FX_TXTBREAK_None;
diff --git a/xfa/fde/cfx_wordbreak.cpp b/xfa/fde/cfx_wordbreak.cpp
index 48b45a4e82..2d37ba1707 100644
--- a/xfa/fde/cfx_wordbreak.cpp
+++ b/xfa/fde/cfx_wordbreak.cpp
@@ -8,6 +8,7 @@
#include <utility>
+#include "third_party/base/ptr_util.h"
#include "xfa/fde/cfx_chariter.h"
namespace {
@@ -2788,7 +2789,7 @@ void CFX_WordBreak::Attach(IFX_CharIter* pIter) {
}
void CFX_WordBreak::Attach(const CFX_WideString& wsText) {
- m_pCurIter.reset(new CFX_CharIter(wsText));
+ m_pCurIter = pdfium::MakeUnique<CFX_CharIter>(wsText);
}
bool CFX_WordBreak::Next(bool bPrev) {
diff --git a/xfa/fde/css/fde_cssstyleselector.cpp b/xfa/fde/css/fde_cssstyleselector.cpp
index 117afcc7ab..72e5ffc12b 100644
--- a/xfa/fde/css/fde_cssstyleselector.cpp
+++ b/xfa/fde/css/fde_cssstyleselector.cpp
@@ -9,6 +9,7 @@
#include <algorithm>
#include <memory>
+#include "third_party/base/ptr_util.h"
#include "third_party/base/stl_util.h"
#include "xfa/fde/css/fde_csscache.h"
#include "xfa/fde/css/fde_cssdeclaration.h"
@@ -126,7 +127,7 @@ void CFDE_CSSStyleSelector::SetDefFontSize(FX_FLOAT fFontSize) {
CFDE_CSSAccelerator* CFDE_CSSStyleSelector::InitAccelerator() {
if (!m_pAccelerator)
- m_pAccelerator.reset(new CFDE_CSSAccelerator);
+ m_pAccelerator = pdfium::MakeUnique<CFDE_CSSAccelerator>();
m_pAccelerator->Clear();
return m_pAccelerator.get();
}
diff --git a/xfa/fde/fde_render.cpp b/xfa/fde/fde_render.cpp
index e1d46f55f9..9528219b45 100644
--- a/xfa/fde/fde_render.cpp
+++ b/xfa/fde/fde_render.cpp
@@ -6,6 +6,7 @@
#include "xfa/fde/fde_render.h"
+#include "third_party/base/ptr_util.h"
#include "xfa/fde/fde_gedevice.h"
#include "xfa/fde/fde_object.h"
#include "xfa/fgas/crt/fgas_memory.h"
@@ -38,7 +39,7 @@ bool CFDE_RenderContext::StartRender(CFDE_RenderDevice* pRenderDevice,
m_pRenderDevice = pRenderDevice;
m_Transform = tmDoc2Device;
if (!m_pIterator)
- m_pIterator.reset(new CFDE_VisualSetIterator);
+ m_pIterator = pdfium::MakeUnique<CFDE_VisualSetIterator>();
return m_pIterator->AttachCanvas(pCanvasSet) && m_pIterator->FilterObjects();
}
@@ -116,7 +117,7 @@ void CFDE_RenderContext::RenderText(IFDE_TextSet* pTextSet,
return;
if (!m_pBrush)
- m_pBrush.reset(new CFDE_Brush);
+ m_pBrush = pdfium::MakeUnique<CFDE_Brush>();
if (m_CharPos.size() < static_cast<size_t>(iCount))
m_CharPos.resize(iCount, FXTEXT_CHARPOS());
diff --git a/xfa/fde/tto/fde_textout.cpp b/xfa/fde/tto/fde_textout.cpp
index 68a68565d1..d7155b7107 100644
--- a/xfa/fde/tto/fde_textout.cpp
+++ b/xfa/fde/tto/fde_textout.cpp
@@ -10,6 +10,7 @@
#include "core/fxcrt/fx_coordinates.h"
#include "core/fxcrt/fx_system.h"
+#include "third_party/base/ptr_util.h"
#include "xfa/fde/cfde_path.h"
#include "xfa/fde/fde_gedevice.h"
#include "xfa/fde/fde_object.h"
@@ -132,12 +133,12 @@ void CFDE_TextOut::SetDIBitmap(CFX_DIBitmap* pDIB) {
m_pRenderDevice.reset();
CFX_FxgeDevice* device = new CFX_FxgeDevice;
device->Attach(pDIB, false, nullptr, false);
- m_pRenderDevice.reset(new CFDE_RenderDevice(device, false));
+ m_pRenderDevice = pdfium::MakeUnique<CFDE_RenderDevice>(device, false);
}
void CFDE_TextOut::SetRenderDevice(CFX_RenderDevice* pDevice) {
ASSERT(pDevice);
- m_pRenderDevice.reset(new CFDE_RenderDevice(pDevice, false));
+ m_pRenderDevice = pdfium::MakeUnique<CFDE_RenderDevice>(pDevice, false);
}
void CFDE_TextOut::SetClipRect(const CFX_Rect& rtClip) {