| 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_resolveprocessor.h" | 7 #include "xfa/fxfa/parser/xfa_script_resolveprocessor.h" | 
| 8 | 8 | 
| 9 #include "core/fxcrt/include/fx_ext.h" | 9 #include "core/fxcrt/include/fx_ext.h" | 
| 10 #include "xfa/fxfa/fm2js/xfa_fm2jsapi.h" | 10 #include "xfa/fxfa/fm2js/xfa_fm2jsapi.h" | 
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 115   CFX_WideString wsName = rnd.m_wsName; | 115   CFX_WideString wsName = rnd.m_wsName; | 
| 116   CFX_WideString wsCondition = rnd.m_wsCondition; | 116   CFX_WideString wsCondition = rnd.m_wsCondition; | 
| 117   int32_t iNameLen = wsName.GetLength(); | 117   int32_t iNameLen = wsName.GetLength(); | 
| 118   if (iNameLen == 1) { | 118   if (iNameLen == 1) { | 
| 119     nodes.Add(rnd.m_CurNode); | 119     nodes.Add(rnd.m_CurNode); | 
| 120     return 1; | 120     return 1; | 
| 121   } | 121   } | 
| 122   if (rnd.m_nLevel > 0) { | 122   if (rnd.m_nLevel > 0) { | 
| 123     return -1; | 123     return -1; | 
| 124   } | 124   } | 
| 125   FX_DWORD dwNameHash = | 125   uint32_t dwNameHash = | 
| 126       FX_HashCode_String_GetW((const FX_WCHAR*)wsName + 1, iNameLen - 1); | 126       FX_HashCode_String_GetW((const FX_WCHAR*)wsName + 1, iNameLen - 1); | 
| 127   if (dwNameHash == XFA_HASHCODE_Xfa) { | 127   if (dwNameHash == XFA_HASHCODE_Xfa) { | 
| 128     nodes.Add(rnd.m_pSC->GetDocument()->GetRoot()); | 128     nodes.Add(rnd.m_pSC->GetDocument()->GetRoot()); | 
| 129   } else { | 129   } else { | 
| 130     CXFA_Object* pObjNode = rnd.m_pSC->GetDocument()->GetXFAObject(dwNameHash); | 130     CXFA_Object* pObjNode = rnd.m_pSC->GetDocument()->GetXFAObject(dwNameHash); | 
| 131     if (pObjNode) { | 131     if (pObjNode) { | 
| 132       rnd.m_Nodes.Add(pObjNode); | 132       rnd.m_Nodes.Add(pObjNode); | 
| 133     } | 133     } | 
| 134   } | 134   } | 
| 135   if (rnd.m_Nodes.GetSize() > 0) { | 135   if (rnd.m_Nodes.GetSize() > 0) { | 
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 211     CXFA_ResolveNodesData& rnd) { | 211     CXFA_ResolveNodesData& rnd) { | 
| 212   if (rnd.m_nLevel > 32) { | 212   if (rnd.m_nLevel > 32) { | 
| 213     return 0; | 213     return 0; | 
| 214   } | 214   } | 
| 215   if (!rnd.m_CurNode->IsNode()) { | 215   if (!rnd.m_CurNode->IsNode()) { | 
| 216     return 0; | 216     return 0; | 
| 217   } | 217   } | 
| 218   CXFA_Node* curNode = ToNode(rnd.m_CurNode); | 218   CXFA_Node* curNode = ToNode(rnd.m_CurNode); | 
| 219   CXFA_ObjArray& nodes = rnd.m_Nodes; | 219   CXFA_ObjArray& nodes = rnd.m_Nodes; | 
| 220   int32_t nNum = nodes.GetSize(); | 220   int32_t nNum = nodes.GetSize(); | 
| 221   FX_DWORD dwStyles = rnd.m_dwStyles; | 221   uint32_t dwStyles = rnd.m_dwStyles; | 
| 222   CFX_WideString& wsName = rnd.m_wsName; | 222   CFX_WideString& wsName = rnd.m_wsName; | 
| 223   uint32_t uNameHash = rnd.m_uHashName; | 223   uint32_t uNameHash = rnd.m_uHashName; | 
| 224   CFX_WideString& wsCondition = rnd.m_wsCondition; | 224   CFX_WideString& wsCondition = rnd.m_wsCondition; | 
| 225   CXFA_ResolveNodesData rndFind; | 225   CXFA_ResolveNodesData rndFind; | 
| 226   rndFind.m_wsName = rnd.m_wsName; | 226   rndFind.m_wsName = rnd.m_wsName; | 
| 227   rndFind.m_wsCondition = rnd.m_wsCondition; | 227   rndFind.m_wsCondition = rnd.m_wsCondition; | 
| 228   rndFind.m_pSC = rnd.m_pSC; | 228   rndFind.m_pSC = rnd.m_pSC; | 
| 229   rndFind.m_nLevel = rnd.m_nLevel + 1; | 229   rndFind.m_nLevel = rnd.m_nLevel + 1; | 
| 230   rndFind.m_uHashName = uNameHash; | 230   rndFind.m_uHashName = uNameHash; | 
| 231   CXFA_NodeArray children; | 231   CXFA_NodeArray children; | 
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 384       nodes.Add(curNode->AsNode()); | 384       nodes.Add(curNode->AsNode()); | 
| 385       XFA_ResolveNode_FilterCondition(rnd, wsCondition); | 385       XFA_ResolveNode_FilterCondition(rnd, wsCondition); | 
| 386       if (nodes.GetSize() > 0) { | 386       if (nodes.GetSize() > 0) { | 
| 387         return 1; | 387         return 1; | 
| 388       } | 388       } | 
| 389     } | 389     } | 
| 390     return 0; | 390     return 0; | 
| 391   } | 391   } | 
| 392   if (dwStyles & XFA_RESOLVENODE_Siblings) { | 392   if (dwStyles & XFA_RESOLVENODE_Siblings) { | 
| 393     CXFA_Node* child = parentNode->GetNodeItem(XFA_NODEITEM_FirstChild); | 393     CXFA_Node* child = parentNode->GetNodeItem(XFA_NODEITEM_FirstChild); | 
| 394     FX_DWORD dwSubStyles = | 394     uint32_t dwSubStyles = | 
| 395         XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Properties; | 395         XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Properties; | 
| 396     if (dwStyles & XFA_RESOLVENODE_TagName) { | 396     if (dwStyles & XFA_RESOLVENODE_TagName) { | 
| 397       dwSubStyles |= XFA_RESOLVENODE_TagName; | 397       dwSubStyles |= XFA_RESOLVENODE_TagName; | 
| 398     } | 398     } | 
| 399     if (dwStyles & XFA_RESOLVENODE_ALL) { | 399     if (dwStyles & XFA_RESOLVENODE_ALL) { | 
| 400       dwSubStyles |= XFA_RESOLVENODE_ALL; | 400       dwSubStyles |= XFA_RESOLVENODE_ALL; | 
| 401     } | 401     } | 
| 402     rndFind.m_dwStyles = dwSubStyles; | 402     rndFind.m_dwStyles = dwSubStyles; | 
| 403     while (child) { | 403     while (child) { | 
| 404       if (child == curNode) { | 404       if (child == curNode) { | 
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 436         } | 436         } | 
| 437       } else { | 437       } else { | 
| 438         if (m_pNodeHelper->XFA_NodeIsTransparent(child)) { | 438         if (m_pNodeHelper->XFA_NodeIsTransparent(child)) { | 
| 439           bInnerSearch = TRUE; | 439           bInnerSearch = TRUE; | 
| 440         } | 440         } | 
| 441       } | 441       } | 
| 442       if (bInnerSearch) { | 442       if (bInnerSearch) { | 
| 443         rndFind.m_CurNode = child; | 443         rndFind.m_CurNode = child; | 
| 444         CFX_WideString wsOriginCondition = rndFind.m_wsCondition; | 444         CFX_WideString wsOriginCondition = rndFind.m_wsCondition; | 
| 445         rndFind.m_wsCondition.Empty(); | 445         rndFind.m_wsCondition.Empty(); | 
| 446         FX_DWORD dwOriginStyle = rndFind.m_dwStyles; | 446         uint32_t dwOriginStyle = rndFind.m_dwStyles; | 
| 447         rndFind.m_dwStyles = dwOriginStyle | XFA_RESOLVENODE_ALL; | 447         rndFind.m_dwStyles = dwOriginStyle | XFA_RESOLVENODE_ALL; | 
| 448         XFA_ResolveNodes_Normal(rndFind); | 448         XFA_ResolveNodes_Normal(rndFind); | 
| 449         rndFind.m_dwStyles = dwOriginStyle; | 449         rndFind.m_dwStyles = dwOriginStyle; | 
| 450         rndFind.m_wsCondition = wsOriginCondition; | 450         rndFind.m_wsCondition = wsOriginCondition; | 
| 451         if (rndFind.m_Nodes.GetSize() > 0) { | 451         if (rndFind.m_Nodes.GetSize() > 0) { | 
| 452           nodes.Append(rndFind.m_Nodes); | 452           nodes.Append(rndFind.m_Nodes); | 
| 453           rndFind.m_Nodes.RemoveAll(); | 453           rndFind.m_Nodes.RemoveAll(); | 
| 454         } | 454         } | 
| 455       } | 455       } | 
| 456       child = child->GetNodeItem(XFA_NODEITEM_NextSibling); | 456       child = child->GetNodeItem(XFA_NODEITEM_NextSibling); | 
| (...skipping 12 matching lines...) Expand all  Loading... | 
| 469         } | 469         } | 
| 470       } | 470       } | 
| 471       XFA_ResolveNode_FilterCondition(rnd, wsCondition); | 471       XFA_ResolveNode_FilterCondition(rnd, wsCondition); | 
| 472       if (nodes.GetSize() > 0) { | 472       if (nodes.GetSize() > 0) { | 
| 473         return 1; | 473         return 1; | 
| 474       } | 474       } | 
| 475       return 0; | 475       return 0; | 
| 476     } | 476     } | 
| 477   } | 477   } | 
| 478   if (dwStyles & XFA_RESOLVENODE_Parent) { | 478   if (dwStyles & XFA_RESOLVENODE_Parent) { | 
| 479     FX_DWORD dwSubStyles = XFA_RESOLVENODE_Siblings | XFA_RESOLVENODE_Parent | | 479     uint32_t dwSubStyles = XFA_RESOLVENODE_Siblings | XFA_RESOLVENODE_Parent | | 
| 480                            XFA_RESOLVENODE_Properties; | 480                            XFA_RESOLVENODE_Properties; | 
| 481     if (dwStyles & XFA_RESOLVENODE_TagName) { | 481     if (dwStyles & XFA_RESOLVENODE_TagName) { | 
| 482       dwSubStyles |= XFA_RESOLVENODE_TagName; | 482       dwSubStyles |= XFA_RESOLVENODE_TagName; | 
| 483     } | 483     } | 
| 484     if (dwStyles & XFA_RESOLVENODE_ALL) { | 484     if (dwStyles & XFA_RESOLVENODE_ALL) { | 
| 485       dwSubStyles |= XFA_RESOLVENODE_ALL; | 485       dwSubStyles |= XFA_RESOLVENODE_ALL; | 
| 486     } | 486     } | 
| 487     rndFind.m_dwStyles = dwSubStyles; | 487     rndFind.m_dwStyles = dwSubStyles; | 
| 488     rndFind.m_CurNode = parentNode; | 488     rndFind.m_CurNode = parentNode; | 
| 489     CXFA_NodeArray& array = rnd.m_pSC->GetUpObjectArray(); | 489     CXFA_NodeArray& array = rnd.m_pSC->GetUpObjectArray(); | 
| (...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 775     case '.': | 775     case '.': | 
| 776       if (iLen > 1 && (wsCondition[1] == '[' || wsCondition[1] == '(')) { | 776       if (iLen > 1 && (wsCondition[1] == '[' || wsCondition[1] == '(')) { | 
| 777         XFA_ResolveNode_DoPredicateFilter(iCurrIndex, wsCondition, iFoundCount, | 777         XFA_ResolveNode_DoPredicateFilter(iCurrIndex, wsCondition, iFoundCount, | 
| 778                                           rnd); | 778                                           rnd); | 
| 779       } | 779       } | 
| 780     default: | 780     default: | 
| 781       return; | 781       return; | 
| 782   } | 782   } | 
| 783 } | 783 } | 
| 784 void CXFA_ResolveProcessor::XFA_ResolveNodes_SetStylesForChild( | 784 void CXFA_ResolveProcessor::XFA_ResolveNodes_SetStylesForChild( | 
| 785     FX_DWORD dwParentStyles, | 785     uint32_t dwParentStyles, | 
| 786     CXFA_ResolveNodesData& rnd) { | 786     CXFA_ResolveNodesData& rnd) { | 
| 787   FX_DWORD dwSubStyles = XFA_RESOLVENODE_Children; | 787   uint32_t dwSubStyles = XFA_RESOLVENODE_Children; | 
| 788   if (dwParentStyles & XFA_RESOLVENODE_TagName) { | 788   if (dwParentStyles & XFA_RESOLVENODE_TagName) { | 
| 789     dwSubStyles |= XFA_RESOLVENODE_TagName; | 789     dwSubStyles |= XFA_RESOLVENODE_TagName; | 
| 790   } | 790   } | 
| 791   dwSubStyles &= ~XFA_RESOLVENODE_Parent; | 791   dwSubStyles &= ~XFA_RESOLVENODE_Parent; | 
| 792   dwSubStyles &= ~XFA_RESOLVENODE_Siblings; | 792   dwSubStyles &= ~XFA_RESOLVENODE_Siblings; | 
| 793   dwSubStyles &= ~XFA_RESOLVENODE_Properties; | 793   dwSubStyles &= ~XFA_RESOLVENODE_Properties; | 
| 794   dwSubStyles |= XFA_RESOLVENODE_ALL; | 794   dwSubStyles |= XFA_RESOLVENODE_ALL; | 
| 795   rnd.m_dwStyles = dwSubStyles; | 795   rnd.m_dwStyles = dwSubStyles; | 
| 796 } | 796 } | 
| 797 int32_t CXFA_ResolveProcessor::XFA_ResolveNode_SetResultCreateNode( | 797 int32_t CXFA_ResolveProcessor::XFA_ResolveNode_SetResultCreateNode( | 
| (...skipping 19 matching lines...) Expand all  Loading... | 
| 817   if (m_pNodeHelper->XFA_CreateNode_ForCondition(wsNextCondition)) { | 817   if (m_pNodeHelper->XFA_CreateNode_ForCondition(wsNextCondition)) { | 
| 818     if (m_pNodeHelper->m_eLastCreateType == XFA_ELEMENT_DataGroup) { | 818     if (m_pNodeHelper->m_eLastCreateType == XFA_ELEMENT_DataGroup) { | 
| 819       iIndex = 0; | 819       iIndex = 0; | 
| 820     } else { | 820     } else { | 
| 821       iIndex = iCount - 1; | 821       iIndex = iCount - 1; | 
| 822     } | 822     } | 
| 823   } else { | 823   } else { | 
| 824     iIndex = iCount - 1; | 824     iIndex = iCount - 1; | 
| 825   } | 825   } | 
| 826 } | 826 } | 
| OLD | NEW | 
|---|