From 7c40157c9d8d72b91dcde3e79f2a083e4319e2eb Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Thu, 4 Oct 2018 19:15:30 +0000 Subject: Remove CPWL_EditCtrl::m_pEdit null checks. It is always non-null. Move initializers to header while we're at it. Change-Id: I64f59ab1d5ffee9256f87e4712e46fb71f14ef08 Reviewed-on: https://pdfium-review.googlesource.com/c/43473 Reviewed-by: Lei Zhang Commit-Queue: Tom Sepez --- fpdfsdk/pwl/cpwl_edit_ctrl.cpp | 18 ++++-------------- fpdfsdk/pwl/cpwl_edit_ctrl.h | 13 +++++-------- 2 files changed, 9 insertions(+), 22 deletions(-) (limited to 'fpdfsdk/pwl') diff --git a/fpdfsdk/pwl/cpwl_edit_ctrl.cpp b/fpdfsdk/pwl/cpwl_edit_ctrl.cpp index 579a587175..33a83cc349 100644 --- a/fpdfsdk/pwl/cpwl_edit_ctrl.cpp +++ b/fpdfsdk/pwl/cpwl_edit_ctrl.cpp @@ -14,14 +14,11 @@ #include "fpdfsdk/pwl/cpwl_scroll_bar.h" #include "fpdfsdk/pwl/cpwl_wnd.h" #include "public/fpdf_fwlevent.h" +#include "third_party/base/ptr_util.h" -CPWL_EditCtrl::CPWL_EditCtrl() - : m_pEdit(new CPWL_EditImpl), - m_pEditCaret(nullptr), - m_bMouseDown(false), - m_nCharSet(FX_CHARSET_Default) {} +CPWL_EditCtrl::CPWL_EditCtrl() : m_pEdit(pdfium::MakeUnique()) {} -CPWL_EditCtrl::~CPWL_EditCtrl() {} +CPWL_EditCtrl::~CPWL_EditCtrl() = default; void CPWL_EditCtrl::OnCreate(CreateParams* pParamsToAdjust) { pParamsToAdjust->eCursorType = FXCT_VBEAM; @@ -29,7 +26,6 @@ void CPWL_EditCtrl::OnCreate(CreateParams* pParamsToAdjust) { void CPWL_EditCtrl::OnCreated() { SetFontSize(GetCreationParams().fFontSize); - m_pEdit->SetFontMap(GetFontMap()); m_pEdit->SetNotify(this); m_pEdit->Initialize(); @@ -52,16 +48,10 @@ void CPWL_EditCtrl::SetCursor() { } WideString CPWL_EditCtrl::GetSelectedText() { - if (m_pEdit) - return m_pEdit->GetSelectedText(); - - return WideString(); + return m_pEdit->GetSelectedText(); } void CPWL_EditCtrl::ReplaceSelection(const WideString& text) { - if (!m_pEdit) - return; - m_pEdit->ClearSelection(); m_pEdit->InsertText(text, FX_CHARSET_Default); } diff --git a/fpdfsdk/pwl/cpwl_edit_ctrl.h b/fpdfsdk/pwl/cpwl_edit_ctrl.h index a21c8a2700..741ce9c668 100644 --- a/fpdfsdk/pwl/cpwl_edit_ctrl.h +++ b/fpdfsdk/pwl/cpwl_edit_ctrl.h @@ -9,6 +9,7 @@ #include +#include "core/fxcrt/fx_codepage.h" #include "core/fxcrt/fx_string.h" #include "fpdfsdk/pwl/cpwl_wnd.h" @@ -73,24 +74,20 @@ class CPWL_EditCtrl : public CPWL_Wnd { void CutText(); void InsertWord(uint16_t word, int32_t nCharset); void InsertReturn(); - bool IsWndHorV(); - void Delete(); void Backspace(); - void GetCaretInfo(CFX_PointF* ptHead, CFX_PointF* ptFoot) const; - void SetEditCaret(bool bVisible); - std::unique_ptr m_pEdit; - CPWL_Caret* m_pEditCaret; - bool m_bMouseDown; + std::unique_ptr const m_pEdit; + CPWL_Caret* m_pEditCaret = nullptr; + bool m_bMouseDown = false; private: void CreateEditCaret(const CreateParams& cp); - int32_t m_nCharSet; + int32_t m_nCharSet = FX_CHARSET_Default; }; #endif // FPDFSDK_PWL_CPWL_EDIT_CTRL_H_ -- cgit v1.2.3