Add GetDocument() helper to CJX_Object

Change-Id: I710ea0baa1befb093d7174d4fc61a5ab28e9f92a
Reviewed-on: https://pdfium-review.googlesource.com/17315
Commit-Queue: dsinclair <dsinclair@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
diff --git a/fxjs/cjx_eventpseudomodel.cpp b/fxjs/cjx_eventpseudomodel.cpp
index 62b4ec8..04d09d7 100644
--- a/fxjs/cjx_eventpseudomodel.cpp
+++ b/fxjs/cjx_eventpseudomodel.cpp
@@ -47,10 +47,6 @@
 
 CJX_EventPseudoModel::~CJX_EventPseudoModel() {}
 
-CScript_EventPseudoModel* CJX_EventPseudoModel::GetXFAEventPseudoModel() {
-  return static_cast<CScript_EventPseudoModel*>(GetXFAObject());
-}
-
 void CJX_EventPseudoModel::Change(CFXJSE_Value* pValue,
                                   bool bSetting,
                                   XFA_ATTRIBUTE eAttribute) {
@@ -148,8 +144,7 @@
 }
 
 void CJX_EventPseudoModel::Emit(CFXJSE_Arguments* pArguments) {
-  CFXJSE_Engine* pScriptContext =
-      GetXFAEventPseudoModel()->GetDocument()->GetScriptContext();
+  CFXJSE_Engine* pScriptContext = GetDocument()->GetScriptContext();
   if (!pScriptContext)
     return;
 
@@ -157,7 +152,7 @@
   if (!pEventParam)
     return;
 
-  CXFA_FFNotify* pNotify = GetXFAEventPseudoModel()->GetDocument()->GetNotify();
+  CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
   if (!pNotify)
     return;
 
@@ -169,8 +164,7 @@
 }
 
 void CJX_EventPseudoModel::Reset(CFXJSE_Arguments* pArguments) {
-  CFXJSE_Engine* pScriptContext =
-      GetXFAEventPseudoModel()->GetDocument()->GetScriptContext();
+  CFXJSE_Engine* pScriptContext = GetDocument()->GetScriptContext();
   if (!pScriptContext)
     return;
 
@@ -184,8 +178,7 @@
 void CJX_EventPseudoModel::Property(CFXJSE_Value* pValue,
                                     XFA_Event dwFlag,
                                     bool bSetting) {
-  CFXJSE_Engine* pScriptContext =
-      GetXFAEventPseudoModel()->GetDocument()->GetScriptContext();
+  CFXJSE_Engine* pScriptContext = GetDocument()->GetScriptContext();
   if (!pScriptContext)
     return;
 
diff --git a/fxjs/cjx_eventpseudomodel.h b/fxjs/cjx_eventpseudomodel.h
index 10bacae..95de0b5 100644
--- a/fxjs/cjx_eventpseudomodel.h
+++ b/fxjs/cjx_eventpseudomodel.h
@@ -38,8 +38,6 @@
   explicit CJX_EventPseudoModel(CScript_EventPseudoModel* model);
   ~CJX_EventPseudoModel() override;
 
-  CScript_EventPseudoModel* GetXFAEventPseudoModel();
-
   void Change(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute);
   void CommitKey(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute);
   void FullText(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute);
diff --git a/fxjs/cjx_hostpseudomodel.cpp b/fxjs/cjx_hostpseudomodel.cpp
index e18fddf..b667e7a 100644
--- a/fxjs/cjx_hostpseudomodel.cpp
+++ b/fxjs/cjx_hostpseudomodel.cpp
@@ -55,14 +55,10 @@
 
 CJX_HostPseudoModel::~CJX_HostPseudoModel() {}
 
-CScript_HostPseudoModel* CJX_HostPseudoModel::GetXFAHostPseudoModel() {
-  return static_cast<CScript_HostPseudoModel*>(GetXFAObject());
-}
-
 void CJX_HostPseudoModel::AppType(CFXJSE_Value* pValue,
                                   bool bSetting,
                                   XFA_ATTRIBUTE eAttribute) {
-  CXFA_FFNotify* pNotify = GetXFAHostPseudoModel()->GetDocument()->GetNotify();
+  CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
   if (!pNotify)
     return;
 
@@ -76,7 +72,7 @@
 void CJX_HostPseudoModel::CalculationsEnabled(CFXJSE_Value* pValue,
                                               bool bSetting,
                                               XFA_ATTRIBUTE eAttribute) {
-  CXFA_FFNotify* pNotify = GetXFAHostPseudoModel()->GetDocument()->GetNotify();
+  CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
   if (!pNotify)
     return;
 
@@ -92,7 +88,7 @@
 void CJX_HostPseudoModel::CurrentPage(CFXJSE_Value* pValue,
                                       bool bSetting,
                                       XFA_ATTRIBUTE eAttribute) {
-  CXFA_FFNotify* pNotify = GetXFAHostPseudoModel()->GetDocument()->GetNotify();
+  CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
   if (!pNotify)
     return;
 
@@ -107,7 +103,7 @@
 void CJX_HostPseudoModel::Language(CFXJSE_Value* pValue,
                                    bool bSetting,
                                    XFA_ATTRIBUTE eAttribute) {
-  CXFA_FFNotify* pNotify = GetXFAHostPseudoModel()->GetDocument()->GetNotify();
+  CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
   if (!pNotify)
     return;
 
@@ -122,7 +118,7 @@
 void CJX_HostPseudoModel::NumPages(CFXJSE_Value* pValue,
                                    bool bSetting,
                                    XFA_ATTRIBUTE eAttribute) {
-  CXFA_FFNotify* pNotify = GetXFAHostPseudoModel()->GetDocument()->GetNotify();
+  CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
   if (!pNotify)
     return;
 
@@ -137,7 +133,7 @@
 void CJX_HostPseudoModel::Platform(CFXJSE_Value* pValue,
                                    bool bSetting,
                                    XFA_ATTRIBUTE eAttribute) {
-  CXFA_FFNotify* pNotify = GetXFAHostPseudoModel()->GetDocument()->GetNotify();
+  CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
   if (!pNotify)
     return;
 
@@ -152,13 +148,10 @@
 void CJX_HostPseudoModel::Title(CFXJSE_Value* pValue,
                                 bool bSetting,
                                 XFA_ATTRIBUTE eAttribute) {
-  if (!GetXFAHostPseudoModel()
-           ->GetDocument()
-           ->GetScriptContext()
-           ->IsRunAtClient())
+  if (!GetDocument()->GetScriptContext()->IsRunAtClient())
     return;
 
-  CXFA_FFNotify* pNotify = GetXFAHostPseudoModel()->GetDocument()->GetNotify();
+  CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
   if (!pNotify)
     return;
 
@@ -176,7 +169,7 @@
 void CJX_HostPseudoModel::ValidationsEnabled(CFXJSE_Value* pValue,
                                              bool bSetting,
                                              XFA_ATTRIBUTE eAttribute) {
-  CXFA_FFNotify* pNotify = GetXFAHostPseudoModel()->GetDocument()->GetNotify();
+  CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
   if (!pNotify)
     return;
 
@@ -194,13 +187,10 @@
 void CJX_HostPseudoModel::Variation(CFXJSE_Value* pValue,
                                     bool bSetting,
                                     XFA_ATTRIBUTE eAttribute) {
-  if (!GetXFAHostPseudoModel()
-           ->GetDocument()
-           ->GetScriptContext()
-           ->IsRunAtClient())
+  if (!GetDocument()->GetScriptContext()->IsRunAtClient())
     return;
 
-  CXFA_FFNotify* pNotify = GetXFAHostPseudoModel()->GetDocument()->GetNotify();
+  CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
   if (!pNotify)
     return;
 
@@ -214,7 +204,7 @@
 void CJX_HostPseudoModel::Version(CFXJSE_Value* pValue,
                                   bool bSetting,
                                   XFA_ATTRIBUTE eAttribute) {
-  CXFA_FFNotify* pNotify = GetXFAHostPseudoModel()->GetDocument()->GetNotify();
+  CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
   if (!pNotify)
     return;
 
@@ -228,7 +218,7 @@
 void CJX_HostPseudoModel::Name(CFXJSE_Value* pValue,
                                bool bSetting,
                                XFA_ATTRIBUTE eAttribute) {
-  CXFA_FFNotify* pNotify = GetXFAHostPseudoModel()->GetDocument()->GetNotify();
+  CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
   if (!pNotify)
     return;
 
@@ -241,10 +231,7 @@
 }
 
 void CJX_HostPseudoModel::GotoURL(CFXJSE_Arguments* pArguments) {
-  if (!GetXFAHostPseudoModel()
-           ->GetDocument()
-           ->GetScriptContext()
-           ->IsRunAtClient())
+  if (!GetDocument()->GetScriptContext()->IsRunAtClient())
     return;
 
   int32_t iLength = pArguments->GetLength();
@@ -253,7 +240,7 @@
     return;
   }
 
-  CXFA_FFNotify* pNotify = GetXFAHostPseudoModel()->GetDocument()->GetNotify();
+  CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
   if (!pNotify)
     return;
 
@@ -267,10 +254,7 @@
 }
 
 void CJX_HostPseudoModel::OpenList(CFXJSE_Arguments* pArguments) {
-  if (!GetXFAHostPseudoModel()
-           ->GetDocument()
-           ->GetScriptContext()
-           ->IsRunAtClient())
+  if (!GetDocument()->GetScriptContext()->IsRunAtClient())
     return;
 
   int32_t iLength = pArguments->GetLength();
@@ -279,7 +263,7 @@
     return;
   }
 
-  CXFA_FFNotify* pNotify = GetXFAHostPseudoModel()->GetDocument()->GetNotify();
+  CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
   if (!pNotify)
     return;
 
@@ -289,8 +273,7 @@
     if (pValue->IsObject()) {
       pNode = ToNode(pValue.get(), nullptr);
     } else if (pValue->IsString()) {
-      CFXJSE_Engine* pScriptContext =
-          GetXFAHostPseudoModel()->GetDocument()->GetScriptContext();
+      CFXJSE_Engine* pScriptContext = GetDocument()->GetScriptContext();
       if (!pScriptContext)
         return;
 
@@ -310,8 +293,7 @@
     }
   }
 
-  CXFA_LayoutProcessor* pDocLayout =
-      GetXFAHostPseudoModel()->GetDocument()->GetDocLayout();
+  CXFA_LayoutProcessor* pDocLayout = GetDocument()->GetDocLayout();
   if (!pDocLayout)
     return;
 
@@ -331,7 +313,7 @@
     return;
   }
 
-  CXFA_FFNotify* pNotify = GetXFAHostPseudoModel()->GetDocument()->GetNotify();
+  CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
   if (!pNotify)
     return;
 
@@ -374,7 +356,7 @@
     return;
   }
 
-  CXFA_FFNotify* pNotify = GetXFAHostPseudoModel()->GetDocument()->GetNotify();
+  CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
   if (!pNotify)
     return;
 
@@ -394,8 +376,7 @@
   int32_t iExpLength = wsExpression.GetLength();
   while (iStart < iExpLength) {
     iStart = FilterName(wsExpression.AsStringView(), iStart, wsName);
-    CFXJSE_Engine* pScriptContext =
-        GetXFAHostPseudoModel()->GetDocument()->GetScriptContext();
+    CFXJSE_Engine* pScriptContext = GetDocument()->GetScriptContext();
     if (!pScriptContext)
       return;
 
@@ -419,10 +400,7 @@
 }
 
 void CJX_HostPseudoModel::Beep(CFXJSE_Arguments* pArguments) {
-  if (!GetXFAHostPseudoModel()
-           ->GetDocument()
-           ->GetScriptContext()
-           ->IsRunAtClient())
+  if (!GetDocument()->GetScriptContext()->IsRunAtClient())
     return;
 
   int32_t iLength = pArguments->GetLength();
@@ -431,7 +409,7 @@
     return;
   }
 
-  CXFA_FFNotify* pNotify = GetXFAHostPseudoModel()->GetDocument()->GetNotify();
+  CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
   if (!pNotify)
     return;
 
@@ -443,10 +421,7 @@
 }
 
 void CJX_HostPseudoModel::SetFocus(CFXJSE_Arguments* pArguments) {
-  if (!GetXFAHostPseudoModel()
-           ->GetDocument()
-           ->GetScriptContext()
-           ->IsRunAtClient())
+  if (!GetDocument()->GetScriptContext()->IsRunAtClient())
     return;
 
   int32_t iLength = pArguments->GetLength();
@@ -455,7 +430,7 @@
     return;
   }
 
-  CXFA_FFNotify* pNotify = GetXFAHostPseudoModel()->GetDocument()->GetNotify();
+  CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
   if (!pNotify)
     return;
 
@@ -465,8 +440,7 @@
     if (pValue->IsObject()) {
       pNode = ToNode(pValue.get(), nullptr);
     } else if (pValue->IsString()) {
-      CFXJSE_Engine* pScriptContext =
-          GetXFAHostPseudoModel()->GetDocument()->GetScriptContext();
+      CFXJSE_Engine* pScriptContext = GetDocument()->GetScriptContext();
       if (!pScriptContext)
         return;
 
@@ -489,7 +463,7 @@
 }
 
 void CJX_HostPseudoModel::GetFocus(CFXJSE_Arguments* pArguments) {
-  CXFA_FFNotify* pNotify = GetXFAHostPseudoModel()->GetDocument()->GetNotify();
+  CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
   if (!pNotify)
     return;
 
@@ -497,17 +471,12 @@
   if (!pNode)
     return;
 
-  pArguments->GetReturnValue()->Assign(GetXFAHostPseudoModel()
-                                           ->GetDocument()
-                                           ->GetScriptContext()
-                                           ->GetJSValueFromMap(pNode));
+  pArguments->GetReturnValue()->Assign(
+      GetDocument()->GetScriptContext()->GetJSValueFromMap(pNode));
 }
 
 void CJX_HostPseudoModel::MessageBox(CFXJSE_Arguments* pArguments) {
-  if (!GetXFAHostPseudoModel()
-           ->GetDocument()
-           ->GetScriptContext()
-           ->IsRunAtClient())
+  if (!GetDocument()->GetScriptContext()->IsRunAtClient())
     return;
 
   int32_t iLength = pArguments->GetLength();
@@ -516,7 +485,7 @@
     return;
   }
 
-  CXFA_FFNotify* pNotify = GetXFAHostPseudoModel()->GetDocument()->GetNotify();
+  CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
   if (!pNotify)
     return;
 
@@ -557,7 +526,7 @@
     return false;
 
   bool bIsJsType = false;
-  if (GetXFAHostPseudoModel()->GetDocument()->GetScriptContext()->GetType() ==
+  if (GetDocument()->GetScriptContext()->GetType() ==
       XFA_SCRIPTLANGTYPE_Javascript) {
     bIsJsType = true;
   }
@@ -577,10 +546,7 @@
 }
 
 void CJX_HostPseudoModel::Print(CFXJSE_Arguments* pArguments) {
-  if (!GetXFAHostPseudoModel()
-           ->GetDocument()
-           ->GetScriptContext()
-           ->IsRunAtClient())
+  if (!GetDocument()->GetScriptContext()->IsRunAtClient())
     return;
 
   int32_t iLength = pArguments->GetLength();
@@ -589,7 +555,7 @@
     return;
   }
 
-  CXFA_FFNotify* pNotify = GetXFAHostPseudoModel()->GetDocument()->GetNotify();
+  CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
   if (!pNotify)
     return;
 
@@ -660,7 +626,7 @@
     return;
   }
 
-  CXFA_FFNotify* pNotify = GetXFAHostPseudoModel()->GetDocument()->GetNotify();
+  CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
   if (!pNotify)
     return;
 
@@ -678,7 +644,7 @@
 }
 
 void CJX_HostPseudoModel::PageUp(CFXJSE_Arguments* pArguments) {
-  CXFA_FFNotify* pNotify = GetXFAHostPseudoModel()->GetDocument()->GetNotify();
+  CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
   if (!pNotify)
     return;
 
@@ -693,7 +659,7 @@
 }
 
 void CJX_HostPseudoModel::PageDown(CFXJSE_Arguments* pArguments) {
-  CXFA_FFNotify* pNotify = GetXFAHostPseudoModel()->GetDocument()->GetNotify();
+  CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
   if (!pNotify)
     return;
 
@@ -713,7 +679,7 @@
 }
 
 void CJX_HostPseudoModel::CurrentDateTime(CFXJSE_Arguments* pArguments) {
-  CXFA_FFNotify* pNotify = GetXFAHostPseudoModel()->GetDocument()->GetNotify();
+  CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
   if (!pNotify)
     return;
 
diff --git a/fxjs/cjx_hostpseudomodel.h b/fxjs/cjx_hostpseudomodel.h
index 8349707..cb4a2b0 100644
--- a/fxjs/cjx_hostpseudomodel.h
+++ b/fxjs/cjx_hostpseudomodel.h
@@ -19,8 +19,6 @@
   explicit CJX_HostPseudoModel(CScript_HostPseudoModel* model);
   ~CJX_HostPseudoModel() override;
 
-  CScript_HostPseudoModel* GetXFAHostPseudoModel();
-
   void AppType(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute);
   void CalculationsEnabled(CFXJSE_Value* pValue,
                            bool bSetting,
diff --git a/fxjs/cjx_layoutpseudomodel.cpp b/fxjs/cjx_layoutpseudomodel.cpp
index 671e8aa..904ef5b 100644
--- a/fxjs/cjx_layoutpseudomodel.cpp
+++ b/fxjs/cjx_layoutpseudomodel.cpp
@@ -29,15 +29,10 @@
 
 CJX_LayoutPseudoModel::~CJX_LayoutPseudoModel() {}
 
-CScript_LayoutPseudoModel* CJX_LayoutPseudoModel::GetXFALayoutPseudoModel() {
-  return static_cast<CScript_LayoutPseudoModel*>(GetXFAObject());
-}
-
 void CJX_LayoutPseudoModel::Ready(CFXJSE_Value* pValue,
                                   bool bSetting,
                                   XFA_ATTRIBUTE eAttribute) {
-  CXFA_FFNotify* pNotify =
-      GetXFALayoutPseudoModel()->GetDocument()->GetNotify();
+  CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
   if (!pNotify)
     return;
   if (bSetting) {
@@ -85,8 +80,7 @@
 
   int32_t iIndex = iLength >= 3 ? pArguments->GetInt32(2) : 0;
 
-  CXFA_LayoutProcessor* pDocLayout =
-      GetXFALayoutPseudoModel()->GetDocument()->GetDocLayout();
+  CXFA_LayoutProcessor* pDocLayout = GetDocument()->GetDocLayout();
   if (!pDocLayout)
     return;
 
@@ -146,8 +140,7 @@
 
 void CJX_LayoutPseudoModel::NumberedPageCount(CFXJSE_Arguments* pArguments,
                                               bool bNumbered) {
-  CXFA_LayoutProcessor* pDocLayout =
-      GetXFALayoutPseudoModel()->GetDocument()->GetDocLayout();
+  CXFA_LayoutProcessor* pDocLayout = GetDocument()->GetDocLayout();
   if (!pDocLayout)
     return;
 
@@ -187,8 +180,7 @@
   if (!pNode)
     return;
 
-  CXFA_LayoutProcessor* pDocLayout =
-      GetXFALayoutPseudoModel()->GetDocument()->GetDocLayout();
+  CXFA_LayoutProcessor* pDocLayout = GetDocument()->GetDocLayout();
   if (!pDocLayout)
     return;
 
@@ -363,25 +355,20 @@
   if (iLength >= 3)
     bOnPageArea = pArguments->GetInt32(2) == 0 ? false : true;
 
-  CXFA_FFNotify* pNotify =
-      GetXFALayoutPseudoModel()->GetDocument()->GetNotify();
+  CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
   if (!pNotify)
     return;
 
-  CXFA_LayoutProcessor* pDocLayout =
-      GetXFALayoutPseudoModel()->GetDocument()->GetDocLayout();
+  CXFA_LayoutProcessor* pDocLayout = GetDocument()->GetDocLayout();
   if (!pDocLayout)
     return;
 
-  auto pArrayNodeList = pdfium::MakeUnique<CXFA_ArrayNodeList>(
-      GetXFALayoutPseudoModel()->GetDocument());
+  auto pArrayNodeList = pdfium::MakeUnique<CXFA_ArrayNodeList>(GetDocument());
   pArrayNodeList->SetArrayNodeList(
       GetObjArray(pDocLayout, iIndex, wsType, bOnPageArea));
-  pArguments->GetReturnValue()->SetObject(pArrayNodeList.release(),
-                                          GetXFALayoutPseudoModel()
-                                              ->GetDocument()
-                                              ->GetScriptContext()
-                                              ->GetJseNormalClass());
+  pArguments->GetReturnValue()->SetObject(
+      pArrayNodeList.release(),
+      GetDocument()->GetScriptContext()->GetJseNormalClass());
 }
 
 void CJX_LayoutPseudoModel::AbsPageCount(CFXJSE_Arguments* pArguments) {
@@ -397,11 +384,10 @@
 }
 
 void CJX_LayoutPseudoModel::Relayout(CFXJSE_Arguments* pArguments) {
-  CXFA_Node* pRootNode = GetXFALayoutPseudoModel()->GetDocument()->GetRoot();
+  CXFA_Node* pRootNode = GetDocument()->GetRoot();
   CXFA_Node* pFormRoot = pRootNode->GetFirstChildByClass(XFA_Element::Form);
   CXFA_Node* pContentRootNode = pFormRoot->GetNodeItem(XFA_NODEITEM_FirstChild);
-  CXFA_LayoutProcessor* pLayoutProcessor =
-      GetXFALayoutPseudoModel()->GetDocument()->GetLayoutProcessor();
+  CXFA_LayoutProcessor* pLayoutProcessor = GetDocument()->GetLayoutProcessor();
   if (pContentRootNode)
     pLayoutProcessor->AddChangedContainer(pContentRootNode);
 
@@ -457,8 +443,7 @@
   if (!pNode)
     pValue->SetInteger(0);
 
-  CXFA_LayoutProcessor* pDocLayout =
-      GetXFALayoutPseudoModel()->GetDocument()->GetDocLayout();
+  CXFA_LayoutProcessor* pDocLayout = GetDocument()->GetDocLayout();
   if (!pDocLayout)
     return;
 
diff --git a/fxjs/cjx_layoutpseudomodel.h b/fxjs/cjx_layoutpseudomodel.h
index 276eff8..e0e1f78 100644
--- a/fxjs/cjx_layoutpseudomodel.h
+++ b/fxjs/cjx_layoutpseudomodel.h
@@ -29,8 +29,6 @@
   explicit CJX_LayoutPseudoModel(CScript_LayoutPseudoModel* model);
   ~CJX_LayoutPseudoModel() override;
 
-  CScript_LayoutPseudoModel* GetXFALayoutPseudoModel();
-
   void Ready(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute);
 
   void H(CFXJSE_Arguments* pArguments);
diff --git a/fxjs/cjx_node.cpp b/fxjs/cjx_node.cpp
index b7175bc..1f39245 100644
--- a/fxjs/cjx_node.cpp
+++ b/fxjs/cjx_node.cpp
@@ -387,7 +387,7 @@
       CXFA_Node* pNewInstance = GetXFANode()->CreateInstance(true);
       GetXFANode()->InsertItem(pNewInstance, iCount, iCount, false);
       iCount++;
-      CXFA_FFNotify* pNotify = GetXFANode()->GetDocument()->GetNotify();
+      CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
       if (!pNotify) {
         return 0;
       }
@@ -395,11 +395,10 @@
     }
   }
 
-  CXFA_LayoutProcessor* pLayoutPro =
-      GetXFANode()->GetDocument()->GetLayoutProcessor();
+  CXFA_LayoutProcessor* pLayoutPro = GetDocument()->GetLayoutProcessor();
   if (pLayoutPro) {
     pLayoutPro->AddChangedContainer(
-        ToNode(GetXFANode()->GetDocument()->GetXFAObject(XFA_HASHCODE_Form)));
+        ToNode(GetDocument()->GetXFAObject(XFA_HASHCODE_Form)));
   }
   return 0;
 }
@@ -416,11 +415,10 @@
   CXFA_Node* pMoveInstance = GetXFANode()->GetItem(iFrom);
   GetXFANode()->RemoveItem(pMoveInstance, false);
   GetXFANode()->InsertItem(pMoveInstance, iTo, iCount - 1, true);
-  CXFA_LayoutProcessor* pLayoutPro =
-      GetXFANode()->GetDocument()->GetLayoutProcessor();
+  CXFA_LayoutProcessor* pLayoutPro = GetDocument()->GetLayoutProcessor();
   if (pLayoutPro) {
     pLayoutPro->AddChangedContainer(
-        ToNode(GetXFANode()->GetDocument()->GetXFAObject(XFA_HASHCODE_Form)));
+        ToNode(GetDocument()->GetXFAObject(XFA_HASHCODE_Form)));
   }
   return 0;
 }
@@ -433,8 +431,7 @@
   }
   WideString wsExpression =
       WideString::FromUTF8(pArguments->GetUTF8String(0).AsStringView());
-  CFXJSE_Engine* pScriptContext =
-      GetXFANode()->GetDocument()->GetScriptContext();
+  CFXJSE_Engine* pScriptContext = GetDocument()->GetScriptContext();
   if (!pScriptContext)
     return;
   CXFA_Node* refNode = GetXFANode();
@@ -485,8 +482,7 @@
                     XFA_RESOLVENODE_Siblings;
   CXFA_Node* refNode = GetXFANode();
   if (refNode->GetElementType() == XFA_Element::Xfa)
-    refNode = ToNode(
-        GetXFANode()->GetDocument()->GetScriptContext()->GetThisObject());
+    refNode = ToNode(GetDocument()->GetScriptContext()->GetThisObject());
   Script_Som_ResolveNodeList(pValue, wsExpression, dwFlag, refNode);
 }
 
@@ -494,8 +490,7 @@
                                           WideString wsExpression,
                                           uint32_t dwFlag,
                                           CXFA_Node* refNode) {
-  CFXJSE_Engine* pScriptContext =
-      GetXFANode()->GetDocument()->GetScriptContext();
+  CFXJSE_Engine* pScriptContext = GetDocument()->GetScriptContext();
   if (!pScriptContext)
     return;
   XFA_RESOLVENODE_RS resoveNodeRS;
@@ -503,8 +498,7 @@
     refNode = GetXFANode();
   pScriptContext->ResolveObjects(refNode, wsExpression.AsStringView(),
                                  resoveNodeRS, dwFlag);
-  CXFA_ArrayNodeList* pNodeList =
-      new CXFA_ArrayNodeList(GetXFANode()->GetDocument());
+  CXFA_ArrayNodeList* pNodeList = new CXFA_ArrayNodeList(GetDocument());
   if (resoveNodeRS.dwFlags == XFA_RESOVENODE_RSTYPE_Nodes) {
     for (CXFA_Object* pObject : resoveNodeRS.objects) {
       if (pObject->IsNode())
@@ -540,8 +534,7 @@
 void CJX_Node::Script_TreeClass_Nodes(CFXJSE_Value* pValue,
                                       bool bSetting,
                                       XFA_ATTRIBUTE eAttribute) {
-  CFXJSE_Engine* pScriptContext =
-      GetXFANode()->GetDocument()->GetScriptContext();
+  CFXJSE_Engine* pScriptContext = GetDocument()->GetScriptContext();
   if (!pScriptContext)
     return;
 
@@ -550,7 +543,7 @@
     FXJSE_ThrowMessage(wsMessage.UTF8Encode().AsStringView());
   } else {
     CXFA_AttachNodeList* pNodeList =
-        new CXFA_AttachNodeList(GetXFANode()->GetDocument(), GetXFANode());
+        new CXFA_AttachNodeList(GetDocument(), GetXFANode());
     pValue->SetObject(pNodeList, pScriptContext->GetJseNormalClass());
   }
 }
@@ -578,8 +571,7 @@
   CXFA_Node* pParent = GetXFANode()->GetNodeItem(XFA_NODEITEM_Parent);
   if (pParent)
     pValue->Assign(
-        GetXFANode()->GetDocument()->GetScriptContext()->GetJSValueFromMap(
-            pParent));
+        GetDocument()->GetScriptContext()->GetJSValueFromMap(pParent));
   else
     pValue->SetNull();
 }
@@ -661,8 +653,7 @@
   bool bClone = !!pArguments->GetInt32(0);
   CXFA_Node* pCloneNode = GetXFANode()->Clone(bClone);
   pArguments->GetReturnValue()->Assign(
-      GetXFANode()->GetDocument()->GetScriptContext()->GetJSValueFromMap(
-          pCloneNode));
+      GetDocument()->GetScriptContext()->GetJSValueFromMap(pCloneNode));
 }
 
 void CJX_Node::Script_NodeClass_GetAttribute(CFXJSE_Arguments* pArguments) {
@@ -695,8 +686,7 @@
   CXFA_Node* pNode = GetProperty(
       iValue, XFA_GetElementTypeForName(wsExpression.AsStringView()));
   pArguments->GetReturnValue()->Assign(
-      GetXFANode()->GetDocument()->GetScriptContext()->GetJSValueFromMap(
-          pNode));
+      GetDocument()->GetScriptContext()->GetJSValueFromMap(pNode));
 }
 
 void CJX_Node::Script_NodeClass_IsPropertySpecified(
@@ -749,8 +739,7 @@
     bIgnoreRoot = !!pArguments->GetInt32(1);
   if (iLength >= 3)
     bOverwrite = !!pArguments->GetInt32(2);
-  auto pParser =
-      pdfium::MakeUnique<CXFA_SimpleParser>(GetXFANode()->GetDocument(), false);
+  auto pParser = pdfium::MakeUnique<CXFA_SimpleParser>(GetDocument(), false);
   if (!pParser)
     return;
   CFX_XMLNode* pXMLNode = pParser->ParseXMLData(wsExpression);
@@ -946,9 +935,8 @@
     ThrowInvalidPropertyException();
     return;
   }
-  pValue->Assign(
-      GetXFANode()->GetDocument()->GetScriptContext()->GetJSValueFromMap(
-          GetXFANode()->GetModelNode()));
+  pValue->Assign(GetDocument()->GetScriptContext()->GetJSValueFromMap(
+      GetXFANode()->GetModelNode()));
 }
 
 void CJX_Node::Script_NodeClass_IsContainer(CFXJSE_Value* pValue,
@@ -986,20 +974,17 @@
   std::vector<CXFA_Node*> properties =
       GetXFANode()->GetNodeList(XFA_NODEFILTER_OneOfProperty);
   if (!properties.empty()) {
-    pValue->Assign(
-        GetXFANode()->GetDocument()->GetScriptContext()->GetJSValueFromMap(
-            properties.front()));
+    pValue->Assign(GetDocument()->GetScriptContext()->GetJSValueFromMap(
+        properties.front()));
   }
 }
 
 void CJX_Node::Script_ContainerClass_GetDelta(CFXJSE_Arguments* pArguments) {}
 
 void CJX_Node::Script_ContainerClass_GetDeltas(CFXJSE_Arguments* pArguments) {
-  CXFA_ArrayNodeList* pFormNodes =
-      new CXFA_ArrayNodeList(GetXFANode()->GetDocument());
+  CXFA_ArrayNodeList* pFormNodes = new CXFA_ArrayNodeList(GetDocument());
   pArguments->GetReturnValue()->SetObject(
-      pFormNodes,
-      GetXFANode()->GetDocument()->GetScriptContext()->GetJseNormalClass());
+      pFormNodes, GetDocument()->GetScriptContext()->GetJseNormalClass());
 }
 void CJX_Node::Script_ModelClass_ClearErrorList(CFXJSE_Arguments* pArguments) {}
 
@@ -1076,12 +1061,11 @@
 void CJX_Node::Script_Attribute_SendAttributeChangeMessage(
     XFA_ATTRIBUTE eAttribute,
     bool bScriptModify) {
-  CXFA_LayoutProcessor* pLayoutPro =
-      GetXFANode()->GetDocument()->GetLayoutProcessor();
+  CXFA_LayoutProcessor* pLayoutPro = GetDocument()->GetLayoutProcessor();
   if (!pLayoutPro)
     return;
 
-  CXFA_FFNotify* pNotify = GetXFANode()->GetDocument()->GetNotify();
+  CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
   if (!pNotify)
     return;
 
@@ -1240,8 +1224,8 @@
     SetAttribute(eAttribute, wsValue.AsStringView(), true);
     if (eAttribute == XFA_ATTRIBUTE_Use &&
         GetXFANode()->GetElementType() == XFA_Element::Desc) {
-      CXFA_Node* pTemplateNode = ToNode(
-          GetXFANode()->GetDocument()->GetXFAObject(XFA_HASHCODE_Template));
+      CXFA_Node* pTemplateNode =
+          ToNode(GetDocument()->GetXFAObject(XFA_HASHCODE_Template));
       CXFA_Node* pProtoRoot =
           pTemplateNode->GetFirstChildByClass(XFA_Element::Subform)
               ->GetFirstChildByClass(XFA_Element::Proto);
@@ -1262,15 +1246,14 @@
                           XFA_RESOLVENODE_Properties | XFA_RESOLVENODE_Parent |
                           XFA_RESOLVENODE_Siblings;
         XFA_RESOLVENODE_RS resoveNodeRS;
-        int32_t iRet =
-            GetXFANode()->GetDocument()->GetScriptContext()->ResolveObjects(
-                pProtoRoot, wsSOM.AsStringView(), resoveNodeRS, dwFlag);
+        int32_t iRet = GetDocument()->GetScriptContext()->ResolveObjects(
+            pProtoRoot, wsSOM.AsStringView(), resoveNodeRS, dwFlag);
         if (iRet > 0 && resoveNodeRS.objects.front()->IsNode()) {
           pProtoNode = resoveNodeRS.objects.front()->AsNode();
         }
       } else if (!wsID.IsEmpty()) {
-        pProtoNode = GetXFANode()->GetDocument()->GetNodeByID(
-            pProtoRoot, wsID.AsStringView());
+        pProtoNode =
+            GetDocument()->GetNodeByID(pProtoRoot, wsID.AsStringView());
       }
       if (pProtoNode) {
         CXFA_Node* pHeadChild =
@@ -1290,7 +1273,7 @@
           GetXFANode()->InsertChild(pHeadChild);
           pHeadChild = pSibling;
         }
-        GetXFANode()->GetDocument()->RemovePurgeNode(pProtoForm);
+        GetDocument()->RemovePurgeNode(pProtoForm);
         delete pProtoForm;
       }
     }
@@ -1368,7 +1351,7 @@
         break;
     }
     if (!bNew) {
-      CXFA_FFNotify* pNotify = GetXFANode()->GetDocument()->GetNotify();
+      CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
       if (!pNotify) {
         return;
       }
@@ -1620,8 +1603,7 @@
   }
 
   pValue->Assign(
-      GetXFANode()->GetDocument()->GetScriptContext()->GetJSValueFromMap(
-          pDataNode));
+      GetDocument()->GetScriptContext()->GetJSValueFromMap(pDataNode));
 }
 
 void CJX_Node::Script_Draw_DefaultValue(CFXJSE_Value* pValue,
@@ -1869,7 +1851,7 @@
     return;
   }
 
-  CXFA_FFNotify* pNotify = GetXFANode()->GetDocument()->GetNotify();
+  CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
   if (!pNotify)
     return;
 
@@ -1960,7 +1942,7 @@
     return;
   }
 
-  CXFA_FFNotify* pNotify = GetXFANode()->GetDocument()->GetNotify();
+  CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
   if (!pNotify)
     return;
 
@@ -2042,7 +2024,7 @@
     return;
   }
 
-  CXFA_FFNotify* pNotify = GetXFANode()->GetDocument()->GetNotify();
+  CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
   if (!pNotify) {
     pArguments->GetReturnValue()->SetBoolean(false);
     return;
@@ -2073,7 +2055,7 @@
                                           true, true, true);
   } else {
     WideString wsValue = GetScriptContent(true);
-    XFA_VERSION curVersion = GetXFANode()->GetDocument()->GetCurVersionMode();
+    XFA_VERSION curVersion = GetDocument()->GetCurVersionMode();
     if (wsValue.IsEmpty() && curVersion >= XFA_VERSION_300) {
       pValue->SetNull();
     } else {
@@ -2125,8 +2107,7 @@
     return;
   }
   pArguments->GetReturnValue()->Assign(
-      GetXFANode()->GetDocument()->GetScriptContext()->GetJSValueFromMap(
-          pReturnNode));
+      GetDocument()->GetScriptContext()->GetJSValueFromMap(pReturnNode));
 }
 
 void CJX_Node::Script_ExclGroup_ExecInitialize(CFXJSE_Arguments* pArguments) {
@@ -2135,7 +2116,7 @@
     return;
   }
 
-  CXFA_FFNotify* pNotify = GetXFANode()->GetDocument()->GetNotify();
+  CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
   if (!pNotify)
     return;
 
@@ -2148,7 +2129,7 @@
     return;
   }
 
-  CXFA_FFNotify* pNotify = GetXFANode()->GetDocument()->GetNotify();
+  CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
   if (!pNotify)
     return;
 
@@ -2161,7 +2142,7 @@
     return;
   }
 
-  CXFA_FFNotify* pNotify = GetXFANode()->GetDocument()->GetNotify();
+  CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
   if (!pNotify) {
     pArguments->GetReturnValue()->SetBoolean(false);
     return;
@@ -2189,7 +2170,7 @@
     }
     if (pManagerNode) {
       pManagerNode->JSNode()->InstanceManager_MoveInstance(iTo, iFrom);
-      CXFA_FFNotify* pNotify = GetXFANode()->GetDocument()->GetNotify();
+      CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
       if (!pNotify) {
         return;
       }
@@ -2237,8 +2218,7 @@
   }
 
   pValue->Assign(
-      GetXFANode()->GetDocument()->GetScriptContext()->GetJSValueFromMap(
-          pInstanceMgr));
+      GetDocument()->GetScriptContext()->GetJSValueFromMap(pInstanceMgr));
 }
 
 void CJX_Node::Script_Subform_Locale(CFXJSE_Value* pValue,
@@ -2271,7 +2251,7 @@
     return;
   }
 
-  CXFA_FFNotify* pNotify = GetXFANode()->GetDocument()->GetNotify();
+  CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
   if (!pNotify)
     return;
 
@@ -2284,7 +2264,7 @@
     return;
   }
 
-  CXFA_FFNotify* pNotify = GetXFANode()->GetDocument()->GetNotify();
+  CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
   if (!pNotify)
     return;
 
@@ -2297,7 +2277,7 @@
     return;
   }
 
-  CXFA_FFNotify* pNotify = GetXFANode()->GetDocument()->GetNotify();
+  CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
   if (!pNotify) {
     pArguments->GetReturnValue()->SetBoolean(false);
     return;
@@ -2327,7 +2307,7 @@
     ThrowParamCountMismatchException(L"remerge");
     return;
   }
-  GetXFANode()->GetDocument()->DoDataRemerge(true);
+  GetDocument()->DoDataRemerge(true);
 }
 
 void CJX_Node::Script_Template_ExecInitialize(CFXJSE_Arguments* pArguments) {
@@ -2373,8 +2353,7 @@
 
   if (strName.IsEmpty()) {
     pArguments->GetReturnValue()->Assign(
-        GetXFANode()->GetDocument()->GetScriptContext()->GetJSValueFromMap(
-            pNewNode));
+        GetDocument()->GetScriptContext()->GetJSValueFromMap(pNewNode));
     return;
   }
 
@@ -2390,8 +2369,7 @@
     pNewNode->CreateXMLMappingNode();
 
   pArguments->GetReturnValue()->Assign(
-      GetXFANode()->GetDocument()->GetScriptContext()->GetJSValueFromMap(
-          pNewNode));
+      GetDocument()->GetScriptContext()->GetJSValueFromMap(pNewNode));
 }
 
 void CJX_Node::Script_Template_Recalculate(CFXJSE_Arguments* pArguments) {
@@ -2485,7 +2463,7 @@
   int32_t iFrom = pArguments->GetInt32(0);
   int32_t iTo = pArguments->GetInt32(1);
   InstanceManager_MoveInstance(iTo, iFrom);
-  CXFA_FFNotify* pNotify = GetXFANode()->GetDocument()->GetNotify();
+  CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
   if (!pNotify) {
     return;
   }
@@ -2520,7 +2498,7 @@
   }
   CXFA_Node* pRemoveInstance = GetXFANode()->GetItem(iIndex);
   GetXFANode()->RemoveItem(pRemoveInstance);
-  CXFA_FFNotify* pNotify = GetXFANode()->GetDocument()->GetNotify();
+  CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
   if (pNotify) {
     for (int32_t i = iIndex; i < iCount - 1; i++) {
       CXFA_Node* pSubformInstance = GetXFANode()->GetItem(i);
@@ -2530,13 +2508,12 @@
       }
     }
   }
-  CXFA_LayoutProcessor* pLayoutPro =
-      GetXFANode()->GetDocument()->GetLayoutProcessor();
+  CXFA_LayoutProcessor* pLayoutPro = GetDocument()->GetLayoutProcessor();
   if (!pLayoutPro) {
     return;
   }
   pLayoutPro->AddChangedContainer(
-      ToNode(GetXFANode()->GetDocument()->GetXFAObject(XFA_HASHCODE_Form)));
+      ToNode(GetDocument()->GetXFAObject(XFA_HASHCODE_Form)));
 }
 
 void CJX_Node::Script_InstanceManager_SetInstances(
@@ -2570,20 +2547,18 @@
   CXFA_Node* pNewInstance = GetXFANode()->CreateInstance(fFlags);
   GetXFANode()->InsertItem(pNewInstance, iCount, iCount, false);
   pArguments->GetReturnValue()->Assign(
-      GetXFANode()->GetDocument()->GetScriptContext()->GetJSValueFromMap(
-          pNewInstance));
-  CXFA_FFNotify* pNotify = GetXFANode()->GetDocument()->GetNotify();
+      GetDocument()->GetScriptContext()->GetJSValueFromMap(pNewInstance));
+  CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
   if (!pNotify) {
     return;
   }
   pNotify->RunNodeInitialize(pNewInstance);
-  CXFA_LayoutProcessor* pLayoutPro =
-      GetXFANode()->GetDocument()->GetLayoutProcessor();
+  CXFA_LayoutProcessor* pLayoutPro = GetDocument()->GetLayoutProcessor();
   if (!pLayoutPro) {
     return;
   }
   pLayoutPro->AddChangedContainer(
-      ToNode(GetXFANode()->GetDocument()->GetXFAObject(XFA_HASHCODE_Form)));
+      ToNode(GetDocument()->GetXFAObject(XFA_HASHCODE_Form)));
 }
 
 void CJX_Node::Script_InstanceManager_InsertInstance(
@@ -2612,20 +2587,18 @@
   CXFA_Node* pNewInstance = GetXFANode()->CreateInstance(bBind);
   GetXFANode()->InsertItem(pNewInstance, iIndex, iCount, true);
   pArguments->GetReturnValue()->Assign(
-      GetXFANode()->GetDocument()->GetScriptContext()->GetJSValueFromMap(
-          pNewInstance));
-  CXFA_FFNotify* pNotify = GetXFANode()->GetDocument()->GetNotify();
+      GetDocument()->GetScriptContext()->GetJSValueFromMap(pNewInstance));
+  CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
   if (!pNotify) {
     return;
   }
   pNotify->RunNodeInitialize(pNewInstance);
-  CXFA_LayoutProcessor* pLayoutPro =
-      GetXFANode()->GetDocument()->GetLayoutProcessor();
+  CXFA_LayoutProcessor* pLayoutPro = GetDocument()->GetLayoutProcessor();
   if (!pLayoutPro) {
     return;
   }
   pLayoutPro->AddChangedContainer(
-      ToNode(GetXFANode()->GetDocument()->GetXFAObject(XFA_HASHCODE_Form)));
+      ToNode(GetDocument()->GetXFAObject(XFA_HASHCODE_Form)));
 }
 void CJX_Node::Script_Occur_Max(CFXJSE_Value* pValue,
                                 bool bSetting,
@@ -2673,12 +2646,10 @@
   }
 
   std::vector<CXFA_Node*> formItems;
-  CXFA_ArrayNodeList* pFormNodes =
-      new CXFA_ArrayNodeList(GetXFANode()->GetDocument());
+  CXFA_ArrayNodeList* pFormNodes = new CXFA_ArrayNodeList(GetDocument());
   pFormNodes->SetArrayNodeList(formItems);
   pArguments->GetReturnValue()->SetObject(
-      pFormNodes,
-      GetXFANode()->GetDocument()->GetScriptContext()->GetJseNormalClass());
+      pFormNodes, GetDocument()->GetScriptContext()->GetJseNormalClass());
 }
 
 void CJX_Node::Script_Form_Remerge(CFXJSE_Arguments* pArguments) {
@@ -2687,7 +2658,7 @@
     return;
   }
 
-  GetXFANode()->GetDocument()->DoDataRemerge(true);
+  GetDocument()->DoDataRemerge(true);
 }
 
 void CJX_Node::Script_Form_ExecInitialize(CFXJSE_Arguments* pArguments) {
@@ -2696,7 +2667,7 @@
     return;
   }
 
-  CXFA_FFNotify* pNotify = GetXFANode()->GetDocument()->GetNotify();
+  CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
   if (!pNotify)
     return;
 
@@ -2705,7 +2676,7 @@
 
 void CJX_Node::Script_Form_Recalculate(CFXJSE_Arguments* pArguments) {
   CXFA_EventParam* pEventParam =
-      GetXFANode()->GetDocument()->GetScriptContext()->GetEventParam();
+      GetDocument()->GetScriptContext()->GetEventParam();
   if (pEventParam->m_eType == XFA_EVENT_Calculate ||
       pEventParam->m_eType == XFA_EVENT_InitCalculate) {
     return;
@@ -2715,7 +2686,7 @@
     return;
   }
 
-  CXFA_FFNotify* pNotify = GetXFANode()->GetDocument()->GetNotify();
+  CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
   if (!pNotify)
     return;
   if (pArguments->GetInt32(0) != 0)
@@ -2732,7 +2703,7 @@
     return;
   }
 
-  CXFA_FFNotify* pNotify = GetXFANode()->GetDocument()->GetNotify();
+  CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
   if (!pNotify)
     return;
 
@@ -2745,7 +2716,7 @@
     return;
   }
 
-  CXFA_FFNotify* pNotify = GetXFANode()->GetDocument()->GetNotify();
+  CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
   if (!pNotify) {
     pArguments->GetReturnValue()->SetBoolean(false);
     return;
@@ -2932,12 +2903,9 @@
                                bool bSetting,
                                XFA_ATTRIBUTE eAttribute) {
   if (!bSetting) {
-    CXFA_Object* pThis =
-        GetXFANode()->GetDocument()->GetScriptContext()->GetThisObject();
+    CXFA_Object* pThis = GetDocument()->GetScriptContext()->GetThisObject();
     ASSERT(pThis);
-    pValue->Assign(
-        GetXFANode()->GetDocument()->GetScriptContext()->GetJSValueFromMap(
-            pThis));
+    pValue->Assign(GetDocument()->GetScriptContext()->GetJSValueFromMap(pThis));
   }
 }
 
@@ -3555,11 +3523,9 @@
   }
   if (pNode) {
     if (bScriptModify) {
-      CFXJSE_Engine* pScriptContext =
-          GetXFANode()->GetDocument()->GetScriptContext();
+      CFXJSE_Engine* pScriptContext = GetDocument()->GetScriptContext();
       if (pScriptContext) {
-        GetXFANode()->GetDocument()->GetScriptContext()->AddNodesOfRunScript(
-            GetXFANode());
+        GetDocument()->GetScriptContext()->AddNodesOfRunScript(GetXFANode());
       }
     }
     return TryCData(XFA_ATTRIBUTE_Value, wsContent, false, bProto);
@@ -3634,7 +3600,7 @@
   const XFA_PACKETINFO* pPacket = XFA_GetPacketByID(dwPacket);
   CXFA_Node* pNewNode = nullptr;
   for (; iCount <= index; iCount++) {
-    pNewNode = GetXFANode()->GetDocument()->CreateNode(pPacket, eProperty);
+    pNewNode = GetDocument()->CreateNode(pPacket, eProperty);
     if (!pNewNode)
       return nullptr;
     GetXFANode()->InsertChild(pNewNode, nullptr);
@@ -3907,7 +3873,7 @@
       GetEventParaInfoByName(wsEventName);
   if (eventParaInfo) {
     uint32_t validFlags = eventParaInfo->m_validFlags;
-    CXFA_FFNotify* pNotify = GetXFANode()->GetDocument()->GetNotify();
+    CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
     if (!pNotify) {
       return iRet;
     }
diff --git a/fxjs/cjx_nodelist.cpp b/fxjs/cjx_nodelist.cpp
index 8200e2e..9a0c4a2 100644
--- a/fxjs/cjx_nodelist.cpp
+++ b/fxjs/cjx_nodelist.cpp
@@ -80,7 +80,7 @@
     return;
   }
   pArguments->GetReturnValue()->Assign(
-      GetXFANodeList()->GetDocument()->GetScriptContext()->GetJSValueFromMap(
+      GetDocument()->GetScriptContext()->GetJSValueFromMap(
           GetXFANodeList()->Item(iIndex)));
 }
 
@@ -99,8 +99,7 @@
     return;
 
   pArguments->GetReturnValue()->Assign(
-      GetXFANodeList()->GetDocument()->GetScriptContext()->GetJSValueFromMap(
-          pNode));
+      GetDocument()->GetScriptContext()->GetJSValueFromMap(pNode));
 }
 
 void CJX_NodeList::Script_ListClass_Length(CFXJSE_Value* pValue,
diff --git a/fxjs/cjx_object.cpp b/fxjs/cjx_object.cpp
index a3ba05f..3efab63 100644
--- a/fxjs/cjx_object.cpp
+++ b/fxjs/cjx_object.cpp
@@ -13,6 +13,10 @@
 
 CJX_Object::~CJX_Object() {}
 
+CXFA_Document* CJX_Object::GetDocument() const {
+  return object_->GetDocument();
+}
+
 void CJX_Object::Script_ObjectClass_ClassName(CFXJSE_Value* pValue,
                                               bool bSetting,
                                               XFA_ATTRIBUTE eAttribute) {
diff --git a/fxjs/cjx_object.h b/fxjs/cjx_object.h
index 7cb91b9..27006f5 100644
--- a/fxjs/cjx_object.h
+++ b/fxjs/cjx_object.h
@@ -10,6 +10,7 @@
 #include "core/fxcrt/unowned_ptr.h"
 #include "core/fxcrt/widestring.h"
 #include "xfa/fxfa/fxfa_basic.h"
+#include "xfa/fxfa/parser/cxfa_document.h"
 
 class CFXJSE_Value;
 class CXFA_Object;
@@ -21,6 +22,8 @@
   CXFA_Object* GetXFAObject() { return object_.Get(); }
   const CXFA_Object* GetXFAObject() const { return object_.Get(); }
 
+  CXFA_Document* GetDocument() const;
+
   void Script_ObjectClass_ClassName(CFXJSE_Value* pValue,
                                     bool bSetting,
                                     XFA_ATTRIBUTE eAttribute);