Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(71)

Side by Side Diff: xfa/fxfa/parser/xfa_object_imp.cpp

Issue 1980223002: Revert of Replace Release() { delete this; } in fde_xml_imp.h (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « xfa/fxfa/parser/xfa_document_serialize.cpp ('k') | xfa/fxfa/parser/xfa_parser.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include "xfa/fxfa/parser/xfa_object.h" 7 #include "xfa/fxfa/parser/xfa_object.h"
8 8
9 #include <memory> 9 #include <memory>
10 10
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 CXFA_Node::~CXFA_Node() { 113 CXFA_Node::~CXFA_Node() {
114 ASSERT(m_pParent == NULL); 114 ASSERT(m_pParent == NULL);
115 RemoveMapModuleKey(); 115 RemoveMapModuleKey();
116 CXFA_Node *pNext, *pNode = m_pChild; 116 CXFA_Node *pNext, *pNode = m_pChild;
117 while (pNode) { 117 while (pNode) {
118 pNext = pNode->m_pNext; 118 pNext = pNode->m_pNext;
119 pNode->m_pParent = NULL; 119 pNode->m_pParent = NULL;
120 delete pNode; 120 delete pNode;
121 pNode = pNext; 121 pNode = pNext;
122 } 122 }
123 if (m_pXMLNode && HasFlag(XFA_NODEFLAG_OwnXMLNode)) 123 if (m_pXMLNode && HasFlag(XFA_NODEFLAG_OwnXMLNode)) {
124 delete m_pXMLNode; 124 m_pXMLNode->Release();
125 }
125 } 126 }
126
127 CXFA_Node* CXFA_Node::Clone(FX_BOOL bRecursive) { 127 CXFA_Node* CXFA_Node::Clone(FX_BOOL bRecursive) {
128 CXFA_Document* pFactory = m_pDocument->GetParser()->GetFactory(); 128 CXFA_Document* pFactory = m_pDocument->GetParser()->GetFactory();
129 CXFA_Node* pClone = pFactory->CreateNode(m_ePacket, m_eNodeClass); 129 CXFA_Node* pClone = pFactory->CreateNode(m_ePacket, m_eNodeClass);
130 if (!pClone) { 130 if (!pClone) {
131 return NULL; 131 return NULL;
132 } 132 }
133 MergeAllData(pClone); 133 MergeAllData(pClone);
134 pClone->UpdateNameHash(); 134 pClone->UpdateNameHash();
135 if (IsNeedSavingXMLNode()) { 135 if (IsNeedSavingXMLNode()) {
136 CFDE_XMLNode* pCloneXML = NULL; 136 CFDE_XMLNode* pCloneXML = NULL;
(...skipping 818 matching lines...) Expand 10 before | Expand all | Expand 10 after
955 if (wsExpression.IsEmpty()) { 955 if (wsExpression.IsEmpty()) {
956 return; 956 return;
957 } 957 }
958 } 958 }
959 if (iLength >= 2) { 959 if (iLength >= 2) {
960 bIgnoreRoot = pArguments->GetInt32(1) == 0 ? FALSE : TRUE; 960 bIgnoreRoot = pArguments->GetInt32(1) == 0 ? FALSE : TRUE;
961 } 961 }
962 if (iLength >= 3) { 962 if (iLength >= 3) {
963 bOverwrite = pArguments->GetInt32(2) == 0 ? FALSE : TRUE; 963 bOverwrite = pArguments->GetInt32(2) == 0 ? FALSE : TRUE;
964 } 964 }
965 std::unique_ptr<IXFA_Parser> pParser(IXFA_Parser::Create(m_pDocument)); 965 IXFA_Parser* pParser = IXFA_Parser::Create(m_pDocument);
966 if (!pParser) {
967 return;
968 }
966 CFDE_XMLNode* pXMLNode = NULL; 969 CFDE_XMLNode* pXMLNode = NULL;
967 int32_t iParserStatus = pParser->ParseXMLData(wsExpression, pXMLNode, NULL); 970 int32_t iParserStatus = pParser->ParseXMLData(wsExpression, pXMLNode, NULL);
968 if (iParserStatus != XFA_PARSESTATUS_Done || !pXMLNode) 971 if (iParserStatus != XFA_PARSESTATUS_Done || !pXMLNode) {
972 pParser->Release();
973 pParser = NULL;
969 return; 974 return;
970 975 }
971 if (bIgnoreRoot && 976 if (bIgnoreRoot &&
972 (pXMLNode->GetType() != FDE_XMLNODE_Element || 977 (pXMLNode->GetType() != FDE_XMLNODE_Element ||
973 XFA_RecognizeRichText(static_cast<CFDE_XMLElement*>(pXMLNode)))) { 978 XFA_RecognizeRichText(static_cast<CFDE_XMLElement*>(pXMLNode)))) {
974 bIgnoreRoot = FALSE; 979 bIgnoreRoot = FALSE;
975 } 980 }
976 CXFA_Node* pFakeRoot = Clone(FALSE); 981 CXFA_Node* pFakeRoot = Clone(FALSE);
977 CFX_WideStringC wsContentType = GetCData(XFA_ATTRIBUTE_ContentType); 982 CFX_WideStringC wsContentType = GetCData(XFA_ATTRIBUTE_ContentType);
978 if (!wsContentType.IsEmpty()) { 983 if (!wsContentType.IsEmpty()) {
979 pFakeRoot->SetCData(XFA_ATTRIBUTE_ContentType, 984 pFakeRoot->SetCData(XFA_ATTRIBUTE_ContentType,
980 CFX_WideString(wsContentType)); 985 CFX_WideString(wsContentType));
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
1047 pChild->SetFlag(XFA_NODEFLAG_Initialized, true); 1052 pChild->SetFlag(XFA_NODEFLAG_Initialized, true);
1048 pChild = pItem; 1053 pChild = pItem;
1049 } 1054 }
1050 } 1055 }
1051 if (pFakeXMLRoot) { 1056 if (pFakeXMLRoot) {
1052 pFakeRoot->SetXMLMappingNode(pFakeXMLRoot); 1057 pFakeRoot->SetXMLMappingNode(pFakeXMLRoot);
1053 pFakeRoot->SetFlag(XFA_NODEFLAG_OwnXMLNode, false); 1058 pFakeRoot->SetFlag(XFA_NODEFLAG_OwnXMLNode, false);
1054 } 1059 }
1055 pFakeRoot->SetFlag(XFA_NODEFLAG_HasRemoved, false); 1060 pFakeRoot->SetFlag(XFA_NODEFLAG_HasRemoved, false);
1056 } else { 1061 } else {
1057 delete pFakeXMLRoot; 1062 if (pFakeXMLRoot) {
1058 pFakeXMLRoot = nullptr; 1063 pFakeXMLRoot->Release();
1064 pFakeXMLRoot = NULL;
1065 }
1059 } 1066 }
1067 pParser->Release();
1068 pParser = NULL;
1060 } 1069 }
1061
1062 void CXFA_Node::Script_NodeClass_SaveFilteredXML(CFXJSE_Arguments* pArguments) { 1070 void CXFA_Node::Script_NodeClass_SaveFilteredXML(CFXJSE_Arguments* pArguments) {
1063 } 1071 }
1064 1072
1065 void CXFA_Node::Script_NodeClass_SaveXML(CFXJSE_Arguments* pArguments) { 1073 void CXFA_Node::Script_NodeClass_SaveXML(CFXJSE_Arguments* pArguments) {
1066 int32_t iLength = pArguments->GetLength(); 1074 int32_t iLength = pArguments->GetLength();
1067 if (iLength < 0 || iLength > 1) { 1075 if (iLength < 0 || iLength > 1) {
1068 ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"saveXML"); 1076 ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"saveXML");
1069 return; 1077 return;
1070 } 1078 }
1071 FX_BOOL bPrettyMode = FALSE; 1079 FX_BOOL bPrettyMode = FALSE;
(...skipping 4285 matching lines...) Expand 10 before | Expand all | Expand 10 after
5357 return m_pAttachNode->InsertChild(pNewNode, pBeforeNode); 5365 return m_pAttachNode->InsertChild(pNewNode, pBeforeNode);
5358 } 5366 }
5359 FX_BOOL CXFA_AttachNodeList::Remove(CXFA_Node* pNode) { 5367 FX_BOOL CXFA_AttachNodeList::Remove(CXFA_Node* pNode) {
5360 return m_pAttachNode->RemoveChild(pNode); 5368 return m_pAttachNode->RemoveChild(pNode);
5361 } 5369 }
5362 CXFA_Node* CXFA_AttachNodeList::Item(int32_t iIndex) { 5370 CXFA_Node* CXFA_AttachNodeList::Item(int32_t iIndex) {
5363 return m_pAttachNode->GetChild( 5371 return m_pAttachNode->GetChild(
5364 iIndex, XFA_ELEMENT_UNKNOWN, 5372 iIndex, XFA_ELEMENT_UNKNOWN,
5365 m_pAttachNode->GetClassID() == XFA_ELEMENT_Subform); 5373 m_pAttachNode->GetClassID() == XFA_ELEMENT_Subform);
5366 } 5374 }
OLDNEW
« no previous file with comments | « xfa/fxfa/parser/xfa_document_serialize.cpp ('k') | xfa/fxfa/parser/xfa_parser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698