summaryrefslogtreecommitdiff
path: root/fxjs
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2018-07-11 17:23:53 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-07-11 17:23:53 +0000
commitb165ffb64e59998ec6d5f76c82bd2fe53734b3cd (patch)
tree2d1de5e7dc0fc4b6a4e1fbaa8437e57f9acfd4e8 /fxjs
parent7c694a4632dc3b11e26d66a44e598a211913d02a (diff)
downloadpdfium-b165ffb64e59998ec6d5f76c82bd2fe53734b3cd.tar.xz
Use JSGetObject() in more places.chromium/3489
Change-Id: I7f26709bdad56cc2712f21e8e644be7c53ec5ec4 Reviewed-on: https://pdfium-review.googlesource.com/37513 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
Diffstat (limited to 'fxjs')
-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;