summaryrefslogtreecommitdiff
path: root/xfa
diff options
context:
space:
mode:
authordsinclair <dsinclair@chromium.org>2016-07-19 10:27:12 -0700
committerCommit bot <commit-bot@chromium.org>2016-07-19 10:27:12 -0700
commiteea31b75a11215aa72a9845d47c38d2ce1edd4f7 (patch)
treef6ef06a0c323a0a842981da595144fc8d2085d86 /xfa
parent3617751cea45fd636d58f535a662337fcea40c4a (diff)
downloadpdfium-chromium/2803.tar.xz
Cleanup CXFA_Documentchromium/2803chromium/2802
Removing unused XFA_LAYOUTRESULT, cleanup unused parameters, convert XFA_DocFlag to an enum from defines and make the constructor explicit. Review-Url: https://codereview.chromium.org/2166433002
Diffstat (limited to 'xfa')
-rw-r--r--xfa/fxfa/app/xfa_ffnotify.cpp11
-rw-r--r--xfa/fxfa/parser/xfa_document.h73
-rw-r--r--xfa/fxfa/parser/xfa_document_datamerger_imp.cpp17
-rw-r--r--xfa/fxfa/parser/xfa_layout_pagemgr_new.cpp13
-rw-r--r--xfa/fxfa/parser/xfa_object_imp.cpp2
5 files changed, 61 insertions, 55 deletions
diff --git a/xfa/fxfa/app/xfa_ffnotify.cpp b/xfa/fxfa/app/xfa_ffnotify.cpp
index be8268a9d4..09003f023c 100644
--- a/xfa/fxfa/app/xfa_ffnotify.cpp
+++ b/xfa/fxfa/app/xfa_ffnotify.cpp
@@ -174,20 +174,19 @@ void CXFA_FFNotify::StartFieldDrawLayout(CXFA_Node* pItem,
FX_FLOAT& fCalcWidth,
FX_FLOAT& fCalcHeight) {
CXFA_WidgetAcc* pAcc = static_cast<CXFA_WidgetAcc*>(pItem->GetWidgetData());
- if (!pAcc) {
+ if (!pAcc)
return;
- }
+
pAcc->StartWidgetLayout(fCalcWidth, fCalcHeight);
}
+
FX_BOOL CXFA_FFNotify::FindSplitPos(CXFA_Node* pItem,
int32_t iBlockIndex,
FX_FLOAT& fCalcHeightPos) {
CXFA_WidgetAcc* pAcc = static_cast<CXFA_WidgetAcc*>(pItem->GetWidgetData());
- if (!pAcc) {
- return FALSE;
- }
- return (XFA_LAYOUTRESULT)pAcc->FindSplitPos(iBlockIndex, fCalcHeightPos);
+ return pAcc && pAcc->FindSplitPos(iBlockIndex, fCalcHeightPos);
}
+
FX_BOOL CXFA_FFNotify::RunScript(CXFA_Node* pScript, CXFA_Node* pFormItem) {
FX_BOOL bRet = FALSE;
CXFA_FFDocView* pDocView = m_pDoc->GetDocView();
diff --git a/xfa/fxfa/parser/xfa_document.h b/xfa/fxfa/parser/xfa_document.h
index 176f0c7b98..fbc027a8d4 100644
--- a/xfa/fxfa/parser/xfa_document.h
+++ b/xfa/fxfa/parser/xfa_document.h
@@ -11,17 +11,6 @@
#include "xfa/fxfa/parser/xfa_localemgr.h"
#include "xfa/fxfa/parser/xfa_object.h"
-class CFDE_XMLDoc;
-class CXFA_Document;
-class CXFA_LayoutItem;
-class CXFA_LayoutProcessor;
-class CXFA_Node;
-class CXFA_LayoutProcessor;
-class CXFA_DocumentParser;
-class CXFA_ContainerLayoutItem;
-class CXFA_FFNotify;
-class CXFA_ScriptContext;
-
enum XFA_VERSION {
XFA_VERSION_UNKNOWN = 0,
XFA_VERSION_200 = 200,
@@ -40,69 +29,84 @@ enum XFA_VERSION {
XFA_VERSION_MAX = 400,
};
-enum XFA_LAYOUTRESULT {
- XFA_LAYOUTRESULT_Continue,
- XFA_LAYOUTRESULT_Done,
- XFA_LAYOUTRESULT_NextContent,
+enum XFA_DocFlag {
+ XFA_DOCFLAG_StrictScoping = 0x0001,
+ XFA_DOCFLAG_HasInteractive = 0x0002,
+ XFA_DOCFLAG_Interactive = 0x0004,
+ XFA_DOCFLAG_Scripting = 0x0008
};
-#define XFA_LAYOUTNOTIFY_StrictHeight 0x0001
-#define XFA_LAYOUTNOTIFY_NoParentBreak 0x0002
-#define XFA_DOCFLAG_StrictScoping 0x0001
-#define XFA_DOCFLAG_HasInteractive 0x0002
-#define XFA_DOCFLAG_Interactive 0x0004
-#define XFA_DOCFLAG_Scripting 0x0008
+class CFDE_XMLDoc;
class CScript_DataWindow;
class CScript_EventPseudoModel;
class CScript_HostPseudoModel;
class CScript_LogPseudoModel;
class CScript_LayoutPseudoModel;
class CScript_SignaturePseudoModel;
+class CXFA_Document;
+class CXFA_LayoutItem;
+class CXFA_LayoutProcessor;
+class CXFA_Node;
+class CXFA_LayoutProcessor;
+class CXFA_DocumentParser;
+class CXFA_ContainerLayoutItem;
+class CXFA_FFNotify;
+class CXFA_ScriptContext;
class CXFA_Document {
public:
- CXFA_Document(CXFA_DocumentParser* pParser);
+ explicit CXFA_Document(CXFA_DocumentParser* pParser);
~CXFA_Document();
+ CXFA_ScriptContext* InitScriptContext(v8::Isolate* pIsolate);
+
CXFA_Node* GetRoot() const { return m_pRootNode; }
CFDE_XMLDoc* GetXMLDoc() const;
CXFA_FFNotify* GetNotify() const;
- void SetRoot(CXFA_Node* pNewRoot);
+ CXFA_LocaleMgr* GetLocalMgr();
CXFA_Object* GetXFAObject(XFA_HashCode wsNodeNameHash);
+ CXFA_Node* GetNodeByID(CXFA_Node* pRoot, const CFX_WideStringC& wsID);
+ CXFA_Node* GetNotBindNode(CXFA_ObjArray& arrayNodes);
+ CXFA_LayoutProcessor* GetLayoutProcessor();
+ CXFA_LayoutProcessor* GetDocLayout();
+ CXFA_ScriptContext* GetScriptContext();
+
+ void SetRoot(CXFA_Node* pNewRoot);
+
void AddPurgeNode(CXFA_Node* pNode);
FX_BOOL RemovePurgeNode(CXFA_Node* pNode);
void PurgeNodes();
+
bool HasFlag(uint32_t dwFlag) { return (m_dwDocFlags & dwFlag) == dwFlag; }
- void SetFlag(uint32_t dwFlag, FX_BOOL bOn = TRUE);
+ void SetFlag(uint32_t dwFlag, FX_BOOL bOn);
+
FX_BOOL IsInteractive();
XFA_VERSION GetCurVersionMode() { return m_eCurVersionMode; }
XFA_VERSION RecognizeXFAVersionNumber(CFX_WideString& wsTemplateNS);
- CXFA_LocaleMgr* GetLocalMgr();
+
CXFA_Node* CreateNode(uint32_t dwPacket, XFA_Element eElement);
CXFA_Node* CreateNode(const XFA_PACKETINFO* pPacket, XFA_Element eElement);
+
void DoProtoMerge();
- CXFA_Node* GetNodeByID(CXFA_Node* pRoot, const CFX_WideStringC& wsID);
void DoDataMerge();
void DoDataRemerge(FX_BOOL bDoDataMerge);
CXFA_Node* DataMerge_CopyContainer(CXFA_Node* pTemplateNode,
CXFA_Node* pFormNode,
CXFA_Node* pDataScope,
- FX_BOOL bOneInstance = FALSE,
- FX_BOOL bDataMerge = TRUE,
- FX_BOOL bUpLevel = TRUE);
+ FX_BOOL bOneInstance,
+ FX_BOOL bDataMerge,
+ FX_BOOL bUpLevel);
void DataMerge_UpdateBindingRelations(CXFA_Node* pFormUpdateRoot);
- CXFA_Node* GetNotBindNode(CXFA_ObjArray& arrayNodes);
- CXFA_LayoutProcessor* GetLayoutProcessor();
- CXFA_LayoutProcessor* GetDocLayout();
- CXFA_ScriptContext* InitScriptContext(v8::Isolate* pIsolate);
- CXFA_ScriptContext* GetScriptContext();
+
void ClearLayoutData();
CFX_MapPtrTemplate<uint32_t, CXFA_Node*> m_rgGlobalBinding;
CXFA_NodeArray m_pPendingPageSet;
protected:
+ friend class CXFA_SimpleParser;
+
CXFA_DocumentParser* m_pParser;
CXFA_ScriptContext* m_pScriptContext;
CXFA_LayoutProcessor* m_pLayoutProcessor;
@@ -117,7 +121,6 @@ class CXFA_Document {
CXFA_NodeSet m_PurgeNodes;
XFA_VERSION m_eCurVersionMode;
uint32_t m_dwDocFlags;
- friend class CXFA_SimpleParser;
};
#endif // XFA_FXFA_PARSER_XFA_DOCUMENT_H_
diff --git a/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp b/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp
index 55718e2c88..06bd0dc557 100644
--- a/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp
+++ b/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp
@@ -855,7 +855,8 @@ CXFA_Node* CopyContainer_SubformSet(CXFA_Document* pDocument,
ASSERT(rgItemMatchList.GetSize());
SortRecurseRecord(rgItemMatchList, pDataScope, TRUE);
pDocument->DataMerge_CopyContainer(
- rgItemMatchList[0].pTemplateChild, pSubformSetNode, pDataScope);
+ rgItemMatchList[0].pTemplateChild, pSubformSetNode, pDataScope,
+ FALSE, TRUE, TRUE);
break;
}
case XFA_ATTRIBUTEENUM_Unordered: {
@@ -865,13 +866,14 @@ CXFA_Node* CopyContainer_SubformSet(CXFA_Document* pDocument,
i++) {
pDocument->DataMerge_CopyContainer(
rgItemMatchList[i].pTemplateChild, pSubformSetNode,
- pDataScope);
+ pDataScope, FALSE, TRUE, TRUE);
}
}
for (int32_t i = 0, count = rgItemUnmatchList.GetSize(); i < count;
i++) {
pDocument->DataMerge_CopyContainer(rgItemUnmatchList[i],
- pSubformSetNode, pDataScope);
+ pSubformSetNode, pDataScope,
+ FALSE, TRUE, TRUE);
}
break;
}
@@ -894,7 +896,7 @@ CXFA_Node* CopyContainer_SubformSet(CXFA_Document* pDocument,
pTemplateChild, TRUE, nullptr);
} else if (pTemplateChild->IsContainerNode()) {
pDocument->DataMerge_CopyContainer(pTemplateChild, pSubformSetNode,
- pDataScope);
+ pDataScope, FALSE, TRUE, TRUE);
}
}
}
@@ -935,7 +937,7 @@ CXFA_Node* CopyContainer_SubformSet(CXFA_Document* pDocument,
pTemplateChild, TRUE, nullptr);
} else if (pTemplateChild->IsContainerNode()) {
pDocument->DataMerge_CopyContainer(pTemplateChild, pSubformNode,
- pDataScope);
+ pDataScope, FALSE, TRUE, TRUE);
}
}
}
@@ -963,7 +965,7 @@ CXFA_Node* CopyContainer_SubformSet(CXFA_Document* pDocument,
continue;
pDocument->DataMerge_CopyContainer(pTemplateChild, pSubformSetNode,
- pDataScope, FALSE, bDataMerge);
+ pDataScope, FALSE, bDataMerge, TRUE);
bFound = TRUE;
}
}
@@ -1470,7 +1472,8 @@ void CXFA_Document::DoDataMerge() {
XFA_NodeMerge_CloneOrMergeContainer(this, pSubformSetNode, pTemplateChild,
TRUE, nullptr);
} else if (pTemplateChild->IsContainerNode()) {
- DataMerge_CopyContainer(pTemplateChild, pSubformSetNode, pDataTopLevel);
+ DataMerge_CopyContainer(pTemplateChild, pSubformSetNode, pDataTopLevel,
+ FALSE, TRUE, TRUE);
}
}
if (pDDRoot)
diff --git a/xfa/fxfa/parser/xfa_layout_pagemgr_new.cpp b/xfa/fxfa/parser/xfa_layout_pagemgr_new.cpp
index 5055000a6b..7ddb759363 100644
--- a/xfa/fxfa/parser/xfa_layout_pagemgr_new.cpp
+++ b/xfa/fxfa/parser/xfa_layout_pagemgr_new.cpp
@@ -849,7 +849,7 @@ FX_BOOL CXFA_LayoutPageMgr::ProcessBreakBeforeOrAfter(
pDataScope = XFA_DataMerge_FindDataScope(pFormNode);
}
pBreakLeaderNode = pDocument->DataMerge_CopyContainer(
- pLeaderTemplate, pFormNode, pDataScope, TRUE);
+ pLeaderTemplate, pFormNode, pDataScope, TRUE, TRUE, TRUE);
pDocument->DataMerge_UpdateBindingRelations(pBreakLeaderNode);
SetLayoutGeneratedNodeFlag(pBreakLeaderNode);
}
@@ -858,7 +858,7 @@ FX_BOOL CXFA_LayoutPageMgr::ProcessBreakBeforeOrAfter(
pDataScope = XFA_DataMerge_FindDataScope(pFormNode);
}
pBreakTrailerNode = pDocument->DataMerge_CopyContainer(
- pTrailerTemplate, pFormNode, pDataScope, TRUE);
+ pTrailerTemplate, pFormNode, pDataScope, TRUE, TRUE, TRUE);
pDocument->DataMerge_UpdateBindingRelations(pBreakTrailerNode);
SetLayoutGeneratedNodeFlag(pBreakTrailerNode);
}
@@ -881,7 +881,7 @@ FX_BOOL CXFA_LayoutPageMgr::ProcessBookendLeaderOrTrailer(
pDataScope = XFA_DataMerge_FindDataScope(pFormNode);
}
pBookendAppendNode = pDocument->DataMerge_CopyContainer(
- pLeaderTemplate, pFormNode, pDataScope, TRUE);
+ pLeaderTemplate, pFormNode, pDataScope, TRUE, TRUE, TRUE);
pDocument->DataMerge_UpdateBindingRelations(pBookendAppendNode);
SetLayoutGeneratedNodeFlag(pBookendAppendNode);
return TRUE;
@@ -1003,7 +1003,7 @@ FX_BOOL CXFA_LayoutPageMgr::ProcessOverflow(CXFA_Node* pFormNode,
pDataScope = XFA_DataMerge_FindDataScope(pFormNode);
}
pLeaderNode = pDocument->DataMerge_CopyContainer(
- pLeaderTemplate, pFormNode, pDataScope, TRUE);
+ pLeaderTemplate, pFormNode, pDataScope, TRUE, TRUE, TRUE);
pDocument->DataMerge_UpdateBindingRelations(pLeaderNode);
SetLayoutGeneratedNodeFlag(pLeaderNode);
}
@@ -1012,7 +1012,7 @@ FX_BOOL CXFA_LayoutPageMgr::ProcessOverflow(CXFA_Node* pFormNode,
pDataScope = XFA_DataMerge_FindDataScope(pFormNode);
}
pTrailerNode = pDocument->DataMerge_CopyContainer(
- pTrailerTemplate, pFormNode, pDataScope, TRUE);
+ pTrailerTemplate, pFormNode, pDataScope, TRUE, TRUE, TRUE);
pDocument->DataMerge_UpdateBindingRelations(pTrailerNode);
SetLayoutGeneratedNodeFlag(pTrailerNode);
}
@@ -1742,7 +1742,8 @@ void CXFA_LayoutPageMgr::MergePageSetContents() {
}
pContainerItem->m_pFormNode = pDocument->DataMerge_CopyContainer(
pContainerItem->m_pFormNode, pParentNode,
- ToNode(pDocument->GetXFAObject(XFA_HASHCODE_Record)), TRUE);
+ ToNode(pDocument->GetXFAObject(XFA_HASHCODE_Record)), TRUE, TRUE,
+ TRUE);
} break;
case XFA_Element::ContentArea: {
CXFA_Node* pParentNode = pContainerItem->m_pParent->m_pFormNode;
diff --git a/xfa/fxfa/parser/xfa_object_imp.cpp b/xfa/fxfa/parser/xfa_object_imp.cpp
index de2f804a4c..463247e640 100644
--- a/xfa/fxfa/parser/xfa_object_imp.cpp
+++ b/xfa/fxfa/parser/xfa_object_imp.cpp
@@ -2979,7 +2979,7 @@ static CXFA_Node* XFA_ScriptInstanceManager_CreateInstance(
ASSERT(pDataScope);
}
CXFA_Node* pInstance = pDocument->DataMerge_CopyContainer(
- pTemplateNode, pFormParent, pDataScope, TRUE, bDataMerge);
+ pTemplateNode, pFormParent, pDataScope, TRUE, bDataMerge, TRUE);
if (pInstance) {
pDocument->DataMerge_UpdateBindingRelations(pInstance);
pFormParent->RemoveChild(pInstance);