summaryrefslogtreecommitdiff
path: root/xfa
diff options
context:
space:
mode:
Diffstat (limited to 'xfa')
-rw-r--r--xfa/fwl/cfwl_app.cpp2
-rw-r--r--xfa/fwl/cfwl_notedriver.cpp39
-rw-r--r--xfa/fwl/cfwl_notedriver.h15
3 files changed, 27 insertions, 29 deletions
diff --git a/xfa/fwl/cfwl_app.cpp b/xfa/fwl/cfwl_app.cpp
index 58ca93de61..666a91d209 100644
--- a/xfa/fwl/cfwl_app.cpp
+++ b/xfa/fwl/cfwl_app.cpp
@@ -19,4 +19,4 @@ CFWL_App::CFWL_App(CXFA_FFApp* pAdapter)
ASSERT(m_pAdapterNative);
}
-CFWL_App::~CFWL_App() {}
+CFWL_App::~CFWL_App() = default;
diff --git a/xfa/fwl/cfwl_notedriver.cpp b/xfa/fwl/cfwl_notedriver.cpp
index e33a423086..b1f21ece37 100644
--- a/xfa/fwl/cfwl_notedriver.cpp
+++ b/xfa/fwl/cfwl_notedriver.cpp
@@ -24,14 +24,11 @@
#include "xfa/fwl/cfwl_widgetmgr.h"
CFWL_NoteDriver::CFWL_NoteDriver()
- : m_pHover(nullptr),
- m_pFocus(nullptr),
- m_pGrab(nullptr),
- m_pNoteLoop(pdfium::MakeUnique<CFWL_NoteLoop>()) {
+ : m_pNoteLoop(pdfium::MakeUnique<CFWL_NoteLoop>()) {
PushNoteLoop(m_pNoteLoop.get());
}
-CFWL_NoteDriver::~CFWL_NoteDriver() {}
+CFWL_NoteDriver::~CFWL_NoteDriver() = default;
void CFWL_NoteDriver::SendEvent(CFWL_Event* pNote) {
for (const auto& pair : m_eventTargets) {
@@ -66,14 +63,14 @@ void CFWL_NoteDriver::UnregisterEventTarget(CFWL_Widget* pListener) {
}
void CFWL_NoteDriver::PushNoteLoop(CFWL_NoteLoop* pNoteLoop) {
- m_NoteLoopQueue.push_back(pNoteLoop);
+ m_NoteLoopQueue.emplace_back(pNoteLoop);
}
CFWL_NoteLoop* CFWL_NoteDriver::PopNoteLoop() {
if (m_NoteLoopQueue.empty())
return nullptr;
- CFWL_NoteLoop* p = m_NoteLoopQueue.back();
+ CFWL_NoteLoop* p = m_NoteLoopQueue.back().Get();
m_NoteLoopQueue.pop_back();
return p;
}
@@ -82,7 +79,7 @@ bool CFWL_NoteDriver::SetFocus(CFWL_Widget* pFocus) {
if (m_pFocus == pFocus)
return true;
- CFWL_Widget* pPrev = m_pFocus;
+ CFWL_Widget* pPrev = m_pFocus.Get();
m_pFocus = pFocus;
if (pPrev) {
if (IFWL_WidgetDelegate* pDelegate = pPrev->GetDelegate()) {
@@ -135,8 +132,8 @@ void CFWL_NoteDriver::NotifyTargetDestroy(CFWL_Widget* pNoteTarget) {
UnregisterEventTarget(pNoteTarget);
- for (CFWL_Widget* pWidget : m_Forms) {
- CFWL_Form* pForm = static_cast<CFWL_Form*>(pWidget);
+ for (const auto& pWidget : m_Forms) {
+ CFWL_Form* pForm = static_cast<CFWL_Form*>(pWidget.Get());
if (!pForm)
continue;
@@ -153,7 +150,7 @@ void CFWL_NoteDriver::RegisterForm(CFWL_Widget* pForm) {
if (!pForm || pdfium::ContainsValue(m_Forms, pForm))
return;
- m_Forms.push_back(pForm);
+ m_Forms.emplace_back(pForm);
if (m_Forms.size() == 1 && !m_NoteLoopQueue.empty() && m_NoteLoopQueue[0])
m_NoteLoopQueue[0]->SetMainForm(pForm);
}
@@ -181,7 +178,7 @@ void CFWL_NoteDriver::UnqueueMessageAndProcess(CFWL_NoteLoop* pNoteLoop) {
}
CFWL_NoteLoop* CFWL_NoteDriver::GetTopLoop() const {
- return !m_NoteLoopQueue.empty() ? m_NoteLoopQueue.back() : nullptr;
+ return !m_NoteLoopQueue.empty() ? m_NoteLoopQueue.back().Get() : nullptr;
}
void CFWL_NoteDriver::ProcessMessage(std::unique_ptr<CFWL_Message> pMessage) {
@@ -254,8 +251,8 @@ bool CFWL_NoteDriver::DoKey(CFWL_Message* pMessage, CFWL_Widget* pMessageForm) {
pMsg->m_dwKeyCode == FWL_VKEY_Tab) {
CFWL_WidgetMgr* pWidgetMgr = pMessageForm->GetOwnerApp()->GetWidgetMgr();
CFWL_Widget* pForm = GetMessageForm(pMsg->GetDstTarget());
- CFWL_Widget* pFocus = m_pFocus;
- if (m_pFocus && pWidgetMgr->GetSystemFormWidget(m_pFocus) != pForm)
+ CFWL_Widget* pFocus = m_pFocus.Get();
+ if (m_pFocus && pWidgetMgr->GetSystemFormWidget(m_pFocus.Get()) != pForm)
pFocus = nullptr;
bool bFind = false;
@@ -284,7 +281,7 @@ bool CFWL_NoteDriver::DoKey(CFWL_Message* pMessage, CFWL_Widget* pMessageForm) {
}
return false;
}
- pMsg->SetDstTarget(m_pFocus);
+ pMsg->SetDstTarget(m_pFocus.Get());
return true;
}
@@ -326,7 +323,7 @@ bool CFWL_NoteDriver::DoMouseEx(CFWL_Message* pMessage,
return false;
CFWL_Widget* pTarget = nullptr;
if (m_pGrab)
- pTarget = m_pGrab;
+ pTarget = m_pGrab.Get();
CFWL_MessageMouse* pMsg = static_cast<CFWL_MessageMouse*>(pMessage);
if (!pTarget)
@@ -347,8 +344,8 @@ void CFWL_NoteDriver::MouseSecondary(CFWL_Message* pMessage) {
CFWL_MessageMouse* pMsg = static_cast<CFWL_MessageMouse*>(pMessage);
if (m_pHover) {
- CFWL_MessageMouse msLeave(nullptr, m_pHover);
- msLeave.m_pos = pTarget->TransformTo(m_pHover, pMsg->m_pos);
+ CFWL_MessageMouse msLeave(nullptr, m_pHover.Get());
+ msLeave.m_pos = pTarget->TransformTo(m_pHover.Get(), pMsg->m_pos);
msLeave.m_dwFlags = 0;
msLeave.m_dwCmd = FWL_MouseCommand::Leave;
DispatchMessage(&msLeave, nullptr);
@@ -367,13 +364,13 @@ void CFWL_NoteDriver::MouseSecondary(CFWL_Message* pMessage) {
}
bool CFWL_NoteDriver::IsValidMessage(CFWL_Message* pMessage) {
- for (CFWL_NoteLoop* pNoteLoop : m_NoteLoopQueue) {
+ for (const auto& pNoteLoop : m_NoteLoopQueue) {
CFWL_Widget* pForm = pNoteLoop->GetForm();
if (pForm && pForm == pMessage->GetDstTarget())
return true;
}
- for (CFWL_Widget* pWidget : m_Forms) {
- CFWL_Form* pForm = static_cast<CFWL_Form*>(pWidget);
+ for (const auto& pWidget : m_Forms) {
+ auto* pForm = static_cast<const CFWL_Form*>(pWidget.Get());
if (pForm == pMessage->GetDstTarget())
return true;
}
diff --git a/xfa/fwl/cfwl_notedriver.h b/xfa/fwl/cfwl_notedriver.h
index 0db482ecbc..f894fe33d8 100644
--- a/xfa/fwl/cfwl_notedriver.h
+++ b/xfa/fwl/cfwl_notedriver.h
@@ -12,6 +12,7 @@
#include <memory>
#include <vector>
+#include "core/fxcrt/unowned_ptr.h"
#include "xfa/fwl/cfwl_event.h"
#include "xfa/fwl/cfwl_widget.h"
#include "xfa/fxgraphics/cxfa_graphics.h"
@@ -36,7 +37,7 @@ class CFWL_NoteDriver {
void PushNoteLoop(CFWL_NoteLoop* pNoteLoop);
CFWL_NoteLoop* PopNoteLoop();
- CFWL_Widget* GetFocus() const { return m_pFocus; }
+ CFWL_Widget* GetFocus() const { return m_pFocus.Get(); }
bool SetFocus(CFWL_Widget* pFocus);
void SetGrab(CFWL_Widget* pGrab, bool bSet) {
m_pGrab = bSet ? pGrab : nullptr;
@@ -66,14 +67,14 @@ class CFWL_NoteDriver {
bool IsValidMessage(CFWL_Message* pMessage);
CFWL_Widget* GetMessageForm(CFWL_Widget* pDstTarget);
- std::vector<CFWL_Widget*> m_Forms;
+ std::vector<UnownedPtr<CFWL_Widget>> m_Forms;
std::deque<std::unique_ptr<CFWL_Message>> m_NoteQueue;
- std::vector<CFWL_NoteLoop*> m_NoteLoopQueue;
- std::map<uint32_t, std::unique_ptr<CFWL_EventTarget>> m_eventTargets;
- CFWL_Widget* m_pHover;
- CFWL_Widget* m_pFocus;
- CFWL_Widget* m_pGrab;
std::unique_ptr<CFWL_NoteLoop> m_pNoteLoop;
+ std::vector<UnownedPtr<CFWL_NoteLoop>> m_NoteLoopQueue;
+ std::map<uint32_t, std::unique_ptr<CFWL_EventTarget>> m_eventTargets;
+ UnownedPtr<CFWL_Widget> m_pHover;
+ UnownedPtr<CFWL_Widget> m_pFocus;
+ UnownedPtr<CFWL_Widget> m_pGrab;
};
#endif // XFA_FWL_CFWL_NOTEDRIVER_H_