summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2017-12-14 20:51:03 +0000
committerChromium commit bot <commit-bot@chromium.org>2017-12-14 20:51:03 +0000
commitdf4f30eaaa469c3703118f89579d506209a49237 (patch)
tree881eb4c93dadd3b07414cc950ed5cbbbb3c9693a
parent51ef4a6ca3b4ae9b618cb1c96f84697a2bf4a2b1 (diff)
downloadpdfium-df4f30eaaa469c3703118f89579d506209a49237.tar.xz
Add types to the CXFA_Node::Get*{Child|Sibling}* methods
This CL templates the various Get methods in CXFA_Node in order to return the correct node type. Change-Id: I4f50df6dd9213873deb8f8f262eaf579c6c4ca7d Reviewed-on: https://pdfium-review.googlesource.com/21230 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
-rw-r--r--fxjs/xfa/cjx_layoutpseudomodel.cpp4
-rw-r--r--fxjs/xfa/cjx_object.cpp9
-rw-r--r--xfa/fxfa/cxfa_ffdoc.cpp14
-rw-r--r--xfa/fxfa/cxfa_ffdocview.cpp12
-rw-r--r--xfa/fxfa/cxfa_ffdocview.h3
-rw-r--r--xfa/fxfa/cxfa_ffwidgethandler.cpp7
-rw-r--r--xfa/fxfa/parser/cxfa_containerlayoutitem.cpp4
-rw-r--r--xfa/fxfa/parser/cxfa_document.cpp21
-rw-r--r--xfa/fxfa/parser/cxfa_itemlayoutprocessor.cpp55
-rw-r--r--xfa/fxfa/parser/cxfa_layoutitem.cpp6
-rw-r--r--xfa/fxfa/parser/cxfa_layoutpagemgr.cpp83
-rw-r--r--xfa/fxfa/parser/cxfa_layoutprocessor.cpp5
-rw-r--r--xfa/fxfa/parser/cxfa_localemgr.cpp22
-rw-r--r--xfa/fxfa/parser/cxfa_node.cpp20
-rw-r--r--xfa/fxfa/parser/cxfa_node.h21
-rw-r--r--xfa/fxfa/parser/cxfa_nodelocale.cpp4
-rw-r--r--xfa/fxfa/parser/cxfa_occurdata.h2
-rw-r--r--xfa/fxfa/parser/cxfa_simple_parser.cpp11
-rw-r--r--xfa/fxfa/parser/xfa_document_datamerger_imp.cpp76
19 files changed, 241 insertions, 138 deletions
diff --git a/fxjs/xfa/cjx_layoutpseudomodel.cpp b/fxjs/xfa/cjx_layoutpseudomodel.cpp
index 638da41eea..c275970744 100644
--- a/fxjs/xfa/cjx_layoutpseudomodel.cpp
+++ b/fxjs/xfa/cjx_layoutpseudomodel.cpp
@@ -17,6 +17,7 @@
#include "xfa/fxfa/parser/cxfa_arraynodelist.h"
#include "xfa/fxfa/parser/cxfa_containerlayoutitem.h"
#include "xfa/fxfa/parser/cxfa_document.h"
+#include "xfa/fxfa/parser/cxfa_form.h"
#include "xfa/fxfa/parser/cxfa_layoutitem.h"
#include "xfa/fxfa/parser/cxfa_layoutprocessor.h"
#include "xfa/fxfa/parser/cxfa_measurement.h"
@@ -400,7 +401,8 @@ CJS_Return CJX_LayoutPseudoModel::relayout(
CJS_V8* runtime,
const std::vector<v8::Local<v8::Value>>& params) {
CXFA_Node* pRootNode = GetDocument()->GetRoot();
- CXFA_Node* pFormRoot = pRootNode->GetFirstChildByClass(XFA_Element::Form);
+ CXFA_Form* pFormRoot =
+ pRootNode->GetFirstChildByClass<CXFA_Form>(XFA_Element::Form);
CXFA_Node* pContentRootNode = pFormRoot->GetNodeItem(XFA_NODEITEM_FirstChild);
CXFA_LayoutProcessor* pLayoutProcessor = GetDocument()->GetLayoutProcessor();
if (pContentRootNode)
diff --git a/fxjs/xfa/cjx_object.cpp b/fxjs/xfa/cjx_object.cpp
index c49cc5bbce..fcf77d434d 100644
--- a/fxjs/xfa/cjx_object.cpp
+++ b/fxjs/xfa/cjx_object.cpp
@@ -26,7 +26,10 @@
#include "xfa/fxfa/parser/cxfa_measurement.h"
#include "xfa/fxfa/parser/cxfa_node.h"
#include "xfa/fxfa/parser/cxfa_object.h"
+#include "xfa/fxfa/parser/cxfa_occur.h"
#include "xfa/fxfa/parser/cxfa_occurdata.h"
+#include "xfa/fxfa/parser/cxfa_proto.h"
+#include "xfa/fxfa/parser/cxfa_subform.h"
#include "xfa/fxfa/parser/cxfa_validate.h"
#include "xfa/fxfa/parser/cxfa_value.h"
#include "xfa/fxfa/parser/xfa_utils.h"
@@ -1217,9 +1220,9 @@ void CJX_Object::Script_Attribute_String(CFXJSE_Value* pValue,
CXFA_Node* pTemplateNode =
ToNode(GetDocument()->GetXFAObject(XFA_HASHCODE_Template));
- CXFA_Node* pProtoRoot =
- pTemplateNode->GetFirstChildByClass(XFA_Element::Subform)
- ->GetFirstChildByClass(XFA_Element::Proto);
+ CXFA_Proto* pProtoRoot =
+ pTemplateNode->GetFirstChildByClass<CXFA_Subform>(XFA_Element::Subform)
+ ->GetFirstChildByClass<CXFA_Proto>(XFA_Element::Proto);
WideString wsID;
WideString wsSOM;
diff --git a/xfa/fxfa/cxfa_ffdoc.cpp b/xfa/fxfa/cxfa_ffdoc.cpp
index 2d22fb8c68..bb05d66968 100644
--- a/xfa/fxfa/cxfa_ffdoc.cpp
+++ b/xfa/fxfa/cxfa_ffdoc.cpp
@@ -28,9 +28,12 @@
#include "xfa/fxfa/cxfa_ffnotify.h"
#include "xfa/fxfa/cxfa_ffwidget.h"
#include "xfa/fxfa/cxfa_fontmgr.h"
+#include "xfa/fxfa/parser/cxfa_acrobat.h"
+#include "xfa/fxfa/parser/cxfa_acrobat7.h"
#include "xfa/fxfa/parser/cxfa_dataexporter.h"
#include "xfa/fxfa/parser/cxfa_dataimporter.h"
#include "xfa/fxfa/parser/cxfa_document.h"
+#include "xfa/fxfa/parser/cxfa_dynamicrender.h"
#include "xfa/fxfa/parser/cxfa_node.h"
namespace {
@@ -245,16 +248,19 @@ void CXFA_FFDoc::StopLoad() {
if (!pConfig)
return;
- CXFA_Node* pAcrobat = pConfig->GetFirstChildByClass(XFA_Element::Acrobat);
+ CXFA_Acrobat* pAcrobat =
+ pConfig->GetFirstChildByClass<CXFA_Acrobat>(XFA_Element::Acrobat);
if (!pAcrobat)
return;
- CXFA_Node* pAcrobat7 = pAcrobat->GetFirstChildByClass(XFA_Element::Acrobat7);
+ CXFA_Acrobat7* pAcrobat7 =
+ pAcrobat->GetFirstChildByClass<CXFA_Acrobat7>(XFA_Element::Acrobat7);
if (!pAcrobat7)
return;
- CXFA_Node* pDynamicRender =
- pAcrobat7->GetFirstChildByClass(XFA_Element::DynamicRender);
+ CXFA_DynamicRender* pDynamicRender =
+ pAcrobat7->GetFirstChildByClass<CXFA_DynamicRender>(
+ XFA_Element::DynamicRender);
if (!pDynamicRender)
return;
diff --git a/xfa/fxfa/cxfa_ffdocview.cpp b/xfa/fxfa/cxfa_ffdocview.cpp
index ed91020dff..3fea83c0e7 100644
--- a/xfa/fxfa/cxfa_ffdocview.cpp
+++ b/xfa/fxfa/cxfa_ffdocview.cpp
@@ -32,6 +32,7 @@
#include "xfa/fxfa/parser/cxfa_acrobat.h"
#include "xfa/fxfa/parser/cxfa_binditemsdata.h"
#include "xfa/fxfa/parser/cxfa_layoutprocessor.h"
+#include "xfa/fxfa/parser/cxfa_pageset.h"
#include "xfa/fxfa/parser/cxfa_present.h"
#include "xfa/fxfa/parser/cxfa_subform.h"
#include "xfa/fxfa/parser/cxfa_validate.h"
@@ -120,8 +121,8 @@ void CXFA_FFDocView::StopLayout() {
if (!pSubformNode)
return;
- CXFA_Node* pPageSetNode =
- pSubformNode->GetFirstChildByClass(XFA_Element::PageSet);
+ CXFA_PageSet* pPageSetNode =
+ pSubformNode->GetFirstChildByClass<CXFA_PageSet>(XFA_Element::PageSet);
if (!pPageSetNode)
return;
@@ -315,7 +316,7 @@ CXFA_FFWidgetHandler* CXFA_FFDocView::GetWidgetHandler() {
std::unique_ptr<CXFA_WidgetAccIterator>
CXFA_FFDocView::CreateWidgetAccIterator() {
- CXFA_Node* pFormRoot = GetRootSubform();
+ CXFA_Subform* pFormRoot = GetRootSubform();
return pFormRoot ? pdfium::MakeUnique<CXFA_WidgetAccIterator>(pFormRoot)
: nullptr;
}
@@ -775,11 +776,12 @@ void CXFA_FFDocView::SetChangeMark() {
m_pDoc->GetDocEnvironment()->SetChangeMark(m_pDoc.Get());
}
-CXFA_Node* CXFA_FFDocView::GetRootSubform() {
+CXFA_Subform* CXFA_FFDocView::GetRootSubform() {
CXFA_Node* pFormPacketNode =
ToNode(m_pDoc->GetXFADoc()->GetXFAObject(XFA_HASHCODE_Form));
if (!pFormPacketNode)
return nullptr;
- return pFormPacketNode->GetFirstChildByClass(XFA_Element::Subform);
+ return pFormPacketNode->GetFirstChildByClass<CXFA_Subform>(
+ XFA_Element::Subform);
}
diff --git a/xfa/fxfa/cxfa_ffdocview.h b/xfa/fxfa/cxfa_ffdocview.h
index 8be5cf16b8..e5b27b58ea 100644
--- a/xfa/fxfa/cxfa_ffdocview.h
+++ b/xfa/fxfa/cxfa_ffdocview.h
@@ -18,6 +18,7 @@
class CXFA_FFWidgetHandler;
class CXFA_FFDoc;
class CXFA_FFWidget;
+class CXFA_Subform;
class CXFA_WidgetAccIterator;
extern const XFA_AttributeEnum gs_EventActivity[];
@@ -116,7 +117,7 @@ class CXFA_FFDocView {
size_t RunCalculateRecursive(size_t index);
void ShowNullTestMsg();
bool ResetSingleWidgetAccData(CXFA_WidgetAcc* pWidgetAcc);
- CXFA_Node* GetRootSubform();
+ CXFA_Subform* GetRootSubform();
UnownedPtr<CXFA_FFDoc> const m_pDoc;
std::unique_ptr<CXFA_FFWidgetHandler> m_pWidgetHandler;
diff --git a/xfa/fxfa/cxfa_ffwidgethandler.cpp b/xfa/fxfa/cxfa_ffwidgethandler.cpp
index 685e92d61a..7fe3c17ff5 100644
--- a/xfa/fxfa/cxfa_ffwidgethandler.cpp
+++ b/xfa/fxfa/cxfa_ffwidgethandler.cpp
@@ -13,9 +13,11 @@
#include "xfa/fxfa/cxfa_fffield.h"
#include "xfa/fxfa/cxfa_ffwidget.h"
#include "xfa/fxfa/cxfa_fwladapterwidgetmgr.h"
+#include "xfa/fxfa/parser/cxfa_checkbutton.h"
#include "xfa/fxfa/parser/cxfa_layoutprocessor.h"
#include "xfa/fxfa/parser/cxfa_measurement.h"
#include "xfa/fxfa/parser/cxfa_node.h"
+#include "xfa/fxfa/parser/cxfa_ui.h"
#include "xfa/fxfa/parser/cxfa_validate.h"
CXFA_FFWidgetHandler::CXFA_FFWidgetHandler(CXFA_FFDocView* pDocView)
@@ -354,8 +356,9 @@ CXFA_Node* CXFA_FFWidgetHandler::CreateExclGroup(CXFA_Node* pParent,
CXFA_Node* CXFA_FFWidgetHandler::CreateRadioButton(CXFA_Node* pParent,
CXFA_Node* pBefore) const {
CXFA_Node* pField = CreateField(XFA_Element::CheckButton, pParent, pBefore);
- CXFA_Node* pUi = pField->GetFirstChildByClass(XFA_Element::Ui);
- CXFA_Node* pWidget = pUi->GetFirstChildByClass(XFA_Element::CheckButton);
+ CXFA_Ui* pUi = pField->GetFirstChildByClass<CXFA_Ui>(XFA_Element::Ui);
+ CXFA_CheckButton* pWidget =
+ pUi->GetFirstChildByClass<CXFA_CheckButton>(XFA_Element::CheckButton);
pWidget->JSObject()->SetEnum(XFA_Attribute::Shape, XFA_AttributeEnum::Round,
false);
return pField;
diff --git a/xfa/fxfa/parser/cxfa_containerlayoutitem.cpp b/xfa/fxfa/parser/cxfa_containerlayoutitem.cpp
index 28c0c2eedd..e47a9931a3 100644
--- a/xfa/fxfa/parser/cxfa_containerlayoutitem.cpp
+++ b/xfa/fxfa/parser/cxfa_containerlayoutitem.cpp
@@ -9,6 +9,7 @@
#include "xfa/fxfa/parser/cxfa_layoutpagemgr.h"
#include "xfa/fxfa/parser/cxfa_layoutprocessor.h"
#include "xfa/fxfa/parser/cxfa_measurement.h"
+#include "xfa/fxfa/parser/cxfa_medium.h"
#include "xfa/fxfa/parser/cxfa_node.h"
CXFA_ContainerLayoutItem::CXFA_ContainerLayoutItem(CXFA_Node* pNode)
@@ -27,7 +28,8 @@ int32_t CXFA_ContainerLayoutItem::GetPageIndex() const {
CFX_SizeF CXFA_ContainerLayoutItem::GetPageSize() const {
CFX_SizeF size;
- CXFA_Node* pMedium = m_pFormNode->GetFirstChildByClass(XFA_Element::Medium);
+ CXFA_Medium* pMedium =
+ m_pFormNode->GetFirstChildByClass<CXFA_Medium>(XFA_Element::Medium);
if (!pMedium)
return size;
diff --git a/xfa/fxfa/parser/cxfa_document.cpp b/xfa/fxfa/parser/cxfa_document.cpp
index 3ba5a44cf9..de057aa933 100644
--- a/xfa/fxfa/parser/cxfa_document.cpp
+++ b/xfa/fxfa/parser/cxfa_document.cpp
@@ -15,11 +15,14 @@
#include "xfa/fxfa/parser/cscript_layoutpseudomodel.h"
#include "xfa/fxfa/parser/cscript_logpseudomodel.h"
#include "xfa/fxfa/parser/cscript_signaturepseudomodel.h"
+#include "xfa/fxfa/parser/cxfa_datagroup.h"
#include "xfa/fxfa/parser/cxfa_document_parser.h"
#include "xfa/fxfa/parser/cxfa_interactive.h"
#include "xfa/fxfa/parser/cxfa_layoutprocessor.h"
#include "xfa/fxfa/parser/cxfa_localemgr.h"
#include "xfa/fxfa/parser/cxfa_node.h"
+#include "xfa/fxfa/parser/cxfa_pdf.h"
+#include "xfa/fxfa/parser/cxfa_present.h"
#include "xfa/fxfa/parser/cxfa_traversestrategy_xfanode.h"
#include "xfa/fxfa/parser/xfa_resolvenode_rs.h"
#include "xfa/fxfa/parser/xfa_utils.h"
@@ -154,11 +157,13 @@ CXFA_Object* CXFA_Document::GetXFAObject(XFA_HashCode dwNodeNameHash) {
if (!pDatasetsNode)
return nullptr;
- for (CXFA_Node* pDatasetsChild =
- pDatasetsNode->GetFirstChildByClass(XFA_Element::DataGroup);
+ for (CXFA_DataGroup* pDatasetsChild =
+ pDatasetsNode->GetFirstChildByClass<CXFA_DataGroup>(
+ XFA_Element::DataGroup);
pDatasetsChild;
- pDatasetsChild = pDatasetsChild->GetNextSameClassSibling(
- XFA_Element::DataGroup)) {
+ pDatasetsChild =
+ pDatasetsChild->GetNextSameClassSibling<CXFA_DataGroup>(
+ XFA_Element::DataGroup)) {
if (pDatasetsChild->GetNameHash() != XFA_HASHCODE_Data)
continue;
@@ -178,7 +183,8 @@ CXFA_Object* CXFA_Document::GetXFAObject(XFA_HashCode dwNodeNameHash) {
}
case XFA_HASHCODE_Record: {
CXFA_Node* pData = ToNode(GetXFAObject(XFA_HASHCODE_Data));
- return pData ? pData->GetFirstChildByClass(XFA_Element::DataGroup)
+ return pData ? pData->GetFirstChildByClass<CXFA_DataGroup>(
+ XFA_Element::DataGroup)
: nullptr;
}
case XFA_HASHCODE_DataWindow: {
@@ -254,11 +260,12 @@ bool CXFA_Document::IsInteractive() {
if (!pConfig)
return false;
- CXFA_Node* pPresent = pConfig->GetFirstChildByClass(XFA_Element::Present);
+ CXFA_Present* pPresent =
+ pConfig->GetFirstChildByClass<CXFA_Present>(XFA_Element::Present);
if (!pPresent)
return false;
- CXFA_Node* pPDF = pPresent->GetFirstChildByClass(XFA_Element::Pdf);
+ CXFA_Pdf* pPDF = pPresent->GetFirstChildByClass<CXFA_Pdf>(XFA_Element::Pdf);
if (!pPDF)
return false;
diff --git a/xfa/fxfa/parser/cxfa_itemlayoutprocessor.cpp b/xfa/fxfa/parser/cxfa_itemlayoutprocessor.cpp
index a52821b218..0bf547a000 100644
--- a/xfa/fxfa/parser/cxfa_itemlayoutprocessor.cpp
+++ b/xfa/fxfa/parser/cxfa_itemlayoutprocessor.cpp
@@ -18,13 +18,17 @@
#include "xfa/fxfa/parser/cxfa_containerlayoutitem.h"
#include "xfa/fxfa/parser/cxfa_contentlayoutitem.h"
#include "xfa/fxfa/parser/cxfa_document.h"
+#include "xfa/fxfa/parser/cxfa_keep.h"
#include "xfa/fxfa/parser/cxfa_layoutcontext.h"
#include "xfa/fxfa/parser/cxfa_layoutpagemgr.h"
#include "xfa/fxfa/parser/cxfa_localemgr.h"
+#include "xfa/fxfa/parser/cxfa_margin.h"
#include "xfa/fxfa/parser/cxfa_measurement.h"
#include "xfa/fxfa/parser/cxfa_node.h"
#include "xfa/fxfa/parser/cxfa_nodeiteratortemplate.h"
+#include "xfa/fxfa/parser/cxfa_occur.h"
#include "xfa/fxfa/parser/cxfa_occurdata.h"
+#include "xfa/fxfa/parser/cxfa_para.h"
#include "xfa/fxfa/parser/cxfa_traversestrategy_xfanode.h"
#include "xfa/fxfa/parser/xfa_utils.h"
@@ -130,7 +134,8 @@ CFX_SizeF CalculateContainerComponentSizeFromContentSize(
float fContentCalculatedHeight,
const CFX_SizeF& currentContainerSize) {
CFX_SizeF componentSize = currentContainerSize;
- CXFA_Node* pMarginNode = pFormNode->GetFirstChildByClass(XFA_Element::Margin);
+ CXFA_Margin* pMarginNode =
+ pFormNode->GetFirstChildByClass<CXFA_Margin>(XFA_Element::Margin);
if (bContainerWidthAutoSize) {
componentSize.width = fContentCalculatedWidth;
if (pMarginNode) {
@@ -172,8 +177,9 @@ void RelocateTableRowCells(CXFA_ContentLayoutItem* pLayoutRow,
CFX_SizeF containerSize = CalculateContainerSpecifiedSize(
pLayoutRow->m_pFormNode, &bContainerWidthAutoSize,
&bContainerHeightAutoSize);
- CXFA_Node* pMarginNode =
- pLayoutRow->m_pFormNode->GetFirstChildByClass(XFA_Element::Margin);
+ CXFA_Margin* pMarginNode =
+ pLayoutRow->m_pFormNode->GetFirstChildByClass<CXFA_Margin>(
+ XFA_Element::Margin);
float fLeftInset = 0;
float fTopInset = 0;
float fRightInset = 0;
@@ -255,8 +261,9 @@ void RelocateTableRowCells(CXFA_ContentLayoutItem* pLayoutRow,
&fContentCalculatedHeight);
float fOldChildHeight = pLayoutChild->m_sSize.height;
pLayoutChild->m_sSize.height = fContentCalculatedHeight;
- CXFA_Node* pParaNode =
- pLayoutChild->m_pFormNode->GetFirstChildByClass(XFA_Element::Para);
+ CXFA_Para* pParaNode =
+ pLayoutChild->m_pFormNode->GetFirstChildByClass<CXFA_Para>(
+ XFA_Element::Para);
if (pParaNode && pLayoutChild->m_pFirstChild) {
float fOffHeight = fContentCalculatedHeight - fOldChildHeight;
XFA_AttributeEnum eVType =
@@ -346,8 +353,9 @@ void AddTrailerBeforeSplit(CXFA_ItemLayoutProcessor* pProcessor,
}
UpdatePendingItemLayout(pProcessor, pTrailerLayoutItem);
- CXFA_Node* pMarginNode =
- pProcessor->m_pFormNode->GetFirstChildByClass(XFA_Element::Margin);
+ CXFA_Margin* pMarginNode =
+ pProcessor->m_pFormNode->GetFirstChildByClass<CXFA_Margin>(
+ XFA_Element::Margin);
float fLeftInset = 0;
float fTopInset = 0;
float fRightInset = 0;
@@ -413,8 +421,9 @@ void AddLeaderAfterSplit(CXFA_ItemLayoutProcessor* pProcessor,
CXFA_ContentLayoutItem* pLeaderLayoutItem) {
UpdatePendingItemLayout(pProcessor, pLeaderLayoutItem);
- CXFA_Node* pMarginNode =
- pProcessor->m_pFormNode->GetFirstChildByClass(XFA_Element::Margin);
+ CXFA_Margin* pMarginNode =
+ pProcessor->m_pFormNode->GetFirstChildByClass<CXFA_Margin>(
+ XFA_Element::Margin);
float fLeftInset = 0;
float fRightInset = 0;
if (pMarginNode) {
@@ -522,7 +531,8 @@ bool ExistContainerKeep(CXFA_Node* pCurNode, bool bPreFind) {
if (!pPreContainer)
return false;
- CXFA_Node* pKeep = pCurNode->GetFirstChildByClass(XFA_Element::Keep);
+ CXFA_Keep* pKeep =
+ pCurNode->GetFirstChildByClass<CXFA_Keep>(XFA_Element::Keep);
if (pKeep) {
XFA_Attribute eKeepType = XFA_Attribute::Previous;
if (!bPreFind)
@@ -538,7 +548,7 @@ bool ExistContainerKeep(CXFA_Node* pCurNode, bool bPreFind) {
}
}
- pKeep = pPreContainer->GetFirstChildByClass(XFA_Element::Keep);
+ pKeep = pPreContainer->GetFirstChildByClass<CXFA_Keep>(XFA_Element::Keep);
if (!pKeep)
return false;
@@ -996,8 +1006,8 @@ bool FindLayoutItemSplitPos(CXFA_ContentLayoutItem* pLayoutItem,
CXFA_Document* pDocument = pFormNode->GetDocument();
CXFA_FFNotify* pNotify = pDocument->GetNotify();
float fCurTopMargin = 0, fCurBottomMargin = 0;
- CXFA_Node* pMarginNode =
- pFormNode->GetFirstChildByClass(XFA_Element::Margin);
+ CXFA_Margin* pMarginNode =
+ pFormNode->GetFirstChildByClass<CXFA_Margin>(XFA_Element::Margin);
if (pMarginNode && bCalculateMargin) {
fCurTopMargin = pMarginNode->JSObject()
->GetMeasure(XFA_Attribute::TopInset)
@@ -1221,8 +1231,9 @@ void CXFA_ItemLayoutProcessor::SplitLayoutItem(
if (eLayout == XFA_AttributeEnum::Position)
bCalculateMargin = false;
- CXFA_Node* pMarginNode =
- pLayoutItem->m_pFormNode->GetFirstChildByClass(XFA_Element::Margin);
+ CXFA_Margin* pMarginNode =
+ pLayoutItem->m_pFormNode->GetFirstChildByClass<CXFA_Margin>(
+ XFA_Element::Margin);
if (pMarginNode && bCalculateMargin) {
fCurTopMargin = pMarginNode->JSObject()
->GetMeasure(XFA_Attribute::TopInset)
@@ -1784,8 +1795,8 @@ void CXFA_ItemLayoutProcessor::DoLayoutTableContainer(CXFA_Node* pLayoutNode) {
m_pFormNode, &bContainerWidthAutoSize, &bContainerHeightAutoSize);
float fContentCalculatedWidth = 0;
float fContentCalculatedHeight = 0;
- CXFA_Node* pMarginNode =
- m_pFormNode->GetFirstChildByClass(XFA_Element::Margin);
+ CXFA_Margin* pMarginNode =
+ m_pFormNode->GetFirstChildByClass<CXFA_Margin>(XFA_Element::Margin);
float fLeftInset = 0;
float fRightInset = 0;
if (pMarginNode) {
@@ -2184,8 +2195,8 @@ XFA_ItemLayoutProcessorResult CXFA_ItemLayoutProcessor::DoLayoutFlowedContainer(
}
}
- CXFA_Node* pMarginNode =
- m_pFormNode->GetFirstChildByClass(XFA_Element::Margin);
+ CXFA_Margin* pMarginNode =
+ m_pFormNode->GetFirstChildByClass<CXFA_Margin>(XFA_Element::Margin);
float fLeftInset = 0;
float fTopInset = 0;
float fRightInset = 0;
@@ -2840,9 +2851,9 @@ bool CXFA_ItemLayoutProcessor::JudgeLeaderOrTrailerForOccur(
if (!pTemplate)
pTemplate = pFormNode;
- int32_t iMax =
- CXFA_OccurData(pTemplate->GetFirstChildByClass(XFA_Element::Occur))
- .GetMax();
+ int32_t iMax = CXFA_OccurData(pTemplate->GetFirstChildByClass<CXFA_Occur>(
+ XFA_Element::Occur))
+ .GetMax();
if (iMax < 0)
return true;
diff --git a/xfa/fxfa/parser/cxfa_layoutitem.cpp b/xfa/fxfa/parser/cxfa_layoutitem.cpp
index 02602fd55d..2dfd1efc94 100644
--- a/xfa/fxfa/parser/cxfa_layoutitem.cpp
+++ b/xfa/fxfa/parser/cxfa_layoutitem.cpp
@@ -9,6 +9,7 @@
#include "xfa/fxfa/cxfa_ffnotify.h"
#include "xfa/fxfa/parser/cxfa_containerlayoutitem.h"
#include "xfa/fxfa/parser/cxfa_contentlayoutitem.h"
+#include "xfa/fxfa/parser/cxfa_margin.h"
#include "xfa/fxfa/parser/cxfa_measurement.h"
#include "xfa/fxfa/parser/cxfa_node.h"
@@ -73,8 +74,9 @@ CFX_RectF CXFA_LayoutItem::GetRect(bool bRelative) const {
pLayoutItem = pLayoutItem->m_pParent) {
if (CXFA_ContentLayoutItem* pContent = pLayoutItem->AsContentLayoutItem()) {
sPos += pContent->m_sPos;
- CXFA_Node* pMarginNode =
- pLayoutItem->m_pFormNode->GetFirstChildByClass(XFA_Element::Margin);
+ CXFA_Margin* pMarginNode =
+ pLayoutItem->m_pFormNode->GetFirstChildByClass<CXFA_Margin>(
+ XFA_Element::Margin);
if (pMarginNode) {
sPos += CFX_PointF(pMarginNode->JSObject()
->GetMeasure(XFA_Attribute::LeftInset)
diff --git a/xfa/fxfa/parser/cxfa_layoutpagemgr.cpp b/xfa/fxfa/parser/cxfa_layoutpagemgr.cpp
index 21b3aca235..5cd7b76ddc 100644
--- a/xfa/fxfa/parser/cxfa_layoutpagemgr.cpp
+++ b/xfa/fxfa/parser/cxfa_layoutpagemgr.cpp
@@ -21,6 +21,9 @@
#include "xfa/fxfa/parser/cxfa_node.h"
#include "xfa/fxfa/parser/cxfa_nodeiteratortemplate.h"
#include "xfa/fxfa/parser/cxfa_object.h"
+#include "xfa/fxfa/parser/cxfa_occur.h"
+#include "xfa/fxfa/parser/cxfa_pageset.h"
+#include "xfa/fxfa/parser/cxfa_subform.h"
#include "xfa/fxfa/parser/cxfa_traversestrategy_contentareacontainerlayoutitem.h"
#include "xfa/fxfa/parser/cxfa_traversestrategy_layoutitem.h"
#include "xfa/fxfa/parser/cxfa_traversestrategy_xfacontainernode.h"
@@ -312,7 +315,8 @@ bool CXFA_LayoutPageMgr::InitLayoutPage(CXFA_Node* pFormNode) {
pPageArea = pPageArea->GetNodeItem(XFA_NODEITEM_NextSibling)) {
if (pPageArea->GetElementType() == XFA_Element::PageArea) {
iCount++;
- if (pPageArea->GetFirstChildByClass(XFA_Element::ContentArea))
+ if (pPageArea->GetFirstChildByClass<CXFA_ContentArea>(
+ XFA_Element::ContentArea))
return true;
}
}
@@ -390,11 +394,12 @@ bool CXFA_LayoutPageMgr::PrepareFirstPage(CXFA_Node* pRootSubform) {
break;
bProBreakBefore = true;
- pRootSubform = pRootSubform->GetFirstChildByClass(XFA_Element::Subform);
+ pRootSubform =
+ pRootSubform->GetFirstChildByClass<CXFA_Subform>(XFA_Element::Subform);
while (pRootSubform &&
!XFA_ItemLayoutProcessor_IsTakingSpace(pRootSubform)) {
- pRootSubform =
- pRootSubform->GetNextSameClassSibling(XFA_Element::Subform);
+ pRootSubform = pRootSubform->GetNextSameClassSibling<CXFA_Subform>(
+ XFA_Element::Subform);
}
}
CXFA_Node* pLeader;
@@ -820,8 +825,8 @@ bool CXFA_LayoutPageMgr::ExecuteBreakBeforeOrAfter(
CXFA_Node* pContainer = pFormNode->GetTemplateNode();
bool bStartNew =
pCurNode->JSObject()->GetInteger(XFA_Attribute::StartNew) != 0;
- CXFA_Script* pScript = static_cast<CXFA_Script*>(
- pCurNode->GetFirstChildByClass(XFA_Element::Script));
+ CXFA_Script* pScript =
+ pCurNode->GetFirstChildByClass<CXFA_Script>(XFA_Element::Script);
if (pScript && !RunBreakTestScript(pScript))
return false;
@@ -1143,7 +1148,8 @@ bool CXFA_LayoutPageMgr::FindPageAreaFromPageSet_Ordered(
if (it != m_pPageSetMap.end())
iPageSetCount = it->second;
int32_t iMax = -1;
- CXFA_Node* pOccurNode = pPageSet->GetFirstChildByClass(XFA_Element::Occur);
+ CXFA_Node* pOccurNode =
+ pPageSet->GetFirstChildByClass<CXFA_Occur>(XFA_Element::Occur);
if (pOccurNode) {
pdfium::Optional<int32_t> ret =
pOccurNode->JSObject()->TryInteger(XFA_Attribute::Max, false);
@@ -1162,7 +1168,8 @@ bool CXFA_LayoutPageMgr::FindPageAreaFromPageSet_Ordered(
pCurrentNode = pCurrentNode->GetNodeItem(XFA_NODEITEM_NextSibling)) {
if (pCurrentNode->GetElementType() == XFA_Element::PageArea) {
if ((pTargetPageArea == pCurrentNode || !pTargetPageArea)) {
- if (!pCurrentNode->GetFirstChildByClass(XFA_Element::ContentArea)) {
+ if (!pCurrentNode->GetFirstChildByClass<CXFA_ContentArea>(
+ XFA_Element::ContentArea)) {
if (pTargetPageArea == pCurrentNode) {
CreateMinPageRecord(pCurrentNode, true);
pTargetPageArea = nullptr;
@@ -1175,7 +1182,8 @@ bool CXFA_LayoutPageMgr::FindPageAreaFromPageSet_Ordered(
AddPageAreaLayoutItem(pNewRecord, pCurrentNode);
if (!pTargetContentArea) {
pTargetContentArea =
- pCurrentNode->GetFirstChildByClass(XFA_Element::ContentArea);
+ pCurrentNode->GetFirstChildByClass<CXFA_ContentArea>(
+ XFA_Element::ContentArea);
}
AddContentAreaLayoutItem(pNewRecord, pTargetContentArea);
}
@@ -1238,8 +1246,9 @@ bool CXFA_LayoutPageMgr::FindPageAreaFromPageSet_SimplexDuplex(
}
CXFA_ContainerRecord* pNewRecord = CreateContainerRecord();
AddPageAreaLayoutItem(pNewRecord, pCurrentNode);
- AddContentAreaLayoutItem(pNewRecord, pCurrentNode->GetFirstChildByClass(
- XFA_Element::ContentArea));
+ AddContentAreaLayoutItem(
+ pNewRecord, pCurrentNode->GetFirstChildByClass<CXFA_ContentArea>(
+ XFA_Element::ContentArea));
pPreferredPageArea = pCurrentNode;
return false;
}
@@ -1255,7 +1264,8 @@ bool CXFA_LayoutPageMgr::FindPageAreaFromPageSet_SimplexDuplex(
return false;
}
if ((pTargetPageArea == pCurrentNode || !pTargetPageArea)) {
- if (!pCurrentNode->GetFirstChildByClass(XFA_Element::ContentArea)) {
+ if (!pCurrentNode->GetFirstChildByClass<CXFA_ContentArea>(
+ XFA_Element::ContentArea)) {
if (pTargetPageArea == pCurrentNode) {
CXFA_ContainerRecord* pNewRecord = CreateContainerRecord();
AddPageAreaLayoutItem(pNewRecord, pCurrentNode);
@@ -1275,8 +1285,9 @@ bool CXFA_LayoutPageMgr::FindPageAreaFromPageSet_SimplexDuplex(
} else if (pTargetPageArea && !MatchPageAreaOddOrEven(pTargetPageArea)) {
CXFA_ContainerRecord* pNewRecord = CreateContainerRecord();
AddPageAreaLayoutItem(pNewRecord, pCurrentNode);
- AddContentAreaLayoutItem(pNewRecord, pCurrentNode->GetFirstChildByClass(
- XFA_Element::ContentArea));
+ AddContentAreaLayoutItem(
+ pNewRecord, pCurrentNode->GetFirstChildByClass<CXFA_ContentArea>(
+ XFA_Element::ContentArea));
}
} else if (pCurrentNode->GetElementType() == XFA_Element::PageSet) {
if (FindPageAreaFromPageSet_SimplexDuplex(
@@ -1300,8 +1311,8 @@ bool CXFA_LayoutPageMgr::FindPageAreaFromPageSet_SimplexDuplex(
CXFA_ContainerRecord* pNewRecord = CreateContainerRecord();
AddPageAreaLayoutItem(pNewRecord, pCurPageArea);
if (!pTargetContentArea) {
- pTargetContentArea =
- pCurPageArea->GetFirstChildByClass(XFA_Element::ContentArea);
+ pTargetContentArea = pCurPageArea->GetFirstChildByClass<CXFA_ContentArea>(
+ XFA_Element::ContentArea);
}
AddContentAreaLayoutItem(pNewRecord, pTargetContentArea);
}
@@ -1341,7 +1352,7 @@ CXFA_Node* CXFA_LayoutPageMgr::GetNextAvailPageArea(
if (IsPageSetRootOrderedOccurrence()) {
int32_t iMax = -1;
CXFA_Node* pOccurNode =
- m_pCurPageArea->GetFirstChildByClass(XFA_Element::Occur);
+ m_pCurPageArea->GetFirstChildByClass<CXFA_Occur>(XFA_Element::Occur);
if (pOccurNode) {
pdfium::Optional<int32_t> ret =
pOccurNode->JSObject()->TryInteger(XFA_Attribute::Max, false);
@@ -1355,7 +1366,8 @@ CXFA_Node* CXFA_LayoutPageMgr::GetNextAvailPageArea(
AddPageAreaLayoutItem(pNewRecord, m_pCurPageArea);
if (!pTargetContentArea) {
pTargetContentArea =
- m_pCurPageArea->GetFirstChildByClass(XFA_Element::ContentArea);
+ m_pCurPageArea->GetFirstChildByClass<CXFA_ContentArea>(
+ XFA_Element::ContentArea);
}
AddContentAreaLayoutItem(pNewRecord, pTargetContentArea);
}
@@ -1397,8 +1409,8 @@ bool CXFA_LayoutPageMgr::GetNextContentArea(CXFA_Node* pContentArea) {
CXFA_Node* pCurContentNode =
GetCurrentContainerRecord()->pCurContentArea->m_pFormNode;
if (!pContentArea) {
- pContentArea =
- pCurContentNode->GetNextSameClassSibling(XFA_Element::ContentArea);
+ pContentArea = pCurContentNode->GetNextSameClassSibling<CXFA_ContentArea>(
+ XFA_Element::ContentArea);
if (!pContentArea)
return false;
} else {
@@ -1449,7 +1461,8 @@ int32_t CXFA_LayoutPageMgr::CreateMinPageRecord(CXFA_Node* pPageArea,
int32_t iMin = 0;
pdfium::Optional<int32_t> ret;
- CXFA_Node* pOccurNode = pPageArea->GetFirstChildByClass(XFA_Element::Occur);
+ CXFA_Node* pOccurNode =
+ pPageArea->GetFirstChildByClass<CXFA_Occur>(XFA_Element::Occur);
if (pOccurNode) {
ret = pOccurNode->JSObject()->TryInteger(XFA_Attribute::Min, false);
if (ret)
@@ -1459,8 +1472,8 @@ int32_t CXFA_LayoutPageMgr::CreateMinPageRecord(CXFA_Node* pPageArea,
if (!ret && !bTargetPageArea)
return iMin;
- CXFA_Node* pContentArea =
- pPageArea->GetFirstChildByClass(XFA_Element::ContentArea);
+ CXFA_Node* pContentArea = pPageArea->GetFirstChildByClass<CXFA_ContentArea>(
+ XFA_Element::ContentArea);
if (iMin < 1 && bTargetPageArea && !pContentArea)
iMin = 1;
@@ -1489,7 +1502,8 @@ void CXFA_LayoutPageMgr::CreateMinPageSetRecord(CXFA_Node* pPageSet,
if (bCreateAll)
iCurSetCount = 0;
- CXFA_Node* pOccurNode = pPageSet->GetFirstChildByClass(XFA_Element::Occur);
+ CXFA_Node* pOccurNode =
+ pPageSet->GetFirstChildByClass<CXFA_Occur>(XFA_Element::Occur);
if (!pOccurNode)
return;
@@ -1545,8 +1559,8 @@ bool CXFA_LayoutPageMgr::GetNextAvailContentHeight(float fChildHeight) {
if (!pCurContentNode)
return false;
- pCurContentNode =
- pCurContentNode->GetNextSameClassSibling(XFA_Element::ContentArea);
+ pCurContentNode = pCurContentNode->GetNextSameClassSibling<CXFA_ContentArea>(
+ XFA_Element::ContentArea);
if (pCurContentNode) {
float fNextContentHeight = pCurContentNode->JSObject()
->GetMeasure(XFA_Attribute::H)
@@ -1555,7 +1569,8 @@ bool CXFA_LayoutPageMgr::GetNextAvailContentHeight(float fChildHeight) {
}
CXFA_Node* pPageNode = GetCurrentContainerRecord()->pCurPageArea->m_pFormNode;
- CXFA_Node* pOccurNode = pPageNode->GetFirstChildByClass(XFA_Element::Occur);
+ CXFA_Node* pOccurNode =
+ pPageNode->GetFirstChildByClass<CXFA_Occur>(XFA_Element::Occur);
int32_t iMax = 0;
pdfium::Optional<int32_t> ret;
if (pOccurNode) {
@@ -1582,7 +1597,8 @@ bool CXFA_LayoutPageMgr::GetNextAvailContentHeight(float fChildHeight) {
}
if (pNextPage) {
CXFA_Node* pContentArea =
- pNextPage->GetFirstChildByClass(XFA_Element::ContentArea);
+ pNextPage->GetFirstChildByClass<CXFA_ContentArea>(
+ XFA_Element::ContentArea);
if (pContentArea) {
float fNextContentHeight = pContentArea->JSObject()
->GetMeasure(XFA_Attribute::H)
@@ -1595,8 +1611,8 @@ bool CXFA_LayoutPageMgr::GetNextAvailContentHeight(float fChildHeight) {
}
}
- CXFA_Node* pContentArea =
- pPageNode->GetFirstChildByClass(XFA_Element::ContentArea);
+ CXFA_Node* pContentArea = pPageNode->GetFirstChildByClass<CXFA_ContentArea>(
+ XFA_Element::ContentArea);
float fNextContentHeight = pContentArea->JSObject()
->GetMeasure(XFA_Attribute::H)
.ToUnit(XFA_Unit::Pt);
@@ -1830,7 +1846,7 @@ void CXFA_LayoutPageMgr::MergePageSetContents() {
CXFA_Node* pFormToplevelSubform =
pDocument->GetXFAObject(XFA_HASHCODE_Form)
->AsNode()
- ->GetFirstChildByClass(XFA_Element::Subform);
+ ->GetFirstChildByClass<CXFA_Subform>(XFA_Element::Subform);
pFormToplevelSubform->InsertChild(pPendingPageSet, nullptr);
}
pDocument->DataMerge_UpdateBindingRelations(pPendingPageSet);
@@ -1840,7 +1856,7 @@ void CXFA_LayoutPageMgr::MergePageSetContents() {
CXFA_Node* pPageSet = GetRootLayoutItem()->m_pFormNode;
while (pPageSet) {
CXFA_Node* pNextPageSet =
- pPageSet->GetNextSameClassSibling(XFA_Element::PageSet);
+ pPageSet->GetNextSameClassSibling<CXFA_PageSet>(XFA_Element::PageSet);
CXFA_NodeIteratorTemplate<CXFA_Node, CXFA_TraverseStrategy_XFANode>
sIterator(pPageSet);
CXFA_Node* pNode = sIterator.GetCurrent();
@@ -2002,7 +2018,8 @@ void CXFA_LayoutPageMgr::PrepareLayout() {
}
while (pPageSetFormNode) {
CXFA_Node* pNextPageSet =
- pPageSetFormNode->GetNextSameClassSibling(XFA_Element::PageSet);
+ pPageSetFormNode->GetNextSameClassSibling<CXFA_PageSet>(
+ XFA_Element::PageSet);
pPageSetFormNode->GetNodeItem(XFA_NODEITEM_Parent)
->RemoveChild(pPageSetFormNode, false);
pRootLayoutItem->m_pFormNode->GetDocument()->m_pPendingPageSet.push_back(
diff --git a/xfa/fxfa/parser/cxfa_layoutprocessor.cpp b/xfa/fxfa/parser/cxfa_layoutprocessor.cpp
index 37906ce297..36caa0c0a6 100644
--- a/xfa/fxfa/parser/cxfa_layoutprocessor.cpp
+++ b/xfa/fxfa/parser/cxfa_layoutprocessor.cpp
@@ -15,6 +15,7 @@
#include "xfa/fxfa/parser/cxfa_localemgr.h"
#include "xfa/fxfa/parser/cxfa_measurement.h"
#include "xfa/fxfa/parser/cxfa_node.h"
+#include "xfa/fxfa/parser/cxfa_subform.h"
#include "xfa/fxfa/parser/xfa_document_datamerger_imp.h"
#include "xfa/fxfa/parser/xfa_utils.h"
@@ -38,8 +39,8 @@ int32_t CXFA_LayoutProcessor::StartLayout(bool bForceRestart) {
if (!pFormPacketNode)
return -1;
- CXFA_Node* pFormRoot =
- pFormPacketNode->GetFirstChildByClass(XFA_Element::Subform);
+ CXFA_Subform* pFormRoot =
+ pFormPacketNode->GetFirstChildByClass<CXFA_Subform>(XFA_Element::Subform);
if (!pFormRoot)
return -1;
diff --git a/xfa/fxfa/parser/cxfa_localemgr.cpp b/xfa/fxfa/parser/cxfa_localemgr.cpp
index e7aa09b52d..323a63dd72 100644
--- a/xfa/fxfa/parser/cxfa_localemgr.cpp
+++ b/xfa/fxfa/parser/cxfa_localemgr.cpp
@@ -16,8 +16,12 @@
#include "core/fxcodec/fx_codec.h"
#include "core/fxcrt/xml/cxml_element.h"
#include "third_party/base/ptr_util.h"
+#include "xfa/fxfa/parser/cxfa_acrobat.h"
+#include "xfa/fxfa/parser/cxfa_common.h"
+#include "xfa/fxfa/parser/cxfa_locale.h"
#include "xfa/fxfa/parser/cxfa_node.h"
#include "xfa/fxfa/parser/cxfa_nodelocale.h"
+#include "xfa/fxfa/parser/cxfa_present.h"
#include "xfa/fxfa/parser/cxfa_xmllocale.h"
#include "xfa/fxfa/parser/xfa_utils.h"
@@ -1225,17 +1229,19 @@ WideStringView CXFA_LocaleMgr::GetConfigLocaleName(CXFA_Node* pConfig) {
m_wsConfigLocale.clear();
if (pConfig) {
CXFA_Node* pChildfConfig =
- pConfig->GetFirstChildByClass(XFA_Element::Acrobat);
+ pConfig->GetFirstChildByClass<CXFA_Acrobat>(XFA_Element::Acrobat);
if (!pChildfConfig) {
- pChildfConfig = pConfig->GetFirstChildByClass(XFA_Element::Present);
+ pChildfConfig =
+ pConfig->GetFirstChildByClass<CXFA_Present>(XFA_Element::Present);
}
- CXFA_Node* pCommon =
- pChildfConfig
- ? pChildfConfig->GetFirstChildByClass(XFA_Element::Common)
+ CXFA_Common* pCommon =
+ pChildfConfig ? pChildfConfig->GetFirstChildByClass<CXFA_Common>(
+ XFA_Element::Common)
+ : nullptr;
+ CXFA_Locale* pLocale =
+ pCommon
+ ? pCommon->GetFirstChildByClass<CXFA_Locale>(XFA_Element::Locale)
: nullptr;
- CXFA_Node* pLocale =
- pCommon ? pCommon->GetFirstChildByClass(XFA_Element::Locale)
- : nullptr;
if (pLocale) {
m_wsConfigLocale = pLocale->JSObject()
->TryCData(XFA_Attribute::Value, false)
diff --git a/xfa/fxfa/parser/cxfa_node.cpp b/xfa/fxfa/parser/cxfa_node.cpp
index 195af08bf7..3d05b53bfd 100644
--- a/xfa/fxfa/parser/cxfa_node.cpp
+++ b/xfa/fxfa/parser/cxfa_node.cpp
@@ -30,11 +30,14 @@
#include "xfa/fxfa/parser/cxfa_arraynodelist.h"
#include "xfa/fxfa/parser/cxfa_attachnodelist.h"
#include "xfa/fxfa/parser/cxfa_document.h"
+#include "xfa/fxfa/parser/cxfa_keep.h"
#include "xfa/fxfa/parser/cxfa_layoutprocessor.h"
#include "xfa/fxfa/parser/cxfa_measurement.h"
#include "xfa/fxfa/parser/cxfa_nodeiteratortemplate.h"
+#include "xfa/fxfa/parser/cxfa_occur.h"
#include "xfa/fxfa/parser/cxfa_occurdata.h"
#include "xfa/fxfa/parser/cxfa_simple_parser.h"
+#include "xfa/fxfa/parser/cxfa_subform.h"
#include "xfa/fxfa/parser/cxfa_traversestrategy_xfacontainernode.h"
#include "xfa/fxfa/parser/xfa_basic_data.h"
#include "xfa/fxfa/parser/xfa_utils.h"
@@ -621,7 +624,8 @@ CXFA_WidgetData* CXFA_Node::GetContainerWidgetData() {
bool CXFA_Node::GetLocaleName(WideString& wsLocaleName) {
CXFA_Node* pForm = GetDocument()->GetXFAObject(XFA_HASHCODE_Form)->AsNode();
- CXFA_Node* pTopSubform = pForm->GetFirstChildByClass(XFA_Element::Subform);
+ CXFA_Subform* pTopSubform =
+ pForm->GetFirstChildByClass<CXFA_Subform>(XFA_Element::Subform);
ASSERT(pTopSubform);
CXFA_Node* pLocaleNode = this;
@@ -658,7 +662,7 @@ bool CXFA_Node::GetLocaleName(WideString& wsLocaleName) {
}
XFA_AttributeEnum CXFA_Node::GetIntact() {
- CXFA_Node* pKeep = GetFirstChildByClass(XFA_Element::Keep);
+ CXFA_Keep* pKeep = GetFirstChildByClass<CXFA_Keep>(XFA_Element::Keep);
XFA_AttributeEnum eLayoutType = JSObject()
->TryEnum(XFA_Attribute::Layout, true)
.value_or(XFA_AttributeEnum::Position);
@@ -681,8 +685,8 @@ XFA_AttributeEnum CXFA_Node::GetIntact() {
return XFA_AttributeEnum::ContentArea;
}
- CXFA_Node* pNode =
- pPreviewRow->GetFirstChildByClass(XFA_Element::Keep);
+ CXFA_Keep* pNode =
+ pPreviewRow->GetFirstChildByClass<CXFA_Keep>(XFA_Element::Keep);
pdfium::Optional<XFA_AttributeEnum> ret;
if (pNode)
ret = pNode->JSObject()->TryEnum(XFA_Attribute::Next, false);
@@ -983,7 +987,7 @@ CXFA_Node* CXFA_Node::GetFirstChildByName(uint32_t dwNameHash) const {
return nullptr;
}
-CXFA_Node* CXFA_Node::GetFirstChildByClass(XFA_Element eType) const {
+CXFA_Node* CXFA_Node::GetFirstChildByClassInternal(XFA_Element eType) const {
for (CXFA_Node* pNode = GetNodeItem(XFA_NODEITEM_FirstChild); pNode;
pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling)) {
if (pNode->GetElementType() == eType) {
@@ -1003,12 +1007,12 @@ CXFA_Node* CXFA_Node::GetNextSameNameSibling(uint32_t dwNameHash) const {
return nullptr;
}
-CXFA_Node* CXFA_Node::GetNextSameNameSibling(
+CXFA_Node* CXFA_Node::GetNextSameNameSiblingInternal(
const WideStringView& wsNodeName) const {
return GetNextSameNameSibling(FX_HashCode_GetW(wsNodeName, false));
}
-CXFA_Node* CXFA_Node::GetNextSameClassSibling(XFA_Element eType) const {
+CXFA_Node* CXFA_Node::GetNextSameClassSiblingInternal(XFA_Element eType) const {
for (CXFA_Node* pNode = GetNodeItem(XFA_NODEITEM_NextSibling); pNode;
pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling)) {
if (pNode->GetElementType() == eType) {
@@ -1064,7 +1068,7 @@ CXFA_Node* CXFA_Node::GetInstanceMgrOfSubform() {
}
CXFA_Node* CXFA_Node::GetOccurNode() {
- return GetFirstChildByClass(XFA_Element::Occur);
+ return GetFirstChildByClass<CXFA_Occur>(XFA_Element::Occur);
}
bool CXFA_Node::HasFlag(XFA_NodeFlag dwFlag) const {
diff --git a/xfa/fxfa/parser/cxfa_node.h b/xfa/fxfa/parser/cxfa_node.h
index c2c7605e85..c9f1505f2e 100644
--- a/xfa/fxfa/parser/cxfa_node.h
+++ b/xfa/fxfa/parser/cxfa_node.h
@@ -183,12 +183,23 @@ class CXFA_Node : public CXFA_Object {
CXFA_WidgetData* GetContainerWidgetData();
bool GetLocaleName(WideString& wsLocaleName);
XFA_AttributeEnum GetIntact();
+
CXFA_Node* GetFirstChildByName(const WideStringView& wsNodeName) const;
CXFA_Node* GetFirstChildByName(uint32_t dwNodeNameHash) const;
- CXFA_Node* GetFirstChildByClass(XFA_Element eType) const;
+ template <typename T>
+ T* GetFirstChildByClass(XFA_Element eType) const {
+ return static_cast<T*>(GetFirstChildByClassInternal(eType));
+ }
CXFA_Node* GetNextSameNameSibling(uint32_t dwNodeNameHash) const;
- CXFA_Node* GetNextSameNameSibling(const WideStringView& wsNodeName) const;
- CXFA_Node* GetNextSameClassSibling(XFA_Element eType) const;
+ template <typename T>
+ T* GetNextSameNameSibling(const WideStringView& wsNodeName) const {
+ return static_cast<T*>(GetNextSameNameSiblingInternal(wsNodeName));
+ }
+ template <typename T>
+ T* GetNextSameClassSibling(XFA_Element eType) const {
+ return static_cast<T*>(GetNextSameClassSiblingInternal(eType));
+ }
+
int32_t GetNodeSameNameIndex() const;
int32_t GetNodeSameClassIndex() const;
CXFA_Node* GetInstanceMgrOfSubform();
@@ -233,6 +244,10 @@ class CXFA_Node : public CXFA_Object {
CXFA_Node* GetChildInternal(int32_t index,
XFA_Element eType,
bool bOnlyChild);
+ CXFA_Node* GetFirstChildByClassInternal(XFA_Element eType) const;
+ CXFA_Node* GetNextSameNameSiblingInternal(
+ const WideStringView& wsNodeName) const;
+ CXFA_Node* GetNextSameClassSiblingInternal(XFA_Element eType) const;
const PropertyData* const m_Properties;
const AttributeData* const m_Attributes;
diff --git a/xfa/fxfa/parser/cxfa_nodelocale.cpp b/xfa/fxfa/parser/cxfa_nodelocale.cpp
index e7bba363cf..5031216de9 100644
--- a/xfa/fxfa/parser/cxfa_nodelocale.cpp
+++ b/xfa/fxfa/parser/cxfa_nodelocale.cpp
@@ -165,8 +165,8 @@ WideString CXFA_NodeLocale::GetCalendarSymbol(XFA_Element eElement,
if (!pCalendar)
return WideString();
- CXFA_Node* pNode = pCalendar->GetFirstChildByClass(eElement);
- for (; pNode; pNode = pNode->GetNextSameClassSibling(eElement)) {
+ CXFA_Node* pNode = pCalendar->GetFirstChildByClass<CXFA_Node>(eElement);
+ for (; pNode; pNode = pNode->GetNextSameClassSibling<CXFA_Node>(eElement)) {
if (pNode->JSObject()->GetBoolean(XFA_Attribute::Abbr) == bAbbr) {
CXFA_Node* pSymbol =
pNode->GetChild<CXFA_Node>(index, XFA_Element::Unknown, false);
diff --git a/xfa/fxfa/parser/cxfa_occurdata.h b/xfa/fxfa/parser/cxfa_occurdata.h
index 7c90a1993b..1b4d600875 100644
--- a/xfa/fxfa/parser/cxfa_occurdata.h
+++ b/xfa/fxfa/parser/cxfa_occurdata.h
@@ -12,7 +12,7 @@
#include "core/fxcrt/fx_system.h"
#include "xfa/fxfa/parser/cxfa_datadata.h"
-class CXFA_Node;
+class CXFA_Occur;
class CXFA_OccurData : public CXFA_DataData {
public:
diff --git a/xfa/fxfa/parser/cxfa_simple_parser.cpp b/xfa/fxfa/parser/cxfa_simple_parser.cpp
index 5c722821cb..feafdcf38d 100644
--- a/xfa/fxfa/parser/cxfa_simple_parser.cpp
+++ b/xfa/fxfa/parser/cxfa_simple_parser.cpp
@@ -26,6 +26,8 @@
#include "xfa/fxfa/fxfa.h"
#include "xfa/fxfa/parser/cxfa_document.h"
#include "xfa/fxfa/parser/cxfa_node.h"
+#include "xfa/fxfa/parser/cxfa_subform.h"
+#include "xfa/fxfa/parser/cxfa_template.h"
#include "xfa/fxfa/parser/xfa_basic_data.h"
#include "xfa/fxfa/parser/xfa_utils.h"
@@ -709,10 +711,11 @@ CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket_Form(
pNode->JSObject()->SetCData(XFA_Attribute::Name, packet->name, false, false);
pNode->JSObject()->SetAttribute(XFA_Attribute::Checksum,
wsChecksum.AsStringView(), false);
- CXFA_Node* pTemplateRoot =
- m_pRootNode->GetFirstChildByClass(XFA_Element::Template);
- CXFA_Node* pTemplateChosen =
- pTemplateRoot ? pTemplateRoot->GetFirstChildByClass(XFA_Element::Subform)
+ CXFA_Template* pTemplateRoot =
+ m_pRootNode->GetFirstChildByClass<CXFA_Template>(XFA_Element::Template);
+ CXFA_Subform* pTemplateChosen =
+ pTemplateRoot ? pTemplateRoot->GetFirstChildByClass<CXFA_Subform>(
+ XFA_Element::Subform)
: nullptr;
bool bUseAttribute = true;
if (pTemplateChosen &&
diff --git a/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp b/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp
index 22b339aba5..6b7488c4a7 100644
--- a/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp
+++ b/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp
@@ -15,13 +15,20 @@
#include "fxjs/cfxjse_engine.h"
#include "third_party/base/logging.h"
#include "third_party/base/stl_util.h"
+#include "xfa/fxfa/parser/cxfa_bind.h"
+#include "xfa/fxfa/parser/cxfa_datagroup.h"
#include "xfa/fxfa/parser/cxfa_document.h"
+#include "xfa/fxfa/parser/cxfa_form.h"
#include "xfa/fxfa/parser/cxfa_items.h"
#include "xfa/fxfa/parser/cxfa_layoutprocessor.h"
#include "xfa/fxfa/parser/cxfa_localemgr.h"
#include "xfa/fxfa/parser/cxfa_node.h"
#include "xfa/fxfa/parser/cxfa_nodeiteratortemplate.h"
+#include "xfa/fxfa/parser/cxfa_occur.h"
#include "xfa/fxfa/parser/cxfa_occurdata.h"
+#include "xfa/fxfa/parser/cxfa_pageset.h"
+#include "xfa/fxfa/parser/cxfa_subform.h"
+#include "xfa/fxfa/parser/cxfa_template.h"
#include "xfa/fxfa/parser/cxfa_traversestrategy_xfacontainernode.h"
#include "xfa/fxfa/parser/cxfa_traversestrategy_xfanode.h"
#include "xfa/fxfa/parser/cxfa_value.h"
@@ -402,10 +409,12 @@ CXFA_Node* ScopeMatchGlobalBinding(CXFA_Node* pDataScope,
return pDataChild;
}
- for (CXFA_Node* pDataChild =
- pCurDataScope->GetFirstChildByClass(XFA_Element::DataGroup);
- pDataChild; pDataChild = pDataChild->GetNextSameClassSibling(
- XFA_Element::DataGroup)) {
+ for (CXFA_DataGroup* pDataChild =
+ pCurDataScope->GetFirstChildByClass<CXFA_DataGroup>(
+ XFA_Element::DataGroup);
+ pDataChild;
+ pDataChild = pDataChild->GetNextSameClassSibling<CXFA_DataGroup>(
+ XFA_Element::DataGroup)) {
CXFA_Node* pDataNode = ScopeMatchGlobalBinding(pDataChild, dwNameHash,
eMatchDataNodeType, false);
if (pDataNode)
@@ -588,8 +597,8 @@ CXFA_Node* FindMatchingDataNode(
continue;
}
- CXFA_Node* pTemplateNodeOccur =
- pCurTemplateNode->GetFirstChildByClass(XFA_Element::Occur);
+ CXFA_Occur* pTemplateNodeOccur =
+ pCurTemplateNode->GetFirstChildByClass<CXFA_Occur>(XFA_Element::Occur);
if (pTemplateNodeOccur) {
int32_t iMin;
int32_t iMax;
@@ -602,8 +611,8 @@ CXFA_Node* FindMatchingDataNode(
}
}
- CXFA_Node* pTemplateNodeBind =
- pCurTemplateNode->GetFirstChildByClass(XFA_Element::Bind);
+ CXFA_Bind* pTemplateNodeBind =
+ pCurTemplateNode->GetFirstChildByClass<CXFA_Bind>(XFA_Element::Bind);
XFA_AttributeEnum eMatch =
pTemplateNodeBind
? pTemplateNodeBind->JSObject()->GetEnum(XFA_Attribute::Match)
@@ -719,14 +728,16 @@ CXFA_Node* CopyContainer_SubformSet(CXFA_Document* pDocument,
pDocument, pFormParentNode,
pTemplateNode, &subformArray)
: nullptr;
- if (CXFA_Node* pOccurTemplateNode =
- pTemplateNode->GetFirstChildByClass(XFA_Element::Occur)) {
+ if (CXFA_Occur* pOccurTemplateNode =
+ pTemplateNode->GetFirstChildByClass<CXFA_Occur>(
+ XFA_Element::Occur)) {
pOccurNode = pInstMgrNode ? XFA_NodeMerge_CloneOrMergeContainer(
pDocument, pInstMgrNode,
pOccurTemplateNode, false, nullptr)
: pOccurTemplateNode;
} else if (pInstMgrNode) {
- pOccurNode = pInstMgrNode->GetFirstChildByClass(XFA_Element::Occur);
+ pOccurNode =
+ pInstMgrNode->GetFirstChildByClass<CXFA_Occur>(XFA_Element::Occur);
if (pOccurNode)
pOccurNode->ClearFlag(XFA_NodeFlag_UnusedNode);
}
@@ -746,8 +757,10 @@ CXFA_Node* CopyContainer_SubformSet(CXFA_Document* pDocument,
int32_t iMax = 1;
int32_t iInit = 1;
int32_t iMin = 1;
- if (!bOneInstance && pOccurNode)
- std::tie(iMin, iMax, iInit) = CXFA_OccurData(pOccurNode).GetOccurInfo();
+ if (!bOneInstance && pOccurNode) {
+ std::tie(iMin, iMax, iInit) =
+ CXFA_OccurData(static_cast<CXFA_Occur*>(pOccurNode)).GetOccurInfo();
+ }
XFA_AttributeEnum eRelation =
eType == XFA_Element::SubformSet
@@ -1090,9 +1103,10 @@ void UpdateBindingRelations(CXFA_Document* pDocument,
if (eType == XFA_Element::Subform || eType == XFA_Element::ExclGroup ||
eType == XFA_Element::Field) {
CXFA_Node* pTemplateNode = pFormNode->GetTemplateNode();
- CXFA_Node* pTemplateNodeBind =
- pTemplateNode ? pTemplateNode->GetFirstChildByClass(XFA_Element::Bind)
- : nullptr;
+ CXFA_Bind* pTemplateNodeBind =
+ pTemplateNode
+ ? pTemplateNode->GetFirstChildByClass<CXFA_Bind>(XFA_Element::Bind)
+ : nullptr;
XFA_AttributeEnum eMatch =
pTemplateNodeBind
? pTemplateNodeBind->JSObject()->GetEnum(XFA_Attribute::Match)
@@ -1431,11 +1445,11 @@ void CXFA_Document::DoDataMerge() {
pDatasetsRoot->InsertChild(pDataRoot, nullptr);
}
- CXFA_Node* pDataTopLevel =
- pDataRoot->GetFirstChildByClass(XFA_Element::DataGroup);
+ CXFA_DataGroup* pDataTopLevel =
+ pDataRoot->GetFirstChildByClass<CXFA_DataGroup>(XFA_Element::DataGroup);
uint32_t dwNameHash = pDataTopLevel ? pDataTopLevel->GetNameHash() : 0;
- CXFA_Node* pTemplateRoot =
- m_pRootNode->GetFirstChildByClass(XFA_Element::Template);
+ CXFA_Template* pTemplateRoot =
+ m_pRootNode->GetFirstChildByClass<CXFA_Template>(XFA_Element::Template);
if (!pTemplateRoot)
return;
@@ -1444,16 +1458,19 @@ void CXFA_Document::DoDataMerge() {
: nullptr;
if (!pTemplateChosen ||
pTemplateChosen->GetElementType() != XFA_Element::Subform) {
- pTemplateChosen = pTemplateRoot->GetFirstChildByClass(XFA_Element::Subform);
+ pTemplateChosen =
+ pTemplateRoot->GetFirstChildByClass<CXFA_Subform>(XFA_Element::Subform);
}
if (!pTemplateChosen)
return;
- CXFA_Node* pFormRoot = m_pRootNode->GetFirstChildByClass(XFA_Element::Form);
+ CXFA_Form* pFormRoot =
+ m_pRootNode->GetFirstChildByClass<CXFA_Form>(XFA_Element::Form);
bool bEmptyForm = false;
if (!pFormRoot) {
bEmptyForm = true;
- pFormRoot = CreateNode(XFA_PacketType::Form, XFA_Element::Form);
+ pFormRoot = static_cast<CXFA_Form*>(
+ CreateNode(XFA_PacketType::Form, XFA_Element::Form));
ASSERT(pFormRoot);
pFormRoot->JSObject()->SetCData(XFA_Attribute::Name, L"form", false, false);
m_pRootNode->InsertChild(pFormRoot, nullptr);
@@ -1476,8 +1493,8 @@ void CXFA_Document::DoDataMerge() {
CFX_XMLElement* pDataTopLevelXMLNode =
new CFX_XMLElement(wsDataTopLevelName);
- pDataTopLevel =
- CreateNode(XFA_PacketType::Datasets, XFA_Element::DataGroup);
+ pDataTopLevel = static_cast<CXFA_DataGroup*>(
+ CreateNode(XFA_PacketType::Datasets, XFA_Element::DataGroup));
pDataTopLevel->JSObject()->SetCData(XFA_Attribute::Name, wsDataTopLevelName,
false, false);
pDataTopLevel->SetXMLMappingNode(pDataTopLevelXMLNode);
@@ -1503,12 +1520,13 @@ void CXFA_Document::DoDataMerge() {
UpdateDataRelation(pDataRoot, pDDRoot);
DataMerge_UpdateBindingRelations(pSubformSetNode);
- CXFA_Node* pPageSetNode =
- pSubformSetNode->GetFirstChildByClass(XFA_Element::PageSet);
+ CXFA_PageSet* pPageSetNode =
+ pSubformSetNode->GetFirstChildByClass<CXFA_PageSet>(XFA_Element::PageSet);
while (pPageSetNode) {
m_pPendingPageSet.push_back(pPageSetNode);
- CXFA_Node* pNextPageSetNode =
- pPageSetNode->GetNextSameClassSibling(XFA_Element::PageSet);
+ CXFA_PageSet* pNextPageSetNode =
+ pPageSetNode->GetNextSameClassSibling<CXFA_PageSet>(
+ XFA_Element::PageSet);
pSubformSetNode->RemoveChild(pPageSetNode, true);
pPageSetNode = pNextPageSetNode;
}