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

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

Issue 1919563002: Pass CFX_*StringCs to FX_HashCode_GETA and _GETW hash functions. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: fix issue from c4 Created 4 years, 8 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_document_datamerger_imp.cpp ('k') | xfa/fxfa/parser/xfa_object_imp.cpp » ('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 "core/fxcrt/include/fx_ext.h" 7 #include "core/fxcrt/include/fx_ext.h"
8 #include "xfa/fxfa/app/xfa_ffnotify.h" 8 #include "xfa/fxfa/app/xfa_ffnotify.h"
9 #include "xfa/fxfa/fm2js/xfa_fm2jsapi.h" 9 #include "xfa/fxfa/fm2js/xfa_fm2jsapi.h"
10 #include "xfa/fxfa/parser/xfa_basic_imp.h" 10 #include "xfa/fxfa/parser/xfa_basic_imp.h"
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 if (m_pRootNode) { 87 if (m_pRootNode) {
88 AddPurgeNode(m_pRootNode); 88 AddPurgeNode(m_pRootNode);
89 } 89 }
90 m_pRootNode = pNewRoot; 90 m_pRootNode = pNewRoot;
91 RemovePurgeNode(pNewRoot); 91 RemovePurgeNode(pNewRoot);
92 } 92 }
93 CXFA_FFNotify* CXFA_Document::GetNotify() const { 93 CXFA_FFNotify* CXFA_Document::GetNotify() const {
94 return m_pParser->GetNotify(); 94 return m_pParser->GetNotify();
95 } 95 }
96 CXFA_Object* CXFA_Document::GetXFAObject(const CFX_WideStringC& wsNodeName) { 96 CXFA_Object* CXFA_Document::GetXFAObject(const CFX_WideStringC& wsNodeName) {
97 return GetXFAObject( 97 return GetXFAObject(FX_HashCode_GetW(wsNodeName, false));
98 FX_HashCode_String_GetW(wsNodeName.c_str(), wsNodeName.GetLength()));
99 } 98 }
100 CXFA_Object* CXFA_Document::GetXFAObject(uint32_t dwNodeNameHash) { 99 CXFA_Object* CXFA_Document::GetXFAObject(uint32_t dwNodeNameHash) {
101 switch (dwNodeNameHash) { 100 switch (dwNodeNameHash) {
102 case XFA_HASHCODE_Data: { 101 case XFA_HASHCODE_Data: {
103 CXFA_Node* pDatasetsNode = ToNode(GetXFAObject(XFA_HASHCODE_Datasets)); 102 CXFA_Node* pDatasetsNode = ToNode(GetXFAObject(XFA_HASHCODE_Datasets));
104 if (!pDatasetsNode) { 103 if (!pDatasetsNode) {
105 return NULL; 104 return NULL;
106 } 105 }
107 for (CXFA_Node* pDatasetsChild = 106 for (CXFA_Node* pDatasetsChild =
108 pDatasetsNode->GetFirstChildByClass(XFA_ELEMENT_DataGroup); 107 pDatasetsNode->GetFirstChildByClass(XFA_ELEMENT_DataGroup);
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 if (!pTemplateRoot) { 359 if (!pTemplateRoot) {
361 return; 360 return;
362 } 361 }
363 CFX_MapPtrTemplate<uint32_t, CXFA_Node*> mIDMap; 362 CFX_MapPtrTemplate<uint32_t, CXFA_Node*> mIDMap;
364 CXFA_NodeSet sUseNodes; 363 CXFA_NodeSet sUseNodes;
365 CXFA_NodeIterator sIterator(pTemplateRoot); 364 CXFA_NodeIterator sIterator(pTemplateRoot);
366 for (CXFA_Node* pNode = sIterator.GetCurrent(); pNode; 365 for (CXFA_Node* pNode = sIterator.GetCurrent(); pNode;
367 pNode = sIterator.MoveToNext()) { 366 pNode = sIterator.MoveToNext()) {
368 CFX_WideStringC wsIDVal; 367 CFX_WideStringC wsIDVal;
369 if (pNode->TryCData(XFA_ATTRIBUTE_Id, wsIDVal) && !wsIDVal.IsEmpty()) { 368 if (pNode->TryCData(XFA_ATTRIBUTE_Id, wsIDVal) && !wsIDVal.IsEmpty()) {
370 mIDMap[FX_HashCode_String_GetW(wsIDVal.c_str(), wsIDVal.GetLength())] = 369 mIDMap[FX_HashCode_GetW(wsIDVal, false)] = pNode;
371 pNode;
372 } 370 }
373 CFX_WideStringC wsUseVal; 371 CFX_WideStringC wsUseVal;
374 if (pNode->TryCData(XFA_ATTRIBUTE_Use, wsUseVal) && !wsUseVal.IsEmpty()) { 372 if (pNode->TryCData(XFA_ATTRIBUTE_Use, wsUseVal) && !wsUseVal.IsEmpty()) {
375 sUseNodes.Add(pNode); 373 sUseNodes.Add(pNode);
376 } else if (pNode->TryCData(XFA_ATTRIBUTE_Usehref, wsUseVal) && 374 } else if (pNode->TryCData(XFA_ATTRIBUTE_Usehref, wsUseVal) &&
377 !wsUseVal.IsEmpty()) { 375 !wsUseVal.IsEmpty()) {
378 sUseNodes.Add(pNode); 376 sUseNodes.Add(pNode);
379 } 377 }
380 } 378 }
381 FX_POSITION pos = sUseNodes.GetStartPosition(); 379 FX_POSITION pos = sUseNodes.GetStartPosition();
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
419 uint32_t dwFlag = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Attributes | 417 uint32_t dwFlag = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Attributes |
420 XFA_RESOLVENODE_Properties | XFA_RESOLVENODE_Parent | 418 XFA_RESOLVENODE_Properties | XFA_RESOLVENODE_Parent |
421 XFA_RESOLVENODE_Siblings; 419 XFA_RESOLVENODE_Siblings;
422 XFA_RESOLVENODE_RS resoveNodeRS; 420 XFA_RESOLVENODE_RS resoveNodeRS;
423 int32_t iRet = m_pScriptContext->ResolveObjects(pUseHrefNode, wsSOM, 421 int32_t iRet = m_pScriptContext->ResolveObjects(pUseHrefNode, wsSOM,
424 resoveNodeRS, dwFlag); 422 resoveNodeRS, dwFlag);
425 if (iRet > 0 && resoveNodeRS.nodes[0]->IsNode()) { 423 if (iRet > 0 && resoveNodeRS.nodes[0]->IsNode()) {
426 pProtoNode = resoveNodeRS.nodes[0]->AsNode(); 424 pProtoNode = resoveNodeRS.nodes[0]->AsNode();
427 } 425 }
428 } else if (!wsID.IsEmpty()) { 426 } else if (!wsID.IsEmpty()) {
429 if (!mIDMap.Lookup( 427 if (!mIDMap.Lookup(FX_HashCode_GetW(wsID, false), pProtoNode)) {
430 FX_HashCode_String_GetW(wsID.c_str(), wsID.GetLength()),
431 pProtoNode)) {
432 continue; 428 continue;
433 } 429 }
434 } 430 }
435 if (!pProtoNode) { 431 if (!pProtoNode) {
436 continue; 432 continue;
437 } 433 }
438 XFA_ProtoMerge_MergeNode(this, pUseHrefNode, pProtoNode); 434 XFA_ProtoMerge_MergeNode(this, pUseHrefNode, pProtoNode);
439 } 435 }
440 } 436 }
OLDNEW
« no previous file with comments | « xfa/fxfa/parser/xfa_document_datamerger_imp.cpp ('k') | xfa/fxfa/parser/xfa_object_imp.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698