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

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

Issue 1981003002: Replace Release() { delete this; } in fde_xml_imp.h (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: One more unique_ptr 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
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 m_pXMLNode->Release(); 124 delete m_pXMLNode;
125 }
126 } 125 }
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 IXFA_Parser* pParser = IXFA_Parser::Create(m_pDocument); 965 std::unique_ptr<IXFA_Parser> pParser(IXFA_Parser::Create(m_pDocument));
966 if (!pParser) { 966 if (!pParser)
Lei Zhang 2016/05/16 20:38:09 Always false, right?
Tom Sepez 2016/05/16 21:29:06 Done.
967 return; 967 return;
968 } 968
969 CFDE_XMLNode* pXMLNode = NULL; 969 CFDE_XMLNode* pXMLNode = NULL;
970 int32_t iParserStatus = pParser->ParseXMLData(wsExpression, pXMLNode, NULL); 970 int32_t iParserStatus = pParser->ParseXMLData(wsExpression, pXMLNode, NULL);
971 if (iParserStatus != XFA_PARSESTATUS_Done || !pXMLNode) { 971 if (iParserStatus != XFA_PARSESTATUS_Done || !pXMLNode)
972 pParser->Release();
973 pParser = NULL;
974 return; 972 return;
975 } 973
976 if (bIgnoreRoot && 974 if (bIgnoreRoot &&
977 (pXMLNode->GetType() != FDE_XMLNODE_Element || 975 (pXMLNode->GetType() != FDE_XMLNODE_Element ||
978 XFA_RecognizeRichText(static_cast<CFDE_XMLElement*>(pXMLNode)))) { 976 XFA_RecognizeRichText(static_cast<CFDE_XMLElement*>(pXMLNode)))) {
979 bIgnoreRoot = FALSE; 977 bIgnoreRoot = FALSE;
980 } 978 }
981 CXFA_Node* pFakeRoot = Clone(FALSE); 979 CXFA_Node* pFakeRoot = Clone(FALSE);
982 CFX_WideStringC wsContentType = GetCData(XFA_ATTRIBUTE_ContentType); 980 CFX_WideStringC wsContentType = GetCData(XFA_ATTRIBUTE_ContentType);
983 if (!wsContentType.IsEmpty()) { 981 if (!wsContentType.IsEmpty()) {
984 pFakeRoot->SetCData(XFA_ATTRIBUTE_ContentType, 982 pFakeRoot->SetCData(XFA_ATTRIBUTE_ContentType,
985 CFX_WideString(wsContentType)); 983 CFX_WideString(wsContentType));
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
1052 pChild->SetFlag(XFA_NODEFLAG_Initialized, true); 1050 pChild->SetFlag(XFA_NODEFLAG_Initialized, true);
1053 pChild = pItem; 1051 pChild = pItem;
1054 } 1052 }
1055 } 1053 }
1056 if (pFakeXMLRoot) { 1054 if (pFakeXMLRoot) {
1057 pFakeRoot->SetXMLMappingNode(pFakeXMLRoot); 1055 pFakeRoot->SetXMLMappingNode(pFakeXMLRoot);
1058 pFakeRoot->SetFlag(XFA_NODEFLAG_OwnXMLNode, false); 1056 pFakeRoot->SetFlag(XFA_NODEFLAG_OwnXMLNode, false);
1059 } 1057 }
1060 pFakeRoot->SetFlag(XFA_NODEFLAG_HasRemoved, false); 1058 pFakeRoot->SetFlag(XFA_NODEFLAG_HasRemoved, false);
1061 } else { 1059 } else {
1062 if (pFakeXMLRoot) { 1060 delete pFakeXMLRoot;
Lei Zhang 2016/05/16 20:38:09 Can this be an unique_ptr?
Tom Sepez 2016/05/16 21:29:06 Maybe later. This gets assigned in a couple of pl
1063 pFakeXMLRoot->Release(); 1061 pFakeXMLRoot = nullptr;
1064 pFakeXMLRoot = NULL;
1065 }
1066 } 1062 }
1067 pParser->Release();
1068 pParser = NULL;
1069 } 1063 }
1064
1070 void CXFA_Node::Script_NodeClass_SaveFilteredXML(CFXJSE_Arguments* pArguments) { 1065 void CXFA_Node::Script_NodeClass_SaveFilteredXML(CFXJSE_Arguments* pArguments) {
1071 } 1066 }
1072 1067
1073 void CXFA_Node::Script_NodeClass_SaveXML(CFXJSE_Arguments* pArguments) { 1068 void CXFA_Node::Script_NodeClass_SaveXML(CFXJSE_Arguments* pArguments) {
1074 int32_t iLength = pArguments->GetLength(); 1069 int32_t iLength = pArguments->GetLength();
1075 if (iLength < 0 || iLength > 1) { 1070 if (iLength < 0 || iLength > 1) {
1076 ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"saveXML"); 1071 ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"saveXML");
1077 return; 1072 return;
1078 } 1073 }
1079 FX_BOOL bPrettyMode = FALSE; 1074 FX_BOOL bPrettyMode = FALSE;
(...skipping 4285 matching lines...) Expand 10 before | Expand all | Expand 10 after
5365 return m_pAttachNode->InsertChild(pNewNode, pBeforeNode); 5360 return m_pAttachNode->InsertChild(pNewNode, pBeforeNode);
5366 } 5361 }
5367 FX_BOOL CXFA_AttachNodeList::Remove(CXFA_Node* pNode) { 5362 FX_BOOL CXFA_AttachNodeList::Remove(CXFA_Node* pNode) {
5368 return m_pAttachNode->RemoveChild(pNode); 5363 return m_pAttachNode->RemoveChild(pNode);
5369 } 5364 }
5370 CXFA_Node* CXFA_AttachNodeList::Item(int32_t iIndex) { 5365 CXFA_Node* CXFA_AttachNodeList::Item(int32_t iIndex) {
5371 return m_pAttachNode->GetChild( 5366 return m_pAttachNode->GetChild(
5372 iIndex, XFA_ELEMENT_UNKNOWN, 5367 iIndex, XFA_ELEMENT_UNKNOWN,
5373 m_pAttachNode->GetClassID() == XFA_ELEMENT_Subform); 5368 m_pAttachNode->GetClassID() == XFA_ELEMENT_Subform);
5374 } 5369 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698