summaryrefslogtreecommitdiff
path: root/fpdfsdk/src/javascript/JS_Runtime.cpp
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2015-10-06 11:10:52 -0700
committerTom Sepez <tsepez@chromium.org>2015-10-06 11:10:52 -0700
commitf0a5b2803c09f3605dcd606e764ef604f0d2a8ea (patch)
treec70b0fd99702afbeb7474b7c168d13dc5d6831a3 /fpdfsdk/src/javascript/JS_Runtime.cpp
parent4ea721cb7954898a9722c389dae86c62957352d0 (diff)
downloadpdfium-f0a5b2803c09f3605dcd606e764ef604f0d2a8ea.tar.xz
Store object definition ID in each js_class.
Avoids doing a lookup via FXJS_V8 for something already known in CJS layer. Also: Consolidate repeated code in JS macros. Remove knowledge that Document is global from FXJS layer R=thestig@chromium.org Review URL: https://codereview.chromium.org/1382263002 .
Diffstat (limited to 'fpdfsdk/src/javascript/JS_Runtime.cpp')
-rw-r--r--fpdfsdk/src/javascript/JS_Runtime.cpp43
1 files changed, 21 insertions, 22 deletions
diff --git a/fpdfsdk/src/javascript/JS_Runtime.cpp b/fpdfsdk/src/javascript/JS_Runtime.cpp
index 2daa62608b..a17b8e23a5 100644
--- a/fpdfsdk/src/javascript/JS_Runtime.cpp
+++ b/fpdfsdk/src/javascript/JS_Runtime.cpp
@@ -84,34 +84,34 @@ void CJS_Runtime::DefineJSObjects() {
// The call order determines the "ObjDefID" assigned to each class.
// ObjDefIDs 0 - 2
- CJS_Border::DefineJSObjects(GetIsolate(), FXJS_STATIC);
- CJS_Display::DefineJSObjects(GetIsolate(), FXJS_STATIC);
- CJS_Font::DefineJSObjects(GetIsolate(), FXJS_STATIC);
+ CJS_Border::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_STATIC);
+ CJS_Display::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_STATIC);
+ CJS_Font::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_STATIC);
// ObjDefIDs 3 - 5
- CJS_Highlight::DefineJSObjects(GetIsolate(), FXJS_STATIC);
- CJS_Position::DefineJSObjects(GetIsolate(), FXJS_STATIC);
- CJS_ScaleHow::DefineJSObjects(GetIsolate(), FXJS_STATIC);
+ CJS_Highlight::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_STATIC);
+ CJS_Position::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_STATIC);
+ CJS_ScaleHow::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_STATIC);
// ObjDefIDs 6 - 8
- CJS_ScaleWhen::DefineJSObjects(GetIsolate(), FXJS_STATIC);
- CJS_Style::DefineJSObjects(GetIsolate(), FXJS_STATIC);
- CJS_Zoomtype::DefineJSObjects(GetIsolate(), FXJS_STATIC);
+ CJS_ScaleWhen::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_STATIC);
+ CJS_Style::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_STATIC);
+ CJS_Zoomtype::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_STATIC);
// ObjDefIDs 9 - 11
- CJS_App::DefineJSObjects(GetIsolate(), FXJS_STATIC);
- CJS_Color::DefineJSObjects(GetIsolate(), FXJS_STATIC);
- CJS_Console::DefineJSObjects(GetIsolate(), FXJS_STATIC);
+ CJS_App::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_STATIC);
+ CJS_Color::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_STATIC);
+ CJS_Console::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_STATIC);
// ObjDefIDs 12 - 14
- CJS_Document::DefineJSObjects(GetIsolate(), FXJS_DYNAMIC);
- CJS_Event::DefineJSObjects(GetIsolate(), FXJS_STATIC);
- CJS_Field::DefineJSObjects(GetIsolate(), FXJS_DYNAMIC);
+ CJS_Document::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_GLOBAL);
+ CJS_Event::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_STATIC);
+ CJS_Field::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_DYNAMIC);
// ObjDefIDs 15 - 17
- CJS_Global::DefineJSObjects(GetIsolate(), FXJS_STATIC);
- CJS_Icon::DefineJSObjects(GetIsolate(), FXJS_DYNAMIC);
- CJS_Util::DefineJSObjects(GetIsolate(), FXJS_STATIC);
+ CJS_Global::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_STATIC);
+ CJS_Icon::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_DYNAMIC);
+ CJS_Util::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_STATIC);
// ObjDefIDs 18 - 20 (these can't fail, return void).
CJS_PublicMethods::DefineJSObjects(GetIsolate());
@@ -119,8 +119,8 @@ void CJS_Runtime::DefineJSObjects() {
CJS_GlobalArrays::DefineJSObjects(GetIsolate());
// ObjDefIDs 21 - 22.
- CJS_TimerObj::DefineJSObjects(GetIsolate(), FXJS_DYNAMIC);
- CJS_PrintParamsObj::DefineJSObjects(GetIsolate(), FXJS_DYNAMIC);
+ CJS_TimerObj::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_DYNAMIC);
+ CJS_PrintParamsObj::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_DYNAMIC);
}
IFXJS_Context* CJS_Runtime::NewContext() {
@@ -159,8 +159,7 @@ void CJS_Runtime::SetReaderDocument(CPDFSDK_Document* pReaderDoc) {
if (pReaderDoc) {
v8::Local<v8::Object> pThis = FXJS_GetThisObj(GetIsolate());
if (!pThis.IsEmpty()) {
- if (FXJS_GetObjDefnID(pThis) ==
- FXJS_GetObjDefnID(GetIsolate(), L"Document")) {
+ if (FXJS_GetObjDefnID(pThis) == CJS_Document::g_nObjDefnID) {
if (CJS_Document* pJSDocument =
(CJS_Document*)FXJS_GetPrivate(GetIsolate(), pThis)) {
if (Document* pDocument = (Document*)pJSDocument->GetEmbedObject())