From 5d0e8432c63a5e7a0b42fd4621c1c454ff49985e Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Tue, 22 Sep 2015 15:50:03 -0700 Subject: Merge to XFA: Use std::set<> to track active event handlers. Merge conflicts in JS_Runtime.cpp (cherry picked from commit d8d223127d706aa4961b2c9b0037ab256fce9a8f) Original Review URL: https://codereview.chromium.org/1352393003 . R=thestig@chromium.org Review URL: https://codereview.chromium.org/1365503003 . --- fpdfsdk/include/javascript/JS_Runtime.h | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) (limited to 'fpdfsdk/include') diff --git a/fpdfsdk/include/javascript/JS_Runtime.h b/fpdfsdk/include/javascript/JS_Runtime.h index b53e50e6ce..042bba9dcb 100644 --- a/fpdfsdk/include/javascript/JS_Runtime.h +++ b/fpdfsdk/include/javascript/JS_Runtime.h @@ -7,6 +7,9 @@ #ifndef FPDFSDK_INCLUDE_JAVASCRIPT_JS_RUNTIME_H_ #define FPDFSDK_INCLUDE_JAVASCRIPT_JS_RUNTIME_H_ +#include +#include + #include "../../../third_party/base/nonstd_unique_ptr.h" #include "../../../core/include/fxcrt/fx_basic.h" #include "../jsapi/fxjs_v8.h" @@ -15,15 +18,10 @@ class CJS_Context; -class CJS_FieldEvent { - public: - CFX_WideString sTargetName; - JS_EVENT_T eEventType; - CJS_FieldEvent* pNext; -}; - class CJS_Runtime : public IFXJS_Runtime { public: + using FieldEvent = std::pair; + explicit CJS_Runtime(CPDFDoc_Environment* pApp); ~CJS_Runtime() override; @@ -36,11 +34,9 @@ class CJS_Runtime : public IFXJS_Runtime { CPDFDoc_Environment* GetReaderApp() const { return m_pApp; } - FX_BOOL AddEventToLoop(const CFX_WideString& sTargetName, - JS_EVENT_T eEventType); - void RemoveEventInLoop(const CFX_WideString& sTargetName, - JS_EVENT_T eEventType); - void RemoveEventsInLoop(CJS_FieldEvent* pStart); + // Returns true if the event isn't already found in the set. + bool AddEventToSet(const FieldEvent& event); + void RemoveEventFromSet(const FieldEvent& event); void BeginBlock() { m_bBlocking = TRUE; } void EndBlock() { m_bBlocking = FALSE; } @@ -61,7 +57,7 @@ class CJS_Runtime : public IFXJS_Runtime { CPDFDoc_Environment* m_pApp; CPDFSDK_Document* m_pDocument; FX_BOOL m_bBlocking; - CJS_FieldEvent* m_pFieldEventPath; + std::set m_FieldEventSet; v8::Isolate* m_isolate; bool m_isolateManaged; nonstd::unique_ptr m_pArrayBufferAllocator; -- cgit v1.2.3