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

Side by Side Diff: xfa/fde/css/fde_cssstyleselector.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/fde/css/fde_cssstyleselector.h ('k') | xfa/fde/fde_render.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/fde/css/fde_cssstyleselector.h" 7 #include "xfa/fde/css/fde_cssstyleselector.h"
8 8
9 #include <algorithm> 9 #include <algorithm>
10 10
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 m_fDefFontSize(12.0f), 213 m_fDefFontSize(12.0f),
214 m_pRuleDataStore(NULL), 214 m_pRuleDataStore(NULL),
215 m_pInlineStyleStore(NULL), 215 m_pInlineStyleStore(NULL),
216 m_pFixedStyleStore(NULL), 216 m_pFixedStyleStore(NULL),
217 m_pAccelerator(NULL) { 217 m_pAccelerator(NULL) {
218 m_ePriorities[FDE_CSSSTYLESHEETPRIORITY_High] = FDE_CSSSTYLESHEETGROUP_Author; 218 m_ePriorities[FDE_CSSSTYLESHEETPRIORITY_High] = FDE_CSSSTYLESHEETGROUP_Author;
219 m_ePriorities[FDE_CSSSTYLESHEETPRIORITY_Mid] = FDE_CSSSTYLESHEETGROUP_User; 219 m_ePriorities[FDE_CSSSTYLESHEETPRIORITY_Mid] = FDE_CSSSTYLESHEETGROUP_User;
220 m_ePriorities[FDE_CSSSTYLESHEETPRIORITY_Low] = 220 m_ePriorities[FDE_CSSSTYLESHEETPRIORITY_Low] =
221 FDE_CSSSTYLESHEETGROUP_UserAgent; 221 FDE_CSSSTYLESHEETGROUP_UserAgent;
222 } 222 }
223
223 CFDE_CSSStyleSelector::~CFDE_CSSStyleSelector() { 224 CFDE_CSSStyleSelector::~CFDE_CSSStyleSelector() {
224 Reset(); 225 Reset();
225 if (m_pInlineStyleStore != NULL) { 226 if (m_pInlineStyleStore)
226 m_pInlineStyleStore->Release(); 227 m_pInlineStyleStore->Release();
227 } 228 if (m_pFixedStyleStore)
228 if (m_pFixedStyleStore != NULL) {
229 m_pFixedStyleStore->Release(); 229 m_pFixedStyleStore->Release();
230 } 230 delete m_pAccelerator;
231 if (m_pAccelerator != NULL) {
232 delete m_pAccelerator;
233 }
234 } 231 }
232
235 void CFDE_CSSStyleSelector::SetFontMgr(IFX_FontMgr* pFontMgr) { 233 void CFDE_CSSStyleSelector::SetFontMgr(IFX_FontMgr* pFontMgr) {
236 m_pFontMgr = pFontMgr; 234 m_pFontMgr = pFontMgr;
237 } 235 }
238 void CFDE_CSSStyleSelector::SetDefFontSize(FX_FLOAT fFontSize) { 236 void CFDE_CSSStyleSelector::SetDefFontSize(FX_FLOAT fFontSize) {
239 ASSERT(fFontSize > 0); 237 ASSERT(fFontSize > 0);
240 m_fDefFontSize = fFontSize; 238 m_fDefFontSize = fFontSize;
241 } 239 }
240
242 CFDE_CSSAccelerator* CFDE_CSSStyleSelector::InitAccelerator() { 241 CFDE_CSSAccelerator* CFDE_CSSStyleSelector::InitAccelerator() {
243 if (m_pAccelerator == NULL) { 242 if (!m_pAccelerator)
244 m_pAccelerator = new CFDE_CSSAccelerator; 243 m_pAccelerator = new CFDE_CSSAccelerator;
245 ASSERT(m_pAccelerator != NULL);
246 }
247 m_pAccelerator->Clear(); 244 m_pAccelerator->Clear();
248 return m_pAccelerator; 245 return m_pAccelerator;
249 } 246 }
247
250 IFDE_CSSComputedStyle* CFDE_CSSStyleSelector::CreateComputedStyle( 248 IFDE_CSSComputedStyle* CFDE_CSSStyleSelector::CreateComputedStyle(
251 IFDE_CSSComputedStyle* pParentStyle) { 249 IFDE_CSSComputedStyle* pParentStyle) {
252 if (m_pFixedStyleStore == NULL) { 250 if (m_pFixedStyleStore == NULL) {
253 m_pFixedStyleStore = FX_CreateAllocator(FX_ALLOCTYPE_Fixed, 16, 251 m_pFixedStyleStore = FX_CreateAllocator(FX_ALLOCTYPE_Fixed, 16,
254 sizeof(CFDE_CSSComputedStyle)); 252 sizeof(CFDE_CSSComputedStyle));
255 ASSERT(m_pFixedStyleStore != NULL); 253 ASSERT(m_pFixedStyleStore != NULL);
256 } 254 }
257 CFDE_CSSComputedStyle* pStyle = FXTARGET_NewWith(m_pFixedStyleStore) 255 CFDE_CSSComputedStyle* pStyle = FXTARGET_NewWith(m_pFixedStyleStore)
258 CFDE_CSSComputedStyle(m_pFixedStyleStore); 256 CFDE_CSSComputedStyle(m_pFixedStyleStore);
259 if (pParentStyle) { 257 if (pParentStyle) {
(...skipping 1522 matching lines...) Expand 10 before | Expand all | Expand 10 after
1782 return FDE_CSSTEXTTRANSFORM_LowerCase; 1780 return FDE_CSSTEXTTRANSFORM_LowerCase;
1783 default: 1781 default:
1784 return FDE_CSSTEXTTRANSFORM_None; 1782 return FDE_CSSTEXTTRANSFORM_None;
1785 } 1783 }
1786 } 1784 }
1787 FDE_CSSFONTVARIANT CFDE_CSSStyleSelector::ToFontVariant( 1785 FDE_CSSFONTVARIANT CFDE_CSSStyleSelector::ToFontVariant(
1788 FDE_CSSPROPERTYVALUE eValue) { 1786 FDE_CSSPROPERTYVALUE eValue) {
1789 return eValue == FDE_CSSPROPERTYVALUE_SmallCaps ? FDE_CSSFONTVARIANT_SmallCaps 1787 return eValue == FDE_CSSPROPERTYVALUE_SmallCaps ? FDE_CSSFONTVARIANT_SmallCaps
1790 : FDE_CSSFONTVARIANT_Normal; 1788 : FDE_CSSFONTVARIANT_Normal;
1791 } 1789 }
OLDNEW
« no previous file with comments | « xfa/fde/css/fde_cssstyleselector.h ('k') | xfa/fde/fde_render.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698