diff options
author | Tom Sepez <tsepez@chromium.org> | 2017-04-14 17:07:09 -0700 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-04-18 14:11:29 +0000 |
commit | 5f28b86694455e5ef37736b73fe17d2c271ac721 (patch) | |
tree | 46c93dd9028d12f813f56ad8d1b12fee818de7a4 /xfa/fxfa/app/xfa_ffbarcode.cpp | |
parent | 0f9b0a9d72a46cf708866aebc5f1103087b3d2c2 (diff) | |
download | pdfium-5f28b86694455e5ef37736b73fe17d2c271ac721.tar.xz |
Use unique_ptr for m_pNormalWidget
Change-Id: I8f28171b55c625061bb047899dbfcd4a61004e09
Reviewed-on: https://pdfium-review.googlesource.com/4253
Commit-Queue: dsinclair <dsinclair@chromium.org>
Reviewed-by: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'xfa/fxfa/app/xfa_ffbarcode.cpp')
-rw-r--r-- | xfa/fxfa/app/xfa_ffbarcode.cpp | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/xfa/fxfa/app/xfa_ffbarcode.cpp b/xfa/fxfa/app/xfa_ffbarcode.cpp index 72adb3c96b..92d687781d 100644 --- a/xfa/fxfa/app/xfa_ffbarcode.cpp +++ b/xfa/fxfa/app/xfa_ffbarcode.cpp @@ -6,7 +6,10 @@ #include "xfa/fxfa/app/xfa_ffbarcode.h" +#include <utility> + #include "core/fxcrt/fx_ext.h" +#include "third_party/base/ptr_util.h" #include "xfa/fwl/cfwl_app.h" #include "xfa/fwl/cfwl_barcode.h" #include "xfa/fwl/cfwl_notedriver.h" @@ -122,14 +125,15 @@ CXFA_FFBarcode::CXFA_FFBarcode(CXFA_WidgetAcc* pDataAcc) CXFA_FFBarcode::~CXFA_FFBarcode() {} bool CXFA_FFBarcode::LoadWidget() { - CFWL_Barcode* pFWLBarcode = new CFWL_Barcode(GetFWLApp()); - - m_pNormalWidget = pFWLBarcode; + auto pNew = pdfium::MakeUnique<CFWL_Barcode>(GetFWLApp()); + CFWL_Barcode* pFWLBarcode = pNew.get(); + m_pNormalWidget = std::move(pNew); m_pNormalWidget->SetLayoutItem(this); + CFWL_NoteDriver* pNoteDriver = m_pNormalWidget->GetOwnerApp()->GetNoteDriver(); - pNoteDriver->RegisterEventTarget(m_pNormalWidget, m_pNormalWidget); - + pNoteDriver->RegisterEventTarget(m_pNormalWidget.get(), + m_pNormalWidget.get()); m_pOldDelegate = m_pNormalWidget->GetDelegate(); m_pNormalWidget->SetDelegate(this); m_pNormalWidget->LockUpdate(); @@ -141,6 +145,7 @@ bool CXFA_FFBarcode::LoadWidget() { m_pNormalWidget->UnlockUpdate(); return CXFA_FFField::LoadWidget(); } + void CXFA_FFBarcode::RenderWidget(CFX_Graphics* pGS, CFX_Matrix* pMatrix, uint32_t dwStatus) { @@ -164,7 +169,7 @@ void CXFA_FFBarcode::RenderWidget(CFX_Graphics* pGS, void CXFA_FFBarcode::UpdateWidgetProperty() { CXFA_FFTextEdit::UpdateWidgetProperty(); - CFWL_Barcode* pBarCodeWidget = (CFWL_Barcode*)m_pNormalWidget; + auto* pBarCodeWidget = static_cast<CFWL_Barcode*>(m_pNormalWidget.get()); CFX_WideString wsType = GetDataAcc()->GetBarcodeType(); const XFA_BARCODETYPEENUMINFO* pBarcodeTypeInfo = XFA_GetBarcodeTypeByName(wsType.AsStringC()); @@ -222,7 +227,7 @@ void CXFA_FFBarcode::UpdateWidgetProperty() { } bool CXFA_FFBarcode::OnLButtonDown(uint32_t dwFlags, const CFX_PointF& point) { - CFWL_Barcode* pBarCodeWidget = (CFWL_Barcode*)m_pNormalWidget; + auto* pBarCodeWidget = static_cast<CFWL_Barcode*>(m_pNormalWidget.get()); if (!pBarCodeWidget || pBarCodeWidget->IsProtectedType()) return false; if (m_pDataAcc->GetAccess() != XFA_ATTRIBUTEENUM_Open) @@ -231,7 +236,7 @@ bool CXFA_FFBarcode::OnLButtonDown(uint32_t dwFlags, const CFX_PointF& point) { } bool CXFA_FFBarcode::OnRButtonDown(uint32_t dwFlags, const CFX_PointF& point) { - CFWL_Barcode* pBarCodeWidget = (CFWL_Barcode*)m_pNormalWidget; + auto* pBarCodeWidget = static_cast<CFWL_Barcode*>(m_pNormalWidget.get()); if (!pBarCodeWidget || pBarCodeWidget->IsProtectedType()) return false; return CXFA_FFTextEdit::OnRButtonDown(dwFlags, point); |