diff options
author | Dan Sinclair <dsinclair@chromium.org> | 2017-11-01 13:12:39 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-11-01 13:12:39 +0000 |
commit | 3fff90a670d860a7b0319aa0edf8628917d0a122 (patch) | |
tree | cd41a597e4a400dfa7ced5eea330fdf9f5ca832f /xfa/fxfa/parser/cxfa_scriptcontext.h | |
parent | 994f20cfb76f4902491a94c4ef61f55705fc124d (diff) | |
download | pdfium-3fff90a670d860a7b0319aa0edf8628917d0a122.tar.xz |
Move some XFA JS code into fxjs/
This CL renames cxfa_scriptcontext to cfxjse_engine and
cxfa_fm2jscontext to cfxjse_formcalc_context.
From reading the code, the script context appears to handle the v8 setup
and object code. The formcalc context code is related to handling the JS
code generated from the transpiler.
I, think, these new names make the intended usage clearer. They also
move the code into fxjs/ to keep along side the rest of the JS code.
Change-Id: I50619fbe48ca1f553a44cf0e0cb0210be8e45e4f
Reviewed-on: https://pdfium-review.googlesource.com/17130
Commit-Queue: dsinclair <dsinclair@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'xfa/fxfa/parser/cxfa_scriptcontext.h')
-rw-r--r-- | xfa/fxfa/parser/cxfa_scriptcontext.h | 126 |
1 files changed, 0 insertions, 126 deletions
diff --git a/xfa/fxfa/parser/cxfa_scriptcontext.h b/xfa/fxfa/parser/cxfa_scriptcontext.h deleted file mode 100644 index 75d30278bd..0000000000 --- a/xfa/fxfa/parser/cxfa_scriptcontext.h +++ /dev/null @@ -1,126 +0,0 @@ -// Copyright 2014 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#ifndef XFA_FXFA_PARSER_CXFA_SCRIPTCONTEXT_H_ -#define XFA_FXFA_PARSER_CXFA_SCRIPTCONTEXT_H_ - -#include <map> -#include <memory> -#include <vector> - -#include "fxjs/cfxjse_arguments.h" -#include "xfa/fxfa/cxfa_eventparam.h" -#include "xfa/fxfa/fm2js/cxfa_fm2jscontext.h" -#include "xfa/fxfa/parser/cxfa_document.h" -#include "xfa/fxfa/parser/xfa_resolvenode_rs.h" - -#define XFA_RESOLVENODE_TagName 0x0002 - -class CXFA_ResolveProcessor; - -class CXFA_ScriptContext { - public: - explicit CXFA_ScriptContext(CXFA_Document* pDocument); - ~CXFA_ScriptContext(); - - void Initialize(v8::Isolate* pIsolate); - void SetEventParam(CXFA_EventParam param) { m_eventParam = param; } - CXFA_EventParam* GetEventParam() { return &m_eventParam; } - bool RunScript(XFA_SCRIPTLANGTYPE eScriptType, - const WideStringView& wsScript, - CFXJSE_Value* pRetValue, - CXFA_Object* pThisObject); - - int32_t ResolveObjects(CXFA_Object* refObject, - const WideStringView& wsExpression, - XFA_RESOLVENODE_RS& resolveNodeRS, - uint32_t dwStyles = XFA_RESOLVENODE_Children, - CXFA_Node* bindNode = nullptr); - CFXJSE_Value* GetJSValueFromMap(CXFA_Object* pObject); - void AddToCacheList(std::unique_ptr<CXFA_NodeList> pList); - CXFA_Object* GetThisObject() const { return m_pThisObject; } - v8::Isolate* GetRuntime() const { return m_pIsolate; } - - int32_t GetIndexByName(CXFA_Node* refNode); - int32_t GetIndexByClassName(CXFA_Node* refNode); - void GetSomExpression(CXFA_Node* refNode, WideString& wsExpression); - - void SetNodesOfRunScript(std::vector<CXFA_Node*>* pArray); - void AddNodesOfRunScript(const std::vector<CXFA_Node*>& nodes); - void AddNodesOfRunScript(CXFA_Node* pNode); - CFXJSE_Class* GetJseNormalClass(); - - void SetRunAtType(XFA_ATTRIBUTEENUM eRunAt) { m_eRunAtType = eRunAt; } - bool IsRunAtClient() { return m_eRunAtType != XFA_ATTRIBUTEENUM_Server; } - bool QueryNodeByFlag(CXFA_Node* refNode, - const WideStringView& propname, - CFXJSE_Value* pValue, - uint32_t dwFlag, - bool bSetting); - bool QueryVariableValue(CXFA_Node* pScriptNode, - const ByteStringView& szPropName, - CFXJSE_Value* pValue, - bool bGetter); - bool QueryBuiltinValue(const ByteStringView& szPropName, - CFXJSE_Value* pValue); - static void GlobalPropertyGetter(CFXJSE_Value* pObject, - const ByteStringView& szPropName, - CFXJSE_Value* pValue); - static void GlobalPropertySetter(CFXJSE_Value* pObject, - const ByteStringView& szPropName, - CFXJSE_Value* pValue); - static void NormalPropertyGetter(CFXJSE_Value* pObject, - const ByteStringView& szPropName, - CFXJSE_Value* pValue); - static void NormalPropertySetter(CFXJSE_Value* pObject, - const ByteStringView& szPropName, - CFXJSE_Value* pValue); - static void NormalMethodCall(CFXJSE_Value* hThis, - const ByteStringView& szFuncName, - CFXJSE_Arguments& args); - static int32_t NormalPropTypeGetter(CFXJSE_Value* pObject, - const ByteStringView& szPropName, - bool bQueryIn); - static int32_t GlobalPropTypeGetter(CFXJSE_Value* pObject, - const ByteStringView& szPropName, - bool bQueryIn); - bool RunVariablesScript(CXFA_Node* pScriptNode); - CXFA_Object* GetVariablesThis(CXFA_Object* pObject, bool bScriptNode = false); - bool IsStrictScopeInJavaScript(); - XFA_SCRIPTLANGTYPE GetType(); - std::vector<CXFA_Node*>* GetUpObjectArray() { return &m_upObjectArray; } - CXFA_Document* GetDocument() const { return m_pDocument.Get(); } - - static CXFA_Object* ToObject(CFXJSE_Value* pValue, CFXJSE_Class* pClass); - - private: - void DefineJsContext(); - CFXJSE_Context* CreateVariablesContext(CXFA_Node* pScriptNode, - CXFA_Node* pSubform); - void DefineJsClass(); - void RemoveBuiltInObjs(CFXJSE_Context* pContext) const; - - UnownedPtr<CXFA_Document> const m_pDocument; - std::unique_ptr<CFXJSE_Context> m_JsContext; - v8::Isolate* m_pIsolate; - CFXJSE_Class* m_pJsClass; - XFA_SCRIPTLANGTYPE m_eScriptType; - std::map<CXFA_Object*, std::unique_ptr<CFXJSE_Value>> m_mapObjectToValue; - std::map<CXFA_Object*, std::unique_ptr<CFXJSE_Context>> - m_mapVariableToContext; - CXFA_EventParam m_eventParam; - std::vector<CXFA_Node*> m_upObjectArray; - // CacheList holds the NodeList items so we can clean them up when we're done. - std::vector<std::unique_ptr<CXFA_NodeList>> m_CacheList; - std::vector<CXFA_Node*>* m_pScriptNodeArray; - std::unique_ptr<CXFA_ResolveProcessor> m_ResolveProcessor; - std::unique_ptr<CXFA_FM2JSContext> m_FM2JSContext; - CXFA_Object* m_pThisObject; - uint32_t m_dwBuiltInInFlags; - XFA_ATTRIBUTEENUM m_eRunAtType; -}; - -#endif // XFA_FXFA_PARSER_CXFA_SCRIPTCONTEXT_H_ |