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

Side by Side Diff: xfa/fde/css/fde_cssstylesheet.cpp

Issue 1944093002: Cleanup XFA-Specific memory allocators. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Dan's comments, remove more unused methods. 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_cssstylesheet.h ('k') | xfa/fee/fde_txtedtbuf.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/fde/css/fde_cssstylesheet.h" 7 #include "xfa/fde/css/fde_cssstylesheet.h"
8 8
9 #include "xfa/fde/css/fde_cssdatatable.h" 9 #include "xfa/fde/css/fde_cssdatatable.h"
10 #include "xfa/fde/css/fde_csssyntax.h" 10 #include "xfa/fde/css/fde_csssyntax.h"
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 143
144 CFDE_CSSSyntaxParser* pSyntax = new CFDE_CSSSyntaxParser; 144 CFDE_CSSSyntaxParser* pSyntax = new CFDE_CSSSyntaxParser;
145 FX_BOOL bRet = pSyntax->Init(pBuffer, iBufSize) && LoadFromSyntax(pSyntax); 145 FX_BOOL bRet = pSyntax->Init(pBuffer, iBufSize) && LoadFromSyntax(pSyntax);
146 pSyntax->Release(); 146 pSyntax->Release();
147 m_wCodePage = wCodePage; 147 m_wCodePage = wCodePage;
148 m_szUrl = szUrl; 148 m_szUrl = szUrl;
149 return bRet; 149 return bRet;
150 } 150 }
151 FX_BOOL CFDE_CSSStyleSheet::LoadFromSyntax(CFDE_CSSSyntaxParser* pSyntax) { 151 FX_BOOL CFDE_CSSStyleSheet::LoadFromSyntax(CFDE_CSSSyntaxParser* pSyntax) {
152 Reset(); 152 Reset();
153 m_pAllocator = FX_CreateAllocator(FX_ALLOCTYPE_Static, 1024, 0); 153 m_pAllocator = IFX_MemoryAllocator::Create(FX_ALLOCTYPE_Static, 1024, 0);
154 if (m_pAllocator == NULL) {
155 return FALSE;
156 }
157 FDE_CSSSYNTAXSTATUS eStatus; 154 FDE_CSSSYNTAXSTATUS eStatus;
158 do { 155 do {
159 switch (eStatus = pSyntax->DoSyntaxParse()) { 156 switch (eStatus = pSyntax->DoSyntaxParse()) {
160 case FDE_CSSSYNTAXSTATUS_StyleRule: 157 case FDE_CSSSYNTAXSTATUS_StyleRule:
161 eStatus = LoadStyleRule(pSyntax, m_RuleArray); 158 eStatus = LoadStyleRule(pSyntax, m_RuleArray);
162 break; 159 break;
163 case FDE_CSSSYNTAXSTATUS_MediaRule: 160 case FDE_CSSSYNTAXSTATUS_MediaRule:
164 eStatus = LoadMediaRule(pSyntax); 161 eStatus = LoadMediaRule(pSyntax);
165 break; 162 break;
166 case FDE_CSSSYNTAXSTATUS_FontFaceRule: 163 case FDE_CSSSYNTAXSTATUS_FontFaceRule:
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 case FDE_CSSSYNTAXSTATUS_PropertyName: 347 case FDE_CSSSYNTAXSTATUS_PropertyName:
351 case FDE_CSSSYNTAXSTATUS_PropertyValue: 348 case FDE_CSSSYNTAXSTATUS_PropertyValue:
352 break; 349 break;
353 case FDE_CSSSYNTAXSTATUS_DeclClose: 350 case FDE_CSSSYNTAXSTATUS_DeclClose:
354 return FDE_CSSSYNTAXSTATUS_None; 351 return FDE_CSSSYNTAXSTATUS_None;
355 FDE_CSSSWITCHDEFAULTS(); 352 FDE_CSSSWITCHDEFAULTS();
356 } 353 }
357 } 354 }
358 return FDE_CSSSYNTAXSTATUS_None; 355 return FDE_CSSSYNTAXSTATUS_None;
359 } 356 }
360 void CFDE_CSSStyleRule::SetSelector(IFX_MEMAllocator* pStaticStore, 357 void CFDE_CSSStyleRule::SetSelector(IFX_MemoryAllocator* pStaticStore,
361 const CFDE_CSSSelectorArray& list) { 358 const CFDE_CSSSelectorArray& list) {
362 ASSERT(m_ppSelector == NULL); 359 ASSERT(m_ppSelector == NULL);
363 m_iSelectors = list.GetSize(); 360 m_iSelectors = list.GetSize();
364 m_ppSelector = static_cast<CFDE_CSSSelector**>( 361 m_ppSelector = static_cast<CFDE_CSSSelector**>(
365 pStaticStore->Alloc(m_iSelectors * sizeof(CFDE_CSSSelector*))); 362 pStaticStore->Alloc(m_iSelectors * sizeof(CFDE_CSSSelector*)));
366 for (int32_t i = 0; i < m_iSelectors; ++i) { 363 for (int32_t i = 0; i < m_iSelectors; ++i) {
367 m_ppSelector[i] = list.GetAt(i); 364 m_ppSelector[i] = list.GetAt(i);
368 } 365 }
369 } 366 }
370 CFDE_CSSMediaRule::~CFDE_CSSMediaRule() { 367 CFDE_CSSMediaRule::~CFDE_CSSMediaRule() {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 FX_WCHAR wch = *psz; 399 FX_WCHAR wch = *psz;
403 if (FDE_IsCSSChar(wch) || (wch >= '0' && wch <= '9') || wch == '_' || 400 if (FDE_IsCSSChar(wch) || (wch >= '0' && wch <= '9') || wch == '_' ||
404 wch == '-') { 401 wch == '-') {
405 ++psz; 402 ++psz;
406 } else { 403 } else {
407 break; 404 break;
408 } 405 }
409 } 406 }
410 return psz - pStart; 407 return psz - pStart;
411 } 408 }
412 CFDE_CSSSelector* CFDE_CSSSelector::FromString(IFX_MEMAllocator* pStaticStore, 409 CFDE_CSSSelector* CFDE_CSSSelector::FromString(
413 const FX_WCHAR* psz, 410 IFX_MemoryAllocator* pStaticStore,
414 int32_t iLen) { 411 const FX_WCHAR* psz,
412 int32_t iLen) {
415 ASSERT(pStaticStore != NULL && psz != NULL && iLen > 0); 413 ASSERT(pStaticStore != NULL && psz != NULL && iLen > 0);
416 const FX_WCHAR* pStart = psz; 414 const FX_WCHAR* pStart = psz;
417 const FX_WCHAR* pEnd = psz + iLen; 415 const FX_WCHAR* pEnd = psz + iLen;
418 for (; psz < pEnd; ++psz) { 416 for (; psz < pEnd; ++psz) {
419 switch (*psz) { 417 switch (*psz) {
420 case '>': 418 case '>':
421 case '[': 419 case '[':
422 case '+': 420 case '+':
423 return NULL; 421 return NULL;
424 } 422 }
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
497 return NULL; 495 return NULL;
498 } 496 }
499 } 497 }
500 if (pPersudoFirst == NULL) { 498 if (pPersudoFirst == NULL) {
501 return pFirst; 499 return pFirst;
502 } else { 500 } else {
503 pPersudoLast->SetNext(pFirst); 501 pPersudoLast->SetNext(pFirst);
504 return pPersudoFirst; 502 return pPersudoFirst;
505 } 503 }
506 } 504 }
OLDNEW
« no previous file with comments | « xfa/fde/css/fde_cssstylesheet.h ('k') | xfa/fee/fde_txtedtbuf.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698