Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
cjx_treelist.cpp
Go to the documentation of this file.
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 "fxjs/xfa/cjx_treelist.h"
8
9#include <vector>
10
11#include "fxjs/js_resources.h"
12#include "fxjs/xfa/cfxjse_engine.h"
13#include "fxjs/xfa/cfxjse_value.h"
14#include "third_party/base/containers/span.h"
15#include "v8/include/v8-object.h"
16#include "xfa/fxfa/parser/cxfa_document.h"
17#include "xfa/fxfa/parser/cxfa_node.h"
18#include "xfa/fxfa/parser/cxfa_treelist.h"
19
20const CJX_MethodSpec CJX_TreeList::MethodSpecs[] = {
21 {"namedItem", namedItem_static}};
22
23CJX_TreeList::CJX_TreeList(CXFA_TreeList* list) : CJX_List(list) {
24 DefineMethods(MethodSpecs);
25}
26
27CJX_TreeList::~CJX_TreeList() = default;
28
29bool CJX_TreeList::DynamicTypeIs(TypeTag eType) const {
30 return eType == static_type__ || ParentType__::DynamicTypeIs(eType);
31}
32
33CXFA_TreeList* CJX_TreeList::GetXFATreeList() {
34 return ToTreeList(GetXFAObject());
35}
36
37CJS_Result CJX_TreeList::namedItem(CFXJSE_Engine* runtime,
38 pdfium::span<v8::Local<v8::Value>> params) {
39 if (params.size() != 1)
41
42 CXFA_Node* pNode = GetXFATreeList()->NamedItem(
43 runtime->ToWideString(params[0]).AsStringView());
44 if (!pNode)
46
47 return CJS_Result::Success(runtime->GetOrCreateJSBindingFromMap(pNode));
48}
friend class EventParamScope
static CJS_Result Success()
Definition cjs_result.h:27
static CJS_Result Failure(JSMessage id)
Definition cjs_result.h:34
bool DynamicTypeIs(TypeTag eType) const override
Definition cjx_list.cpp:34
void DefineMethods(pdfium::span< const CJX_MethodSpec > methods)
CXFA_Object * GetXFAObject() const
Definition cjx_object.h:113
~CJX_TreeList() override
bool DynamicTypeIs(TypeTag eType) const override
JSMessage