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

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

Issue 1919563002: Pass CFX_*StringCs to FX_HashCode_GETA and _GETW hash functions. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: fix issue from c4 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/fgas/crt/fgas_codepage.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_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 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 FDE_CSSSYNTAXSTATUS CFDE_CSSStyleSheet::LoadMediaRule( 189 FDE_CSSSYNTAXSTATUS CFDE_CSSStyleSheet::LoadMediaRule(
190 IFDE_CSSSyntaxParser* pSyntax) { 190 IFDE_CSSSyntaxParser* pSyntax) {
191 uint32_t dwMediaList = 0; 191 uint32_t dwMediaList = 0;
192 CFDE_CSSMediaRule* pMediaRule = NULL; 192 CFDE_CSSMediaRule* pMediaRule = NULL;
193 for (;;) { 193 for (;;) {
194 switch (pSyntax->DoSyntaxParse()) { 194 switch (pSyntax->DoSyntaxParse()) {
195 case FDE_CSSSYNTAXSTATUS_MediaType: { 195 case FDE_CSSSYNTAXSTATUS_MediaType: {
196 int32_t iLen; 196 int32_t iLen;
197 const FX_WCHAR* psz = pSyntax->GetCurrentString(iLen); 197 const FX_WCHAR* psz = pSyntax->GetCurrentString(iLen);
198 FDE_LPCCSSMEDIATYPETABLE pMediaType = 198 FDE_LPCCSSMEDIATYPETABLE pMediaType =
199 FDE_GetCSSMediaTypeByName(psz, iLen); 199 FDE_GetCSSMediaTypeByName(CFX_WideStringC(psz, iLen));
200 if (pMediaType != NULL) { 200 if (pMediaType != NULL) {
201 dwMediaList |= pMediaType->wValue; 201 dwMediaList |= pMediaType->wValue;
202 } 202 }
203 } break; 203 } break;
204 case FDE_CSSSYNTAXSTATUS_StyleRule: 204 case FDE_CSSSYNTAXSTATUS_StyleRule:
205 if (pMediaRule == NULL) { 205 if (pMediaRule == NULL) {
206 SkipRuleSet(pSyntax); 206 SkipRuleSet(pSyntax);
207 } else { 207 } else {
208 FDE_CSSSYNTAXSTATUS eStatus = 208 FDE_CSSSYNTAXSTATUS eStatus =
209 LoadStyleRule(pSyntax, pMediaRule->GetArray()); 209 LoadStyleRule(pSyntax, pMediaRule->GetArray());
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 case FDE_CSSSYNTAXSTATUS_Selector: { 242 case FDE_CSSSYNTAXSTATUS_Selector: {
243 pszValue = pSyntax->GetCurrentString(iValueLen); 243 pszValue = pSyntax->GetCurrentString(iValueLen);
244 IFDE_CSSSelector* pSelector = 244 IFDE_CSSSelector* pSelector =
245 CFDE_CSSSelector::FromString(m_pAllocator, pszValue, iValueLen); 245 CFDE_CSSSelector::FromString(m_pAllocator, pszValue, iValueLen);
246 if (pSelector != NULL) { 246 if (pSelector != NULL) {
247 m_Selectors.Add(pSelector); 247 m_Selectors.Add(pSelector);
248 } 248 }
249 } break; 249 } break;
250 case FDE_CSSSYNTAXSTATUS_PropertyName: 250 case FDE_CSSSYNTAXSTATUS_PropertyName:
251 pszValue = pSyntax->GetCurrentString(iValueLen); 251 pszValue = pSyntax->GetCurrentString(iValueLen);
252 propertyArgs.pProperty = FDE_GetCSSPropertyByName(pszValue, iValueLen); 252 propertyArgs.pProperty =
253 FDE_GetCSSPropertyByName(CFX_WideStringC(pszValue, iValueLen));
253 if (propertyArgs.pProperty == NULL) { 254 if (propertyArgs.pProperty == NULL) {
254 wsName = CFX_WideStringC(pszValue, iValueLen); 255 wsName = CFX_WideStringC(pszValue, iValueLen);
255 } 256 }
256 break; 257 break;
257 case FDE_CSSSYNTAXSTATUS_PropertyValue: 258 case FDE_CSSSYNTAXSTATUS_PropertyValue:
258 if (propertyArgs.pProperty != NULL) { 259 if (propertyArgs.pProperty != NULL) {
259 pszValue = pSyntax->GetCurrentString(iValueLen); 260 pszValue = pSyntax->GetCurrentString(iValueLen);
260 if (iValueLen > 0) { 261 if (iValueLen > 0) {
261 pStyleRule->GetDeclImp().AddProperty(&propertyArgs, pszValue, 262 pStyleRule->GetDeclImp().AddProperty(&propertyArgs, pszValue,
262 iValueLen); 263 iValueLen);
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 const FX_WCHAR* pszValue = NULL; 299 const FX_WCHAR* pszValue = NULL;
299 int32_t iValueLen = 0; 300 int32_t iValueLen = 0;
300 FDE_CSSPROPERTYARGS propertyArgs; 301 FDE_CSSPROPERTYARGS propertyArgs;
301 propertyArgs.pStaticStore = m_pAllocator; 302 propertyArgs.pStaticStore = m_pAllocator;
302 propertyArgs.pStringCache = &m_StringCache; 303 propertyArgs.pStringCache = &m_StringCache;
303 propertyArgs.pProperty = NULL; 304 propertyArgs.pProperty = NULL;
304 for (;;) { 305 for (;;) {
305 switch (pSyntax->DoSyntaxParse()) { 306 switch (pSyntax->DoSyntaxParse()) {
306 case FDE_CSSSYNTAXSTATUS_PropertyName: 307 case FDE_CSSSYNTAXSTATUS_PropertyName:
307 pszValue = pSyntax->GetCurrentString(iValueLen); 308 pszValue = pSyntax->GetCurrentString(iValueLen);
308 propertyArgs.pProperty = FDE_GetCSSPropertyByName(pszValue, iValueLen); 309 propertyArgs.pProperty =
310 FDE_GetCSSPropertyByName(CFX_WideStringC(pszValue, iValueLen));
309 break; 311 break;
310 case FDE_CSSSYNTAXSTATUS_PropertyValue: 312 case FDE_CSSSYNTAXSTATUS_PropertyValue:
311 if (propertyArgs.pProperty != NULL) { 313 if (propertyArgs.pProperty != NULL) {
312 pszValue = pSyntax->GetCurrentString(iValueLen); 314 pszValue = pSyntax->GetCurrentString(iValueLen);
313 if (iValueLen > 0) { 315 if (iValueLen > 0) {
314 pFontFaceRule->GetDeclImp().AddProperty(&propertyArgs, pszValue, 316 pFontFaceRule->GetDeclImp().AddProperty(&propertyArgs, pszValue,
315 iValueLen); 317 iValueLen);
316 } 318 }
317 } 319 }
318 break; 320 break;
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
427 return NULL; 429 return NULL;
428 } 430 }
429 } 431 }
430 CFDE_CSSSelector *pFirst = NULL, *pLast = NULL; 432 CFDE_CSSSelector *pFirst = NULL, *pLast = NULL;
431 CFDE_CSSSelector *pPersudoFirst = NULL, *pPersudoLast = NULL; 433 CFDE_CSSSelector *pPersudoFirst = NULL, *pPersudoLast = NULL;
432 for (psz = pStart; psz < pEnd;) { 434 for (psz = pStart; psz < pEnd;) {
433 FX_WCHAR wch = *psz; 435 FX_WCHAR wch = *psz;
434 if (wch == '.' || wch == '#') { 436 if (wch == '.' || wch == '#') {
435 if (psz == pStart || psz[-1] == ' ') { 437 if (psz == pStart || psz[-1] == ' ') {
436 CFDE_CSSSelector* p = FXTARGET_NewWith(pStaticStore) 438 CFDE_CSSSelector* p = FXTARGET_NewWith(pStaticStore)
437 CFDE_CSSSelector(FDE_CSSSELECTORTYPE_Element, L"*", 1, TRUE); 439 CFDE_CSSSelector(FDE_CSSSELECTORTYPE_Element, L"*", 1, true);
438 if (p == NULL) { 440 if (p == NULL) {
439 return NULL; 441 return NULL;
440 } 442 }
441 if (pFirst != NULL) { 443 if (pFirst != NULL) {
442 pFirst->SetType(FDE_CSSSELECTORTYPE_Descendant); 444 pFirst->SetType(FDE_CSSSELECTORTYPE_Descendant);
443 p->SetNext(pFirst); 445 p->SetNext(pFirst);
444 } 446 }
445 pFirst = pLast = p; 447 pFirst = pLast = p;
446 } 448 }
447 FXSYS_assert(pLast != NULL); 449 FXSYS_assert(pLast != NULL);
448 int32_t iNameLen = FDE_GetCSSNameLen(++psz, pEnd); 450 int32_t iNameLen = FDE_GetCSSNameLen(++psz, pEnd);
449 if (iNameLen == 0) { 451 if (iNameLen == 0) {
450 return NULL; 452 return NULL;
451 } 453 }
452 FDE_CSSSELECTORTYPE eType = 454 FDE_CSSSELECTORTYPE eType =
453 wch == '.' ? FDE_CSSSELECTORTYPE_Class : FDE_CSSSELECTORTYPE_ID; 455 wch == '.' ? FDE_CSSSELECTORTYPE_Class : FDE_CSSSELECTORTYPE_ID;
454 CFDE_CSSSelector* p = FXTARGET_NewWith(pStaticStore) 456 CFDE_CSSSelector* p = FXTARGET_NewWith(pStaticStore)
455 CFDE_CSSSelector(eType, psz, iNameLen, FALSE); 457 CFDE_CSSSelector(eType, psz, iNameLen, false);
456 if (p == NULL) { 458 if (p == NULL) {
457 return NULL; 459 return NULL;
458 } 460 }
459 p->SetNext(pLast->GetNextSelector()); 461 p->SetNext(pLast->GetNextSelector());
460 pLast->SetNext(p); 462 pLast->SetNext(p);
461 pLast = p; 463 pLast = p;
462 psz += iNameLen; 464 psz += iNameLen;
463 } else if (FDE_IsCSSChar(wch) || wch == '*') { 465 } else if (FDE_IsCSSChar(wch) || wch == '*') {
464 int32_t iNameLen = wch == '*' ? 1 : FDE_GetCSSNameLen(psz, pEnd); 466 int32_t iNameLen = wch == '*' ? 1 : FDE_GetCSSNameLen(psz, pEnd);
465 if (iNameLen == 0) { 467 if (iNameLen == 0) {
466 return NULL; 468 return NULL;
467 } 469 }
468 CFDE_CSSSelector* p = FXTARGET_NewWith(pStaticStore) 470 CFDE_CSSSelector* p = FXTARGET_NewWith(pStaticStore)
469 CFDE_CSSSelector(FDE_CSSSELECTORTYPE_Element, psz, iNameLen, TRUE); 471 CFDE_CSSSelector(FDE_CSSSELECTORTYPE_Element, psz, iNameLen, true);
470 if (p == NULL) { 472 if (p == NULL) {
471 return NULL; 473 return NULL;
472 } 474 }
473 if (pFirst == NULL) { 475 if (pFirst == NULL) {
474 pFirst = pLast = p; 476 pFirst = pLast = p;
475 } else { 477 } else {
476 pFirst->SetType(FDE_CSSSELECTORTYPE_Descendant); 478 pFirst->SetType(FDE_CSSSELECTORTYPE_Descendant);
477 p->SetNext(pFirst); 479 p->SetNext(pFirst);
478 pFirst = pLast = p; 480 pFirst = pLast = p;
479 } 481 }
480 psz += iNameLen; 482 psz += iNameLen;
481 } else if (wch == ':') { 483 } else if (wch == ':') {
482 int32_t iNameLen = FDE_GetCSSPersudoLen(psz, pEnd); 484 int32_t iNameLen = FDE_GetCSSPersudoLen(psz, pEnd);
483 if (iNameLen == 0) { 485 if (iNameLen == 0) {
484 return NULL; 486 return NULL;
485 } 487 }
486 CFDE_CSSSelector* p = FXTARGET_NewWith(pStaticStore) 488 CFDE_CSSSelector* p = FXTARGET_NewWith(pStaticStore)
487 CFDE_CSSSelector(FDE_CSSSELECTORTYPE_Persudo, psz, iNameLen, TRUE); 489 CFDE_CSSSelector(FDE_CSSSELECTORTYPE_Persudo, psz, iNameLen, true);
488 if (p == NULL) { 490 if (p == NULL) {
489 return NULL; 491 return NULL;
490 } 492 }
491 if (pPersudoFirst == NULL) { 493 if (pPersudoFirst == NULL) {
492 pPersudoFirst = pPersudoLast = p; 494 pPersudoFirst = pPersudoLast = p;
493 } else { 495 } else {
494 pPersudoLast->SetNext(p); 496 pPersudoLast->SetNext(p);
495 pPersudoLast = p; 497 pPersudoLast = p;
496 } 498 }
497 psz += iNameLen; 499 psz += iNameLen;
498 } else if (wch == ' ') { 500 } else if (wch == ' ') {
499 psz++; 501 psz++;
500 } else { 502 } else {
501 return NULL; 503 return NULL;
502 } 504 }
503 } 505 }
504 if (pPersudoFirst == NULL) { 506 if (pPersudoFirst == NULL) {
505 return pFirst; 507 return pFirst;
506 } else { 508 } else {
507 pPersudoLast->SetNext(pFirst); 509 pPersudoLast->SetNext(pFirst);
508 return pPersudoFirst; 510 return pPersudoFirst;
509 } 511 }
510 } 512 }
OLDNEW
« no previous file with comments | « xfa/fde/css/fde_cssstylesheet.h ('k') | xfa/fgas/crt/fgas_codepage.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698