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

Unified Diff: fpdfsdk/javascript/cjs_runtime.cpp

Issue 2053843002: Cleanup some cjs_runtime ifdefs. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: fpdfsdk/javascript/cjs_runtime.cpp
diff --git a/fpdfsdk/javascript/cjs_runtime.cpp b/fpdfsdk/javascript/cjs_runtime.cpp
index fcdbfcfb4df9431abc4948b3445e9a4147d78bc6..020472e5848809a608f3a90c8ff2b7d9d996ee3e 100644
--- a/fpdfsdk/javascript/cjs_runtime.cpp
+++ b/fpdfsdk/javascript/cjs_runtime.cpp
@@ -64,6 +64,10 @@ CJS_Runtime::CJS_Runtime(CPDFDoc_Environment* pApp)
if (pPlatform->version == 2) {
pExternalIsolate = reinterpret_cast<v8::Isolate*>(pPlatform->m_isolate);
embedderDataSlot = pPlatform->m_v8EmbedderSlot;
+ }
+ FXJS_Initialize(embedderDataSlot, pExternalIsolate);
+ }
+ m_isolateManaged = FXJS_GetIsolate(&m_isolate);
#else
if (CPDFXFA_App::GetInstance()->GetJSERuntime()) {
// TODO(tsepez): CPDFXFA_App should also use the embedder provided isolate.
@@ -78,11 +82,7 @@ CJS_Runtime::CJS_Runtime(CPDFDoc_Environment* pApp)
embedderDataSlot = pPlatform->m_v8EmbedderSlot;
}
FXJS_Initialize(embedderDataSlot, pExternalIsolate);
-#endif
}
-#ifndef PDF_ENABLE_XFA
- FXJS_Initialize(embedderDataSlot, pExternalIsolate);
-#else
m_isolateManaged = FXJS_GetIsolate(&m_isolate);
}
@@ -94,20 +94,16 @@ CJS_Runtime::CJS_Runtime(CPDFDoc_Environment* pApp)
FXJS_InitializeRuntime(GetIsolate(), this, &m_context, &m_StaticObjects);
ReleaseContext(pContext);
return;
-#endif
}
-#ifndef PDF_ENABLE_XFA
- m_isolateManaged = FXJS_GetIsolate(&m_isolate);
-#else
-
#endif
+
if (m_isolateManaged || FXJS_GlobalIsolateRefCount() == 0)
DefineJSObjects();
#ifdef PDF_ENABLE_XFA
CPDFXFA_App::GetInstance()->SetJavaScriptInitialized(TRUE);
-
#endif
+
CJS_Context* pContext = (CJS_Context*)NewContext();
FXJS_InitializeRuntime(GetIsolate(), this, &m_context, &m_StaticObjects);
ReleaseContext(pContext);
@@ -245,6 +241,16 @@ v8::Local<v8::Array> CJS_Runtime::GetConstArray(const CFX_WideString& name) {
return v8::Local<v8::Array>::New(m_isolate, m_ConstArrays[name]);
}
+void CJS_Runtime::AddObserver(Observer* observer) {
+ ASSERT(!pdfium::ContainsKey(m_observers, observer));
+ m_observers.insert(observer);
+}
+
+void CJS_Runtime::RemoveObserver(Observer* observer) {
+ ASSERT(pdfium::ContainsKey(m_observers, observer));
+ m_observers.erase(observer);
+}
+
#ifdef PDF_ENABLE_XFA
CFX_WideString ChangeObjName(const CFX_WideString& str) {
CFX_WideString sRet = str;
@@ -253,7 +259,6 @@ CFX_WideString ChangeObjName(const CFX_WideString& str) {
}
FX_BOOL CJS_Runtime::GetValueByName(const CFX_ByteStringC& utf8Name,
CFXJSE_Value* pValue) {
-#ifdef PDF_ENABLE_XFA
const FX_CHAR* name = utf8Name.c_str();
v8::Isolate::Scope isolate_scope(GetIsolate());
@@ -281,13 +286,10 @@ FX_BOOL CJS_Runtime::GetValueByName(const CFX_ByteStringC& utf8Name,
return FALSE;
}
pValue->ForceSetValue(propvalue);
-#endif
-
return TRUE;
}
FX_BOOL CJS_Runtime::SetValueByName(const CFX_ByteStringC& utf8Name,
CFXJSE_Value* pValue) {
-#ifdef PDF_ENABLE_XFA
if (utf8Name.IsEmpty() || !pValue)
return FALSE;
const FX_CHAR* name = utf8Name.c_str();
@@ -306,17 +308,6 @@ FX_BOOL CJS_Runtime::SetValueByName(const CFX_ByteStringC& utf8Name,
v8::String::NewFromUtf8(pIsolate, name, v8::String::kNormalString,
utf8Name.GetLength()),
propvalue);
-#endif
return TRUE;
}
-
#endif
-void CJS_Runtime::AddObserver(Observer* observer) {
- ASSERT(!pdfium::ContainsKey(m_observers, observer));
- m_observers.insert(observer);
-}
-
-void CJS_Runtime::RemoveObserver(Observer* observer) {
- ASSERT(pdfium::ContainsKey(m_observers, observer));
- m_observers.erase(observer);
-}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698