| 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/src/foxitlib.h" | 7 #include "xfa/src/foxitlib.h" |
| 8 #include "xfa/src/fxfa/src/common/xfa_docdata.h" | 8 #include "xfa/src/fxfa/src/common/xfa_docdata.h" |
| 9 #include "xfa/src/fxfa/src/common/xfa_doclayout.h" | 9 #include "xfa/src/fxfa/src/common/xfa_doclayout.h" |
| 10 #include "xfa/src/fxfa/src/common/xfa_document.h" | 10 #include "xfa/src/fxfa/src/common/xfa_document.h" |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 return false; | 146 return false; |
| 147 XFA_RESOLVENODE_RS resolveRs; | 147 XFA_RESOLVENODE_RS resolveRs; |
| 148 if (ResolveObjects(refNode, propname, resolveRs, dwFlag) <= 0) | 148 if (ResolveObjects(refNode, propname, resolveRs, dwFlag) <= 0) |
| 149 return false; | 149 return false; |
| 150 if (resolveRs.dwFlags == XFA_RESOVENODE_RSTYPE_Nodes) { | 150 if (resolveRs.dwFlags == XFA_RESOVENODE_RSTYPE_Nodes) { |
| 151 FXJSE_HVALUE pValue = GetJSValueFromMap(resolveRs.nodes[0]); | 151 FXJSE_HVALUE pValue = GetJSValueFromMap(resolveRs.nodes[0]); |
| 152 FXJSE_Value_Set(hValue, pValue); | 152 FXJSE_Value_Set(hValue, pValue); |
| 153 return true; | 153 return true; |
| 154 } | 154 } |
| 155 if (resolveRs.dwFlags == XFA_RESOVENODE_RSTYPE_Attribute) { | 155 if (resolveRs.dwFlags == XFA_RESOVENODE_RSTYPE_Attribute) { |
| 156 XFA_LPCSCRIPTATTRIBUTEINFO lpAttributeInfo = resolveRs.pScriptAttribute; | 156 const XFA_SCRIPTATTRIBUTEINFO* lpAttributeInfo = resolveRs.pScriptAttribute; |
| 157 if (lpAttributeInfo) { | 157 if (lpAttributeInfo) { |
| 158 (resolveRs.nodes[0]->*(lpAttributeInfo->lpfnCallback))( | 158 (resolveRs.nodes[0]->*(lpAttributeInfo->lpfnCallback))( |
| 159 hValue, bSetting, (XFA_ATTRIBUTE)lpAttributeInfo->eAttribute); | 159 hValue, bSetting, (XFA_ATTRIBUTE)lpAttributeInfo->eAttribute); |
| 160 } | 160 } |
| 161 } | 161 } |
| 162 return true; | 162 return true; |
| 163 } | 163 } |
| 164 void CXFA_ScriptContext::GlobalPropertyGetter(FXJSE_HOBJECT hObject, | 164 void CXFA_ScriptContext::GlobalPropertyGetter(FXJSE_HOBJECT hObject, |
| 165 const CFX_ByteStringC& szPropName, | 165 const CFX_ByteStringC& szPropName, |
| 166 FXJSE_HVALUE hValue) { | 166 FXJSE_HVALUE hValue) { |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 CXFA_Object* pOrginalObject = | 270 CXFA_Object* pOrginalObject = |
| 271 (CXFA_Object*)FXJSE_Value_ToObject(hObject, NULL); | 271 (CXFA_Object*)FXJSE_Value_ToObject(hObject, NULL); |
| 272 if (pOrginalObject == NULL) { | 272 if (pOrginalObject == NULL) { |
| 273 return; | 273 return; |
| 274 } | 274 } |
| 275 CXFA_ScriptContext* lpScriptContext = | 275 CXFA_ScriptContext* lpScriptContext = |
| 276 (CXFA_ScriptContext*)pOrginalObject->GetDocument()->GetScriptContext(); | 276 (CXFA_ScriptContext*)pOrginalObject->GetDocument()->GetScriptContext(); |
| 277 CXFA_Object* pObject = lpScriptContext->GetVariablesThis(pOrginalObject); | 277 CXFA_Object* pObject = lpScriptContext->GetVariablesThis(pOrginalObject); |
| 278 CFX_WideString wsPropName = CFX_WideString::FromUTF8( | 278 CFX_WideString wsPropName = CFX_WideString::FromUTF8( |
| 279 (const FX_CHAR*)szPropName.GetPtr(), szPropName.GetLength()); | 279 (const FX_CHAR*)szPropName.GetPtr(), szPropName.GetLength()); |
| 280 XFA_LPCSCRIPTATTRIBUTEINFO lpAttributeInfo = | 280 const XFA_SCRIPTATTRIBUTEINFO* lpAttributeInfo = |
| 281 XFA_GetScriptAttributeByName(pObject->GetClassID(), wsPropName); | 281 XFA_GetScriptAttributeByName(pObject->GetClassID(), wsPropName); |
| 282 if (lpAttributeInfo) { | 282 if (lpAttributeInfo) { |
| 283 (pObject->*(lpAttributeInfo->lpfnCallback))( | 283 (pObject->*(lpAttributeInfo->lpfnCallback))( |
| 284 hValue, TRUE, (XFA_ATTRIBUTE)lpAttributeInfo->eAttribute); | 284 hValue, TRUE, (XFA_ATTRIBUTE)lpAttributeInfo->eAttribute); |
| 285 } else { | 285 } else { |
| 286 if (pObject->IsNode()) { | 286 if (pObject->IsNode()) { |
| 287 if (wsPropName.GetAt(0) == '#') { | 287 if (wsPropName.GetAt(0) == '#') { |
| 288 wsPropName = wsPropName.Right(wsPropName.GetLength() - 1); | 288 wsPropName = wsPropName.Right(wsPropName.GetLength() - 1); |
| 289 } | 289 } |
| 290 CXFA_Node* pNode = ToNode(pObject); | 290 CXFA_Node* pNode = ToNode(pObject); |
| 291 CXFA_Node* pPropOrChild = NULL; | 291 CXFA_Node* pPropOrChild = NULL; |
| 292 XFA_LPCELEMENTINFO lpElementInfo = XFA_GetElementByName(wsPropName); | 292 const XFA_ELEMENTINFO* lpElementInfo = XFA_GetElementByName(wsPropName); |
| 293 if (lpElementInfo) { | 293 if (lpElementInfo) { |
| 294 pPropOrChild = pNode->GetProperty(0, lpElementInfo->eName); | 294 pPropOrChild = pNode->GetProperty(0, lpElementInfo->eName); |
| 295 } else { | 295 } else { |
| 296 pPropOrChild = pNode->GetFirstChildByName(wsPropName); | 296 pPropOrChild = pNode->GetFirstChildByName(wsPropName); |
| 297 } | 297 } |
| 298 if (pPropOrChild) { | 298 if (pPropOrChild) { |
| 299 CFX_WideString wsDefaultName = FX_WSTRC(L"{default}"); | 299 CFX_WideString wsDefaultName = FX_WSTRC(L"{default}"); |
| 300 XFA_LPCSCRIPTATTRIBUTEINFO lpAttributeInfo = | 300 const XFA_SCRIPTATTRIBUTEINFO* lpAttributeInfo = |
| 301 XFA_GetScriptAttributeByName(pPropOrChild->GetClassID(), | 301 XFA_GetScriptAttributeByName(pPropOrChild->GetClassID(), |
| 302 wsDefaultName); | 302 wsDefaultName); |
| 303 if (lpAttributeInfo) { | 303 if (lpAttributeInfo) { |
| 304 (pPropOrChild->*(lpAttributeInfo->lpfnCallback))( | 304 (pPropOrChild->*(lpAttributeInfo->lpfnCallback))( |
| 305 hValue, TRUE, (XFA_ATTRIBUTE)lpAttributeInfo->eAttribute); | 305 hValue, TRUE, (XFA_ATTRIBUTE)lpAttributeInfo->eAttribute); |
| 306 return; | 306 return; |
| 307 } | 307 } |
| 308 } | 308 } |
| 309 } | 309 } |
| 310 CXFA_Object* pScriptObject = | 310 CXFA_Object* pScriptObject = |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 361 CFXJSE_Arguments& args) { | 361 CFXJSE_Arguments& args) { |
| 362 CXFA_Object* pObject = (CXFA_Object*)FXJSE_Value_ToObject(hThis, NULL); | 362 CXFA_Object* pObject = (CXFA_Object*)FXJSE_Value_ToObject(hThis, NULL); |
| 363 if (pObject == NULL) { | 363 if (pObject == NULL) { |
| 364 return; | 364 return; |
| 365 } | 365 } |
| 366 CXFA_ScriptContext* lpScriptContext = | 366 CXFA_ScriptContext* lpScriptContext = |
| 367 (CXFA_ScriptContext*)pObject->GetDocument()->GetScriptContext(); | 367 (CXFA_ScriptContext*)pObject->GetDocument()->GetScriptContext(); |
| 368 pObject = lpScriptContext->GetVariablesThis(pObject); | 368 pObject = lpScriptContext->GetVariablesThis(pObject); |
| 369 CFX_WideString wsFunName = CFX_WideString::FromUTF8( | 369 CFX_WideString wsFunName = CFX_WideString::FromUTF8( |
| 370 (const FX_CHAR*)szFuncName.GetPtr(), szFuncName.GetLength()); | 370 (const FX_CHAR*)szFuncName.GetPtr(), szFuncName.GetLength()); |
| 371 XFA_LPCMETHODINFO lpMethodInfo = | 371 const XFA_METHODINFO* lpMethodInfo = |
| 372 XFA_GetMethodByName(pObject->GetClassID(), wsFunName); | 372 XFA_GetMethodByName(pObject->GetClassID(), wsFunName); |
| 373 if (NULL == lpMethodInfo) { | 373 if (NULL == lpMethodInfo) { |
| 374 return; | 374 return; |
| 375 } | 375 } |
| 376 (pObject->*(lpMethodInfo->lpfnCallback))(&args); | 376 (pObject->*(lpMethodInfo->lpfnCallback))(&args); |
| 377 } | 377 } |
| 378 FX_BOOL CXFA_ScriptContext::IsStrictScopeInJavaScript() { | 378 FX_BOOL CXFA_ScriptContext::IsStrictScopeInJavaScript() { |
| 379 return m_pDocument->HasFlag(XFA_DOCFLAG_StrictScoping); | 379 return m_pDocument->HasFlag(XFA_DOCFLAG_StrictScoping); |
| 380 } | 380 } |
| 381 XFA_SCRIPTLANGTYPE CXFA_ScriptContext::GetType() { | 381 XFA_SCRIPTLANGTYPE CXFA_ScriptContext::GetType() { |
| (...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 774 if (!m_pScriptNodeArray) { | 774 if (!m_pScriptNodeArray) { |
| 775 return; | 775 return; |
| 776 } | 776 } |
| 777 if (m_pScriptNodeArray->Find(pNode) == -1) { | 777 if (m_pScriptNodeArray->Find(pNode) == -1) { |
| 778 m_pScriptNodeArray->Add(pNode); | 778 m_pScriptNodeArray->Add(pNode); |
| 779 } | 779 } |
| 780 } | 780 } |
| 781 IXFA_ScriptContext* XFA_ScriptContext_Create(CXFA_Document* pDocument) { | 781 IXFA_ScriptContext* XFA_ScriptContext_Create(CXFA_Document* pDocument) { |
| 782 return new CXFA_ScriptContext(pDocument); | 782 return new CXFA_ScriptContext(pDocument); |
| 783 } | 783 } |
| OLD | NEW |