From 6dc4fb899acfee6261a44cde8015b5c8f3eb75a3 Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Tue, 17 Oct 2017 09:08:26 -0400 Subject: Remove friends from PWL classes This CL removes the friend entries from the various pwl/ classes. Change-Id: Ib93a2bedcde521eb92e53580b5d7cd9bca08902f Reviewed-on: https://pdfium-review.googlesource.com/16150 Reviewed-by: Ryan Harrison Commit-Queue: dsinclair --- fpdfsdk/pwl/cpwl_edit_impl.h | 42 ++++++++++++++++-------------------------- fpdfsdk/pwl/cpwl_wnd.cpp | 28 +++++----------------------- fpdfsdk/pwl/cpwl_wnd.h | 8 +++----- 3 files changed, 24 insertions(+), 54 deletions(-) diff --git a/fpdfsdk/pwl/cpwl_edit_impl.h b/fpdfsdk/pwl/cpwl_edit_impl.h index 11edae6180..387f6e700d 100644 --- a/fpdfsdk/pwl/cpwl_edit_impl.h +++ b/fpdfsdk/pwl/cpwl_edit_impl.h @@ -362,17 +362,22 @@ class CPWL_EditImpl { uint16_t Word, uint16_t SubWord); - private: - friend class CPWL_EditImpl_Iterator; - friend class CFXEU_InsertWord; - friend class CFXEU_InsertReturn; - friend class CFXEU_Backspace; - friend class CFXEU_Delete; - friend class CFXEU_Clear; - friend class CFXEU_InsertText; - void SetSelection(const CPVT_WordPlace& begin, const CPVT_WordPlace& end); + bool Delete(bool bAddUndo, bool bPaint); + bool Clear(bool bAddUndo, bool bPaint); + bool InsertText(const WideString& sText, + int32_t charset, + bool bAddUndo, + bool bPaint); + bool InsertWord(uint16_t word, int32_t charset, bool bAddUndo, bool bPaint); + bool InsertReturn(bool bAddUndo, bool bPaint); + bool Backspace(bool bAddUndo, bool bPaint); + void SetCaret(const CPVT_WordPlace& place); + + CFX_PointF VTToEdit(const CFX_PointF& point) const; + + private: void RearrangeAll(); void RearrangePart(const CPVT_WordRange& range); void ScrollToCaret(); @@ -382,35 +387,20 @@ class CPWL_EditImpl { void SetScrollLimit(); void SetContentChanged(); - bool InsertWord(uint16_t word, - int32_t charset, - bool bAddUndo, - bool bPaint); - bool InsertReturn(bool bAddUndo, bool bPaint); - bool Backspace(bool bAddUndo, bool bPaint); - bool Delete(bool bAddUndo, bool bPaint); - bool Clear(bool bAddUndo, bool bPaint); - bool InsertText(const WideString& sText, - int32_t charset, - bool bAddUndo, - bool bPaint); void PaintInsertText(const CPVT_WordPlace& wpOld, const CPVT_WordPlace& wpNew); - inline CFX_PointF VTToEdit(const CFX_PointF& point) const; - inline CFX_PointF EditToVT(const CFX_PointF& point) const; - inline CFX_FloatRect VTToEdit(const CFX_FloatRect& rect) const; + CFX_PointF EditToVT(const CFX_PointF& point) const; + CFX_FloatRect VTToEdit(const CFX_FloatRect& rect) const; void Refresh(); void RefreshPushLineRects(const CPVT_WordRange& wr); - void SetCaret(const CPVT_WordPlace& place); void SetCaretInfo(); void SetCaretOrigin(); void AddEditUndoItem(std::unique_ptr pEditUndoItem); - private: std::unique_ptr m_pVT; UnownedPtr m_pNotify; UnownedPtr m_pOperationNotify; diff --git a/fpdfsdk/pwl/cpwl_wnd.cpp b/fpdfsdk/pwl/cpwl_wnd.cpp index ec605a3844..368db74ec4 100644 --- a/fpdfsdk/pwl/cpwl_wnd.cpp +++ b/fpdfsdk/pwl/cpwl_wnd.cpp @@ -47,31 +47,14 @@ CPWL_Wnd::CreateParams::CreateParams(const CreateParams& other) = default; CPWL_Wnd::CreateParams::~CreateParams() = default; class CPWL_MsgControl : public Observable { - friend class CPWL_Wnd; - public: - explicit CPWL_MsgControl(CPWL_Wnd* pWnd) { - m_pCreatedWnd = pWnd; - Default(); - } - - ~CPWL_MsgControl() { Default(); } - - void Default() { - m_aMousePath.clear(); - m_aKeyboardPath.clear(); - m_pMainMouseWnd = nullptr; - m_pMainKeyboardWnd = nullptr; - } + explicit CPWL_MsgControl(CPWL_Wnd* pWnd) : m_pCreatedWnd(pWnd) {} + ~CPWL_MsgControl() {} bool IsWndCreated(const CPWL_Wnd* pWnd) const { return m_pCreatedWnd == pWnd; } - bool IsMainCaptureMouse(const CPWL_Wnd* pWnd) const { - return pWnd == m_pMainMouseWnd; - } - bool IsWndCaptureMouse(const CPWL_Wnd* pWnd) const { return pWnd && pdfium::ContainsValue(m_aMousePath, pWnd); } @@ -114,7 +97,6 @@ class CPWL_MsgControl : public Observable { void SetCapture(CPWL_Wnd* pWnd) { m_aMousePath.clear(); if (pWnd) { - m_pMainMouseWnd = pWnd; CPWL_Wnd* pParent = pWnd; while (pParent) { m_aMousePath.push_back(pParent); @@ -124,15 +106,15 @@ class CPWL_MsgControl : public Observable { } void ReleaseCapture() { - m_pMainMouseWnd = nullptr; m_aMousePath.clear(); } + CPWL_Wnd* GetFocusedWindow() const { return m_pMainKeyboardWnd.Get(); } + private: std::vector m_aMousePath; std::vector m_aKeyboardPath; UnownedPtr m_pCreatedWnd; - UnownedPtr m_pMainMouseWnd; UnownedPtr m_pMainKeyboardWnd; }; @@ -804,7 +786,7 @@ void CPWL_Wnd::SetChildMatrix(const CFX_Matrix& mt) { const CPWL_Wnd* CPWL_Wnd::GetFocused() const { CPWL_MsgControl* pMsgCtrl = GetMsgControl(); - return pMsgCtrl ? pMsgCtrl->m_pMainKeyboardWnd.Get() : nullptr; + return pMsgCtrl ? pMsgCtrl->GetFocusedWindow() : nullptr; } void CPWL_Wnd::EnableWindow(bool bEnable) { diff --git a/fpdfsdk/pwl/cpwl_wnd.h b/fpdfsdk/pwl/cpwl_wnd.h index a9a434dbd1..ba52420ade 100644 --- a/fpdfsdk/pwl/cpwl_wnd.h +++ b/fpdfsdk/pwl/cpwl_wnd.h @@ -249,9 +249,10 @@ class CPWL_Wnd : public CPWL_TimerHandler, public Observable { void SetChildMatrix(const CFX_Matrix& mt); CFX_Matrix GetWindowMatrix() const; - protected: - friend class CPWL_MsgControl; + virtual void OnSetFocus(); + virtual void OnKillFocus(); + protected: // CPWL_TimerHandler CFX_SystemHandler* GetSystemHandler() const override; @@ -267,9 +268,6 @@ class CPWL_Wnd : public CPWL_TimerHandler, public Observable { virtual void OnCreated(); virtual void OnDestroy(); - virtual void OnSetFocus(); - virtual void OnKillFocus(); - void SetNotifyFlag(bool bNotifying = true) { m_bNotifying = bNotifying; } bool IsNotifying() const { return m_bNotifying; } bool IsValid() const { return m_bCreated; } -- cgit v1.2.3