diff options
author | Tom Sepez <tsepez@chromium.org> | 2018-07-02 16:44:02 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2018-07-02 16:44:02 +0000 |
commit | e353d72449a9298410dc479bf27410d83e56b215 (patch) | |
tree | 814ace49b09aeb0ba440550b1b29fbe4af8b6ea6 | |
parent | 09646f2d0497eb4cdcf2f3843585faa9264196f4 (diff) | |
download | pdfium-e353d72449a9298410dc479bf27410d83e56b215.tar.xz |
Use UnownedPtr<> in cfwl_event.h and cfwl_message.h
Change-Id: I1981eb23006db203e845e954a7847cfa992d5e03
Reviewed-on: https://pdfium-review.googlesource.com/36710
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
-rw-r--r-- | xfa/fwl/cfwl_combolist.cpp | 2 | ||||
-rw-r--r-- | xfa/fwl/cfwl_datetimepicker.cpp | 4 | ||||
-rw-r--r-- | xfa/fwl/cfwl_edit.cpp | 2 | ||||
-rw-r--r-- | xfa/fwl/cfwl_event.cpp | 9 | ||||
-rw-r--r-- | xfa/fwl/cfwl_event.h | 9 | ||||
-rw-r--r-- | xfa/fwl/cfwl_eventtarget.cpp | 2 | ||||
-rw-r--r-- | xfa/fwl/cfwl_listbox.cpp | 2 | ||||
-rw-r--r-- | xfa/fwl/cfwl_message.cpp | 11 | ||||
-rw-r--r-- | xfa/fwl/cfwl_message.h | 14 | ||||
-rw-r--r-- | xfa/fwl/cfwl_notedriver.cpp | 33 | ||||
-rw-r--r-- | xfa/fwl/cfwl_widget.cpp | 5 | ||||
-rw-r--r-- | xfa/fwl/cfwl_widgetmgr.cpp | 5 |
12 files changed, 53 insertions, 45 deletions
diff --git a/xfa/fwl/cfwl_combolist.cpp b/xfa/fwl/cfwl_combolist.cpp index 1180acf5c8..004fbb46b9 100644 --- a/xfa/fwl/cfwl_combolist.cpp +++ b/xfa/fwl/cfwl_combolist.cpp @@ -208,7 +208,7 @@ bool CFWL_ComboList::OnDropListKey(CFWL_MessageKey* pKey) { bPropagate = true; } if (bPropagate) { - pKey->m_pDstTarget = m_pOuter; + pKey->SetDstTarget(m_pOuter); pOuter->GetDelegate()->OnProcessMessage(pKey); return true; } diff --git a/xfa/fwl/cfwl_datetimepicker.cpp b/xfa/fwl/cfwl_datetimepicker.cpp index f5afbf6eaa..8c37e1dbe8 100644 --- a/xfa/fwl/cfwl_datetimepicker.cpp +++ b/xfa/fwl/cfwl_datetimepicker.cpp @@ -395,7 +395,7 @@ void CFWL_DateTimePicker::OnFocusChanged(CFWL_Message* pMsg, bool bSet) { m_pProperties->m_rtWidget.height - 1); } rtInvalidate = m_rtBtn; - pMsg->m_pDstTarget = m_pEdit.get(); + pMsg->SetDstTarget(m_pEdit.get()); m_pEdit->GetDelegate()->OnProcessMessage(pMsg); } else { m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Focused; @@ -404,7 +404,7 @@ void CFWL_DateTimePicker::OnFocusChanged(CFWL_Message* pMsg, bool bSet) { if (IsMonthCalendarVisible()) ShowMonthCalendar(false); if (m_pEdit->GetStates() & FWL_WGTSTATE_Focused) { - pMsg->m_pSrcTarget = m_pEdit.get(); + pMsg->SetSrcTarget(m_pEdit.get()); m_pEdit->GetDelegate()->OnProcessMessage(pMsg); } } diff --git a/xfa/fwl/cfwl_edit.cpp b/xfa/fwl/cfwl_edit.cpp index 623cf4e956..fc6ce094ea 100644 --- a/xfa/fwl/cfwl_edit.cpp +++ b/xfa/fwl/cfwl_edit.cpp @@ -1068,7 +1068,7 @@ void CFWL_Edit::OnProcessEvent(CFWL_Event* pEvent) { if (!pEvent || pEvent->GetType() != CFWL_Event::Type::Scroll) return; - CFWL_Widget* pSrcTarget = pEvent->m_pSrcTarget; + CFWL_Widget* pSrcTarget = pEvent->GetSrcTarget(); if ((pSrcTarget == m_pVertScrollBar.get() && m_pVertScrollBar) || (pSrcTarget == m_pHorzScrollBar.get() && m_pHorzScrollBar)) { CFWL_EventScroll* pScrollEvent = static_cast<CFWL_EventScroll*>(pEvent); diff --git a/xfa/fwl/cfwl_event.cpp b/xfa/fwl/cfwl_event.cpp index 827ecccc10..5922bc1982 100644 --- a/xfa/fwl/cfwl_event.cpp +++ b/xfa/fwl/cfwl_event.cpp @@ -6,15 +6,14 @@ #include "xfa/fwl/cfwl_event.h" -CFWL_Event::CFWL_Event(CFWL_Event::Type type) - : CFWL_Event(type, nullptr, nullptr) {} +CFWL_Event::CFWL_Event(CFWL_Event::Type type) : m_type(type) {} CFWL_Event::CFWL_Event(Type type, CFWL_Widget* pSrcTarget) - : CFWL_Event(type, pSrcTarget, nullptr) {} + : m_type(type), m_pSrcTarget(pSrcTarget) {} CFWL_Event::CFWL_Event(Type type, CFWL_Widget* pSrcTarget, CFWL_Widget* pDstTarget) - : m_pSrcTarget(pSrcTarget), m_pDstTarget(pDstTarget), m_type(type) {} + : m_type(type), m_pSrcTarget(pSrcTarget), m_pDstTarget(pDstTarget) {} -CFWL_Event::~CFWL_Event() {} +CFWL_Event::~CFWL_Event() = default; diff --git a/xfa/fwl/cfwl_event.h b/xfa/fwl/cfwl_event.h index 8546447209..0c4d23efd3 100644 --- a/xfa/fwl/cfwl_event.h +++ b/xfa/fwl/cfwl_event.h @@ -39,12 +39,13 @@ class CFWL_Event { virtual ~CFWL_Event(); Type GetType() const { return m_type; } - - CFWL_Widget* m_pSrcTarget; - CFWL_Widget* m_pDstTarget; + CFWL_Widget* GetSrcTarget() const { return m_pSrcTarget.Get(); } + CFWL_Widget* GetDstTarget() const { return m_pDstTarget.Get(); } private: - Type m_type; + const Type m_type; + UnownedPtr<CFWL_Widget> const m_pSrcTarget; + UnownedPtr<CFWL_Widget> const m_pDstTarget; }; #endif // XFA_FWL_CFWL_EVENT_H_ diff --git a/xfa/fwl/cfwl_eventtarget.cpp b/xfa/fwl/cfwl_eventtarget.cpp index 8a3b78799b..d6a717d0d2 100644 --- a/xfa/fwl/cfwl_eventtarget.cpp +++ b/xfa/fwl/cfwl_eventtarget.cpp @@ -23,7 +23,7 @@ bool CFWL_EventTarget::ProcessEvent(CFWL_Event* pEvent) { IFWL_WidgetDelegate* pDelegate = m_pListener->GetDelegate(); if (!pDelegate) return false; - if (!m_widgets.empty() && m_widgets.count(pEvent->m_pSrcTarget) == 0) + if (!m_widgets.empty() && m_widgets.count(pEvent->GetSrcTarget()) == 0) return false; pDelegate->OnProcessEvent(pEvent); diff --git a/xfa/fwl/cfwl_listbox.cpp b/xfa/fwl/cfwl_listbox.cpp index 5f683d3e11..445d81ceb7 100644 --- a/xfa/fwl/cfwl_listbox.cpp +++ b/xfa/fwl/cfwl_listbox.cpp @@ -702,7 +702,7 @@ void CFWL_ListBox::OnProcessEvent(CFWL_Event* pEvent) { if (pEvent->GetType() != CFWL_Event::Type::Scroll) return; - CFWL_Widget* pSrcTarget = pEvent->m_pSrcTarget; + CFWL_Widget* pSrcTarget = pEvent->GetSrcTarget(); if ((pSrcTarget == m_pVertScrollBar.get() && m_pVertScrollBar) || (pSrcTarget == m_pHorzScrollBar.get() && m_pHorzScrollBar)) { CFWL_EventScroll* pScrollEvent = static_cast<CFWL_EventScroll*>(pEvent); diff --git a/xfa/fwl/cfwl_message.cpp b/xfa/fwl/cfwl_message.cpp index 258fe62060..7411c24bd7 100644 --- a/xfa/fwl/cfwl_message.cpp +++ b/xfa/fwl/cfwl_message.cpp @@ -6,18 +6,19 @@ #include "xfa/fwl/cfwl_message.h" -CFWL_Message::CFWL_Message(CFWL_Message::Type type) - : CFWL_Message(type, nullptr, nullptr) {} +CFWL_Message::CFWL_Message(CFWL_Message::Type type) : m_type(type) {} CFWL_Message::CFWL_Message(Type type, CFWL_Widget* pSrcTarget) - : CFWL_Message(type, pSrcTarget, nullptr) {} + : m_type(type), m_pSrcTarget(pSrcTarget) {} CFWL_Message::CFWL_Message(Type type, CFWL_Widget* pSrcTarget, CFWL_Widget* pDstTarget) - : m_pSrcTarget(pSrcTarget), m_pDstTarget(pDstTarget), m_type(type) {} + : m_type(type), m_pSrcTarget(pSrcTarget), m_pDstTarget(pDstTarget) {} -CFWL_Message::~CFWL_Message() {} +CFWL_Message::CFWL_Message(const CFWL_Message& that) = default; + +CFWL_Message::~CFWL_Message() = default; std::unique_ptr<CFWL_Message> CFWL_Message::Clone() { return nullptr; diff --git a/xfa/fwl/cfwl_message.h b/xfa/fwl/cfwl_message.h index 99cf01b5b8..2d97895cc8 100644 --- a/xfa/fwl/cfwl_message.h +++ b/xfa/fwl/cfwl_message.h @@ -11,6 +11,7 @@ #include "core/fxcrt/fx_string.h" #include "core/fxcrt/fx_system.h" +#include "core/fxcrt/unowned_ptr.h" class CFWL_Widget; @@ -21,16 +22,21 @@ class CFWL_Message { explicit CFWL_Message(Type type); CFWL_Message(Type type, CFWL_Widget* pSrcTarget); CFWL_Message(Type type, CFWL_Widget* pSrcTarget, CFWL_Widget* pDstTarget); + CFWL_Message(const CFWL_Message& that); virtual ~CFWL_Message(); virtual std::unique_ptr<CFWL_Message> Clone(); - Type GetType() const { return m_type; } - CFWL_Widget* m_pSrcTarget; - CFWL_Widget* m_pDstTarget; + Type GetType() const { return m_type; } + CFWL_Widget* GetSrcTarget() const { return m_pSrcTarget.Get(); } + CFWL_Widget* GetDstTarget() const { return m_pDstTarget.Get(); } + void SetSrcTarget(CFWL_Widget* pWidget) { m_pSrcTarget = pWidget; } + void SetDstTarget(CFWL_Widget* pWidget) { m_pDstTarget = pWidget; } private: - Type m_type; + const Type m_type; + UnownedPtr<CFWL_Widget> m_pSrcTarget; + UnownedPtr<CFWL_Widget> m_pDstTarget; }; #endif // XFA_FWL_CFWL_MESSAGE_H_ diff --git a/xfa/fwl/cfwl_notedriver.cpp b/xfa/fwl/cfwl_notedriver.cpp index f585625882..e33a423086 100644 --- a/xfa/fwl/cfwl_notedriver.cpp +++ b/xfa/fwl/cfwl_notedriver.cpp @@ -185,7 +185,7 @@ CFWL_NoteLoop* CFWL_NoteDriver::GetTopLoop() const { } void CFWL_NoteDriver::ProcessMessage(std::unique_ptr<CFWL_Message> pMessage) { - CFWL_Widget* pMessageForm = pMessage->m_pDstTarget; + CFWL_Widget* pMessageForm = pMessage->GetDstTarget(); if (!pMessageForm) return; @@ -227,7 +227,8 @@ bool CFWL_NoteDriver::DispatchMessage(CFWL_Message* pMessage, default: break; } - if (IFWL_WidgetDelegate* pDelegate = pMessage->m_pDstTarget->GetDelegate()) + IFWL_WidgetDelegate* pDelegate = pMessage->GetDstTarget()->GetDelegate(); + if (pDelegate) pDelegate->OnProcessMessage(pMessage); return true; @@ -235,13 +236,13 @@ bool CFWL_NoteDriver::DispatchMessage(CFWL_Message* pMessage, bool CFWL_NoteDriver::DoSetFocus(CFWL_Message* pMessage, CFWL_Widget* pMessageForm) { - m_pFocus = pMessage->m_pDstTarget; + m_pFocus = pMessage->GetDstTarget(); return true; } bool CFWL_NoteDriver::DoKillFocus(CFWL_Message* pMessage, CFWL_Widget* pMessageForm) { - if (m_pFocus == pMessage->m_pDstTarget) + if (m_pFocus == pMessage->GetDstTarget()) m_pFocus = nullptr; return true; } @@ -252,7 +253,7 @@ bool CFWL_NoteDriver::DoKey(CFWL_Message* pMessage, CFWL_Widget* pMessageForm) { if (pMsg->m_dwCmd == FWL_KeyCommand::KeyDown && pMsg->m_dwKeyCode == FWL_VKEY_Tab) { CFWL_WidgetMgr* pWidgetMgr = pMessageForm->GetOwnerApp()->GetWidgetMgr(); - CFWL_Widget* pForm = GetMessageForm(pMsg->m_pDstTarget); + CFWL_Widget* pForm = GetMessageForm(pMsg->GetDstTarget()); CFWL_Widget* pFocus = m_pFocus; if (m_pFocus && pWidgetMgr->GetSystemFormWidget(m_pFocus) != pForm) pFocus = nullptr; @@ -277,13 +278,13 @@ bool CFWL_NoteDriver::DoKey(CFWL_Message* pMessage, CFWL_Widget* pMessageForm) { CFWL_WidgetMgr* pWidgetMgr = pMessageForm->GetOwnerApp()->GetWidgetMgr(); CFWL_Widget* defButton = pWidgetMgr->GetDefaultButton(pMessageForm); if (defButton) { - pMsg->m_pDstTarget = defButton; + pMsg->SetDstTarget(defButton); return true; } } return false; } - pMsg->m_pDstTarget = m_pFocus; + pMsg->SetDstTarget(m_pFocus); return true; } @@ -293,12 +294,12 @@ bool CFWL_NoteDriver::DoMouse(CFWL_Message* pMessage, if (pMsg->m_dwCmd == FWL_MouseCommand::Leave || pMsg->m_dwCmd == FWL_MouseCommand::Hover || pMsg->m_dwCmd == FWL_MouseCommand::Enter) { - return !!pMsg->m_pDstTarget; + return !!pMsg->GetDstTarget(); } - if (pMsg->m_pDstTarget != pMessageForm) - pMsg->m_pos = pMsg->m_pDstTarget->TransformTo(pMessageForm, pMsg->m_pos); + if (pMsg->GetDstTarget() != pMessageForm) + pMsg->m_pos = pMsg->GetDstTarget()->TransformTo(pMessageForm, pMsg->m_pos); if (!DoMouseEx(pMsg, pMessageForm)) - pMsg->m_pDstTarget = pMessageForm; + pMsg->SetDstTarget(pMessageForm); return true; } @@ -314,7 +315,7 @@ bool CFWL_NoteDriver::DoWheel(CFWL_Message* pMessage, return false; pMsg->m_pos = pMessageForm->TransformTo(pDst, pMsg->m_pos); - pMsg->m_pDstTarget = pDst; + pMsg->SetDstTarget(pDst); return true; } @@ -335,12 +336,12 @@ bool CFWL_NoteDriver::DoMouseEx(CFWL_Message* pMessage, if (pTarget && pMessageForm != pTarget) pMsg->m_pos = pMessageForm->TransformTo(pTarget, pMsg->m_pos); - pMsg->m_pDstTarget = pTarget; + pMsg->SetDstTarget(pTarget); return true; } void CFWL_NoteDriver::MouseSecondary(CFWL_Message* pMessage) { - CFWL_Widget* pTarget = pMessage->m_pDstTarget; + CFWL_Widget* pTarget = pMessage->GetDstTarget(); if (pTarget == m_pHover) return; @@ -368,12 +369,12 @@ void CFWL_NoteDriver::MouseSecondary(CFWL_Message* pMessage) { bool CFWL_NoteDriver::IsValidMessage(CFWL_Message* pMessage) { for (CFWL_NoteLoop* pNoteLoop : m_NoteLoopQueue) { CFWL_Widget* pForm = pNoteLoop->GetForm(); - if (pForm && pForm == pMessage->m_pDstTarget) + if (pForm && pForm == pMessage->GetDstTarget()) return true; } for (CFWL_Widget* pWidget : m_Forms) { CFWL_Form* pForm = static_cast<CFWL_Form*>(pWidget); - if (pForm == pMessage->m_pDstTarget) + if (pForm == pMessage->GetDstTarget()) return true; } return false; diff --git a/xfa/fwl/cfwl_widget.cpp b/xfa/fwl/cfwl_widget.cpp index 4ebce30818..d0dbab10d5 100644 --- a/xfa/fwl/cfwl_widget.cpp +++ b/xfa/fwl/cfwl_widget.cpp @@ -448,14 +448,13 @@ bool CFWL_Widget::IsParent(CFWL_Widget* pParent) { } void CFWL_Widget::OnProcessMessage(CFWL_Message* pMessage) { - if (!pMessage->m_pDstTarget) + CFWL_Widget* pWidget = pMessage->GetDstTarget(); + if (!pWidget) return; - CFWL_Widget* pWidget = pMessage->m_pDstTarget; switch (pMessage->GetType()) { case CFWL_Message::Type::Mouse: { CFWL_MessageMouse* pMsgMouse = static_cast<CFWL_MessageMouse*>(pMessage); - CFWL_EventMouse evt(pWidget, pWidget); evt.m_dwCmd = pMsgMouse->m_dwCmd; pWidget->DispatchEvent(&evt); diff --git a/xfa/fwl/cfwl_widgetmgr.cpp b/xfa/fwl/cfwl_widgetmgr.cpp index f19479e72b..adbc895cff 100644 --- a/xfa/fwl/cfwl_widgetmgr.cpp +++ b/xfa/fwl/cfwl_widgetmgr.cpp @@ -358,10 +358,11 @@ void CFWL_WidgetMgr::GetAdapterPopupPos(CFWL_Widget* pWidget, void CFWL_WidgetMgr::OnProcessMessageToForm(CFWL_Message* pMessage) { if (!pMessage) return; - if (!pMessage->m_pDstTarget) + + CFWL_Widget* pDstWidget = pMessage->GetDstTarget(); + if (!pDstWidget) return; - CFWL_Widget* pDstWidget = pMessage->m_pDstTarget; const CFWL_App* pApp = pDstWidget->GetOwnerApp(); if (!pApp) return; |