summaryrefslogtreecommitdiff
path: root/fpdfsdk/src/javascript/JS_Runtime.cpp
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2015-09-10 11:56:37 -0700
committerTom Sepez <tsepez@chromium.org>2015-09-10 11:56:37 -0700
commit6df59849472958e7de96da6d9fc7b223b7c1f1c3 (patch)
tree90b4908f6de484252f9757010b7002c4f0365a58 /fpdfsdk/src/javascript/JS_Runtime.cpp
parent0d0935d3d6603dd7d851b1d5828635230f4c43ca (diff)
downloadpdfium-6df59849472958e7de96da6d9fc7b223b7c1f1c3.tar.xz
Remove some abstractions in fxjs_v8.h.
It's too hard to keep mapping between v8 and fx abstractions; the lack of transparency prevents those skilled in v8 only from working on this code. Apparently, the original intention was to confine v8 types to fpdfsdk/{include,src}/jsapi, but fpdfsdk/{include,src}/javascript is already well-polluted with v8 types. Also remove no-op JS_SetThisObj(). Also remove unused ParserParams() [noticed because it was incorrectly passing handles as pointers]. Also remove cast operator from CJS_Runtime and call GetIsolate() explicitly. R=thestig@chromium.org Review URL: https://codereview.chromium.org/1332973002 .
Diffstat (limited to 'fpdfsdk/src/javascript/JS_Runtime.cpp')
-rw-r--r--fpdfsdk/src/javascript/JS_Runtime.cpp61
1 files changed, 28 insertions, 33 deletions
diff --git a/fpdfsdk/src/javascript/JS_Runtime.cpp b/fpdfsdk/src/javascript/JS_Runtime.cpp
index 4ef34a8d20..e3b3ed0f49 100644
--- a/fpdfsdk/src/javascript/JS_Runtime.cpp
+++ b/fpdfsdk/src/javascript/JS_Runtime.cpp
@@ -116,7 +116,7 @@ CJS_Runtime::CJS_Runtime(CPDFDoc_Environment* pApp)
InitJSObjects();
CJS_Context* pContext = (CJS_Context*)NewContext();
- JS_InitialRuntime(*this, this, pContext, m_context);
+ JS_InitialRuntime(GetIsolate(), this, pContext, m_context);
ReleaseContext(pContext);
}
@@ -125,9 +125,7 @@ CJS_Runtime::~CJS_Runtime() {
delete m_ContextArray.GetAt(i);
m_ContextArray.RemoveAll();
-
- JS_ReleaseRuntime(*this, m_context);
-
+ JS_ReleaseRuntime(GetIsolate(), m_context);
RemoveEventsInLoop(m_pFieldEventPath);
m_pApp = NULL;
@@ -145,59 +143,59 @@ FX_BOOL CJS_Runtime::InitJSObjects() {
v8::Local<v8::Context> context = v8::Context::New(GetIsolate());
v8::Context::Scope context_scope(context);
// 0 - 8
- if (CJS_Border::Init(*this, JS_STATIC) < 0)
+ if (CJS_Border::Init(GetIsolate(), JS_STATIC) < 0)
return FALSE;
- if (CJS_Display::Init(*this, JS_STATIC) < 0)
+ if (CJS_Display::Init(GetIsolate(), JS_STATIC) < 0)
return FALSE;
- if (CJS_Font::Init(*this, JS_STATIC) < 0)
+ if (CJS_Font::Init(GetIsolate(), JS_STATIC) < 0)
return FALSE;
- if (CJS_Highlight::Init(*this, JS_STATIC) < 0)
+ if (CJS_Highlight::Init(GetIsolate(), JS_STATIC) < 0)
return FALSE;
- if (CJS_Position::Init(*this, JS_STATIC) < 0)
+ if (CJS_Position::Init(GetIsolate(), JS_STATIC) < 0)
return FALSE;
- if (CJS_ScaleHow::Init(*this, JS_STATIC) < 0)
+ if (CJS_ScaleHow::Init(GetIsolate(), JS_STATIC) < 0)
return FALSE;
- if (CJS_ScaleWhen::Init(*this, JS_STATIC) < 0)
+ if (CJS_ScaleWhen::Init(GetIsolate(), JS_STATIC) < 0)
return FALSE;
- if (CJS_Style::Init(*this, JS_STATIC) < 0)
+ if (CJS_Style::Init(GetIsolate(), JS_STATIC) < 0)
return FALSE;
- if (CJS_Zoomtype::Init(*this, JS_STATIC) < 0)
+ if (CJS_Zoomtype::Init(GetIsolate(), JS_STATIC) < 0)
return FALSE;
// 9 - 11
- if (CJS_App::Init(*this, JS_STATIC) < 0)
+ if (CJS_App::Init(GetIsolate(), JS_STATIC) < 0)
return FALSE;
- if (CJS_Color::Init(*this, JS_STATIC) < 0)
+ if (CJS_Color::Init(GetIsolate(), JS_STATIC) < 0)
return FALSE;
- if (CJS_Console::Init(*this, JS_STATIC) < 0)
+ if (CJS_Console::Init(GetIsolate(), JS_STATIC) < 0)
return FALSE;
// 12 - 14
- if (CJS_Document::Init(*this, JS_DYNAMIC) < 0)
+ if (CJS_Document::Init(GetIsolate(), JS_DYNAMIC) < 0)
return FALSE;
- if (CJS_Event::Init(*this, JS_STATIC) < 0)
+ if (CJS_Event::Init(GetIsolate(), JS_STATIC) < 0)
return FALSE;
- if (CJS_Field::Init(*this, JS_DYNAMIC) < 0)
+ if (CJS_Field::Init(GetIsolate(), JS_DYNAMIC) < 0)
return FALSE;
// 15 - 17
- if (CJS_Global::Init(*this, JS_STATIC) < 0)
+ if (CJS_Global::Init(GetIsolate(), JS_STATIC) < 0)
return FALSE;
- if (CJS_Icon::Init(*this, JS_DYNAMIC) < 0)
+ if (CJS_Icon::Init(GetIsolate(), JS_DYNAMIC) < 0)
return FALSE;
- if (CJS_Util::Init(*this, JS_STATIC) < 0)
+ if (CJS_Util::Init(GetIsolate(), JS_STATIC) < 0)
return FALSE;
- if (CJS_PublicMethods::Init(*this) < 0)
+ if (CJS_PublicMethods::Init(GetIsolate()) < 0)
return FALSE;
- if (CJS_GlobalConsts::Init(*this) < 0)
+ if (CJS_GlobalConsts::Init(GetIsolate()) < 0)
return FALSE;
- if (CJS_GlobalArrays::Init(*this) < 0)
+ if (CJS_GlobalArrays::Init(GetIsolate()) < 0)
return FALSE;
- if (CJS_TimerObj::Init(*this, JS_DYNAMIC) < 0)
+ if (CJS_TimerObj::Init(GetIsolate(), JS_DYNAMIC) < 0)
return FALSE;
- if (CJS_PrintParamsObj::Init(*this, JS_DYNAMIC) < 0)
+ if (CJS_PrintParamsObj::Init(GetIsolate(), JS_DYNAMIC) < 0)
return FALSE;
return TRUE;
@@ -236,20 +234,17 @@ void CJS_Runtime::SetReaderDocument(CPDFSDK_Document* pReaderDoc) {
v8::Context::Scope context_scope(context);
m_pDocument = pReaderDoc;
-
if (pReaderDoc) {
- JSObject pThis = JS_GetThisObj(*this);
+ v8::Local<v8::Object> pThis = JS_GetThisObj(GetIsolate());
if (!pThis.IsEmpty()) {
- if (JS_GetObjDefnID(pThis) == JS_GetObjDefnID(*this, L"Document")) {
+ if (JS_GetObjDefnID(pThis) ==
+ JS_GetObjDefnID(GetIsolate(), L"Document")) {
if (CJS_Document* pJSDocument = (CJS_Document*)JS_GetPrivate(pThis)) {
if (Document* pDocument = (Document*)pJSDocument->GetEmbedObject())
pDocument->AttachDoc(pReaderDoc);
}
}
}
- JS_SetThisObj(*this, JS_GetObjDefnID(*this, L"Document"));
- } else {
- JS_SetThisObj(*this, JS_GetObjDefnID(*this, L"app"));
}
}
}