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

Side by Side Diff: fpdfsdk/src/javascript/JS_Runtime.cpp

Issue 1400503003: Merge to XFA: Only call DefineJSObjects() once for the global V8 isolate. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: rebase Created 5 years, 2 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/include/jsapi/fxjs_v8.h ('k') | fpdfsdk/src/jsapi/fxjs_v8.cpp » ('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 "JS_Runtime.h" 7 #include "JS_Runtime.h"
8 8
9 #include "../../../xfa/src/fxjse/src/value.h" 9 #include "../../../xfa/src/fxjse/src/value.h"
10 #include "../../include/fpdfxfa/fpdfxfa_app.h" 10 #include "../../include/fpdfxfa/fpdfxfa_app.h"
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 v8::Isolate::Scope isolate_scope(isolate); 63 v8::Isolate::Scope isolate_scope(isolate);
64 v8::Locker locker(isolate); 64 v8::Locker locker(isolate);
65 v8::HandleScope handle_scope(isolate); 65 v8::HandleScope handle_scope(isolate);
66 if (CPDFXFA_App::GetInstance()->IsJavaScriptInitialized()) { 66 if (CPDFXFA_App::GetInstance()->IsJavaScriptInitialized()) {
67 CJS_Context* pContext = (CJS_Context*)NewContext(); 67 CJS_Context* pContext = (CJS_Context*)NewContext();
68 FXJS_InitializeRuntime(GetIsolate(), this, pContext, m_context); 68 FXJS_InitializeRuntime(GetIsolate(), this, pContext, m_context);
69 ReleaseContext(pContext); 69 ReleaseContext(pContext);
70 return; 70 return;
71 } 71 }
72 72
73 DefineJSObjects(); 73 if (m_isolateManaged || FXJS_GlobalIsolateRefCount() == 0)
74 DefineJSObjects();
75
74 CPDFXFA_App::GetInstance()->SetJavaScriptInitialized(TRUE); 76 CPDFXFA_App::GetInstance()->SetJavaScriptInitialized(TRUE);
75 77
76 CJS_Context* pContext = (CJS_Context*)NewContext(); 78 CJS_Context* pContext = (CJS_Context*)NewContext();
77 FXJS_InitializeRuntime(GetIsolate(), this, pContext, m_context); 79 FXJS_InitializeRuntime(GetIsolate(), this, pContext, m_context);
78 ReleaseContext(pContext); 80 ReleaseContext(pContext);
79 } 81 }
80 82
81 CJS_Runtime::~CJS_Runtime() { 83 CJS_Runtime::~CJS_Runtime() {
82 for (auto* obs : m_observers) 84 for (auto* obs : m_observers)
83 obs->OnDestroyed(); 85 obs->OnDestroyed();
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 265
264 void CJS_Runtime::AddObserver(Observer* observer) { 266 void CJS_Runtime::AddObserver(Observer* observer) {
265 ASSERT(m_observers.find(observer) == m_observers.end()); 267 ASSERT(m_observers.find(observer) == m_observers.end());
266 m_observers.insert(observer); 268 m_observers.insert(observer);
267 } 269 }
268 270
269 void CJS_Runtime::RemoveObserver(Observer* observer) { 271 void CJS_Runtime::RemoveObserver(Observer* observer) {
270 ASSERT(m_observers.find(observer) != m_observers.end()); 272 ASSERT(m_observers.find(observer) != m_observers.end());
271 m_observers.erase(observer); 273 m_observers.erase(observer);
272 } 274 }
OLDNEW
« no previous file with comments | « fpdfsdk/include/jsapi/fxjs_v8.h ('k') | fpdfsdk/src/jsapi/fxjs_v8.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698