Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
cjx_list.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_list.h"
8
9
#
include
"core/fxcrt/numerics/safe_conversions.h"
10
#
include
"core/fxcrt/span.h"
11
#
include
"fxjs/fxv8.h"
12
#
include
"fxjs/js_resources.h"
13
#
include
"fxjs/xfa/cfxjse_class.h"
14
#
include
"fxjs/xfa/cfxjse_engine.h"
15
#
include
"v8/include/v8-object.h"
16
#
include
"v8/include/v8-primitive.h"
17
#
include
"xfa/fxfa/parser/cxfa_document.h"
18
#
include
"xfa/fxfa/parser/cxfa_list.h"
19
#
include
"xfa/fxfa/parser/cxfa_node.h"
20
21
const
CJX_MethodSpec
CJX_List
::MethodSpecs[] = {{
"append"
, append_static},
22
{
"insert"
, insert_static},
23
{
"item"
, item_static},
24
{
"remove"
, remove_static}};
25
26
CJX_List
::
CJX_List
(
CXFA_List
* list) :
CJX_Object
(list) {
27
DefineMethods(MethodSpecs);
28
}
29
30
CJX_List
::~
CJX_List
() =
default
;
31
32
bool
CJX_List
::
DynamicTypeIs
(
TypeTag
eType)
const
{
33
return
eType == static_type__ || ParentType__
::
DynamicTypeIs
(eType);
34
}
35
36
CXFA_List
*
CJX_List
::GetXFAList() {
37
return
ToList(
GetXFAObject
());
38
}
39
40
CJS_Result
CJX_List
::append(
CFXJSE_Engine
* runtime,
41
pdfium::span<v8::Local<v8::Value>> params) {
42
if
(params.size() != 1)
43
return
CJS_Result
::
Failure
(
JSMessage
::
kParamError
)
;
44
45
auto
* pNode = ToNode(runtime->ToXFAObject(params[0]));
46
if
(!pNode)
47
return
CJS_Result
::
Failure
(
JSMessage
::
kValueError
)
;
48
49
if
(!GetXFAList()
->
Append
(
pNode
)
)
50
return
CJS_Result
::
Failure
(
JSMessage
::
kWouldBeCyclic
)
;
51
52
return
CJS_Result
::
Success
(
)
;
53
}
54
55
CJS_Result
CJX_List
::insert(
CFXJSE_Engine
* runtime,
56
pdfium::span<v8::Local<v8::Value>> params) {
57
if
(params.size() != 2)
58
return
CJS_Result
::
Failure
(
JSMessage
::
kParamError
)
;
59
60
auto
* pNewNode = ToNode(runtime->ToXFAObject(params[0]));
61
if
(!pNewNode)
62
return
CJS_Result
::
Failure
(
JSMessage
::
kValueError
)
;
63
64
auto
* pBeforeNode = ToNode(runtime->ToXFAObject(params[1]));
65
if
(!GetXFAList()
->
Insert
(
pNewNode
,
pBeforeNode
)
)
66
return
CJS_Result
::
Failure
(
JSMessage
::
kValueError
)
;
67
68
return
CJS_Result
::
Success
(
)
;
69
}
70
71
CJS_Result
CJX_List
::remove(
CFXJSE_Engine
* runtime,
72
pdfium::span<v8::Local<v8::Value>> params) {
73
if
(params.size() != 1)
74
return
CJS_Result
::
Failure
(
JSMessage
::
kParamError
)
;
75
76
auto
* pNode = ToNode(runtime->ToXFAObject(params[0]));
77
if
(!pNode)
78
return
CJS_Result
::
Failure
(
JSMessage
::
kValueError
)
;
79
80
GetXFAList()
->
Remove
(
pNode
)
;
81
return
CJS_Result
::
Success
(
)
;
82
}
83
84
CJS_Result
CJX_List
::item(
CFXJSE_Engine
* runtime,
85
pdfium::span<v8::Local<v8::Value>> params) {
86
if
(params.size() != 1)
87
return
CJS_Result
::
Failure
(
JSMessage
::
kParamError
)
;
88
89
int32_t index = runtime->ToInt32(params[0]);
90
size_t cast_index =
static_cast
<size_t>(index);
91
if
(index < 0 || cast_index >= GetXFAList()->GetLength())
92
return
CJS_Result
::
Failure
(
JSMessage
::
kInvalidInputError
)
;
93
94
return
CJS_Result
::
Success
(
95
runtime->NewNormalXFAObject(GetXFAList()->Item(cast_index))
)
;
96
}
97
98
void
CJX_List
::length(
v8
::Isolate* pIsolate,
99
v8::Local<v8::Value>* pValue,
100
bool
bSetting,
101
XFA_Attribute
eAttribute) {
102
if
(bSetting) {
103
ThrowInvalidPropertyException
(pIsolate);
104
return
;
105
}
106
*pValue = fxv8::NewNumberHelper(
107
pIsolate,
pdfium
::checked_cast<int32_t>(GetXFAList()->GetLength()));
108
}
CFXJSE_Engine::EventParamScope
friend class EventParamScope
Definition
cfxjse_engine.h:127
CJS_Result
Definition
cjs_result.h:15
CJS_Result::Success
static CJS_Result Success()
Definition
cjs_result.h:28
CJS_Result::Failure
static CJS_Result Failure(JSMessage id)
Definition
cjs_result.h:35
CJX_List
Definition
cjx_list.h:15
CJX_List::CJX_List
CJX_List(CXFA_List *list)
Definition
cjx_list.cpp:26
CJX_List::DynamicTypeIs
bool DynamicTypeIs(TypeTag eType) const override
Definition
cjx_list.cpp:32
CJX_List::~CJX_List
~CJX_List() override
CJX_Object
Definition
cjx_object.h:46
CJX_Object::GetXFAObject
CXFA_Object * GetXFAObject() const
Definition
cjx_object.h:113
CJX_Object::ThrowInvalidPropertyException
void ThrowInvalidPropertyException(v8::Isolate *pIsolate) const
Definition
cjx_object.cpp:186
CJX_Object::TypeTag
TypeTag
Definition
cjx_object.h:49
CJX_Object::DynamicTypeIs
virtual bool DynamicTypeIs(TypeTag eType) const
Definition
cjx_object.cpp:123
CXFA_List
Definition
cxfa_list.h:17
CXFA_List::Remove
virtual void Remove(CXFA_Node *pNode)=0
CXFA_List::Append
virtual bool Append(CXFA_Node *pNode)=0
CXFA_List::Insert
virtual bool Insert(CXFA_Node *pNewNode, CXFA_Node *pBeforeNode)=0
pdfium::CFDETextOutLargeBitmapTest
Definition
cfde_textout_unittest.cpp:117
XFA_Attribute
XFA_Attribute
Definition
fxfa_basic.h:67
JSMessage
JSMessage
Definition
js_resources.h:12
JSMessage::kParamError
@ kParamError
Definition
js_resources.h:14
JSMessage::kWouldBeCyclic
@ kWouldBeCyclic
Definition
js_resources.h:38
JSMessage::kInvalidInputError
@ kInvalidInputError
Definition
js_resources.h:15
JSMessage::kValueError
@ kValueError
Definition
js_resources.h:29
v8
Definition
fxv8_unittest.h:15
CJX_MethodSpec
Definition
cjx_object.h:40
qtwebengine
src
3rdparty
chromium
third_party
pdfium
fxjs
xfa
cjx_list.cpp
Generated on
for Qt by
1.18.0