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_occur.h"
8
9 #include "fxjs/fxv8.h"
10 #include "fxjs/xfa/cfxjse_value.h"
11 #include "v8/include/v8-primitive.h"
12 #include "xfa/fxfa/parser/cxfa_occur.h"
13
CJX_Occur(CXFA_Occur * node)14 CJX_Occur::CJX_Occur(CXFA_Occur* node) : CJX_Node(node) {}
15
16 CJX_Occur::~CJX_Occur() = default;
17
DynamicTypeIs(TypeTag eType) const18 bool CJX_Occur::DynamicTypeIs(TypeTag eType) const {
19 return eType == static_type__ || ParentType__::DynamicTypeIs(eType);
20 }
21
max(v8::Isolate * pIsolate,v8::Local<v8::Value> * pValue,bool bSetting,XFA_Attribute eAttribute)22 void CJX_Occur::max(v8::Isolate* pIsolate,
23 v8::Local<v8::Value>* pValue,
24 bool bSetting,
25 XFA_Attribute eAttribute) {
26 CXFA_Occur* occur = static_cast<CXFA_Occur*>(GetXFANode());
27 if (!bSetting) {
28 *pValue = fxv8::NewNumberHelper(pIsolate, occur->GetMax());
29 return;
30 }
31 occur->SetMax(fxv8::ReentrantToInt32Helper(pIsolate, *pValue));
32 }
33
34 // NOLINTNEXTLINE(build/include_what_you_use)
min(v8::Isolate * pIsolate,v8::Local<v8::Value> * pValue,bool bSetting,XFA_Attribute eAttribute)35 void CJX_Occur::min(v8::Isolate* pIsolate,
36 v8::Local<v8::Value>* pValue,
37 bool bSetting,
38 XFA_Attribute eAttribute) {
39 CXFA_Occur* occur = static_cast<CXFA_Occur*>(GetXFANode());
40 if (!bSetting) {
41 *pValue = fxv8::NewNumberHelper(pIsolate, occur->GetMin());
42 return;
43 }
44 occur->SetMin(fxv8::ReentrantToInt32Helper(pIsolate, *pValue));
45 }
46