summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2018-06-07 00:44:25 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-06-07 00:44:25 +0000
commitd5c4ab1ef458d158e268b5293c231928c59aacb9 (patch)
treecdd99cc7513e8b59282c33dffe3d94e2ae2533e6
parent10569fcd4a3a9fb0140aa641372bcd462c6aa2f3 (diff)
downloadpdfium-d5c4ab1ef458d158e268b5293c231928c59aacb9.tar.xz
Remove v8::Context slot usage entierly from fxjs
Its no longer required. Change-Id: I180ca99817352a91b6d9d7c9b45985cd96dc730e Reviewed-on: https://pdfium-review.googlesource.com/34290 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
-rw-r--r--fxjs/cfxjs_engine.cpp22
-rw-r--r--fxjs/cfxjs_engine.h5
-rw-r--r--fxjs/cfxjse_context.cpp4
-rw-r--r--fxjs/cfxjse_context.h1
-rw-r--r--fxjs/cfxjse_engine.cpp7
-rw-r--r--fxjs/cfxjse_formcalc_context.cpp2
6 files changed, 4 insertions, 37 deletions
diff --git a/fxjs/cfxjs_engine.cpp b/fxjs/cfxjs_engine.cpp
index 5d0f3b0ec5..763a3d9f14 100644
--- a/fxjs/cfxjs_engine.cpp
+++ b/fxjs/cfxjs_engine.cpp
@@ -15,11 +15,6 @@
class CFXJS_PerObjectData;
-// Keep this consistent with the values defined in gin/public/context_holder.h
-// (without actually requiring a dependency on gin itself for the standalone
-// embedders of PDFIum). The value we want to use is:
-// kPerContextDataStartIndex + kEmbedderPDFium, which is 3.
-static const unsigned int kPerContextDataIndex = 3u;
static unsigned int g_embedderDataSlot = 1u;
static v8::Isolate* g_isolate = nullptr;
static size_t g_isolate_ref_count = 0;
@@ -297,18 +292,6 @@ CFXJS_Engine::CFXJS_Engine(v8::Isolate* pIsolate) : CFX_V8(pIsolate) {}
CFXJS_Engine::~CFXJS_Engine() = default;
// static
-CFXJS_Engine* CFXJS_Engine::EngineFromIsolateCurrentContext(
- v8::Isolate* pIsolate) {
- return EngineFromContext(pIsolate->GetCurrentContext());
-}
-
-// static
-CFXJS_Engine* CFXJS_Engine::EngineFromContext(v8::Local<v8::Context> pContext) {
- return static_cast<CFXJS_Engine*>(
- pContext->GetAlignedPointerFromEmbedderData(kPerContextDataIndex));
-}
-
-// static
int CFXJS_Engine::GetObjDefnID(v8::Local<v8::Object> pObj) {
CFXJS_PerObjectData* pData = CFXJS_PerObjectData::GetFromObject(pObj);
return pData ? pData->m_ObjDefID : -1;
@@ -332,10 +315,6 @@ void CFXJS_Engine::FreeObjectPrivate(v8::Local<v8::Object> pObj) {
delete pData;
}
-void CFXJS_Engine::SetIntoContext(v8::Local<v8::Context> pContext) {
- pContext->SetAlignedPointerInEmbedderData(kPerContextDataIndex, this);
-}
-
int CFXJS_Engine::DefineObj(const char* sObjName,
FXJSOBJTYPE eObjType,
CFXJS_Engine::Constructor pConstructor,
@@ -451,7 +430,6 @@ void CFXJS_Engine::InitializeEngine() {
}
v8::Context::Scope context_scope(v8Context);
- SetIntoContext(v8Context);
int maxID = CFXJS_ObjDefinition::MaxID(GetIsolate());
m_StaticObjects.resize(maxID + 1);
diff --git a/fxjs/cfxjs_engine.h b/fxjs/cfxjs_engine.h
index 0c9d70d83d..a5f94767c5 100644
--- a/fxjs/cfxjs_engine.h
+++ b/fxjs/cfxjs_engine.h
@@ -81,17 +81,12 @@ class CFXJS_Engine : public CFX_V8 {
std::function<void(CFXJS_Engine* pEngine, v8::Local<v8::Object> obj)>;
using Destructor = std::function<void(v8::Local<v8::Object> obj)>;
- static CFXJS_Engine* EngineFromIsolateCurrentContext(v8::Isolate* pIsolate);
- static CFXJS_Engine* EngineFromContext(v8::Local<v8::Context> pContext);
-
static int GetObjDefnID(v8::Local<v8::Object> pObj);
static CJS_Object* GetObjectPrivate(v8::Local<v8::Object> pObj);
static void SetObjectPrivate(v8::Local<v8::Object> pObj,
std::unique_ptr<CJS_Object> p);
static void FreeObjectPrivate(v8::Local<v8::Object> pObj);
- void SetIntoContext(v8::Local<v8::Context> pContext);
-
// Always returns a valid, newly-created objDefnID.
int DefineObj(const char* sObjName,
FXJSOBJTYPE eObjType,
diff --git a/fxjs/cfxjse_context.cpp b/fxjs/cfxjse_context.cpp
index 01f86c37be..59cb4af9a7 100644
--- a/fxjs/cfxjse_context.cpp
+++ b/fxjs/cfxjse_context.cpp
@@ -153,7 +153,6 @@ CFXJSE_HostObject* FXJSE_RetrieveObjectBinding(v8::Local<v8::Object> hJSObject,
// static
std::unique_ptr<CFXJSE_Context> CFXJSE_Context::Create(
v8::Isolate* pIsolate,
- CFXJS_Engine* pOptionalEngineToSet,
const FXJSE_CLASS_DESCRIPTOR* pGlobalClass,
CFXJSE_HostObject* pGlobalObject) {
CFXJSE_ScopeUtil_IsolateHandle scope(pIsolate);
@@ -196,9 +195,6 @@ std::unique_ptr<CFXJSE_Context> CFXJSE_Context::Create(
v8::Local<v8::Object> hGlobalObject = GetGlobalObjectFromContext(hNewContext);
FXJSE_UpdateObjectBinding(hGlobalObject, pGlobalObject);
- if (pOptionalEngineToSet)
- pOptionalEngineToSet->SetIntoContext(hNewContext);
-
pContext->m_hContext.Reset(pIsolate, hNewContext);
return pContext;
}
diff --git a/fxjs/cfxjse_context.h b/fxjs/cfxjse_context.h
index 0f4c97a0ae..8ab955197c 100644
--- a/fxjs/cfxjse_context.h
+++ b/fxjs/cfxjse_context.h
@@ -22,7 +22,6 @@ class CFXJSE_Context {
public:
static std::unique_ptr<CFXJSE_Context> Create(
v8::Isolate* pIsolate,
- CFXJS_Engine* pOptionalEngineToSet,
const FXJSE_CLASS_DESCRIPTOR* pGlobalClass,
CFXJSE_HostObject* pGlobalObject);
diff --git a/fxjs/cfxjse_engine.cpp b/fxjs/cfxjse_engine.cpp
index 2361a64441..21aed7002b 100644
--- a/fxjs/cfxjse_engine.cpp
+++ b/fxjs/cfxjse_engine.cpp
@@ -99,7 +99,6 @@ CFXJSE_Engine::CFXJSE_Engine(CXFA_Document* pDocument,
m_pSubordinateRuntime(fxjs_runtime),
m_pDocument(pDocument),
m_JsContext(CFXJSE_Context::Create(fxjs_runtime->GetIsolate(),
- fxjs_runtime,
&GlobalClassDescriptor,
pDocument->GetRoot())),
m_pJsClass(nullptr),
@@ -464,9 +463,9 @@ CFXJSE_Context* CFXJSE_Engine::CreateVariablesContext(CXFA_Node* pScriptNode,
if (!pScriptNode || !pSubform)
return nullptr;
- auto pNewContext = CFXJSE_Context::Create(
- GetIsolate(), m_pSubordinateRuntime.Get(), &VariablesClassDescriptor,
- new CXFA_ThisProxy(pSubform, pScriptNode));
+ auto pNewContext =
+ CFXJSE_Context::Create(GetIsolate(), &VariablesClassDescriptor,
+ new CXFA_ThisProxy(pSubform, pScriptNode));
RemoveBuiltInObjs(pNewContext.get());
pNewContext->EnableCompatibleMode();
CFXJSE_Context* pResult = pNewContext.get();
diff --git a/fxjs/cfxjse_formcalc_context.cpp b/fxjs/cfxjse_formcalc_context.cpp
index 6a938a5da7..181d9a1dce 100644
--- a/fxjs/cfxjse_formcalc_context.cpp
+++ b/fxjs/cfxjse_formcalc_context.cpp
@@ -2839,7 +2839,7 @@ void CFXJSE_FormCalcContext::Eval(CFXJSE_Value* pThis,
}
std::unique_ptr<CFXJSE_Context> pNewContext(
- CFXJSE_Context::Create(pIsolate, nullptr, nullptr, nullptr));
+ CFXJSE_Context::Create(pIsolate, nullptr, nullptr));
auto returnValue = pdfium::MakeUnique<CFXJSE_Value>(pIsolate);
pNewContext->ExecuteScript(