| OLD | NEW |
| 1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | 6 |
| 7 #include "xfa/fxfa/parser/xfa_script_imp.h" | 7 #include "xfa/fxfa/parser/xfa_script_imp.h" |
| 8 | 8 |
| 9 #include "core/fxcrt/include/fx_ext.h" | 9 #include "core/fxcrt/include/fx_ext.h" |
| 10 #include "xfa/fxfa/app/xfa_ffnotify.h" | 10 #include "xfa/fxfa/app/xfa_ffnotify.h" |
| 11 #include "xfa/fxfa/fm2js/xfa_fm2jsapi.h" | 11 #include "xfa/fxfa/fm2js/xfa_fm2jsapi.h" |
| 12 #include "xfa/fxfa/parser/xfa_doclayout.h" | 12 #include "xfa/fxfa/parser/xfa_doclayout.h" |
| 13 #include "xfa/fxfa/parser/xfa_document.h" | 13 #include "xfa/fxfa/parser/xfa_document.h" |
| 14 #include "xfa/fxfa/parser/xfa_localemgr.h" | 14 #include "xfa/fxfa/parser/xfa_localemgr.h" |
| 15 #include "xfa/fxfa/parser/xfa_object.h" | 15 #include "xfa/fxfa/parser/xfa_object.h" |
| 16 #include "xfa/fxfa/parser/xfa_parser.h" | 16 #include "xfa/fxfa/parser/xfa_parser.h" |
| 17 #include "xfa/fxfa/parser/xfa_script.h" | 17 #include "xfa/fxfa/parser/xfa_script.h" |
| 18 #include "xfa/fxfa/parser/xfa_script_nodehelper.h" | 18 #include "xfa/fxfa/parser/xfa_script_nodehelper.h" |
| 19 #include "xfa/fxfa/parser/xfa_script_resolveprocessor.h" | 19 #include "xfa/fxfa/parser/xfa_script_resolveprocessor.h" |
| 20 #include "xfa/fxfa/parser/xfa_utils.h" | 20 #include "xfa/fxfa/parser/xfa_utils.h" |
| 21 #include "xfa/fxjse/cfxjse_arguments.h" | 21 #include "xfa/fxjse/cfxjse_arguments.h" |
| 22 | 22 |
| 23 CXFA_ScriptContext::CXFA_ScriptContext(CXFA_Document* pDocument) | 23 CXFA_ScriptContext::CXFA_ScriptContext(CXFA_Document* pDocument) |
| 24 : m_pDocument(pDocument), | 24 : m_pDocument(pDocument), |
| 25 m_pJsContext(nullptr), | 25 m_pJsContext(nullptr), |
| 26 m_pIsolate(nullptr), | 26 m_pIsolate(nullptr), |
| 27 m_hJsClass(nullptr), | 27 m_pJsClass(nullptr), |
| 28 m_eScriptType(XFA_SCRIPTLANGTYPE_Unkown), | 28 m_eScriptType(XFA_SCRIPTLANGTYPE_Unkown), |
| 29 m_pScriptNodeArray(nullptr), | 29 m_pScriptNodeArray(nullptr), |
| 30 m_pResolveProcessor(nullptr), | 30 m_pResolveProcessor(nullptr), |
| 31 m_hFM2JSContext(nullptr), | 31 m_hFM2JSContext(nullptr), |
| 32 m_pThisObject(nullptr), | 32 m_pThisObject(nullptr), |
| 33 m_dwBuiltInInFlags(0), | 33 m_dwBuiltInInFlags(0), |
| 34 m_eRunAtType(XFA_ATTRIBUTEENUM_Client) { | 34 m_eRunAtType(XFA_ATTRIBUTEENUM_Client) { |
| 35 FXSYS_memset(&m_JsGlobalClass, 0, sizeof(FXJSE_CLASS)); | 35 FXSYS_memset(&m_JsGlobalClass, 0, sizeof(FXJSE_CLASS)); |
| 36 FXSYS_memset(&m_JsNormalClass, 0, sizeof(FXJSE_CLASS)); | 36 FXSYS_memset(&m_JsNormalClass, 0, sizeof(FXJSE_CLASS)); |
| 37 } | 37 } |
| (...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 525 m_JsNormalClass.name = "XFAObject"; | 525 m_JsNormalClass.name = "XFAObject"; |
| 526 m_JsNormalClass.propNum = 0; | 526 m_JsNormalClass.propNum = 0; |
| 527 m_JsNormalClass.properties = NULL; | 527 m_JsNormalClass.properties = NULL; |
| 528 m_JsNormalClass.methNum = 0; | 528 m_JsNormalClass.methNum = 0; |
| 529 m_JsNormalClass.methods = NULL; | 529 m_JsNormalClass.methods = NULL; |
| 530 m_JsNormalClass.dynPropGetter = CXFA_ScriptContext::NormalPropertyGetter; | 530 m_JsNormalClass.dynPropGetter = CXFA_ScriptContext::NormalPropertyGetter; |
| 531 m_JsNormalClass.dynPropSetter = CXFA_ScriptContext::NormalPropertySetter; | 531 m_JsNormalClass.dynPropSetter = CXFA_ScriptContext::NormalPropertySetter; |
| 532 m_JsNormalClass.dynPropTypeGetter = CXFA_ScriptContext::NormalPropTypeGetter; | 532 m_JsNormalClass.dynPropTypeGetter = CXFA_ScriptContext::NormalPropTypeGetter; |
| 533 m_JsNormalClass.dynPropDeleter = NULL; | 533 m_JsNormalClass.dynPropDeleter = NULL; |
| 534 m_JsNormalClass.dynMethodCall = CXFA_ScriptContext::NormalMethodCall; | 534 m_JsNormalClass.dynMethodCall = CXFA_ScriptContext::NormalMethodCall; |
| 535 m_hJsClass = FXJSE_DefineClass(m_pJsContext, &m_JsNormalClass); | 535 m_pJsClass = FXJSE_DefineClass(m_pJsContext, &m_JsNormalClass); |
| 536 } | 536 } |
| 537 void CXFA_ScriptContext::RemoveBuiltInObjs(CFXJSE_Context* pContext) const { | 537 void CXFA_ScriptContext::RemoveBuiltInObjs(CFXJSE_Context* pContext) const { |
| 538 static const CFX_ByteStringC OBJ_NAME[2] = {"Number", "Date"}; | 538 static const CFX_ByteStringC OBJ_NAME[2] = {"Number", "Date"}; |
| 539 FXJSE_HVALUE hObject = FXJSE_Context_GetGlobalObject(pContext); | 539 FXJSE_HVALUE hObject = FXJSE_Context_GetGlobalObject(pContext); |
| 540 FXJSE_HVALUE hProp = FXJSE_Value_Create(m_pIsolate); | 540 FXJSE_HVALUE hProp = FXJSE_Value_Create(m_pIsolate); |
| 541 for (int i = 0; i < 2; ++i) { | 541 for (int i = 0; i < 2; ++i) { |
| 542 if (FXJSE_Value_GetObjectProp(hObject, OBJ_NAME[i], hProp)) | 542 if (FXJSE_Value_GetObjectProp(hObject, OBJ_NAME[i], hProp)) |
| 543 FXJSE_Value_DeleteObjectProp(hObject, OBJ_NAME[i]); | 543 FXJSE_Value_DeleteObjectProp(hObject, OBJ_NAME[i]); |
| 544 } | 544 } |
| 545 FXJSE_Value_Release(hProp); | 545 FXJSE_Value_Release(hProp); |
| 546 FXJSE_Value_Release(hObject); | 546 FXJSE_Value_Release(hObject); |
| 547 } | 547 } |
| 548 FXJSE_HCLASS CXFA_ScriptContext::GetJseNormalClass() { | 548 CFXJSE_Class* CXFA_ScriptContext::GetJseNormalClass() { |
| 549 return m_hJsClass; | 549 return m_pJsClass; |
| 550 } | 550 } |
| 551 int32_t CXFA_ScriptContext::ResolveObjects(CXFA_Object* refNode, | 551 int32_t CXFA_ScriptContext::ResolveObjects(CXFA_Object* refNode, |
| 552 const CFX_WideStringC& wsExpression, | 552 const CFX_WideStringC& wsExpression, |
| 553 XFA_RESOLVENODE_RS& resolveNodeRS, | 553 XFA_RESOLVENODE_RS& resolveNodeRS, |
| 554 uint32_t dwStyles, | 554 uint32_t dwStyles, |
| 555 CXFA_Node* bindNode) { | 555 CXFA_Node* bindNode) { |
| 556 if (wsExpression.IsEmpty()) { | 556 if (wsExpression.IsEmpty()) { |
| 557 return 0; | 557 return 0; |
| 558 } | 558 } |
| 559 if (m_eScriptType != XFA_SCRIPTLANGTYPE_Formcalc || | 559 if (m_eScriptType != XFA_SCRIPTLANGTYPE_Formcalc || |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 715 FXJSE_HVALUE CXFA_ScriptContext::GetJSValueFromMap(CXFA_Object* pObject) { | 715 FXJSE_HVALUE CXFA_ScriptContext::GetJSValueFromMap(CXFA_Object* pObject) { |
| 716 if (!pObject) { | 716 if (!pObject) { |
| 717 return NULL; | 717 return NULL; |
| 718 } | 718 } |
| 719 if (pObject->IsNode()) { | 719 if (pObject->IsNode()) { |
| 720 RunVariablesScript(pObject->AsNode()); | 720 RunVariablesScript(pObject->AsNode()); |
| 721 } | 721 } |
| 722 void* pValue = m_mapXFAToHValue.GetValueAt(pObject); | 722 void* pValue = m_mapXFAToHValue.GetValueAt(pObject); |
| 723 if (pValue == NULL) { | 723 if (pValue == NULL) { |
| 724 FXJSE_HVALUE jsHvalue = FXJSE_Value_Create(m_pIsolate); | 724 FXJSE_HVALUE jsHvalue = FXJSE_Value_Create(m_pIsolate); |
| 725 FXJSE_Value_SetObject(jsHvalue, pObject, m_hJsClass); | 725 FXJSE_Value_SetObject(jsHvalue, pObject, m_pJsClass); |
| 726 m_mapXFAToHValue.SetAt(pObject, jsHvalue); | 726 m_mapXFAToHValue.SetAt(pObject, jsHvalue); |
| 727 pValue = jsHvalue; | 727 pValue = jsHvalue; |
| 728 } | 728 } |
| 729 return (FXJSE_HVALUE)pValue; | 729 return (FXJSE_HVALUE)pValue; |
| 730 } | 730 } |
| 731 int32_t CXFA_ScriptContext::GetIndexByName(CXFA_Node* refNode) { | 731 int32_t CXFA_ScriptContext::GetIndexByName(CXFA_Node* refNode) { |
| 732 CXFA_NodeHelper* lpNodeHelper = m_pResolveProcessor->GetNodeHelper(); | 732 CXFA_NodeHelper* lpNodeHelper = m_pResolveProcessor->GetNodeHelper(); |
| 733 return lpNodeHelper->XFA_GetIndex(refNode, XFA_LOGIC_Transparent, | 733 return lpNodeHelper->XFA_GetIndex(refNode, XFA_LOGIC_Transparent, |
| 734 lpNodeHelper->XFA_NodeIsProperty(refNode), | 734 lpNodeHelper->XFA_NodeIsProperty(refNode), |
| 735 FALSE); | 735 FALSE); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 758 } | 758 } |
| 759 } | 759 } |
| 760 void CXFA_ScriptContext::AddNodesOfRunScript(CXFA_Node* pNode) { | 760 void CXFA_ScriptContext::AddNodesOfRunScript(CXFA_Node* pNode) { |
| 761 if (!m_pScriptNodeArray) { | 761 if (!m_pScriptNodeArray) { |
| 762 return; | 762 return; |
| 763 } | 763 } |
| 764 if (m_pScriptNodeArray->Find(pNode) == -1) { | 764 if (m_pScriptNodeArray->Find(pNode) == -1) { |
| 765 m_pScriptNodeArray->Add(pNode); | 765 m_pScriptNodeArray->Add(pNode); |
| 766 } | 766 } |
| 767 } | 767 } |
| OLD | NEW |