summaryrefslogtreecommitdiff
path: root/xfa/fxfa/parser/cxfa_node.h
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2017-11-01 16:04:36 +0000
committerChromium commit bot <commit-bot@chromium.org>2017-11-01 16:04:36 +0000
commite5434b5531f2c081c1d69f67125b6665070ea969 (patch)
tree1fa141f20597c62e9f2e2738d438bfaaecc772a3 /xfa/fxfa/parser/cxfa_node.h
parent3fff90a670d860a7b0319aa0edf8628917d0a122 (diff)
downloadpdfium-e5434b5531f2c081c1d69f67125b6665070ea969.tar.xz
Split JS code out of CXFA_Node.
This CL moves JS code out of CXFA_Node and places it into fxjs/cjx_node. The CXFA_Node then has a CJX_Node as a member and, currently, proxies JS calls to the CJX_Node member. Change-Id: Ic5b95184c8fd2347f0bdcfbccfa89bb6b52835b6 Reviewed-on: https://pdfium-review.googlesource.com/17290 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'xfa/fxfa/parser/cxfa_node.h')
-rw-r--r--xfa/fxfa/parser/cxfa_node.h218
1 files changed, 36 insertions, 182 deletions
diff --git a/xfa/fxfa/parser/cxfa_node.h b/xfa/fxfa/parser/cxfa_node.h
index 7faed0e38f..6151d738a2 100644
--- a/xfa/fxfa/parser/cxfa_node.h
+++ b/xfa/fxfa/parser/cxfa_node.h
@@ -11,6 +11,7 @@
#include <vector>
#include "core/fxcrt/fx_string.h"
+#include "fxjs/cjx_node.h"
#include "xfa/fxfa/parser/cxfa_object.h"
class CFX_XMLNode;
@@ -34,12 +35,6 @@ enum XFA_NodeFlag {
XFA_NodeFlag_LayoutGeneratedNode = 1 << 8
};
-enum XFA_SOM_MESSAGETYPE {
- XFA_SOM_ValidationMessage,
- XFA_SOM_FormatMessage,
- XFA_SOM_MandatoryMessage
-};
-
enum XFA_NODEITEM {
XFA_NODEITEM_Parent,
XFA_NODEITEM_FirstChild,
@@ -47,35 +42,34 @@ enum XFA_NODEITEM {
XFA_NODEITEM_PrevSibling,
};
-typedef void (*PD_CALLBACK_FREEDATA)(void* pData);
-typedef void (*PD_CALLBACK_DUPLICATEDATA)(void*& pData);
-
-struct XFA_MAPDATABLOCKCALLBACKINFO {
- PD_CALLBACK_FREEDATA pFree;
- PD_CALLBACK_DUPLICATEDATA pCopy;
-};
-
-struct XFA_MAPDATABLOCK {
- uint8_t* GetData() const { return (uint8_t*)this + sizeof(XFA_MAPDATABLOCK); }
- XFA_MAPDATABLOCKCALLBACKINFO* pCallbackInfo;
- int32_t iBytes;
-};
-
-struct XFA_MAPMODULEDATA {
- XFA_MAPMODULEDATA();
- ~XFA_MAPMODULEDATA();
-
- std::map<void*, void*> m_ValueMap;
- std::map<void*, XFA_MAPDATABLOCK*> m_BufferMap;
-};
+const XFA_ATTRIBUTEENUMINFO* GetAttributeEnumByID(XFA_ATTRIBUTEENUM eName);
class CXFA_Node : public CXFA_Object {
public:
+ ~CXFA_Node() override;
+
uint32_t GetPacketID() const { return m_ePacket; }
void SetFlag(uint32_t dwFlag, bool bNotify);
void ClearFlag(uint32_t dwFlag);
+ CJX_Node* JSNode() { return &m_JSNode; }
+ const CJX_Node* JSNode() const { return &m_JSNode; }
+ CXFA_Node* GetParent() { return m_pParent; }
+ CXFA_Node* GetChildNode() { return m_pChild; }
+
+ CXFA_Node* CreateInstance(CXFA_Node* pInstMgrNode, bool bDataMerge);
+ int32_t GetCount(CXFA_Node* pInstMgrNode);
+ CXFA_Node* GetItem(CXFA_Node* pInstMgrNode, int32_t iIndex);
+ void RemoveItem(CXFA_Node* pInstMgrNode,
+ CXFA_Node* pRemoveInstance,
+ bool bRemoveDataBinding = true);
+ void InsertItem(CXFA_Node* pInstMgrNode,
+ CXFA_Node* pNewInstance,
+ int32_t iPos,
+ int32_t iCount = -1,
+ bool bMoveDataBindingNodes = true);
+
bool IsInitialized() const { return HasFlag(XFA_NodeFlag_Initialized); }
bool IsOwnXMLNode() const { return HasFlag(XFA_NodeFlag_OwnXMLNode); }
bool IsUserInteractive() const {
@@ -103,111 +97,7 @@ class CXFA_Node : public CXFA_Object {
bool IsUnnamed() const { return m_dwNameHash == 0; }
CXFA_Node* GetModelNode();
void UpdateNameHash();
- bool HasAttribute(XFA_ATTRIBUTE eAttr, bool bCanInherit = false);
- bool SetAttribute(XFA_ATTRIBUTE eAttr,
- const WideStringView& wsValue,
- bool bNotify = false);
- bool GetAttribute(XFA_ATTRIBUTE eAttr,
- WideString& wsValue,
- bool bUseDefault = true);
- bool SetAttribute(const WideStringView& wsAttr,
- const WideStringView& wsValue,
- bool bNotify = false);
- bool GetAttribute(const WideStringView& wsAttr,
- WideString& wsValue,
- bool bUseDefault = true);
- bool RemoveAttribute(const WideStringView& wsAttr);
- bool SetContent(const WideString& wsContent,
- const WideString& wsXMLValue,
- bool bNotify = false,
- bool bScriptModify = false,
- bool bSyncData = true);
- bool TryContent(WideString& wsContent,
- bool bScriptModify = false,
- bool bProto = true);
- WideString GetContent();
-
- bool TryNamespace(WideString& wsNamespace);
- bool SetBoolean(XFA_ATTRIBUTE eAttr, bool bValue, bool bNotify = false) {
- return SetValue(eAttr, XFA_ATTRIBUTETYPE_Boolean, (void*)(uintptr_t)bValue,
- bNotify);
- }
- bool TryBoolean(XFA_ATTRIBUTE eAttr, bool& bValue, bool bUseDefault = true);
- bool GetBoolean(XFA_ATTRIBUTE eAttr) {
- bool bValue;
- return TryBoolean(eAttr, bValue, true) ? bValue : false;
- }
- bool SetInteger(XFA_ATTRIBUTE eAttr, int32_t iValue, bool bNotify = false) {
- return SetValue(eAttr, XFA_ATTRIBUTETYPE_Integer, (void*)(uintptr_t)iValue,
- bNotify);
- }
- bool TryInteger(XFA_ATTRIBUTE eAttr,
- int32_t& iValue,
- bool bUseDefault = true);
- int32_t GetInteger(XFA_ATTRIBUTE eAttr) {
- int32_t iValue;
- return TryInteger(eAttr, iValue, true) ? iValue : 0;
- }
- bool SetEnum(XFA_ATTRIBUTE eAttr,
- XFA_ATTRIBUTEENUM eValue,
- bool bNotify = false) {
- return SetValue(eAttr, XFA_ATTRIBUTETYPE_Enum, (void*)(uintptr_t)eValue,
- bNotify);
- }
- bool TryEnum(XFA_ATTRIBUTE eAttr,
- XFA_ATTRIBUTEENUM& eValue,
- bool bUseDefault = true);
- XFA_ATTRIBUTEENUM GetEnum(XFA_ATTRIBUTE eAttr) {
- XFA_ATTRIBUTEENUM eValue;
- return TryEnum(eAttr, eValue, true) ? eValue : XFA_ATTRIBUTEENUM_Unknown;
- }
- bool SetCData(XFA_ATTRIBUTE eAttr,
- const WideString& wsValue,
- bool bNotify = false,
- bool bScriptModify = false);
- bool SetAttributeValue(const WideString& wsValue,
- const WideString& wsXMLValue,
- bool bNotify = false,
- bool bScriptModify = false);
- bool TryCData(XFA_ATTRIBUTE eAttr,
- WideString& wsValue,
- bool bUseDefault = true,
- bool bProto = true);
- bool TryCData(XFA_ATTRIBUTE eAttr,
- WideStringView& wsValue,
- bool bUseDefault = true,
- bool bProto = true);
- WideStringView GetCData(XFA_ATTRIBUTE eAttr) {
- WideStringView wsValue;
- return TryCData(eAttr, wsValue) ? wsValue : WideStringView();
- }
- bool SetMeasure(XFA_ATTRIBUTE eAttr,
- CXFA_Measurement mValue,
- bool bNotify = false);
- bool TryMeasure(XFA_ATTRIBUTE eAttr,
- CXFA_Measurement& mValue,
- bool bUseDefault = true) const;
- CXFA_Measurement GetMeasure(XFA_ATTRIBUTE eAttr) const;
- bool SetObject(XFA_ATTRIBUTE eAttr,
- void* pData,
- XFA_MAPDATABLOCKCALLBACKINFO* pCallbackInfo = nullptr);
- bool TryObject(XFA_ATTRIBUTE eAttr, void*& pData);
- void* GetObject(XFA_ATTRIBUTE eAttr) {
- void* pData;
- return TryObject(eAttr, pData) ? pData : nullptr;
- }
- bool SetUserData(void* pKey,
- void* pData,
- XFA_MAPDATABLOCKCALLBACKINFO* pCallbackInfo = nullptr);
- bool TryUserData(void* pKey, void*& pData, bool bProtoAlso = false);
- void* GetUserData(void* pKey, bool bProtoAlso = false) {
- void* pData;
- return TryUserData(pKey, pData, bProtoAlso) ? pData : nullptr;
- }
- CXFA_Node* GetProperty(int32_t index,
- XFA_Element eType,
- bool bCreateProperty = true);
int32_t CountChildren(XFA_Element eType, bool bOnlyChild = false);
CXFA_Node* GetChild(int32_t index,
XFA_Element eType,
@@ -250,6 +140,14 @@ class CXFA_Node : public CXFA_Object {
CXFA_Node* GetInstanceMgrOfSubform();
CXFA_Node* GetOccurNode();
+
+ int32_t Subform_and_SubformSet_InstanceIndex();
+ int32_t InstanceManager_SetInstances(int32_t iCount);
+ int32_t InstanceManager_MoveInstance(int32_t iTo, int32_t iFrom);
+
+ void OnChanged(XFA_ATTRIBUTE eAttr, bool bNotify, bool bScriptModify);
+ void OnChanging(XFA_ATTRIBUTE eAttr, bool bNotify);
+
void Script_TreeClass_ResolveNode(CFXJSE_Arguments* pArguments);
void Script_TreeClass_ResolveNodes(CFXJSE_Arguments* pArguments);
void Script_Som_ResolveNodeList(CFXJSE_Value* pValue,
@@ -447,7 +345,6 @@ class CXFA_Node : public CXFA_Object {
void Script_Subform_ExecValidate(CFXJSE_Arguments* pArguments);
void Script_Subform_GetInvalidObjects(CFXJSE_Arguments* pArguments);
- int32_t Subform_and_SubformSet_InstanceIndex();
void Script_Template_FormNodes(CFXJSE_Arguments* pArguments);
void Script_Template_Remerge(CFXJSE_Arguments* pArguments);
void Script_Template_ExecInitialize(CFXJSE_Arguments* pArguments);
@@ -470,8 +367,7 @@ class CXFA_Node : public CXFA_Object {
void Script_InstanceManager_SetInstances(CFXJSE_Arguments* pArguments);
void Script_InstanceManager_AddInstance(CFXJSE_Arguments* pArguments);
void Script_InstanceManager_InsertInstance(CFXJSE_Arguments* pArguments);
- int32_t InstanceManager_SetInstances(int32_t iCount);
- int32_t InstanceManager_MoveInstance(int32_t iTo, int32_t iFrom);
+
void Script_Occur_Max(CFXJSE_Value* pValue,
bool bSetting,
XFA_ATTRIBUTE eAttribute);
@@ -533,6 +429,10 @@ class CXFA_Node : public CXFA_Object {
bool bSetting,
XFA_ATTRIBUTE eAttribute);
+ void ThrowMissingPropertyException(const WideString& obj,
+ const WideString& prop) const;
+ void ThrowTooManyOccurancesException(const WideString& obj) const;
+
private:
friend class CXFA_Document;
@@ -541,52 +441,11 @@ class CXFA_Node : public CXFA_Object {
XFA_ObjectType oType,
XFA_Element eType,
const WideStringView& elementName);
- ~CXFA_Node() override;
bool HasFlag(XFA_NodeFlag dwFlag) const;
CXFA_Node* Deprecated_GetPrevSibling();
- bool SetValue(XFA_ATTRIBUTE eAttr,
- XFA_ATTRIBUTETYPE eType,
- void* pValue,
- bool bNotify);
- bool GetValue(XFA_ATTRIBUTE eAttr,
- XFA_ATTRIBUTETYPE eType,
- bool bUseDefault,
- void*& pValue);
+
void OnRemoved(bool bNotify);
- void OnChanging(XFA_ATTRIBUTE eAttr, bool bNotify);
- void OnChanged(XFA_ATTRIBUTE eAttr, bool bNotify, bool bScriptModify);
- int32_t execSingleEventByName(const WideStringView& wsEventName,
- XFA_Element eType);
- bool SetScriptContent(const WideString& wsContent,
- const WideString& wsXMLValue,
- bool bNotify = true,
- bool bScriptModify = false,
- bool bSyncData = true);
- WideString GetScriptContent(bool bScriptModify = false);
- XFA_MAPMODULEDATA* CreateMapModuleData();
- XFA_MAPMODULEDATA* GetMapModuleData() const;
- void SetMapModuleValue(void* pKey, void* pValue);
- bool GetMapModuleValue(void* pKey, void*& pValue);
- void SetMapModuleString(void* pKey, const WideStringView& wsValue);
- bool GetMapModuleString(void* pKey, WideStringView& wsValue);
- void SetMapModuleBuffer(
- void* pKey,
- void* pValue,
- int32_t iBytes,
- XFA_MAPDATABLOCKCALLBACKINFO* pCallbackInfo = nullptr);
- bool GetMapModuleBuffer(void* pKey,
- void*& pValue,
- int32_t& iBytes,
- bool bProtoAlso = true) const;
- bool HasMapModuleKey(void* pKey, bool bProtoAlso = false);
- void RemoveMapModuleKey(void* pKey = nullptr);
- void MergeAllData(void* pDstModule);
- void MoveBufferMapData(CXFA_Node* pDstModule, void* pKey);
- void MoveBufferMapData(CXFA_Node* pSrcModule,
- CXFA_Node* pDstModule,
- void* pKey,
- bool bRecursive = false);
CXFA_Node* m_pNext;
CXFA_Node* m_pChild;
@@ -597,12 +456,7 @@ class CXFA_Node : public CXFA_Object {
uint16_t m_uNodeFlags;
uint32_t m_dwNameHash;
CXFA_Node* m_pAuxNode;
- XFA_MAPMODULEDATA* m_pMapModuleData;
-
- private:
- void ThrowMissingPropertyException(const WideString& obj,
- const WideString& prop) const;
- void ThrowTooManyOccurancesException(const WideString& obj) const;
+ CJX_Node m_JSNode;
};
#endif // XFA_FXFA_PARSER_CXFA_NODE_H_