diff options
author | Tom Sepez <tsepez@chromium.org> | 2019-06-11 19:49:00 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2019-06-11 19:49:00 +0000 |
commit | 7dbb85b7e82c1fca4c4dfbdcf61d400d6200bc7b (patch) | |
tree | 954f1cce1251c7981a071cf6e2f9fcb5badac6b5 | |
parent | 49d717afc97415c2e89cfc5f0dbb2294f11cecec (diff) | |
download | pdfium-7dbb85b7e82c1fca4c4dfbdcf61d400d6200bc7b.tar.gz |
Rename CJS_EventHandler to CJS_EventRecorder.
Longstanding irk. As far as I can tell, the EventHandler doesn't
actually handle anything. Instead it records details for others
to handle.
Straight rename, no functional change.
Change-Id: I5864f8e7a3da7200f6fcfafd5cfbe986e7a99362
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/55870
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
-rw-r--r-- | fxjs/BUILD.gn | 4 | ||||
-rw-r--r-- | fxjs/cjs_color.cpp | 2 | ||||
-rw-r--r-- | fxjs/cjs_console.cpp | 2 | ||||
-rw-r--r-- | fxjs/cjs_document.cpp | 4 | ||||
-rw-r--r-- | fxjs/cjs_event.cpp | 90 | ||||
-rw-r--r-- | fxjs/cjs_event_context.cpp | 88 | ||||
-rw-r--r-- | fxjs/cjs_event_context.h | 6 | ||||
-rw-r--r-- | fxjs/cjs_eventrecorder.cpp (renamed from fxjs/cjs_eventhandler.cpp) | 243 | ||||
-rw-r--r-- | fxjs/cjs_eventrecorder.h (renamed from fxjs/cjs_eventhandler.h) | 12 | ||||
-rw-r--r-- | fxjs/cjs_global.cpp | 2 | ||||
-rw-r--r-- | fxjs/cjs_publicmethods.cpp | 46 | ||||
-rw-r--r-- | fxjs/cjs_publicmethods_embeddertest.cpp | 6 | ||||
-rw-r--r-- | fxjs/cjs_runtime.cpp | 2 | ||||
-rw-r--r-- | fxjs/cjs_runtime.h | 2 | ||||
-rw-r--r-- | fxjs/cjs_util.cpp | 2 |
15 files changed, 256 insertions, 255 deletions
diff --git a/fxjs/BUILD.gn b/fxjs/BUILD.gn index 30648f992..10ee776b6 100644 --- a/fxjs/BUILD.gn +++ b/fxjs/BUILD.gn @@ -54,8 +54,8 @@ jumbo_source_set("fxjs") { "cjs_event.h", "cjs_event_context.cpp", "cjs_event_context.h", - "cjs_eventhandler.cpp", - "cjs_eventhandler.h", + "cjs_eventrecorder.cpp", + "cjs_eventrecorder.h", "cjs_field.cpp", "cjs_field.h", "cjs_font.cpp", diff --git a/fxjs/cjs_color.cpp b/fxjs/cjs_color.cpp index fa1d8053c..2b75e7527 100644 --- a/fxjs/cjs_color.cpp +++ b/fxjs/cjs_color.cpp @@ -11,7 +11,7 @@ #include "core/fxge/cfx_color.h" #include "fxjs/cjs_event_context.h" -#include "fxjs/cjs_eventhandler.h" +#include "fxjs/cjs_eventrecorder.h" #include "fxjs/cjs_object.h" #include "fxjs/cjs_runtime.h" #include "fxjs/js_define.h" diff --git a/fxjs/cjs_console.cpp b/fxjs/cjs_console.cpp index 4d432db66..c696bbdcf 100644 --- a/fxjs/cjs_console.cpp +++ b/fxjs/cjs_console.cpp @@ -9,7 +9,7 @@ #include <vector> #include "fxjs/cjs_event_context.h" -#include "fxjs/cjs_eventhandler.h" +#include "fxjs/cjs_eventrecorder.h" #include "fxjs/cjs_object.h" #include "fxjs/js_define.h" diff --git a/fxjs/cjs_document.cpp b/fxjs/cjs_document.cpp index b0faab157..133ec43b2 100644 --- a/fxjs/cjs_document.cpp +++ b/fxjs/cjs_document.cpp @@ -629,8 +629,8 @@ CJS_Result CJS_Document::submitForm( if (!m_pFormFillEnv) return CJS_Result::Failure(JSMessage::kBadObjectError); - CJS_EventHandler* pHandler = - pRuntime->GetCurrentEventContext()->GetEventHandler(); + CJS_EventRecorder* pHandler = + pRuntime->GetCurrentEventContext()->GetEventRecorder(); if (!pHandler->IsUserGesture()) return CJS_Result::Failure(JSMessage::kUserGestureRequiredError); diff --git a/fxjs/cjs_event.cpp b/fxjs/cjs_event.cpp index a4a759220..a906fe285 100644 --- a/fxjs/cjs_event.cpp +++ b/fxjs/cjs_event.cpp @@ -7,7 +7,7 @@ #include "fxjs/cjs_event.h" #include "fxjs/cjs_event_context.h" -#include "fxjs/cjs_eventhandler.h" +#include "fxjs/cjs_eventrecorder.h" #include "fxjs/cjs_field.h" #include "fxjs/cjs_object.h" #include "fxjs/js_define.h" @@ -55,16 +55,16 @@ CJS_Event::CJS_Event(v8::Local<v8::Object> pObject, CJS_Runtime* pRuntime) CJS_Event::~CJS_Event() = default; CJS_Result CJS_Event::get_change(CJS_Runtime* pRuntime) { - CJS_EventHandler* pEvent = - pRuntime->GetCurrentEventContext()->GetEventHandler(); + CJS_EventRecorder* pEvent = + pRuntime->GetCurrentEventContext()->GetEventRecorder(); return CJS_Result::Success( pRuntime->NewString(pEvent->Change().AsStringView())); } CJS_Result CJS_Event::set_change(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - CJS_EventHandler* pEvent = - pRuntime->GetCurrentEventContext()->GetEventHandler(); + CJS_EventRecorder* pEvent = + pRuntime->GetCurrentEventContext()->GetEventRecorder(); if (vp->IsString()) { WideString& wChange = pEvent->Change(); @@ -74,8 +74,8 @@ CJS_Result CJS_Event::set_change(CJS_Runtime* pRuntime, } CJS_Result CJS_Event::get_change_ex(CJS_Runtime* pRuntime) { - CJS_EventHandler* pEvent = - pRuntime->GetCurrentEventContext()->GetEventHandler(); + CJS_EventRecorder* pEvent = + pRuntime->GetCurrentEventContext()->GetEventRecorder(); return CJS_Result::Success( pRuntime->NewString(pEvent->ChangeEx().AsStringView())); } @@ -86,8 +86,8 @@ CJS_Result CJS_Event::set_change_ex(CJS_Runtime* pRuntime, } CJS_Result CJS_Event::get_commit_key(CJS_Runtime* pRuntime) { - CJS_EventHandler* pEvent = - pRuntime->GetCurrentEventContext()->GetEventHandler(); + CJS_EventRecorder* pEvent = + pRuntime->GetCurrentEventContext()->GetEventRecorder(); return CJS_Result::Success(pRuntime->NewNumber(pEvent->CommitKey())); } @@ -97,8 +97,8 @@ CJS_Result CJS_Event::set_commit_key(CJS_Runtime* pRuntime, } CJS_Result CJS_Event::get_field_full(CJS_Runtime* pRuntime) { - CJS_EventHandler* pEvent = - pRuntime->GetCurrentEventContext()->GetEventHandler(); + CJS_EventRecorder* pEvent = + pRuntime->GetCurrentEventContext()->GetEventRecorder(); if (pEvent->Name() != "Keystroke") return CJS_Result::Failure(L"unrecognized event"); @@ -111,8 +111,8 @@ CJS_Result CJS_Event::set_field_full(CJS_Runtime* pRuntime, } CJS_Result CJS_Event::get_key_down(CJS_Runtime* pRuntime) { - CJS_EventHandler* pEvent = - pRuntime->GetCurrentEventContext()->GetEventHandler(); + CJS_EventRecorder* pEvent = + pRuntime->GetCurrentEventContext()->GetEventRecorder(); return CJS_Result::Success(pRuntime->NewBoolean(pEvent->KeyDown())); } @@ -122,8 +122,8 @@ CJS_Result CJS_Event::set_key_down(CJS_Runtime* pRuntime, } CJS_Result CJS_Event::get_modifier(CJS_Runtime* pRuntime) { - CJS_EventHandler* pEvent = - pRuntime->GetCurrentEventContext()->GetEventHandler(); + CJS_EventRecorder* pEvent = + pRuntime->GetCurrentEventContext()->GetEventRecorder(); return CJS_Result::Success(pRuntime->NewBoolean(pEvent->Modifier())); } @@ -133,8 +133,8 @@ CJS_Result CJS_Event::set_modifier(CJS_Runtime* pRuntime, } CJS_Result CJS_Event::get_name(CJS_Runtime* pRuntime) { - CJS_EventHandler* pEvent = - pRuntime->GetCurrentEventContext()->GetEventHandler(); + CJS_EventRecorder* pEvent = + pRuntime->GetCurrentEventContext()->GetEventRecorder(); return CJS_Result::Success(pRuntime->NewString(pEvent->Name())); } @@ -143,14 +143,14 @@ CJS_Result CJS_Event::set_name(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { } CJS_Result CJS_Event::get_rc(CJS_Runtime* pRuntime) { - CJS_EventHandler* pEvent = - pRuntime->GetCurrentEventContext()->GetEventHandler(); + CJS_EventRecorder* pEvent = + pRuntime->GetCurrentEventContext()->GetEventRecorder(); return CJS_Result::Success(pRuntime->NewBoolean(pEvent->Rc())); } CJS_Result CJS_Event::set_rc(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - CJS_EventHandler* pEvent = - pRuntime->GetCurrentEventContext()->GetEventHandler(); + CJS_EventRecorder* pEvent = + pRuntime->GetCurrentEventContext()->GetEventRecorder(); pEvent->Rc() = pRuntime->ToBoolean(vp); return CJS_Result::Success(); } @@ -183,8 +183,8 @@ CJS_Result CJS_Event::set_rich_value(CJS_Runtime* pRuntime, } CJS_Result CJS_Event::get_sel_end(CJS_Runtime* pRuntime) { - CJS_EventHandler* pEvent = - pRuntime->GetCurrentEventContext()->GetEventHandler(); + CJS_EventRecorder* pEvent = + pRuntime->GetCurrentEventContext()->GetEventRecorder(); if (pEvent->Name() != "Keystroke") return CJS_Result::Success(); @@ -193,8 +193,8 @@ CJS_Result CJS_Event::get_sel_end(CJS_Runtime* pRuntime) { CJS_Result CJS_Event::set_sel_end(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - CJS_EventHandler* pEvent = - pRuntime->GetCurrentEventContext()->GetEventHandler(); + CJS_EventRecorder* pEvent = + pRuntime->GetCurrentEventContext()->GetEventRecorder(); if (pEvent->Name() == "Keystroke") pEvent->SetSelEnd(pRuntime->ToInt32(vp)); @@ -202,8 +202,8 @@ CJS_Result CJS_Event::set_sel_end(CJS_Runtime* pRuntime, } CJS_Result CJS_Event::get_sel_start(CJS_Runtime* pRuntime) { - CJS_EventHandler* pEvent = - pRuntime->GetCurrentEventContext()->GetEventHandler(); + CJS_EventRecorder* pEvent = + pRuntime->GetCurrentEventContext()->GetEventRecorder(); if (pEvent->Name() != "Keystroke") return CJS_Result::Success(); @@ -212,8 +212,8 @@ CJS_Result CJS_Event::get_sel_start(CJS_Runtime* pRuntime) { CJS_Result CJS_Event::set_sel_start(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - CJS_EventHandler* pEvent = - pRuntime->GetCurrentEventContext()->GetEventHandler(); + CJS_EventRecorder* pEvent = + pRuntime->GetCurrentEventContext()->GetEventRecorder(); if (pEvent->Name() == "Keystroke") pEvent->SetSelStart(pRuntime->ToInt32(vp)); @@ -221,8 +221,8 @@ CJS_Result CJS_Event::set_sel_start(CJS_Runtime* pRuntime, } CJS_Result CJS_Event::get_shift(CJS_Runtime* pRuntime) { - CJS_EventHandler* pEvent = - pRuntime->GetCurrentEventContext()->GetEventHandler(); + CJS_EventRecorder* pEvent = + pRuntime->GetCurrentEventContext()->GetEventRecorder(); return CJS_Result::Success(pRuntime->NewBoolean(pEvent->Shift())); } @@ -232,8 +232,8 @@ CJS_Result CJS_Event::set_shift(CJS_Runtime* pRuntime, } CJS_Result CJS_Event::get_source(CJS_Runtime* pRuntime) { - CJS_EventHandler* pEvent = - pRuntime->GetCurrentEventContext()->GetEventHandler(); + CJS_EventRecorder* pEvent = + pRuntime->GetCurrentEventContext()->GetEventRecorder(); return CJS_Result::Success(pEvent->Source()->ToV8Object()); } @@ -243,8 +243,8 @@ CJS_Result CJS_Event::set_source(CJS_Runtime* pRuntime, } CJS_Result CJS_Event::get_target(CJS_Runtime* pRuntime) { - CJS_EventHandler* pEvent = - pRuntime->GetCurrentEventContext()->GetEventHandler(); + CJS_EventRecorder* pEvent = + pRuntime->GetCurrentEventContext()->GetEventRecorder(); return CJS_Result::Success(pEvent->Target_Field()->ToV8Object()); } @@ -254,8 +254,8 @@ CJS_Result CJS_Event::set_target(CJS_Runtime* pRuntime, } CJS_Result CJS_Event::get_target_name(CJS_Runtime* pRuntime) { - CJS_EventHandler* pEvent = - pRuntime->GetCurrentEventContext()->GetEventHandler(); + CJS_EventRecorder* pEvent = + pRuntime->GetCurrentEventContext()->GetEventRecorder(); return CJS_Result::Success( pRuntime->NewString(pEvent->TargetName().AsStringView())); } @@ -266,8 +266,8 @@ CJS_Result CJS_Event::set_target_name(CJS_Runtime* pRuntime, } CJS_Result CJS_Event::get_type(CJS_Runtime* pRuntime) { - CJS_EventHandler* pEvent = - pRuntime->GetCurrentEventContext()->GetEventHandler(); + CJS_EventRecorder* pEvent = + pRuntime->GetCurrentEventContext()->GetEventRecorder(); return CJS_Result::Success(pRuntime->NewString(pEvent->Type())); } @@ -276,8 +276,8 @@ CJS_Result CJS_Event::set_type(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { } CJS_Result CJS_Event::get_value(CJS_Runtime* pRuntime) { - CJS_EventHandler* pEvent = - pRuntime->GetCurrentEventContext()->GetEventHandler(); + CJS_EventRecorder* pEvent = + pRuntime->GetCurrentEventContext()->GetEventRecorder(); if (pEvent->Type() != "Field") return CJS_Result::Failure(L"Bad event type."); @@ -290,8 +290,8 @@ CJS_Result CJS_Event::get_value(CJS_Runtime* pRuntime) { CJS_Result CJS_Event::set_value(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - CJS_EventHandler* pEvent = - pRuntime->GetCurrentEventContext()->GetEventHandler(); + CJS_EventRecorder* pEvent = + pRuntime->GetCurrentEventContext()->GetEventRecorder(); if (pEvent->Type() != "Field") return CJS_Result::Failure(L"Bad event type."); @@ -309,8 +309,8 @@ CJS_Result CJS_Event::set_value(CJS_Runtime* pRuntime, } CJS_Result CJS_Event::get_will_commit(CJS_Runtime* pRuntime) { - CJS_EventHandler* pEvent = - pRuntime->GetCurrentEventContext()->GetEventHandler(); + CJS_EventRecorder* pEvent = + pRuntime->GetCurrentEventContext()->GetEventRecorder(); return CJS_Result::Success(pRuntime->NewBoolean(pEvent->WillCommit())); } diff --git a/fxjs/cjs_event_context.cpp b/fxjs/cjs_event_context.cpp index 3d40c9dc5..95ae25b67 100644 --- a/fxjs/cjs_event_context.cpp +++ b/fxjs/cjs_event_context.cpp @@ -7,14 +7,14 @@ #include "fxjs/cjs_event_context.h" #include "core/fxcrt/autorestorer.h" -#include "fxjs/cjs_eventhandler.h" +#include "fxjs/cjs_eventrecorder.h" #include "fxjs/cjs_runtime.h" #include "fxjs/js_define.h" #include "fxjs/js_resources.h" CJS_EventContext::CJS_EventContext(CJS_Runtime* pRuntime) : m_pRuntime(pRuntime), - m_pEventHandler(new CJS_EventHandler(this)), + m_pEventRecorder(new CJS_EventRecorder(this)), m_bBusy(false) { ASSERT(pRuntime); } @@ -40,9 +40,9 @@ Optional<IJS_Runtime::JS_Error> CJS_EventContext::RunScript( AutoRestorer<bool> restorer(&m_bBusy); m_bBusy = true; - ASSERT(m_pEventHandler->IsValid()); - CJS_Runtime::FieldEvent event(m_pEventHandler->TargetName(), - m_pEventHandler->EventType()); + ASSERT(m_pEventRecorder->IsValid()); + CJS_Runtime::FieldEvent event(m_pEventRecorder->TargetName(), + m_pEventRecorder->EventType()); if (!m_pRuntime->AddEventToSet(event)) { return IJS_Runtime::JS_Error( 1, 1, JSGetStringFromID(JSMessage::kDuplicateEventError)); @@ -53,111 +53,111 @@ Optional<IJS_Runtime::JS_Error> CJS_EventContext::RunScript( err = m_pRuntime->ExecuteScript(script); m_pRuntime->RemoveEventFromSet(event); - m_pEventHandler->Destroy(); + m_pEventRecorder->Destroy(); return err; } void CJS_EventContext::OnApp_Init() { - m_pEventHandler->OnApp_Init(); + m_pEventRecorder->OnApp_Init(); } void CJS_EventContext::OnDoc_Open(CPDFSDK_FormFillEnvironment* pFormFillEnv, const WideString& strTargetName) { - m_pEventHandler->OnDoc_Open(pFormFillEnv, strTargetName); + m_pEventRecorder->OnDoc_Open(pFormFillEnv, strTargetName); } void CJS_EventContext::OnDoc_WillPrint( CPDFSDK_FormFillEnvironment* pFormFillEnv) { - m_pEventHandler->OnDoc_WillPrint(pFormFillEnv); + m_pEventRecorder->OnDoc_WillPrint(pFormFillEnv); } void CJS_EventContext::OnDoc_DidPrint( CPDFSDK_FormFillEnvironment* pFormFillEnv) { - m_pEventHandler->OnDoc_DidPrint(pFormFillEnv); + m_pEventRecorder->OnDoc_DidPrint(pFormFillEnv); } void CJS_EventContext::OnDoc_WillSave( CPDFSDK_FormFillEnvironment* pFormFillEnv) { - m_pEventHandler->OnDoc_WillSave(pFormFillEnv); + m_pEventRecorder->OnDoc_WillSave(pFormFillEnv); } void CJS_EventContext::OnDoc_DidSave( CPDFSDK_FormFillEnvironment* pFormFillEnv) { - m_pEventHandler->OnDoc_DidSave(pFormFillEnv); + m_pEventRecorder->OnDoc_DidSave(pFormFillEnv); } void CJS_EventContext::OnDoc_WillClose( CPDFSDK_FormFillEnvironment* pFormFillEnv) { - m_pEventHandler->OnDoc_WillClose(pFormFillEnv); + m_pEventRecorder->OnDoc_WillClose(pFormFillEnv); } void CJS_EventContext::OnPage_Open(CPDFSDK_FormFillEnvironment* pFormFillEnv) { - m_pEventHandler->OnPage_Open(pFormFillEnv); + m_pEventRecorder->OnPage_Open(pFormFillEnv); } void CJS_EventContext::OnPage_Close(CPDFSDK_FormFillEnvironment* pFormFillEnv) { - m_pEventHandler->OnPage_Close(pFormFillEnv); + m_pEventRecorder->OnPage_Close(pFormFillEnv); } void CJS_EventContext::OnPage_InView( CPDFSDK_FormFillEnvironment* pFormFillEnv) { - m_pEventHandler->OnPage_InView(pFormFillEnv); + m_pEventRecorder->OnPage_InView(pFormFillEnv); } void CJS_EventContext::OnPage_OutView( CPDFSDK_FormFillEnvironment* pFormFillEnv) { - m_pEventHandler->OnPage_OutView(pFormFillEnv); + m_pEventRecorder->OnPage_OutView(pFormFillEnv); } void CJS_EventContext::OnField_MouseDown(bool bModifier, bool bShift, CPDF_FormField* pTarget) { - m_pEventHandler->OnField_MouseDown(bModifier, bShift, pTarget); + m_pEventRecorder->OnField_MouseDown(bModifier, bShift, pTarget); } void CJS_EventContext::OnField_MouseEnter(bool bModifier, bool bShift, CPDF_FormField* pTarget) { - m_pEventHandler->OnField_MouseEnter(bModifier, bShift, pTarget); + m_pEventRecorder->OnField_MouseEnter(bModifier, bShift, pTarget); } void CJS_EventContext::OnField_MouseExit(bool bModifier, bool bShift, CPDF_FormField* pTarget) { - m_pEventHandler->OnField_MouseExit(bModifier, bShift, pTarget); + m_pEventRecorder->OnField_MouseExit(bModifier, bShift, pTarget); } void CJS_EventContext::OnField_MouseUp(bool bModifier, bool bShift, CPDF_FormField* pTarget) { - m_pEventHandler->OnField_MouseUp(bModifier, bShift, pTarget); + m_pEventRecorder->OnField_MouseUp(bModifier, bShift, pTarget); } void CJS_EventContext::OnField_Focus(bool bModifier, bool bShift, CPDF_FormField* pTarget, WideString* Value) { - m_pEventHandler->OnField_Focus(bModifier, bShift, pTarget, Value); + m_pEventRecorder->OnField_Focus(bModifier, bShift, pTarget, Value); } void CJS_EventContext::OnField_Blur(bool bModifier, bool bShift, CPDF_FormField* pTarget, WideString* Value) { - m_pEventHandler->OnField_Blur(bModifier, bShift, pTarget, Value); + m_pEventRecorder->OnField_Blur(bModifier, bShift, pTarget, Value); } void CJS_EventContext::OnField_Calculate(CPDF_FormField* pSource, CPDF_FormField* pTarget, WideString* pValue, bool* pRc) { - m_pEventHandler->OnField_Calculate(pSource, pTarget, pValue, pRc); + m_pEventRecorder->OnField_Calculate(pSource, pTarget, pValue, pRc); } void CJS_EventContext::OnField_Format(CPDF_FormField* pTarget, WideString* Value, bool bWillCommit) { - m_pEventHandler->OnField_Format(pTarget, Value, bWillCommit); + m_pEventRecorder->OnField_Format(pTarget, Value, bWillCommit); } void CJS_EventContext::OnField_Keystroke(WideString* strChange, @@ -172,7 +172,7 @@ void CJS_EventContext::OnField_Keystroke(WideString* strChange, bool bWillCommit, bool bFieldFull, bool* bRc) { - m_pEventHandler->OnField_Keystroke( + m_pEventRecorder->OnField_Keystroke( strChange, strChangeEx, bKeyDown, bModifier, nSelEnd, nSelStart, bShift, pTarget, Value, bWillCommit, bFieldFull, bRc); } @@ -185,92 +185,92 @@ void CJS_EventContext::OnField_Validate(WideString* strChange, CPDF_FormField* pTarget, WideString* Value, bool* bRc) { - m_pEventHandler->OnField_Validate(strChange, strChangeEx, bKeyDown, bModifier, - bShift, pTarget, Value, bRc); + m_pEventRecorder->OnField_Validate(strChange, strChangeEx, bKeyDown, + bModifier, bShift, pTarget, Value, bRc); } void CJS_EventContext::OnScreen_Focus(bool bModifier, bool bShift, CPDFSDK_Annot* pScreen) { - m_pEventHandler->OnScreen_Focus(bModifier, bShift, pScreen); + m_pEventRecorder->OnScreen_Focus(bModifier, bShift, pScreen); } void CJS_EventContext::OnScreen_Blur(bool bModifier, bool bShift, CPDFSDK_Annot* pScreen) { - m_pEventHandler->OnScreen_Blur(bModifier, bShift, pScreen); + m_pEventRecorder->OnScreen_Blur(bModifier, bShift, pScreen); } void CJS_EventContext::OnScreen_Open(bool bModifier, bool bShift, CPDFSDK_Annot* pScreen) { - m_pEventHandler->OnScreen_Open(bModifier, bShift, pScreen); + m_pEventRecorder->OnScreen_Open(bModifier, bShift, pScreen); } void CJS_EventContext::OnScreen_Close(bool bModifier, bool bShift, CPDFSDK_Annot* pScreen) { - m_pEventHandler->OnScreen_Close(bModifier, bShift, pScreen); + m_pEventRecorder->OnScreen_Close(bModifier, bShift, pScreen); } void CJS_EventContext::OnScreen_MouseDown(bool bModifier, bool bShift, CPDFSDK_Annot* pScreen) { - m_pEventHandler->OnScreen_MouseDown(bModifier, bShift, pScreen); + m_pEventRecorder->OnScreen_MouseDown(bModifier, bShift, pScreen); } void CJS_EventContext::OnScreen_MouseUp(bool bModifier, bool bShift, CPDFSDK_Annot* pScreen) { - m_pEventHandler->OnScreen_MouseUp(bModifier, bShift, pScreen); + m_pEventRecorder->OnScreen_MouseUp(bModifier, bShift, pScreen); } void CJS_EventContext::OnScreen_MouseEnter(bool bModifier, bool bShift, CPDFSDK_Annot* pScreen) { - m_pEventHandler->OnScreen_MouseEnter(bModifier, bShift, pScreen); + m_pEventRecorder->OnScreen_MouseEnter(bModifier, bShift, pScreen); } void CJS_EventContext::OnScreen_MouseExit(bool bModifier, bool bShift, CPDFSDK_Annot* pScreen) { - m_pEventHandler->OnScreen_MouseExit(bModifier, bShift, pScreen); + m_pEventRecorder->OnScreen_MouseExit(bModifier, bShift, pScreen); } void CJS_EventContext::OnScreen_InView(bool bModifier, bool bShift, CPDFSDK_Annot* pScreen) { - m_pEventHandler->OnScreen_InView(bModifier, bShift, pScreen); + m_pEventRecorder->OnScreen_InView(bModifier, bShift, pScreen); } void CJS_EventContext::OnScreen_OutView(bool bModifier, bool bShift, CPDFSDK_Annot* pScreen) { - m_pEventHandler->OnScreen_OutView(bModifier, bShift, pScreen); + m_pEventRecorder->OnScreen_OutView(bModifier, bShift, pScreen); } void CJS_EventContext::OnBookmark_MouseUp(CPDF_Bookmark* pBookMark) { - m_pEventHandler->OnBookmark_MouseUp(pBookMark); + m_pEventRecorder->OnBookmark_MouseUp(pBookMark); } void CJS_EventContext::OnLink_MouseUp( CPDFSDK_FormFillEnvironment* pFormFillEnv) { - m_pEventHandler->OnLink_MouseUp(pFormFillEnv); + m_pEventRecorder->OnLink_MouseUp(pFormFillEnv); } void CJS_EventContext::OnConsole_Exec() { - m_pEventHandler->OnConsole_Exec(); + m_pEventRecorder->OnConsole_Exec(); } void CJS_EventContext::OnExternal_Exec() { - m_pEventHandler->OnExternal_Exec(); + m_pEventRecorder->OnExternal_Exec(); } void CJS_EventContext::OnBatchExec(CPDFSDK_FormFillEnvironment* pFormFillEnv) { - m_pEventHandler->OnBatchExec(pFormFillEnv); + m_pEventRecorder->OnBatchExec(pFormFillEnv); } void CJS_EventContext::OnMenu_Exec(CPDFSDK_FormFillEnvironment* pFormFillEnv, const WideString& strTargetName) { - m_pEventHandler->OnMenu_Exec(pFormFillEnv, strTargetName); + m_pEventRecorder->OnMenu_Exec(pFormFillEnv, strTargetName); } diff --git a/fxjs/cjs_event_context.h b/fxjs/cjs_event_context.h index a9933e67b..1abc71e63 100644 --- a/fxjs/cjs_event_context.h +++ b/fxjs/cjs_event_context.h @@ -14,7 +14,7 @@ #include "core/fxcrt/unowned_ptr.h" #include "fxjs/ijs_event_context.h" -class CJS_EventHandler; +class CJS_EventRecorder; class CJS_Runtime; class CPDFSDK_FormFillEnvironment; @@ -123,13 +123,13 @@ class CJS_EventContext final : public IJS_EventContext { void OnExternal_Exec() override; CJS_Runtime* GetJSRuntime() const { return m_pRuntime.Get(); } - CJS_EventHandler* GetEventHandler() const { return m_pEventHandler.get(); } + CJS_EventRecorder* GetEventRecorder() const { return m_pEventRecorder.get(); } CPDFSDK_FormFillEnvironment* GetFormFillEnv(); private: UnownedPtr<CJS_Runtime> const m_pRuntime; - std::unique_ptr<CJS_EventHandler> m_pEventHandler; + std::unique_ptr<CJS_EventRecorder> m_pEventRecorder; bool m_bBusy; }; diff --git a/fxjs/cjs_eventhandler.cpp b/fxjs/cjs_eventrecorder.cpp index 921cf2aa6..df2892a05 100644 --- a/fxjs/cjs_eventhandler.cpp +++ b/fxjs/cjs_eventrecorder.cpp @@ -4,7 +4,7 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com -#include "fxjs/cjs_eventhandler.h" +#include "fxjs/cjs_eventrecorder.h" #include "core/fpdfdoc/cpdf_formfield.h" #include "fxjs/cjs_document.h" @@ -14,77 +14,78 @@ #include "fxjs/cjs_runtime.h" #include "fxjs/js_define.h" -CJS_EventHandler::CJS_EventHandler(CJS_EventContext* pContext) +CJS_EventRecorder::CJS_EventRecorder(CJS_EventContext* pContext) : m_pJSEventContext(pContext) {} -CJS_EventHandler::~CJS_EventHandler() {} +CJS_EventRecorder::~CJS_EventRecorder() {} -void CJS_EventHandler::OnApp_Init() { +void CJS_EventRecorder::OnApp_Init() { Initialize(JET_APP_INIT); } -void CJS_EventHandler::OnDoc_Open(CPDFSDK_FormFillEnvironment* pFormFillEnv, - const WideString& strTargetName) { +void CJS_EventRecorder::OnDoc_Open(CPDFSDK_FormFillEnvironment* pFormFillEnv, + const WideString& strTargetName) { Initialize(JET_DOC_OPEN); m_pTargetFormFillEnv.Reset(pFormFillEnv); m_strTargetName = strTargetName; } -void CJS_EventHandler::OnDoc_WillPrint( +void CJS_EventRecorder::OnDoc_WillPrint( CPDFSDK_FormFillEnvironment* pFormFillEnv) { Initialize(JET_DOC_WILLPRINT); m_pTargetFormFillEnv.Reset(pFormFillEnv); } -void CJS_EventHandler::OnDoc_DidPrint( +void CJS_EventRecorder::OnDoc_DidPrint( CPDFSDK_FormFillEnvironment* pFormFillEnv) { Initialize(JET_DOC_DIDPRINT); m_pTargetFormFillEnv.Reset(pFormFillEnv); } -void CJS_EventHandler::OnDoc_WillSave( +void CJS_EventRecorder::OnDoc_WillSave( CPDFSDK_FormFillEnvironment* pFormFillEnv) { Initialize(JET_DOC_WILLSAVE); m_pTargetFormFillEnv.Reset(pFormFillEnv); } -void CJS_EventHandler::OnDoc_DidSave( +void CJS_EventRecorder::OnDoc_DidSave( CPDFSDK_FormFillEnvironment* pFormFillEnv) { Initialize(JET_DOC_DIDSAVE); m_pTargetFormFillEnv.Reset(pFormFillEnv); } -void CJS_EventHandler::OnDoc_WillClose( +void CJS_EventRecorder::OnDoc_WillClose( CPDFSDK_FormFillEnvironment* pFormFillEnv) { Initialize(JET_DOC_WILLCLOSE); m_pTargetFormFillEnv.Reset(pFormFillEnv); } -void CJS_EventHandler::OnPage_Open(CPDFSDK_FormFillEnvironment* pFormFillEnv) { +void CJS_EventRecorder::OnPage_Open(CPDFSDK_FormFillEnvironment* pFormFillEnv) { Initialize(JET_PAGE_OPEN); m_pTargetFormFillEnv.Reset(pFormFillEnv); } -void CJS_EventHandler::OnPage_Close(CPDFSDK_FormFillEnvironment* pFormFillEnv) { +void CJS_EventRecorder::OnPage_Close( + CPDFSDK_FormFillEnvironment* pFormFillEnv) { Initialize(JET_PAGE_CLOSE); m_pTargetFormFillEnv.Reset(pFormFillEnv); } -void CJS_EventHandler::OnPage_InView( +void CJS_EventRecorder::OnPage_InView( CPDFSDK_FormFillEnvironment* pFormFillEnv) { Initialize(JET_PAGE_INVIEW); m_pTargetFormFillEnv.Reset(pFormFillEnv); } -void CJS_EventHandler::OnPage_OutView( +void CJS_EventRecorder::OnPage_OutView( CPDFSDK_FormFillEnvironment* pFormFillEnv) { Initialize(JET_PAGE_OUTVIEW); m_pTargetFormFillEnv.Reset(pFormFillEnv); } -void CJS_EventHandler::OnField_MouseEnter(bool bModifier, - bool bShift, - CPDF_FormField* pTarget) { +void CJS_EventRecorder::OnField_MouseEnter(bool bModifier, + bool bShift, + CPDF_FormField* pTarget) { Initialize(JET_FIELD_MOUSEENTER); m_bModifier = bModifier; @@ -93,9 +94,9 @@ void CJS_EventHandler::OnField_MouseEnter(bool bModifier, m_strTargetName = pTarget->GetFullName(); } -void CJS_EventHandler::OnField_MouseExit(bool bModifier, - bool bShift, - CPDF_FormField* pTarget) { +void CJS_EventRecorder::OnField_MouseExit(bool bModifier, + bool bShift, + CPDF_FormField* pTarget) { Initialize(JET_FIELD_MOUSEEXIT); m_bModifier = bModifier; @@ -103,9 +104,9 @@ void CJS_EventHandler::OnField_MouseExit(bool bModifier, m_strTargetName = pTarget->GetFullName(); } -void CJS_EventHandler::OnField_MouseDown(bool bModifier, - bool bShift, - CPDF_FormField* pTarget) { +void CJS_EventRecorder::OnField_MouseDown(bool bModifier, + bool bShift, + CPDF_FormField* pTarget) { Initialize(JET_FIELD_MOUSEDOWN); m_eEventType = JET_FIELD_MOUSEDOWN; @@ -114,9 +115,9 @@ void CJS_EventHandler::OnField_MouseDown(bool bModifier, m_strTargetName = pTarget->GetFullName(); } -void CJS_EventHandler::OnField_MouseUp(bool bModifier, - bool bShift, - CPDF_FormField* pTarget) { +void CJS_EventRecorder::OnField_MouseUp(bool bModifier, + bool bShift, + CPDF_FormField* pTarget) { Initialize(JET_FIELD_MOUSEUP); m_bModifier = bModifier; @@ -124,10 +125,10 @@ void CJS_EventHandler::OnField_MouseUp(bool bModifier, m_strTargetName = pTarget->GetFullName(); } -void CJS_EventHandler::OnField_Focus(bool bModifier, - bool bShift, - CPDF_FormField* pTarget, - WideString* pValue) { +void CJS_EventRecorder::OnField_Focus(bool bModifier, + bool bShift, + CPDF_FormField* pTarget, + WideString* pValue) { ASSERT(pValue); Initialize(JET_FIELD_FOCUS); @@ -137,10 +138,10 @@ void CJS_EventHandler::OnField_Focus(bool bModifier, m_pValue = pValue; } -void CJS_EventHandler::OnField_Blur(bool bModifier, - bool bShift, - CPDF_FormField* pTarget, - WideString* pValue) { +void CJS_EventRecorder::OnField_Blur(bool bModifier, + bool bShift, + CPDF_FormField* pTarget, + WideString* pValue) { ASSERT(pValue); Initialize(JET_FIELD_BLUR); @@ -150,18 +151,18 @@ void CJS_EventHandler::OnField_Blur(bool bModifier, m_pValue = pValue; } -void CJS_EventHandler::OnField_Keystroke(WideString* strChange, - const WideString& strChangeEx, - bool KeyDown, - bool bModifier, - int* pSelEnd, - int* pSelStart, - bool bShift, - CPDF_FormField* pTarget, - WideString* pValue, - bool bWillCommit, - bool bFieldFull, - bool* pbRc) { +void CJS_EventRecorder::OnField_Keystroke(WideString* strChange, + const WideString& strChangeEx, + bool KeyDown, + bool bModifier, + int* pSelEnd, + int* pSelStart, + bool bShift, + CPDF_FormField* pTarget, + WideString* pValue, + bool bWillCommit, + bool bFieldFull, + bool* pbRc) { ASSERT(pValue); ASSERT(pbRc); ASSERT(pSelStart); @@ -184,14 +185,14 @@ void CJS_EventHandler::OnField_Keystroke(WideString* strChange, m_bFieldFull = bFieldFull; } -void CJS_EventHandler::OnField_Validate(WideString* strChange, - const WideString& strChangeEx, - bool bKeyDown, - bool bModifier, - bool bShift, - CPDF_FormField* pTarget, - WideString* pValue, - bool* pbRc) { +void CJS_EventRecorder::OnField_Validate(WideString* strChange, + const WideString& strChangeEx, + bool bKeyDown, + bool bModifier, + bool bShift, + CPDF_FormField* pTarget, + WideString* pValue, + bool* pbRc) { ASSERT(pValue); ASSERT(pbRc); @@ -207,10 +208,10 @@ void CJS_EventHandler::OnField_Validate(WideString* strChange, m_pbRc = pbRc; } -void CJS_EventHandler::OnField_Calculate(CPDF_FormField* pSource, - CPDF_FormField* pTarget, - WideString* pValue, - bool* pRc) { +void CJS_EventRecorder::OnField_Calculate(CPDF_FormField* pSource, + CPDF_FormField* pTarget, + WideString* pValue, + bool* pRc) { ASSERT(pValue); ASSERT(pRc); @@ -223,9 +224,9 @@ void CJS_EventHandler::OnField_Calculate(CPDF_FormField* pSource, m_pbRc = pRc; } -void CJS_EventHandler::OnField_Format(CPDF_FormField* pTarget, - WideString* pValue, - bool bWillCommit) { +void CJS_EventRecorder::OnField_Format(CPDF_FormField* pTarget, + WideString* pValue, + bool bWillCommit) { ASSERT(pValue); Initialize(JET_FIELD_FORMAT); @@ -235,9 +236,9 @@ void CJS_EventHandler::OnField_Format(CPDF_FormField* pTarget, m_bWillCommit = bWillCommit; } -void CJS_EventHandler::OnScreen_Focus(bool bModifier, - bool bShift, - CPDFSDK_Annot* pScreen) { +void CJS_EventRecorder::OnScreen_Focus(bool bModifier, + bool bShift, + CPDFSDK_Annot* pScreen) { Initialize(JET_SCREEN_FOCUS); m_bModifier = bModifier; @@ -245,9 +246,9 @@ void CJS_EventHandler::OnScreen_Focus(bool bModifier, m_pTargetAnnot.Reset(pScreen); } -void CJS_EventHandler::OnScreen_Blur(bool bModifier, - bool bShift, - CPDFSDK_Annot* pScreen) { +void CJS_EventRecorder::OnScreen_Blur(bool bModifier, + bool bShift, + CPDFSDK_Annot* pScreen) { Initialize(JET_SCREEN_BLUR); m_bModifier = bModifier; @@ -255,9 +256,9 @@ void CJS_EventHandler::OnScreen_Blur(bool bModifier, m_pTargetAnnot.Reset(pScreen); } -void CJS_EventHandler::OnScreen_Open(bool bModifier, - bool bShift, - CPDFSDK_Annot* pScreen) { +void CJS_EventRecorder::OnScreen_Open(bool bModifier, + bool bShift, + CPDFSDK_Annot* pScreen) { Initialize(JET_SCREEN_OPEN); m_bModifier = bModifier; @@ -265,9 +266,9 @@ void CJS_EventHandler::OnScreen_Open(bool bModifier, m_pTargetAnnot.Reset(pScreen); } -void CJS_EventHandler::OnScreen_Close(bool bModifier, - bool bShift, - CPDFSDK_Annot* pScreen) { +void CJS_EventRecorder::OnScreen_Close(bool bModifier, + bool bShift, + CPDFSDK_Annot* pScreen) { Initialize(JET_SCREEN_CLOSE); m_bModifier = bModifier; @@ -275,9 +276,9 @@ void CJS_EventHandler::OnScreen_Close(bool bModifier, m_pTargetAnnot.Reset(pScreen); } -void CJS_EventHandler::OnScreen_MouseDown(bool bModifier, - bool bShift, - CPDFSDK_Annot* pScreen) { +void CJS_EventRecorder::OnScreen_MouseDown(bool bModifier, + bool bShift, + CPDFSDK_Annot* pScreen) { Initialize(JET_SCREEN_MOUSEDOWN); m_bModifier = bModifier; @@ -285,9 +286,9 @@ void CJS_EventHandler::OnScreen_MouseDown(bool bModifier, m_pTargetAnnot.Reset(pScreen); } -void CJS_EventHandler::OnScreen_MouseUp(bool bModifier, - bool bShift, - CPDFSDK_Annot* pScreen) { +void CJS_EventRecorder::OnScreen_MouseUp(bool bModifier, + bool bShift, + CPDFSDK_Annot* pScreen) { Initialize(JET_SCREEN_MOUSEUP); m_bModifier = bModifier; @@ -295,9 +296,9 @@ void CJS_EventHandler::OnScreen_MouseUp(bool bModifier, m_pTargetAnnot.Reset(pScreen); } -void CJS_EventHandler::OnScreen_MouseEnter(bool bModifier, - bool bShift, - CPDFSDK_Annot* pScreen) { +void CJS_EventRecorder::OnScreen_MouseEnter(bool bModifier, + bool bShift, + CPDFSDK_Annot* pScreen) { Initialize(JET_SCREEN_MOUSEENTER); m_bModifier = bModifier; @@ -305,9 +306,9 @@ void CJS_EventHandler::OnScreen_MouseEnter(bool bModifier, m_pTargetAnnot.Reset(pScreen); } -void CJS_EventHandler::OnScreen_MouseExit(bool bModifier, - bool bShift, - CPDFSDK_Annot* pScreen) { +void CJS_EventRecorder::OnScreen_MouseExit(bool bModifier, + bool bShift, + CPDFSDK_Annot* pScreen) { Initialize(JET_SCREEN_MOUSEEXIT); m_bModifier = bModifier; @@ -315,36 +316,36 @@ void CJS_EventHandler::OnScreen_MouseExit(bool bModifier, m_pTargetAnnot.Reset(pScreen); } -void CJS_EventHandler::OnScreen_InView(bool bModifier, - bool bShift, - CPDFSDK_Annot* pScreen) { +void CJS_EventRecorder::OnScreen_InView(bool bModifier, + bool bShift, + CPDFSDK_Annot* pScreen) { Initialize(JET_SCREEN_INVIEW); m_bModifier = bModifier; m_bShift = bShift; m_pTargetAnnot.Reset(pScreen); } -void CJS_EventHandler::OnScreen_OutView(bool bModifier, - bool bShift, - CPDFSDK_Annot* pScreen) { +void CJS_EventRecorder::OnScreen_OutView(bool bModifier, + bool bShift, + CPDFSDK_Annot* pScreen) { Initialize(JET_SCREEN_OUTVIEW); m_bModifier = bModifier; m_bShift = bShift; m_pTargetAnnot.Reset(pScreen); } -void CJS_EventHandler::OnLink_MouseUp( +void CJS_EventRecorder::OnLink_MouseUp( CPDFSDK_FormFillEnvironment* pTargetFormFillEnv) { Initialize(JET_LINK_MOUSEUP); m_pTargetFormFillEnv.Reset(pTargetFormFillEnv); } -void CJS_EventHandler::OnBookmark_MouseUp(CPDF_Bookmark* pBookMark) { +void CJS_EventRecorder::OnBookmark_MouseUp(CPDF_Bookmark* pBookMark) { Initialize(JET_BOOKMARK_MOUSEUP); m_pTargetBookMark = pBookMark; } -void CJS_EventHandler::OnMenu_Exec( +void CJS_EventRecorder::OnMenu_Exec( CPDFSDK_FormFillEnvironment* pTargetFormFillEnv, const WideString& strTargetName) { Initialize(JET_MENU_EXEC); @@ -352,21 +353,21 @@ void CJS_EventHandler::OnMenu_Exec( m_strTargetName = strTargetName; } -void CJS_EventHandler::OnExternal_Exec() { +void CJS_EventRecorder::OnExternal_Exec() { Initialize(JET_EXTERNAL_EXEC); } -void CJS_EventHandler::OnBatchExec( +void CJS_EventRecorder::OnBatchExec( CPDFSDK_FormFillEnvironment* pTargetFormFillEnv) { Initialize(JET_BATCH_EXEC); m_pTargetFormFillEnv.Reset(pTargetFormFillEnv); } -void CJS_EventHandler::OnConsole_Exec() { +void CJS_EventRecorder::OnConsole_Exec() { Initialize(JET_CONSOLE_EXEC); } -void CJS_EventHandler::Initialize(JS_EVENT_T type) { +void CJS_EventRecorder::Initialize(JS_EVENT_T type) { m_eEventType = type; m_strTargetName.clear(); @@ -395,15 +396,15 @@ void CJS_EventHandler::Initialize(JS_EVENT_T type) { m_bValid = true; } -void CJS_EventHandler::Destroy() { +void CJS_EventRecorder::Destroy() { m_bValid = false; } -bool CJS_EventHandler::IsValid() const { +bool CJS_EventRecorder::IsValid() const { return m_bValid; } -bool CJS_EventHandler::IsUserGesture() const { +bool CJS_EventRecorder::IsUserGesture() const { switch (m_eEventType) { case JET_FIELD_MOUSEDOWN: case JET_FIELD_MOUSEUP: @@ -418,34 +419,34 @@ bool CJS_EventHandler::IsUserGesture() const { } } -WideString& CJS_EventHandler::Change() { +WideString& CJS_EventRecorder::Change() { if (m_pWideStrChange) { return *m_pWideStrChange; } return m_WideStrChangeDu; } -WideString CJS_EventHandler::ChangeEx() const { +WideString CJS_EventRecorder::ChangeEx() const { return m_WideStrChangeEx; } -int CJS_EventHandler::CommitKey() const { +int CJS_EventRecorder::CommitKey() const { return m_nCommitKey; } -bool CJS_EventHandler::FieldFull() const { +bool CJS_EventRecorder::FieldFull() const { return m_bFieldFull; } -bool CJS_EventHandler::KeyDown() const { +bool CJS_EventRecorder::KeyDown() const { return m_bKeyDown; } -bool CJS_EventHandler::Modifier() const { +bool CJS_EventRecorder::Modifier() const { return m_bModifier; } -ByteStringView CJS_EventHandler::Name() const { +ByteStringView CJS_EventRecorder::Name() const { switch (m_eEventType) { case JET_APP_INIT: return "Init"; @@ -516,7 +517,7 @@ ByteStringView CJS_EventHandler::Name() const { } } -ByteStringView CJS_EventHandler::Type() const { +ByteStringView CJS_EventRecorder::Type() const { switch (m_eEventType) { case JET_APP_INIT: return "App"; @@ -571,33 +572,33 @@ ByteStringView CJS_EventHandler::Type() const { } } -bool& CJS_EventHandler::Rc() { +bool& CJS_EventRecorder::Rc() { return m_pbRc ? *m_pbRc : m_bRcDu; } -int CJS_EventHandler::SelEnd() const { +int CJS_EventRecorder::SelEnd() const { return m_pISelEnd ? *m_pISelEnd : m_nSelEndDu; } -int CJS_EventHandler::SelStart() const { +int CJS_EventRecorder::SelStart() const { return m_pISelStart ? *m_pISelStart : m_nSelStartDu; } -void CJS_EventHandler::SetSelEnd(int value) { +void CJS_EventRecorder::SetSelEnd(int value) { int& target = m_pISelEnd ? *m_pISelEnd : m_nSelEndDu; target = value; } -void CJS_EventHandler::SetSelStart(int value) { +void CJS_EventRecorder::SetSelStart(int value) { int& target = m_pISelStart ? *m_pISelStart : m_nSelStartDu; target = value; } -bool CJS_EventHandler::Shift() const { +bool CJS_EventRecorder::Shift() const { return m_bShift; } -CJS_Field* CJS_EventHandler::Source() { +CJS_Field* CJS_EventRecorder::Source() { CJS_Runtime* pRuntime = m_pJSEventContext->GetJSRuntime(); v8::Local<v8::Object> pDocObj = pRuntime->NewFXJSBoundObject( CJS_Document::GetObjDefnID(), FXJSOBJTYPE_DYNAMIC); @@ -623,7 +624,7 @@ CJS_Field* CJS_EventHandler::Source() { return pJSField; } -CJS_Field* CJS_EventHandler::Target_Field() { +CJS_Field* CJS_EventRecorder::Target_Field() { CJS_Runtime* pRuntime = m_pJSEventContext->GetJSRuntime(); v8::Local<v8::Object> pDocObj = pRuntime->NewFXJSBoundObject( CJS_Document::GetObjDefnID(), FXJSOBJTYPE_DYNAMIC); @@ -649,14 +650,14 @@ CJS_Field* CJS_EventHandler::Target_Field() { return pJSField; } -WideString& CJS_EventHandler::Value() { +WideString& CJS_EventRecorder::Value() { return *m_pValue; } -bool CJS_EventHandler::WillCommit() const { +bool CJS_EventRecorder::WillCommit() const { return m_bWillCommit; } -WideString CJS_EventHandler::TargetName() const { +WideString CJS_EventRecorder::TargetName() const { return m_strTargetName; } diff --git a/fxjs/cjs_eventhandler.h b/fxjs/cjs_eventrecorder.h index 4d797c192..c6174ec74 100644 --- a/fxjs/cjs_eventhandler.h +++ b/fxjs/cjs_eventrecorder.h @@ -4,8 +4,8 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com -#ifndef FXJS_CJS_EVENTHANDLER_H_ -#define FXJS_CJS_EVENTHANDLER_H_ +#ifndef FXJS_CJS_EVENTRECORDER_H_ +#define FXJS_CJS_EVENTRECORDER_H_ #include "core/fxcrt/fx_string.h" #include "core/fxcrt/fx_system.h" @@ -59,10 +59,10 @@ enum JS_EVENT_T { JET_LINK_MOUSEUP }; -class CJS_EventHandler { +class CJS_EventRecorder { public: - explicit CJS_EventHandler(CJS_EventContext* pContext); - virtual ~CJS_EventHandler(); + explicit CJS_EventRecorder(CJS_EventContext* pContext); + virtual ~CJS_EventRecorder(); void OnApp_Init(); @@ -201,4 +201,4 @@ class CJS_EventHandler { CPDFSDK_Annot::ObservedPtr m_pTargetAnnot; }; -#endif // FXJS_CJS_EVENTHANDLER_H_ +#endif // FXJS_CJS_EVENTRECORDER_H_ diff --git a/fxjs/cjs_global.cpp b/fxjs/cjs_global.cpp index 28d22149b..3d61c1775 100644 --- a/fxjs/cjs_global.cpp +++ b/fxjs/cjs_global.cpp @@ -15,7 +15,7 @@ #include "fxjs/cfx_globaldata.h" #include "fxjs/cfx_keyvalue.h" #include "fxjs/cjs_event_context.h" -#include "fxjs/cjs_eventhandler.h" +#include "fxjs/cjs_eventrecorder.h" #include "fxjs/cjs_object.h" #include "fxjs/js_define.h" #include "fxjs/js_resources.h" diff --git a/fxjs/cjs_publicmethods.cpp b/fxjs/cjs_publicmethods.cpp index 9cc2bbc60..0308671d7 100644 --- a/fxjs/cjs_publicmethods.cpp +++ b/fxjs/cjs_publicmethods.cpp @@ -26,7 +26,7 @@ #include "fpdfsdk/cpdfsdk_interactiveform.h" #include "fxjs/cjs_color.h" #include "fxjs/cjs_event_context.h" -#include "fxjs/cjs_eventhandler.h" +#include "fxjs/cjs_eventrecorder.h" #include "fxjs/cjs_field.h" #include "fxjs/cjs_object.h" #include "fxjs/cjs_runtime.h" @@ -121,7 +121,7 @@ ByteString CalculateString(double dValue, } #endif -WideString CalcMergedString(const CJS_EventHandler* event, +WideString CalcMergedString(const CJS_EventRecorder* event, const WideString& value, const WideString& change) { WideString prefix = value.Left(event->SelStart()); @@ -587,8 +587,8 @@ CJS_Result CJS_PublicMethods::AFNumber_Format( if (params.size() != 6) return CJS_Result::Failure(JSMessage::kParamError); - CJS_EventHandler* pEvent = - pRuntime->GetCurrentEventContext()->GetEventHandler(); + CJS_EventRecorder* pEvent = + pRuntime->GetCurrentEventContext()->GetEventRecorder(); if (!pEvent->m_pValue) return CJS_Result::Failure(WideString::FromASCII("No event handler")); @@ -695,7 +695,7 @@ CJS_Result CJS_PublicMethods::AFNumber_Keystroke( return CJS_Result::Failure(JSMessage::kParamError); CJS_EventContext* pContext = pRuntime->GetCurrentEventContext(); - CJS_EventHandler* pEvent = pContext->GetEventHandler(); + CJS_EventRecorder* pEvent = pContext->GetEventRecorder(); if (!pEvent->m_pValue) return CJS_Result::Failure(JSMessage::kBadObjectError); @@ -783,8 +783,8 @@ CJS_Result CJS_PublicMethods::AFPercent_Format( if (params.size() < 2) return CJS_Result::Failure(JSMessage::kParamError); - CJS_EventHandler* pEvent = - pRuntime->GetCurrentEventContext()->GetEventHandler(); + CJS_EventRecorder* pEvent = + pRuntime->GetCurrentEventContext()->GetEventRecorder(); if (!pEvent->m_pValue) return CJS_Result::Failure(JSMessage::kBadObjectError); @@ -880,7 +880,7 @@ CJS_Result CJS_PublicMethods::AFDate_FormatEx( return CJS_Result::Failure(JSMessage::kParamError); CJS_EventContext* pContext = pRuntime->GetCurrentEventContext(); - CJS_EventHandler* pEvent = pContext->GetEventHandler(); + CJS_EventRecorder* pEvent = pContext->GetEventRecorder(); if (!pEvent->m_pValue) return CJS_Result::Failure(JSMessage::kBadObjectError); @@ -955,7 +955,7 @@ CJS_Result CJS_PublicMethods::AFDate_KeystrokeEx( } CJS_EventContext* pContext = pRuntime->GetCurrentEventContext(); - CJS_EventHandler* pEvent = pContext->GetEventHandler(); + CJS_EventRecorder* pEvent = pContext->GetEventRecorder(); if (!pEvent->WillCommit()) return CJS_Result::Success(); @@ -1051,8 +1051,8 @@ CJS_Result CJS_PublicMethods::AFSpecial_Format( if (params.size() != 1) return CJS_Result::Failure(JSMessage::kParamError); - CJS_EventHandler* pEvent = - pRuntime->GetCurrentEventContext()->GetEventHandler(); + CJS_EventRecorder* pEvent = + pRuntime->GetCurrentEventContext()->GetEventRecorder(); if (!pEvent->m_pValue) return CJS_Result::Failure(JSMessage::kBadObjectError); @@ -1088,7 +1088,7 @@ CJS_Result CJS_PublicMethods::AFSpecial_KeystrokeEx( return CJS_Result::Failure(JSMessage::kParamError); CJS_EventContext* pContext = pRuntime->GetCurrentEventContext(); - CJS_EventHandler* pEvent = pContext->GetEventHandler(); + CJS_EventRecorder* pEvent = pContext->GetEventRecorder(); if (!pEvent->m_pValue) return CJS_Result::Failure(JSMessage::kBadObjectError); @@ -1169,8 +1169,8 @@ CJS_Result CJS_PublicMethods::AFSpecial_Keystroke( if (params.size() != 1) return CJS_Result::Failure(JSMessage::kParamError); - CJS_EventHandler* pEvent = - pRuntime->GetCurrentEventContext()->GetEventHandler(); + CJS_EventRecorder* pEvent = + pRuntime->GetCurrentEventContext()->GetEventRecorder(); if (!pEvent->m_pValue) return CJS_Result::Failure(JSMessage::kBadObjectError); @@ -1204,18 +1204,18 @@ CJS_Result CJS_PublicMethods::AFMergeChange( if (params.size() != 1) return CJS_Result::Failure(JSMessage::kParamError); - CJS_EventHandler* pEventHandler = - pRuntime->GetCurrentEventContext()->GetEventHandler(); + CJS_EventRecorder* pEventRecorder = + pRuntime->GetCurrentEventContext()->GetEventRecorder(); WideString swValue; - if (pEventHandler->m_pValue) - swValue = pEventHandler->Value(); + if (pEventRecorder->m_pValue) + swValue = pEventRecorder->Value(); - if (pEventHandler->WillCommit()) + if (pEventRecorder->WillCommit()) return CJS_Result::Success(pRuntime->NewString(swValue.AsStringView())); return CJS_Result::Success(pRuntime->NewString( - CalcMergedString(pEventHandler, swValue, pEventHandler->Change()) + CalcMergedString(pEventRecorder, swValue, pEventRecorder->Change()) .AsStringView())); } @@ -1364,8 +1364,8 @@ CJS_Result CJS_PublicMethods::AFSimple_Calculate( dValue = floor(dValue * FXSYS_pow(10, 6) + 0.49) / FXSYS_pow(10, 6); CJS_EventContext* pContext = pRuntime->GetCurrentEventContext(); - if (pContext->GetEventHandler()->m_pValue) { - pContext->GetEventHandler()->Value() = + if (pContext->GetEventRecorder()->m_pValue) { + pContext->GetEventRecorder()->Value() = pRuntime->ToWideString(pRuntime->NewNumber(dValue)); } @@ -1381,7 +1381,7 @@ CJS_Result CJS_PublicMethods::AFRange_Validate( return CJS_Result::Failure(JSMessage::kParamError); CJS_EventContext* pContext = pRuntime->GetCurrentEventContext(); - CJS_EventHandler* pEvent = pContext->GetEventHandler(); + CJS_EventRecorder* pEvent = pContext->GetEventRecorder(); if (!pEvent->m_pValue) return CJS_Result::Failure(JSMessage::kBadObjectError); diff --git a/fxjs/cjs_publicmethods_embeddertest.cpp b/fxjs/cjs_publicmethods_embeddertest.cpp index 56f04aa72..aefcb636f 100644 --- a/fxjs/cjs_publicmethods_embeddertest.cpp +++ b/fxjs/cjs_publicmethods_embeddertest.cpp @@ -190,7 +190,7 @@ TEST_F(CJS_PublicMethodsEmbedderTest, AFSimple_CalculateSum) { runtime.NewEventContext(); WideString result; - runtime.GetCurrentEventContext()->GetEventHandler()->m_pValue = &result; + runtime.GetCurrentEventContext()->GetEventRecorder()->m_pValue = &result; auto ary = runtime.NewArray(); runtime.PutArrayElement(ary, 0, runtime.NewString("Calc1_A")); @@ -203,7 +203,7 @@ TEST_F(CJS_PublicMethodsEmbedderTest, AFSimple_CalculateSum) { CJS_Result ret = CJS_PublicMethods::AFSimple_Calculate(&runtime, params); UnloadPage(page); - runtime.GetCurrentEventContext()->GetEventHandler()->m_pValue = nullptr; + runtime.GetCurrentEventContext()->GetEventRecorder()->m_pValue = nullptr; ASSERT_TRUE(!ret.HasError()); ASSERT_TRUE(!ret.HasReturn()); @@ -223,7 +223,7 @@ TEST_F(CJS_PublicMethodsEmbedderTest, AFNumber_Keystroke) { CPDFSDKFormFillEnvironmentFromFPDFFormHandle(form_handle())); runtime.NewEventContext(); - auto* handler = runtime.GetCurrentEventContext()->GetEventHandler(); + auto* handler = runtime.GetCurrentEventContext()->GetEventRecorder(); bool valid = true; WideString result = L"-10"; diff --git a/fxjs/cjs_runtime.cpp b/fxjs/cjs_runtime.cpp index 56a561779..e488c2601 100644 --- a/fxjs/cjs_runtime.cpp +++ b/fxjs/cjs_runtime.cpp @@ -19,7 +19,7 @@ #include "fxjs/cjs_document.h" #include "fxjs/cjs_event.h" #include "fxjs/cjs_event_context.h" -#include "fxjs/cjs_eventhandler.h" +#include "fxjs/cjs_eventrecorder.h" #include "fxjs/cjs_field.h" #include "fxjs/cjs_font.h" #include "fxjs/cjs_global.h" diff --git a/fxjs/cjs_runtime.h b/fxjs/cjs_runtime.h index 6b14b8f91..33c41f2d7 100644 --- a/fxjs/cjs_runtime.h +++ b/fxjs/cjs_runtime.h @@ -15,7 +15,7 @@ #include "core/fxcrt/observable.h" #include "fpdfsdk/cpdfsdk_formfillenvironment.h" #include "fxjs/cfxjs_engine.h" -#include "fxjs/cjs_eventhandler.h" +#include "fxjs/cjs_eventrecorder.h" #include "fxjs/ijs_runtime.h" class CJS_EventContext; diff --git a/fxjs/cjs_util.cpp b/fxjs/cjs_util.cpp index 18faf6181..b39097599 100644 --- a/fxjs/cjs_util.cpp +++ b/fxjs/cjs_util.cpp @@ -17,7 +17,7 @@ #include "build/build_config.h" #include "core/fxcrt/fx_extension.h" #include "fxjs/cjs_event_context.h" -#include "fxjs/cjs_eventhandler.h" +#include "fxjs/cjs_eventrecorder.h" #include "fxjs/cjs_object.h" #include "fxjs/cjs_publicmethods.h" #include "fxjs/cjs_runtime.h" |