From 75acda66db9db257ec92172ea1a30b6616117b8d Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Mon, 29 Jan 2018 20:17:36 +0000 Subject: Kill some bare |new|s in cjs_field.cpp Change-Id: Id4d9f21d94d8b21199846ec5f7613590fd20579e Reviewed-on: https://pdfium-review.googlesource.com/24310 Reviewed-by: Lei Zhang Commit-Queue: Tom Sepez --- fxjs/cjs_document.cpp | 4 ++-- fxjs/cjs_document.h | 2 +- fxjs/cjs_field.cpp | 37 +++++++++++++++++++------------------ 3 files changed, 22 insertions(+), 21 deletions(-) (limited to 'fxjs') diff --git a/fxjs/cjs_document.cpp b/fxjs/cjs_document.cpp index d4eca2f175..76d3f18b40 100644 --- a/fxjs/cjs_document.cpp +++ b/fxjs/cjs_document.cpp @@ -1474,8 +1474,8 @@ CJS_Return Document::gotoNamedDest( return CJS_Return(true); } -void Document::AddDelayData(CJS_DelayData* pData) { - m_DelayData.push_back(std::unique_ptr(pData)); +void Document::AddDelayData(std::unique_ptr pData) { + m_DelayData.push_back(std::move(pData)); } void Document::DoFieldDelay(const WideString& sFieldName, int nControlIndex) { diff --git a/fxjs/cjs_document.h b/fxjs/cjs_document.h index edfaf96200..896522c684 100644 --- a/fxjs/cjs_document.h +++ b/fxjs/cjs_document.h @@ -211,7 +211,7 @@ class Document : public CJS_EmbedObj { CPDFSDK_FormFillEnvironment* GetFormFillEnv() const { return m_pFormFillEnv.Get(); } - void AddDelayData(CJS_DelayData* pData); + void AddDelayData(std::unique_ptr pData); void DoFieldDelay(const WideString& sFieldName, int nControlIndex); CJS_Document* GetCJSDoc() const; diff --git a/fxjs/cjs_field.cpp b/fxjs/cjs_field.cpp index 7f530cf4d8..b9b93d40a5 100644 --- a/fxjs/cjs_field.cpp +++ b/fxjs/cjs_field.cpp @@ -8,6 +8,7 @@ #include #include +#include #include "core/fpdfapi/font/cpdf_font.h" #include "core/fpdfdoc/cpdf_formfield.h" @@ -2590,47 +2591,47 @@ CJS_Return Field::set_source(CJS_Runtime* pRuntime, v8::Local vp) { } void Field::AddDelay_Int(FIELD_PROP prop, int32_t n) { - CJS_DelayData* pNewData = - new CJS_DelayData(prop, m_nFormControlIndex, m_FieldName); + auto pNewData = + pdfium::MakeUnique(prop, m_nFormControlIndex, m_FieldName); pNewData->num = n; - m_pJSDoc->AddDelayData(pNewData); + m_pJSDoc->AddDelayData(std::move(pNewData)); } void Field::AddDelay_Bool(FIELD_PROP prop, bool b) { - CJS_DelayData* pNewData = - new CJS_DelayData(prop, m_nFormControlIndex, m_FieldName); + auto pNewData = + pdfium::MakeUnique(prop, m_nFormControlIndex, m_FieldName); pNewData->b = b; - m_pJSDoc->AddDelayData(pNewData); + m_pJSDoc->AddDelayData(std::move(pNewData)); } void Field::AddDelay_String(FIELD_PROP prop, const ByteString& string) { - CJS_DelayData* pNewData = - new CJS_DelayData(prop, m_nFormControlIndex, m_FieldName); + auto pNewData = + pdfium::MakeUnique(prop, m_nFormControlIndex, m_FieldName); pNewData->string = string; - m_pJSDoc->AddDelayData(pNewData); + m_pJSDoc->AddDelayData(std::move(pNewData)); } void Field::AddDelay_Rect(FIELD_PROP prop, const CFX_FloatRect& rect) { - CJS_DelayData* pNewData = - new CJS_DelayData(prop, m_nFormControlIndex, m_FieldName); + auto pNewData = + pdfium::MakeUnique(prop, m_nFormControlIndex, m_FieldName); pNewData->rect = rect; - m_pJSDoc->AddDelayData(pNewData); + m_pJSDoc->AddDelayData(std::move(pNewData)); } void Field::AddDelay_WordArray(FIELD_PROP prop, const std::vector& array) { - CJS_DelayData* pNewData = - new CJS_DelayData(prop, m_nFormControlIndex, m_FieldName); + auto pNewData = + pdfium::MakeUnique(prop, m_nFormControlIndex, m_FieldName); pNewData->wordarray = array; - m_pJSDoc->AddDelayData(pNewData); + m_pJSDoc->AddDelayData(std::move(pNewData)); } void Field::AddDelay_WideStringArray(FIELD_PROP prop, const std::vector& array) { - CJS_DelayData* pNewData = - new CJS_DelayData(prop, m_nFormControlIndex, m_FieldName); + auto pNewData = + pdfium::MakeUnique(prop, m_nFormControlIndex, m_FieldName); pNewData->widestringarray = array; - m_pJSDoc->AddDelayData(pNewData); + m_pJSDoc->AddDelayData(std::move(pNewData)); } void Field::DoDelay(CPDFSDK_FormFillEnvironment* pFormFillEnv, -- cgit v1.2.3