• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_container.h"
8 
9 #include "core/fxcrt/span.h"
10 #include "fxjs/xfa/cfxjse_class.h"
11 #include "fxjs/xfa/cfxjse_engine.h"
12 #include "fxjs/xfa/cfxjse_value.h"
13 #include "v8/include/cppgc/allocation.h"
14 #include "v8/include/v8-object.h"
15 #include "xfa/fxfa/parser/cxfa_arraynodelist.h"
16 #include "xfa/fxfa/parser/cxfa_document.h"
17 #include "xfa/fxfa/parser/cxfa_field.h"
18 
19 const CJX_MethodSpec CJX_Container::MethodSpecs[] = {
20     {"getDelta", getDelta_static},
21     {"getDeltas", getDeltas_static}};
22 
CJX_Container(CXFA_Node * node)23 CJX_Container::CJX_Container(CXFA_Node* node) : CJX_Node(node) {
24   DefineMethods(MethodSpecs);
25 }
26 
27 CJX_Container::~CJX_Container() = default;
28 
DynamicTypeIs(TypeTag eType) const29 bool CJX_Container::DynamicTypeIs(TypeTag eType) const {
30   return eType == static_type__ || ParentType__::DynamicTypeIs(eType);
31 }
32 
getDelta(CFXJSE_Engine * runtime,pdfium::span<v8::Local<v8::Value>> params)33 CJS_Result CJX_Container::getDelta(CFXJSE_Engine* runtime,
34                                    pdfium::span<v8::Local<v8::Value>> params) {
35   return CJS_Result::Success();
36 }
37 
getDeltas(CFXJSE_Engine * runtime,pdfium::span<v8::Local<v8::Value>> params)38 CJS_Result CJX_Container::getDeltas(CFXJSE_Engine* runtime,
39                                     pdfium::span<v8::Local<v8::Value>> params) {
40   CXFA_Document* pDoc = GetDocument();
41   auto* pList = cppgc::MakeGarbageCollected<CXFA_ArrayNodeList>(
42       pDoc->GetHeap()->GetAllocationHandle(), pDoc);
43   pDoc->GetNodeOwner()->PersistList(pList);
44   return CJS_Result::Success(runtime->NewNormalXFAObject(pList));
45 }
46