OLD | NEW |
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 #include <memory> | 10 #include <memory> |
(...skipping 10 matching lines...) Expand all Loading... |
21 int32_t iCount = m_arrCounterData.GetSize(); | 21 int32_t iCount = m_arrCounterData.GetSize(); |
22 for (int32_t i = 0; i < iCount; i++) { | 22 for (int32_t i = 0; i < iCount; i++) { |
23 if (FXSYS_wcscmp(pszIdentifier, m_arrCounterData.ElementAt(i).m_pszIdent) == | 23 if (FXSYS_wcscmp(pszIdentifier, m_arrCounterData.ElementAt(i).m_pszIdent) == |
24 0) { | 24 0) { |
25 return i; | 25 return i; |
26 } | 26 } |
27 } | 27 } |
28 return -1; | 28 return -1; |
29 } | 29 } |
30 void CFDE_CSSCounterStyle::DoUpdateIndex(IFDE_CSSValueList* pList) { | 30 void CFDE_CSSCounterStyle::DoUpdateIndex(IFDE_CSSValueList* pList) { |
31 if (pList == NULL) { | 31 if (!pList) |
32 return; | 32 return; |
33 } | 33 |
34 int32_t iCount = pList->CountValues(); | 34 int32_t iCount = pList->CountValues(); |
35 FX_FLOAT fDefValue = 1.0; | 35 FX_FLOAT fDefValue = 1.0; |
36 FX_BOOL bDefIncrement = TRUE; | 36 FX_BOOL bDefIncrement = TRUE; |
37 if (pList == m_pCounterReset) { | 37 if (pList == m_pCounterReset) { |
38 fDefValue = 0.0; | 38 fDefValue = 0.0; |
39 bDefIncrement = FALSE; | 39 bDefIncrement = FALSE; |
40 } | 40 } |
41 for (int32_t i = 0; i < iCount; i++) { | 41 for (int32_t i = 0; i < iCount; i++) { |
42 IFDE_CSSValueList* pCounter = (IFDE_CSSValueList*)pList->GetValue(i); | 42 IFDE_CSSValueList* pCounter = (IFDE_CSSValueList*)pList->GetValue(i); |
43 int32_t iLen; | 43 int32_t iLen; |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 } | 77 } |
78 m_arrCounterData.RemoveAll(); | 78 m_arrCounterData.RemoveAll(); |
79 DoUpdateIndex(m_pCounterInc); | 79 DoUpdateIndex(m_pCounterInc); |
80 DoUpdateIndex(m_pCounterReset); | 80 DoUpdateIndex(m_pCounterReset); |
81 m_bIndexDirty = FALSE; | 81 m_bIndexDirty = FALSE; |
82 } | 82 } |
83 | 83 |
84 FDE_CSSRuleData::FDE_CSSRuleData(CFDE_CSSSelector* pSel, | 84 FDE_CSSRuleData::FDE_CSSRuleData(CFDE_CSSSelector* pSel, |
85 CFDE_CSSDeclaration* pDecl, | 85 CFDE_CSSDeclaration* pDecl, |
86 uint32_t dwPos) | 86 uint32_t dwPos) |
87 : pSelector(pSel), pDeclaration(pDecl), dwPriority(dwPos), pNext(NULL) { | 87 : pSelector(pSel), pDeclaration(pDecl), dwPriority(dwPos), pNext(nullptr) { |
88 static const uint32_t s_Specific[5] = {0x00010000, 0x00010000, 0x00100000, | 88 static const uint32_t s_Specific[5] = {0x00010000, 0x00010000, 0x00100000, |
89 0x00100000, 0x01000000}; | 89 0x00100000, 0x01000000}; |
90 for (; pSel != NULL; pSel = pSel->GetNextSelector()) { | 90 for (; pSel; pSel = pSel->GetNextSelector()) { |
91 FDE_CSSSELECTORTYPE eType = pSel->GetType(); | 91 FDE_CSSSELECTORTYPE eType = pSel->GetType(); |
92 if (eType > FDE_CSSSELECTORTYPE_Descendant || | 92 if (eType > FDE_CSSSELECTORTYPE_Descendant || |
93 pSel->GetNameHash() != FDE_CSSUNIVERSALHASH) { | 93 pSel->GetNameHash() != FDE_CSSUNIVERSALHASH) { |
94 dwPriority += s_Specific[eType]; | 94 dwPriority += s_Specific[eType]; |
95 } | 95 } |
96 } | 96 } |
97 } | 97 } |
98 void CFDE_CSSRuleCollection::Clear() { | 98 void CFDE_CSSRuleCollection::Clear() { |
99 m_IDRules.RemoveAll(); | 99 m_IDRules.RemoveAll(); |
100 m_TagRules.RemoveAll(); | 100 m_TagRules.RemoveAll(); |
101 m_ClassRules.RemoveAll(); | 101 m_ClassRules.RemoveAll(); |
102 m_pUniversalRules = NULL; | 102 m_pUniversalRules = nullptr; |
103 m_pStaticStore = NULL; | 103 m_pStaticStore = nullptr; |
104 m_iSelectors = 0; | 104 m_iSelectors = 0; |
105 } | 105 } |
106 void CFDE_CSSRuleCollection::AddRulesFrom(const CFDE_CSSStyleSheetArray& sheets, | 106 void CFDE_CSSRuleCollection::AddRulesFrom(const CFDE_CSSStyleSheetArray& sheets, |
107 uint32_t dwMediaList, | 107 uint32_t dwMediaList, |
108 IFGAS_FontMgr* pFontMgr) { | 108 IFGAS_FontMgr* pFontMgr) { |
109 int32_t iSheets = sheets.GetSize(); | 109 int32_t iSheets = sheets.GetSize(); |
110 for (int32_t i = 0; i < iSheets; ++i) { | 110 for (int32_t i = 0; i < iSheets; ++i) { |
111 IFDE_CSSStyleSheet* pSheet = sheets.GetAt(i); | 111 IFDE_CSSStyleSheet* pSheet = sheets.GetAt(i); |
112 if (uint32_t dwMatchMedia = pSheet->GetMediaList() & dwMediaList) { | 112 if (uint32_t dwMatchMedia = pSheet->GetMediaList() & dwMediaList) { |
113 int32_t iRules = pSheet->CountRules(); | 113 int32_t iRules = pSheet->CountRules(); |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 default: | 175 default: |
176 break; | 176 break; |
177 } | 177 } |
178 } | 178 } |
179 void CFDE_CSSRuleCollection::AddRuleTo(CFX_MapPtrToPtr& map, | 179 void CFDE_CSSRuleCollection::AddRuleTo(CFX_MapPtrToPtr& map, |
180 uint32_t dwKey, | 180 uint32_t dwKey, |
181 CFDE_CSSSelector* pSel, | 181 CFDE_CSSSelector* pSel, |
182 CFDE_CSSDeclaration* pDecl) { | 182 CFDE_CSSDeclaration* pDecl) { |
183 void* pKey = (void*)(uintptr_t)dwKey; | 183 void* pKey = (void*)(uintptr_t)dwKey; |
184 FDE_CSSRuleData* pData = NewRuleData(pSel, pDecl); | 184 FDE_CSSRuleData* pData = NewRuleData(pSel, pDecl); |
185 FDE_CSSRuleData* pList = NULL; | 185 FDE_CSSRuleData* pList = nullptr; |
186 if (!map.Lookup(pKey, (void*&)pList)) { | 186 if (!map.Lookup(pKey, (void*&)pList)) { |
187 map.SetAt(pKey, pData); | 187 map.SetAt(pKey, pData); |
188 } else if (AddRuleTo(pList, pData)) { | 188 } else if (AddRuleTo(pList, pData)) { |
189 map.SetAt(pKey, pList); | 189 map.SetAt(pKey, pList); |
190 } | 190 } |
191 } | 191 } |
192 | 192 |
193 FX_BOOL CFDE_CSSRuleCollection::AddRuleTo(FDE_CSSRuleData*& pList, | 193 FX_BOOL CFDE_CSSRuleCollection::AddRuleTo(FDE_CSSRuleData*& pList, |
194 FDE_CSSRuleData* pData) { | 194 FDE_CSSRuleData* pData) { |
195 if (pList) { | 195 if (pList) { |
196 pData->pNext = pList->pNext; | 196 pData->pNext = pList->pNext; |
197 pList->pNext = pData; | 197 pList->pNext = pData; |
198 return FALSE; | 198 return FALSE; |
199 } | 199 } |
200 | 200 |
201 pList = pData; | 201 pList = pData; |
202 return TRUE; | 202 return TRUE; |
203 } | 203 } |
204 | 204 |
205 FDE_CSSRuleData* CFDE_CSSRuleCollection::NewRuleData( | 205 FDE_CSSRuleData* CFDE_CSSRuleCollection::NewRuleData( |
206 CFDE_CSSSelector* pSel, | 206 CFDE_CSSSelector* pSel, |
207 CFDE_CSSDeclaration* pDecl) { | 207 CFDE_CSSDeclaration* pDecl) { |
208 return FXTARGET_NewWith(m_pStaticStore) | 208 return FXTARGET_NewWith(m_pStaticStore) |
209 FDE_CSSRuleData(pSel, pDecl, ++m_iSelectors); | 209 FDE_CSSRuleData(pSel, pDecl, ++m_iSelectors); |
210 } | 210 } |
211 | 211 |
212 CFDE_CSSStyleSelector::CFDE_CSSStyleSelector() | 212 CFDE_CSSStyleSelector::CFDE_CSSStyleSelector() |
213 : m_pFontMgr(NULL), | 213 : m_pFontMgr(nullptr), |
214 m_fDefFontSize(12.0f), | 214 m_fDefFontSize(12.0f), |
215 m_pRuleDataStore(NULL), | 215 m_pRuleDataStore(nullptr), |
216 m_pInlineStyleStore(NULL), | 216 m_pInlineStyleStore(nullptr), |
217 m_pFixedStyleStore(NULL), | 217 m_pFixedStyleStore(nullptr), |
218 m_pAccelerator(NULL) { | 218 m_pAccelerator(nullptr) { |
219 m_ePriorities[FDE_CSSSTYLESHEETPRIORITY_High] = FDE_CSSSTYLESHEETGROUP_Author; | 219 m_ePriorities[FDE_CSSSTYLESHEETPRIORITY_High] = FDE_CSSSTYLESHEETGROUP_Author; |
220 m_ePriorities[FDE_CSSSTYLESHEETPRIORITY_Mid] = FDE_CSSSTYLESHEETGROUP_User; | 220 m_ePriorities[FDE_CSSSTYLESHEETPRIORITY_Mid] = FDE_CSSSTYLESHEETGROUP_User; |
221 m_ePriorities[FDE_CSSSTYLESHEETPRIORITY_Low] = | 221 m_ePriorities[FDE_CSSSTYLESHEETPRIORITY_Low] = |
222 FDE_CSSSTYLESHEETGROUP_UserAgent; | 222 FDE_CSSSTYLESHEETGROUP_UserAgent; |
223 } | 223 } |
224 | 224 |
225 CFDE_CSSStyleSelector::~CFDE_CSSStyleSelector() { | 225 CFDE_CSSStyleSelector::~CFDE_CSSStyleSelector() { |
226 Reset(); | 226 Reset(); |
227 delete m_pInlineStyleStore; | 227 delete m_pInlineStyleStore; |
228 delete m_pFixedStyleStore; | 228 delete m_pFixedStyleStore; |
(...skipping 30 matching lines...) Expand all Loading... |
259 pStyle->m_InheritedData.Reset(); | 259 pStyle->m_InheritedData.Reset(); |
260 } | 260 } |
261 pStyle->m_NonInheritedData.Reset(); | 261 pStyle->m_NonInheritedData.Reset(); |
262 return pStyle; | 262 return pStyle; |
263 } | 263 } |
264 FX_BOOL CFDE_CSSStyleSelector::SetStyleSheet(FDE_CSSSTYLESHEETGROUP eType, | 264 FX_BOOL CFDE_CSSStyleSelector::SetStyleSheet(FDE_CSSSTYLESHEETGROUP eType, |
265 IFDE_CSSStyleSheet* pSheet) { | 265 IFDE_CSSStyleSheet* pSheet) { |
266 ASSERT(eType < FDE_CSSSTYLESHEETGROUP_MAX); | 266 ASSERT(eType < FDE_CSSSTYLESHEETGROUP_MAX); |
267 CFDE_CSSStyleSheetArray& dest = m_SheetGroups[eType]; | 267 CFDE_CSSStyleSheetArray& dest = m_SheetGroups[eType]; |
268 dest.RemoveAt(0, dest.GetSize()); | 268 dest.RemoveAt(0, dest.GetSize()); |
269 if (pSheet != NULL) { | 269 if (pSheet) |
270 dest.Add(pSheet); | 270 dest.Add(pSheet); |
271 } | |
272 return TRUE; | 271 return TRUE; |
273 } | 272 } |
274 FX_BOOL CFDE_CSSStyleSelector::SetStyleSheets( | 273 FX_BOOL CFDE_CSSStyleSelector::SetStyleSheets( |
275 FDE_CSSSTYLESHEETGROUP eType, | 274 FDE_CSSSTYLESHEETGROUP eType, |
276 const CFDE_CSSStyleSheetArray* pArray) { | 275 const CFDE_CSSStyleSheetArray* pArray) { |
277 ASSERT(eType < FDE_CSSSTYLESHEETGROUP_MAX); | 276 ASSERT(eType < FDE_CSSSTYLESHEETGROUP_MAX); |
278 CFDE_CSSStyleSheetArray& dest = m_SheetGroups[eType]; | 277 CFDE_CSSStyleSheetArray& dest = m_SheetGroups[eType]; |
279 if (pArray == NULL) { | 278 if (pArray) |
| 279 dest.Copy(*pArray); |
| 280 else |
280 dest.RemoveAt(0, dest.GetSize()); | 281 dest.RemoveAt(0, dest.GetSize()); |
281 } else { | |
282 dest.Copy(*pArray); | |
283 } | |
284 return TRUE; | 282 return TRUE; |
285 } | 283 } |
286 void CFDE_CSSStyleSelector::SetStylePriority( | 284 void CFDE_CSSStyleSelector::SetStylePriority( |
287 FDE_CSSSTYLESHEETGROUP eType, | 285 FDE_CSSSTYLESHEETGROUP eType, |
288 FDE_CSSSTYLESHEETPRIORITY ePriority) { | 286 FDE_CSSSTYLESHEETPRIORITY ePriority) { |
289 m_ePriorities[ePriority] = eType; | 287 m_ePriorities[ePriority] = eType; |
290 } | 288 } |
291 void CFDE_CSSStyleSelector::UpdateStyleIndex(uint32_t dwMediaList) { | 289 void CFDE_CSSStyleSelector::UpdateStyleIndex(uint32_t dwMediaList) { |
292 Reset(); | 290 Reset(); |
293 m_pRuleDataStore = IFX_MemoryAllocator::Create(FX_ALLOCTYPE_Static, 1024, 0); | 291 m_pRuleDataStore = IFX_MemoryAllocator::Create(FX_ALLOCTYPE_Static, 1024, 0); |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
355 if (MatchSelector(pCache, pList->pSelector, ePersudoType)) | 353 if (MatchSelector(pCache, pList->pSelector, ePersudoType)) |
356 m_MatchedRules.push_back(pList); | 354 m_MatchedRules.push_back(pList); |
357 pList = pList->pNext; | 355 pList = pList->pNext; |
358 } | 356 } |
359 } | 357 } |
360 | 358 |
361 FX_BOOL CFDE_CSSStyleSelector::MatchSelector(FDE_CSSTagCache* pCache, | 359 FX_BOOL CFDE_CSSStyleSelector::MatchSelector(FDE_CSSTagCache* pCache, |
362 CFDE_CSSSelector* pSel, | 360 CFDE_CSSSelector* pSel, |
363 FDE_CSSPERSUDO ePersudoType) { | 361 FDE_CSSPERSUDO ePersudoType) { |
364 uint32_t dwHash; | 362 uint32_t dwHash; |
365 while (pSel != NULL && pCache != NULL) { | 363 while (pSel && pCache) { |
366 switch (pSel->GetType()) { | 364 switch (pSel->GetType()) { |
367 case FDE_CSSSELECTORTYPE_Descendant: | 365 case FDE_CSSSELECTORTYPE_Descendant: |
368 dwHash = pSel->GetNameHash(); | 366 dwHash = pSel->GetNameHash(); |
369 while ((pCache = pCache->GetParent()) != NULL) { | 367 while ((pCache = pCache->GetParent()) != nullptr) { |
370 if (dwHash != FDE_CSSUNIVERSALHASH && dwHash != pCache->HashTag()) { | 368 if (dwHash != FDE_CSSUNIVERSALHASH && dwHash != pCache->HashTag()) { |
371 continue; | 369 continue; |
372 } | 370 } |
373 if (MatchSelector(pCache, pSel->GetNextSelector(), ePersudoType)) { | 371 if (MatchSelector(pCache, pSel->GetNextSelector(), ePersudoType)) { |
374 return TRUE; | 372 return TRUE; |
375 } | 373 } |
376 } | 374 } |
377 return FALSE; | 375 return FALSE; |
378 case FDE_CSSSELECTORTYPE_ID: | 376 case FDE_CSSSELECTORTYPE_ID: |
379 dwHash = pCache->HashID(); | 377 dwHash = pCache->HashID(); |
(...skipping 18 matching lines...) Expand all Loading... |
398 if (dwHash != pSel->GetNameHash()) { | 396 if (dwHash != pSel->GetNameHash()) { |
399 return FALSE; | 397 return FALSE; |
400 } | 398 } |
401 break; | 399 break; |
402 default: | 400 default: |
403 ASSERT(FALSE); | 401 ASSERT(FALSE); |
404 break; | 402 break; |
405 } | 403 } |
406 pSel = pSel->GetNextSelector(); | 404 pSel = pSel->GetNextSelector(); |
407 } | 405 } |
408 return pSel == NULL && pCache != NULL; | 406 return !pSel && pCache; |
409 } | 407 } |
410 | 408 |
411 void CFDE_CSSStyleSelector::ComputeStyle( | 409 void CFDE_CSSStyleSelector::ComputeStyle( |
412 CXFA_CSSTagProvider* pTag, | 410 CXFA_CSSTagProvider* pTag, |
413 const CFDE_CSSDeclaration** ppDeclArray, | 411 const CFDE_CSSDeclaration** ppDeclArray, |
414 int32_t iDeclCount, | 412 int32_t iDeclCount, |
415 IFDE_CSSComputedStyle* pDestStyle) { | 413 IFDE_CSSComputedStyle* pDestStyle) { |
416 ASSERT(iDeclCount >= 0); | 414 ASSERT(iDeclCount >= 0); |
417 ASSERT(pDestStyle); | 415 ASSERT(pDestStyle); |
418 | 416 |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
473 void CFDE_CSSStyleSelector::ApplyDeclarations( | 471 void CFDE_CSSStyleSelector::ApplyDeclarations( |
474 FX_BOOL bPriority, | 472 FX_BOOL bPriority, |
475 const CFDE_CSSDeclaration** ppDeclArray, | 473 const CFDE_CSSDeclaration** ppDeclArray, |
476 int32_t iDeclCount, | 474 int32_t iDeclCount, |
477 IFDE_CSSComputedStyle* pDestStyle) { | 475 IFDE_CSSComputedStyle* pDestStyle) { |
478 CFDE_CSSComputedStyle* pComputedStyle = (CFDE_CSSComputedStyle*)pDestStyle; | 476 CFDE_CSSComputedStyle* pComputedStyle = (CFDE_CSSComputedStyle*)pDestStyle; |
479 IFDE_CSSValue* pVal; | 477 IFDE_CSSValue* pVal; |
480 FX_BOOL bImportant; | 478 FX_BOOL bImportant; |
481 int32_t i; | 479 int32_t i; |
482 if (bPriority) { | 480 if (bPriority) { |
483 IFDE_CSSValue *pLastest = NULL, *pImportant = NULL; | 481 IFDE_CSSValue *pLastest = nullptr, *pImportant = nullptr; |
484 for (i = 0; i < iDeclCount; ++i) { | 482 for (i = 0; i < iDeclCount; ++i) { |
485 pVal = ppDeclArray[i]->GetProperty(FDE_CSSPROPERTY_FontSize, bImportant); | 483 pVal = ppDeclArray[i]->GetProperty(FDE_CSSPROPERTY_FontSize, bImportant); |
486 if (pVal == NULL) { | 484 if (!pVal) |
487 continue; | 485 continue; |
488 } else if (bImportant) { | 486 |
| 487 if (bImportant) |
489 pImportant = pVal; | 488 pImportant = pVal; |
490 } else { | 489 else |
491 pLastest = pVal; | 490 pLastest = pVal; |
492 } | |
493 } | 491 } |
494 if (pImportant) { | 492 if (pImportant) { |
495 ApplyProperty(FDE_CSSPROPERTY_FontSize, pImportant, pComputedStyle); | 493 ApplyProperty(FDE_CSSPROPERTY_FontSize, pImportant, pComputedStyle); |
496 } else if (pLastest) { | 494 } else if (pLastest) { |
497 ApplyProperty(FDE_CSSPROPERTY_FontSize, pLastest, pComputedStyle); | 495 ApplyProperty(FDE_CSSPROPERTY_FontSize, pLastest, pComputedStyle); |
498 } | 496 } |
499 } else { | 497 } else { |
500 CFDE_CSSDeclarationArray importants; | 498 CFDE_CSSDeclarationArray importants; |
501 const CFDE_CSSDeclaration* pDecl = nullptr; | 499 const CFDE_CSSDeclaration* pDecl = nullptr; |
502 FDE_CSSPROPERTY eProp; | 500 FDE_CSSPROPERTY eProp; |
503 FX_POSITION pos; | 501 FX_POSITION pos; |
504 for (i = 0; i < iDeclCount; ++i) { | 502 for (i = 0; i < iDeclCount; ++i) { |
505 pDecl = ppDeclArray[i]; | 503 pDecl = ppDeclArray[i]; |
506 pos = pDecl->GetStartPosition(); | 504 pos = pDecl->GetStartPosition(); |
507 while (pos != NULL) { | 505 while (pos) { |
508 pDecl->GetNextProperty(pos, eProp, pVal, bImportant); | 506 pDecl->GetNextProperty(pos, eProp, pVal, bImportant); |
509 if (eProp == FDE_CSSPROPERTY_FontSize) { | 507 if (eProp == FDE_CSSPROPERTY_FontSize) { |
510 continue; | 508 continue; |
511 } else if (!bImportant) { | 509 } else if (!bImportant) { |
512 ApplyProperty(eProp, pVal, pComputedStyle); | 510 ApplyProperty(eProp, pVal, pComputedStyle); |
513 } else if (importants.GetSize() == 0 || | 511 } else if (importants.GetSize() == 0 || |
514 importants[importants.GetUpperBound()] != pDecl) { | 512 importants[importants.GetUpperBound()] != pDecl) { |
515 importants.Add(const_cast<CFDE_CSSDeclaration*>(pDecl)); | 513 importants.Add(const_cast<CFDE_CSSDeclaration*>(pDecl)); |
516 } | 514 } |
517 } | 515 } |
518 } | 516 } |
519 iDeclCount = importants.GetSize(); | 517 iDeclCount = importants.GetSize(); |
520 for (i = 0; i < iDeclCount; ++i) { | 518 for (i = 0; i < iDeclCount; ++i) { |
521 pDecl = importants[i]; | 519 pDecl = importants[i]; |
522 pos = pDecl->GetStartPosition(); | 520 pos = pDecl->GetStartPosition(); |
523 while (pos != NULL) { | 521 while (pos) { |
524 pDecl->GetNextProperty(pos, eProp, pVal, bImportant); | 522 pDecl->GetNextProperty(pos, eProp, pVal, bImportant); |
525 if (bImportant && eProp != FDE_CSSPROPERTY_FontSize) { | 523 if (bImportant && eProp != FDE_CSSPROPERTY_FontSize) { |
526 ApplyProperty(eProp, pVal, pComputedStyle); | 524 ApplyProperty(eProp, pVal, pComputedStyle); |
527 } | 525 } |
528 } | 526 } |
529 } | 527 } |
530 CFX_WideString wsName, wsValue; | 528 CFX_WideString wsName, wsValue; |
531 pos = pDecl->GetStartCustom(); | 529 pos = pDecl->GetStartCustom(); |
532 while (pos) { | 530 while (pos) { |
533 pDecl->GetNextCustom(pos, wsName, wsValue); | 531 pDecl->GetNextCustom(pos, wsName, wsValue); |
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
948 case FDE_CSSPROPERTY_ColumnRuleWidth: | 946 case FDE_CSSPROPERTY_ColumnRuleWidth: |
949 SetLengthWithPercent(FDE_CSSNONINHERITS.m_ColumnRuleWidth, eType, | 947 SetLengthWithPercent(FDE_CSSNONINHERITS.m_ColumnRuleWidth, eType, |
950 pPrimitive, FDE_CSSFONTSIZE); | 948 pPrimitive, FDE_CSSFONTSIZE); |
951 break; | 949 break; |
952 case FDE_CSSPROPERTY_ColumnWidth: | 950 case FDE_CSSPROPERTY_ColumnWidth: |
953 SetLengthWithPercent(FDE_CSSNONINHERITS.m_ColumnWidth, eType, | 951 SetLengthWithPercent(FDE_CSSNONINHERITS.m_ColumnWidth, eType, |
954 pPrimitive, FDE_CSSFONTSIZE); | 952 pPrimitive, FDE_CSSFONTSIZE); |
955 break; | 953 break; |
956 case FDE_CSSPROPERTY_BackgroundImage: | 954 case FDE_CSSPROPERTY_BackgroundImage: |
957 if (eType == FDE_CSSPRIMITIVETYPE_Enum) { | 955 if (eType == FDE_CSSPRIMITIVETYPE_Enum) { |
958 FDE_CSSNONINHERITS.m_pszBKGImage = NULL; | 956 FDE_CSSNONINHERITS.m_pszBKGImage = nullptr; |
959 } else if (eType == FDE_CSSPRIMITIVETYPE_URI) { | 957 } else if (eType == FDE_CSSPRIMITIVETYPE_URI) { |
960 int32_t iLength; | 958 int32_t iLength; |
961 FDE_CSSNONINHERITS.m_pszBKGImage = pPrimitive->GetString(iLength); | 959 FDE_CSSNONINHERITS.m_pszBKGImage = pPrimitive->GetString(iLength); |
962 } | 960 } |
963 break; | 961 break; |
964 case FDE_CSSPROPERTY_Position: | 962 case FDE_CSSPROPERTY_Position: |
965 if (eType == FDE_CSSPRIMITIVETYPE_Enum) { | 963 if (eType == FDE_CSSPRIMITIVETYPE_Enum) { |
966 FDE_CSSNONINHERITS.m_ePosition = ToPosition(pPrimitive->GetEnum()); | 964 FDE_CSSNONINHERITS.m_ePosition = ToPosition(pPrimitive->GetEnum()); |
967 } | 965 } |
968 break; | 966 break; |
969 case FDE_CSSPROPERTY_Top: | 967 case FDE_CSSPROPERTY_Top: |
970 SetLengthWithPercent(FDE_CSSNONINHERITS.m_Top, eType, pPrimitive, | 968 SetLengthWithPercent(FDE_CSSNONINHERITS.m_Top, eType, pPrimitive, |
971 FDE_CSSFONTSIZE); | 969 FDE_CSSFONTSIZE); |
972 break; | 970 break; |
973 case FDE_CSSPROPERTY_Bottom: | 971 case FDE_CSSPROPERTY_Bottom: |
974 SetLengthWithPercent(FDE_CSSNONINHERITS.m_Bottom, eType, pPrimitive, | 972 SetLengthWithPercent(FDE_CSSNONINHERITS.m_Bottom, eType, pPrimitive, |
975 FDE_CSSFONTSIZE); | 973 FDE_CSSFONTSIZE); |
976 break; | 974 break; |
977 case FDE_CSSPROPERTY_Left: | 975 case FDE_CSSPROPERTY_Left: |
978 SetLengthWithPercent(FDE_CSSNONINHERITS.m_Left, eType, pPrimitive, | 976 SetLengthWithPercent(FDE_CSSNONINHERITS.m_Left, eType, pPrimitive, |
979 FDE_CSSFONTSIZE); | 977 FDE_CSSFONTSIZE); |
980 break; | 978 break; |
981 case FDE_CSSPROPERTY_Right: | 979 case FDE_CSSPROPERTY_Right: |
982 SetLengthWithPercent(FDE_CSSNONINHERITS.m_Right, eType, pPrimitive, | 980 SetLengthWithPercent(FDE_CSSNONINHERITS.m_Right, eType, pPrimitive, |
983 FDE_CSSFONTSIZE); | 981 FDE_CSSFONTSIZE); |
984 break; | 982 break; |
985 case FDE_CSSPROPERTY_ListStyleImage: | 983 case FDE_CSSPROPERTY_ListStyleImage: |
986 if (eType == FDE_CSSPRIMITIVETYPE_Enum) { | 984 if (eType == FDE_CSSPRIMITIVETYPE_Enum) { |
987 FDE_CSSINHERITS.m_pszListStyleImage = NULL; | 985 FDE_CSSINHERITS.m_pszListStyleImage = nullptr; |
988 } else if (eType == FDE_CSSPRIMITIVETYPE_URI) { | 986 } else if (eType == FDE_CSSPRIMITIVETYPE_URI) { |
989 int32_t iLength; | 987 int32_t iLength; |
990 FDE_CSSINHERITS.m_pszListStyleImage = pPrimitive->GetString(iLength); | 988 FDE_CSSINHERITS.m_pszListStyleImage = pPrimitive->GetString(iLength); |
991 } | 989 } |
992 break; | 990 break; |
993 case FDE_CSSPROPERTY_CaptionSide: | 991 case FDE_CSSPROPERTY_CaptionSide: |
994 if (eType == FDE_CSSPRIMITIVETYPE_Enum) { | 992 if (eType == FDE_CSSPRIMITIVETYPE_Enum) { |
995 FDE_CSSINHERITS.m_eCaptionSide = ToCaptionSide(pPrimitive->GetEnum()); | 993 FDE_CSSINHERITS.m_eCaptionSide = ToCaptionSide(pPrimitive->GetEnum()); |
996 } | 994 } |
997 break; | 995 break; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1034 int32_t iCount = pList->CountValues(); | 1032 int32_t iCount = pList->CountValues(); |
1035 if (iCount > 0) { | 1033 if (iCount > 0) { |
1036 switch (eProperty) { | 1034 switch (eProperty) { |
1037 case FDE_CSSPROPERTY_FontFamily: | 1035 case FDE_CSSPROPERTY_FontFamily: |
1038 FDE_CSSINHERITS.m_pFontFamily = pList; | 1036 FDE_CSSINHERITS.m_pFontFamily = pList; |
1039 break; | 1037 break; |
1040 case FDE_CSSPROPERTY_TextDecoration: | 1038 case FDE_CSSPROPERTY_TextDecoration: |
1041 FDE_CSSNONINHERITS.m_dwTextDecoration = ToTextDecoration(pList); | 1039 FDE_CSSNONINHERITS.m_dwTextDecoration = ToTextDecoration(pList); |
1042 break; | 1040 break; |
1043 case FDE_CSSPROPERTY_CounterIncrement: { | 1041 case FDE_CSSPROPERTY_CounterIncrement: { |
1044 if (FDE_CSSNONINHERITS.m_pCounterStyle == NULL) { | 1042 if (!FDE_CSSNONINHERITS.m_pCounterStyle) |
1045 FDE_CSSNONINHERITS.m_pCounterStyle = new CFDE_CSSCounterStyle; | 1043 FDE_CSSNONINHERITS.m_pCounterStyle = new CFDE_CSSCounterStyle; |
1046 } | |
1047 FDE_CSSNONINHERITS.m_pCounterStyle->SetCounterIncrementList(pList); | 1044 FDE_CSSNONINHERITS.m_pCounterStyle->SetCounterIncrementList(pList); |
1048 } break; | 1045 } break; |
1049 case FDE_CSSPROPERTY_CounterReset: { | 1046 case FDE_CSSPROPERTY_CounterReset: { |
1050 if (FDE_CSSNONINHERITS.m_pCounterStyle == NULL) { | 1047 if (!FDE_CSSNONINHERITS.m_pCounterStyle) |
1051 FDE_CSSNONINHERITS.m_pCounterStyle = new CFDE_CSSCounterStyle; | 1048 FDE_CSSNONINHERITS.m_pCounterStyle = new CFDE_CSSCounterStyle; |
1052 } | |
1053 FDE_CSSNONINHERITS.m_pCounterStyle->SetCounterResetList(pList); | 1049 FDE_CSSNONINHERITS.m_pCounterStyle->SetCounterResetList(pList); |
1054 } break; | 1050 } break; |
1055 case FDE_CSSPROPERTY_Content: | 1051 case FDE_CSSPROPERTY_Content: |
1056 FDE_CSSNONINHERITS.m_pContentList = pList; | 1052 FDE_CSSNONINHERITS.m_pContentList = pList; |
1057 break; | 1053 break; |
1058 case FDE_CSSPROPERTY_Quotes: | 1054 case FDE_CSSPROPERTY_Quotes: |
1059 FDE_CSSINHERITS.m_pQuotes = pList; | 1055 FDE_CSSINHERITS.m_pQuotes = pList; |
1060 break; | 1056 break; |
1061 case FDE_CSSPROPERTY_TextCombine: { | 1057 case FDE_CSSPROPERTY_TextCombine: { |
1062 for (int32_t i = 0; i < pList->CountValues(); i++) { | 1058 for (int32_t i = 0; i < pList->CountValues(); i++) { |
(...skipping 711 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1774 return FDE_CSSTEXTTRANSFORM_LowerCase; | 1770 return FDE_CSSTEXTTRANSFORM_LowerCase; |
1775 default: | 1771 default: |
1776 return FDE_CSSTEXTTRANSFORM_None; | 1772 return FDE_CSSTEXTTRANSFORM_None; |
1777 } | 1773 } |
1778 } | 1774 } |
1779 FDE_CSSFONTVARIANT CFDE_CSSStyleSelector::ToFontVariant( | 1775 FDE_CSSFONTVARIANT CFDE_CSSStyleSelector::ToFontVariant( |
1780 FDE_CSSPROPERTYVALUE eValue) { | 1776 FDE_CSSPROPERTYVALUE eValue) { |
1781 return eValue == FDE_CSSPROPERTYVALUE_SmallCaps ? FDE_CSSFONTVARIANT_SmallCaps | 1777 return eValue == FDE_CSSPROPERTYVALUE_SmallCaps ? FDE_CSSFONTVARIANT_SmallCaps |
1782 : FDE_CSSFONTVARIANT_Normal; | 1778 : FDE_CSSFONTVARIANT_Normal; |
1783 } | 1779 } |
OLD | NEW |