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

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

Issue 2072803002: Make code compile with clang_use_chrome_plugin (final) (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: rebase Created 4 years, 6 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/fde/css/fde_csssyntax.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 <memory> 9 #include <memory>
10 10
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 IFX_Stream* pStream, 52 IFX_Stream* pStream,
53 uint16_t wCodePage, 53 uint16_t wCodePage,
54 uint32_t dwMediaList) { 54 uint32_t dwMediaList) {
55 CFDE_CSSStyleSheet* pStyleSheet = new CFDE_CSSStyleSheet(dwMediaList); 55 CFDE_CSSStyleSheet* pStyleSheet = new CFDE_CSSStyleSheet(dwMediaList);
56 if (!pStyleSheet->LoadFromStream(szUrl, pStream, wCodePage)) { 56 if (!pStyleSheet->LoadFromStream(szUrl, pStream, wCodePage)) {
57 pStyleSheet->Release(); 57 pStyleSheet->Release();
58 pStyleSheet = nullptr; 58 pStyleSheet = nullptr;
59 } 59 }
60 return pStyleSheet; 60 return pStyleSheet;
61 } 61 }
62
62 IFDE_CSSStyleSheet* IFDE_CSSStyleSheet::LoadFromBuffer( 63 IFDE_CSSStyleSheet* IFDE_CSSStyleSheet::LoadFromBuffer(
63 const CFX_WideString& szUrl, 64 const CFX_WideString& szUrl,
64 const FX_WCHAR* pBuffer, 65 const FX_WCHAR* pBuffer,
65 int32_t iBufSize, 66 int32_t iBufSize,
66 uint16_t wCodePage, 67 uint16_t wCodePage,
67 uint32_t dwMediaList) { 68 uint32_t dwMediaList) {
68 CFDE_CSSStyleSheet* pStyleSheet = new CFDE_CSSStyleSheet(dwMediaList); 69 CFDE_CSSStyleSheet* pStyleSheet = new CFDE_CSSStyleSheet(dwMediaList);
69 if (!pStyleSheet->LoadFromBuffer(szUrl, pBuffer, iBufSize, wCodePage)) { 70 if (!pStyleSheet->LoadFromBuffer(szUrl, pBuffer, iBufSize, wCodePage)) {
70 pStyleSheet->Release(); 71 pStyleSheet->Release();
71 pStyleSheet = nullptr; 72 pStyleSheet = nullptr;
72 } 73 }
73 return pStyleSheet; 74 return pStyleSheet;
74 } 75 }
76
75 CFDE_CSSStyleSheet::CFDE_CSSStyleSheet(uint32_t dwMediaList) 77 CFDE_CSSStyleSheet::CFDE_CSSStyleSheet(uint32_t dwMediaList)
76 : m_wCodePage(FX_CODEPAGE_UTF8), 78 : m_wCodePage(FX_CODEPAGE_UTF8),
77 m_wRefCount(1), 79 m_wRefCount(1),
78 m_dwMediaList(dwMediaList), 80 m_dwMediaList(dwMediaList),
79 m_pAllocator(nullptr) { 81 m_pAllocator(nullptr) {
80 ASSERT(m_dwMediaList > 0); 82 ASSERT(m_dwMediaList > 0);
81 } 83 }
84
82 CFDE_CSSStyleSheet::~CFDE_CSSStyleSheet() { 85 CFDE_CSSStyleSheet::~CFDE_CSSStyleSheet() {
83 Reset(); 86 Reset();
84 } 87 }
88
85 void CFDE_CSSStyleSheet::Reset() { 89 void CFDE_CSSStyleSheet::Reset() {
86 for (int32_t i = m_RuleArray.GetSize() - 1; i >= 0; --i) { 90 for (int32_t i = m_RuleArray.GetSize() - 1; i >= 0; --i) {
87 IFDE_CSSRule* pRule = m_RuleArray.GetAt(i); 91 IFDE_CSSRule* pRule = m_RuleArray.GetAt(i);
88 switch (pRule->GetType()) { 92 switch (pRule->GetType()) {
89 case FDE_CSSRULETYPE_Style: 93 case FDE_CSSRULETYPE_Style:
90 static_cast<CFDE_CSSStyleRule*>(pRule)->~CFDE_CSSStyleRule(); 94 static_cast<CFDE_CSSStyleRule*>(pRule)->~CFDE_CSSStyleRule();
91 break; 95 break;
92 case FDE_CSSRULETYPE_Media: 96 case FDE_CSSRULETYPE_Media:
93 static_cast<CFDE_CSSMediaRule*>(pRule)->~CFDE_CSSMediaRule(); 97 static_cast<CFDE_CSSMediaRule*>(pRule)->~CFDE_CSSMediaRule();
94 break; 98 break;
95 case FDE_CSSRULETYPE_FontFace: 99 case FDE_CSSRULETYPE_FontFace:
96 static_cast<CFDE_CSSFontFaceRule*>(pRule)->~CFDE_CSSFontFaceRule(); 100 static_cast<CFDE_CSSFontFaceRule*>(pRule)->~CFDE_CSSFontFaceRule();
97 break; 101 break;
98 default: 102 default:
99 ASSERT(FALSE); 103 ASSERT(FALSE);
100 break; 104 break;
101 } 105 }
102 } 106 }
103 m_RuleArray.RemoveAll(); 107 m_RuleArray.RemoveAll();
104 m_Selectors.RemoveAll(); 108 m_Selectors.RemoveAll();
105 m_StringCache.clear(); 109 m_StringCache.clear();
106 delete m_pAllocator; 110 delete m_pAllocator;
107 m_pAllocator = nullptr; 111 m_pAllocator = nullptr;
108 } 112 }
113
109 uint32_t CFDE_CSSStyleSheet::Retain() { 114 uint32_t CFDE_CSSStyleSheet::Retain() {
110 return ++m_wRefCount; 115 return ++m_wRefCount;
111 } 116 }
117
112 uint32_t CFDE_CSSStyleSheet::Release() { 118 uint32_t CFDE_CSSStyleSheet::Release() {
113 uint32_t dwRefCount = --m_wRefCount; 119 uint32_t dwRefCount = --m_wRefCount;
114 if (dwRefCount == 0) { 120 if (dwRefCount == 0) {
115 delete this; 121 delete this;
116 } 122 }
117 return dwRefCount; 123 return dwRefCount;
118 } 124 }
125
126 FX_BOOL CFDE_CSSStyleSheet::GetUrl(CFX_WideString& szUrl) {
127 szUrl = m_szUrl;
128 return szUrl.GetLength() > 0;
129 }
130
131 uint32_t CFDE_CSSStyleSheet::GetMediaList() const {
132 return m_dwMediaList;
133 }
134
135 uint16_t CFDE_CSSStyleSheet::GetCodePage() const {
136 return m_wCodePage;
137 }
138
119 int32_t CFDE_CSSStyleSheet::CountRules() const { 139 int32_t CFDE_CSSStyleSheet::CountRules() const {
120 return m_RuleArray.GetSize(); 140 return m_RuleArray.GetSize();
121 } 141 }
142
122 IFDE_CSSRule* CFDE_CSSStyleSheet::GetRule(int32_t index) { 143 IFDE_CSSRule* CFDE_CSSStyleSheet::GetRule(int32_t index) {
123 return m_RuleArray.GetAt(index); 144 return m_RuleArray.GetAt(index);
124 } 145 }
125 146
126 FX_BOOL CFDE_CSSStyleSheet::LoadFromStream(const CFX_WideString& szUrl, 147 FX_BOOL CFDE_CSSStyleSheet::LoadFromStream(const CFX_WideString& szUrl,
127 IFX_Stream* pStream, 148 IFX_Stream* pStream,
128 uint16_t wCodePage) { 149 uint16_t wCodePage) {
129 std::unique_ptr<CFDE_CSSSyntaxParser> pSyntax(new CFDE_CSSSyntaxParser); 150 std::unique_ptr<CFDE_CSSSyntaxParser> pSyntax(new CFDE_CSSSyntaxParser);
130 if (pStream->GetCodePage() != wCodePage) 151 if (pStream->GetCodePage() != wCodePage)
131 pStream->SetCodePage(wCodePage); 152 pStream->SetCodePage(wCodePage);
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 eStatus = LoadPageRule(pSyntax); 192 eStatus = LoadPageRule(pSyntax);
172 break; 193 break;
173 default: 194 default:
174 break; 195 break;
175 } 196 }
176 } while (eStatus >= FDE_CSSSYNTAXSTATUS_None); 197 } while (eStatus >= FDE_CSSSYNTAXSTATUS_None);
177 m_Selectors.RemoveAll(); 198 m_Selectors.RemoveAll();
178 m_StringCache.clear(); 199 m_StringCache.clear();
179 return eStatus != FDE_CSSSYNTAXSTATUS_Error; 200 return eStatus != FDE_CSSSYNTAXSTATUS_Error;
180 } 201 }
202
181 FDE_CSSSYNTAXSTATUS CFDE_CSSStyleSheet::LoadMediaRule( 203 FDE_CSSSYNTAXSTATUS CFDE_CSSStyleSheet::LoadMediaRule(
182 CFDE_CSSSyntaxParser* pSyntax) { 204 CFDE_CSSSyntaxParser* pSyntax) {
183 uint32_t dwMediaList = 0; 205 uint32_t dwMediaList = 0;
184 CFDE_CSSMediaRule* pMediaRule = nullptr; 206 CFDE_CSSMediaRule* pMediaRule = nullptr;
185 for (;;) { 207 for (;;) {
186 switch (pSyntax->DoSyntaxParse()) { 208 switch (pSyntax->DoSyntaxParse()) {
187 case FDE_CSSSYNTAXSTATUS_MediaType: { 209 case FDE_CSSSYNTAXSTATUS_MediaType: {
188 int32_t iLen; 210 int32_t iLen;
189 const FX_WCHAR* psz = pSyntax->GetCurrentString(iLen); 211 const FX_WCHAR* psz = pSyntax->GetCurrentString(iLen);
190 FDE_LPCCSSMEDIATYPETABLE pMediaType = 212 FDE_LPCCSSMEDIATYPETABLE pMediaType =
(...skipping 18 matching lines...) Expand all
209 FXTARGET_NewWith(m_pAllocator) CFDE_CSSMediaRule(dwMediaList); 231 FXTARGET_NewWith(m_pAllocator) CFDE_CSSMediaRule(dwMediaList);
210 m_RuleArray.Add(pMediaRule); 232 m_RuleArray.Add(pMediaRule);
211 } 233 }
212 break; 234 break;
213 case FDE_CSSSYNTAXSTATUS_DeclClose: 235 case FDE_CSSSYNTAXSTATUS_DeclClose:
214 return FDE_CSSSYNTAXSTATUS_None; 236 return FDE_CSSSYNTAXSTATUS_None;
215 FDE_CSSSWITCHDEFAULTS(); 237 FDE_CSSSWITCHDEFAULTS();
216 } 238 }
217 } 239 }
218 } 240 }
241
219 FDE_CSSSYNTAXSTATUS CFDE_CSSStyleSheet::LoadStyleRule( 242 FDE_CSSSYNTAXSTATUS CFDE_CSSStyleSheet::LoadStyleRule(
220 CFDE_CSSSyntaxParser* pSyntax, 243 CFDE_CSSSyntaxParser* pSyntax,
221 CFDE_CSSRuleArray& ruleArray) { 244 CFDE_CSSRuleArray& ruleArray) {
222 m_Selectors.RemoveAt(0, m_Selectors.GetSize()); 245 m_Selectors.RemoveAt(0, m_Selectors.GetSize());
223 CFDE_CSSStyleRule* pStyleRule = nullptr; 246 CFDE_CSSStyleRule* pStyleRule = nullptr;
224 const FX_WCHAR* pszValue = nullptr; 247 const FX_WCHAR* pszValue = nullptr;
225 int32_t iValueLen = 0; 248 int32_t iValueLen = 0;
226 FDE_CSSPROPERTYARGS propertyArgs; 249 FDE_CSSPROPERTYARGS propertyArgs;
227 propertyArgs.pStaticStore = m_pAllocator; 250 propertyArgs.pStaticStore = m_pAllocator;
228 propertyArgs.pStringCache = &m_StringCache; 251 propertyArgs.pStringCache = &m_StringCache;
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 case FDE_CSSSYNTAXSTATUS_DeclClose: 296 case FDE_CSSSYNTAXSTATUS_DeclClose:
274 if (pStyleRule && !pStyleRule->GetDeclImp().GetStartPosition()) { 297 if (pStyleRule && !pStyleRule->GetDeclImp().GetStartPosition()) {
275 pStyleRule->~CFDE_CSSStyleRule(); 298 pStyleRule->~CFDE_CSSStyleRule();
276 ruleArray.RemoveLast(1); 299 ruleArray.RemoveLast(1);
277 } 300 }
278 return FDE_CSSSYNTAXSTATUS_None; 301 return FDE_CSSSYNTAXSTATUS_None;
279 FDE_CSSSWITCHDEFAULTS(); 302 FDE_CSSSWITCHDEFAULTS();
280 } 303 }
281 } 304 }
282 } 305 }
306
283 FDE_CSSSYNTAXSTATUS CFDE_CSSStyleSheet::LoadFontFaceRule( 307 FDE_CSSSYNTAXSTATUS CFDE_CSSStyleSheet::LoadFontFaceRule(
284 CFDE_CSSSyntaxParser* pSyntax, 308 CFDE_CSSSyntaxParser* pSyntax,
285 CFDE_CSSRuleArray& ruleArray) { 309 CFDE_CSSRuleArray& ruleArray) {
286 CFDE_CSSFontFaceRule* pFontFaceRule = nullptr; 310 CFDE_CSSFontFaceRule* pFontFaceRule = nullptr;
287 const FX_WCHAR* pszValue = nullptr; 311 const FX_WCHAR* pszValue = nullptr;
288 int32_t iValueLen = 0; 312 int32_t iValueLen = 0;
289 FDE_CSSPROPERTYARGS propertyArgs; 313 FDE_CSSPROPERTYARGS propertyArgs;
290 propertyArgs.pStaticStore = m_pAllocator; 314 propertyArgs.pStaticStore = m_pAllocator;
291 propertyArgs.pStringCache = &m_StringCache; 315 propertyArgs.pStringCache = &m_StringCache;
292 propertyArgs.pProperty = nullptr; 316 propertyArgs.pProperty = nullptr;
(...skipping 18 matching lines...) Expand all
311 pFontFaceRule = FXTARGET_NewWith(m_pAllocator) CFDE_CSSFontFaceRule; 335 pFontFaceRule = FXTARGET_NewWith(m_pAllocator) CFDE_CSSFontFaceRule;
312 ruleArray.Add(pFontFaceRule); 336 ruleArray.Add(pFontFaceRule);
313 } 337 }
314 break; 338 break;
315 case FDE_CSSSYNTAXSTATUS_DeclClose: 339 case FDE_CSSSYNTAXSTATUS_DeclClose:
316 return FDE_CSSSYNTAXSTATUS_None; 340 return FDE_CSSSYNTAXSTATUS_None;
317 FDE_CSSSWITCHDEFAULTS(); 341 FDE_CSSSWITCHDEFAULTS();
318 } 342 }
319 } 343 }
320 } 344 }
345
321 FDE_CSSSYNTAXSTATUS CFDE_CSSStyleSheet::LoadImportRule( 346 FDE_CSSSYNTAXSTATUS CFDE_CSSStyleSheet::LoadImportRule(
322 CFDE_CSSSyntaxParser* pSyntax) { 347 CFDE_CSSSyntaxParser* pSyntax) {
323 for (;;) { 348 for (;;) {
324 switch (pSyntax->DoSyntaxParse()) { 349 switch (pSyntax->DoSyntaxParse()) {
325 case FDE_CSSSYNTAXSTATUS_ImportClose: 350 case FDE_CSSSYNTAXSTATUS_ImportClose:
326 return FDE_CSSSYNTAXSTATUS_None; 351 return FDE_CSSSYNTAXSTATUS_None;
327 case FDE_CSSSYNTAXSTATUS_URI: 352 case FDE_CSSSYNTAXSTATUS_URI:
328 break; 353 break;
329 FDE_CSSSWITCHDEFAULTS(); 354 FDE_CSSSWITCHDEFAULTS();
330 } 355 }
331 } 356 }
332 } 357 }
358
333 FDE_CSSSYNTAXSTATUS CFDE_CSSStyleSheet::LoadPageRule( 359 FDE_CSSSYNTAXSTATUS CFDE_CSSStyleSheet::LoadPageRule(
334 CFDE_CSSSyntaxParser* pSyntax) { 360 CFDE_CSSSyntaxParser* pSyntax) {
335 return SkipRuleSet(pSyntax); 361 return SkipRuleSet(pSyntax);
336 } 362 }
363
337 FDE_CSSSYNTAXSTATUS CFDE_CSSStyleSheet::SkipRuleSet( 364 FDE_CSSSYNTAXSTATUS CFDE_CSSStyleSheet::SkipRuleSet(
338 CFDE_CSSSyntaxParser* pSyntax) { 365 CFDE_CSSSyntaxParser* pSyntax) {
339 for (;;) { 366 for (;;) {
340 switch (pSyntax->DoSyntaxParse()) { 367 switch (pSyntax->DoSyntaxParse()) {
341 case FDE_CSSSYNTAXSTATUS_Selector: 368 case FDE_CSSSYNTAXSTATUS_Selector:
342 case FDE_CSSSYNTAXSTATUS_DeclOpen: 369 case FDE_CSSSYNTAXSTATUS_DeclOpen:
343 case FDE_CSSSYNTAXSTATUS_PropertyName: 370 case FDE_CSSSYNTAXSTATUS_PropertyName:
344 case FDE_CSSSYNTAXSTATUS_PropertyValue: 371 case FDE_CSSSYNTAXSTATUS_PropertyValue:
345 break; 372 break;
346 case FDE_CSSSYNTAXSTATUS_DeclClose: 373 case FDE_CSSSYNTAXSTATUS_DeclClose:
347 return FDE_CSSSYNTAXSTATUS_None; 374 return FDE_CSSSYNTAXSTATUS_None;
348 FDE_CSSSWITCHDEFAULTS(); 375 FDE_CSSSWITCHDEFAULTS();
349 } 376 }
350 } 377 }
351 } 378 }
379
380 CFDE_CSSStyleRule::CFDE_CSSStyleRule() : m_ppSelector(NULL), m_iSelectors(0) {}
381
382 int32_t CFDE_CSSStyleRule::CountSelectorLists() const {
383 return m_iSelectors;
384 }
385
386 CFDE_CSSSelector* CFDE_CSSStyleRule::GetSelectorList(int32_t index) const {
387 return m_ppSelector[index];
388 }
389
390 CFDE_CSSDeclaration* CFDE_CSSStyleRule::GetDeclaration() {
391 return &m_Declaration;
392 }
393
352 void CFDE_CSSStyleRule::SetSelector(IFX_MemoryAllocator* pStaticStore, 394 void CFDE_CSSStyleRule::SetSelector(IFX_MemoryAllocator* pStaticStore,
353 const CFDE_CSSSelectorArray& list) { 395 const CFDE_CSSSelectorArray& list) {
354 ASSERT(!m_ppSelector); 396 ASSERT(!m_ppSelector);
355 m_iSelectors = list.GetSize(); 397 m_iSelectors = list.GetSize();
356 m_ppSelector = static_cast<CFDE_CSSSelector**>( 398 m_ppSelector = static_cast<CFDE_CSSSelector**>(
357 pStaticStore->Alloc(m_iSelectors * sizeof(CFDE_CSSSelector*))); 399 pStaticStore->Alloc(m_iSelectors * sizeof(CFDE_CSSSelector*)));
358 for (int32_t i = 0; i < m_iSelectors; ++i) { 400 for (int32_t i = 0; i < m_iSelectors; ++i) {
359 m_ppSelector[i] = list.GetAt(i); 401 m_ppSelector[i] = list.GetAt(i);
360 } 402 }
361 } 403 }
404
405 CFDE_CSSMediaRule::CFDE_CSSMediaRule(uint32_t dwMediaList)
406 : m_dwMediaList(dwMediaList) {}
407
362 CFDE_CSSMediaRule::~CFDE_CSSMediaRule() { 408 CFDE_CSSMediaRule::~CFDE_CSSMediaRule() {
363 for (int32_t i = m_RuleArray.GetSize() - 1; i >= 0; --i) { 409 for (int32_t i = m_RuleArray.GetSize() - 1; i >= 0; --i) {
364 IFDE_CSSRule* pRule = m_RuleArray.GetAt(i); 410 IFDE_CSSRule* pRule = m_RuleArray.GetAt(i);
365 switch (pRule->GetType()) { 411 switch (pRule->GetType()) {
366 case FDE_CSSRULETYPE_Style: 412 case FDE_CSSRULETYPE_Style:
367 ((CFDE_CSSStyleRule*)pRule)->~CFDE_CSSStyleRule(); 413 ((CFDE_CSSStyleRule*)pRule)->~CFDE_CSSStyleRule();
368 break; 414 break;
369 default: 415 default:
370 ASSERT(FALSE); 416 ASSERT(FALSE);
371 break; 417 break;
372 } 418 }
373 } 419 }
374 } 420 }
375 inline FX_BOOL FDE_IsCSSChar(FX_WCHAR wch) { 421
422 uint32_t CFDE_CSSMediaRule::GetMediaList() const {
423 return m_dwMediaList;
424 }
425
426 int32_t CFDE_CSSMediaRule::CountRules() const {
427 return m_RuleArray.GetSize();
428 }
429
430 IFDE_CSSRule* CFDE_CSSMediaRule::GetRule(int32_t index) {
431 return m_RuleArray.GetAt(index);
432 }
433
434 FX_BOOL FDE_IsCSSChar(FX_WCHAR wch) {
376 return (wch >= 'a' && wch <= 'z') || (wch >= 'A' && wch <= 'Z'); 435 return (wch >= 'a' && wch <= 'z') || (wch >= 'A' && wch <= 'Z');
377 } 436 }
437
378 int32_t FDE_GetCSSPersudoLen(const FX_WCHAR* psz, const FX_WCHAR* pEnd) { 438 int32_t FDE_GetCSSPersudoLen(const FX_WCHAR* psz, const FX_WCHAR* pEnd) {
379 ASSERT(*psz == ':'); 439 ASSERT(*psz == ':');
380 const FX_WCHAR* pStart = psz; 440 const FX_WCHAR* pStart = psz;
381 while (psz < pEnd) { 441 while (psz < pEnd) {
382 FX_WCHAR wch = *psz; 442 FX_WCHAR wch = *psz;
383 if (FDE_IsCSSChar(wch) || wch == ':') { 443 if (FDE_IsCSSChar(wch) || wch == ':') {
384 ++psz; 444 ++psz;
385 } else { 445 } else {
386 break; 446 break;
387 } 447 }
388 } 448 }
389 return psz - pStart; 449 return psz - pStart;
390 } 450 }
451
391 int32_t FDE_GetCSSNameLen(const FX_WCHAR* psz, const FX_WCHAR* pEnd) { 452 int32_t FDE_GetCSSNameLen(const FX_WCHAR* psz, const FX_WCHAR* pEnd) {
392 const FX_WCHAR* pStart = psz; 453 const FX_WCHAR* pStart = psz;
393 while (psz < pEnd) { 454 while (psz < pEnd) {
394 FX_WCHAR wch = *psz; 455 FX_WCHAR wch = *psz;
395 if (FDE_IsCSSChar(wch) || (wch >= '0' && wch <= '9') || wch == '_' || 456 if (FDE_IsCSSChar(wch) || (wch >= '0' && wch <= '9') || wch == '_' ||
396 wch == '-') { 457 wch == '-') {
397 ++psz; 458 ++psz;
398 } else { 459 } else {
399 break; 460 break;
400 } 461 }
401 } 462 }
402 return psz - pStart; 463 return psz - pStart;
403 } 464 }
465
466 CFDE_CSSSelector::CFDE_CSSSelector(FDE_CSSSELECTORTYPE eType,
467 const FX_WCHAR* psz,
468 int32_t iLen,
469 bool bIgnoreCase)
470 : m_eType(eType),
471 m_dwHash(FX_HashCode_GetW(CFX_WideStringC(psz, iLen), bIgnoreCase)),
472 m_pNext(nullptr) {}
473
474 FDE_CSSSELECTORTYPE CFDE_CSSSelector::GetType() const {
475 return m_eType;
476 }
477
478 uint32_t CFDE_CSSSelector::GetNameHash() const {
479 return m_dwHash;
480 }
481
482 CFDE_CSSSelector* CFDE_CSSSelector::GetNextSelector() const {
483 return m_pNext;
484 }
485
404 CFDE_CSSSelector* CFDE_CSSSelector::FromString( 486 CFDE_CSSSelector* CFDE_CSSSelector::FromString(
405 IFX_MemoryAllocator* pStaticStore, 487 IFX_MemoryAllocator* pStaticStore,
406 const FX_WCHAR* psz, 488 const FX_WCHAR* psz,
407 int32_t iLen) { 489 int32_t iLen) {
408 ASSERT(pStaticStore && psz && iLen > 0); 490 ASSERT(pStaticStore && psz && iLen > 0);
491
409 const FX_WCHAR* pStart = psz; 492 const FX_WCHAR* pStart = psz;
410 const FX_WCHAR* pEnd = psz + iLen; 493 const FX_WCHAR* pEnd = psz + iLen;
411 for (; psz < pEnd; ++psz) { 494 for (; psz < pEnd; ++psz) {
412 switch (*psz) { 495 switch (*psz) {
413 case '>': 496 case '>':
414 case '[': 497 case '[':
415 case '+': 498 case '+':
416 return nullptr; 499 return nullptr;
417 } 500 }
418 } 501 }
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
489 } else { 572 } else {
490 return nullptr; 573 return nullptr;
491 } 574 }
492 } 575 }
493 if (!pPersudoFirst) 576 if (!pPersudoFirst)
494 return pFirst; 577 return pFirst;
495 578
496 pPersudoLast->SetNext(pFirst); 579 pPersudoLast->SetNext(pFirst);
497 return pPersudoFirst; 580 return pPersudoFirst;
498 } 581 }
582
583 CFDE_CSSDeclaration* CFDE_CSSFontFaceRule::GetDeclaration() {
584 return &m_Declaration;
585 }
OLDNEW
« no previous file with comments | « xfa/fde/css/fde_cssstylesheet.h ('k') | xfa/fde/css/fde_csssyntax.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698