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 namespace pdfium { 22 23 class CFWL_Event; 24 25 class CFWL_NoteDriver final : public cppgc::GarbageCollected<CFWL_NoteDriver> { 26 public: 27 CONSTRUCT_VIA_MAKE_GARBAGE_COLLECTED; 28 ~CFWL_NoteDriver(); 29 30 void Trace(cppgc::Visitor* visitor) const; 31 32 void SendEvent(CFWL_Event* pNote); 33 void ProcessMessage(CFWL_Message* pMessage); 34 void RegisterEventTarget(CFWL_Widget* pListener, CFWL_Widget* pEventSource); 35 void UnregisterEventTarget(CFWL_Widget* pListener); 36 void NotifyTargetHide(CFWL_Widget* pNoteTarget); 37 void NotifyTargetDestroy(CFWL_Widget* pNoteTarget); SetGrab(CFWL_Widget * pGrab)38 void SetGrab(CFWL_Widget* pGrab) { m_pGrab = pGrab; } 39 40 private: 41 class Target : public cppgc::GarbageCollected<Target> { 42 public: 43 explicit Target(CFWL_Widget* pListener); 44 ~Target(); 45 46 void Trace(cppgc::Visitor* visitor) const; 47 void SetEventSource(CFWL_Widget* pSource); 48 bool ProcessEvent(CFWL_Event* pEvent); IsValid()49 bool IsValid() const { return m_bValid; } Invalidate()50 void Invalidate() { m_bValid = false; } 51 52 private: 53 bool m_bValid = true; 54 cppgc::Member<CFWL_Widget> const m_pListener; 55 std::set<cppgc::Member<CFWL_Widget>> m_widgets; 56 }; 57 58 explicit CFWL_NoteDriver(CFWL_App* pApp); 59 60 bool DispatchMessage(CFWL_Message* pMessage, CFWL_Widget* pMessageForm); 61 bool DoSetFocus(CFWL_Message* pMsg, CFWL_Widget* pMessageForm); 62 bool DoKillFocus(CFWL_Message* pMsg, CFWL_Widget* pMessageForm); 63 bool DoKey(CFWL_Message* pMsg, CFWL_Widget* pMessageForm); 64 bool DoMouse(CFWL_Message* pMsg, CFWL_Widget* pMessageForm); 65 bool DoWheel(CFWL_Message* pMsg, CFWL_Widget* pMessageForm); 66 bool DoMouseEx(CFWL_Message* pMsg, CFWL_Widget* pMessageForm); 67 void MouseSecondary(CFWL_Message* pMsg); 68 69 cppgc::Member<CFWL_App> m_pApp; 70 cppgc::Member<CFWL_Widget> m_pHover; 71 cppgc::Member<CFWL_Widget> m_pFocus; 72 cppgc::Member<CFWL_Widget> m_pGrab; 73 std::map<uint64_t, cppgc::Member<Target>> m_eventTargets; 74 }; 75 76 } // namespace pdfium 77 78 // TODO(crbug.com/42271761): Remove. 79 using pdfium::CFWL_NoteDriver; 80 81 #endif // XFA_FWL_CFWL_NOTEDRIVER_H_ 82