Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(81)

Side by Side Diff: xfa/fxfa/parser/xfa_script_imp.cpp

Issue 2014863002: Revert of Remove parameters which are always null (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « xfa/fxfa/parser/xfa_script_hostpseudomodel.cpp ('k') | xfa/fxjse/cfxjse_arguments.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
94 FXJSE_HVALUE pValue = pThisObject ? GetJSValueFromMap(pThisObject) : NULL; 94 FXJSE_HVALUE pValue = pThisObject ? GetJSValueFromMap(pThisObject) : NULL;
95 FX_BOOL bRet = 95 FX_BOOL bRet =
96 FXJSE_ExecuteScript(m_hJsContext, btScript.c_str(), hRetValue, pValue); 96 FXJSE_ExecuteScript(m_hJsContext, btScript.c_str(), hRetValue, pValue);
97 m_pThisObject = pOriginalObject; 97 m_pThisObject = pOriginalObject;
98 m_eScriptType = eSaveType; 98 m_eScriptType = eSaveType;
99 return bRet; 99 return bRet;
100 } 100 }
101 void CXFA_ScriptContext::GlobalPropertySetter(FXJSE_HOBJECT hObject, 101 void CXFA_ScriptContext::GlobalPropertySetter(FXJSE_HOBJECT hObject,
102 const CFX_ByteStringC& szPropName, 102 const CFX_ByteStringC& szPropName,
103 FXJSE_HVALUE hValue) { 103 FXJSE_HVALUE hValue) {
104 CXFA_Object* lpOrginalNode = (CXFA_Object*)FXJSE_Value_ToObject(hObject); 104 CXFA_Object* lpOrginalNode =
105 (CXFA_Object*)FXJSE_Value_ToObject(hObject, NULL);
105 CXFA_Document* pDoc = lpOrginalNode->GetDocument(); 106 CXFA_Document* pDoc = lpOrginalNode->GetDocument();
106 CXFA_ScriptContext* lpScriptContext = 107 CXFA_ScriptContext* lpScriptContext =
107 (CXFA_ScriptContext*)pDoc->GetScriptContext(); 108 (CXFA_ScriptContext*)pDoc->GetScriptContext();
108 CXFA_Object* lpCurNode = lpScriptContext->GetVariablesThis(lpOrginalNode); 109 CXFA_Object* lpCurNode = lpScriptContext->GetVariablesThis(lpOrginalNode);
109 CFX_WideString wsPropName = CFX_WideString::FromUTF8(szPropName); 110 CFX_WideString wsPropName = CFX_WideString::FromUTF8(szPropName);
110 uint32_t dwFlag = XFA_RESOLVENODE_Parent | XFA_RESOLVENODE_Siblings | 111 uint32_t dwFlag = XFA_RESOLVENODE_Parent | XFA_RESOLVENODE_Siblings |
111 XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Properties | 112 XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Properties |
112 XFA_RESOLVENODE_Attributes; 113 XFA_RESOLVENODE_Attributes;
113 CXFA_Node* pRefNode = ToNode(lpScriptContext->GetThisObject()); 114 CXFA_Node* pRefNode = ToNode(lpScriptContext->GetThisObject());
114 if (lpOrginalNode->GetObjectType() == XFA_OBJECTTYPE_VariablesThis) { 115 if (lpOrginalNode->GetObjectType() == XFA_OBJECTTYPE_VariablesThis) {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 if (lpAttributeInfo) { 152 if (lpAttributeInfo) {
152 (resolveRs.nodes[0]->*(lpAttributeInfo->lpfnCallback))( 153 (resolveRs.nodes[0]->*(lpAttributeInfo->lpfnCallback))(
153 hValue, bSetting, (XFA_ATTRIBUTE)lpAttributeInfo->eAttribute); 154 hValue, bSetting, (XFA_ATTRIBUTE)lpAttributeInfo->eAttribute);
154 } 155 }
155 } 156 }
156 return true; 157 return true;
157 } 158 }
158 void CXFA_ScriptContext::GlobalPropertyGetter(FXJSE_HOBJECT hObject, 159 void CXFA_ScriptContext::GlobalPropertyGetter(FXJSE_HOBJECT hObject,
159 const CFX_ByteStringC& szPropName, 160 const CFX_ByteStringC& szPropName,
160 FXJSE_HVALUE hValue) { 161 FXJSE_HVALUE hValue) {
161 CXFA_Object* pOrginalObject = (CXFA_Object*)FXJSE_Value_ToObject(hObject); 162 CXFA_Object* pOrginalObject =
163 (CXFA_Object*)FXJSE_Value_ToObject(hObject, NULL);
162 CXFA_Document* pDoc = pOrginalObject->GetDocument(); 164 CXFA_Document* pDoc = pOrginalObject->GetDocument();
163 CXFA_ScriptContext* lpScriptContext = 165 CXFA_ScriptContext* lpScriptContext =
164 (CXFA_ScriptContext*)pDoc->GetScriptContext(); 166 (CXFA_ScriptContext*)pDoc->GetScriptContext();
165 CXFA_Object* lpCurNode = lpScriptContext->GetVariablesThis(pOrginalObject); 167 CXFA_Object* lpCurNode = lpScriptContext->GetVariablesThis(pOrginalObject);
166 CFX_WideString wsPropName = CFX_WideString::FromUTF8(szPropName); 168 CFX_WideString wsPropName = CFX_WideString::FromUTF8(szPropName);
167 if (lpScriptContext->GetType() == XFA_SCRIPTLANGTYPE_Formcalc) { 169 if (lpScriptContext->GetType() == XFA_SCRIPTLANGTYPE_Formcalc) {
168 if (szPropName == FOXIT_XFA_FM2JS_FORMCALC_RUNTIME) { 170 if (szPropName == FOXIT_XFA_FM2JS_FORMCALC_RUNTIME) {
169 XFA_FM2JS_GlobalPropertyGetter(lpScriptContext->m_hFM2JSContext, hValue); 171 XFA_FM2JS_GlobalPropertyGetter(lpScriptContext->m_hFM2JSContext, hValue);
170 return; 172 return;
171 } 173 }
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 CXFA_FFNotify* pNotify = pDoc->GetNotify(); 207 CXFA_FFNotify* pNotify = pDoc->GetNotify();
206 if (!pNotify) { 208 if (!pNotify) {
207 return; 209 return;
208 } 210 }
209 pNotify->GetDocProvider()->GetGlobalProperty(pNotify->GetHDOC(), szPropName, 211 pNotify->GetDocProvider()->GetGlobalProperty(pNotify->GetHDOC(), szPropName,
210 hValue); 212 hValue);
211 } 213 }
212 void CXFA_ScriptContext::NormalPropertyGetter(FXJSE_HOBJECT hObject, 214 void CXFA_ScriptContext::NormalPropertyGetter(FXJSE_HOBJECT hObject,
213 const CFX_ByteStringC& szPropName, 215 const CFX_ByteStringC& szPropName,
214 FXJSE_HVALUE hValue) { 216 FXJSE_HVALUE hValue) {
215 CXFA_Object* pOrginalObject = (CXFA_Object*)FXJSE_Value_ToObject(hObject); 217 CXFA_Object* pOrginalObject =
218 (CXFA_Object*)FXJSE_Value_ToObject(hObject, NULL);
216 if (pOrginalObject == NULL) { 219 if (pOrginalObject == NULL) {
217 FXJSE_Value_SetUndefined(hValue); 220 FXJSE_Value_SetUndefined(hValue);
218 return; 221 return;
219 } 222 }
220 CFX_WideString wsPropName = CFX_WideString::FromUTF8(szPropName); 223 CFX_WideString wsPropName = CFX_WideString::FromUTF8(szPropName);
221 CXFA_ScriptContext* lpScriptContext = 224 CXFA_ScriptContext* lpScriptContext =
222 (CXFA_ScriptContext*)pOrginalObject->GetDocument()->GetScriptContext(); 225 (CXFA_ScriptContext*)pOrginalObject->GetDocument()->GetScriptContext();
223 CXFA_Object* pObject = lpScriptContext->GetVariablesThis(pOrginalObject); 226 CXFA_Object* pObject = lpScriptContext->GetVariablesThis(pOrginalObject);
224 if (wsPropName == FX_WSTRC(L"xfa")) { 227 if (wsPropName == FX_WSTRC(L"xfa")) {
225 FXJSE_HVALUE pValue = lpScriptContext->GetJSValueFromMap( 228 FXJSE_HVALUE pValue = lpScriptContext->GetJSValueFromMap(
(...skipping 24 matching lines...) Expand all
250 bRet = lpScriptContext->QueryVariableHValue(ToNode(pScriptObject), 253 bRet = lpScriptContext->QueryVariableHValue(ToNode(pScriptObject),
251 szPropName, hValue, TRUE); 254 szPropName, hValue, TRUE);
252 } 255 }
253 if (!bRet) { 256 if (!bRet) {
254 FXJSE_Value_SetUndefined(hValue); 257 FXJSE_Value_SetUndefined(hValue);
255 } 258 }
256 } 259 }
257 void CXFA_ScriptContext::NormalPropertySetter(FXJSE_HOBJECT hObject, 260 void CXFA_ScriptContext::NormalPropertySetter(FXJSE_HOBJECT hObject,
258 const CFX_ByteStringC& szPropName, 261 const CFX_ByteStringC& szPropName,
259 FXJSE_HVALUE hValue) { 262 FXJSE_HVALUE hValue) {
260 CXFA_Object* pOrginalObject = (CXFA_Object*)FXJSE_Value_ToObject(hObject); 263 CXFA_Object* pOrginalObject =
264 (CXFA_Object*)FXJSE_Value_ToObject(hObject, NULL);
261 if (pOrginalObject == NULL) { 265 if (pOrginalObject == NULL) {
262 return; 266 return;
263 } 267 }
264 CXFA_ScriptContext* lpScriptContext = 268 CXFA_ScriptContext* lpScriptContext =
265 (CXFA_ScriptContext*)pOrginalObject->GetDocument()->GetScriptContext(); 269 (CXFA_ScriptContext*)pOrginalObject->GetDocument()->GetScriptContext();
266 CXFA_Object* pObject = lpScriptContext->GetVariablesThis(pOrginalObject); 270 CXFA_Object* pObject = lpScriptContext->GetVariablesThis(pOrginalObject);
267 CFX_WideString wsPropName = CFX_WideString::FromUTF8(szPropName); 271 CFX_WideString wsPropName = CFX_WideString::FromUTF8(szPropName);
268 const XFA_SCRIPTATTRIBUTEINFO* lpAttributeInfo = XFA_GetScriptAttributeByName( 272 const XFA_SCRIPTATTRIBUTEINFO* lpAttributeInfo = XFA_GetScriptAttributeByName(
269 pObject->GetClassID(), wsPropName.AsStringC()); 273 pObject->GetClassID(), wsPropName.AsStringC());
270 if (lpAttributeInfo) { 274 if (lpAttributeInfo) {
(...skipping 30 matching lines...) Expand all
301 if (pScriptObject) { 305 if (pScriptObject) {
302 lpScriptContext->QueryVariableHValue(ToNode(pScriptObject), szPropName, 306 lpScriptContext->QueryVariableHValue(ToNode(pScriptObject), szPropName,
303 hValue, FALSE); 307 hValue, FALSE);
304 } 308 }
305 } 309 }
306 } 310 }
307 int32_t CXFA_ScriptContext::NormalPropTypeGetter( 311 int32_t CXFA_ScriptContext::NormalPropTypeGetter(
308 FXJSE_HOBJECT hObject, 312 FXJSE_HOBJECT hObject,
309 const CFX_ByteStringC& szPropName, 313 const CFX_ByteStringC& szPropName,
310 FX_BOOL bQueryIn) { 314 FX_BOOL bQueryIn) {
311 CXFA_Object* pObject = (CXFA_Object*)FXJSE_Value_ToObject(hObject); 315 CXFA_Object* pObject = (CXFA_Object*)FXJSE_Value_ToObject(hObject, NULL);
312 if (pObject == NULL) { 316 if (pObject == NULL) {
313 return FXJSE_ClassPropType_None; 317 return FXJSE_ClassPropType_None;
314 } 318 }
315 CXFA_ScriptContext* lpScriptContext = 319 CXFA_ScriptContext* lpScriptContext =
316 (CXFA_ScriptContext*)pObject->GetDocument()->GetScriptContext(); 320 (CXFA_ScriptContext*)pObject->GetDocument()->GetScriptContext();
317 pObject = lpScriptContext->GetVariablesThis(pObject); 321 pObject = lpScriptContext->GetVariablesThis(pObject);
318 XFA_ELEMENT objElement = pObject->GetClassID(); 322 XFA_ELEMENT objElement = pObject->GetClassID();
319 CFX_WideString wsPropName = CFX_WideString::FromUTF8(szPropName); 323 CFX_WideString wsPropName = CFX_WideString::FromUTF8(szPropName);
320 if (XFA_GetMethodByName(objElement, wsPropName.AsStringC())) { 324 if (XFA_GetMethodByName(objElement, wsPropName.AsStringC())) {
321 return FXJSE_ClassPropType_Method; 325 return FXJSE_ClassPropType_Method;
322 } 326 }
323 if (bQueryIn && 327 if (bQueryIn &&
324 !XFA_GetScriptAttributeByName(objElement, wsPropName.AsStringC())) { 328 !XFA_GetScriptAttributeByName(objElement, wsPropName.AsStringC())) {
325 return FXJSE_ClassPropType_None; 329 return FXJSE_ClassPropType_None;
326 } 330 }
327 return FXJSE_ClassPropType_Property; 331 return FXJSE_ClassPropType_Property;
328 } 332 }
329 int32_t CXFA_ScriptContext::GlobalPropTypeGetter( 333 int32_t CXFA_ScriptContext::GlobalPropTypeGetter(
330 FXJSE_HOBJECT hObject, 334 FXJSE_HOBJECT hObject,
331 const CFX_ByteStringC& szPropName, 335 const CFX_ByteStringC& szPropName,
332 FX_BOOL bQueryIn) { 336 FX_BOOL bQueryIn) {
333 CXFA_Object* pObject = (CXFA_Object*)FXJSE_Value_ToObject(hObject); 337 CXFA_Object* pObject = (CXFA_Object*)FXJSE_Value_ToObject(hObject, NULL);
334 if (pObject == NULL) { 338 if (pObject == NULL) {
335 return FXJSE_ClassPropType_None; 339 return FXJSE_ClassPropType_None;
336 } 340 }
337 CXFA_ScriptContext* lpScriptContext = 341 CXFA_ScriptContext* lpScriptContext =
338 (CXFA_ScriptContext*)pObject->GetDocument()->GetScriptContext(); 342 (CXFA_ScriptContext*)pObject->GetDocument()->GetScriptContext();
339 pObject = lpScriptContext->GetVariablesThis(pObject); 343 pObject = lpScriptContext->GetVariablesThis(pObject);
340 XFA_ELEMENT objElement = pObject->GetClassID(); 344 XFA_ELEMENT objElement = pObject->GetClassID();
341 CFX_WideString wsPropName = CFX_WideString::FromUTF8(szPropName); 345 CFX_WideString wsPropName = CFX_WideString::FromUTF8(szPropName);
342 if (XFA_GetMethodByName(objElement, wsPropName.AsStringC())) { 346 if (XFA_GetMethodByName(objElement, wsPropName.AsStringC())) {
343 return FXJSE_ClassPropType_Method; 347 return FXJSE_ClassPropType_Method;
344 } 348 }
345 return FXJSE_ClassPropType_Property; 349 return FXJSE_ClassPropType_Property;
346 } 350 }
347 void CXFA_ScriptContext::NormalMethodCall(FXJSE_HOBJECT hThis, 351 void CXFA_ScriptContext::NormalMethodCall(FXJSE_HOBJECT hThis,
348 const CFX_ByteStringC& szFuncName, 352 const CFX_ByteStringC& szFuncName,
349 CFXJSE_Arguments& args) { 353 CFXJSE_Arguments& args) {
350 CXFA_Object* pObject = (CXFA_Object*)FXJSE_Value_ToObject(hThis); 354 CXFA_Object* pObject = (CXFA_Object*)FXJSE_Value_ToObject(hThis, NULL);
351 if (pObject == NULL) { 355 if (pObject == NULL) {
352 return; 356 return;
353 } 357 }
354 CXFA_ScriptContext* lpScriptContext = 358 CXFA_ScriptContext* lpScriptContext =
355 (CXFA_ScriptContext*)pObject->GetDocument()->GetScriptContext(); 359 (CXFA_ScriptContext*)pObject->GetDocument()->GetScriptContext();
356 pObject = lpScriptContext->GetVariablesThis(pObject); 360 pObject = lpScriptContext->GetVariablesThis(pObject);
357 CFX_WideString wsFunName = CFX_WideString::FromUTF8(szFuncName); 361 CFX_WideString wsFunName = CFX_WideString::FromUTF8(szFuncName);
358 const XFA_METHODINFO* lpMethodInfo = 362 const XFA_METHODINFO* lpMethodInfo =
359 XFA_GetMethodByName(pObject->GetClassID(), wsFunName.AsStringC()); 363 XFA_GetMethodByName(pObject->GetClassID(), wsFunName.AsStringC());
360 if (NULL == lpMethodInfo) { 364 if (NULL == lpMethodInfo) {
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
502 return bRes; 506 return bRes;
503 } 507 }
504 508
505 void CXFA_ScriptContext::ReleaseVariablesMap() { 509 void CXFA_ScriptContext::ReleaseVariablesMap() {
506 FX_POSITION ps = m_mapVariableToHValue.GetStartPosition(); 510 FX_POSITION ps = m_mapVariableToHValue.GetStartPosition();
507 while (ps) { 511 while (ps) {
508 CXFA_Object* pScriptNode; 512 CXFA_Object* pScriptNode;
509 FXJSE_HCONTEXT hVariableContext = nullptr; 513 FXJSE_HCONTEXT hVariableContext = nullptr;
510 m_mapVariableToHValue.GetNextAssoc(ps, pScriptNode, hVariableContext); 514 m_mapVariableToHValue.GetNextAssoc(ps, pScriptNode, hVariableContext);
511 FXJSE_HVALUE hObject = FXJSE_Context_GetGlobalObject(hVariableContext); 515 FXJSE_HVALUE hObject = FXJSE_Context_GetGlobalObject(hVariableContext);
512 delete static_cast<CXFA_ThisProxy*>(FXJSE_Value_ToObject(hObject)); 516 delete static_cast<CXFA_ThisProxy*>(FXJSE_Value_ToObject(hObject, nullptr));
513 FXJSE_Value_Release(hObject); 517 FXJSE_Value_Release(hObject);
514 FXJSE_Context_Release(hVariableContext); 518 FXJSE_Context_Release(hVariableContext);
515 } 519 }
516 m_mapVariableToHValue.RemoveAll(); 520 m_mapVariableToHValue.RemoveAll();
517 } 521 }
518 522
519 void CXFA_ScriptContext::DefineJsClass() { 523 void CXFA_ScriptContext::DefineJsClass() {
520 m_JsNormalClass.constructor = NULL; 524 m_JsNormalClass.constructor = NULL;
521 m_JsNormalClass.name = "XFAObject"; 525 m_JsNormalClass.name = "XFAObject";
522 m_JsNormalClass.propNum = 0; 526 m_JsNormalClass.propNum = 0;
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
636 nRet = m_pResolveProcessor->XFA_ResolveNodes(rndFind); 640 nRet = m_pResolveProcessor->XFA_ResolveNodes(rndFind);
637 if (nRet < 1) { 641 if (nRet < 1) {
638 continue; 642 continue;
639 } 643 }
640 if (rndFind.m_dwFlag == XFA_RESOVENODE_RSTYPE_Attribute && 644 if (rndFind.m_dwFlag == XFA_RESOVENODE_RSTYPE_Attribute &&
641 rndFind.m_pScriptAttribute && nStart < wsExpression.GetLength()) { 645 rndFind.m_pScriptAttribute && nStart < wsExpression.GetLength()) {
642 FXJSE_HVALUE hValue = FXJSE_Value_Create(m_pIsolate); 646 FXJSE_HVALUE hValue = FXJSE_Value_Create(m_pIsolate);
643 (rndFind.m_Nodes[0]->*(rndFind.m_pScriptAttribute->lpfnCallback))( 647 (rndFind.m_Nodes[0]->*(rndFind.m_pScriptAttribute->lpfnCallback))(
644 hValue, FALSE, 648 hValue, FALSE,
645 (XFA_ATTRIBUTE)rndFind.m_pScriptAttribute->eAttribute); 649 (XFA_ATTRIBUTE)rndFind.m_pScriptAttribute->eAttribute);
646 rndFind.m_Nodes.SetAt(0, (CXFA_Object*)FXJSE_Value_ToObject(hValue)); 650 rndFind.m_Nodes.SetAt(0,
651 (CXFA_Object*)FXJSE_Value_ToObject(hValue, NULL));
647 FXJSE_Value_Release(hValue); 652 FXJSE_Value_Release(hValue);
648 } 653 }
649 int32_t iSize = m_upObjectArray.GetSize(); 654 int32_t iSize = m_upObjectArray.GetSize();
650 if (iSize) { 655 if (iSize) {
651 m_upObjectArray.RemoveAt(iSize - 1); 656 m_upObjectArray.RemoveAt(iSize - 1);
652 } 657 }
653 retNodes.Append(rndFind.m_Nodes); 658 retNodes.Append(rndFind.m_Nodes);
654 rndFind.m_Nodes.RemoveAll(); 659 rndFind.m_Nodes.RemoveAll();
655 if (bDataBind) { 660 if (bDataBind) {
656 break; 661 break;
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
753 } 758 }
754 } 759 }
755 void CXFA_ScriptContext::AddNodesOfRunScript(CXFA_Node* pNode) { 760 void CXFA_ScriptContext::AddNodesOfRunScript(CXFA_Node* pNode) {
756 if (!m_pScriptNodeArray) { 761 if (!m_pScriptNodeArray) {
757 return; 762 return;
758 } 763 }
759 if (m_pScriptNodeArray->Find(pNode) == -1) { 764 if (m_pScriptNodeArray->Find(pNode) == -1) {
760 m_pScriptNodeArray->Add(pNode); 765 m_pScriptNodeArray->Add(pNode);
761 } 766 }
762 } 767 }
OLDNEW
« no previous file with comments | « xfa/fxfa/parser/xfa_script_hostpseudomodel.cpp ('k') | xfa/fxjse/cfxjse_arguments.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698