1 // Copyright 2017 PDFium Authors. All rights reserved.
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_xfa.h"
8 
9 #include "fxjs/xfa/cfxjse_engine.h"
10 #include "fxjs/xfa/cfxjse_value.h"
11 #include "xfa/fxfa/parser/cxfa_document.h"
12 #include "xfa/fxfa/parser/cxfa_xfa.h"
13 
CJX_Xfa(CXFA_Xfa * node)14 CJX_Xfa::CJX_Xfa(CXFA_Xfa* node) : CJX_Model(node) {}
15 
16 CJX_Xfa::~CJX_Xfa() = default;
17 
DynamicTypeIs(TypeTag eType) const18 bool CJX_Xfa::DynamicTypeIs(TypeTag eType) const {
19   return eType == static_type__ || ParentType__::DynamicTypeIs(eType);
20 }
21 
thisValue(CFXJSE_Value * pValue,bool bSetting,XFA_Attribute eAttribute)22 void CJX_Xfa::thisValue(CFXJSE_Value* pValue,
23                         bool bSetting,
24                         XFA_Attribute eAttribute) {
25   if (bSetting)
26     return;
27 
28   auto* pScriptContext = GetDocument()->GetScriptContext();
29   CXFA_Object* pThis = pScriptContext->GetThisObject();
30   if (!pThis) {
31     pValue->SetNull();
32     return;
33   }
34   pValue->Assign(pScriptContext->GetOrCreateJSBindingFromMap(pThis));
35 }
36