summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordsinclair <dsinclair@chromium.org>2016-11-21 17:57:21 -0800
committerCommit bot <commit-bot@chromium.org>2016-11-21 17:57:21 -0800
commit4bd717ba4e40d4d3775c5e19334f4733fca8cb42 (patch)
tree473e54389cec12eebaade8189948e34705c52edc
parent12ff1eba3eaa4a27089f1837a0826dfcac163db2 (diff)
downloadpdfium-4bd717ba4e40d4d3775c5e19334f4733fca8cb42.tar.xz
Remove FwlEventMask
The only value being set from the enum was the All Mask. This was always set through the default value in the methods. This Cl removes the mask code completely and updates surrounding code as needed. Review-Url: https://codereview.chromium.org/2515243003
-rw-r--r--xfa/fwl/core/cfwl_event.h13
-rw-r--r--xfa/fwl/core/cfwl_eventtarget.cpp59
-rw-r--r--xfa/fwl/core/cfwl_eventtarget.h9
-rw-r--r--xfa/fwl/core/cfwl_notedriver.cpp5
-rw-r--r--xfa/fwl/core/cfwl_notedriver.h4
-rw-r--r--xfa/fwl/core/ifwl_form.cpp2
-rw-r--r--xfa/fwl/core/ifwl_widget.cpp5
-rw-r--r--xfa/fwl/core/ifwl_widget.h3
8 files changed, 19 insertions, 81 deletions
diff --git a/xfa/fwl/core/cfwl_event.h b/xfa/fwl/core/cfwl_event.h
index cabb5838d0..550457a6bd 100644
--- a/xfa/fwl/core/cfwl_event.h
+++ b/xfa/fwl/core/cfwl_event.h
@@ -37,19 +37,6 @@ enum class CFWL_EventType {
Validate
};
-enum FWLEventMask {
- FWL_EVENT_MOUSE_MASK = 1 << 0,
- FWL_EVENT_MOUSEWHEEL_MASK = 1 << 1,
- FWL_EVENT_KEY_MASK = 1 << 2,
- FWL_EVENT_FOCUSCHANGED_MASK = 1 << 3,
- FWL_EVENT_DRAW_MASK = 1 << 4,
- FWL_EVENT_CLOSE_MASK = 1 << 5,
- FWL_EVENT_SIZECHANGED_MASK = 1 << 6,
- FWL_EVENT_IDLE_MASK = 1 << 7,
- FWL_EVENT_CONTROL_MASK = 1 << 8,
- FWL_EVENT_ALL_MASK = 0xFF
-};
-
class CFX_Graphics;
class IFWL_Widget;
diff --git a/xfa/fwl/core/cfwl_eventtarget.cpp b/xfa/fwl/core/cfwl_eventtarget.cpp
index 77fb9d8354..836a7ed34d 100644
--- a/xfa/fwl/core/cfwl_eventtarget.cpp
+++ b/xfa/fwl/core/cfwl_eventtarget.cpp
@@ -12,63 +12,20 @@
CFWL_EventTarget::CFWL_EventTarget(IFWL_Widget* pListener)
: m_pListener(pListener), m_bInvalid(false) {}
-CFWL_EventTarget::~CFWL_EventTarget() {
- m_eventSources.RemoveAll();
-}
+CFWL_EventTarget::~CFWL_EventTarget() {}
-int32_t CFWL_EventTarget::SetEventSource(IFWL_Widget* pSource,
- uint32_t dwFilter) {
- if (pSource) {
- m_eventSources.SetAt(pSource, dwFilter);
- return m_eventSources.GetCount();
- }
- return 1;
+void CFWL_EventTarget::SetEventSource(IFWL_Widget* pSource) {
+ if (pSource)
+ m_widgets.insert(pSource);
}
bool CFWL_EventTarget::ProcessEvent(CFWL_Event* pEvent) {
IFWL_WidgetDelegate* pDelegate = m_pListener->GetDelegate();
if (!pDelegate)
return false;
- if (m_eventSources.GetCount() == 0) {
- pDelegate->OnProcessEvent(pEvent);
- return true;
- }
-
- FX_POSITION pos = m_eventSources.GetStartPosition();
- while (pos) {
- IFWL_Widget* pSource = nullptr;
- uint32_t dwFilter = 0;
- m_eventSources.GetNextAssoc(pos, (void*&)pSource, dwFilter);
- if (pSource == pEvent->m_pSrcTarget) {
- if (IsFilterEvent(pEvent, dwFilter)) {
- pDelegate->OnProcessEvent(pEvent);
- return true;
- }
- }
- }
- return false;
-}
-
-bool CFWL_EventTarget::IsFilterEvent(CFWL_Event* pEvent,
- uint32_t dwFilter) const {
- if (dwFilter == FWL_EVENT_ALL_MASK)
- return true;
+ if (!m_widgets.empty() && m_widgets.count(pEvent->m_pSrcTarget) == 0)
+ return false;
- switch (pEvent->GetClassID()) {
- case CFWL_EventType::Mouse:
- return !!(dwFilter & FWL_EVENT_MOUSE_MASK);
- case CFWL_EventType::MouseWheel:
- return !!(dwFilter & FWL_EVENT_MOUSEWHEEL_MASK);
- case CFWL_EventType::Key:
- return !!(dwFilter & FWL_EVENT_KEY_MASK);
- case CFWL_EventType::SetFocus:
- case CFWL_EventType::KillFocus:
- return !!(dwFilter & FWL_EVENT_FOCUSCHANGED_MASK);
- case CFWL_EventType::Close:
- return !!(dwFilter & FWL_EVENT_CLOSE_MASK);
- case CFWL_EventType::SizeChanged:
- return !!(dwFilter & FWL_EVENT_SIZECHANGED_MASK);
- default:
- return !!(dwFilter & FWL_EVENT_CONTROL_MASK);
- }
+ pDelegate->OnProcessEvent(pEvent);
+ return true;
}
diff --git a/xfa/fwl/core/cfwl_eventtarget.h b/xfa/fwl/core/cfwl_eventtarget.h
index b7e43ce5ff..3ed8e9a4b7 100644
--- a/xfa/fwl/core/cfwl_eventtarget.h
+++ b/xfa/fwl/core/cfwl_eventtarget.h
@@ -7,6 +7,8 @@
#ifndef XFA_FWL_CORE_CFWL_EVENTTARGET_H_
#define XFA_FWL_CORE_CFWL_EVENTTARGET_H_
+#include <set>
+
#include "core/fxcrt/fx_basic.h"
#include "xfa/fwl/core/cfwl_event.h"
@@ -18,17 +20,14 @@ class CFWL_EventTarget {
explicit CFWL_EventTarget(IFWL_Widget* pListener);
~CFWL_EventTarget();
- int32_t SetEventSource(IFWL_Widget* pSource,
- uint32_t dwFilter = FWL_EVENT_ALL_MASK);
+ void SetEventSource(IFWL_Widget* pSource);
bool ProcessEvent(CFWL_Event* pEvent);
bool IsInvalid() const { return m_bInvalid; }
void FlagInvalid() { m_bInvalid = true; }
private:
- bool IsFilterEvent(CFWL_Event* pEvent, uint32_t dwFilter) const;
-
- CFX_MapPtrTemplate<void*, uint32_t> m_eventSources;
+ std::set<IFWL_Widget*> m_widgets;
IFWL_Widget* m_pListener;
bool m_bInvalid;
};
diff --git a/xfa/fwl/core/cfwl_notedriver.cpp b/xfa/fwl/core/cfwl_notedriver.cpp
index 7c53e54847..2041c619e7 100644
--- a/xfa/fwl/core/cfwl_notedriver.cpp
+++ b/xfa/fwl/core/cfwl_notedriver.cpp
@@ -46,8 +46,7 @@ void CFWL_NoteDriver::SendEvent(CFWL_Event* pNote) {
}
void CFWL_NoteDriver::RegisterEventTarget(IFWL_Widget* pListener,
- IFWL_Widget* pEventSource,
- uint32_t dwFilter) {
+ IFWL_Widget* pEventSource) {
uint32_t key = pListener->GetEventKey();
if (key == 0) {
do {
@@ -58,7 +57,7 @@ void CFWL_NoteDriver::RegisterEventTarget(IFWL_Widget* pListener,
if (!m_eventTargets[key])
m_eventTargets[key] = new CFWL_EventTarget(pListener);
- m_eventTargets[key]->SetEventSource(pEventSource, dwFilter);
+ m_eventTargets[key]->SetEventSource(pEventSource);
}
void CFWL_NoteDriver::UnregisterEventTarget(IFWL_Widget* pListener) {
diff --git a/xfa/fwl/core/cfwl_notedriver.h b/xfa/fwl/core/cfwl_notedriver.h
index a9b2c715db..9e5fa99f6a 100644
--- a/xfa/fwl/core/cfwl_notedriver.h
+++ b/xfa/fwl/core/cfwl_notedriver.h
@@ -29,9 +29,7 @@ class CFWL_NoteDriver {
void SendEvent(CFWL_Event* pNote);
- void RegisterEventTarget(IFWL_Widget* pListener,
- IFWL_Widget* pEventSource = nullptr,
- uint32_t dwFilter = FWL_EVENT_ALL_MASK);
+ void RegisterEventTarget(IFWL_Widget* pListener, IFWL_Widget* pEventSource);
void UnregisterEventTarget(IFWL_Widget* pListener);
void ClearEventTargets(bool bRemoveAll);
diff --git a/xfa/fwl/core/ifwl_form.cpp b/xfa/fwl/core/ifwl_form.cpp
index bbc16ebdeb..56b98e34d2 100644
--- a/xfa/fwl/core/ifwl_form.cpp
+++ b/xfa/fwl/core/ifwl_form.cpp
@@ -61,7 +61,7 @@ IFWL_Form::IFWL_Form(const IFWL_App* app,
m_rtRestore.Reset();
RegisterForm();
- RegisterEventTarget();
+ RegisterEventTarget(nullptr);
}
IFWL_Form::~IFWL_Form() {
diff --git a/xfa/fwl/core/ifwl_widget.cpp b/xfa/fwl/core/ifwl_widget.cpp
index ca574b2356..102ca2e0f0 100644
--- a/xfa/fwl/core/ifwl_widget.cpp
+++ b/xfa/fwl/core/ifwl_widget.cpp
@@ -584,8 +584,7 @@ bool IFWL_Widget::GetPopupPosGeneral(FX_FLOAT fMinHeight,
return true;
}
-void IFWL_Widget::RegisterEventTarget(IFWL_Widget* pEventSource,
- uint32_t dwFilter) {
+void IFWL_Widget::RegisterEventTarget(IFWL_Widget* pEventSource) {
const IFWL_App* pApp = GetOwnerApp();
if (!pApp)
return;
@@ -594,7 +593,7 @@ void IFWL_Widget::RegisterEventTarget(IFWL_Widget* pEventSource,
if (!pNoteDriver)
return;
- pNoteDriver->RegisterEventTarget(this, pEventSource, dwFilter);
+ pNoteDriver->RegisterEventTarget(this, pEventSource);
}
void IFWL_Widget::UnregisterEventTarget() {
diff --git a/xfa/fwl/core/ifwl_widget.h b/xfa/fwl/core/ifwl_widget.h
index ebd430356b..414678fb60 100644
--- a/xfa/fwl/core/ifwl_widget.h
+++ b/xfa/fwl/core/ifwl_widget.h
@@ -166,8 +166,7 @@ class IFWL_Widget : public IFWL_WidgetDelegate {
FX_FLOAT fMaxHeight,
const CFX_RectF& rtAnchor,
CFX_RectF& rtPopup);
- void RegisterEventTarget(IFWL_Widget* pEventSource = nullptr,
- uint32_t dwFilter = FWL_EVENT_ALL_MASK);
+ void RegisterEventTarget(IFWL_Widget* pEventSource);
void UnregisterEventTarget();
void DispatchKeyEvent(CFWL_MsgKey* pNote);
void DispatchEvent(CFWL_Event* pEvent);