summaryrefslogtreecommitdiff
path: root/fpdfsdk
diff options
context:
space:
mode:
Diffstat (limited to 'fpdfsdk')
-rw-r--r--fpdfsdk/javascript/JS_EventHandler.cpp57
-rw-r--r--fpdfsdk/javascript/JS_EventHandler.h6
-rw-r--r--fpdfsdk/javascript/app.cpp2
-rw-r--r--fpdfsdk/javascript/cjs_runtime.cpp4
-rw-r--r--fpdfsdk/javascript/cjs_runtime.h3
-rw-r--r--fpdfsdk/javascript/global.cpp2
-rw-r--r--fpdfsdk/javascript/global.h2
7 files changed, 37 insertions, 39 deletions
diff --git a/fpdfsdk/javascript/JS_EventHandler.cpp b/fpdfsdk/javascript/JS_EventHandler.cpp
index bf4062301d..cec7735dc1 100644
--- a/fpdfsdk/javascript/JS_EventHandler.cpp
+++ b/fpdfsdk/javascript/JS_EventHandler.cpp
@@ -45,60 +45,60 @@ void CJS_EventHandler::OnApp_Init() {
void CJS_EventHandler::OnDoc_Open(CPDFSDK_FormFillEnvironment* pFormFillEnv,
const CFX_WideString& strTargetName) {
Initial(JET_DOC_OPEN);
- m_pTargetFormFillEnv = pFormFillEnv;
+ m_pTargetFormFillEnv.Reset(pFormFillEnv);
m_strTargetName = strTargetName;
}
void CJS_EventHandler::OnDoc_WillPrint(
CPDFSDK_FormFillEnvironment* pFormFillEnv) {
Initial(JET_DOC_WILLPRINT);
- m_pTargetFormFillEnv = pFormFillEnv;
+ m_pTargetFormFillEnv.Reset(pFormFillEnv);
}
void CJS_EventHandler::OnDoc_DidPrint(
CPDFSDK_FormFillEnvironment* pFormFillEnv) {
Initial(JET_DOC_DIDPRINT);
- m_pTargetFormFillEnv = pFormFillEnv;
+ m_pTargetFormFillEnv.Reset(pFormFillEnv);
}
void CJS_EventHandler::OnDoc_WillSave(
CPDFSDK_FormFillEnvironment* pFormFillEnv) {
Initial(JET_DOC_WILLSAVE);
- m_pTargetFormFillEnv = pFormFillEnv;
+ m_pTargetFormFillEnv.Reset(pFormFillEnv);
}
void CJS_EventHandler::OnDoc_DidSave(
CPDFSDK_FormFillEnvironment* pFormFillEnv) {
Initial(JET_DOC_DIDSAVE);
- m_pTargetFormFillEnv = pFormFillEnv;
+ m_pTargetFormFillEnv.Reset(pFormFillEnv);
}
void CJS_EventHandler::OnDoc_WillClose(
CPDFSDK_FormFillEnvironment* pFormFillEnv) {
Initial(JET_DOC_WILLCLOSE);
- m_pTargetFormFillEnv = pFormFillEnv;
+ m_pTargetFormFillEnv.Reset(pFormFillEnv);
}
void CJS_EventHandler::OnPage_Open(CPDFSDK_FormFillEnvironment* pFormFillEnv) {
Initial(JET_PAGE_OPEN);
- m_pTargetFormFillEnv = pFormFillEnv;
+ m_pTargetFormFillEnv.Reset(pFormFillEnv);
}
void CJS_EventHandler::OnPage_Close(CPDFSDK_FormFillEnvironment* pFormFillEnv) {
Initial(JET_PAGE_CLOSE);
- m_pTargetFormFillEnv = pFormFillEnv;
+ m_pTargetFormFillEnv.Reset(pFormFillEnv);
}
void CJS_EventHandler::OnPage_InView(
CPDFSDK_FormFillEnvironment* pFormFillEnv) {
Initial(JET_PAGE_INVIEW);
- m_pTargetFormFillEnv = pFormFillEnv;
+ m_pTargetFormFillEnv.Reset(pFormFillEnv);
}
void CJS_EventHandler::OnPage_OutView(
CPDFSDK_FormFillEnvironment* pFormFillEnv) {
Initial(JET_PAGE_OUTVIEW);
- m_pTargetFormFillEnv = pFormFillEnv;
+ m_pTargetFormFillEnv.Reset(pFormFillEnv);
}
void CJS_EventHandler::OnField_MouseEnter(bool bModifier,
@@ -247,7 +247,7 @@ void CJS_EventHandler::OnScreen_Focus(bool bModifier,
m_bModifier = bModifier;
m_bShift = bShift;
- m_pTargetAnnot = pScreen;
+ m_pTargetAnnot.Reset(pScreen);
}
void CJS_EventHandler::OnScreen_Blur(bool bModifier,
@@ -257,7 +257,7 @@ void CJS_EventHandler::OnScreen_Blur(bool bModifier,
m_bModifier = bModifier;
m_bShift = bShift;
- m_pTargetAnnot = pScreen;
+ m_pTargetAnnot.Reset(pScreen);
}
void CJS_EventHandler::OnScreen_Open(bool bModifier,
@@ -267,7 +267,7 @@ void CJS_EventHandler::OnScreen_Open(bool bModifier,
m_bModifier = bModifier;
m_bShift = bShift;
- m_pTargetAnnot = pScreen;
+ m_pTargetAnnot.Reset(pScreen);
}
void CJS_EventHandler::OnScreen_Close(bool bModifier,
@@ -277,7 +277,7 @@ void CJS_EventHandler::OnScreen_Close(bool bModifier,
m_bModifier = bModifier;
m_bShift = bShift;
- m_pTargetAnnot = pScreen;
+ m_pTargetAnnot.Reset(pScreen);
}
void CJS_EventHandler::OnScreen_MouseDown(bool bModifier,
@@ -287,7 +287,7 @@ void CJS_EventHandler::OnScreen_MouseDown(bool bModifier,
m_bModifier = bModifier;
m_bShift = bShift;
- m_pTargetAnnot = pScreen;
+ m_pTargetAnnot.Reset(pScreen);
}
void CJS_EventHandler::OnScreen_MouseUp(bool bModifier,
@@ -297,7 +297,7 @@ void CJS_EventHandler::OnScreen_MouseUp(bool bModifier,
m_bModifier = bModifier;
m_bShift = bShift;
- m_pTargetAnnot = pScreen;
+ m_pTargetAnnot.Reset(pScreen);
}
void CJS_EventHandler::OnScreen_MouseEnter(bool bModifier,
@@ -307,7 +307,7 @@ void CJS_EventHandler::OnScreen_MouseEnter(bool bModifier,
m_bModifier = bModifier;
m_bShift = bShift;
- m_pTargetAnnot = pScreen;
+ m_pTargetAnnot.Reset(pScreen);
}
void CJS_EventHandler::OnScreen_MouseExit(bool bModifier,
@@ -317,38 +317,35 @@ void CJS_EventHandler::OnScreen_MouseExit(bool bModifier,
m_bModifier = bModifier;
m_bShift = bShift;
- m_pTargetAnnot = pScreen;
+ m_pTargetAnnot.Reset(pScreen);
}
void CJS_EventHandler::OnScreen_InView(bool bModifier,
bool bShift,
CPDFSDK_Annot* pScreen) {
Initial(JET_SCREEN_INVIEW);
-
m_bModifier = bModifier;
m_bShift = bShift;
- m_pTargetAnnot = pScreen;
+ m_pTargetAnnot.Reset(pScreen);
}
void CJS_EventHandler::OnScreen_OutView(bool bModifier,
bool bShift,
CPDFSDK_Annot* pScreen) {
Initial(JET_SCREEN_OUTVIEW);
-
m_bModifier = bModifier;
m_bShift = bShift;
- m_pTargetAnnot = pScreen;
+ m_pTargetAnnot.Reset(pScreen);
}
void CJS_EventHandler::OnLink_MouseUp(
CPDFSDK_FormFillEnvironment* pTargetFormFillEnv) {
Initial(JET_LINK_MOUSEUP);
- m_pTargetFormFillEnv = pTargetFormFillEnv;
+ m_pTargetFormFillEnv.Reset(pTargetFormFillEnv);
}
void CJS_EventHandler::OnBookmark_MouseUp(CPDF_Bookmark* pBookMark) {
Initial(JET_BOOKMARK_MOUSEUP);
-
m_pTargetBookMark = pBookMark;
}
@@ -356,7 +353,7 @@ void CJS_EventHandler::OnMenu_Exec(
CPDFSDK_FormFillEnvironment* pTargetFormFillEnv,
const CFX_WideString& strTargetName) {
Initial(JET_MENU_EXEC);
- m_pTargetFormFillEnv = pTargetFormFillEnv;
+ m_pTargetFormFillEnv.Reset(pTargetFormFillEnv);
m_strTargetName = strTargetName;
}
@@ -367,7 +364,7 @@ void CJS_EventHandler::OnExternal_Exec() {
void CJS_EventHandler::OnBatchExec(
CPDFSDK_FormFillEnvironment* pTargetFormFillEnv) {
Initial(JET_BATCH_EXEC);
- m_pTargetFormFillEnv = pTargetFormFillEnv;
+ m_pTargetFormFillEnv.Reset(pTargetFormFillEnv);
}
void CJS_EventHandler::OnConsole_Exec() {
@@ -397,8 +394,8 @@ void CJS_EventHandler::Initial(JS_EVENT_T type) {
m_bRcDu = false;
m_pTargetBookMark = nullptr;
- m_pTargetFormFillEnv = nullptr;
- m_pTargetAnnot = nullptr;
+ m_pTargetFormFillEnv.Reset();
+ m_pTargetAnnot.Reset();
m_bValid = true;
}
@@ -603,7 +600,7 @@ Field* CJS_EventHandler::Source() {
static_cast<CJS_Document*>(pRuntime->GetObjectPrivate(pDocObj));
Document* pDocument = (Document*)pJSDocument->GetEmbedObject();
pDocument->SetFormFillEnv(m_pTargetFormFillEnv
- ? m_pTargetFormFillEnv
+ ? m_pTargetFormFillEnv.Get()
: m_pJSEventContext->GetFormFillEnv());
CJS_Field* pJSField =
@@ -627,7 +624,7 @@ Field* CJS_EventHandler::Target_Field() {
static_cast<CJS_Document*>(pRuntime->GetObjectPrivate(pDocObj));
Document* pDocument = (Document*)pJSDocument->GetEmbedObject();
pDocument->SetFormFillEnv(m_pTargetFormFillEnv
- ? m_pTargetFormFillEnv
+ ? m_pTargetFormFillEnv.Get()
: m_pJSEventContext->GetFormFillEnv());
CJS_Field* pJSField =
diff --git a/fpdfsdk/javascript/JS_EventHandler.h b/fpdfsdk/javascript/JS_EventHandler.h
index ff8ff9e301..b9836b04e4 100644
--- a/fpdfsdk/javascript/JS_EventHandler.h
+++ b/fpdfsdk/javascript/JS_EventHandler.h
@@ -9,10 +9,10 @@
#include "core/fxcrt/fx_string.h"
#include "core/fxcrt/fx_system.h"
+#include "fpdfsdk/cpdfsdk_formfillenvironment.h"
class CJS_EventContext;
class CPDFSDK_Annot;
-class CPDFSDK_FormFillEnvironment;
class CPDF_Bookmark;
class CPDF_FormField;
class Field;
@@ -189,8 +189,8 @@ class CJS_EventHandler {
bool m_bRcDu;
CPDF_Bookmark* m_pTargetBookMark;
- CPDFSDK_FormFillEnvironment* m_pTargetFormFillEnv;
- CPDFSDK_Annot* m_pTargetAnnot;
+ CPDFSDK_FormFillEnvironment::ObservedPtr m_pTargetFormFillEnv;
+ CPDFSDK_Annot::ObservedPtr m_pTargetAnnot;
};
#endif // FPDFSDK_JAVASCRIPT_JS_EVENTHANDLER_H_
diff --git a/fpdfsdk/javascript/app.cpp b/fpdfsdk/javascript/app.cpp
index 668156f0aa..0c75f6be4a 100644
--- a/fpdfsdk/javascript/app.cpp
+++ b/fpdfsdk/javascript/app.cpp
@@ -55,7 +55,7 @@ class GlobalTimer {
const uint32_t m_dwTimeOut;
const CFX_WideString m_swJScript;
CJS_Runtime::ObservedPtr m_pRuntime;
- CPDFSDK_FormFillEnvironment* const m_pFormFillEnv;
+ CPDFSDK_FormFillEnvironment::ObservedPtr m_pFormFillEnv;
};
GlobalTimer::GlobalTimer(app* pObj,
diff --git a/fpdfsdk/javascript/cjs_runtime.cpp b/fpdfsdk/javascript/cjs_runtime.cpp
index 8466e4d3fd..1ece0b6f79 100644
--- a/fpdfsdk/javascript/cjs_runtime.cpp
+++ b/fpdfsdk/javascript/cjs_runtime.cpp
@@ -187,11 +187,11 @@ void CJS_Runtime::SetFormFillEnvToDocument() {
if (!pDocument)
return;
- pDocument->SetFormFillEnv(m_pFormFillEnv);
+ pDocument->SetFormFillEnv(m_pFormFillEnv.Get());
}
CPDFSDK_FormFillEnvironment* CJS_Runtime::GetFormFillEnv() const {
- return m_pFormFillEnv;
+ return m_pFormFillEnv.Get();
}
int CJS_Runtime::ExecuteScript(const CFX_WideString& script,
diff --git a/fpdfsdk/javascript/cjs_runtime.h b/fpdfsdk/javascript/cjs_runtime.h
index 039e24b63e..0bde51f9de 100644
--- a/fpdfsdk/javascript/cjs_runtime.h
+++ b/fpdfsdk/javascript/cjs_runtime.h
@@ -15,6 +15,7 @@
#include "core/fxcrt/cfx_observable.h"
#include "core/fxcrt/fx_basic.h"
+#include "fpdfsdk/cpdfsdk_formfillenvironment.h"
#include "fpdfsdk/javascript/JS_EventHandler.h"
#include "fpdfsdk/javascript/ijs_runtime.h"
#include "fxjs/fxjs_v8.h"
@@ -61,7 +62,7 @@ class CJS_Runtime : public IJS_Runtime,
void SetFormFillEnvToDocument();
std::vector<std::unique_ptr<CJS_EventContext>> m_EventContextArray;
- CPDFSDK_FormFillEnvironment* const m_pFormFillEnv;
+ CPDFSDK_FormFillEnvironment::ObservedPtr m_pFormFillEnv;
bool m_bBlocking;
bool m_isolateManaged;
std::set<FieldEvent> m_FieldEventSet;
diff --git a/fpdfsdk/javascript/global.cpp b/fpdfsdk/javascript/global.cpp
index 7dd8ab57be..a450606b1a 100644
--- a/fpdfsdk/javascript/global.cpp
+++ b/fpdfsdk/javascript/global.cpp
@@ -55,7 +55,7 @@ JSGlobalAlternate::~JSGlobalAlternate() {
}
void JSGlobalAlternate::Initial(CPDFSDK_FormFillEnvironment* pFormFillEnv) {
- m_pFormFillEnv = pFormFillEnv;
+ m_pFormFillEnv.Reset(pFormFillEnv);
m_pGlobalData = CJS_GlobalData::GetRetainedInstance(pFormFillEnv);
UpdateGlobalPersistentVariables();
}
diff --git a/fpdfsdk/javascript/global.h b/fpdfsdk/javascript/global.h
index 50dfcf3795..e313929bea 100644
--- a/fpdfsdk/javascript/global.h
+++ b/fpdfsdk/javascript/global.h
@@ -68,7 +68,7 @@ class JSGlobalAlternate : public CJS_EmbedObj {
std::map<CFX_ByteString, JSGlobalData*> m_mapGlobal;
CFX_WideString m_sFilePath;
CJS_GlobalData* m_pGlobalData;
- CPDFSDK_FormFillEnvironment* m_pFormFillEnv;
+ CPDFSDK_FormFillEnvironment::ObservedPtr m_pFormFillEnv;
};
class CJS_Global : public CJS_Object {