Remove one form of CFXJSE_ScoeUtil_IsolateHandleContext constructor. Removing knowledge of class CFXJSE_Engine from the isolate tracking code improves separability down the road, etc. etc. Change-Id: I37bc6bdffe89a3f90947e66791ebc950ca1fa958 Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/76770 Reviewed-by: Daniel Hosseinian <dhoss@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
diff --git a/fxjs/xfa/cfxjse_engine.cpp b/fxjs/xfa/cfxjse_engine.cpp index 1c42218..4f32bba 100644 --- a/fxjs/xfa/cfxjse_engine.cpp +++ b/fxjs/xfa/cfxjse_engine.cpp
@@ -136,7 +136,7 @@ CFXJSE_Engine::~CFXJSE_Engine() { // This is what ensures that the v8 object bound to a CJX_Object // no longer retains that binding since it will outlive that object. - CFXJSE_ScopeUtil_IsolateHandleContext scope(this); + CFXJSE_ScopeUtil_IsolateHandleContext scope(GetJseContext()); for (const auto& pair : m_mapObjectToObject) { const v8::Global<v8::Object>& binding = pair.second; FXJSE_ClearObjectBinding(v8::Local<v8::Object>::New(GetIsolate(), binding)); @@ -147,7 +147,7 @@ WideStringView wsScript, CFXJSE_Value* hRetValue, CXFA_Object* pThisObject) { - CFXJSE_ScopeUtil_IsolateHandleContext scope(this); + CFXJSE_ScopeUtil_IsolateHandleContext scope(GetJseContext()); AutoRestorer<CXFA_Script::Type> typeRestorer(&m_eScriptType); m_eScriptType = eScriptType; @@ -627,7 +627,7 @@ } void CFXJSE_Engine::RemoveBuiltInObjs(CFXJSE_Context* pContext) { - CFXJSE_ScopeUtil_IsolateHandleContext scope(this); + CFXJSE_ScopeUtil_IsolateHandleContext scope(GetJseContext()); v8::Local<v8::Object> pObject = pContext->GetGlobalObject(); fxv8::ReentrantDeleteObjectPropertyHelper(GetIsolate(), pObject, "Number"); fxv8::ReentrantDeleteObjectPropertyHelper(GetIsolate(), pObject, "Date");
diff --git a/fxjs/xfa/cfxjse_formcalc_context_embeddertest.cpp b/fxjs/xfa/cfxjse_formcalc_context_embeddertest.cpp index b2cd1d2..977f3f7 100644 --- a/fxjs/xfa/cfxjse_formcalc_context_embeddertest.cpp +++ b/fxjs/xfa/cfxjse_formcalc_context_embeddertest.cpp
@@ -19,6 +19,10 @@ ~CFXJSE_FormCalcContextEmbedderTest() override = default; protected: + CFXJSE_Context* GetJseContext() { + return GetScriptContext()->GetJseContext(); + } + void ExecuteExpectError(ByteStringView input) { EXPECT_FALSE(Execute(input)) << "Program: " << input; } @@ -26,14 +30,14 @@ void ExecuteExpectNull(ByteStringView input) { EXPECT_TRUE(Execute(input)) << "Program: " << input; - CFXJSE_ScopeUtil_IsolateHandleContext scope(GetScriptContext()); + CFXJSE_ScopeUtil_IsolateHandleContext scope(GetJseContext()); EXPECT_TRUE(fxv8::IsNull(GetValue())) << "Program: " << input; } void ExecuteExpectBool(ByteStringView input, bool expected) { EXPECT_TRUE(Execute(input)) << "Program: " << input; - CFXJSE_ScopeUtil_IsolateHandleContext scope(GetScriptContext()); + CFXJSE_ScopeUtil_IsolateHandleContext scope(GetJseContext()); v8::Local<v8::Value> value = GetValue(); // Yes, bools might be integers, somehow. @@ -46,7 +50,7 @@ void ExecuteExpectInt32(ByteStringView input, int32_t expected) { EXPECT_TRUE(Execute(input)) << "Program: " << input; - CFXJSE_ScopeUtil_IsolateHandleContext scope(GetScriptContext()); + CFXJSE_ScopeUtil_IsolateHandleContext scope(GetJseContext()); v8::Local<v8::Value> value = GetValue(); EXPECT_TRUE(fxv8::IsInteger(value)) << "Program: " << input; EXPECT_EQ(expected, fxv8::ReentrantToInt32Helper(isolate(), value)) @@ -56,7 +60,7 @@ void ExecuteExpectFloat(ByteStringView input, float expected) { EXPECT_TRUE(Execute(input)) << "Program: " << input; - CFXJSE_ScopeUtil_IsolateHandleContext scope(GetScriptContext()); + CFXJSE_ScopeUtil_IsolateHandleContext scope(GetJseContext()); v8::Local<v8::Value> value = GetValue(); EXPECT_TRUE(fxv8::IsNumber(value)); EXPECT_FLOAT_EQ(expected, fxv8::ReentrantToFloatHelper(isolate(), value)) @@ -68,7 +72,7 @@ float precision) { EXPECT_TRUE(Execute(input)) << "Program: " << input; - CFXJSE_ScopeUtil_IsolateHandleContext scope(GetScriptContext()); + CFXJSE_ScopeUtil_IsolateHandleContext scope(GetJseContext()); v8::Local<v8::Value> value = GetValue(); EXPECT_TRUE(fxv8::IsNumber(value)); EXPECT_NEAR(expected, fxv8::ReentrantToFloatHelper(isolate(), value), @@ -79,7 +83,7 @@ void ExecuteExpectNaN(ByteStringView input) { EXPECT_TRUE(Execute(input)) << "Program: " << input; - CFXJSE_ScopeUtil_IsolateHandleContext scope(GetScriptContext()); + CFXJSE_ScopeUtil_IsolateHandleContext scope(GetJseContext()); v8::Local<v8::Value> value = GetValue(); EXPECT_TRUE(fxv8::IsNumber(value)); EXPECT_TRUE(std::isnan(fxv8::ReentrantToDoubleHelper(isolate(), value))); @@ -88,7 +92,7 @@ void ExecuteExpectString(ByteStringView input, const char* expected) { EXPECT_TRUE(Execute(input)) << "Program: " << input; - CFXJSE_ScopeUtil_IsolateHandleContext scope(GetScriptContext()); + CFXJSE_ScopeUtil_IsolateHandleContext scope(GetJseContext()); v8::Local<v8::Value> value = GetValue(); EXPECT_TRUE(fxv8::IsString(value)); EXPECT_STREQ(expected, @@ -1128,7 +1132,7 @@ ASSERT_TRUE(OpenDocument("simple_xfa.pdf")); EXPECT_TRUE(Execute("Uuid()")); - CFXJSE_ScopeUtil_IsolateHandleContext scope(GetScriptContext()); + CFXJSE_ScopeUtil_IsolateHandleContext scope(GetJseContext()); v8::Local<v8::Value> value = GetValue(); EXPECT_TRUE(fxv8::IsString(value)); }
diff --git a/fxjs/xfa/cfxjse_isolatetracker.cpp b/fxjs/xfa/cfxjse_isolatetracker.cpp index 11274a0..acc56ab 100644 --- a/fxjs/xfa/cfxjse_isolatetracker.cpp +++ b/fxjs/xfa/cfxjse_isolatetracker.cpp
@@ -7,7 +7,6 @@ #include "fxjs/xfa/cfxjse_isolatetracker.h" #include "fxjs/xfa/cfxjse_context.h" -#include "fxjs/xfa/cfxjse_engine.h" #include "fxjs/xfa/cfxjse_runtimedata.h" CFXJSE_ScopeUtil_IsolateHandle::CFXJSE_ScopeUtil_IsolateHandle( @@ -25,10 +24,6 @@ CFXJSE_Context* pContext) : isolate_handle_(pContext->GetIsolate()), context_(pContext) {} -CFXJSE_ScopeUtil_IsolateHandleContext::CFXJSE_ScopeUtil_IsolateHandleContext( - CFXJSE_Engine* pEngine) - : CFXJSE_ScopeUtil_IsolateHandleContext(pEngine->GetJseContext()) {} - CFXJSE_ScopeUtil_IsolateHandleContext:: ~CFXJSE_ScopeUtil_IsolateHandleContext() = default;
diff --git a/fxjs/xfa/cfxjse_isolatetracker.h b/fxjs/xfa/cfxjse_isolatetracker.h index d3105c8..3e78c57 100644 --- a/fxjs/xfa/cfxjse_isolatetracker.h +++ b/fxjs/xfa/cfxjse_isolatetracker.h
@@ -10,7 +10,6 @@ #include "v8/include/v8.h" class CFXJSE_Context; -class CFXJSE_Engine; class CFXJSE_ScopeUtil_IsolateHandle { public: @@ -46,7 +45,6 @@ class CFXJSE_ScopeUtil_IsolateHandleContext { public: explicit CFXJSE_ScopeUtil_IsolateHandleContext(CFXJSE_Context* pContext); - explicit CFXJSE_ScopeUtil_IsolateHandleContext(CFXJSE_Engine* pEngine); CFXJSE_ScopeUtil_IsolateHandleContext( const CFXJSE_ScopeUtil_IsolateHandleContext&) = delete; CFXJSE_ScopeUtil_IsolateHandleContext& operator=(