1 // Copyright 2014 The PDFium Authors 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 6 7 #ifndef XFA_FWL_CFWL_NOTEDRIVER_H_ 8 #define XFA_FWL_CFWL_NOTEDRIVER_H_ 9 10 #include <map> 11 #include <memory> 12 #include <set> 13 14 #include "fxjs/gc/heap.h" 15 #include "v8/include/cppgc/garbage-collected.h" 16 #include "v8/include/cppgc/member.h" 17 #include "v8/include/cppgc/visitor.h" 18 #include "xfa/fgas/graphics/cfgas_gegraphics.h" 19 #include "xfa/fwl/cfwl_widget.h" 20 21 class CFWL_Event; 22 23 class CFWL_NoteDriver final : public cppgc::GarbageCollected<CFWL_NoteDriver> { 24 public: 25 CONSTRUCT_VIA_MAKE_GARBAGE_COLLECTED; 26 ~CFWL_NoteDriver(); 27 28 void Trace(cppgc::Visitor* visitor) const; 29 30 void SendEvent(CFWL_Event* pNote); 31 void ProcessMessage(CFWL_Message* pMessage); 32 void RegisterEventTarget(CFWL_Widget* pListener, CFWL_Widget* pEventSource); 33 void UnregisterEventTarget(CFWL_Widget* pListener); 34 void NotifyTargetHide(CFWL_Widget* pNoteTarget); 35 void NotifyTargetDestroy(CFWL_Widget* pNoteTarget); SetGrab(CFWL_Widget * pGrab)36 void SetGrab(CFWL_Widget* pGrab) { m_pGrab = pGrab; } 37 38 private: 39 class Target : public cppgc::GarbageCollected<Target> { 40 public: 41 explicit Target(CFWL_Widget* pListener); 42 ~Target(); 43 44 void Trace(cppgc::Visitor* visitor) const; 45 void SetEventSource(CFWL_Widget* pSource); 46 bool ProcessEvent(CFWL_Event* pEvent); IsValid()47 bool IsValid() const { return m_bValid; } Invalidate()48 void Invalidate() { m_bValid = false; } 49 50 private: 51 bool m_bValid = true; 52 cppgc::Member<CFWL_Widget> const m_pListener; 53 std::set<cppgc::Member<CFWL_Widget>> m_widgets; 54 }; 55 56 explicit CFWL_NoteDriver(CFWL_App* pApp); 57 58 bool DispatchMessage(CFWL_Message* pMessage, CFWL_Widget* pMessageForm); 59 bool DoSetFocus(CFWL_Message* pMsg, CFWL_Widget* pMessageForm); 60 bool DoKillFocus(CFWL_Message* pMsg, CFWL_Widget* pMessageForm); 61 bool DoKey(CFWL_Message* pMsg, CFWL_Widget* pMessageForm); 62 bool DoMouse(CFWL_Message* pMsg, CFWL_Widget* pMessageForm); 63 bool DoWheel(CFWL_Message* pMsg, CFWL_Widget* pMessageForm); 64 bool DoMouseEx(CFWL_Message* pMsg, CFWL_Widget* pMessageForm); 65 void MouseSecondary(CFWL_Message* pMsg); 66 67 cppgc::Member<CFWL_App> m_pApp; 68 std::map<uint64_t, cppgc::Member<Target>> m_eventTargets; 69 cppgc::Member<CFWL_Widget> m_pHover; 70 cppgc::Member<CFWL_Widget> m_pFocus; 71 cppgc::Member<CFWL_Widget> m_pGrab; 72 }; 73 74 #endif // XFA_FWL_CFWL_NOTEDRIVER_H_ 75