summaryrefslogtreecommitdiff
path: root/fpdfsdk/src/javascript/app.cpp
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2015-10-05 17:00:03 -0700
committerLei Zhang <thestig@chromium.org>2015-10-05 17:00:03 -0700
commit2d5a0e173f3bb8335cf302f1194305c2f9e65bed (patch)
tree9e82cf609b817dfc153a1506ed2b2188663275d5 /fpdfsdk/src/javascript/app.cpp
parentca70a69f4b5ac05eb7e054cfa014d219b915f632 (diff)
downloadpdfium-2d5a0e173f3bb8335cf302f1194305c2f9e65bed.tar.xz
Merge to XFA: CJS_Timer should observe CJS_Runtime destruction.
Also remove dead CJS_EmbedObj::{Begin,End}Timer code. BUG=539107 R=tsepez@chromium.org Review URL: https://codereview.chromium.org/1384883002 . (cherry picked from commit 794c9b67d3d519342aa7e15052766f7d4a99f551) Review URL: https://codereview.chromium.org/1386053002 .
Diffstat (limited to 'fpdfsdk/src/javascript/app.cpp')
-rw-r--r--fpdfsdk/src/javascript/app.cpp27
1 files changed, 10 insertions, 17 deletions
diff --git a/fpdfsdk/src/javascript/app.cpp b/fpdfsdk/src/javascript/app.cpp
index 248e50ecd4..1466dc16a6 100644
--- a/fpdfsdk/src/javascript/app.cpp
+++ b/fpdfsdk/src/javascript/app.cpp
@@ -414,16 +414,10 @@ FX_BOOL app::setInterval(IFXJS_Context* cc,
CPDFDoc_Environment* pApp = pRuntime->GetReaderApp();
ASSERT(pApp);
- CJS_Timer* pTimer = new CJS_Timer(this, pApp);
+ CJS_Timer* pTimer =
+ new CJS_Timer(this, pApp, pRuntime, 0, script, dwInterval, 0);
m_aTimer.Add(pTimer);
- pTimer->SetType(0);
- pTimer->SetRuntime(pRuntime);
- pTimer->SetJScript(script);
- pTimer->SetTimeOut(0);
- // pTimer->SetStartTime(GetTickCount());
- pTimer->SetJSTimer(dwInterval);
-
v8::Local<v8::Object> pRetObj = FXJS_NewFxDynamicObj(
pRuntime->GetIsolate(), pContext,
FXJS_GetObjDefnID(pRuntime->GetIsolate(), L"TimerObj"));
@@ -468,15 +462,10 @@ FX_BOOL app::setTimeOut(IFXJS_Context* cc,
CPDFDoc_Environment* pApp = pRuntime->GetReaderApp();
ASSERT(pApp);
- CJS_Timer* pTimer = new CJS_Timer(this, pApp);
+ CJS_Timer* pTimer =
+ new CJS_Timer(this, pApp, pRuntime, 1, script, dwTimeOut, dwTimeOut);
m_aTimer.Add(pTimer);
- pTimer->SetType(1);
- pTimer->SetRuntime(pRuntime);
- pTimer->SetJScript(script);
- pTimer->SetTimeOut(dwTimeOut);
- pTimer->SetJSTimer(dwTimeOut);
-
v8::Local<v8::Object> pRetObj = FXJS_NewFxDynamicObj(
pRuntime->GetIsolate(), pContext,
FXJS_GetObjDefnID(pRuntime->GetIsolate(), L"TimerObj"));
@@ -591,13 +580,17 @@ FX_BOOL app::execMenuItem(IFXJS_Context* cc,
void app::TimerProc(CJS_Timer* pTimer) {
ASSERT(pTimer != NULL);
+ CJS_Runtime* pRuntime = pTimer->GetRuntime();
+
switch (pTimer->GetType()) {
case 0: // interval
- RunJsScript(pTimer->GetRuntime(), pTimer->GetJScript());
+ if (pRuntime)
+ RunJsScript(pRuntime, pTimer->GetJScript());
break;
case 1:
if (pTimer->GetTimeOut() > 0) {
- RunJsScript(pTimer->GetRuntime(), pTimer->GetJScript());
+ if (pRuntime)
+ RunJsScript(pRuntime, pTimer->GetJScript());
pTimer->KillJSTimer();
}
break;