| 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 483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 521 m_JsNormalClass.name = "XFAObject"; | 521 m_JsNormalClass.name = "XFAObject"; |
| 522 m_JsNormalClass.propNum = 0; | 522 m_JsNormalClass.propNum = 0; |
| 523 m_JsNormalClass.properties = NULL; | 523 m_JsNormalClass.properties = NULL; |
| 524 m_JsNormalClass.methNum = 0; | 524 m_JsNormalClass.methNum = 0; |
| 525 m_JsNormalClass.methods = NULL; | 525 m_JsNormalClass.methods = NULL; |
| 526 m_JsNormalClass.dynPropGetter = CXFA_ScriptContext::NormalPropertyGetter; | 526 m_JsNormalClass.dynPropGetter = CXFA_ScriptContext::NormalPropertyGetter; |
| 527 m_JsNormalClass.dynPropSetter = CXFA_ScriptContext::NormalPropertySetter; | 527 m_JsNormalClass.dynPropSetter = CXFA_ScriptContext::NormalPropertySetter; |
| 528 m_JsNormalClass.dynPropTypeGetter = CXFA_ScriptContext::NormalPropTypeGetter; | 528 m_JsNormalClass.dynPropTypeGetter = CXFA_ScriptContext::NormalPropTypeGetter; |
| 529 m_JsNormalClass.dynPropDeleter = NULL; | 529 m_JsNormalClass.dynPropDeleter = NULL; |
| 530 m_JsNormalClass.dynMethodCall = CXFA_ScriptContext::NormalMethodCall; | 530 m_JsNormalClass.dynMethodCall = CXFA_ScriptContext::NormalMethodCall; |
| 531 m_hJsClass = FXJSE_DefineClass(m_pJsContext, &m_JsNormalClass); | 531 m_pJsClass = FXJSE_DefineClass(m_pJsContext, &m_JsNormalClass); |
| 532 } | 532 } |
| 533 void CXFA_ScriptContext::RemoveBuiltInObjs(CFXJSE_Context* pContext) const { | 533 void CXFA_ScriptContext::RemoveBuiltInObjs(CFXJSE_Context* pContext) const { |
| 534 static const CFX_ByteStringC OBJ_NAME[2] = {"Number", "Date"}; | 534 static const CFX_ByteStringC OBJ_NAME[2] = {"Number", "Date"}; |
| 535 FXJSE_HVALUE hObject = FXJSE_Context_GetGlobalObject(pContext); | 535 FXJSE_HVALUE hObject = FXJSE_Context_GetGlobalObject(pContext); |
| 536 FXJSE_HVALUE hProp = FXJSE_Value_Create(m_pIsolate); | 536 FXJSE_HVALUE hProp = FXJSE_Value_Create(m_pIsolate); |
| 537 for (int i = 0; i < 2; ++i) { | 537 for (int i = 0; i < 2; ++i) { |
| 538 if (FXJSE_Value_GetObjectProp(hObject, OBJ_NAME[i], hProp)) | 538 if (FXJSE_Value_GetObjectProp(hObject, OBJ_NAME[i], hProp)) |
| 539 FXJSE_Value_DeleteObjectProp(hObject, OBJ_NAME[i]); | 539 FXJSE_Value_DeleteObjectProp(hObject, OBJ_NAME[i]); |
| 540 } | 540 } |
| 541 FXJSE_Value_Release(hProp); | 541 FXJSE_Value_Release(hProp); |
| 542 FXJSE_Value_Release(hObject); | 542 FXJSE_Value_Release(hObject); |
| 543 } | 543 } |
| 544 FXJSE_HCLASS CXFA_ScriptContext::GetJseNormalClass() { | 544 CFXJSE_Class* CXFA_ScriptContext::GetJseNormalClass() { |
| 545 return m_hJsClass; | 545 return m_pJsClass; |
| 546 } | 546 } |
| 547 int32_t CXFA_ScriptContext::ResolveObjects(CXFA_Object* refNode, | 547 int32_t CXFA_ScriptContext::ResolveObjects(CXFA_Object* refNode, |
| 548 const CFX_WideStringC& wsExpression, | 548 const CFX_WideStringC& wsExpression, |
| 549 XFA_RESOLVENODE_RS& resolveNodeRS, | 549 XFA_RESOLVENODE_RS& resolveNodeRS, |
| 550 uint32_t dwStyles, | 550 uint32_t dwStyles, |
| 551 CXFA_Node* bindNode) { | 551 CXFA_Node* bindNode) { |
| 552 if (wsExpression.IsEmpty()) { | 552 if (wsExpression.IsEmpty()) { |
| 553 return 0; | 553 return 0; |
| 554 } | 554 } |
| 555 if (m_eScriptType != XFA_SCRIPTLANGTYPE_Formcalc || | 555 if (m_eScriptType != XFA_SCRIPTLANGTYPE_Formcalc || |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 710 FXJSE_HVALUE CXFA_ScriptContext::GetJSValueFromMap(CXFA_Object* pObject) { | 710 FXJSE_HVALUE CXFA_ScriptContext::GetJSValueFromMap(CXFA_Object* pObject) { |
| 711 if (!pObject) { | 711 if (!pObject) { |
| 712 return NULL; | 712 return NULL; |
| 713 } | 713 } |
| 714 if (pObject->IsNode()) { | 714 if (pObject->IsNode()) { |
| 715 RunVariablesScript(pObject->AsNode()); | 715 RunVariablesScript(pObject->AsNode()); |
| 716 } | 716 } |
| 717 void* pValue = m_mapXFAToHValue.GetValueAt(pObject); | 717 void* pValue = m_mapXFAToHValue.GetValueAt(pObject); |
| 718 if (pValue == NULL) { | 718 if (pValue == NULL) { |
| 719 FXJSE_HVALUE jsHvalue = FXJSE_Value_Create(m_pIsolate); | 719 FXJSE_HVALUE jsHvalue = FXJSE_Value_Create(m_pIsolate); |
| 720 FXJSE_Value_SetObject(jsHvalue, pObject, m_hJsClass); | 720 FXJSE_Value_SetObject(jsHvalue, pObject, m_pJsClass); |
| 721 m_mapXFAToHValue.SetAt(pObject, jsHvalue); | 721 m_mapXFAToHValue.SetAt(pObject, jsHvalue); |
| 722 pValue = jsHvalue; | 722 pValue = jsHvalue; |
| 723 } | 723 } |
| 724 return (FXJSE_HVALUE)pValue; | 724 return (FXJSE_HVALUE)pValue; |
| 725 } | 725 } |
| 726 int32_t CXFA_ScriptContext::GetIndexByName(CXFA_Node* refNode) { | 726 int32_t CXFA_ScriptContext::GetIndexByName(CXFA_Node* refNode) { |
| 727 CXFA_NodeHelper* lpNodeHelper = m_pResolveProcessor->GetNodeHelper(); | 727 CXFA_NodeHelper* lpNodeHelper = m_pResolveProcessor->GetNodeHelper(); |
| 728 return lpNodeHelper->XFA_GetIndex(refNode, XFA_LOGIC_Transparent, | 728 return lpNodeHelper->XFA_GetIndex(refNode, XFA_LOGIC_Transparent, |
| 729 lpNodeHelper->XFA_NodeIsProperty(refNode), | 729 lpNodeHelper->XFA_NodeIsProperty(refNode), |
| 730 FALSE); | 730 FALSE); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 753 } | 753 } |
| 754 } | 754 } |
| 755 void CXFA_ScriptContext::AddNodesOfRunScript(CXFA_Node* pNode) { | 755 void CXFA_ScriptContext::AddNodesOfRunScript(CXFA_Node* pNode) { |
| 756 if (!m_pScriptNodeArray) { | 756 if (!m_pScriptNodeArray) { |
| 757 return; | 757 return; |
| 758 } | 758 } |
| 759 if (m_pScriptNodeArray->Find(pNode) == -1) { | 759 if (m_pScriptNodeArray->Find(pNode) == -1) { |
| 760 m_pScriptNodeArray->Add(pNode); | 760 m_pScriptNodeArray->Add(pNode); |
| 761 } | 761 } |
| 762 } | 762 } |
| OLD | NEW |