| 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" |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 return FALSE; | 94 return FALSE; |
| 95 } | 95 } |
| 96 btScript = | 96 btScript = |
| 97 FX_UTF8Encode(wsJavaScript.GetBuffer(), wsJavaScript.GetLength()); | 97 FX_UTF8Encode(wsJavaScript.GetBuffer(), wsJavaScript.GetLength()); |
| 98 } else { | 98 } else { |
| 99 btScript = FX_UTF8Encode(wsScript.c_str(), wsScript.GetLength()); | 99 btScript = FX_UTF8Encode(wsScript.c_str(), wsScript.GetLength()); |
| 100 } | 100 } |
| 101 CXFA_Object* pOriginalObject = m_pThisObject; | 101 CXFA_Object* pOriginalObject = m_pThisObject; |
| 102 m_pThisObject = pThisObject; | 102 m_pThisObject = pThisObject; |
| 103 FXJSE_HVALUE pValue = pThisObject ? GetJSValueFromMap(pThisObject) : NULL; | 103 FXJSE_HVALUE pValue = pThisObject ? GetJSValueFromMap(pThisObject) : NULL; |
| 104 FX_BOOL bRet = FXJSE_ExecuteScript(m_hJsContext, btScript, hRetValue, pValue); | 104 FX_BOOL bRet = |
| 105 FXJSE_ExecuteScript(m_hJsContext, btScript.c_str(), hRetValue, pValue); |
| 105 m_pThisObject = pOriginalObject; | 106 m_pThisObject = pOriginalObject; |
| 106 m_eScriptType = eSaveType; | 107 m_eScriptType = eSaveType; |
| 107 return bRet; | 108 return bRet; |
| 108 } | 109 } |
| 109 void CXFA_ScriptContext::GlobalPropertySetter(FXJSE_HOBJECT hObject, | 110 void CXFA_ScriptContext::GlobalPropertySetter(FXJSE_HOBJECT hObject, |
| 110 const CFX_ByteStringC& szPropName, | 111 const CFX_ByteStringC& szPropName, |
| 111 FXJSE_HVALUE hValue) { | 112 FXJSE_HVALUE hValue) { |
| 112 CXFA_Object* lpOrginalNode = | 113 CXFA_Object* lpOrginalNode = |
| 113 (CXFA_Object*)FXJSE_Value_ToObject(hObject, NULL); | 114 (CXFA_Object*)FXJSE_Value_ToObject(hObject, NULL); |
| 114 CXFA_Document* pDoc = lpOrginalNode->GetDocument(); | 115 CXFA_Document* pDoc = lpOrginalNode->GetDocument(); |
| (...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 459 return FALSE; | 460 return FALSE; |
| 460 } | 461 } |
| 461 CFX_ByteString btScript = | 462 CFX_ByteString btScript = |
| 462 FX_UTF8Encode(wsScript.c_str(), wsScript.GetLength()); | 463 FX_UTF8Encode(wsScript.c_str(), wsScript.GetLength()); |
| 463 FXJSE_HVALUE hRetValue = FXJSE_Value_Create(m_hJsRuntime); | 464 FXJSE_HVALUE hRetValue = FXJSE_Value_Create(m_hJsRuntime); |
| 464 CXFA_Node* pThisObject = pParent->GetNodeItem(XFA_NODEITEM_Parent); | 465 CXFA_Node* pThisObject = pParent->GetNodeItem(XFA_NODEITEM_Parent); |
| 465 FXJSE_HCONTEXT hVariablesContext = | 466 FXJSE_HCONTEXT hVariablesContext = |
| 466 CreateVariablesContext(pScriptNode, pThisObject); | 467 CreateVariablesContext(pScriptNode, pThisObject); |
| 467 CXFA_Object* pOriginalObject = m_pThisObject; | 468 CXFA_Object* pOriginalObject = m_pThisObject; |
| 468 m_pThisObject = pThisObject; | 469 m_pThisObject = pThisObject; |
| 469 FX_BOOL bRet = FXJSE_ExecuteScript(hVariablesContext, btScript, hRetValue); | 470 FX_BOOL bRet = |
| 471 FXJSE_ExecuteScript(hVariablesContext, btScript.c_str(), hRetValue); |
| 470 m_pThisObject = pOriginalObject; | 472 m_pThisObject = pOriginalObject; |
| 471 FXJSE_Value_Release(hRetValue); | 473 FXJSE_Value_Release(hRetValue); |
| 472 return bRet; | 474 return bRet; |
| 473 } | 475 } |
| 474 return TRUE; | 476 return TRUE; |
| 475 } | 477 } |
| 476 FX_BOOL CXFA_ScriptContext::QueryVariableHValue( | 478 FX_BOOL CXFA_ScriptContext::QueryVariableHValue( |
| 477 CXFA_Node* pScriptNode, | 479 CXFA_Node* pScriptNode, |
| 478 const CFX_ByteStringC& szPropName, | 480 const CFX_ByteStringC& szPropName, |
| 479 FXJSE_HVALUE hValue, | 481 FXJSE_HVALUE hValue, |
| (...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 766 } | 768 } |
| 767 } | 769 } |
| 768 void CXFA_ScriptContext::AddNodesOfRunScript(CXFA_Node* pNode) { | 770 void CXFA_ScriptContext::AddNodesOfRunScript(CXFA_Node* pNode) { |
| 769 if (!m_pScriptNodeArray) { | 771 if (!m_pScriptNodeArray) { |
| 770 return; | 772 return; |
| 771 } | 773 } |
| 772 if (m_pScriptNodeArray->Find(pNode) == -1) { | 774 if (m_pScriptNodeArray->Find(pNode) == -1) { |
| 773 m_pScriptNodeArray->Add(pNode); | 775 m_pScriptNodeArray->Add(pNode); |
| 774 } | 776 } |
| 775 } | 777 } |
| OLD | NEW |