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

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

Issue 1925363002: Do not check pointers before deleting them. (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: rebase 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_imp.cpp ('k') | xfa/fxfa/parser/xfa_locale.cpp » ('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_document_layout_imp.h" 7 #include "xfa/fxfa/parser/xfa_document_layout_imp.h"
8 8
9 #include "xfa/fxfa/fm2js/xfa_fm2jsapi.h" 9 #include "xfa/fxfa/fm2js/xfa_fm2jsapi.h"
10 #include "xfa/fxfa/parser/xfa_basic_imp.h" 10 #include "xfa/fxfa/parser/xfa_basic_imp.h"
(...skipping 24 matching lines...) Expand all
35 m_pRootItemLayoutProcessor(NULL), 35 m_pRootItemLayoutProcessor(NULL),
36 m_pLayoutPageMgr(NULL), 36 m_pLayoutPageMgr(NULL),
37 m_nProgressCounter(0), 37 m_nProgressCounter(0),
38 m_bNeeLayout(TRUE) {} 38 m_bNeeLayout(TRUE) {}
39 CXFA_LayoutProcessor::~CXFA_LayoutProcessor() { 39 CXFA_LayoutProcessor::~CXFA_LayoutProcessor() {
40 ClearLayoutData(); 40 ClearLayoutData();
41 } 41 }
42 CXFA_Document* CXFA_LayoutProcessor::GetDocument() const { 42 CXFA_Document* CXFA_LayoutProcessor::GetDocument() const {
43 return m_pDocument; 43 return m_pDocument;
44 } 44 }
45
45 int32_t CXFA_LayoutProcessor::StartLayout(FX_BOOL bForceRestart) { 46 int32_t CXFA_LayoutProcessor::StartLayout(FX_BOOL bForceRestart) {
46 if (!bForceRestart && !IsNeedLayout()) { 47 if (!bForceRestart && !IsNeedLayout())
47 return 100; 48 return 100;
48 } 49
49 if (m_pRootItemLayoutProcessor) { 50 delete m_pRootItemLayoutProcessor;
50 delete m_pRootItemLayoutProcessor; 51 m_pRootItemLayoutProcessor = nullptr;
51 m_pRootItemLayoutProcessor = NULL;
52 }
53 m_nProgressCounter = 0; 52 m_nProgressCounter = 0;
54 CXFA_Node* pFormPacketNode = 53 CXFA_Node* pFormPacketNode =
55 ToNode(m_pDocument->GetXFAObject(XFA_HASHCODE_Form)); 54 ToNode(m_pDocument->GetXFAObject(XFA_HASHCODE_Form));
56 if (!pFormPacketNode) { 55 if (!pFormPacketNode) {
57 return -1; 56 return -1;
58 } 57 }
59 CXFA_Node* pFormRoot = 58 CXFA_Node* pFormRoot =
60 pFormPacketNode->GetFirstChildByClass(XFA_ELEMENT_Subform); 59 pFormPacketNode->GetFirstChildByClass(XFA_ELEMENT_Subform);
61 if (!pFormRoot) { 60 if (!pFormRoot) {
62 return -1; 61 return -1;
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 pFormItem->GetUserData(XFA_LAYOUTITEMKEY)); 139 pFormItem->GetUserData(XFA_LAYOUTITEMKEY));
141 } 140 }
142 void CXFA_LayoutProcessor::AddChangedContainer(CXFA_Node* pContainer) { 141 void CXFA_LayoutProcessor::AddChangedContainer(CXFA_Node* pContainer) {
143 if (m_rgChangedContainers.Find(pContainer) < 0) { 142 if (m_rgChangedContainers.Find(pContainer) < 0) {
144 m_rgChangedContainers.Add(pContainer); 143 m_rgChangedContainers.Add(pContainer);
145 } 144 }
146 } 145 }
147 CXFA_ContainerLayoutItem* CXFA_LayoutProcessor::GetRootLayoutItem() const { 146 CXFA_ContainerLayoutItem* CXFA_LayoutProcessor::GetRootLayoutItem() const {
148 return m_pLayoutPageMgr ? m_pLayoutPageMgr->GetRootLayoutItem() : NULL; 147 return m_pLayoutPageMgr ? m_pLayoutPageMgr->GetRootLayoutItem() : NULL;
149 } 148 }
149
150 void CXFA_LayoutProcessor::ClearLayoutData() { 150 void CXFA_LayoutProcessor::ClearLayoutData() {
151 if (m_pLayoutPageMgr) { 151 delete m_pLayoutPageMgr;
152 delete m_pLayoutPageMgr; 152 m_pLayoutPageMgr = nullptr;
153 m_pLayoutPageMgr = NULL; 153 delete m_pRootItemLayoutProcessor;
154 } 154 m_pRootItemLayoutProcessor = nullptr;
155 if (m_pRootItemLayoutProcessor) {
156 delete m_pRootItemLayoutProcessor;
157 m_pRootItemLayoutProcessor = NULL;
158 }
159 m_nProgressCounter = 0; 155 m_nProgressCounter = 0;
160 } 156 }
157
161 FX_BOOL CXFA_LayoutProcessor::IsNeedLayout() { 158 FX_BOOL CXFA_LayoutProcessor::IsNeedLayout() {
162 return m_bNeeLayout || m_rgChangedContainers.GetSize() > 0; 159 return m_bNeeLayout || m_rgChangedContainers.GetSize() > 0;
163 } 160 }
164 CXFA_LayoutItem::CXFA_LayoutItem(CXFA_Node* pNode, FX_BOOL bIsContentLayoutItem) 161 CXFA_LayoutItem::CXFA_LayoutItem(CXFA_Node* pNode, FX_BOOL bIsContentLayoutItem)
165 : m_pFormNode(pNode), 162 : m_pFormNode(pNode),
166 m_pParent(NULL), 163 m_pParent(NULL),
167 m_pNextSibling(NULL), 164 m_pNextSibling(NULL),
168 m_pFirstChild(NULL), 165 m_pFirstChild(NULL),
169 m_bIsContentLayoutItem(bIsContentLayoutItem) {} 166 m_bIsContentLayoutItem(bIsContentLayoutItem) {}
170 CXFA_LayoutItem::~CXFA_LayoutItem() {} 167 CXFA_LayoutItem::~CXFA_LayoutItem() {}
(...skipping 29 matching lines...) Expand all
200 CXFA_ContentLayoutItem::CXFA_ContentLayoutItem(CXFA_Node* pNode) 197 CXFA_ContentLayoutItem::CXFA_ContentLayoutItem(CXFA_Node* pNode)
201 : CXFA_LayoutItem(pNode, TRUE), 198 : CXFA_LayoutItem(pNode, TRUE),
202 m_pPrev(NULL), 199 m_pPrev(NULL),
203 m_pNext(NULL), 200 m_pNext(NULL),
204 m_dwStatus(0) {} 201 m_dwStatus(0) {}
205 CXFA_ContentLayoutItem::~CXFA_ContentLayoutItem() { 202 CXFA_ContentLayoutItem::~CXFA_ContentLayoutItem() {
206 if (m_pFormNode->GetUserData(XFA_LAYOUTITEMKEY) == this) { 203 if (m_pFormNode->GetUserData(XFA_LAYOUTITEMKEY) == this) {
207 m_pFormNode->SetUserData(XFA_LAYOUTITEMKEY, NULL); 204 m_pFormNode->SetUserData(XFA_LAYOUTITEMKEY, NULL);
208 } 205 }
209 } 206 }
OLDNEW
« no previous file with comments | « xfa/fxfa/parser/xfa_document_imp.cpp ('k') | xfa/fxfa/parser/xfa_locale.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698