summaryrefslogtreecommitdiff
path: root/xfa/fxfa/parser/cxfa_simple_parser.cpp
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2017-12-13 18:29:02 +0000
committerChromium commit bot <commit-bot@chromium.org>2017-12-13 18:29:02 +0000
commit2614250d4f11ed02033a7da095a1694ece12ab78 (patch)
treecc41c5770c17ea47537856991fa44cd1e2acfeb8 /xfa/fxfa/parser/cxfa_simple_parser.cpp
parent14768f3264a4cff8ca0096a27e41f1861b2c422b (diff)
downloadpdfium-2614250d4f11ed02033a7da095a1694ece12ab78.tar.xz
Methods are on CJX_Object not CJX_Node now
This CL converts all of the JSNode() to JSObject() calls as all of the original CJX_Node methods have been moved to CJX_Object. This fixes potential bad casts from things like CJX_Content which do not inhert from CJX_Node. Bug: pdfium:793372 Change-Id: I6c7f63a78f3d47bb6bad74faed3fd8c535bf095e Reviewed-on: https://pdfium-review.googlesource.com/21090 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'xfa/fxfa/parser/cxfa_simple_parser.cpp')
-rw-r--r--xfa/fxfa/parser/cxfa_simple_parser.cpp102
1 files changed, 53 insertions, 49 deletions
diff --git a/xfa/fxfa/parser/cxfa_simple_parser.cpp b/xfa/fxfa/parser/cxfa_simple_parser.cpp
index bd3fdf7af1..5c722821cb 100644
--- a/xfa/fxfa/parser/cxfa_simple_parser.cpp
+++ b/xfa/fxfa/parser/cxfa_simple_parser.cpp
@@ -436,12 +436,12 @@ void CXFA_SimpleParser::ConstructXFANode(CXFA_Node* pXFANode,
CFX_XMLElement* child = static_cast<CFX_XMLElement*>(pXMLChild);
WideString wsNodeStr = child->GetLocalTagName();
- pXFAChild->JSNode()->SetCData(XFA_Attribute::Name, wsNodeStr, false,
- false);
+ pXFAChild->JSObject()->SetCData(XFA_Attribute::Name, wsNodeStr, false,
+ false);
WideString wsChildValue = GetPlainTextFromRichText(child);
if (!wsChildValue.IsEmpty())
- pXFAChild->JSNode()->SetCData(XFA_Attribute::Value, wsChildValue,
- false, false);
+ pXFAChild->JSObject()->SetCData(XFA_Attribute::Value, wsChildValue,
+ false, false);
pXFANode->InsertChild(pXFAChild, nullptr);
pXFAChild->SetXMLMappingNode(pXMLChild);
@@ -513,16 +513,16 @@ CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket_XDP(
return nullptr;
m_pRootNode = pXFARootNode;
- pXFARootNode->JSNode()->SetCData(XFA_Attribute::Name, L"xfa", false, false);
+ pXFARootNode->JSObject()->SetCData(XFA_Attribute::Name, L"xfa", false, false);
CFX_XMLElement* pElement = static_cast<CFX_XMLElement*>(pXMLDocumentNode);
for (auto it : pElement->GetAttributes()) {
if (it.first == L"uuid")
- pXFARootNode->JSNode()->SetCData(XFA_Attribute::Uuid, it.second, false,
- false);
+ pXFARootNode->JSObject()->SetCData(XFA_Attribute::Uuid, it.second, false,
+ false);
else if (it.first == L"timeStamp")
- pXFARootNode->JSNode()->SetCData(XFA_Attribute::TimeStamp, it.second,
- false, false);
+ pXFARootNode->JSObject()->SetCData(XFA_Attribute::TimeStamp, it.second,
+ false, false);
}
CFX_XMLNode* pXMLConfigDOMRoot = nullptr;
@@ -637,7 +637,7 @@ CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket_Config(
if (!pNode)
return nullptr;
- pNode->JSNode()->SetCData(XFA_Attribute::Name, packet->name, false, false);
+ pNode->JSObject()->SetCData(XFA_Attribute::Name, packet->name, false, false);
if (!NormalLoader(pNode, pXMLDocumentNode, XFA_PacketType::Config, true))
return nullptr;
@@ -658,7 +658,7 @@ CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket_Template(
if (!pNode)
return nullptr;
- pNode->JSNode()->SetCData(XFA_Attribute::Name, packet->name, false, false);
+ pNode->JSObject()->SetCData(XFA_Attribute::Name, packet->name, false, false);
if (m_bDocumentParser) {
CFX_XMLElement* pXMLDocumentElement =
static_cast<CFX_XMLElement*>(pXMLDocumentNode);
@@ -706,9 +706,9 @@ CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket_Form(
if (!pNode)
return nullptr;
- pNode->JSNode()->SetCData(XFA_Attribute::Name, packet->name, false, false);
- pNode->JSNode()->SetAttribute(XFA_Attribute::Checksum,
- wsChecksum.AsStringView(), false);
+ 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 =
@@ -716,7 +716,7 @@ CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket_Form(
: nullptr;
bool bUseAttribute = true;
if (pTemplateChosen &&
- pTemplateChosen->JSNode()->GetEnum(XFA_Attribute::RestoreState) !=
+ pTemplateChosen->JSObject()->GetEnum(XFA_Attribute::RestoreState) !=
XFA_AttributeEnum::Auto) {
bUseAttribute = false;
}
@@ -738,7 +738,8 @@ CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket_Data(
if (!pNode)
return nullptr;
- pNode->JSNode()->SetCData(XFA_Attribute::Name, packet->name, false, false);
+ pNode->JSObject()->SetCData(XFA_Attribute::Name, packet->name, false,
+ false);
if (!DataLoader(pNode, pDatasetsXMLNode, false))
return nullptr;
@@ -777,7 +778,7 @@ CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket_Data(
}
WideString wsLocalName =
static_cast<CFX_XMLElement*>(pDataXMLNode)->GetLocalTagName();
- pNode->JSNode()->SetCData(XFA_Attribute::Name, wsLocalName, false, false);
+ pNode->JSObject()->SetCData(XFA_Attribute::Name, wsLocalName, false, false);
if (!DataLoader(pNode, pDataXMLNode, true))
return nullptr;
@@ -803,7 +804,7 @@ CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket_LocaleConnectionSourceSet(
if (!pNode)
return nullptr;
- pNode->JSNode()->SetCData(XFA_Attribute::Name, packet->name, false, false);
+ pNode->JSObject()->SetCData(XFA_Attribute::Name, packet->name, false, false);
if (!NormalLoader(pNode, pXMLDocumentNode, packet_type, true))
return nullptr;
@@ -823,7 +824,7 @@ CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket_Xdc(
if (!pNode)
return nullptr;
- pNode->JSNode()->SetCData(XFA_Attribute::Name, packet->name, false, false);
+ pNode->JSObject()->SetCData(XFA_Attribute::Name, packet->name, false, false);
pNode->SetXMLMappingNode(pXMLDocumentNode);
return pNode;
}
@@ -837,7 +838,7 @@ CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket_User(
WideString wsName =
static_cast<CFX_XMLElement*>(pXMLDocumentNode)->GetLocalTagName();
- pNode->JSNode()->SetCData(XFA_Attribute::Name, wsName, false, false);
+ pNode->JSObject()->SetCData(XFA_Attribute::Name, wsName, false, false);
if (!UserPacketLoader(pNode, pXMLDocumentNode))
return nullptr;
@@ -885,8 +886,8 @@ CXFA_Node* CXFA_SimpleParser::NormalLoader(CXFA_Node* pXFANode,
if (!pXFAChild)
return nullptr;
if (ePacketID == XFA_PacketType::Config) {
- pXFAChild->JSNode()->SetAttribute(XFA_Attribute::Name,
- wsTagName.AsStringView(), false);
+ pXFAChild->JSObject()->SetAttribute(XFA_Attribute::Name,
+ wsTagName.AsStringView(), false);
}
bool IsNeedValue = true;
@@ -905,8 +906,8 @@ CXFA_Node* CXFA_SimpleParser::NormalLoader(CXFA_Node* pXFANode,
attr != XFA_Attribute::Save) {
continue;
}
- pXFAChild->JSNode()->SetAttribute(attr, it.second.AsStringView(),
- false);
+ pXFAChild->JSObject()->SetAttribute(attr, it.second.AsStringView(),
+ false);
}
pXFANode->InsertChild(pXFAChild, nullptr);
if (eType == XFA_Element::Validate || eType == XFA_Element::Locale) {
@@ -947,7 +948,7 @@ void CXFA_SimpleParser::ParseContentNode(CXFA_Node* pXFANode,
XFA_Element element = XFA_Element::Sharptext;
if (pXFANode->GetElementType() == XFA_Element::ExData) {
WideString wsContentType =
- pXFANode->JSNode()->GetCData(XFA_Attribute::ContentType);
+ pXFANode->JSObject()->GetCData(XFA_Attribute::ContentType);
if (wsContentType == L"text/html")
element = XFA_Element::SharpxHTML;
else if (wsContentType == L"text/xml")
@@ -989,11 +990,12 @@ void CXFA_SimpleParser::ParseContentNode(CXFA_Node* pXFANode,
CXFA_Node* pContentRawDataNode =
m_pFactory->CreateNode(ePacketID, element);
ASSERT(pContentRawDataNode);
- pContentRawDataNode->JSNode()->SetCData(XFA_Attribute::Value, wsValue,
- false, false);
+ pContentRawDataNode->JSObject()->SetCData(XFA_Attribute::Value, wsValue,
+ false, false);
pXFANode->InsertChild(pContentRawDataNode, nullptr);
} else {
- pXFANode->JSNode()->SetCData(XFA_Attribute::Value, wsValue, false, false);
+ pXFANode->JSObject()->SetCData(XFA_Attribute::Value, wsValue, false,
+ false);
}
}
}
@@ -1059,7 +1061,7 @@ void CXFA_SimpleParser::ParseDataGroup(CXFA_Node* pXFANode,
if (!pXFAChild)
return;
- pXFAChild->JSNode()->SetCData(
+ pXFAChild->JSObject()->SetCData(
XFA_Attribute::Name, pXMLElement->GetLocalTagName(), false, false);
bool bNeedValue = true;
@@ -1084,14 +1086,14 @@ void CXFA_SimpleParser::ParseDataGroup(CXFA_Node* pXFANode,
if (!pXFAMetaData)
return;
- pXFAMetaData->JSNode()->SetCData(XFA_Attribute::Name, wsName, false,
- false);
- pXFAMetaData->JSNode()->SetCData(XFA_Attribute::QualifiedName,
- it.first, false, false);
- pXFAMetaData->JSNode()->SetCData(XFA_Attribute::Value, it.second,
- false, false);
- pXFAMetaData->JSNode()->SetEnum(XFA_Attribute::Contains,
- XFA_AttributeEnum::MetaData, false);
+ pXFAMetaData->JSObject()->SetCData(XFA_Attribute::Name, wsName, false,
+ false);
+ pXFAMetaData->JSObject()->SetCData(XFA_Attribute::QualifiedName,
+ it.first, false, false);
+ pXFAMetaData->JSObject()->SetCData(XFA_Attribute::Value, it.second,
+ false, false);
+ pXFAMetaData->JSObject()->SetEnum(XFA_Attribute::Contains,
+ XFA_AttributeEnum::MetaData, false);
pXFAChild->InsertChild(pXFAMetaData, nullptr);
pXFAMetaData->SetXMLMappingNode(pXMLElement);
pXFAMetaData->SetFlag(XFA_NodeFlag_Initialized, false);
@@ -1123,8 +1125,8 @@ void CXFA_SimpleParser::ParseDataGroup(CXFA_Node* pXFANode,
if (!pXFAChild)
return;
- pXFAChild->JSNode()->SetCData(XFA_Attribute::Value, wsText, false,
- false);
+ pXFAChild->JSObject()->SetCData(XFA_Attribute::Value, wsText, false,
+ false);
pXFANode->InsertChild(pXFAChild, nullptr);
pXFAChild->SetXMLMappingNode(pXMLText);
pXFAChild->SetFlag(XFA_NodeFlag_Initialized, false);
@@ -1173,9 +1175,10 @@ void CXFA_SimpleParser::ParseDataValue(CXFA_Node* pXFANode,
if (!pXFAChild)
return;
- pXFAChild->JSNode()->SetCData(XFA_Attribute::Name, L"", false, false);
- pXFAChild->JSNode()->SetCData(XFA_Attribute::Value, wsCurValue, false,
- false);
+ pXFAChild->JSObject()->SetCData(XFA_Attribute::Name, L"", false,
+ false);
+ pXFAChild->JSObject()->SetCData(XFA_Attribute::Value, wsCurValue,
+ false, false);
pXFANode->InsertChild(pXFAChild, nullptr);
pXFAChild->SetXMLMappingNode(pXMLCurValueNode);
pXFAChild->SetFlag(XFA_NodeFlag_Initialized, false);
@@ -1191,14 +1194,14 @@ void CXFA_SimpleParser::ParseDataValue(CXFA_Node* pXFANode,
WideString wsNodeStr =
static_cast<CFX_XMLElement*>(pXMLChild)->GetLocalTagName();
- pXFAChild->JSNode()->SetCData(XFA_Attribute::Name, wsNodeStr, false,
- false);
+ pXFAChild->JSObject()->SetCData(XFA_Attribute::Name, wsNodeStr, false,
+ false);
ParseDataValue(pXFAChild, pXMLChild, ePacketID);
pXFANode->InsertChild(pXFAChild, nullptr);
pXFAChild->SetXMLMappingNode(pXMLChild);
pXFAChild->SetFlag(XFA_NodeFlag_Initialized, false);
WideString wsCurValue =
- pXFAChild->JSNode()->GetCData(XFA_Attribute::Value);
+ pXFAChild->JSObject()->GetCData(XFA_Attribute::Value);
wsValueTextBuf << wsCurValue;
}
}
@@ -1211,9 +1214,9 @@ void CXFA_SimpleParser::ParseDataValue(CXFA_Node* pXFANode,
if (!pXFAChild)
return;
- pXFAChild->JSNode()->SetCData(XFA_Attribute::Name, L"", false, false);
- pXFAChild->JSNode()->SetCData(XFA_Attribute::Value, wsCurValue, false,
- false);
+ pXFAChild->JSObject()->SetCData(XFA_Attribute::Name, L"", false, false);
+ pXFAChild->JSObject()->SetCData(XFA_Attribute::Value, wsCurValue, false,
+ false);
pXFANode->InsertChild(pXFAChild, nullptr);
pXFAChild->SetXMLMappingNode(pXMLCurValueNode);
pXFAChild->SetFlag(XFA_NodeFlag_Initialized, false);
@@ -1224,7 +1227,8 @@ void CXFA_SimpleParser::ParseDataValue(CXFA_Node* pXFANode,
pXMLCurValueNode = nullptr;
}
WideString wsNodeValue = wsValueTextBuf.MakeString();
- pXFANode->JSNode()->SetCData(XFA_Attribute::Value, wsNodeValue, false, false);
+ pXFANode->JSObject()->SetCData(XFA_Attribute::Value, wsNodeValue, false,
+ false);
}
void CXFA_SimpleParser::ParseInstruction(CXFA_Node* pXFANode,