OLD | NEW |
| (Empty) |
1 // Copyright 2014 PDFium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | |
6 | |
7 #include "xfa/src/fde/css/fde_cssstyleselector.h" | |
8 | |
9 #include <algorithm> | |
10 | |
11 #include "xfa/src/fde/css/fde_csscache.h" | |
12 #include "xfa/src/fde/css/fde_cssdeclaration.h" | |
13 | |
14 int32_t CFDE_CSSCounterStyle::FindIndex(const FX_WCHAR* pszIdentifier) { | |
15 int32_t iCount = m_arrCounterData.GetSize(); | |
16 for (int32_t i = 0; i < iCount; i++) { | |
17 if (FXSYS_wcscmp(pszIdentifier, m_arrCounterData.ElementAt(i).m_pszIdent) == | |
18 0) { | |
19 return i; | |
20 } | |
21 } | |
22 return -1; | |
23 } | |
24 void CFDE_CSSCounterStyle::DoUpdateIndex(IFDE_CSSValueList* pList) { | |
25 if (pList == NULL) { | |
26 return; | |
27 } | |
28 int32_t iCount = pList->CountValues(); | |
29 FX_FLOAT fDefValue = 1.0; | |
30 FX_BOOL bDefIncrement = TRUE; | |
31 if (pList == m_pCounterReset) { | |
32 fDefValue = 0.0; | |
33 bDefIncrement = FALSE; | |
34 } | |
35 for (int32_t i = 0; i < iCount; i++) { | |
36 IFDE_CSSValueList* pCounter = (IFDE_CSSValueList*)pList->GetValue(i); | |
37 int32_t iLen; | |
38 const FX_WCHAR* pszIdentifier = | |
39 ((IFDE_CSSPrimitiveValue*)(pCounter->GetValue(0)))->GetString(iLen); | |
40 FX_FLOAT fValue = fDefValue; | |
41 if (pCounter->CountValues() > 1) { | |
42 fValue = ((IFDE_CSSPrimitiveValue*)(pCounter->GetValue(1)))->GetFloat(); | |
43 } | |
44 int32_t iIndex = FindIndex(pszIdentifier); | |
45 if (iIndex == -1) { | |
46 FDE_CSSCOUNTERDATA data; | |
47 data.m_pszIdent = pszIdentifier; | |
48 if (bDefIncrement) { | |
49 data.m_bIncrement = TRUE; | |
50 data.m_iIncVal = (int32_t)fValue; | |
51 } else { | |
52 data.m_iResetVal = (int32_t)fValue; | |
53 data.m_bReset = TRUE; | |
54 } | |
55 m_arrCounterData.Add(data); | |
56 } else { | |
57 FDE_CSSCOUNTERDATA& data = m_arrCounterData.ElementAt(iIndex); | |
58 if (bDefIncrement) { | |
59 data.m_bIncrement = TRUE; | |
60 data.m_iIncVal += (int32_t)fValue; | |
61 } else { | |
62 data.m_bReset = TRUE; | |
63 data.m_iResetVal = (int32_t)fValue; | |
64 } | |
65 } | |
66 } | |
67 } | |
68 void CFDE_CSSCounterStyle::UpdateIndex() { | |
69 if (!m_bIndexDirty) { | |
70 return; | |
71 } | |
72 m_arrCounterData.RemoveAll(); | |
73 DoUpdateIndex(m_pCounterInc); | |
74 DoUpdateIndex(m_pCounterReset); | |
75 m_bIndexDirty = FALSE; | |
76 } | |
77 FDE_CSSTEXTEMPHASISMARK CFDE_CSSComputedStyle::GetTextEmphasisMark() const { | |
78 if (m_InheritedData.m_eTextEmphasisMark != FDE_CSSTEXTEMPHASISMARK_Auto) { | |
79 return (FDE_CSSTEXTEMPHASISMARK)m_InheritedData.m_eTextEmphasisMark; | |
80 } | |
81 if (m_InheritedData.m_eWritingMode == FDE_CSSWRITINGMODE_HorizontalTb) { | |
82 return FDE_CSSTEXTEMPHASISMARK_Dot; | |
83 } | |
84 return FDE_CSSTEXTEMPHASISMARK_Sesame; | |
85 } | |
86 FDE_CSSRuleData::FDE_CSSRuleData(IFDE_CSSSelector* pSel, | |
87 IFDE_CSSDeclaration* pDecl, | |
88 FX_DWORD dwPos) | |
89 : pSelector(pSel), pDeclaration(pDecl), dwPriority(dwPos), pNext(NULL) { | |
90 static const FX_DWORD s_Specific[5] = {0x00010000, 0x00010000, 0x00100000, | |
91 0x00100000, 0x01000000}; | |
92 for (; pSel != NULL; pSel = pSel->GetNextSelector()) { | |
93 FDE_CSSSELECTORTYPE eType = pSel->GetType(); | |
94 if (eType > FDE_CSSSELECTORTYPE_Descendant || | |
95 pSel->GetNameHash() != FDE_CSSUNIVERSALHASH) { | |
96 dwPriority += s_Specific[eType]; | |
97 } | |
98 } | |
99 } | |
100 void CFDE_CSSRuleCollection::Clear() { | |
101 m_IDRules.RemoveAll(); | |
102 m_TagRules.RemoveAll(); | |
103 m_ClassRules.RemoveAll(); | |
104 m_pUniversalRules = NULL; | |
105 m_pStaticStore = NULL; | |
106 m_iSelectors = 0; | |
107 } | |
108 void CFDE_CSSRuleCollection::AddRulesFrom(const CFDE_CSSStyleSheetArray& sheets, | |
109 FX_DWORD dwMediaList, | |
110 IFX_FontMgr* pFontMgr) { | |
111 int32_t iSheets = sheets.GetSize(); | |
112 for (int32_t i = 0; i < iSheets; ++i) { | |
113 IFDE_CSSStyleSheet* pSheet = sheets.GetAt(i); | |
114 if (FX_DWORD dwMatchMedia = pSheet->GetMediaList() & dwMediaList) { | |
115 int32_t iRules = pSheet->CountRules(); | |
116 for (int32_t j = 0; j < iRules; j++) { | |
117 AddRulesFrom(pSheet, pSheet->GetRule(j), dwMatchMedia, pFontMgr); | |
118 } | |
119 } | |
120 } | |
121 } | |
122 void CFDE_CSSRuleCollection::AddRulesFrom(IFDE_CSSStyleSheet* pStyleSheet, | |
123 IFDE_CSSRule* pRule, | |
124 FX_DWORD dwMediaList, | |
125 IFX_FontMgr* pFontMgr) { | |
126 switch (pRule->GetType()) { | |
127 case FDE_CSSRULETYPE_Style: { | |
128 IFDE_CSSStyleRule* pStyleRule = (IFDE_CSSStyleRule*)pRule; | |
129 IFDE_CSSDeclaration* pDeclaration = pStyleRule->GetDeclaration(); | |
130 int32_t iSelectors = pStyleRule->CountSelectorLists(); | |
131 for (int32_t i = 0; i < iSelectors; ++i) { | |
132 IFDE_CSSSelector* pSelector = pStyleRule->GetSelectorList(i); | |
133 if (pSelector->GetType() == FDE_CSSSELECTORTYPE_Persudo) { | |
134 FDE_CSSRuleData* pData = NewRuleData(pSelector, pDeclaration); | |
135 AddRuleTo(m_pPersudoRules, pData); | |
136 continue; | |
137 } | |
138 if (pSelector->GetNameHash() != FDE_CSSUNIVERSALHASH) { | |
139 AddRuleTo(m_TagRules, pSelector->GetNameHash(), pSelector, | |
140 pDeclaration); | |
141 continue; | |
142 } | |
143 IFDE_CSSSelector* pNext = pSelector->GetNextSelector(); | |
144 if (pNext == NULL) { | |
145 FDE_CSSRuleData* pData = NewRuleData(pSelector, pDeclaration); | |
146 AddRuleTo(m_pUniversalRules, pData); | |
147 continue; | |
148 } | |
149 switch (pNext->GetType()) { | |
150 case FDE_CSSSELECTORTYPE_ID: | |
151 AddRuleTo(m_IDRules, pNext->GetNameHash(), pSelector, pDeclaration); | |
152 break; | |
153 case FDE_CSSSELECTORTYPE_Class: | |
154 AddRuleTo(m_ClassRules, pNext->GetNameHash(), pSelector, | |
155 pDeclaration); | |
156 break; | |
157 case FDE_CSSSELECTORTYPE_Descendant: | |
158 case FDE_CSSSELECTORTYPE_Element: | |
159 AddRuleTo(m_pUniversalRules, NewRuleData(pSelector, pDeclaration)); | |
160 break; | |
161 default: | |
162 FXSYS_assert(FALSE); | |
163 break; | |
164 } | |
165 } | |
166 } break; | |
167 case FDE_CSSRULETYPE_Media: { | |
168 IFDE_CSSMediaRule* pMediaRule = (IFDE_CSSMediaRule*)pRule; | |
169 if (pMediaRule->GetMediaList() & dwMediaList) { | |
170 int32_t iRules = pMediaRule->CountRules(); | |
171 for (int32_t i = 0; i < iRules; ++i) { | |
172 AddRulesFrom(pStyleSheet, pMediaRule->GetRule(i), dwMediaList, | |
173 pFontMgr); | |
174 } | |
175 } | |
176 } break; | |
177 default: | |
178 break; | |
179 } | |
180 } | |
181 void CFDE_CSSRuleCollection::AddRuleTo(CFX_MapPtrToPtr& map, | |
182 FX_DWORD dwKey, | |
183 IFDE_CSSSelector* pSel, | |
184 IFDE_CSSDeclaration* pDecl) { | |
185 void* pKey = (void*)(uintptr_t)dwKey; | |
186 FDE_CSSRuleData* pData = NewRuleData(pSel, pDecl); | |
187 FDE_CSSRuleData* pList = NULL; | |
188 if (!map.Lookup(pKey, (void*&)pList)) { | |
189 map.SetAt(pKey, pData); | |
190 } else if (AddRuleTo(pList, pData)) { | |
191 map.SetAt(pKey, pList); | |
192 } | |
193 } | |
194 | |
195 FX_BOOL CFDE_CSSRuleCollection::AddRuleTo(FDE_CSSRuleData*& pList, | |
196 FDE_CSSRuleData* pData) { | |
197 if (pList) { | |
198 pData->pNext = pList->pNext; | |
199 pList->pNext = pData; | |
200 return FALSE; | |
201 } | |
202 | |
203 pList = pData; | |
204 return TRUE; | |
205 } | |
206 | |
207 FDE_CSSRuleData* CFDE_CSSRuleCollection::NewRuleData( | |
208 IFDE_CSSSelector* pSel, | |
209 IFDE_CSSDeclaration* pDecl) { | |
210 return FXTARGET_NewWith(m_pStaticStore) | |
211 FDE_CSSRuleData(pSel, pDecl, ++m_iSelectors); | |
212 } | |
213 | |
214 IFDE_CSSStyleSelector* IFDE_CSSStyleSelector::Create() { | |
215 return new CFDE_CSSStyleSelector; | |
216 } | |
217 CFDE_CSSStyleSelector::CFDE_CSSStyleSelector() | |
218 : m_pFontMgr(NULL), | |
219 m_fDefFontSize(12.0f), | |
220 m_pRuleDataStore(NULL), | |
221 m_pInlineStyleStore(NULL), | |
222 m_pFixedStyleStore(NULL), | |
223 m_pAccelerator(NULL) { | |
224 m_ePriorities[FDE_CSSSTYLESHEETPRIORITY_High] = FDE_CSSSTYLESHEETGROUP_Author; | |
225 m_ePriorities[FDE_CSSSTYLESHEETPRIORITY_Mid] = FDE_CSSSTYLESHEETGROUP_User; | |
226 m_ePriorities[FDE_CSSSTYLESHEETPRIORITY_Low] = | |
227 FDE_CSSSTYLESHEETGROUP_UserAgent; | |
228 } | |
229 CFDE_CSSStyleSelector::~CFDE_CSSStyleSelector() { | |
230 Reset(); | |
231 if (m_pInlineStyleStore != NULL) { | |
232 m_pInlineStyleStore->Release(); | |
233 } | |
234 if (m_pFixedStyleStore != NULL) { | |
235 m_pFixedStyleStore->Release(); | |
236 } | |
237 if (m_pAccelerator != NULL) { | |
238 delete m_pAccelerator; | |
239 } | |
240 } | |
241 void CFDE_CSSStyleSelector::SetFontMgr(IFX_FontMgr* pFontMgr) { | |
242 m_pFontMgr = pFontMgr; | |
243 } | |
244 void CFDE_CSSStyleSelector::SetDefFontSize(FX_FLOAT fFontSize) { | |
245 FXSYS_assert(fFontSize > 0); | |
246 m_fDefFontSize = fFontSize; | |
247 } | |
248 IFDE_CSSAccelerator* CFDE_CSSStyleSelector::InitAccelerator() { | |
249 if (m_pAccelerator == NULL) { | |
250 m_pAccelerator = new CFDE_CSSAccelerator; | |
251 FXSYS_assert(m_pAccelerator != NULL); | |
252 } | |
253 m_pAccelerator->Clear(); | |
254 return m_pAccelerator; | |
255 } | |
256 IFDE_CSSComputedStyle* CFDE_CSSStyleSelector::CreateComputedStyle( | |
257 IFDE_CSSComputedStyle* pParentStyle) { | |
258 if (m_pFixedStyleStore == NULL) { | |
259 m_pFixedStyleStore = FX_CreateAllocator(FX_ALLOCTYPE_Fixed, 16, | |
260 sizeof(CFDE_CSSComputedStyle)); | |
261 FXSYS_assert(m_pFixedStyleStore != NULL); | |
262 } | |
263 CFDE_CSSComputedStyle* pStyle = FXTARGET_NewWith(m_pFixedStyleStore) | |
264 CFDE_CSSComputedStyle(m_pFixedStyleStore); | |
265 if (pParentStyle) { | |
266 pStyle->m_InheritedData = | |
267 ((CFDE_CSSComputedStyle*)pParentStyle)->m_InheritedData; | |
268 } else { | |
269 pStyle->m_InheritedData.Reset(); | |
270 } | |
271 pStyle->m_NonInheritedData.Reset(); | |
272 return pStyle; | |
273 } | |
274 FX_BOOL CFDE_CSSStyleSelector::SetStyleSheet(FDE_CSSSTYLESHEETGROUP eType, | |
275 IFDE_CSSStyleSheet* pSheet) { | |
276 FXSYS_assert(eType < FDE_CSSSTYLESHEETGROUP_MAX); | |
277 CFDE_CSSStyleSheetArray& dest = m_SheetGroups[eType]; | |
278 dest.RemoveAt(0, dest.GetSize()); | |
279 if (pSheet != NULL) { | |
280 dest.Add(pSheet); | |
281 } | |
282 return TRUE; | |
283 } | |
284 FX_BOOL CFDE_CSSStyleSelector::SetStyleSheets( | |
285 FDE_CSSSTYLESHEETGROUP eType, | |
286 const CFDE_CSSStyleSheetArray* pArray) { | |
287 FXSYS_assert(eType < FDE_CSSSTYLESHEETGROUP_MAX); | |
288 CFDE_CSSStyleSheetArray& dest = m_SheetGroups[eType]; | |
289 if (pArray == NULL) { | |
290 dest.RemoveAt(0, dest.GetSize()); | |
291 } else { | |
292 dest.Copy(*pArray); | |
293 } | |
294 return TRUE; | |
295 } | |
296 void CFDE_CSSStyleSelector::SetStylePriority( | |
297 FDE_CSSSTYLESHEETGROUP eType, | |
298 FDE_CSSSTYLESHEETPRIORITY ePriority) { | |
299 m_ePriorities[ePriority] = eType; | |
300 } | |
301 void CFDE_CSSStyleSelector::UpdateStyleIndex(FX_DWORD dwMediaList) { | |
302 Reset(); | |
303 m_pRuleDataStore = FX_CreateAllocator(FX_ALLOCTYPE_Static, 1024, 0); | |
304 FXSYS_assert(m_pRuleDataStore != NULL); | |
305 for (int32_t iGroup = 0; iGroup < FDE_CSSSTYLESHEETGROUP_MAX; ++iGroup) { | |
306 CFDE_CSSRuleCollection& rules = m_RuleCollection[iGroup]; | |
307 rules.m_pStaticStore = m_pRuleDataStore; | |
308 rules.AddRulesFrom(m_SheetGroups[iGroup], dwMediaList, m_pFontMgr); | |
309 } | |
310 } | |
311 void CFDE_CSSStyleSelector::Reset() { | |
312 for (int32_t iGroup = 0; iGroup < FDE_CSSSTYLESHEETGROUP_MAX; ++iGroup) { | |
313 m_RuleCollection[iGroup].Clear(); | |
314 } | |
315 if (m_pRuleDataStore != NULL) { | |
316 m_pRuleDataStore->Release(); | |
317 m_pRuleDataStore = NULL; | |
318 } | |
319 } | |
320 int32_t CFDE_CSSStyleSelector::MatchDeclarations( | |
321 IFDE_CSSTagProvider* pTag, | |
322 CFDE_CSSDeclarationArray& matchedDecls, | |
323 FDE_CSSPERSUDO ePersudoType) { | |
324 FXSYS_assert(m_pAccelerator != NULL && pTag != NULL); | |
325 FDE_CSSTagCache* pCache = m_pAccelerator->GetTopElement(); | |
326 FXSYS_assert(pCache != NULL && pCache->GetTag() == pTag); | |
327 matchedDecls.RemoveAt(0, matchedDecls.GetSize()); | |
328 for (int32_t ePriority = FDE_CSSSTYLESHEETPRIORITY_MAX - 1; ePriority >= 0; | |
329 --ePriority) { | |
330 FDE_CSSSTYLESHEETGROUP eGroup = m_ePriorities[ePriority]; | |
331 CFDE_CSSRuleCollection& rules = m_RuleCollection[eGroup]; | |
332 if (rules.CountSelectors() == 0) { | |
333 continue; | |
334 } | |
335 if (ePersudoType == FDE_CSSPERSUDO_NONE) { | |
336 MatchRules(pCache, rules.GetUniversalRuleData(), ePersudoType); | |
337 if (pCache->HashTag()) { | |
338 MatchRules(pCache, rules.GetTagRuleData(pCache->HashTag()), | |
339 ePersudoType); | |
340 } | |
341 int32_t iCount = pCache->CountHashClass(); | |
342 for (int32_t i = 0; i < iCount; i++) { | |
343 pCache->SetClassIndex(i); | |
344 MatchRules(pCache, rules.GetClassRuleData(pCache->HashClass()), | |
345 ePersudoType); | |
346 } | |
347 } else { | |
348 MatchRules(pCache, rules.GetPersudoRuleData(), ePersudoType); | |
349 } | |
350 | |
351 std::sort(m_MatchedRules.begin(), m_MatchedRules.end(), | |
352 [](const FDE_CSSRuleData* p1, const FDE_CSSRuleData* p2) { | |
353 return p1->dwPriority < p2->dwPriority; | |
354 }); | |
355 for (const auto& rule : m_MatchedRules) | |
356 matchedDecls.Add(rule->pDeclaration); | |
357 m_MatchedRules.clear(); | |
358 } | |
359 return matchedDecls.GetSize(); | |
360 } | |
361 | |
362 void CFDE_CSSStyleSelector::MatchRules(FDE_CSSTagCache* pCache, | |
363 FDE_CSSRuleData* pList, | |
364 FDE_CSSPERSUDO ePersudoType) { | |
365 while (pList) { | |
366 if (MatchSelector(pCache, pList->pSelector, ePersudoType)) | |
367 m_MatchedRules.push_back(pList); | |
368 pList = pList->pNext; | |
369 } | |
370 } | |
371 | |
372 FX_BOOL CFDE_CSSStyleSelector::MatchSelector(FDE_CSSTagCache* pCache, | |
373 IFDE_CSSSelector* pSel, | |
374 FDE_CSSPERSUDO ePersudoType) { | |
375 FX_DWORD dwHash; | |
376 while (pSel != NULL && pCache != NULL) { | |
377 switch (pSel->GetType()) { | |
378 case FDE_CSSSELECTORTYPE_Descendant: | |
379 dwHash = pSel->GetNameHash(); | |
380 while ((pCache = pCache->GetParent()) != NULL) { | |
381 if (dwHash != FDE_CSSUNIVERSALHASH && dwHash != pCache->HashTag()) { | |
382 continue; | |
383 } | |
384 if (MatchSelector(pCache, pSel->GetNextSelector(), ePersudoType)) { | |
385 return TRUE; | |
386 } | |
387 } | |
388 return FALSE; | |
389 case FDE_CSSSELECTORTYPE_ID: | |
390 dwHash = pCache->HashID(); | |
391 if (dwHash != pSel->GetNameHash()) { | |
392 return FALSE; | |
393 } | |
394 break; | |
395 case FDE_CSSSELECTORTYPE_Class: | |
396 dwHash = pCache->HashClass(); | |
397 if (dwHash != pSel->GetNameHash()) { | |
398 return FALSE; | |
399 } | |
400 break; | |
401 case FDE_CSSSELECTORTYPE_Element: | |
402 dwHash = pSel->GetNameHash(); | |
403 if (dwHash != FDE_CSSUNIVERSALHASH && dwHash != pCache->HashTag()) { | |
404 return FALSE; | |
405 } | |
406 break; | |
407 case FDE_CSSSELECTORTYPE_Persudo: | |
408 dwHash = FDE_GetCSSPersudoByEnum(ePersudoType)->dwHash; | |
409 if (dwHash != pSel->GetNameHash()) { | |
410 return FALSE; | |
411 } | |
412 break; | |
413 default: | |
414 FXSYS_assert(FALSE); | |
415 break; | |
416 } | |
417 pSel = pSel->GetNextSelector(); | |
418 } | |
419 return pSel == NULL && pCache != NULL; | |
420 } | |
421 | |
422 void CFDE_CSSStyleSelector::ComputeStyle( | |
423 IFDE_CSSTagProvider* pTag, | |
424 const IFDE_CSSDeclaration** ppDeclArray, | |
425 int32_t iDeclCount, | |
426 IFDE_CSSComputedStyle* pDestStyle) { | |
427 FXSYS_assert(iDeclCount >= 0); | |
428 FXSYS_assert(pDestStyle); | |
429 FX_POSITION pos = pTag->GetFirstAttribute(); | |
430 if (pos != NULL) { | |
431 if (m_pInlineStyleStore == NULL) { | |
432 m_pInlineStyleStore = FX_CreateAllocator(FX_ALLOCTYPE_Static, 2048, 0); | |
433 } | |
434 CFDE_CSSDeclaration* pDecl = NULL; | |
435 CFX_WideStringC wsAttri, wsValue; | |
436 FX_DWORD dwAttriHash; | |
437 do { | |
438 pTag->GetNextAttribute(pos, wsAttri, wsValue); | |
439 dwAttriHash = | |
440 FX_HashCode_String_GetW(wsAttri.GetPtr(), wsAttri.GetLength(), TRUE); | |
441 static const FX_DWORD s_dwStyleHash = | |
442 FX_HashCode_String_GetW(L"style", 5, TRUE); | |
443 static const FX_DWORD s_dwAlignHash = | |
444 FX_HashCode_String_GetW(L"align", 5, TRUE); | |
445 if (dwAttriHash == s_dwStyleHash) { | |
446 if (pDecl == NULL) { | |
447 pDecl = FXTARGET_NewWith(m_pInlineStyleStore) CFDE_CSSDeclaration; | |
448 } | |
449 AppendInlineStyle(pDecl, wsValue.GetPtr(), wsValue.GetLength()); | |
450 } else if (dwAttriHash == s_dwAlignHash) { | |
451 if (pDecl == NULL) { | |
452 pDecl = FXTARGET_NewWith(m_pInlineStyleStore) CFDE_CSSDeclaration; | |
453 } | |
454 FDE_CSSPROPERTYARGS args; | |
455 args.pStringCache = NULL; | |
456 args.pStaticStore = m_pInlineStyleStore; | |
457 args.pProperty = FDE_GetCSSPropertyByEnum(FDE_CSSPROPERTY_TextAlign); | |
458 pDecl->AddProperty(&args, wsValue.GetPtr(), wsValue.GetLength()); | |
459 } | |
460 } while (pos != NULL); | |
461 if (pDecl != NULL) { | |
462 CFDE_CSSDeclarationArray decls; | |
463 decls.SetSize(iDeclCount + 1); | |
464 IFDE_CSSDeclaration** ppInline = decls.GetData(); | |
465 FXSYS_memcpy(ppInline, ppDeclArray, | |
466 iDeclCount * sizeof(IFDE_CSSDeclaration*)); | |
467 ppInline[iDeclCount++] = pDecl; | |
468 ApplyDeclarations(TRUE, (const IFDE_CSSDeclaration**)ppInline, iDeclCount, | |
469 pDestStyle); | |
470 ApplyDeclarations(FALSE, (const IFDE_CSSDeclaration**)ppInline, | |
471 iDeclCount, pDestStyle); | |
472 return; | |
473 } | |
474 } | |
475 if (iDeclCount > 0) { | |
476 FXSYS_assert(ppDeclArray != NULL); | |
477 ApplyDeclarations(TRUE, ppDeclArray, iDeclCount, pDestStyle); | |
478 ApplyDeclarations(FALSE, ppDeclArray, iDeclCount, pDestStyle); | |
479 } | |
480 } | |
481 void CFDE_CSSStyleSelector::ApplyDeclarations( | |
482 FX_BOOL bPriority, | |
483 const IFDE_CSSDeclaration** ppDeclArray, | |
484 int32_t iDeclCount, | |
485 IFDE_CSSComputedStyle* pDestStyle) { | |
486 CFDE_CSSComputedStyle* pComputedStyle = (CFDE_CSSComputedStyle*)pDestStyle; | |
487 IFDE_CSSValue* pVal; | |
488 FX_BOOL bImportant; | |
489 int32_t i; | |
490 if (bPriority) { | |
491 IFDE_CSSValue *pLastest = NULL, *pImportant = NULL; | |
492 for (i = 0; i < iDeclCount; ++i) { | |
493 pVal = ppDeclArray[i]->GetProperty(FDE_CSSPROPERTY_FontSize, bImportant); | |
494 if (pVal == NULL) { | |
495 continue; | |
496 } else if (bImportant) { | |
497 pImportant = pVal; | |
498 } else { | |
499 pLastest = pVal; | |
500 } | |
501 } | |
502 if (pImportant) { | |
503 ApplyProperty(FDE_CSSPROPERTY_FontSize, pImportant, pComputedStyle); | |
504 } else if (pLastest) { | |
505 ApplyProperty(FDE_CSSPROPERTY_FontSize, pLastest, pComputedStyle); | |
506 } | |
507 } else { | |
508 CFDE_CSSDeclarationArray importants; | |
509 const IFDE_CSSDeclaration* pDecl = NULL; | |
510 FDE_CSSPROPERTY eProp; | |
511 FX_POSITION pos; | |
512 for (i = 0; i < iDeclCount; ++i) { | |
513 pDecl = ppDeclArray[i]; | |
514 pos = pDecl->GetStartPosition(); | |
515 while (pos != NULL) { | |
516 pDecl->GetNextProperty(pos, eProp, pVal, bImportant); | |
517 if (eProp == FDE_CSSPROPERTY_FontSize) { | |
518 continue; | |
519 } else if (!bImportant) { | |
520 ApplyProperty(eProp, pVal, pComputedStyle); | |
521 } else if (importants.GetSize() == 0 || | |
522 importants[importants.GetUpperBound()] != pDecl) { | |
523 importants.Add((IFDE_CSSDeclaration*)pDecl); | |
524 } | |
525 } | |
526 } | |
527 iDeclCount = importants.GetSize(); | |
528 for (i = 0; i < iDeclCount; ++i) { | |
529 pDecl = importants[i]; | |
530 pos = pDecl->GetStartPosition(); | |
531 while (pos != NULL) { | |
532 pDecl->GetNextProperty(pos, eProp, pVal, bImportant); | |
533 if (bImportant && eProp != FDE_CSSPROPERTY_FontSize) { | |
534 ApplyProperty(eProp, pVal, pComputedStyle); | |
535 } | |
536 } | |
537 } | |
538 CFX_WideString wsName, wsValue; | |
539 pos = pDecl->GetStartCustom(); | |
540 while (pos) { | |
541 pDecl->GetNextCustom(pos, wsName, wsValue); | |
542 pComputedStyle->AddCustomStyle(wsName, wsValue); | |
543 } | |
544 } | |
545 } | |
546 void CFDE_CSSStyleSelector::AppendInlineStyle(CFDE_CSSDeclaration* pDecl, | |
547 const FX_WCHAR* psz, | |
548 int32_t iLen) { | |
549 FXSYS_assert(pDecl != NULL && psz != NULL && iLen > 0); | |
550 IFDE_CSSSyntaxParser* pSyntax = IFDE_CSSSyntaxParser::Create(); | |
551 if (pSyntax == NULL) { | |
552 return; | |
553 } | |
554 if (pSyntax->Init(psz, iLen, 32, TRUE)) { | |
555 int32_t iLen; | |
556 const FX_WCHAR* psz; | |
557 FDE_CSSPROPERTYARGS args; | |
558 args.pStringCache = NULL; | |
559 args.pStaticStore = m_pInlineStyleStore; | |
560 args.pProperty = NULL; | |
561 CFX_WideString wsName; | |
562 for (;;) { | |
563 FDE_CSSSYNTAXSTATUS eStatus = pSyntax->DoSyntaxParse(); | |
564 if (eStatus == FDE_CSSSYNTAXSTATUS_PropertyName) { | |
565 psz = pSyntax->GetCurrentString(iLen); | |
566 args.pProperty = FDE_GetCSSPropertyByName(psz, iLen); | |
567 if (args.pProperty == NULL) { | |
568 wsName = CFX_WideStringC(psz, iLen); | |
569 } | |
570 } else if (eStatus == FDE_CSSSYNTAXSTATUS_PropertyValue) { | |
571 if (args.pProperty != NULL) { | |
572 psz = pSyntax->GetCurrentString(iLen); | |
573 if (iLen > 0) { | |
574 pDecl->AddProperty(&args, psz, iLen); | |
575 } | |
576 } else if (iLen > 0) { | |
577 psz = pSyntax->GetCurrentString(iLen); | |
578 if (iLen > 0) { | |
579 pDecl->AddProperty(&args, wsName, wsName.GetLength(), psz, iLen); | |
580 } | |
581 } | |
582 } else { | |
583 break; | |
584 } | |
585 } | |
586 } | |
587 pSyntax->Release(); | |
588 } | |
589 #define FDE_CSSNONINHERITS (pComputedStyle->m_NonInheritedData) | |
590 #define FDE_CSSINHERITS (pComputedStyle->m_InheritedData) | |
591 #define FDE_CSSFONTSIZE (FDE_CSSINHERITS.m_fFontSize) | |
592 void CFDE_CSSStyleSelector::ApplyProperty( | |
593 FDE_CSSPROPERTY eProperty, | |
594 IFDE_CSSValue* pValue, | |
595 CFDE_CSSComputedStyle* pComputedStyle) { | |
596 if (pValue->GetType() == FDE_CSSVALUETYPE_Primitive) { | |
597 IFDE_CSSPrimitiveValue* pPrimitive = (IFDE_CSSPrimitiveValue*)pValue; | |
598 FDE_CSSPRIMITIVETYPE eType = pPrimitive->GetPrimitiveType(); | |
599 switch (eProperty) { | |
600 case FDE_CSSPROPERTY_Display: | |
601 if (eType == FDE_CSSPRIMITIVETYPE_Enum) { | |
602 FDE_CSSNONINHERITS.m_eDisplay = ToDisplay(pPrimitive->GetEnum()); | |
603 } | |
604 break; | |
605 case FDE_CSSPROPERTY_FontSize: { | |
606 FX_FLOAT& fFontSize = FDE_CSSFONTSIZE; | |
607 if (eType >= FDE_CSSPRIMITIVETYPE_Number && | |
608 eType <= FDE_CSSPRIMITIVETYPE_PC) { | |
609 fFontSize = ApplyNumber(eType, pPrimitive->GetFloat(), fFontSize); | |
610 } else if (eType == FDE_CSSPRIMITIVETYPE_Enum) { | |
611 fFontSize = ToFontSize(pPrimitive->GetEnum(), fFontSize); | |
612 } | |
613 } break; | |
614 case FDE_CSSPROPERTY_LineHeight: | |
615 if (eType == FDE_CSSPRIMITIVETYPE_Number) { | |
616 FDE_CSSINHERITS.m_fLineHeight = | |
617 pPrimitive->GetFloat() * FDE_CSSFONTSIZE; | |
618 } else if (eType > FDE_CSSPRIMITIVETYPE_Number && | |
619 eType <= FDE_CSSPRIMITIVETYPE_PC) { | |
620 FDE_CSSINHERITS.m_fLineHeight = | |
621 ApplyNumber(eType, pPrimitive->GetFloat(), FDE_CSSFONTSIZE); | |
622 } | |
623 break; | |
624 case FDE_CSSPROPERTY_TextAlign: | |
625 if (eType == FDE_CSSPRIMITIVETYPE_Enum) { | |
626 FDE_CSSINHERITS.m_eTextAligh = ToTextAlign(pPrimitive->GetEnum()); | |
627 } | |
628 break; | |
629 case FDE_CSSPROPERTY_TextIndent: | |
630 SetLengthWithPercent(FDE_CSSINHERITS.m_TextIndent, eType, pPrimitive, | |
631 FDE_CSSFONTSIZE); | |
632 break; | |
633 case FDE_CSSPROPERTY_FontWeight: | |
634 if (eType == FDE_CSSPRIMITIVETYPE_Enum) { | |
635 FDE_CSSINHERITS.m_wFontWeight = ToFontWeight(pPrimitive->GetEnum()); | |
636 } else if (eType == FDE_CSSPRIMITIVETYPE_Number) { | |
637 int32_t iValue = (int32_t)pPrimitive->GetFloat() / 100; | |
638 if (iValue >= 1 && iValue <= 9) { | |
639 FDE_CSSINHERITS.m_wFontWeight = iValue * 100; | |
640 } | |
641 } | |
642 break; | |
643 case FDE_CSSPROPERTY_FontStyle: | |
644 if (eType == FDE_CSSPRIMITIVETYPE_Enum) { | |
645 FDE_CSSINHERITS.m_eFontStyle = ToFontStyle(pPrimitive->GetEnum()); | |
646 } | |
647 break; | |
648 case FDE_CSSPROPERTY_Color: | |
649 if (eType == FDE_CSSPRIMITIVETYPE_RGB) { | |
650 FDE_CSSINHERITS.m_dwFontColor = pPrimitive->GetRGBColor(); | |
651 } | |
652 break; | |
653 case FDE_CSSPROPERTY_MarginLeft: | |
654 FDE_CSSNONINHERITS.m_bHasMargin |= | |
655 SetLengthWithPercent(FDE_CSSNONINHERITS.m_MarginWidth.left, eType, | |
656 pPrimitive, FDE_CSSFONTSIZE); | |
657 break; | |
658 case FDE_CSSPROPERTY_MarginTop: | |
659 FDE_CSSNONINHERITS.m_bHasMargin |= | |
660 SetLengthWithPercent(FDE_CSSNONINHERITS.m_MarginWidth.top, eType, | |
661 pPrimitive, FDE_CSSFONTSIZE); | |
662 break; | |
663 case FDE_CSSPROPERTY_MarginRight: | |
664 FDE_CSSNONINHERITS.m_bHasMargin |= | |
665 SetLengthWithPercent(FDE_CSSNONINHERITS.m_MarginWidth.right, eType, | |
666 pPrimitive, FDE_CSSFONTSIZE); | |
667 break; | |
668 case FDE_CSSPROPERTY_MarginBottom: | |
669 FDE_CSSNONINHERITS.m_bHasMargin |= | |
670 SetLengthWithPercent(FDE_CSSNONINHERITS.m_MarginWidth.bottom, eType, | |
671 pPrimitive, FDE_CSSFONTSIZE); | |
672 break; | |
673 case FDE_CSSPROPERTY_PaddingLeft: | |
674 FDE_CSSNONINHERITS.m_bHasPadding |= | |
675 SetLengthWithPercent(FDE_CSSNONINHERITS.m_PaddingWidth.left, eType, | |
676 pPrimitive, FDE_CSSFONTSIZE); | |
677 break; | |
678 case FDE_CSSPROPERTY_PaddingTop: | |
679 FDE_CSSNONINHERITS.m_bHasPadding |= | |
680 SetLengthWithPercent(FDE_CSSNONINHERITS.m_PaddingWidth.top, eType, | |
681 pPrimitive, FDE_CSSFONTSIZE); | |
682 break; | |
683 case FDE_CSSPROPERTY_PaddingRight: | |
684 FDE_CSSNONINHERITS.m_bHasPadding |= | |
685 SetLengthWithPercent(FDE_CSSNONINHERITS.m_PaddingWidth.right, eType, | |
686 pPrimitive, FDE_CSSFONTSIZE); | |
687 break; | |
688 case FDE_CSSPROPERTY_PaddingBottom: | |
689 FDE_CSSNONINHERITS.m_bHasPadding |= | |
690 SetLengthWithPercent(FDE_CSSNONINHERITS.m_PaddingWidth.bottom, | |
691 eType, pPrimitive, FDE_CSSFONTSIZE); | |
692 break; | |
693 case FDE_CSSPROPERTY_BorderLeftWidth: | |
694 FDE_CSSNONINHERITS.m_bHasBorder |= | |
695 SetLengthWithPercent(FDE_CSSNONINHERITS.m_BorderWidth.left, eType, | |
696 pPrimitive, FDE_CSSFONTSIZE); | |
697 break; | |
698 case FDE_CSSPROPERTY_BorderTopWidth: | |
699 FDE_CSSNONINHERITS.m_bHasBorder |= | |
700 SetLengthWithPercent(FDE_CSSNONINHERITS.m_BorderWidth.top, eType, | |
701 pPrimitive, FDE_CSSFONTSIZE); | |
702 break; | |
703 case FDE_CSSPROPERTY_BorderRightWidth: | |
704 FDE_CSSNONINHERITS.m_bHasBorder |= | |
705 SetLengthWithPercent(FDE_CSSNONINHERITS.m_BorderWidth.right, eType, | |
706 pPrimitive, FDE_CSSFONTSIZE); | |
707 break; | |
708 case FDE_CSSPROPERTY_BorderBottomWidth: | |
709 FDE_CSSNONINHERITS.m_bHasBorder |= | |
710 SetLengthWithPercent(FDE_CSSNONINHERITS.m_BorderWidth.bottom, eType, | |
711 pPrimitive, FDE_CSSFONTSIZE); | |
712 break; | |
713 case FDE_CSSPROPERTY_BorderLeftStyle: | |
714 if (eType == FDE_CSSPRIMITIVETYPE_Enum) { | |
715 FDE_CSSNONINHERITS.m_eBDRLeftStyle = | |
716 ToBorderStyle(pPrimitive->GetEnum()); | |
717 } | |
718 break; | |
719 case FDE_CSSPROPERTY_BorderTopStyle: | |
720 if (eType == FDE_CSSPRIMITIVETYPE_Enum) { | |
721 FDE_CSSNONINHERITS.m_eBDRTopStyle = | |
722 ToBorderStyle(pPrimitive->GetEnum()); | |
723 } | |
724 break; | |
725 case FDE_CSSPROPERTY_BorderRightStyle: | |
726 if (eType == FDE_CSSPRIMITIVETYPE_Enum) { | |
727 FDE_CSSNONINHERITS.m_eBDRRightStyle = | |
728 ToBorderStyle(pPrimitive->GetEnum()); | |
729 } | |
730 break; | |
731 case FDE_CSSPROPERTY_BorderBottomStyle: | |
732 if (eType == FDE_CSSPRIMITIVETYPE_Enum) { | |
733 FDE_CSSNONINHERITS.m_eBDRBottomStyle = | |
734 ToBorderStyle(pPrimitive->GetEnum()); | |
735 } | |
736 break; | |
737 case FDE_CSSPROPERTY_BorderLeftColor: | |
738 if (eType == FDE_CSSPRIMITIVETYPE_RGB) { | |
739 FDE_CSSNONINHERITS.m_dwBDRLeftColor = pPrimitive->GetRGBColor(); | |
740 } | |
741 break; | |
742 case FDE_CSSPROPERTY_BorderTopColor: | |
743 if (eType == FDE_CSSPRIMITIVETYPE_RGB) { | |
744 FDE_CSSNONINHERITS.m_dwBDRTopColor = pPrimitive->GetRGBColor(); | |
745 } | |
746 break; | |
747 case FDE_CSSPROPERTY_BorderRightColor: | |
748 if (eType == FDE_CSSPRIMITIVETYPE_RGB) { | |
749 FDE_CSSNONINHERITS.m_dwBDRRightColor = pPrimitive->GetRGBColor(); | |
750 } | |
751 break; | |
752 case FDE_CSSPROPERTY_BorderBottomColor: | |
753 if (eType == FDE_CSSPRIMITIVETYPE_RGB) { | |
754 FDE_CSSNONINHERITS.m_dwBDRBottomColor = pPrimitive->GetRGBColor(); | |
755 } | |
756 break; | |
757 case FDE_CSSPROPERTY_ListStyleType: | |
758 if (eType == FDE_CSSPRIMITIVETYPE_Enum) { | |
759 FDE_CSSNONINHERITS.m_eListStyleType = | |
760 ToListStyleType(pPrimitive->GetEnum()); | |
761 } | |
762 break; | |
763 case FDE_CSSPROPERTY_ListStylePosition: | |
764 if (eType == FDE_CSSPRIMITIVETYPE_Enum) { | |
765 FDE_CSSNONINHERITS.m_eListStylePosition = | |
766 ToListStylePosition(pPrimitive->GetEnum()); | |
767 } | |
768 break; | |
769 case FDE_CSSPROPERTY_BackgroundColor: | |
770 if (eType == FDE_CSSPRIMITIVETYPE_RGB) { | |
771 FDE_CSSNONINHERITS.m_dwBKGColor = pPrimitive->GetRGBColor(); | |
772 } else if (eType == FDE_CSSPRIMITIVETYPE_Enum) { | |
773 FDE_CSSNONINHERITS.m_dwBKGColor = 0; | |
774 } | |
775 break; | |
776 case FDE_CSSPROPERTY_Visibility: | |
777 if (eType == FDE_CSSPRIMITIVETYPE_Enum) { | |
778 FDE_CSSINHERITS.m_eVisibility = ToVisibility(pPrimitive->GetEnum()); | |
779 } | |
780 break; | |
781 case FDE_CSSPROPERTY_Width: | |
782 SetLengthWithPercent(FDE_CSSNONINHERITS.m_BoxSize.cx, eType, pPrimitive, | |
783 FDE_CSSFONTSIZE); | |
784 break; | |
785 case FDE_CSSPROPERTY_Height: | |
786 SetLengthWithPercent(FDE_CSSNONINHERITS.m_BoxSize.cy, eType, pPrimitive, | |
787 FDE_CSSFONTSIZE); | |
788 break; | |
789 case FDE_CSSPROPERTY_MinWidth: | |
790 SetLengthWithPercent(FDE_CSSNONINHERITS.m_MinBoxSize.cx, eType, | |
791 pPrimitive, FDE_CSSFONTSIZE); | |
792 break; | |
793 case FDE_CSSPROPERTY_MinHeight: | |
794 SetLengthWithPercent(FDE_CSSNONINHERITS.m_MinBoxSize.cy, eType, | |
795 pPrimitive, FDE_CSSFONTSIZE); | |
796 break; | |
797 case FDE_CSSPROPERTY_MaxWidth: | |
798 SetLengthWithPercent(FDE_CSSNONINHERITS.m_MaxBoxSize.cx, eType, | |
799 pPrimitive, FDE_CSSFONTSIZE); | |
800 break; | |
801 case FDE_CSSPROPERTY_MaxHeight: | |
802 SetLengthWithPercent(FDE_CSSNONINHERITS.m_MaxBoxSize.cy, eType, | |
803 pPrimitive, FDE_CSSFONTSIZE); | |
804 break; | |
805 case FDE_CSSPROPERTY_VerticalAlign: | |
806 if (eType == FDE_CSSPRIMITIVETYPE_Enum) { | |
807 FDE_CSSNONINHERITS.m_eVerticalAlign = | |
808 ToVerticalAlign(pPrimitive->GetEnum()); | |
809 } else if (eType >= FDE_CSSPRIMITIVETYPE_Number && | |
810 eType <= FDE_CSSPRIMITIVETYPE_PC) { | |
811 FDE_CSSNONINHERITS.m_eVerticalAlign = FDE_CSSVERTICALALIGN_Number; | |
812 FDE_CSSNONINHERITS.m_fVerticalAlign = | |
813 ApplyNumber(eType, pPrimitive->GetFloat(), FDE_CSSFONTSIZE); | |
814 } | |
815 break; | |
816 case FDE_CSSPROPERTY_WhiteSpace: | |
817 if (eType == FDE_CSSPRIMITIVETYPE_Enum) { | |
818 FDE_CSSINHERITS.m_eWhiteSpace = ToWhiteSpace(pPrimitive->GetEnum()); | |
819 } | |
820 break; | |
821 case FDE_CSSPROPERTY_TextTransform: | |
822 if (eType == FDE_CSSPRIMITIVETYPE_Enum) { | |
823 FDE_CSSINHERITS.m_eTextTransform = | |
824 ToTextTransform(pPrimitive->GetEnum()); | |
825 } | |
826 break; | |
827 case FDE_CSSPROPERTY_FontVariant: | |
828 if (eType == FDE_CSSPRIMITIVETYPE_Enum) { | |
829 FDE_CSSINHERITS.m_eFontVariant = ToFontVariant(pPrimitive->GetEnum()); | |
830 } | |
831 break; | |
832 case FDE_CSSPROPERTY_LetterSpacing: | |
833 if (eType == FDE_CSSPRIMITIVETYPE_Percent) { | |
834 break; | |
835 } else if (eType == FDE_CSSPRIMITIVETYPE_Enum) { | |
836 FDE_CSSINHERITS.m_LetterSpacing.Set(FDE_CSSLENGTHUNIT_Normal); | |
837 } else if (eType >= FDE_CSSPRIMITIVETYPE_Number && | |
838 eType <= FDE_CSSPRIMITIVETYPE_PC) { | |
839 SetLengthWithPercent(FDE_CSSINHERITS.m_LetterSpacing, eType, | |
840 pPrimitive, FDE_CSSFONTSIZE); | |
841 } | |
842 break; | |
843 case FDE_CSSPROPERTY_WordSpacing: | |
844 if (eType == FDE_CSSPRIMITIVETYPE_Percent) { | |
845 break; | |
846 } else if (eType == FDE_CSSPRIMITIVETYPE_Enum) { | |
847 FDE_CSSINHERITS.m_WordSpacing.Set(FDE_CSSLENGTHUNIT_Normal); | |
848 } else if (eType >= FDE_CSSPRIMITIVETYPE_Number && | |
849 eType <= FDE_CSSPRIMITIVETYPE_PC) { | |
850 SetLengthWithPercent(FDE_CSSINHERITS.m_WordSpacing, eType, pPrimitive, | |
851 FDE_CSSFONTSIZE); | |
852 } | |
853 break; | |
854 case FDE_CSSPROPERTY_Float: | |
855 if (eType == FDE_CSSPRIMITIVETYPE_Enum) { | |
856 FDE_CSSNONINHERITS.m_eFloat = ToFloat(pPrimitive->GetEnum()); | |
857 } | |
858 break; | |
859 case FDE_CSSPROPERTY_Clear: | |
860 if (eType == FDE_CSSPRIMITIVETYPE_Enum) { | |
861 FDE_CSSNONINHERITS.m_eClear = ToClear(pPrimitive->GetEnum()); | |
862 } | |
863 break; | |
864 case FDE_CSSPROPERTY_WritingMode: | |
865 if (eType == FDE_CSSPRIMITIVETYPE_Enum) { | |
866 FDE_CSSINHERITS.m_eWritingMode = ToWritingMode(pPrimitive->GetEnum()); | |
867 } | |
868 break; | |
869 case FDE_CSSPROPERTY_WordBreak: | |
870 if (eType == FDE_CSSPRIMITIVETYPE_Enum) { | |
871 FDE_CSSINHERITS.m_eWordBreak = ToWordBreak(pPrimitive->GetEnum()); | |
872 } | |
873 break; | |
874 case FDE_CSSPROPERTY_Widows: | |
875 if (eType == FDE_CSSPRIMITIVETYPE_Number) { | |
876 FDE_CSSINHERITS.m_iWidows = (int32_t)pPrimitive->GetFloat(); | |
877 } | |
878 break; | |
879 case FDE_CSSPROPERTY_Orphans: | |
880 if (eType == FDE_CSSPRIMITIVETYPE_Number) { | |
881 FDE_CSSINHERITS.m_iOrphans = (int32_t)pPrimitive->GetFloat(); | |
882 } | |
883 break; | |
884 case FDE_CSSPROPERTY_TextEmphasisColor: | |
885 if (eType == FDE_CSSPRIMITIVETYPE_Enum) { | |
886 switch (pPrimitive->GetEnum()) { | |
887 case FDE_CSSPROPERTYVALUE_Transparent: | |
888 FDE_CSSINHERITS.m_dwTextEmphasisColor = 0; | |
889 FDE_CSSINHERITS.m_bTextEmphasisColorCurrent = FALSE; | |
890 break; | |
891 case FDE_CSSPROPERTYVALUE_Currentcolor: | |
892 FDE_CSSINHERITS.m_bTextEmphasisColorCurrent = TRUE; | |
893 break; | |
894 default: | |
895 break; | |
896 } | |
897 } else if (eType == FDE_CSSPRIMITIVETYPE_RGB) { | |
898 FDE_CSSINHERITS.m_dwTextEmphasisColor = pPrimitive->GetRGBColor(); | |
899 FDE_CSSINHERITS.m_bTextEmphasisColorCurrent = FALSE; | |
900 } | |
901 break; | |
902 case FDE_CSSPROPERTY_PageBreakBefore: | |
903 if (eType == FDE_CSSPRIMITIVETYPE_Enum) { | |
904 FDE_CSSNONINHERITS.m_ePageBreakBefore = | |
905 ToPageBreak(pPrimitive->GetEnum()); | |
906 } | |
907 break; | |
908 case FDE_CSSPROPERTY_PageBreakAfter: | |
909 if (eType == FDE_CSSPRIMITIVETYPE_Enum) { | |
910 FDE_CSSNONINHERITS.m_ePageBreakAfter = | |
911 ToPageBreak(pPrimitive->GetEnum()); | |
912 } | |
913 break; | |
914 case FDE_CSSPROPERTY_PageBreakInside: | |
915 if (eType == FDE_CSSPRIMITIVETYPE_Enum) { | |
916 FDE_CSSNONINHERITS.m_ePageBreakInside = | |
917 ToPageBreak(pPrimitive->GetEnum()); | |
918 } | |
919 break; | |
920 case FDE_CSSPROPERTY_OverflowX: | |
921 if (eType == FDE_CSSPRIMITIVETYPE_Enum) { | |
922 FDE_CSSNONINHERITS.m_eOverflowX = ToOverflow(pPrimitive->GetEnum()); | |
923 } | |
924 break; | |
925 case FDE_CSSPROPERTY_OverflowY: | |
926 if (eType == FDE_CSSPRIMITIVETYPE_Enum) { | |
927 FDE_CSSNONINHERITS.m_eOverflowY = ToOverflow(pPrimitive->GetEnum()); | |
928 } | |
929 break; | |
930 case FDE_CSSPROPERTY_LineBreak: | |
931 if (eType == FDE_CSSPRIMITIVETYPE_Enum) { | |
932 FDE_CSSINHERITS.m_eLineBreak = ToLineBreak(pPrimitive->GetEnum()); | |
933 } | |
934 break; | |
935 case FDE_CSSPROPERTY_ColumnCount: | |
936 if (eType == FDE_CSSPRIMITIVETYPE_Enum) { | |
937 FDE_CSSNONINHERITS.m_ColumnCount.Set(FDE_CSSLENGTHUNIT_Auto); | |
938 } else if (eType == FDE_CSSPRIMITIVETYPE_Number) { | |
939 FDE_CSSNONINHERITS.m_ColumnCount.Set(FDE_CSSLENGTHUNIT_Point, | |
940 pPrimitive->GetFloat()); | |
941 } | |
942 break; | |
943 case FDE_CSSPROPERTY_ColumnGap: | |
944 SetLengthWithPercent(FDE_CSSNONINHERITS.m_ColumnGap, eType, pPrimitive, | |
945 FDE_CSSFONTSIZE); | |
946 break; | |
947 case FDE_CSSPROPERTY_ColumnRuleColor: | |
948 if (eType == FDE_CSSPRIMITIVETYPE_RGB) { | |
949 FDE_CSSNONINHERITS.m_dwColumnRuleColor = pPrimitive->GetRGBColor(); | |
950 FDE_CSSNONINHERITS.m_bColumnRuleColorSame = FALSE; | |
951 } | |
952 break; | |
953 case FDE_CSSPROPERTY_ColumnRuleStyle: | |
954 if (eType == FDE_CSSPRIMITIVETYPE_Enum) { | |
955 FDE_CSSNONINHERITS.m_eColumnRuleStyle = | |
956 ToBorderStyle(pPrimitive->GetEnum()); | |
957 } | |
958 break; | |
959 case FDE_CSSPROPERTY_ColumnRuleWidth: | |
960 SetLengthWithPercent(FDE_CSSNONINHERITS.m_ColumnRuleWidth, eType, | |
961 pPrimitive, FDE_CSSFONTSIZE); | |
962 break; | |
963 case FDE_CSSPROPERTY_ColumnWidth: | |
964 SetLengthWithPercent(FDE_CSSNONINHERITS.m_ColumnWidth, eType, | |
965 pPrimitive, FDE_CSSFONTSIZE); | |
966 break; | |
967 case FDE_CSSPROPERTY_BackgroundImage: | |
968 if (eType == FDE_CSSPRIMITIVETYPE_Enum) { | |
969 FDE_CSSNONINHERITS.m_pszBKGImage = NULL; | |
970 } else if (eType == FDE_CSSPRIMITIVETYPE_URI) { | |
971 int32_t iLength; | |
972 FDE_CSSNONINHERITS.m_pszBKGImage = pPrimitive->GetString(iLength); | |
973 } | |
974 break; | |
975 case FDE_CSSPROPERTY_Position: | |
976 if (eType == FDE_CSSPRIMITIVETYPE_Enum) { | |
977 FDE_CSSNONINHERITS.m_ePosition = ToPosition(pPrimitive->GetEnum()); | |
978 } | |
979 break; | |
980 case FDE_CSSPROPERTY_Top: | |
981 SetLengthWithPercent(FDE_CSSNONINHERITS.m_Top, eType, pPrimitive, | |
982 FDE_CSSFONTSIZE); | |
983 break; | |
984 case FDE_CSSPROPERTY_Bottom: | |
985 SetLengthWithPercent(FDE_CSSNONINHERITS.m_Bottom, eType, pPrimitive, | |
986 FDE_CSSFONTSIZE); | |
987 break; | |
988 case FDE_CSSPROPERTY_Left: | |
989 SetLengthWithPercent(FDE_CSSNONINHERITS.m_Left, eType, pPrimitive, | |
990 FDE_CSSFONTSIZE); | |
991 break; | |
992 case FDE_CSSPROPERTY_Right: | |
993 SetLengthWithPercent(FDE_CSSNONINHERITS.m_Right, eType, pPrimitive, | |
994 FDE_CSSFONTSIZE); | |
995 break; | |
996 case FDE_CSSPROPERTY_ListStyleImage: | |
997 if (eType == FDE_CSSPRIMITIVETYPE_Enum) { | |
998 FDE_CSSINHERITS.m_pszListStyleImage = NULL; | |
999 } else if (eType == FDE_CSSPRIMITIVETYPE_URI) { | |
1000 int32_t iLength; | |
1001 FDE_CSSINHERITS.m_pszListStyleImage = pPrimitive->GetString(iLength); | |
1002 } | |
1003 break; | |
1004 case FDE_CSSPROPERTY_CaptionSide: | |
1005 if (eType == FDE_CSSPRIMITIVETYPE_Enum) { | |
1006 FDE_CSSINHERITS.m_eCaptionSide = ToCaptionSide(pPrimitive->GetEnum()); | |
1007 } | |
1008 break; | |
1009 case FDE_CSSPROPERTY_BackgroundRepeat: | |
1010 if (eType == FDE_CSSPRIMITIVETYPE_Enum) { | |
1011 FDE_CSSNONINHERITS.m_eBKGRepeat = ToBKGRepeat(pPrimitive->GetEnum()); | |
1012 } | |
1013 break; | |
1014 case FDE_CSSPROPERTY_BackgroundAttachment: | |
1015 if (eType == FDE_CSSPRIMITIVETYPE_Enum) { | |
1016 FDE_CSSNONINHERITS.m_eBKGAttachment = | |
1017 ToBKGAttachment(pPrimitive->GetEnum()); | |
1018 } | |
1019 break; | |
1020 case FDE_CSSPROPERTY_RubyAlign: | |
1021 if (eType == FDE_CSSPRIMITIVETYPE_Enum) { | |
1022 FDE_CSSINHERITS.m_eRubyAlign = ToRubyAlign(pPrimitive->GetEnum()); | |
1023 } | |
1024 break; | |
1025 case FDE_CSSPROPERTY_RubyOverhang: | |
1026 if (eType == FDE_CSSPRIMITIVETYPE_Enum) { | |
1027 FDE_CSSINHERITS.m_eRubyOverhang = | |
1028 ToRubyOverhang(pPrimitive->GetEnum()); | |
1029 } | |
1030 break; | |
1031 case FDE_CSSPROPERTY_RubyPosition: | |
1032 if (eType == FDE_CSSPRIMITIVETYPE_Enum) { | |
1033 FDE_CSSINHERITS.m_eRubyPosition = | |
1034 ToRubyPosition(pPrimitive->GetEnum()); | |
1035 } | |
1036 break; | |
1037 case FDE_CSSPROPERTY_RubySpan: | |
1038 FDE_CSSNONINHERITS.m_pRubySpan = pPrimitive; | |
1039 break; | |
1040 default: | |
1041 break; | |
1042 } | |
1043 } else if (pValue->GetType() == FDE_CSSVALUETYPE_List) { | |
1044 IFDE_CSSValueList* pList = (IFDE_CSSValueList*)pValue; | |
1045 int32_t iCount = pList->CountValues(); | |
1046 if (iCount > 0) { | |
1047 switch (eProperty) { | |
1048 case FDE_CSSPROPERTY_FontFamily: | |
1049 FDE_CSSINHERITS.m_pFontFamily = pList; | |
1050 break; | |
1051 case FDE_CSSPROPERTY_TextDecoration: | |
1052 FDE_CSSNONINHERITS.m_dwTextDecoration = ToTextDecoration(pList); | |
1053 break; | |
1054 case FDE_CSSPROPERTY_CounterIncrement: { | |
1055 if (FDE_CSSNONINHERITS.m_pCounterStyle == NULL) { | |
1056 FDE_CSSNONINHERITS.m_pCounterStyle = new CFDE_CSSCounterStyle; | |
1057 } | |
1058 FDE_CSSNONINHERITS.m_pCounterStyle->SetCounterIncrementList(pList); | |
1059 } break; | |
1060 case FDE_CSSPROPERTY_CounterReset: { | |
1061 if (FDE_CSSNONINHERITS.m_pCounterStyle == NULL) { | |
1062 FDE_CSSNONINHERITS.m_pCounterStyle = new CFDE_CSSCounterStyle; | |
1063 } | |
1064 FDE_CSSNONINHERITS.m_pCounterStyle->SetCounterResetList(pList); | |
1065 } break; | |
1066 case FDE_CSSPROPERTY_Content: | |
1067 FDE_CSSNONINHERITS.m_pContentList = pList; | |
1068 break; | |
1069 case FDE_CSSPROPERTY_Quotes: | |
1070 FDE_CSSINHERITS.m_pQuotes = pList; | |
1071 break; | |
1072 case FDE_CSSPROPERTY_TextCombine: { | |
1073 for (int32_t i = 0; i < pList->CountValues(); i++) { | |
1074 IFDE_CSSPrimitiveValue* pVal = | |
1075 (IFDE_CSSPrimitiveValue*)pList->GetValue(i); | |
1076 switch (pVal->GetPrimitiveType()) { | |
1077 case FDE_CSSPRIMITIVETYPE_Enum: { | |
1078 switch (pVal->GetEnum()) { | |
1079 case FDE_CSSPROPERTYVALUE_None: { | |
1080 FDE_CSSNONINHERITS.m_eTextCombine = FDE_CSSTEXTCOMBINE_None; | |
1081 FDE_CSSNONINHERITS.m_bHasTextCombineNumber = FALSE; | |
1082 } break; | |
1083 case FDE_CSSPROPERTYVALUE_Horizontal: { | |
1084 FDE_CSSNONINHERITS.m_eTextCombine = | |
1085 FDE_CSSTEXTCOMBINE_Horizontal; | |
1086 FDE_CSSNONINHERITS.m_bHasTextCombineNumber = FALSE; | |
1087 } break; | |
1088 default: | |
1089 break; | |
1090 } | |
1091 } break; | |
1092 case FDE_CSSPRIMITIVETYPE_Number: | |
1093 FDE_CSSNONINHERITS.m_fTextCombineNumber = pVal->GetFloat(); | |
1094 break; | |
1095 default: | |
1096 break; | |
1097 } | |
1098 } | |
1099 } break; | |
1100 case FDE_CSSPROPERTY_TextEmphasisStyle: { | |
1101 FDE_CSSTEXTEMPHASISFILL eFill; | |
1102 FDE_CSSTEXTEMPHASISMARK eMark; | |
1103 for (int32_t i = 0; i < pList->CountValues(); i++) { | |
1104 IFDE_CSSPrimitiveValue* pVal = | |
1105 (IFDE_CSSPrimitiveValue*)pList->GetValue(i); | |
1106 switch (pVal->GetPrimitiveType()) { | |
1107 case FDE_CSSPRIMITIVETYPE_Enum: { | |
1108 if (ToTextEmphasisFill(pVal->GetEnum(), eFill)) { | |
1109 FDE_CSSINHERITS.m_eTextEmphasisFill = eFill; | |
1110 continue; | |
1111 } else if (ToTextEmphasisMark(pVal->GetEnum(), eMark)) { | |
1112 FDE_CSSINHERITS.m_eTextEmphasisMark = eMark; | |
1113 } | |
1114 } break; | |
1115 case FDE_CSSPRIMITIVETYPE_String: { | |
1116 FDE_CSSINHERITS.m_eTextEmphasisMark = | |
1117 FDE_CSSTEXTEMPHASISMARK_Custom; | |
1118 int32_t iLen; | |
1119 FDE_CSSINHERITS.m_pszTextEmphasisCustomMark = | |
1120 pVal->GetString(iLen); | |
1121 } break; | |
1122 default: | |
1123 break; | |
1124 } | |
1125 } | |
1126 } break; | |
1127 default: | |
1128 break; | |
1129 } | |
1130 } | |
1131 } else { | |
1132 FXSYS_assert(FALSE); | |
1133 } | |
1134 } | |
1135 FX_FLOAT CFDE_CSSStyleSelector::ApplyNumber(FDE_CSSPRIMITIVETYPE eUnit, | |
1136 FX_FLOAT fValue, | |
1137 FX_FLOAT fPercentBase) { | |
1138 switch (eUnit) { | |
1139 case FDE_CSSPRIMITIVETYPE_PX: | |
1140 case FDE_CSSPRIMITIVETYPE_Number: | |
1141 return fValue * 72 / 96; | |
1142 case FDE_CSSPRIMITIVETYPE_PT: | |
1143 return fValue; | |
1144 case FDE_CSSPRIMITIVETYPE_EMS: | |
1145 case FDE_CSSPRIMITIVETYPE_EXS: | |
1146 return fValue * fPercentBase; | |
1147 case FDE_CSSPRIMITIVETYPE_Percent: | |
1148 return fValue * fPercentBase / 100.0f; | |
1149 case FDE_CSSPRIMITIVETYPE_CM: | |
1150 return fValue * 28.3464f; | |
1151 case FDE_CSSPRIMITIVETYPE_MM: | |
1152 return fValue * 2.8346f; | |
1153 case FDE_CSSPRIMITIVETYPE_IN: | |
1154 return fValue * 72.0f; | |
1155 case FDE_CSSPRIMITIVETYPE_PC: | |
1156 return fValue / 12.0f; | |
1157 default: | |
1158 return fValue; | |
1159 } | |
1160 } | |
1161 FDE_CSSRUBYSPAN CFDE_CSSStyleSelector::ToRubySpan(FDE_CSSPROPERTYVALUE eValue) { | |
1162 switch (eValue) { | |
1163 case FDE_CSSPROPERTYVALUE_None: | |
1164 default: | |
1165 return FDE_CSSRUBYSPAN_None; | |
1166 } | |
1167 } | |
1168 FDE_CSSRUBYPOSITION CFDE_CSSStyleSelector::ToRubyPosition( | |
1169 FDE_CSSPROPERTYVALUE eValue) { | |
1170 switch (eValue) { | |
1171 case FDE_CSSPROPERTYVALUE_Before: | |
1172 return FDE_CSSRUBYPOSITION_Before; | |
1173 case FDE_CSSPROPERTYVALUE_After: | |
1174 return FDE_CSSRUBYPOSITION_After; | |
1175 case FDE_CSSPROPERTYVALUE_Right: | |
1176 return FDE_CSSRUBYPOSITION_Right; | |
1177 case FDE_CSSPROPERTYVALUE_Inline: | |
1178 return FDE_CSSRUBYPOSITION_Inline; | |
1179 default: | |
1180 return FDE_CSSRUBYPOSITION_Before; | |
1181 } | |
1182 } | |
1183 FDE_CSSRUBYOVERHANG CFDE_CSSStyleSelector::ToRubyOverhang( | |
1184 FDE_CSSPROPERTYVALUE eValue) { | |
1185 switch (eValue) { | |
1186 case FDE_CSSPROPERTYVALUE_Auto: | |
1187 return FDE_CSSRUBYOVERHANG_Auto; | |
1188 case FDE_CSSPROPERTYVALUE_Start: | |
1189 return FDE_CSSRUBYOVERHANG_Start; | |
1190 case FDE_CSSPROPERTYVALUE_End: | |
1191 return FDE_CSSRUBYOVERHANG_End; | |
1192 case FDE_CSSPROPERTYVALUE_None: | |
1193 default: | |
1194 return FDE_CSSRUBYOVERHANG_None; | |
1195 } | |
1196 } | |
1197 FDE_CSSRUBYALIGN CFDE_CSSStyleSelector::ToRubyAlign( | |
1198 FDE_CSSPROPERTYVALUE eValue) { | |
1199 switch (eValue) { | |
1200 case FDE_CSSPROPERTYVALUE_Auto: | |
1201 return FDE_CSSRUBYALIGN_Auto; | |
1202 case FDE_CSSPROPERTYVALUE_Start: | |
1203 return FDE_CSSRUBYALIGN_Start; | |
1204 case FDE_CSSPROPERTYVALUE_Left: | |
1205 return FDE_CSSRUBYALIGN_End; | |
1206 case FDE_CSSPROPERTYVALUE_Center: | |
1207 return FDE_CSSRUBYALIGN_Center; | |
1208 case FDE_CSSPROPERTYVALUE_End: | |
1209 return FDE_CSSRUBYALIGN_End; | |
1210 case FDE_CSSPROPERTYVALUE_Right: | |
1211 return FDE_CSSRUBYALIGN_Right; | |
1212 case FDE_CSSPROPERTYVALUE_DistributeLetter: | |
1213 return FDE_CSSRUBYALIGN_DistributeLetter; | |
1214 case FDE_CSSPROPERTYVALUE_DistributeSpace: | |
1215 return FDE_CSSRUBYALIGN_DistributeSpace; | |
1216 case FDE_CSSPROPERTYVALUE_LineEdge: | |
1217 return FDE_CSSRUBYALIGN_LineEdge; | |
1218 default: | |
1219 return FDE_CSSRUBYALIGN_Auto; | |
1220 } | |
1221 } | |
1222 FX_BOOL CFDE_CSSStyleSelector::ToTextEmphasisMark( | |
1223 FDE_CSSPROPERTYVALUE eValue, | |
1224 FDE_CSSTEXTEMPHASISMARK& eMark) { | |
1225 switch (eValue) { | |
1226 case FDE_CSSPROPERTYVALUE_None: | |
1227 eMark = FDE_CSSTEXTEMPHASISMARK_None; | |
1228 return TRUE; | |
1229 case FDE_CSSPROPERTYVALUE_Dot: | |
1230 eMark = FDE_CSSTEXTEMPHASISMARK_Dot; | |
1231 return TRUE; | |
1232 case FDE_CSSPROPERTYVALUE_Circle: | |
1233 eMark = FDE_CSSTEXTEMPHASISMARK_Circle; | |
1234 return TRUE; | |
1235 case FDE_CSSPROPERTYVALUE_DoubleCircle: | |
1236 eMark = FDE_CSSTEXTEMPHASISMARK_DoubleCircle; | |
1237 return TRUE; | |
1238 case FDE_CSSPROPERTYVALUE_Triangle: | |
1239 eMark = FDE_CSSTEXTEMPHASISMARK_Triangle; | |
1240 return TRUE; | |
1241 case FDE_CSSPROPERTYVALUE_Sesame: | |
1242 eMark = FDE_CSSTEXTEMPHASISMARK_Sesame; | |
1243 return TRUE; | |
1244 default: | |
1245 return FALSE; | |
1246 } | |
1247 } | |
1248 FX_BOOL CFDE_CSSStyleSelector::ToTextEmphasisFill( | |
1249 FDE_CSSPROPERTYVALUE eValue, | |
1250 FDE_CSSTEXTEMPHASISFILL& eFill) { | |
1251 switch (eValue) { | |
1252 case FDE_CSSPROPERTYVALUE_Filled: | |
1253 eFill = FDE_CSSTEXTEMPHASISFILL_Filled; | |
1254 return TRUE; | |
1255 case FDE_CSSPROPERTYVALUE_Open: | |
1256 eFill = FDE_CSSTEXTEMPHASISFILL_Open; | |
1257 return TRUE; | |
1258 default: | |
1259 return FALSE; | |
1260 } | |
1261 } | |
1262 FDE_CSSBKGATTACHMENT CFDE_CSSStyleSelector::ToBKGAttachment( | |
1263 FDE_CSSPROPERTYVALUE eValue) { | |
1264 switch (eValue) { | |
1265 case FDE_CSSPROPERTYVALUE_Fixed: | |
1266 return FDE_CSSBKGATTACHMENT_Fixed; | |
1267 case FDE_CSSPROPERTYVALUE_Scroll: | |
1268 return FDE_CSSBKGATTACHMENT_Scroll; | |
1269 default: | |
1270 return FDE_CSSBKGATTACHMENT_Fixed; | |
1271 } | |
1272 } | |
1273 FDE_CSSCAPTIONSIDE CFDE_CSSStyleSelector::ToCaptionSide( | |
1274 FDE_CSSPROPERTYVALUE eValue) { | |
1275 switch (eValue) { | |
1276 case FDE_CSSPROPERTYVALUE_Top: | |
1277 return FDE_CSSCAPTIONSIDE_Top; | |
1278 case FDE_CSSPROPERTYVALUE_Bottom: | |
1279 return FDE_CSSCAPTIONSIDE_Bottom; | |
1280 case FDE_CSSPROPERTYVALUE_Left: | |
1281 return FDE_CSSCAPTIONSIDE_Left; | |
1282 case FDE_CSSPROPERTYVALUE_Right: | |
1283 return FDE_CSSCAPTIONSIDE_Right; | |
1284 case FDE_CSSPROPERTYVALUE_Before: | |
1285 return FDE_CSSCAPTIONSIDE_Before; | |
1286 case FDE_CSSPROPERTYVALUE_After: | |
1287 return FDE_CSSCAPTIONSIDE_After; | |
1288 default: | |
1289 return FDE_CSSCAPTIONSIDE_Top; | |
1290 } | |
1291 } | |
1292 FDE_CSSPOSITION CFDE_CSSStyleSelector::ToPosition(FDE_CSSPROPERTYVALUE eValue) { | |
1293 switch (eValue) { | |
1294 case FDE_CSSPROPERTYVALUE_Static: | |
1295 return FDE_CSSPOSITION_Static; | |
1296 case FDE_CSSPROPERTYVALUE_Relative: | |
1297 return FDE_CSSPOSITION_Relative; | |
1298 case FDE_CSSPROPERTYVALUE_Fixed: | |
1299 return FDE_CSSPOSITION_Fixed; | |
1300 case FDE_CSSPROPERTYVALUE_Absolute: | |
1301 return FDE_CSSPOSITION_Absolute; | |
1302 default: | |
1303 return FDE_CSSPOSITION_Static; | |
1304 } | |
1305 } | |
1306 FDE_CSSCURSOR CFDE_CSSStyleSelector::ToCursor(FDE_CSSPROPERTYVALUE eValue) { | |
1307 switch (eValue) { | |
1308 case FDE_CSSPROPERTYVALUE_Auto: | |
1309 return FDE_CSSCURSOR_Auto; | |
1310 case FDE_CSSPROPERTYVALUE_Crosshair: | |
1311 return FDE_CSSCURSOR_Crosshair; | |
1312 case FDE_CSSPROPERTYVALUE_Default: | |
1313 return FDE_CSSCURSOR_Default; | |
1314 case FDE_CSSPROPERTYVALUE_Pointer: | |
1315 return FDE_CSSCURSOR_Pointer; | |
1316 case FDE_CSSPROPERTYVALUE_Move: | |
1317 return FDE_CSSCURSOR_Move; | |
1318 case FDE_CSSPROPERTYVALUE_EResize: | |
1319 return FDE_CSSCURSOR_EResize; | |
1320 case FDE_CSSPROPERTYVALUE_NeResize: | |
1321 return FDE_CSSCURSOR_NeResize; | |
1322 case FDE_CSSPROPERTYVALUE_NwResize: | |
1323 return FDE_CSSCURSOR_NwResize; | |
1324 case FDE_CSSPROPERTYVALUE_NResize: | |
1325 return FDE_CSSCURSOR_NResize; | |
1326 case FDE_CSSPROPERTYVALUE_SeResize: | |
1327 return FDE_CSSCURSOR_SeResize; | |
1328 case FDE_CSSPROPERTYVALUE_SwResize: | |
1329 return FDE_CSSCURSOR_SwResize; | |
1330 default: | |
1331 return FDE_CSSCURSOR_Auto; | |
1332 } | |
1333 } | |
1334 FDE_CSSBKGREPEAT CFDE_CSSStyleSelector::ToBKGRepeat( | |
1335 FDE_CSSPROPERTYVALUE eValue) { | |
1336 switch (eValue) { | |
1337 case FDE_CSSPROPERTYVALUE_Repeat: | |
1338 return FDE_CSSBKGREPEAT_Repeat; | |
1339 case FDE_CSSPROPERTYVALUE_RepeatX: | |
1340 return FDE_CSSBKGREPEAT_RepeatX; | |
1341 case FDE_CSSPROPERTYVALUE_RepeatY: | |
1342 return FDE_CSSBKGREPEAT_RepeatY; | |
1343 case FDE_CSSPROPERTYVALUE_NoRepeat: | |
1344 return FDE_CSSBKGREPEAT_NoRepeat; | |
1345 default: | |
1346 return FDE_CSSBKGREPEAT_Repeat; | |
1347 } | |
1348 } | |
1349 FDE_CSSTEXTCOMBINE CFDE_CSSStyleSelector::ToTextCombine( | |
1350 FDE_CSSPROPERTYVALUE eValue) { | |
1351 switch (eValue) { | |
1352 case FDE_CSSPROPERTYVALUE_Horizontal: | |
1353 return FDE_CSSTEXTCOMBINE_Horizontal; | |
1354 case FDE_CSSPROPERTYVALUE_None: | |
1355 default: | |
1356 return FDE_CSSTEXTCOMBINE_None; | |
1357 } | |
1358 } | |
1359 FDE_CSSLINEBREAK CFDE_CSSStyleSelector::ToLineBreak( | |
1360 FDE_CSSPROPERTYVALUE eValue) { | |
1361 switch (eValue) { | |
1362 case FDE_CSSPROPERTYVALUE_Auto: | |
1363 return FDE_CSSLINEBREAK_Auto; | |
1364 case FDE_CSSPROPERTYVALUE_Loose: | |
1365 return FDE_CSSLINEBREAK_Loose; | |
1366 case FDE_CSSPROPERTYVALUE_Normal: | |
1367 return FDE_CSSLINEBREAK_Normal; | |
1368 case FDE_CSSPROPERTYVALUE_Strict: | |
1369 return FDE_CSSLINEBREAK_Strict; | |
1370 default: | |
1371 return FDE_CSSLINEBREAK_Auto; | |
1372 } | |
1373 } | |
1374 FDE_CSSOVERFLOW CFDE_CSSStyleSelector::ToOverflow(FDE_CSSPROPERTYVALUE eValue) { | |
1375 switch (eValue) { | |
1376 case FDE_CSSPROPERTYVALUE_Visible: | |
1377 return FDE_CSSOVERFLOW_Visible; | |
1378 case FDE_CSSPROPERTYVALUE_Hidden: | |
1379 return FDE_CSSOVERFLOW_Hidden; | |
1380 case FDE_CSSPROPERTYVALUE_Scroll: | |
1381 return FDE_CSSOVERFLOW_Scroll; | |
1382 case FDE_CSSPROPERTYVALUE_Auto: | |
1383 return FDE_CSSOVERFLOW_Auto; | |
1384 case FDE_CSSPROPERTYVALUE_NoDisplay: | |
1385 return FDE_CSSOVERFLOW_NoDisplay; | |
1386 case FDE_CSSPROPERTYVALUE_NoContent: | |
1387 return FDE_CSSOVERFLOW_NoContent; | |
1388 default: | |
1389 return FDE_CSSOVERFLOW_Visible; | |
1390 } | |
1391 } | |
1392 FDE_CSSWRITINGMODE CFDE_CSSStyleSelector::ToWritingMode( | |
1393 FDE_CSSPROPERTYVALUE eValue) { | |
1394 switch (eValue) { | |
1395 case FDE_CSSPROPERTYVALUE_HorizontalTb: | |
1396 return FDE_CSSWRITINGMODE_HorizontalTb; | |
1397 case FDE_CSSPROPERTYVALUE_VerticalRl: | |
1398 return FDE_CSSWRITINGMODE_VerticalRl; | |
1399 case FDE_CSSPROPERTYVALUE_VerticalLr: | |
1400 return FDE_CSSWRITINGMODE_VerticalLr; | |
1401 default: | |
1402 return FDE_CSSWRITINGMODE_HorizontalTb; | |
1403 } | |
1404 } | |
1405 FDE_CSSWORDBREAK CFDE_CSSStyleSelector::ToWordBreak( | |
1406 FDE_CSSPROPERTYVALUE eValue) { | |
1407 switch (eValue) { | |
1408 case FDE_CSSPROPERTYVALUE_Normal: | |
1409 return FDE_CSSWORDBREAK_Normal; | |
1410 case FDE_CSSPROPERTYVALUE_KeepAll: | |
1411 return FDE_CSSWORDBREAK_KeepAll; | |
1412 case FDE_CSSPROPERTYVALUE_BreakAll: | |
1413 return FDE_CSSWORDBREAK_BreakAll; | |
1414 case FDE_CSSPROPERTYVALUE_KeepWords: | |
1415 return FDE_CSSWORDBREAK_KeepWords; | |
1416 default: | |
1417 return FDE_CSSWORDBREAK_Normal; | |
1418 } | |
1419 } | |
1420 FDE_CSSFLOAT CFDE_CSSStyleSelector::ToFloat(FDE_CSSPROPERTYVALUE eValue) { | |
1421 switch (eValue) { | |
1422 case FDE_CSSPROPERTYVALUE_Left: | |
1423 return FDE_CSSFLOAT_Left; | |
1424 case FDE_CSSPROPERTYVALUE_Right: | |
1425 return FDE_CSSFLOAT_Right; | |
1426 case FDE_CSSPROPERTYVALUE_None: | |
1427 return FDE_CSSFLOAT_None; | |
1428 default: | |
1429 return FDE_CSSFLOAT_None; | |
1430 } | |
1431 } | |
1432 FDE_CSSCLEAR CFDE_CSSStyleSelector::ToClear(FDE_CSSPROPERTYVALUE eValue) { | |
1433 switch (eValue) { | |
1434 case FDE_CSSPROPERTYVALUE_None: | |
1435 return FDE_CSSCLEAR_None; | |
1436 case FDE_CSSPROPERTYVALUE_Left: | |
1437 return FDE_CSSCLEAR_Left; | |
1438 case FDE_CSSPROPERTYVALUE_Right: | |
1439 return FDE_CSSCLEAR_Right; | |
1440 case FDE_CSSPROPERTYVALUE_Both: | |
1441 return FDE_CSSCLEAR_Both; | |
1442 default: | |
1443 return FDE_CSSCLEAR_None; | |
1444 } | |
1445 } | |
1446 FDE_CSSPAGEBREAK CFDE_CSSStyleSelector::ToPageBreak( | |
1447 FDE_CSSPROPERTYVALUE eValue) { | |
1448 switch (eValue) { | |
1449 case FDE_CSSPROPERTYVALUE_Avoid: | |
1450 return FDE_CSSPAGEBREAK_Avoid; | |
1451 case FDE_CSSPROPERTYVALUE_Auto: | |
1452 return FDE_CSSPAGEBREAK_Auto; | |
1453 case FDE_CSSPROPERTYVALUE_Always: | |
1454 return FDE_CSSPAGEBREAK_Always; | |
1455 case FDE_CSSPROPERTYVALUE_Left: | |
1456 return FDE_CSSPAGEBREAK_Left; | |
1457 case FDE_CSSPROPERTYVALUE_Right: | |
1458 return FDE_CSSPAGEBREAK_Right; | |
1459 default: | |
1460 return FDE_CSSPAGEBREAK_Auto; | |
1461 } | |
1462 } | |
1463 FDE_CSSDISPLAY CFDE_CSSStyleSelector::ToDisplay(FDE_CSSPROPERTYVALUE eValue) { | |
1464 switch (eValue) { | |
1465 case FDE_CSSPROPERTYVALUE_Inline: | |
1466 return FDE_CSSDISPLAY_Inline; | |
1467 case FDE_CSSPROPERTYVALUE_Block: | |
1468 return FDE_CSSDISPLAY_Block; | |
1469 case FDE_CSSPROPERTYVALUE_None: | |
1470 return FDE_CSSDISPLAY_None; | |
1471 case FDE_CSSPROPERTYVALUE_ListItem: | |
1472 return FDE_CSSDISPLAY_ListItem; | |
1473 case FDE_CSSPROPERTYVALUE_TableCell: | |
1474 return FDE_CSSDISPLAY_TableCell; | |
1475 case FDE_CSSPROPERTYVALUE_TableRow: | |
1476 return FDE_CSSDISPLAY_TableRow; | |
1477 case FDE_CSSPROPERTYVALUE_Table: | |
1478 return FDE_CSSDISPLAY_Table; | |
1479 case FDE_CSSPROPERTYVALUE_TableCaption: | |
1480 return FDE_CSSDISPLAY_TableCaption; | |
1481 case FDE_CSSPROPERTYVALUE_TableRowGroup: | |
1482 return FDE_CSSDISPLAY_TableRowGroup; | |
1483 case FDE_CSSPROPERTYVALUE_TableHeaderGroup: | |
1484 return FDE_CSSDISPLAY_TableHeaderGroup; | |
1485 case FDE_CSSPROPERTYVALUE_TableFooterGroup: | |
1486 return FDE_CSSDISPLAY_TableFooterGroup; | |
1487 case FDE_CSSPROPERTYVALUE_TableColumnGroup: | |
1488 return FDE_CSSDISPLAY_TableColumnGroup; | |
1489 case FDE_CSSPROPERTYVALUE_TableColumn: | |
1490 return FDE_CSSDISPLAY_TableColumn; | |
1491 case FDE_CSSPROPERTYVALUE_InlineTable: | |
1492 return FDE_CSSDISPLAY_InlineTable; | |
1493 case FDE_CSSPROPERTYVALUE_InlineBlock: | |
1494 return FDE_CSSDISPLAY_InlineBlock; | |
1495 case FDE_CSSPROPERTYVALUE_RunIn: | |
1496 return FDE_CSSDISPLAY_RunIn; | |
1497 case FDE_CSSPROPERTYVALUE_Ruby: | |
1498 return FDE_CSSDISPLAY_Ruby; | |
1499 case FDE_CSSPROPERTYVALUE_RubyBase: | |
1500 return FDE_CSSDISPLAY_RubyBase; | |
1501 case FDE_CSSPROPERTYVALUE_RubyText: | |
1502 return FDE_CSSDISPLAY_RubyText; | |
1503 case FDE_CSSPROPERTYVALUE_RubyBaseGroup: | |
1504 return FDE_CSSDISPLSY_RubyBaseGroup; | |
1505 case FDE_CSSPROPERTYVALUE_RubyTextGroup: | |
1506 return FDE_CSSDISPLAY_RubyTextGroup; | |
1507 default: | |
1508 return FDE_CSSDISPLAY_Inline; | |
1509 } | |
1510 } | |
1511 FDE_CSSTEXTALIGN CFDE_CSSStyleSelector::ToTextAlign( | |
1512 FDE_CSSPROPERTYVALUE eValue) { | |
1513 switch (eValue) { | |
1514 case FDE_CSSPROPERTYVALUE_Left: | |
1515 return FDE_CSSTEXTALIGN_Left; | |
1516 case FDE_CSSPROPERTYVALUE_Center: | |
1517 return FDE_CSSTEXTALIGN_Center; | |
1518 case FDE_CSSPROPERTYVALUE_Right: | |
1519 return FDE_CSSTEXTALIGN_Right; | |
1520 case FDE_CSSPROPERTYVALUE_Justify: | |
1521 return FDE_CSSTEXTALIGN_Justify; | |
1522 default: | |
1523 return FDE_CSSTEXTALIGN_Left; | |
1524 } | |
1525 } | |
1526 FX_WORD CFDE_CSSStyleSelector::ToFontWeight(FDE_CSSPROPERTYVALUE eValue) { | |
1527 switch (eValue) { | |
1528 case FDE_CSSPROPERTYVALUE_Normal: | |
1529 return 400; | |
1530 case FDE_CSSPROPERTYVALUE_Bold: | |
1531 return 700; | |
1532 case FDE_CSSPROPERTYVALUE_Bolder: | |
1533 return 900; | |
1534 case FDE_CSSPROPERTYVALUE_Lighter: | |
1535 return 200; | |
1536 default: | |
1537 return 400; | |
1538 } | |
1539 } | |
1540 FDE_CSSFONTSTYLE CFDE_CSSStyleSelector::ToFontStyle( | |
1541 FDE_CSSPROPERTYVALUE eValue) { | |
1542 switch (eValue) { | |
1543 case FDE_CSSPROPERTYVALUE_Italic: | |
1544 case FDE_CSSPROPERTYVALUE_Oblique: | |
1545 return FDE_CSSFONTSTYLE_Italic; | |
1546 default: | |
1547 return FDE_CSSFONTSTYLE_Normal; | |
1548 } | |
1549 } | |
1550 FDE_CSSBORDERSTYLE CFDE_CSSStyleSelector::ToBorderStyle( | |
1551 FDE_CSSPROPERTYVALUE eValue) { | |
1552 switch (eValue) { | |
1553 case FDE_CSSPROPERTYVALUE_None: | |
1554 return FDE_CSSBORDERSTYLE_None; | |
1555 case FDE_CSSPROPERTYVALUE_Solid: | |
1556 return FDE_CSSBORDERSTYLE_Solid; | |
1557 case FDE_CSSPROPERTYVALUE_Hidden: | |
1558 return FDE_CSSBORDERSTYLE_Hidden; | |
1559 case FDE_CSSPROPERTYVALUE_Dotted: | |
1560 return FDE_CSSBORDERSTYLE_Dotted; | |
1561 case FDE_CSSPROPERTYVALUE_Dashed: | |
1562 return FDE_CSSBORDERSTYLE_Dashed; | |
1563 case FDE_CSSPROPERTYVALUE_Double: | |
1564 return FDE_CSSBORDERSTYLE_Double; | |
1565 case FDE_CSSPROPERTYVALUE_Groove: | |
1566 return FDE_CSSBORDERSTYLE_Groove; | |
1567 case FDE_CSSPROPERTYVALUE_Ridge: | |
1568 return FDE_CSSBORDERSTYLE_Ridge; | |
1569 case FDE_CSSPROPERTYVALUE_Inset: | |
1570 return FDE_CSSBORDERSTYLE_Inset; | |
1571 case FDE_CSSPROPERTYVALUE_Outset: | |
1572 return FDE_CSSBORDERSTYLE_outset; | |
1573 default: | |
1574 return FDE_CSSBORDERSTYLE_None; | |
1575 } | |
1576 } | |
1577 FX_BOOL CFDE_CSSStyleSelector::SetLengthWithPercent( | |
1578 FDE_CSSLENGTH& width, | |
1579 FDE_CSSPRIMITIVETYPE eType, | |
1580 IFDE_CSSPrimitiveValue* pPrimitive, | |
1581 FX_FLOAT fFontSize) { | |
1582 if (eType == FDE_CSSPRIMITIVETYPE_Percent) { | |
1583 width.Set(FDE_CSSLENGTHUNIT_Percent, pPrimitive->GetFloat() / 100.0f); | |
1584 return width.NonZero(); | |
1585 } else if (eType >= FDE_CSSPRIMITIVETYPE_Number && | |
1586 eType <= FDE_CSSPRIMITIVETYPE_PC) { | |
1587 FX_FLOAT fValue = ApplyNumber(eType, pPrimitive->GetFloat(), fFontSize); | |
1588 width.Set(FDE_CSSLENGTHUNIT_Point, fValue); | |
1589 return width.NonZero(); | |
1590 } else if (eType == FDE_CSSPRIMITIVETYPE_Enum) { | |
1591 switch (pPrimitive->GetEnum()) { | |
1592 case FDE_CSSPROPERTYVALUE_Auto: | |
1593 width.Set(FDE_CSSLENGTHUNIT_Auto); | |
1594 return TRUE; | |
1595 case FDE_CSSPROPERTYVALUE_None: | |
1596 width.Set(FDE_CSSLENGTHUNIT_None); | |
1597 return TRUE; | |
1598 case FDE_CSSPROPERTYVALUE_Thin: | |
1599 width.Set(FDE_CSSLENGTHUNIT_Point, 2); | |
1600 return TRUE; | |
1601 case FDE_CSSPROPERTYVALUE_Medium: | |
1602 width.Set(FDE_CSSLENGTHUNIT_Point, 3); | |
1603 return TRUE; | |
1604 case FDE_CSSPROPERTYVALUE_Thick: | |
1605 width.Set(FDE_CSSLENGTHUNIT_Point, 4); | |
1606 return TRUE; | |
1607 default: | |
1608 return FALSE; | |
1609 } | |
1610 } | |
1611 return FALSE; | |
1612 } | |
1613 FX_FLOAT CFDE_CSSStyleSelector::ToFontSize(FDE_CSSPROPERTYVALUE eValue, | |
1614 FX_FLOAT fCurFontSize) { | |
1615 switch (eValue) { | |
1616 case FDE_CSSPROPERTYVALUE_XxSmall: | |
1617 return m_fDefFontSize / 1.2f / 1.2f / 1.2f; | |
1618 case FDE_CSSPROPERTYVALUE_XSmall: | |
1619 return m_fDefFontSize / 1.2f / 1.2f; | |
1620 case FDE_CSSPROPERTYVALUE_Small: | |
1621 return m_fDefFontSize / 1.2f; | |
1622 case FDE_CSSPROPERTYVALUE_Medium: | |
1623 return m_fDefFontSize; | |
1624 case FDE_CSSPROPERTYVALUE_Large: | |
1625 return m_fDefFontSize * 1.2f; | |
1626 case FDE_CSSPROPERTYVALUE_XLarge: | |
1627 return m_fDefFontSize * 1.2f * 1.2f; | |
1628 case FDE_CSSPROPERTYVALUE_XxLarge: | |
1629 return m_fDefFontSize * 1.2f * 1.2f * 1.2f; | |
1630 case FDE_CSSPROPERTYVALUE_Larger: | |
1631 return fCurFontSize * 1.2f; | |
1632 case FDE_CSSPROPERTYVALUE_Smaller: | |
1633 return fCurFontSize / 1.2f; | |
1634 default: | |
1635 return fCurFontSize; | |
1636 } | |
1637 } | |
1638 FDE_CSSVERTICALALIGN CFDE_CSSStyleSelector::ToVerticalAlign( | |
1639 FDE_CSSPROPERTYVALUE eValue) { | |
1640 switch (eValue) { | |
1641 case FDE_CSSPROPERTYVALUE_Baseline: | |
1642 return FDE_CSSVERTICALALIGN_Baseline; | |
1643 case FDE_CSSPROPERTYVALUE_Middle: | |
1644 return FDE_CSSVERTICALALIGN_Middle; | |
1645 case FDE_CSSPROPERTYVALUE_Bottom: | |
1646 return FDE_CSSVERTICALALIGN_Bottom; | |
1647 case FDE_CSSPROPERTYVALUE_Super: | |
1648 return FDE_CSSVERTICALALIGN_Super; | |
1649 case FDE_CSSPROPERTYVALUE_Sub: | |
1650 return FDE_CSSVERTICALALIGN_Sub; | |
1651 case FDE_CSSPROPERTYVALUE_Top: | |
1652 return FDE_CSSVERTICALALIGN_Top; | |
1653 case FDE_CSSPROPERTYVALUE_TextTop: | |
1654 return FDE_CSSVERTICALALIGN_TextTop; | |
1655 case FDE_CSSPROPERTYVALUE_TextBottom: | |
1656 return FDE_CSSVERTICALALIGN_TextBottom; | |
1657 default: | |
1658 return FDE_CSSVERTICALALIGN_Baseline; | |
1659 } | |
1660 } | |
1661 FDE_CSSLISTSTYLETYPE CFDE_CSSStyleSelector::ToListStyleType( | |
1662 FDE_CSSPROPERTYVALUE eValue) { | |
1663 switch (eValue) { | |
1664 case FDE_CSSPROPERTYVALUE_None: | |
1665 return FDE_CSSLISTSTYLETYPE_None; | |
1666 case FDE_CSSPROPERTYVALUE_Disc: | |
1667 return FDE_CSSLISTSTYLETYPE_Disc; | |
1668 case FDE_CSSPROPERTYVALUE_Circle: | |
1669 return FDE_CSSLISTSTYLETYPE_Circle; | |
1670 case FDE_CSSPROPERTYVALUE_Square: | |
1671 return FDE_CSSLISTSTYLETYPE_Square; | |
1672 case FDE_CSSPROPERTYVALUE_Decimal: | |
1673 return FDE_CSSLISTSTYLETYPE_Decimal; | |
1674 case FDE_CSSPROPERTYVALUE_DecimalLeadingZero: | |
1675 return FDE_CSSLISTSTYLETYPE_DecimalLeadingZero; | |
1676 case FDE_CSSPROPERTYVALUE_LowerRoman: | |
1677 return FDE_CSSLISTSTYLETYPE_LowerRoman; | |
1678 case FDE_CSSPROPERTYVALUE_UpperRoman: | |
1679 return FDE_CSSLISTSTYLETYPE_UpperRoman; | |
1680 case FDE_CSSPROPERTYVALUE_LowerGreek: | |
1681 return FDE_CSSLISTSTYLETYPE_LowerGreek; | |
1682 case FDE_CSSPROPERTYVALUE_LowerLatin: | |
1683 return FDE_CSSLISTSTYLETYPE_LowerLatin; | |
1684 case FDE_CSSPROPERTYVALUE_UpperLatin: | |
1685 return FDE_CSSLISTSTYLETYPE_UpperLatin; | |
1686 case FDE_CSSPROPERTYVALUE_Armenian: | |
1687 return FDE_CSSLISTSTYLETYPE_Armenian; | |
1688 case FDE_CSSPROPERTYVALUE_Georgian: | |
1689 return FDE_CSSLISTSTYLETYPE_Georgian; | |
1690 case FDE_CSSPROPERTYVALUE_LowerAlpha: | |
1691 return FDE_CSSLISTSTYLETYPE_LowerAlpha; | |
1692 case FDE_CSSPROPERTYVALUE_UpperAlpha: | |
1693 return FDE_CSSLISTSTYLETYPE_UpperAlpha; | |
1694 case FDE_CSSPROPERTYVALUE_CjkIdeographic: | |
1695 return FDE_CSSLISTSTYLETYPE_CjkIdeographic; | |
1696 case FDE_CSSPROPERTYVALUE_Hebrew: | |
1697 return FDE_CSSLISTSTYLETYPE_Hebrew; | |
1698 case FDE_CSSLISTSTYLETYPE_Hiragana: | |
1699 return FDE_CSSLISTSTYLETYPE_Hiragana; | |
1700 case FDE_CSSLISTSTYLETYPE_HiraganaIroha: | |
1701 return FDE_CSSLISTSTYLETYPE_HiraganaIroha; | |
1702 case FDE_CSSLISTSTYLETYPE_Katakana: | |
1703 return FDE_CSSLISTSTYLETYPE_Katakana; | |
1704 case FDE_CSSLISTSTYLETYPE_KatakanaIroha: | |
1705 return FDE_CSSLISTSTYLETYPE_KatakanaIroha; | |
1706 default: | |
1707 return FDE_CSSLISTSTYLETYPE_Disc; | |
1708 } | |
1709 } | |
1710 FDE_CSSLISTSTYLEPOSITION CFDE_CSSStyleSelector::ToListStylePosition( | |
1711 FDE_CSSPROPERTYVALUE eValue) { | |
1712 return eValue == FDE_CSSPROPERTYVALUE_Inside | |
1713 ? FDE_CSSLISTSTYLEPOSITION_Inside | |
1714 : FDE_CSSLISTSTYLEPOSITION_Outside; | |
1715 } | |
1716 FDE_CSSVISIBILITY CFDE_CSSStyleSelector::ToVisibility( | |
1717 FDE_CSSPROPERTYVALUE eValue) { | |
1718 switch (eValue) { | |
1719 case FDE_CSSPROPERTYVALUE_Visible: | |
1720 return FDE_CSSVISIBILITY_Visible; | |
1721 case FDE_CSSPROPERTYVALUE_Hidden: | |
1722 return FDE_CSSVISIBILITY_Hidden; | |
1723 case FDE_CSSPROPERTYVALUE_Collapse: | |
1724 return FDE_CSSVISIBILITY_Collapse; | |
1725 default: | |
1726 return FDE_CSSVISIBILITY_Visible; | |
1727 } | |
1728 } | |
1729 FDE_CSSWHITESPACE CFDE_CSSStyleSelector::ToWhiteSpace( | |
1730 FDE_CSSPROPERTYVALUE eValue) { | |
1731 switch (eValue) { | |
1732 case FDE_CSSPROPERTYVALUE_Normal: | |
1733 return FDE_CSSWHITESPACE_Normal; | |
1734 case FDE_CSSPROPERTYVALUE_Pre: | |
1735 return FDE_CSSWHITESPACE_Pre; | |
1736 case FDE_CSSPROPERTYVALUE_Nowrap: | |
1737 return FDE_CSSWHITESPACE_Nowrap; | |
1738 case FDE_CSSPROPERTYVALUE_PreWrap: | |
1739 return FDE_CSSWHITESPACE_PreWrap; | |
1740 case FDE_CSSPROPERTYVALUE_PreLine: | |
1741 return FDE_CSSWHITESPACE_PreLine; | |
1742 default: | |
1743 return FDE_CSSWHITESPACE_Normal; | |
1744 } | |
1745 } | |
1746 FX_DWORD CFDE_CSSStyleSelector::ToTextDecoration(IFDE_CSSValueList* pValue) { | |
1747 FX_DWORD dwDecoration = 0; | |
1748 for (int32_t i = pValue->CountValues() - 1; i >= 0; --i) { | |
1749 IFDE_CSSPrimitiveValue* pPrimitive = | |
1750 (IFDE_CSSPrimitiveValue*)pValue->GetValue(i); | |
1751 if (pPrimitive->GetPrimitiveType() == FDE_CSSPRIMITIVETYPE_Enum) { | |
1752 switch (pPrimitive->GetEnum()) { | |
1753 case FDE_CSSPROPERTYVALUE_Underline: | |
1754 dwDecoration |= FDE_CSSTEXTDECORATION_Underline; | |
1755 break; | |
1756 case FDE_CSSPROPERTYVALUE_LineThrough: | |
1757 dwDecoration |= FDE_CSSTEXTDECORATION_LineThrough; | |
1758 break; | |
1759 case FDE_CSSPROPERTYVALUE_Overline: | |
1760 dwDecoration |= FDE_CSSTEXTDECORATION_Overline; | |
1761 break; | |
1762 case FDE_CSSPROPERTYVALUE_Blink: | |
1763 dwDecoration |= FDE_CSSTEXTDECORATION_Blink; | |
1764 break; | |
1765 case FDE_CSSPROPERTYVALUE_Double: | |
1766 dwDecoration |= FDE_CSSTEXTDECORATION_Double; | |
1767 break; | |
1768 default: | |
1769 break; | |
1770 } | |
1771 } | |
1772 } | |
1773 return dwDecoration; | |
1774 } | |
1775 FDE_CSSTEXTTRANSFORM CFDE_CSSStyleSelector::ToTextTransform( | |
1776 FDE_CSSPROPERTYVALUE eValue) { | |
1777 switch (eValue) { | |
1778 case FDE_CSSPROPERTYVALUE_None: | |
1779 return FDE_CSSTEXTTRANSFORM_None; | |
1780 case FDE_CSSPROPERTYVALUE_Capitalize: | |
1781 return FDE_CSSTEXTTRANSFORM_Capitalize; | |
1782 case FDE_CSSPROPERTYVALUE_Uppercase: | |
1783 return FDE_CSSTEXTTRANSFORM_UpperCase; | |
1784 case FDE_CSSPROPERTYVALUE_Lowercase: | |
1785 return FDE_CSSTEXTTRANSFORM_LowerCase; | |
1786 default: | |
1787 return FDE_CSSTEXTTRANSFORM_None; | |
1788 } | |
1789 } | |
1790 FDE_CSSFONTVARIANT CFDE_CSSStyleSelector::ToFontVariant( | |
1791 FDE_CSSPROPERTYVALUE eValue) { | |
1792 return eValue == FDE_CSSPROPERTYVALUE_SmallCaps ? FDE_CSSFONTVARIANT_SmallCaps | |
1793 : FDE_CSSFONTVARIANT_Normal; | |
1794 } | |
OLD | NEW |