1 // Copyright 2017 The PDFium Authors 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 6 7 #include "xfa/fxfa/parser/cxfa_treelist.h" 8 9 #include "core/fxcrt/fx_extension.h" 10 #include "fxjs/xfa/cjx_treelist.h" 11 #include "xfa/fxfa/parser/cxfa_document.h" 12 #include "xfa/fxfa/parser/cxfa_node.h" 13 CXFA_TreeList(CXFA_Document * doc)14CXFA_TreeList::CXFA_TreeList(CXFA_Document* doc) 15 : CXFA_List(doc, 16 XFA_ObjectType::TreeList, 17 XFA_Element::TreeList, 18 cppgc::MakeGarbageCollected<CJX_TreeList>( 19 doc->GetHeap()->GetAllocationHandle(), 20 this)) {} 21 22 CXFA_TreeList::~CXFA_TreeList() = default; 23 NamedItem(WideStringView wsName)24CXFA_Node* CXFA_TreeList::NamedItem(WideStringView wsName) { 25 uint32_t dwHashCode = FX_HashCode_GetW(wsName); 26 size_t count = GetLength(); 27 for (size_t i = 0; i < count; i++) { 28 CXFA_Node* ret = Item(i); 29 if (dwHashCode == ret->GetNameHash()) 30 return ret; 31 } 32 return nullptr; 33 } 34