summaryrefslogtreecommitdiff
path: root/fpdfsdk/src/javascript/app.cpp
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2015-10-06 11:45:28 -0700
committerTom Sepez <tsepez@chromium.org>2015-10-06 11:45:28 -0700
commitcd56a7d6fb05bd0babf316a84280a26ecc649d45 (patch)
tree65a4ff0aa976f364e46d1ec69ebbe34ddbc99e90 /fpdfsdk/src/javascript/app.cpp
parent3745841a4c4ab915c98865c1dd71f9debc3e2f99 (diff)
downloadpdfium-cd56a7d6fb05bd0babf316a84280a26ecc649d45.tar.xz
Merge to XFA: Store object definition ID in each js_class.
Manual edits in JS_Define.h. (cherry picked from commit f0a5b2803c09f3605dcd606e764ef604f0d2a8ea) Original Review URL: https://codereview.chromium.org/1382263002 . R=thestig@chromium.org Review URL: https://codereview.chromium.org/1382683008 .
Diffstat (limited to 'fpdfsdk/src/javascript/app.cpp')
-rw-r--r--fpdfsdk/src/javascript/app.cpp94
1 files changed, 32 insertions, 62 deletions
diff --git a/fpdfsdk/src/javascript/app.cpp b/fpdfsdk/src/javascript/app.cpp
index 892712243a..ae9001f04c 100644
--- a/fpdfsdk/src/javascript/app.cpp
+++ b/fpdfsdk/src/javascript/app.cpp
@@ -125,14 +125,12 @@ FX_BOOL app::activeDocs(IFXJS_Context* cc,
CJS_Document* pJSDocument = NULL;
if (pDoc == pCurDoc) {
v8::Local<v8::Object> pObj = FXJS_GetThisObj(pRuntime->GetIsolate());
- if (FXJS_GetObjDefnID(pObj) ==
- FXJS_GetObjDefnID(pRuntime->GetIsolate(), L"Document"))
+ if (FXJS_GetObjDefnID(pObj) == CJS_Document::g_nObjDefnID)
pJSDocument =
(CJS_Document*)FXJS_GetPrivate(pRuntime->GetIsolate(), pObj);
} else {
v8::Local<v8::Object> pObj = FXJS_NewFxDynamicObj(
- pRuntime->GetIsolate(), pContext,
- FXJS_GetObjDefnID(pRuntime->GetIsolate(), L"Document"));
+ pRuntime->GetIsolate(), pContext, CJS_Document::g_nObjDefnID);
pJSDocument =
(CJS_Document*)FXJS_GetPrivate(pRuntime->GetIsolate(), pObj);
ASSERT(pJSDocument != NULL);
@@ -421,20 +419,13 @@ FX_BOOL app::setInterval(IFXJS_Context* cc,
m_aTimer.Add(pTimer);
v8::Local<v8::Object> pRetObj = FXJS_NewFxDynamicObj(
- pRuntime->GetIsolate(), pContext,
- FXJS_GetObjDefnID(pRuntime->GetIsolate(), L"TimerObj"));
-
+ pRuntime->GetIsolate(), pContext, CJS_TimerObj::g_nObjDefnID);
CJS_TimerObj* pJS_TimerObj =
(CJS_TimerObj*)FXJS_GetPrivate(pRuntime->GetIsolate(), pRetObj);
- ASSERT(pJS_TimerObj != NULL);
-
TimerObj* pTimerObj = (TimerObj*)pJS_TimerObj->GetEmbedObject();
- ASSERT(pTimerObj != NULL);
-
pTimerObj->SetTimer(pTimer);
vRet = pRetObj;
-
return TRUE;
}
@@ -469,20 +460,13 @@ FX_BOOL app::setTimeOut(IFXJS_Context* cc,
m_aTimer.Add(pTimer);
v8::Local<v8::Object> pRetObj = FXJS_NewFxDynamicObj(
- pRuntime->GetIsolate(), pContext,
- FXJS_GetObjDefnID(pRuntime->GetIsolate(), L"TimerObj"));
-
+ pRuntime->GetIsolate(), pContext, CJS_TimerObj::g_nObjDefnID);
CJS_TimerObj* pJS_TimerObj =
(CJS_TimerObj*)FXJS_GetPrivate(pRuntime->GetIsolate(), pRetObj);
- ASSERT(pJS_TimerObj != NULL);
-
TimerObj* pTimerObj = (TimerObj*)pJS_TimerObj->GetEmbedObject();
- ASSERT(pTimerObj != NULL);
-
pTimerObj->SetTimer(pTimer);
vRet = pRetObj;
-
return TRUE;
}
@@ -491,35 +475,28 @@ FX_BOOL app::clearTimeOut(IFXJS_Context* cc,
CJS_Value& vRet,
CFX_WideString& sError) {
CJS_Context* pContext = (CJS_Context*)cc;
- ASSERT(pContext != NULL);
- CJS_Runtime* pRuntime = pContext->GetJSRuntime();
- ASSERT(pRuntime != NULL);
-
if (params.size() != 1) {
- sError = JSGetStringFromID((CJS_Context*)cc, IDS_STRING_JSPARAMERROR);
+ sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
return FALSE;
}
if (params[0].GetType() == CJS_Value::VT_fxobject) {
v8::Local<v8::Object> pObj = params[0].ToV8Object();
- {
- if (FXJS_GetObjDefnID(pObj) ==
- FXJS_GetObjDefnID(pRuntime->GetIsolate(), L"TimerObj")) {
- if (CJS_Object* pJSObj = params[0].ToCJSObject()) {
- if (TimerObj* pTimerObj = (TimerObj*)pJSObj->GetEmbedObject()) {
- if (CJS_Timer* pTimer = pTimerObj->GetTimer()) {
- pTimer->KillJSTimer();
-
- for (int i = 0, sz = m_aTimer.GetSize(); i < sz; i++) {
- if (m_aTimer[i] == pTimer) {
- m_aTimer.RemoveAt(i);
- break;
- }
+ if (FXJS_GetObjDefnID(pObj) == CJS_TimerObj::g_nObjDefnID) {
+ if (CJS_Object* pJSObj = params[0].ToCJSObject()) {
+ if (TimerObj* pTimerObj = (TimerObj*)pJSObj->GetEmbedObject()) {
+ if (CJS_Timer* pTimer = pTimerObj->GetTimer()) {
+ pTimer->KillJSTimer();
+
+ for (int i = 0, sz = m_aTimer.GetSize(); i < sz; i++) {
+ if (m_aTimer[i] == pTimer) {
+ m_aTimer.RemoveAt(i);
+ break;
}
-
- delete pTimer;
- pTimerObj->SetTimer(NULL);
}
+
+ delete pTimer;
+ pTimerObj->SetTimer(NULL);
}
}
}
@@ -534,35 +511,28 @@ FX_BOOL app::clearInterval(IFXJS_Context* cc,
CJS_Value& vRet,
CFX_WideString& sError) {
CJS_Context* pContext = (CJS_Context*)cc;
- ASSERT(pContext != NULL);
- CJS_Runtime* pRuntime = pContext->GetJSRuntime();
- ASSERT(pRuntime != NULL);
-
if (params.size() != 1) {
- sError = JSGetStringFromID((CJS_Context*)cc, IDS_STRING_JSPARAMERROR);
+ sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
return FALSE;
}
if (params[0].GetType() == CJS_Value::VT_fxobject) {
v8::Local<v8::Object> pObj = params[0].ToV8Object();
- {
- if (FXJS_GetObjDefnID(pObj) ==
- FXJS_GetObjDefnID(pRuntime->GetIsolate(), L"TimerObj")) {
- if (CJS_Object* pJSObj = params[0].ToCJSObject()) {
- if (TimerObj* pTimerObj = (TimerObj*)pJSObj->GetEmbedObject()) {
- if (CJS_Timer* pTimer = pTimerObj->GetTimer()) {
- pTimer->KillJSTimer();
-
- for (int i = 0, sz = m_aTimer.GetSize(); i < sz; i++) {
- if (m_aTimer[i] == pTimer) {
- m_aTimer.RemoveAt(i);
- break;
- }
+ if (FXJS_GetObjDefnID(pObj) == CJS_TimerObj::g_nObjDefnID) {
+ if (CJS_Object* pJSObj = params[0].ToCJSObject()) {
+ if (TimerObj* pTimerObj = (TimerObj*)pJSObj->GetEmbedObject()) {
+ if (CJS_Timer* pTimer = pTimerObj->GetTimer()) {
+ pTimer->KillJSTimer();
+
+ for (int i = 0, sz = m_aTimer.GetSize(); i < sz; i++) {
+ if (m_aTimer[i] == pTimer) {
+ m_aTimer.RemoveAt(i);
+ break;
}
-
- delete pTimer;
- pTimerObj->SetTimer(NULL);
}
+
+ delete pTimer;
+ pTimerObj->SetTimer(NULL);
}
}
}