diff options
Diffstat (limited to 'xfa/fwl')
-rw-r--r-- | xfa/fwl/cfwl_eventtarget.cpp | 2 | ||||
-rw-r--r-- | xfa/fwl/cfwl_eventtarget.h | 6 | ||||
-rw-r--r-- | xfa/fwl/cfwl_notedriver.cpp | 20 | ||||
-rw-r--r-- | xfa/fwl/cfwl_notedriver.h | 5 |
4 files changed, 13 insertions, 20 deletions
diff --git a/xfa/fwl/cfwl_eventtarget.cpp b/xfa/fwl/cfwl_eventtarget.cpp index 55f8e1fc78..8a3b78799b 100644 --- a/xfa/fwl/cfwl_eventtarget.cpp +++ b/xfa/fwl/cfwl_eventtarget.cpp @@ -10,7 +10,7 @@ #include "xfa/fwl/ifwl_widgetdelegate.h" CFWL_EventTarget::CFWL_EventTarget(CFWL_Widget* pListener) - : m_pListener(pListener), m_bInvalid(false) {} + : m_pListener(pListener), m_bValid(true) {} CFWL_EventTarget::~CFWL_EventTarget() {} diff --git a/xfa/fwl/cfwl_eventtarget.h b/xfa/fwl/cfwl_eventtarget.h index 1bca97232c..36d301df27 100644 --- a/xfa/fwl/cfwl_eventtarget.h +++ b/xfa/fwl/cfwl_eventtarget.h @@ -23,13 +23,13 @@ class CFWL_EventTarget { void SetEventSource(CFWL_Widget* pSource); bool ProcessEvent(CFWL_Event* pEvent); - bool IsInvalid() const { return m_bInvalid; } - void FlagInvalid() { m_bInvalid = true; } + bool IsValid() const { return m_bValid; } + void FlagInvalid() { m_bValid = false; } private: std::set<CFWL_Widget*> m_widgets; CFWL_Widget* m_pListener; - bool m_bInvalid; + bool m_bValid; }; #endif // XFA_FWL_CFWL_EVENTTARGET_H_ diff --git a/xfa/fwl/cfwl_notedriver.cpp b/xfa/fwl/cfwl_notedriver.cpp index 8feb0fb4e5..9012100c32 100644 --- a/xfa/fwl/cfwl_notedriver.cpp +++ b/xfa/fwl/cfwl_notedriver.cpp @@ -31,18 +31,12 @@ CFWL_NoteDriver::CFWL_NoteDriver() PushNoteLoop(m_pNoteLoop.get()); } -CFWL_NoteDriver::~CFWL_NoteDriver() { - ClearEventTargets(true); -} +CFWL_NoteDriver::~CFWL_NoteDriver() {} void CFWL_NoteDriver::SendEvent(CFWL_Event* pNote) { - if (m_eventTargets.empty()) - return; - for (const auto& pair : m_eventTargets) { - CFWL_EventTarget* pEventTarget = pair.second; - if (pEventTarget && !pEventTarget->IsInvalid()) - pEventTarget->ProcessEvent(pNote); + if (pair.second->IsValid()) + pair.second->ProcessEvent(pNote); } } @@ -56,7 +50,7 @@ void CFWL_NoteDriver::RegisterEventTarget(CFWL_Widget* pListener, pListener->SetEventKey(key); } if (!m_eventTargets[key]) - m_eventTargets[key] = new CFWL_EventTarget(pListener); + m_eventTargets[key] = pdfium::MakeUnique<CFWL_EventTarget>(pListener); m_eventTargets[key]->SetEventSource(pEventSource); } @@ -445,13 +439,11 @@ CFWL_Widget* CFWL_NoteDriver::GetMessageForm(CFWL_Widget* pDstTarget) { return pMessageForm; } -void CFWL_NoteDriver::ClearEventTargets(bool bRemoveAll) { +void CFWL_NoteDriver::ClearEventTargets() { auto it = m_eventTargets.begin(); while (it != m_eventTargets.end()) { auto old = it++; - if (old->second && (bRemoveAll || old->second->IsInvalid())) { - delete old->second; + if (!old->second->IsValid()) m_eventTargets.erase(old); - } } } diff --git a/xfa/fwl/cfwl_notedriver.h b/xfa/fwl/cfwl_notedriver.h index e177494ff1..2ea3f97cc0 100644 --- a/xfa/fwl/cfwl_notedriver.h +++ b/xfa/fwl/cfwl_notedriver.h @@ -30,7 +30,7 @@ class CFWL_NoteDriver { void RegisterEventTarget(CFWL_Widget* pListener, CFWL_Widget* pEventSource); void UnregisterEventTarget(CFWL_Widget* pListener); - void ClearEventTargets(bool bRemoveAll); + void ClearEventTargets(); CFWL_NoteLoop* GetTopLoop() const; void PushNoteLoop(CFWL_NoteLoop* pNoteLoop); @@ -69,7 +69,8 @@ class CFWL_NoteDriver { std::vector<CFWL_Widget*> m_Forms; std::deque<std::unique_ptr<CFWL_Message>> m_NoteQueue; std::vector<CFWL_NoteLoop*> m_NoteLoopQueue; - std::unordered_map<uint32_t, CFWL_EventTarget*> m_eventTargets; + std::unordered_map<uint32_t, std::unique_ptr<CFWL_EventTarget>> + m_eventTargets; CFWL_Widget* m_pHover; CFWL_Widget* m_pFocus; CFWL_Widget* m_pGrab; |