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

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

Issue 2089443002: Convert XFA_ELEMENT to an enum class (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: More unknown checks 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
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 "fxjse/include/cfxjse_arguments.h" 10 #include "fxjse/include/cfxjse_arguments.h"
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 CFXJSE_Value* pOriginalValue, 350 CFXJSE_Value* pOriginalValue,
351 const CFX_ByteStringC& szPropName, 351 const CFX_ByteStringC& szPropName,
352 FX_BOOL bQueryIn) { 352 FX_BOOL bQueryIn) {
353 CXFA_Object* pObject = ToObject(pOriginalValue, nullptr); 353 CXFA_Object* pObject = ToObject(pOriginalValue, nullptr);
354 if (!pObject) 354 if (!pObject)
355 return FXJSE_ClassPropType_None; 355 return FXJSE_ClassPropType_None;
356 356
357 CXFA_ScriptContext* lpScriptContext = 357 CXFA_ScriptContext* lpScriptContext =
358 pObject->GetDocument()->GetScriptContext(); 358 pObject->GetDocument()->GetScriptContext();
359 pObject = lpScriptContext->GetVariablesThis(pObject); 359 pObject = lpScriptContext->GetVariablesThis(pObject);
360 XFA_ELEMENT objElement = pObject->GetClassID(); 360 XFA_Element objElement = pObject->GetClassID();
361 CFX_WideString wsPropName = CFX_WideString::FromUTF8(szPropName); 361 CFX_WideString wsPropName = CFX_WideString::FromUTF8(szPropName);
362 if (XFA_GetMethodByName(objElement, wsPropName.AsStringC())) { 362 if (XFA_GetMethodByName(objElement, wsPropName.AsStringC())) {
363 return FXJSE_ClassPropType_Method; 363 return FXJSE_ClassPropType_Method;
364 } 364 }
365 if (bQueryIn && 365 if (bQueryIn &&
366 !XFA_GetScriptAttributeByName(objElement, wsPropName.AsStringC())) { 366 !XFA_GetScriptAttributeByName(objElement, wsPropName.AsStringC())) {
367 return FXJSE_ClassPropType_None; 367 return FXJSE_ClassPropType_None;
368 } 368 }
369 return FXJSE_ClassPropType_Property; 369 return FXJSE_ClassPropType_Property;
370 } 370 }
371 int32_t CXFA_ScriptContext::GlobalPropTypeGetter( 371 int32_t CXFA_ScriptContext::GlobalPropTypeGetter(
372 CFXJSE_Value* pOriginalValue, 372 CFXJSE_Value* pOriginalValue,
373 const CFX_ByteStringC& szPropName, 373 const CFX_ByteStringC& szPropName,
374 FX_BOOL bQueryIn) { 374 FX_BOOL bQueryIn) {
375 CXFA_Object* pObject = ToObject(pOriginalValue, nullptr); 375 CXFA_Object* pObject = ToObject(pOriginalValue, nullptr);
376 if (!pObject) 376 if (!pObject)
377 return FXJSE_ClassPropType_None; 377 return FXJSE_ClassPropType_None;
378 378
379 CXFA_ScriptContext* lpScriptContext = 379 CXFA_ScriptContext* lpScriptContext =
380 pObject->GetDocument()->GetScriptContext(); 380 pObject->GetDocument()->GetScriptContext();
381 pObject = lpScriptContext->GetVariablesThis(pObject); 381 pObject = lpScriptContext->GetVariablesThis(pObject);
382 XFA_ELEMENT objElement = pObject->GetClassID(); 382 XFA_Element objElement = pObject->GetClassID();
383 CFX_WideString wsPropName = CFX_WideString::FromUTF8(szPropName); 383 CFX_WideString wsPropName = CFX_WideString::FromUTF8(szPropName);
384 if (XFA_GetMethodByName(objElement, wsPropName.AsStringC())) { 384 if (XFA_GetMethodByName(objElement, wsPropName.AsStringC())) {
385 return FXJSE_ClassPropType_Method; 385 return FXJSE_ClassPropType_Method;
386 } 386 }
387 return FXJSE_ClassPropType_Property; 387 return FXJSE_ClassPropType_Property;
388 } 388 }
389 void CXFA_ScriptContext::NormalMethodCall(CFXJSE_Value* pThis, 389 void CXFA_ScriptContext::NormalMethodCall(CFXJSE_Value* pThis,
390 const CFX_ByteStringC& szFuncName, 390 const CFX_ByteStringC& szFuncName,
391 CFXJSE_Arguments& args) { 391 CFXJSE_Arguments& args) {
392 CXFA_Object* pObject = ToObject(pThis, nullptr); 392 CXFA_Object* pObject = ToObject(pThis, nullptr);
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
436 return pObject; 436 return pObject;
437 437
438 CXFA_ThisProxy* pProxy = static_cast<CXFA_ThisProxy*>(pObject); 438 CXFA_ThisProxy* pProxy = static_cast<CXFA_ThisProxy*>(pObject);
439 return bScriptNode ? pProxy->GetScriptNode() : pProxy->GetThisNode(); 439 return bScriptNode ? pProxy->GetScriptNode() : pProxy->GetThisNode();
440 } 440 }
441 441
442 FX_BOOL CXFA_ScriptContext::RunVariablesScript(CXFA_Node* pScriptNode) { 442 FX_BOOL CXFA_ScriptContext::RunVariablesScript(CXFA_Node* pScriptNode) {
443 if (!pScriptNode) 443 if (!pScriptNode)
444 return FALSE; 444 return FALSE;
445 445
446 if (pScriptNode->GetClassID() != XFA_ELEMENT_Script) 446 if (pScriptNode->GetClassID() != XFA_Element::Script)
447 return TRUE; 447 return TRUE;
448 448
449 CXFA_Node* pParent = pScriptNode->GetNodeItem(XFA_NODEITEM_Parent); 449 CXFA_Node* pParent = pScriptNode->GetNodeItem(XFA_NODEITEM_Parent);
450 if (!pParent || pParent->GetClassID() != XFA_ELEMENT_Variables) 450 if (!pParent || pParent->GetClassID() != XFA_Element::Variables)
451 return FALSE; 451 return FALSE;
452 452
453 if (m_mapVariableToContext.GetValueAt(pScriptNode)) 453 if (m_mapVariableToContext.GetValueAt(pScriptNode))
454 return TRUE; 454 return TRUE;
455 455
456 CXFA_Node* pTextNode = pScriptNode->GetNodeItem(XFA_NODEITEM_FirstChild); 456 CXFA_Node* pTextNode = pScriptNode->GetNodeItem(XFA_NODEITEM_FirstChild);
457 if (!pTextNode) 457 if (!pTextNode)
458 return FALSE; 458 return FALSE;
459 459
460 CFX_WideStringC wsScript; 460 CFX_WideStringC wsScript;
(...skipping 12 matching lines...) Expand all
473 pVariablesContext->ExecuteScript(btScript.c_str(), hRetValue.get()); 473 pVariablesContext->ExecuteScript(btScript.c_str(), hRetValue.get());
474 m_pThisObject = pOriginalObject; 474 m_pThisObject = pOriginalObject;
475 return bRet; 475 return bRet;
476 } 476 }
477 477
478 FX_BOOL CXFA_ScriptContext::QueryVariableValue( 478 FX_BOOL CXFA_ScriptContext::QueryVariableValue(
479 CXFA_Node* pScriptNode, 479 CXFA_Node* pScriptNode,
480 const CFX_ByteStringC& szPropName, 480 const CFX_ByteStringC& szPropName,
481 CFXJSE_Value* pValue, 481 CFXJSE_Value* pValue,
482 FX_BOOL bGetter) { 482 FX_BOOL bGetter) {
483 if (!pScriptNode || pScriptNode->GetClassID() != XFA_ELEMENT_Script) 483 if (!pScriptNode || pScriptNode->GetClassID() != XFA_Element::Script)
484 return FALSE; 484 return FALSE;
485 485
486 CXFA_Node* variablesNode = pScriptNode->GetNodeItem(XFA_NODEITEM_Parent); 486 CXFA_Node* variablesNode = pScriptNode->GetNodeItem(XFA_NODEITEM_Parent);
487 if (!variablesNode || variablesNode->GetClassID() != XFA_ELEMENT_Variables) 487 if (!variablesNode || variablesNode->GetClassID() != XFA_Element::Variables)
488 return FALSE; 488 return FALSE;
489 489
490 void* lpVariables = m_mapVariableToContext.GetValueAt(pScriptNode); 490 void* lpVariables = m_mapVariableToContext.GetValueAt(pScriptNode);
491 if (!lpVariables) 491 if (!lpVariables)
492 return FALSE; 492 return FALSE;
493 493
494 FX_BOOL bRes = FALSE; 494 FX_BOOL bRes = FALSE;
495 CFXJSE_Context* pVariableContext = static_cast<CFXJSE_Context*>(lpVariables); 495 CFXJSE_Context* pVariableContext = static_cast<CFXJSE_Context*>(lpVariables);
496 std::unique_ptr<CFXJSE_Value> pObject = pVariableContext->GetGlobalObject(); 496 std::unique_ptr<CFXJSE_Value> pObject = pVariableContext->GetGlobalObject();
497 std::unique_ptr<CFXJSE_Value> hVariableValue(new CFXJSE_Value(m_pIsolate)); 497 std::unique_ptr<CFXJSE_Value> hVariableValue(new CFXJSE_Value(m_pIsolate));
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
736 return; 736 return;
737 if (nodes.GetSize() > 0) 737 if (nodes.GetSize() > 0)
738 m_pScriptNodeArray->Copy(nodes); 738 m_pScriptNodeArray->Copy(nodes);
739 } 739 }
740 void CXFA_ScriptContext::AddNodesOfRunScript(CXFA_Node* pNode) { 740 void CXFA_ScriptContext::AddNodesOfRunScript(CXFA_Node* pNode) {
741 if (!m_pScriptNodeArray) 741 if (!m_pScriptNodeArray)
742 return; 742 return;
743 if (m_pScriptNodeArray->Find(pNode) == -1) 743 if (m_pScriptNodeArray->Find(pNode) == -1)
744 m_pScriptNodeArray->Add(pNode); 744 m_pScriptNodeArray->Add(pNode);
745 } 745 }
OLDNEW
« no previous file with comments | « xfa/fxfa/parser/xfa_script_hostpseudomodel.cpp ('k') | xfa/fxfa/parser/xfa_script_layoutpseudomodel.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698