summaryrefslogtreecommitdiff
path: root/fxjs/cjx_node.cpp
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2017-11-30 21:29:11 +0000
committerChromium commit bot <commit-bot@chromium.org>2017-11-30 21:29:11 +0000
commitc40c5aa2d7f1753dd382c35955deafdaca660020 (patch)
treeb427f5516046d40b8dd63f8c7a552fac0bf278ae /fxjs/cjx_node.cpp
parent9daec60824d085db8c2f841fd389c725df1f8b0b (diff)
downloadpdfium-c40c5aa2d7f1753dd382c35955deafdaca660020.tar.xz
A CXFA_Node can only be in one packet
When a CXFA_Node is created it's created as part of a specific packet. Previously the code would accept an XFA_XDPPACKET which was stored internally. This had the potential to allow a node to exist in multiple packets. This CL changes the XFA_XDPPacket to the XFA_PacketType enum class and cleans up a lot of uses to use the more specific packet type. Change-Id: I7fc8c843bfa6bd32295ae58a26bcec311e43c4b0 Reviewed-on: https://pdfium-review.googlesource.com/20012 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'fxjs/cjx_node.cpp')
-rw-r--r--fxjs/cjx_node.cpp32
1 files changed, 16 insertions, 16 deletions
diff --git a/fxjs/cjx_node.cpp b/fxjs/cjx_node.cpp
index cdf89848f8..52cf1d90f2 100644
--- a/fxjs/cjx_node.cpp
+++ b/fxjs/cjx_node.cpp
@@ -777,7 +777,7 @@ void CJX_Node::Script_NodeClass_LoadXML(CFXJSE_Arguments* pArguments) {
pChild = pItem;
}
- if (GetXFANode()->GetPacketID() == XFA_XDPPACKET_Form &&
+ if (GetXFANode()->GetPacketType() == XFA_PacketType::Form &&
GetXFANode()->GetElementType() == XFA_Element::ExData) {
CFX_XMLNode* pTempXMLNode = GetXFANode()->GetXMLMappingNode();
GetXFANode()->SetXMLMappingNode(pFakeXMLRoot.release());
@@ -825,14 +825,14 @@ void CJX_Node::Script_NodeClass_SaveXML(CFXJSE_Arguments* pArguments) {
// TODO(weili): Check whether we need to save pretty print XML, pdfium:501.
WideString bsXMLHeader = L"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
- if (GetXFANode()->GetPacketID() != XFA_XDPPACKET_Form &&
- GetXFANode()->GetPacketID() != XFA_XDPPACKET_Datasets) {
+ if (GetXFANode()->GetPacketType() != XFA_PacketType::Form &&
+ GetXFANode()->GetPacketType() != XFA_PacketType::Datasets) {
pArguments->GetReturnValue()->SetString("");
return;
}
CFX_XMLNode* pElement = nullptr;
- if (GetXFANode()->GetPacketID() == XFA_XDPPACKET_Datasets) {
+ if (GetXFANode()->GetPacketType() == XFA_PacketType::Datasets) {
pElement = GetXFANode()->GetXMLMappingNode();
if (!pElement || pElement->GetType() != FX_XMLNODE_Element) {
pArguments->GetReturnValue()->SetString(
@@ -848,7 +848,7 @@ void CJX_Node::Script_NodeClass_SaveXML(CFXJSE_Arguments* pArguments) {
pStream->SetCodePage(FX_CODEPAGE_UTF8);
pStream->WriteString(bsXMLHeader.AsStringView());
- if (GetXFANode()->GetPacketID() == XFA_XDPPACKET_Form)
+ if (GetXFANode()->GetPacketType() == XFA_PacketType::Form)
XFA_DataExporter_RegenerateFormFile(GetXFANode(), pStream, nullptr, true);
else
pElement->SaveXMLNode(pStream);
@@ -1053,7 +1053,7 @@ void CJX_Node::SendAttributeChangeMessage(XFA_Attribute eAttribute,
if (!pNotify)
return;
- if (!(GetXFANode()->GetPacketID() & XFA_XDPPACKET_Form)) {
+ if (GetXFANode()->GetPacketType() != XFA_PacketType::Form) {
pNotify->OnValueChanged(GetXFANode(), eAttribute, GetXFANode(),
GetXFANode());
return;
@@ -1405,7 +1405,7 @@ void CJX_Node::Script_Som_DefaultValue(CFXJSE_Value* pValue,
WideString wsFormatValue(wsNewValue);
CXFA_WidgetData* pContainerWidgetData = nullptr;
- if (GetXFANode()->GetPacketID() == XFA_XDPPACKET_Datasets) {
+ if (GetXFANode()->GetPacketType() == XFA_PacketType::Datasets) {
WideString wsPicture;
for (const auto& pFormNode : *(GetXFANode()->GetBindItems())) {
if (!pFormNode || pFormNode->HasRemovedChildren())
@@ -1421,7 +1421,7 @@ void CJX_Node::Script_Som_DefaultValue(CFXJSE_Value* pValue,
pContainerWidgetData = nullptr;
}
- } else if (GetXFANode()->GetPacketID() == XFA_XDPPACKET_Form) {
+ } else if (GetXFANode()->GetPacketType() == XFA_PacketType::Form) {
pContainerWidgetData = GetXFANode()->GetContainerWidgetData();
}
@@ -2358,7 +2358,7 @@ void CJX_Node::Script_Template_CreateNode(CFXJSE_Arguments* pArguments) {
pNewNode->JSNode()->SetAttribute(XFA_Attribute::Name, strName.AsStringView(),
true);
- if (pNewNode->GetPacketID() == XFA_XDPPACKET_Datasets)
+ if (pNewNode->GetPacketType() == XFA_PacketType::Datasets)
pNewNode->CreateXMLMappingNode();
pArguments->GetReturnValue()->Assign(
@@ -3084,7 +3084,7 @@ bool CJX_Node::SetCData(XFA_Attribute eAttr,
wsValue);
} else {
bool bDeleteChildren = true;
- if (GetXFANode()->GetPacketID() == XFA_XDPPACKET_Datasets) {
+ if (GetXFANode()->GetPacketType() == XFA_PacketType::Datasets) {
for (CXFA_Node* pChildDataNode =
GetXFANode()->GetNodeItem(XFA_NODEITEM_FirstChild);
pChildDataNode; pChildDataNode = pChildDataNode->GetNodeItem(
@@ -3142,7 +3142,7 @@ void CJX_Node::SetAttributeValue(const WideString& wsValue,
wsXMLValue);
} else {
bool bDeleteChildren = true;
- if (GetXFANode()->GetPacketID() == XFA_XDPPACKET_Datasets) {
+ if (GetXFANode()->GetPacketType() == XFA_PacketType::Datasets) {
for (CXFA_Node* pChildDataNode =
GetXFANode()->GetNodeItem(XFA_NODEITEM_FirstChild);
pChildDataNode; pChildDataNode = pChildDataNode->GetNodeItem(
@@ -3373,7 +3373,7 @@ bool CJX_Node::SetContent(const WideString& wsContent,
break;
case XFA_ObjectType::NodeV:
pNode = GetXFANode();
- if (bSyncData && GetXFANode()->GetPacketID() == XFA_XDPPACKET_Form) {
+ if (bSyncData && GetXFANode()->GetPacketType() == XFA_PacketType::Form) {
CXFA_Node* pParent = GetXFANode()->GetNodeItem(XFA_NODEITEM_Parent);
if (pParent) {
pParent = pParent->GetNodeItem(XFA_NODEITEM_Parent);
@@ -3499,7 +3499,7 @@ pdfium::Optional<WideString> CJX_Node::TryNamespace() {
return {static_cast<CFX_XMLElement*>(pXMLNode)->GetNamespaceURI()};
}
- if (GetXFANode()->GetPacketID() != XFA_XDPPACKET_Datasets)
+ if (GetXFANode()->GetPacketType() != XFA_PacketType::Datasets)
return GetXFANode()->GetModelNode()->JSNode()->TryNamespace();
CFX_XMLNode* pXMLNode = GetXFANode()->GetXMLMappingNode();
@@ -3550,7 +3550,7 @@ CXFA_Node* CJX_Node::GetProperty(int32_t index,
CXFA_Node* pNewNode = nullptr;
for (; iCount <= index; ++iCount) {
pNewNode =
- GetDocument()->CreateNode(GetXFANode()->GetPacketID(), eProperty);
+ GetDocument()->CreateNode(GetXFANode()->GetPacketType(), eProperty);
if (!pNewNode)
return nullptr;
GetXFANode()->InsertChild(pNewNode, nullptr);
@@ -3584,7 +3584,7 @@ bool CJX_Node::GetMapModuleValue(void* pKey, void*& pValue) {
return true;
}
}
- if (pNode->GetPacketID() == XFA_XDPPACKET_Datasets)
+ if (pNode->GetPacketType() == XFA_PacketType::Datasets)
break;
}
return false;
@@ -3648,7 +3648,7 @@ bool CJX_Node::GetMapModuleBuffer(void* pKey,
break;
}
}
- if (!bProtoAlso || pNode->GetPacketID() == XFA_XDPPACKET_Datasets)
+ if (!bProtoAlso || pNode->GetPacketType() == XFA_PacketType::Datasets)
break;
}
if (!pBuffer)