Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(957)

Side by Side Diff: fpdfsdk/javascript/cjs_context.cpp

Issue 2245863002: Push v8::Isolate into CFXJS_Engine class (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Null isolate before letting CFXJS_Engine dtor invoked Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « fpdfsdk/javascript/app.cpp ('k') | fpdfsdk/javascript/cjs_runtime.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include "fpdfsdk/javascript/cjs_context.h" 7 #include "fpdfsdk/javascript/cjs_context.h"
8 8
9 #include "fpdfsdk/javascript/JS_EventHandler.h" 9 #include "fpdfsdk/javascript/JS_EventHandler.h"
10 #include "fpdfsdk/javascript/cjs_runtime.h" 10 #include "fpdfsdk/javascript/cjs_runtime.h"
(...skipping 11 matching lines...) Expand all
22 } 22 }
23 23
24 CPDFDoc_Environment* CJS_Context::GetReaderApp() { 24 CPDFDoc_Environment* CJS_Context::GetReaderApp() {
25 return m_pRuntime->GetReaderApp(); 25 return m_pRuntime->GetReaderApp();
26 } 26 }
27 27
28 FX_BOOL CJS_Context::RunScript(const CFX_WideString& script, 28 FX_BOOL CJS_Context::RunScript(const CFX_WideString& script,
29 CFX_WideString* info) { 29 CFX_WideString* info) {
30 v8::Isolate::Scope isolate_scope(m_pRuntime->GetIsolate()); 30 v8::Isolate::Scope isolate_scope(m_pRuntime->GetIsolate());
31 v8::HandleScope handle_scope(m_pRuntime->GetIsolate()); 31 v8::HandleScope handle_scope(m_pRuntime->GetIsolate());
32 v8::Local<v8::Context> context = m_pRuntime->NewJSContext(); 32 v8::Local<v8::Context> context = m_pRuntime->NewLocalContext();
33 v8::Context::Scope context_scope(context); 33 v8::Context::Scope context_scope(context);
34 34
35 if (m_bBusy) { 35 if (m_bBusy) {
36 *info = JSGetStringFromID(this, IDS_STRING_JSBUSY); 36 *info = JSGetStringFromID(this, IDS_STRING_JSBUSY);
37 return FALSE; 37 return FALSE;
38 } 38 }
39 m_bBusy = TRUE; 39 m_bBusy = TRUE;
40 40
41 ASSERT(m_pEventHandler->IsValid()); 41 ASSERT(m_pEventHandler->IsValid());
42 CJS_Runtime::FieldEvent event(m_pEventHandler->TargetName(), 42 CJS_Runtime::FieldEvent event(m_pEventHandler->TargetName(),
43 m_pEventHandler->EventType()); 43 m_pEventHandler->EventType());
44 if (!m_pRuntime->AddEventToSet(event)) { 44 if (!m_pRuntime->AddEventToSet(event)) {
45 *info = JSGetStringFromID(this, IDS_STRING_JSEVENT); 45 *info = JSGetStringFromID(this, IDS_STRING_JSEVENT);
46 return FALSE; 46 return FALSE;
47 } 47 }
48 48
49 CFX_WideString sErrorMessage; 49 CFX_WideString sErrorMessage;
50 int nRet = 0; 50 int nRet = 0;
51 if (script.GetLength() > 0) { 51 if (script.GetLength() > 0) {
52 nRet = m_pRuntime->Execute(script.c_str(), &sErrorMessage); 52 nRet = m_pRuntime->ExecuteScript(script.c_str(), &sErrorMessage);
53 } 53 }
54 54
55 if (nRet < 0) { 55 if (nRet < 0) {
56 *info += sErrorMessage; 56 *info += sErrorMessage;
57 } else { 57 } else {
58 *info = JSGetStringFromID(this, IDS_STRING_RUN); 58 *info = JSGetStringFromID(this, IDS_STRING_RUN);
59 } 59 }
60 60
61 m_pRuntime->RemoveEventFromSet(event); 61 m_pRuntime->RemoveEventFromSet(event);
62 m_pEventHandler->Destroy(); 62 m_pEventHandler->Destroy();
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 } 267 }
268 268
269 void CJS_Context::OnBatchExec(CPDFSDK_Document* pTarget) { 269 void CJS_Context::OnBatchExec(CPDFSDK_Document* pTarget) {
270 m_pEventHandler->OnBatchExec(pTarget); 270 m_pEventHandler->OnBatchExec(pTarget);
271 } 271 }
272 272
273 void CJS_Context::OnMenu_Exec(CPDFSDK_Document* pTarget, 273 void CJS_Context::OnMenu_Exec(CPDFSDK_Document* pTarget,
274 const CFX_WideString& strTargetName) { 274 const CFX_WideString& strTargetName) {
275 m_pEventHandler->OnMenu_Exec(pTarget, strTargetName); 275 m_pEventHandler->OnMenu_Exec(pTarget, strTargetName);
276 } 276 }
OLDNEW
« no previous file with comments | « fpdfsdk/javascript/app.cpp ('k') | fpdfsdk/javascript/cjs_runtime.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698