summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--fxjs/cjs_app.cpp15
-rw-r--r--fxjs/cjs_document.cpp33
-rw-r--r--fxjs/cjs_runtime.cpp8
3 files changed, 18 insertions, 38 deletions
diff --git a/fxjs/cjs_app.cpp b/fxjs/cjs_app.cpp
index 4648f462b4..ad155b787c 100644
--- a/fxjs/cjs_app.cpp
+++ b/fxjs/cjs_app.cpp
@@ -102,12 +102,8 @@ CJS_App::CJS_App(v8::Local<v8::Object> pObject, CJS_Runtime* pRuntime)
CJS_App::~CJS_App() = default;
CJS_Return CJS_App::get_active_docs(CJS_Runtime* pRuntime) {
- CJS_Document* pJSDocument = nullptr;
v8::Local<v8::Object> pObj = pRuntime->GetThisObj();
- if (CFXJS_Engine::GetObjDefnID(pObj) == CJS_Document::GetObjDefnID()) {
- pJSDocument =
- static_cast<CJS_Document*>(CFXJS_Engine::GetObjectPrivate(pObj));
- }
+ CJS_Document* pJSDocument = JSGetObject<CJS_Document>(pObj);
v8::Local<v8::Array> aDocs = pRuntime->NewArray();
pRuntime->PutArrayElement(
aDocs, 0,
@@ -398,14 +394,11 @@ void CJS_App::ClearTimerCommon(CJS_Runtime* pRuntime,
return;
v8::Local<v8::Object> pObj = pRuntime->ToObject(param);
- if (CFXJS_Engine::GetObjDefnID(pObj) != CJS_TimerObj::GetObjDefnID())
- return;
-
- CJS_Object* pJSObj = CFXJS_Engine::GetObjectPrivate(pObj);
- if (!pJSObj)
+ CJS_TimerObj* pTimer = JSGetObject<CJS_TimerObj>(pObj);
+ if (!pTimer)
return;
- GlobalTimer::Cancel(static_cast<CJS_TimerObj*>(pJSObj)->GetTimerID());
+ GlobalTimer::Cancel(pTimer->GetTimerID());
}
CJS_Return CJS_App::execMenuItem(
diff --git a/fxjs/cjs_document.cpp b/fxjs/cjs_document.cpp
index 35e3e53437..f5b0af4c13 100644
--- a/fxjs/cjs_document.cpp
+++ b/fxjs/cjs_document.cpp
@@ -354,22 +354,16 @@ CJS_Return CJS_Document::print(
if (nLength == 9) {
if (params[8]->IsObject()) {
v8::Local<v8::Object> pObj = pRuntime->ToObject(params[8]);
- if (CFXJS_Engine::GetObjDefnID(pObj) ==
- CJS_PrintParamsObj::GetObjDefnID()) {
- v8::Local<v8::Object> pObj = pRuntime->ToObject(params[8]);
- CJS_Object* pJSObj = CFXJS_Engine::GetObjectPrivate(pObj);
- if (pJSObj) {
- CJS_PrintParamsObj* printObj =
- static_cast<CJS_PrintParamsObj*>(pJSObj);
- bUI = printObj->GetUI();
- nStart = printObj->GetStart();
- nEnd = printObj->GetEnd();
- bSilent = printObj->GetSilent();
- bShrinkToFit = printObj->GetShrinkToFit();
- bPrintAsImage = printObj->GetPrintAsImage();
- bReverse = printObj->GetReverse();
- bAnnotations = printObj->GetAnnotations();
- }
+ CJS_PrintParamsObj* pPrintObj = JSGetObject<CJS_PrintParamsObj>(pObj);
+ if (pPrintObj) {
+ bUI = pPrintObj->GetUI();
+ nStart = pPrintObj->GetStart();
+ nEnd = pPrintObj->GetEnd();
+ bSilent = pPrintObj->GetSilent();
+ bShrinkToFit = pPrintObj->GetShrinkToFit();
+ bPrintAsImage = pPrintObj->GetPrintAsImage();
+ bReverse = pPrintObj->GetReverse();
+ bAnnotations = pPrintObj->GetAnnotations();
}
}
} else {
@@ -1109,13 +1103,8 @@ CJS_Return CJS_Document::addIcon(
if (!params[1]->IsObject())
return CJS_Return(JSMessage::kTypeError);
- v8::Local<v8::Object> pJSIcon = pRuntime->ToObject(params[1]);
- if (CFXJS_Engine::GetObjDefnID(pJSIcon) != CJS_Icon::GetObjDefnID())
- return CJS_Return(JSMessage::kTypeError);
-
v8::Local<v8::Object> pObj = pRuntime->ToObject(params[1]);
- CJS_Object* obj = CFXJS_Engine::GetObjectPrivate(pObj);
- if (!obj)
+ if (!JSGetObject<CJS_Icon>(pObj))
return CJS_Return(JSMessage::kTypeError);
WideString swIconName = pRuntime->ToWideString(params[0]);
diff --git a/fxjs/cjs_runtime.cpp b/fxjs/cjs_runtime.cpp
index f867e31340..96253c08bf 100644
--- a/fxjs/cjs_runtime.cpp
+++ b/fxjs/cjs_runtime.cpp
@@ -161,12 +161,10 @@ void CJS_Runtime::SetFormFillEnvToDocument() {
v8::Context::Scope context_scope(context);
v8::Local<v8::Object> pThis = GetThisObj();
- if (pThis.IsEmpty() ||
- CFXJS_Engine::GetObjDefnID(pThis) != CJS_Document::GetObjDefnID()) {
+ if (pThis.IsEmpty())
return;
- }
- auto* pJSDocument =
- static_cast<CJS_Document*>(CFXJS_Engine::GetObjectPrivate(pThis));
+
+ CJS_Document* pJSDocument = JSGetObject<CJS_Document>(pThis);
if (!pJSDocument)
return;