From 07c0a4952a9fe45e51c6ba5a2e19296e52ea6ec7 Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Thu, 14 Dec 2017 20:29:23 +0000 Subject: Fold CXFA_ScriptData into CXFA_Script This CL removes the CXFA_ScriptData wrapper and uses CXFA_Script directly. Change-Id: I1f1932ef96ee4a24407de7eb1d68b8631a5a67ea Reviewed-on: https://pdfium-review.googlesource.com/21173 Commit-Queue: dsinclair Reviewed-by: Henrique Nakashima --- fxjs/cfxjse_engine.cpp | 16 ++++++++-------- fxjs/cfxjse_engine.h | 7 ++++--- fxjs/cfxjse_resolveprocessor.cpp | 6 +++--- 3 files changed, 15 insertions(+), 14 deletions(-) (limited to 'fxjs') diff --git a/fxjs/cfxjse_engine.cpp b/fxjs/cfxjse_engine.cpp index 65aedddf4f..a1c70a7d16 100644 --- a/fxjs/cfxjse_engine.cpp +++ b/fxjs/cfxjse_engine.cpp @@ -98,7 +98,7 @@ CFXJSE_Engine::CFXJSE_Engine(CXFA_Document* pDocument, v8::Isolate* pIsolate) &GlobalClassDescriptor, pDocument->GetRoot())), m_pJsClass(nullptr), - m_eScriptType(CXFA_ScriptData::Type::Unknown), + m_eScriptType(CXFA_Script::Type::Unknown), m_pScriptNodeArray(nullptr), m_ResolveProcessor(pdfium::MakeUnique()), m_pThisObject(nullptr), @@ -117,14 +117,14 @@ CFXJSE_Engine::~CFXJSE_Engine() { delete ToThisProxy(pair.second->GetGlobalObject().get(), nullptr); } -bool CFXJSE_Engine::RunScript(CXFA_ScriptData::Type eScriptType, +bool CFXJSE_Engine::RunScript(CXFA_Script::Type eScriptType, const WideStringView& wsScript, CFXJSE_Value* hRetValue, CXFA_Object* pThisObject) { ByteString btScript; - AutoRestorer typeRestorer(&m_eScriptType); + AutoRestorer typeRestorer(&m_eScriptType); m_eScriptType = eScriptType; - if (eScriptType == CXFA_ScriptData::Type::Formcalc) { + if (eScriptType == CXFA_Script::Type::Formcalc) { if (!m_FM2JSContext) { m_FM2JSContext = pdfium::MakeUnique( GetIsolate(), m_JsContext.get(), m_pDocument.Get()); @@ -210,7 +210,7 @@ void CFXJSE_Engine::GlobalPropertyGetter(CFXJSE_Value* pObject, CXFA_Document* pDoc = pOriginalObject->GetDocument(); CFXJSE_Engine* lpScriptContext = pDoc->GetScriptContext(); WideString wsPropName = WideString::FromUTF8(szPropName); - if (lpScriptContext->GetType() == CXFA_ScriptData::Type::Formcalc) { + if (lpScriptContext->GetType() == CXFA_Script::Type::Formcalc) { if (szPropName == kFormCalcRuntime) { lpScriptContext->m_FM2JSContext->GlobalPropertyGetter(pValue); return; @@ -305,7 +305,7 @@ void CFXJSE_Engine::NormalPropertyGetter(CFXJSE_Value* pOriginalValue, return; if (pObject == lpScriptContext->GetThisObject() || - (lpScriptContext->GetType() == CXFA_ScriptData::Type::Javascript && + (lpScriptContext->GetType() == CXFA_Script::Type::Javascript && !lpScriptContext->IsStrictScopeInJavaScript())) { bRet = lpScriptContext->QueryNodeByFlag( ToNode(pObject), wsPropName.AsStringView(), pReturnValue, @@ -417,7 +417,7 @@ bool CFXJSE_Engine::IsStrictScopeInJavaScript() { return m_pDocument->HasFlag(XFA_DOCFLAG_StrictScoping); } -CXFA_ScriptData::Type CFXJSE_Engine::GetType() { +CXFA_Script::Type CFXJSE_Engine::GetType() { return m_eScriptType; } @@ -537,7 +537,7 @@ bool CFXJSE_Engine::ResolveObjects(CXFA_Object* refObject, if (wsExpression.IsEmpty()) return false; - if (m_eScriptType != CXFA_ScriptData::Type::Formcalc || + if (m_eScriptType != CXFA_Script::Type::Formcalc || (dwStyles & (XFA_RESOLVENODE_Parent | XFA_RESOLVENODE_Siblings))) { m_upObjectArray.clear(); } diff --git a/fxjs/cfxjse_engine.h b/fxjs/cfxjse_engine.h index 9541f7b26b..777921dfc4 100644 --- a/fxjs/cfxjse_engine.h +++ b/fxjs/cfxjse_engine.h @@ -15,6 +15,7 @@ #include "fxjs/cjs_v8.h" #include "xfa/fxfa/cxfa_eventparam.h" #include "xfa/fxfa/parser/cxfa_document.h" +#include "xfa/fxfa/parser/cxfa_script.h" #include "xfa/fxfa/parser/xfa_resolvenode_rs.h" #define XFA_RESOLVENODE_TagName 0x0002 @@ -53,7 +54,7 @@ class CFXJSE_Engine : public CJS_V8 { void SetEventParam(CXFA_EventParam param) { m_eventParam = param; } CXFA_EventParam* GetEventParam() { return &m_eventParam; } - bool RunScript(CXFA_ScriptData::Type eScriptType, + bool RunScript(CXFA_Script::Type eScriptType, const WideStringView& wsScript, CFXJSE_Value* pRetValue, CXFA_Object* pThisObject); @@ -78,7 +79,7 @@ class CFXJSE_Engine : public CJS_V8 { void SetRunAtType(XFA_AttributeEnum eRunAt) { m_eRunAtType = eRunAt; } bool IsRunAtClient() { return m_eRunAtType != XFA_AttributeEnum::Server; } - CXFA_ScriptData::Type GetType(); + CXFA_Script::Type GetType(); std::vector* GetUpObjectArray() { return &m_upObjectArray; } CXFA_Document* GetDocument() const { return m_pDocument.Get(); } @@ -102,7 +103,7 @@ class CFXJSE_Engine : public CJS_V8 { UnownedPtr const m_pDocument; std::unique_ptr m_JsContext; CFXJSE_Class* m_pJsClass; - CXFA_ScriptData::Type m_eScriptType; + CXFA_Script::Type m_eScriptType; std::map> m_mapObjectToValue; std::map> m_mapVariableToContext; diff --git a/fxjs/cfxjse_resolveprocessor.cpp b/fxjs/cfxjse_resolveprocessor.cpp index f3e4a21312..75c5eea6b5 100644 --- a/fxjs/cfxjse_resolveprocessor.cpp +++ b/fxjs/cfxjse_resolveprocessor.cpp @@ -624,11 +624,11 @@ void CFXJSE_ResolveProcessor::DoPredicateFilter(int32_t iCurIndex, CFXJSE_ResolveNodeData& rnd) { ASSERT(iFoundCount == pdfium::CollectionSize(rnd.m_Objects)); WideString wsExpression; - CXFA_ScriptData::Type eLangType = CXFA_ScriptData::Type::Unknown; + CXFA_Script::Type eLangType = CXFA_Script::Type::Unknown; if (wsCondition.Left(2) == L".[" && wsCondition.Last() == L']') - eLangType = CXFA_ScriptData::Type::Formcalc; + eLangType = CXFA_Script::Type::Formcalc; else if (wsCondition.Left(2) == L".(" && wsCondition.Last() == L')') - eLangType = CXFA_ScriptData::Type::Javascript; + eLangType = CXFA_Script::Type::Javascript; else return; -- cgit v1.2.3