diff options
author | Tom Sepez <tsepez@chromium.org> | 2017-03-22 13:24:18 -0700 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-03-22 20:39:38 +0000 |
commit | 29bd35451003e58ef4be06413cce5544c16c395d (patch) | |
tree | 710bacc1f382d150f33a692412c6792f2d932ba0 | |
parent | 3ae3033bff2582029984f91f40f4a8b748a30c96 (diff) | |
download | pdfium-29bd35451003e58ef4be06413cce5544c16c395d.tar.xz |
Use unique_ptr in xfa_ffpushbutton.h
Change-Id: I605c1219b1090eb13d22237fa1d61d9defe137d5
Reviewed-on: https://pdfium-review.googlesource.com/3151
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Commit-Queue: dsinclair <dsinclair@chromium.org>
Reviewed-by: dsinclair <dsinclair@chromium.org>
-rw-r--r-- | xfa/fxfa/app/xfa_ffpushbutton.cpp | 62 | ||||
-rw-r--r-- | xfa/fxfa/app/xfa_ffpushbutton.h | 10 |
2 files changed, 35 insertions, 37 deletions
diff --git a/xfa/fxfa/app/xfa_ffpushbutton.cpp b/xfa/fxfa/app/xfa_ffpushbutton.cpp index 7989e3207d..2233c5a6bb 100644 --- a/xfa/fxfa/app/xfa_ffpushbutton.cpp +++ b/xfa/fxfa/app/xfa_ffpushbutton.cpp @@ -19,12 +19,7 @@ #include "xfa/fxgraphics/cfx_path.h" CXFA_FFPushButton::CXFA_FFPushButton(CXFA_WidgetAcc* pDataAcc) - : CXFA_FFField(pDataAcc), - m_pRolloverTextLayout(nullptr), - m_pDownTextLayout(nullptr), - m_pDownProvider(nullptr), - m_pRollProvider(nullptr), - m_pOldDelegate(nullptr) {} + : CXFA_FFField(pDataAcc), m_pOldDelegate(nullptr) {} CXFA_FFPushButton::~CXFA_FFPushButton() { CXFA_FFPushButton::UnloadWidget(); @@ -86,14 +81,10 @@ void CXFA_FFPushButton::UpdateWidgetProperty() { } void CXFA_FFPushButton::UnloadWidget() { - delete m_pRolloverTextLayout; - m_pRolloverTextLayout = nullptr; - delete m_pDownTextLayout; - m_pDownTextLayout = nullptr; - delete m_pDownProvider; - m_pDownProvider = nullptr; - delete m_pRollProvider; - m_pRollProvider = nullptr; + m_pRolloverTextLayout.reset(); + m_pDownTextLayout.reset(); + m_pRollProvider.reset(); + m_pDownProvider.reset(); CXFA_FFField::UnloadWidget(); } @@ -125,36 +116,41 @@ float CXFA_FFPushButton::GetLineWidth() { } return 0; } + FX_ARGB CXFA_FFPushButton::GetLineColor() { return 0xFF000000; } + FX_ARGB CXFA_FFPushButton::GetFillColor() { return 0xFFFFFFFF; } + void CXFA_FFPushButton::LoadHighlightCaption() { CXFA_Caption caption = m_pDataAcc->GetCaption(); - if (caption && caption.GetPresence() != XFA_ATTRIBUTEENUM_Hidden) { - { - CFX_WideString wsRollover; - bool bRichText; - if (m_pDataAcc->GetButtonRollover(wsRollover, bRichText)) { - if (!m_pRollProvider) { - m_pRollProvider = - new CXFA_TextProvider(m_pDataAcc, XFA_TEXTPROVIDERTYPE_Rollover); - } - m_pRolloverTextLayout = new CXFA_TextLayout(m_pRollProvider); - } - CFX_WideString wsDown; - if (m_pDataAcc->GetButtonDown(wsDown, bRichText)) { - if (!m_pDownProvider) { - m_pDownProvider = - new CXFA_TextProvider(m_pDataAcc, XFA_TEXTPROVIDERTYPE_Down); - } - m_pDownTextLayout = new CXFA_TextLayout(m_pDownProvider); - } + if (!caption || caption.GetPresence() == XFA_ATTRIBUTEENUM_Hidden) + return; + + bool bRichText; + CFX_WideString wsRollover; + if (m_pDataAcc->GetButtonRollover(wsRollover, bRichText)) { + if (!m_pRollProvider) { + m_pRollProvider = pdfium::MakeUnique<CXFA_TextProvider>( + m_pDataAcc, XFA_TEXTPROVIDERTYPE_Rollover); + } + m_pRolloverTextLayout = + pdfium::MakeUnique<CXFA_TextLayout>(m_pRollProvider.get()); + } + CFX_WideString wsDown; + if (m_pDataAcc->GetButtonDown(wsDown, bRichText)) { + if (!m_pDownProvider) { + m_pDownProvider = pdfium::MakeUnique<CXFA_TextProvider>( + m_pDataAcc, XFA_TEXTPROVIDERTYPE_Down); } + m_pDownTextLayout = + pdfium::MakeUnique<CXFA_TextLayout>(m_pDownProvider.get()); } } + void CXFA_FFPushButton::LayoutHighlightCaption() { CFX_SizeF sz(m_rtCaption.width, m_rtCaption.height); LayoutCaption(); diff --git a/xfa/fxfa/app/xfa_ffpushbutton.h b/xfa/fxfa/app/xfa_ffpushbutton.h index 70853e8942..7e6e9e57d5 100644 --- a/xfa/fxfa/app/xfa_ffpushbutton.h +++ b/xfa/fxfa/app/xfa_ffpushbutton.h @@ -7,6 +7,8 @@ #ifndef XFA_FXFA_APP_XFA_FFPUSHBUTTON_H_ #define XFA_FXFA_APP_XFA_FFPUSHBUTTON_H_ +#include <memory> + #include "xfa/fxfa/app/xfa_fffield.h" #define XFA_FWL_PSBSTYLEEXT_HiliteNone (0L << 0) @@ -42,10 +44,10 @@ class CXFA_FFPushButton : public CXFA_FFField { FX_ARGB GetLineColor(); FX_ARGB GetFillColor(); - CXFA_TextLayout* m_pRolloverTextLayout; - CXFA_TextLayout* m_pDownTextLayout; - CXFA_TextProvider* m_pDownProvider; - CXFA_TextProvider* m_pRollProvider; + std::unique_ptr<CXFA_TextLayout> m_pRolloverTextLayout; + std::unique_ptr<CXFA_TextLayout> m_pDownTextLayout; + std::unique_ptr<CXFA_TextProvider> m_pRollProvider; + std::unique_ptr<CXFA_TextProvider> m_pDownProvider; IFWL_WidgetDelegate* m_pOldDelegate; }; |