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 #ifndef _FDE_CSSSTYLESELECTOR 8 #define _FDE_CSSSTYLESELECTOR 9 #define FDE_CSSUNIVERSALHASH ('*') 10 typedef struct _FDE_CSSRULEDATA : public CFX_Target { 11 public: 12 _FDE_CSSRULEDATA(IFDE_CSSSelector* pSel, 13 IFDE_CSSDeclaration* pDecl, 14 FX_DWORD dwPos); 15 IFDE_CSSSelector* pSelector; 16 IFDE_CSSDeclaration* pDeclaration; 17 FX_DWORD dwPriority; 18 _FDE_CSSRULEDATA* pNext; 19 } FDE_CSSRULEDATA, *FDE_LPCSSRULEDATA; 20 typedef CFX_ArrayTemplate<FDE_LPCSSRULEDATA> CFDE_CSSRuleDataArray; 21 class CFDE_CSSRuleCollection : public CFX_Target { 22 public: 23 CFDE_CSSRuleCollection() 24 : m_pStaticStore(nullptr), 25 m_pUniversalRules(nullptr), 26 m_pPersudoRules(nullptr), 27 m_iSelectors(0) {} 28 ~CFDE_CSSRuleCollection() { Clear(); } 29 void AddRulesFrom(const CFDE_CSSStyleSheetArray& sheets, 30 FX_DWORD dwMediaList, 31 IFX_FontMgr* pFontMgr); 32 void Clear(); 33 34 int32_t CountSelectors() const { return m_iSelectors; } 35 FDE_LPCSSRULEDATA GetIDRuleData(FX_DWORD dwIDHash) { 36 void* pData; 37 return m_IDRules.Lookup((void*)(uintptr_t)dwIDHash, pData) 38 ? (FDE_LPCSSRULEDATA)pData 39 : NULL; 40 } 41 FDE_LPCSSRULEDATA GetTagRuleData(FX_DWORD dwTagHasn) { 42 void* pData; 43 return m_TagRules.Lookup((void*)(uintptr_t)dwTagHasn, pData) 44 ? (FDE_LPCSSRULEDATA)pData 45 : NULL; 46 } 47 FDE_LPCSSRULEDATA GetClassRuleData(FX_DWORD dwIDHash) { 48 void* pData; 49 return m_ClassRules.Lookup((void*)(uintptr_t)dwIDHash, pData) 50 ? (FDE_LPCSSRULEDATA)pData 51 : NULL; 52 } 53 FDE_LPCSSRULEDATA GetUniversalRuleData() { return m_pUniversalRules; } 54 FDE_LPCSSRULEDATA GetPersudoRuleData() { return m_pPersudoRules; } 55 IFX_MEMAllocator* m_pStaticStore; 56 57 protected: 58 void AddRulesFrom(IFDE_CSSStyleSheet* pStyleSheet, 59 IFDE_CSSRule* pRule, 60 FX_DWORD dwMediaList, 61 IFX_FontMgr* pFontMgr); 62 void AddRuleTo(CFX_MapPtrToPtr& map, 63 FX_DWORD dwKey, 64 IFDE_CSSSelector* pSel, 65 IFDE_CSSDeclaration* pDecl); 66 FX_BOOL AddRuleTo(FDE_LPCSSRULEDATA& pList, FDE_LPCSSRULEDATA pData); 67 FDE_LPCSSRULEDATA NewRuleData(IFDE_CSSSelector* pSel, 68 IFDE_CSSDeclaration* pDecl); 69 CFX_MapPtrToPtr m_IDRules; 70 CFX_MapPtrToPtr m_TagRules; 71 CFX_MapPtrToPtr m_ClassRules; 72 FDE_LPCSSRULEDATA m_pUniversalRules; 73 FDE_LPCSSRULEDATA m_pPersudoRules; 74 int32_t m_iSelectors; 75 }; 76 class CFDE_CSSAccelerator; 77 class CFDE_CSSComputedStyle; 78 class CFDE_CSSStyleSelector : public IFDE_CSSStyleSelector, public CFX_Target { 79 public: 80 CFDE_CSSStyleSelector(); 81 ~CFDE_CSSStyleSelector(); 82 virtual void Release() { delete this; } 83 84 virtual void SetFontMgr(IFX_FontMgr* pFontMgr); 85 virtual void SetDefFontSize(FX_FLOAT fFontSize); 86 87 virtual FX_BOOL SetStyleSheet(FDE_CSSSTYLESHEETGROUP eType, 88 IFDE_CSSStyleSheet* pSheet); 89 virtual FX_BOOL SetStyleSheets(FDE_CSSSTYLESHEETGROUP eType, 90 const CFDE_CSSStyleSheetArray* pArray); 91 virtual void SetStylePriority(FDE_CSSSTYLESHEETGROUP eType, 92 FDE_CSSSTYLESHEETPRIORITY ePriority); 93 virtual void UpdateStyleIndex(FX_DWORD dwMediaList); 94 virtual IFDE_CSSAccelerator* InitAccelerator(); 95 virtual IFDE_CSSComputedStyle* CreateComputedStyle( 96 IFDE_CSSComputedStyle* pParentStyle); 97 virtual int32_t MatchDeclarations( 98 IFDE_CSSTagProvider* pTag, 99 CFDE_CSSDeclarationArray& matchedDecls, 100 FDE_CSSPERSUDO ePersudoType = FDE_CSSPERSUDO_NONE); 101 virtual void ComputeStyle(IFDE_CSSTagProvider* pTag, 102 const IFDE_CSSDeclaration** ppDeclArray, 103 int32_t iDeclCount, 104 IFDE_CSSComputedStyle* pDestStyle); 105 106 protected: 107 void Reset(); 108 void MatchRules(FDE_LPCSSTAGCACHE pCache, 109 FDE_LPCSSRULEDATA pList, 110 FDE_CSSPERSUDO ePersudoType); 111 void SortRulesTo(CFDE_CSSDeclarationArray& matchDecls); 112 FX_BOOL MatchSelector(FDE_LPCSSTAGCACHE pCache, 113 IFDE_CSSSelector* pSel, 114 FDE_CSSPERSUDO ePersudoType); 115 void AppendInlineStyle(CFDE_CSSDeclaration* pDecl, 116 const FX_WCHAR* psz, 117 int32_t iLen); 118 void ApplyDeclarations(FX_BOOL bPriority, 119 const IFDE_CSSDeclaration** ppDeclArray, 120 int32_t iDeclCount, 121 IFDE_CSSComputedStyle* pDestStyle); 122 void ApplyProperty(FDE_CSSPROPERTY eProperty, 123 IFDE_CSSValue* pValue, 124 CFDE_CSSComputedStyle* pComputedStyle); 125 126 FX_FLOAT ApplyNumber(FDE_CSSPRIMITIVETYPE eUnit, 127 FX_FLOAT fValue, 128 FX_FLOAT fPercentBase); 129 FX_BOOL SetLengthWithPercent(FDE_CSSLENGTH& width, 130 FDE_CSSPRIMITIVETYPE eType, 131 IFDE_CSSPrimitiveValue* pPrimitive, 132 FX_FLOAT fFontSize); 133 FX_FLOAT ToFontSize(FDE_CSSPROPERTYVALUE eValue, FX_FLOAT fCurFontSize); 134 FDE_CSSDISPLAY ToDisplay(FDE_CSSPROPERTYVALUE eValue); 135 FDE_CSSTEXTALIGN ToTextAlign(FDE_CSSPROPERTYVALUE eValue); 136 FX_WORD ToFontWeight(FDE_CSSPROPERTYVALUE eValue); 137 FDE_CSSFONTSTYLE ToFontStyle(FDE_CSSPROPERTYVALUE eValue); 138 FDE_CSSBORDERSTYLE ToBorderStyle(FDE_CSSPROPERTYVALUE eValue); 139 FDE_CSSVERTICALALIGN ToVerticalAlign(FDE_CSSPROPERTYVALUE eValue); 140 FDE_CSSLISTSTYLETYPE ToListStyleType(FDE_CSSPROPERTYVALUE eValue); 141 FDE_CSSLISTSTYLEPOSITION ToListStylePosition(FDE_CSSPROPERTYVALUE eValue); 142 FDE_CSSVISIBILITY ToVisibility(FDE_CSSPROPERTYVALUE eValue); 143 FDE_CSSWHITESPACE ToWhiteSpace(FDE_CSSPROPERTYVALUE eValue); 144 FX_DWORD ToTextDecoration(IFDE_CSSValueList* pList); 145 FDE_CSSTEXTTRANSFORM ToTextTransform(FDE_CSSPROPERTYVALUE eValue); 146 FDE_CSSFONTVARIANT ToFontVariant(FDE_CSSPROPERTYVALUE eValue); 147 FDE_CSSFLOAT ToFloat(FDE_CSSPROPERTYVALUE eValue); 148 FDE_CSSCLEAR ToClear(FDE_CSSPROPERTYVALUE eValue); 149 FDE_CSSWRITINGMODE ToWritingMode(FDE_CSSPROPERTYVALUE eValue); 150 FDE_CSSWORDBREAK ToWordBreak(FDE_CSSPROPERTYVALUE eValue); 151 FDE_CSSPAGEBREAK ToPageBreak(FDE_CSSPROPERTYVALUE eValue); 152 FDE_CSSOVERFLOW ToOverflow(FDE_CSSPROPERTYVALUE eValue); 153 FDE_CSSLINEBREAK ToLineBreak(FDE_CSSPROPERTYVALUE eValue); 154 FDE_CSSTEXTCOMBINE ToTextCombine(FDE_CSSPROPERTYVALUE eValue); 155 FX_BOOL ToTextEmphasisMark(FDE_CSSPROPERTYVALUE eValue, 156 FDE_CSSTEXTEMPHASISMARK& eMark); 157 FX_BOOL ToTextEmphasisFill(FDE_CSSPROPERTYVALUE eValue, 158 FDE_CSSTEXTEMPHASISFILL& eFill); 159 FDE_CSSCURSOR ToCursor(FDE_CSSPROPERTYVALUE eValue); 160 FDE_CSSPOSITION ToPosition(FDE_CSSPROPERTYVALUE eValue); 161 FDE_CSSCAPTIONSIDE ToCaptionSide(FDE_CSSPROPERTYVALUE eValue); 162 FDE_CSSBKGREPEAT ToBKGRepeat(FDE_CSSPROPERTYVALUE eValue); 163 FDE_CSSBKGATTACHMENT ToBKGAttachment(FDE_CSSPROPERTYVALUE eValue); 164 FDE_CSSRUBYALIGN ToRubyAlign(FDE_CSSPROPERTYVALUE eValue); 165 FDE_CSSRUBYOVERHANG ToRubyOverhang(FDE_CSSPROPERTYVALUE eValue); 166 FDE_CSSRUBYPOSITION ToRubyPosition(FDE_CSSPROPERTYVALUE eValue); 167 FDE_CSSRUBYSPAN ToRubySpan(FDE_CSSPROPERTYVALUE eValue); 168 IFX_FontMgr* m_pFontMgr; 169 FX_FLOAT m_fDefFontSize; 170 IFX_MEMAllocator* m_pRuleDataStore; 171 CFDE_CSSStyleSheetArray m_SheetGroups[FDE_CSSSTYLESHEETGROUP_MAX]; 172 CFDE_CSSRuleCollection m_RuleCollection[FDE_CSSSTYLESHEETGROUP_MAX]; 173 FDE_CSSSTYLESHEETGROUP m_ePriorities[FDE_CSSSTYLESHEETPRIORITY_MAX]; 174 IFX_MEMAllocator* m_pInlineStyleStore; 175 IFX_MEMAllocator* m_pFixedStyleStore; 176 CFDE_CSSAccelerator* m_pAccelerator; 177 CFDE_CSSRuleDataArray m_MatchedRules; 178 }; 179 typedef struct _FDE_CSSCOUNTERDATA { 180 public: 181 _FDE_CSSCOUNTERDATA() { FX_memset(this, 0, sizeof(_FDE_CSSCOUNTERDATA)); } 182 FX_BOOL GetCounterIncrement(int32_t& iValue) { 183 iValue = m_iIncVal; 184 return m_bIncrement; 185 } 186 FX_BOOL GetCounterReset(int32_t& iValue) { 187 iValue = m_iResetVal; 188 return m_bReset; 189 } 190 const FX_WCHAR* m_pszIdent; 191 FX_BOOL m_bIncrement; 192 FX_BOOL m_bReset; 193 int32_t m_iIncVal; 194 int32_t m_iResetVal; 195 } FDE_CSSCOUNTERDATA, *FDE_LPCSSCOUNTERDATA; 196 class CFDE_CSSCounterStyle { 197 public: 198 CFDE_CSSCounterStyle() : m_pCounterInc(NULL), m_pCounterReset(NULL) {} 199 void SetCounterIncrementList(IFDE_CSSValueList* pList) { 200 m_pCounterInc = pList; 201 m_bIndexDirty = TRUE; 202 } 203 void SetCounterResetList(IFDE_CSSValueList* pList) { 204 m_pCounterReset = pList; 205 m_bIndexDirty = TRUE; 206 } 207 int32_t CountCounters() { 208 UpdateIndex(); 209 return m_arrCounterData.GetSize(); 210 } 211 FX_BOOL GetCounterIncrement(int32_t index, int32_t& iValue) { 212 UpdateIndex(); 213 return m_arrCounterData.ElementAt(index).GetCounterIncrement(iValue); 214 } 215 FX_BOOL GetCounterReset(int32_t index, int32_t& iValue) { 216 UpdateIndex(); 217 return m_arrCounterData.ElementAt(index).GetCounterReset(iValue); 218 } 219 const FX_WCHAR* GetCounterIdentifier(int32_t index) { 220 UpdateIndex(); 221 return m_arrCounterData.ElementAt(index).m_pszIdent; 222 } 223 224 protected: 225 void UpdateIndex(); 226 void DoUpdateIndex(IFDE_CSSValueList* pList); 227 int32_t FindIndex(const FX_WCHAR* pszIdentifier); 228 IFDE_CSSValueList* m_pCounterInc; 229 IFDE_CSSValueList* m_pCounterReset; 230 CFX_ArrayTemplate<FDE_CSSCOUNTERDATA> m_arrCounterData; 231 FX_BOOL m_bIndexDirty; 232 }; 233 class CFDE_CSSInheritedData { 234 public: 235 void Reset() { 236 FX_memset(this, 0, sizeof(CFDE_CSSInheritedData)); 237 m_LetterSpacing.Set(FDE_CSSLENGTHUNIT_Normal); 238 m_WordSpacing.Set(FDE_CSSLENGTHUNIT_Normal); 239 m_TextIndent.Set(FDE_CSSLENGTHUNIT_Point, 0); 240 m_fFontSize = 12.0f; 241 m_fLineHeight = 14.0f; 242 m_wFontWeight = 400; 243 m_dwFontColor = 0xFF000000; 244 m_iWidows = 2; 245 m_bTextEmphasisColorCurrent = TRUE; 246 m_iOrphans = 2; 247 } 248 const FX_WCHAR* m_pszListStyleImage; 249 FDE_CSSLENGTH m_LetterSpacing; 250 FDE_CSSLENGTH m_WordSpacing; 251 FDE_CSSLENGTH m_TextIndent; 252 IFDE_CSSValueList* m_pFontFamily; 253 IFDE_CSSValueList* m_pQuotes; 254 IFDE_CSSValueList* m_pCursorUris; 255 FDE_CSSCURSOR m_eCursor; 256 FX_FLOAT m_fFontSize; 257 FX_FLOAT m_fLineHeight; 258 FX_ARGB m_dwFontColor; 259 FX_ARGB m_dwTextEmphasisColor; 260 FX_WORD m_wFontWeight; 261 int32_t m_iWidows; 262 int32_t m_iOrphans; 263 const FX_WCHAR* m_pszTextEmphasisCustomMark; 264 FX_WORD m_eFontVariant : 1; 265 FX_WORD m_eFontStyle : 1; 266 FX_WORD m_bTextEmphasisColorCurrent : 1; 267 FX_WORD m_eTextAligh : 2; 268 FX_WORD m_eVisibility : 2; 269 FX_WORD m_eWhiteSpace : 3; 270 FX_WORD m_eTextTransform : 2; 271 FX_WORD m_eWritingMode : 2; 272 FX_WORD m_eWordBreak : 2; 273 FX_WORD m_eLineBreak : 2; 274 FX_WORD m_eTextEmphasisFill : 1; 275 FX_WORD m_eTextEmphasisMark : 3; 276 FX_WORD m_eCaptionSide : 3; 277 278 FX_WORD m_eRubyAlign : 4; 279 FX_WORD m_eRubyOverhang : 2; 280 FX_WORD m_eRubyPosition : 2; 281 }; 282 class CFDE_CSSNonInheritedData { 283 public: 284 void Reset() { 285 FX_memset(this, 0, sizeof(CFDE_CSSNonInheritedData)); 286 m_MarginWidth = m_BorderWidth = 287 m_PaddingWidth.Set(FDE_CSSLENGTHUNIT_Point, 0); 288 m_MinBoxSize.Set(FDE_CSSLENGTHUNIT_Point, 0); 289 m_MaxBoxSize.Set(FDE_CSSLENGTHUNIT_None); 290 m_eDisplay = FDE_CSSDISPLAY_Inline; 291 m_fVerticalAlign = 0.0f; 292 m_ColumnCount.Set(FDE_CSSLENGTHUNIT_Auto); 293 m_ColumnGap.Set(FDE_CSSLENGTHUNIT_Normal); 294 m_bColumnRuleColorSame = TRUE; 295 m_ColumnWidth.Set(FDE_CSSLENGTHUNIT_Auto); 296 m_ColumnRuleWidth.Set(FDE_CSSLENGTHUNIT_Auto); 297 m_eTextCombine = FDE_CSSTEXTCOMBINE_None; 298 } 299 300 IFDE_CSSValueList* m_pContentList; 301 CFDE_CSSCounterStyle* m_pCounterStyle; 302 FDE_CSSRECT m_MarginWidth; 303 FDE_CSSRECT m_BorderWidth; 304 FDE_CSSRECT m_PaddingWidth; 305 FDE_CSSSIZE m_BoxSize; 306 FDE_CSSSIZE m_MinBoxSize; 307 FDE_CSSSIZE m_MaxBoxSize; 308 FDE_CSSPOINT m_BKGPosition; 309 const FX_WCHAR* m_pszBKGImage; 310 FX_ARGB m_dwBKGColor; 311 FX_ARGB m_dwBDRLeftColor; 312 FX_ARGB m_dwBDRTopColor; 313 FX_ARGB m_dwBDRRightColor; 314 FX_ARGB m_dwBDRBottomColor; 315 IFDE_CSSValue* m_pRubySpan; 316 FDE_CSSLENGTH m_ColumnCount; 317 FDE_CSSLENGTH m_ColumnGap; 318 FDE_CSSLENGTH m_ColumnRuleWidth; 319 FDE_CSSLENGTH m_ColumnWidth; 320 FX_ARGB m_dwColumnRuleColor; 321 FDE_CSSLENGTH m_Top; 322 FDE_CSSLENGTH m_Bottom; 323 FDE_CSSLENGTH m_Left; 324 FDE_CSSLENGTH m_Right; 325 326 FX_FLOAT m_fVerticalAlign; 327 FX_FLOAT m_fTextCombineNumber; 328 FX_DWORD m_eBDRLeftStyle : 4; 329 FX_DWORD m_eBDRTopStyle : 4; 330 FX_DWORD m_eBDRRightStyle : 4; 331 FX_DWORD m_eBDRBottomStyle : 4; 332 FX_DWORD m_eDisplay : 5; 333 FX_DWORD m_eVerticalAlign : 4; 334 FX_DWORD m_eListStyleType : 5; 335 FX_DWORD m_eColumnRuleStyle : 4; 336 FX_DWORD m_ePageBreakInside : 3; 337 FX_DWORD m_ePageBreakAfter : 3; 338 FX_DWORD m_ePageBreakBefore : 3; 339 FX_DWORD m_ePosition : 2; 340 FX_DWORD m_eBKGRepeat : 2; 341 FX_DWORD m_eFloat : 2; 342 FX_DWORD m_eClear : 2; 343 FX_DWORD m_eOverflowX : 3; 344 FX_DWORD m_eOverflowY : 3; 345 FX_DWORD m_eListStylePosition : 1; 346 FX_DWORD m_eBKGAttachment : 1; 347 FX_DWORD m_bHasMargin : 1; 348 FX_DWORD m_bHasBorder : 1; 349 FX_DWORD m_bHasPadding : 1; 350 FX_DWORD m_dwTextDecoration : 5; 351 FX_DWORD m_eTextCombine : 1; 352 FX_DWORD m_bColumnRuleColorSame : 1; 353 FX_DWORD m_bHasTextCombineNumber : 1; 354 }; 355 class CFDE_CSSComputedStyle : public IFDE_CSSComputedStyle, 356 public IFDE_CSSFontStyle, 357 public IFDE_CSSBoundaryStyle, 358 public IFDE_CSSPositionStyle, 359 public IFDE_CSSParagraphStyle, 360 public IFDE_CSSBackgroundStyle, 361 public IFDE_CSSVisualStyle, 362 public IFDE_CSSListStyle, 363 public IFDE_CSSMultiColumnStyle, 364 public IFDE_CSSGeneratedContentStyle, 365 public IFDE_CSSTableStyle, 366 public IFDE_CSSRubyStyle, 367 public CFX_Target { 368 public: 369 CFDE_CSSComputedStyle(IFX_MEMAllocator* pAlloc) 370 : m_dwRefCount(1), m_pAllocator(pAlloc) {} 371 ~CFDE_CSSComputedStyle() {} 372 virtual FX_DWORD AddRef() { return ++m_dwRefCount; } 373 virtual FX_DWORD Release() { 374 FX_DWORD dwRefCount = --m_dwRefCount; 375 if (dwRefCount == 0) { 376 if (m_NonInheritedData.m_pCounterStyle != NULL) { 377 delete m_NonInheritedData.m_pCounterStyle; 378 } 379 FDE_DeleteWith(CFDE_CSSComputedStyle, m_pAllocator, this); 380 } 381 return dwRefCount; 382 } 383 384 virtual void Reset() { 385 m_InheritedData.Reset(); 386 m_NonInheritedData.Reset(); 387 } 388 virtual IFDE_CSSFontStyle* GetFontStyles() const { 389 return (IFDE_CSSFontStyle * const) this; 390 } 391 virtual IFDE_CSSBoundaryStyle* GetBoundaryStyles() const { 392 return (IFDE_CSSBoundaryStyle * const) this; 393 } 394 virtual IFDE_CSSPositionStyle* GetPositionStyles() const { 395 return (IFDE_CSSPositionStyle * const) this; 396 } 397 virtual IFDE_CSSParagraphStyle* GetParagraphStyles() const { 398 return (IFDE_CSSParagraphStyle * const) this; 399 } 400 virtual IFDE_CSSBackgroundStyle* GetBackgroundStyles() const { 401 return (IFDE_CSSBackgroundStyle * const) this; 402 } 403 virtual IFDE_CSSVisualStyle* GetVisualStyles() const { 404 return (IFDE_CSSVisualStyle * const) this; 405 } 406 virtual IFDE_CSSListStyle* GetListStyles() const { 407 return (IFDE_CSSListStyle * const) this; 408 } 409 virtual IFDE_CSSTableStyle* GetTableStyle() const { 410 return (IFDE_CSSTableStyle * const) this; 411 } 412 virtual IFDE_CSSMultiColumnStyle* GetMultiColumnStyle() const { 413 return (IFDE_CSSMultiColumnStyle * const) this; 414 } 415 virtual IFDE_CSSGeneratedContentStyle* GetGeneratedContentStyle() const { 416 return (IFDE_CSSGeneratedContentStyle * const) this; 417 } 418 virtual IFDE_CSSRubyStyle* GetRubyStyle() const { 419 return (IFDE_CSSRubyStyle * const) this; 420 } 421 virtual FX_BOOL GetCustomStyle(const CFX_WideStringC& wsName, 422 CFX_WideString& wsValue) const { 423 for (int32_t i = m_CustomProperties.GetSize() - 2; i > -1; i -= 2) { 424 if (wsName == m_CustomProperties[i]) { 425 wsValue = m_CustomProperties[i + 1]; 426 return TRUE; 427 } 428 } 429 return FALSE; 430 } 431 virtual FDE_CSSRUBYALIGN GetRubyAlign() const { 432 return (FDE_CSSRUBYALIGN)m_InheritedData.m_eRubyAlign; 433 } 434 virtual FDE_CSSRUBYPOSITION GetRubyPosition() const { 435 return (FDE_CSSRUBYPOSITION)m_InheritedData.m_eRubyPosition; 436 } 437 virtual FDE_CSSRUBYOVERHANG GetRubyOverhang() const { 438 return (FDE_CSSRUBYOVERHANG)m_InheritedData.m_eRubyOverhang; 439 } 440 virtual FDE_CSSRUBYSPAN GetRubySpanType() const { 441 return m_NonInheritedData.m_pRubySpan == NULL ? FDE_CSSRUBYSPAN_None 442 : FDE_CSSRUBYSPAN_Attr; 443 } 444 virtual IFDE_CSSValue* GetRubySpanAttr() const { 445 return m_NonInheritedData.m_pRubySpan; 446 } 447 virtual FDE_CSSCAPTIONSIDE GetCaptionSide() const { 448 return (FDE_CSSCAPTIONSIDE)m_InheritedData.m_eCaptionSide; 449 } 450 virtual int32_t CountCounters() { 451 return (m_NonInheritedData.m_pCounterStyle == NULL) 452 ? 0 453 : m_NonInheritedData.m_pCounterStyle->CountCounters(); 454 } 455 virtual const FX_WCHAR* GetCounterIdentifier(int32_t index) { 456 return m_NonInheritedData.m_pCounterStyle->GetCounterIdentifier(index); 457 } 458 virtual FX_BOOL GetCounterReset(int32_t index, int32_t& iValue) { 459 return m_NonInheritedData.m_pCounterStyle->GetCounterReset(index, iValue); 460 } 461 virtual FX_BOOL GetCounterIncrement(int32_t index, int32_t& iValue) { 462 return m_NonInheritedData.m_pCounterStyle->GetCounterIncrement(index, 463 iValue); 464 } 465 virtual IFDE_CSSValueList* GetContent() const { 466 return m_NonInheritedData.m_pContentList; 467 } 468 virtual int32_t CountQuotes() const { 469 return m_InheritedData.m_pQuotes == NULL 470 ? 0 471 : m_InheritedData.m_pQuotes->CountValues(); 472 } 473 virtual const FX_WCHAR* GetQuotes(int32_t index) const { 474 FXSYS_assert(m_InheritedData.m_pQuotes != NULL && 475 m_InheritedData.m_pQuotes->CountValues() > index); 476 return ((IFDE_CSSPrimitiveValue*)(m_InheritedData.m_pQuotes->GetValue( 477 index))) 478 ->GetString(index); 479 } 480 virtual const FDE_CSSLENGTH& GetColumnCount() const { 481 return m_NonInheritedData.m_ColumnCount; 482 } 483 virtual const FDE_CSSLENGTH& GetColumnGap() const { 484 return m_NonInheritedData.m_ColumnGap; 485 } 486 virtual FX_ARGB GetColumnRuleColor() const { 487 return m_NonInheritedData.m_bColumnRuleColorSame 488 ? m_InheritedData.m_dwFontColor 489 : m_NonInheritedData.m_dwColumnRuleColor; 490 } 491 virtual FDE_CSSBORDERSTYLE GetColumnRuleStyle() const { 492 return (FDE_CSSBORDERSTYLE)m_NonInheritedData.m_eColumnRuleStyle; 493 } 494 virtual const FDE_CSSLENGTH& GetColumnRuleWidth() const { 495 return m_NonInheritedData.m_ColumnRuleWidth; 496 } 497 virtual const FDE_CSSLENGTH& GetColumnWidth() const { 498 return m_NonInheritedData.m_ColumnWidth; 499 } 500 virtual void SetColumnCount(const FDE_CSSLENGTH& columnCount) { 501 m_NonInheritedData.m_ColumnCount = columnCount; 502 } 503 virtual void SetColumnGap(const FDE_CSSLENGTH& columnGap) { 504 m_NonInheritedData.m_ColumnGap = columnGap; 505 } 506 virtual void SetColumnRuleColor(FX_ARGB dwColumnRuleColor) { 507 m_NonInheritedData.m_dwColumnRuleColor = dwColumnRuleColor, 508 m_NonInheritedData.m_bColumnRuleColorSame = FALSE; 509 } 510 virtual void SetColumnRuleStyle(FDE_CSSBORDERSTYLE eColumnRuleStyle) { 511 m_NonInheritedData.m_eColumnRuleStyle = eColumnRuleStyle; 512 } 513 virtual void SetColumnRuleWidth(const FDE_CSSLENGTH& columnRuleWidth) { 514 m_NonInheritedData.m_ColumnRuleWidth = columnRuleWidth; 515 } 516 virtual void SetColumnWidth(const FDE_CSSLENGTH& columnWidth) { 517 m_NonInheritedData.m_ColumnWidth = columnWidth; 518 } 519 virtual int32_t CountFontFamilies() const { 520 return m_InheritedData.m_pFontFamily 521 ? m_InheritedData.m_pFontFamily->CountValues() 522 : 0; 523 } 524 virtual const FX_WCHAR* GetFontFamily(int32_t index) const { 525 return ((IFDE_CSSPrimitiveValue*)(m_InheritedData.m_pFontFamily->GetValue( 526 index))) 527 ->GetString(index); 528 } 529 virtual FX_WORD GetFontWeight() const { 530 return m_InheritedData.m_wFontWeight; 531 } 532 virtual FDE_CSSFONTVARIANT GetFontVariant() const { 533 return (FDE_CSSFONTVARIANT)m_InheritedData.m_eFontVariant; 534 } 535 virtual FDE_CSSFONTSTYLE GetFontStyle() const { 536 return (FDE_CSSFONTSTYLE)m_InheritedData.m_eFontStyle; 537 } 538 virtual FX_FLOAT GetFontSize() const { return m_InheritedData.m_fFontSize; } 539 virtual FX_ARGB GetColor() const { return m_InheritedData.m_dwFontColor; } 540 virtual void SetFontWeight(FX_WORD wFontWeight) { 541 m_InheritedData.m_wFontWeight = wFontWeight; 542 } 543 virtual void SetFontVariant(FDE_CSSFONTVARIANT eFontVariant) { 544 m_InheritedData.m_eFontVariant = eFontVariant; 545 } 546 virtual void SetFontStyle(FDE_CSSFONTSTYLE eFontStyle) { 547 m_InheritedData.m_eFontStyle = eFontStyle; 548 } 549 virtual void SetFontSize(FX_FLOAT fFontSize) { 550 m_InheritedData.m_fFontSize = fFontSize; 551 } 552 virtual void SetColor(FX_ARGB dwFontColor) { 553 m_InheritedData.m_dwFontColor = dwFontColor; 554 } 555 virtual FX_ARGB GetBorderLeftColor() const { 556 return m_NonInheritedData.m_dwBDRLeftColor; 557 } 558 virtual FX_ARGB GetBorderTopColor() const { 559 return m_NonInheritedData.m_dwBDRTopColor; 560 } 561 virtual FX_ARGB GetBorderRightColor() const { 562 return m_NonInheritedData.m_dwBDRRightColor; 563 } 564 virtual FX_ARGB GetBorderBottomColor() const { 565 return m_NonInheritedData.m_dwBDRBottomColor; 566 } 567 568 virtual FDE_CSSBORDERSTYLE GetBorderLeftStyle() const { 569 return (FDE_CSSBORDERSTYLE)m_NonInheritedData.m_eBDRLeftStyle; 570 } 571 virtual FDE_CSSBORDERSTYLE GetBorderTopStyle() const { 572 return (FDE_CSSBORDERSTYLE)m_NonInheritedData.m_eBDRTopStyle; 573 } 574 virtual FDE_CSSBORDERSTYLE GetBorderRightStyle() const { 575 return (FDE_CSSBORDERSTYLE)m_NonInheritedData.m_eBDRRightStyle; 576 } 577 virtual FDE_CSSBORDERSTYLE GetBorderBottomStyle() const { 578 return (FDE_CSSBORDERSTYLE)m_NonInheritedData.m_eBDRBottomStyle; 579 } 580 581 virtual const FDE_CSSRECT* GetBorderWidth() const { 582 return m_NonInheritedData.m_bHasBorder ? &(m_NonInheritedData.m_BorderWidth) 583 : NULL; 584 } 585 virtual const FDE_CSSRECT* GetMarginWidth() const { 586 return m_NonInheritedData.m_bHasMargin ? &(m_NonInheritedData.m_MarginWidth) 587 : NULL; 588 } 589 virtual const FDE_CSSRECT* GetPaddingWidth() const { 590 return m_NonInheritedData.m_bHasPadding 591 ? &(m_NonInheritedData.m_PaddingWidth) 592 : NULL; 593 } 594 virtual void SetBorderLeftColor(FX_ARGB dwBorderColor) { 595 m_NonInheritedData.m_dwBDRLeftColor = dwBorderColor; 596 } 597 virtual void SetBorderTopColor(FX_ARGB dwBorderColor) { 598 m_NonInheritedData.m_dwBDRTopColor = dwBorderColor; 599 } 600 virtual void SetBorderRightColor(FX_ARGB dwBorderColor) { 601 m_NonInheritedData.m_dwBDRRightColor = dwBorderColor; 602 } 603 virtual void SetBorderBottomColor(FX_ARGB dwBorderColor) { 604 m_NonInheritedData.m_dwBDRBottomColor = dwBorderColor; 605 } 606 607 virtual void SetBorderLeftStyle(FDE_CSSBORDERSTYLE eBorderStyle) { 608 m_NonInheritedData.m_eBDRLeftStyle = eBorderStyle; 609 } 610 virtual void SetBorderTopStyle(FDE_CSSBORDERSTYLE eBorderStyle) { 611 m_NonInheritedData.m_eBDRTopStyle = eBorderStyle; 612 } 613 virtual void SetBorderRightStyle(FDE_CSSBORDERSTYLE eBorderStyle) { 614 m_NonInheritedData.m_eBDRRightStyle = eBorderStyle; 615 } 616 virtual void SetBorderBottomStyle(FDE_CSSBORDERSTYLE eBorderStyle) { 617 m_NonInheritedData.m_eBDRBottomStyle = eBorderStyle; 618 } 619 620 virtual void SetBorderWidth(const FDE_CSSRECT& rect) { 621 m_NonInheritedData.m_BorderWidth = rect; 622 m_NonInheritedData.m_bHasBorder = TRUE; 623 } 624 virtual void SetMarginWidth(const FDE_CSSRECT& rect) { 625 m_NonInheritedData.m_MarginWidth = rect; 626 m_NonInheritedData.m_bHasMargin = TRUE; 627 } 628 virtual void SetPaddingWidth(const FDE_CSSRECT& rect) { 629 m_NonInheritedData.m_PaddingWidth = rect; 630 m_NonInheritedData.m_bHasPadding = TRUE; 631 } 632 virtual FDE_CSSDISPLAY GetDisplay() const { 633 return (FDE_CSSDISPLAY)m_NonInheritedData.m_eDisplay; 634 } 635 virtual const FDE_CSSSIZE& GetBoxSize() const { 636 return m_NonInheritedData.m_BoxSize; 637 } 638 virtual const FDE_CSSSIZE& GetMinBoxSize() const { 639 return m_NonInheritedData.m_MinBoxSize; 640 } 641 virtual const FDE_CSSSIZE& GetMaxBoxSize() const { 642 return m_NonInheritedData.m_MaxBoxSize; 643 } 644 virtual FDE_CSSFLOAT GetFloat() const { 645 return (FDE_CSSFLOAT)m_NonInheritedData.m_eFloat; 646 } 647 virtual FDE_CSSCLEAR GetClear() const { 648 return (FDE_CSSCLEAR)m_NonInheritedData.m_eClear; 649 } 650 virtual FDE_CSSPOSITION GetPosition() const { 651 return (FDE_CSSPOSITION)m_NonInheritedData.m_ePosition; 652 } 653 virtual FDE_CSSLENGTH GetTop() const { return m_NonInheritedData.m_Top; } 654 virtual FDE_CSSLENGTH GetBottom() const { 655 return m_NonInheritedData.m_Bottom; 656 } 657 virtual FDE_CSSLENGTH GetLeft() const { return m_NonInheritedData.m_Left; } 658 virtual FDE_CSSLENGTH GetRight() const { return m_NonInheritedData.m_Right; } 659 660 virtual void SetDisplay(FDE_CSSDISPLAY eDisplay) { 661 m_NonInheritedData.m_eDisplay = eDisplay; 662 } 663 virtual void SetBoxSize(const FDE_CSSSIZE& size) { 664 m_NonInheritedData.m_BoxSize = size; 665 } 666 virtual void SetMinBoxSize(const FDE_CSSSIZE& size) { 667 m_NonInheritedData.m_MinBoxSize = size; 668 } 669 virtual void SetMaxBoxSize(const FDE_CSSSIZE& size) { 670 m_NonInheritedData.m_MaxBoxSize = size; 671 } 672 virtual void SetFloat(FDE_CSSFLOAT eFloat) { 673 m_NonInheritedData.m_eFloat = eFloat; 674 } 675 virtual void SetClear(FDE_CSSCLEAR eClear) { 676 m_NonInheritedData.m_eClear = eClear; 677 } 678 virtual FX_FLOAT GetLineHeight() const { 679 return m_InheritedData.m_fLineHeight; 680 } 681 virtual FDE_CSSWHITESPACE GetWhiteSpace() const { 682 return (FDE_CSSWHITESPACE)m_InheritedData.m_eWhiteSpace; 683 } 684 virtual const FDE_CSSLENGTH& GetTextIndent() const { 685 return m_InheritedData.m_TextIndent; 686 } 687 virtual FDE_CSSTEXTALIGN GetTextAlign() const { 688 return (FDE_CSSTEXTALIGN)m_InheritedData.m_eTextAligh; 689 } 690 virtual FDE_CSSVERTICALALIGN GetVerticalAlign() const { 691 return (FDE_CSSVERTICALALIGN)m_NonInheritedData.m_eVerticalAlign; 692 } 693 virtual FX_FLOAT GetNumberVerticalAlign() const { 694 return m_NonInheritedData.m_fVerticalAlign; 695 } 696 virtual FDE_CSSTEXTTRANSFORM GetTextTransform() const { 697 return (FDE_CSSTEXTTRANSFORM)m_InheritedData.m_eTextTransform; 698 } 699 virtual FX_DWORD GetTextDecoration() const { 700 return m_NonInheritedData.m_dwTextDecoration; 701 } 702 virtual const FDE_CSSLENGTH& GetLetterSpacing() const { 703 return m_InheritedData.m_LetterSpacing; 704 } 705 virtual const FDE_CSSLENGTH& GetWordSpacing() const { 706 return m_InheritedData.m_WordSpacing; 707 } 708 virtual FDE_CSSWRITINGMODE GetWritingMode() const { 709 return (FDE_CSSWRITINGMODE)m_InheritedData.m_eWritingMode; 710 } 711 virtual FDE_CSSWORDBREAK GetWordBreak() const { 712 return (FDE_CSSWORDBREAK)m_InheritedData.m_eWordBreak; 713 } 714 virtual int32_t GetWidows() const { return m_InheritedData.m_iWidows; } 715 virtual FX_ARGB GetTextEmphasisColor() const { 716 return m_InheritedData.m_bTextEmphasisColorCurrent 717 ? m_InheritedData.m_dwFontColor 718 : m_InheritedData.m_dwTextEmphasisColor; 719 } 720 virtual FDE_CSSPAGEBREAK GetPageBreakBefore() const { 721 return (FDE_CSSPAGEBREAK)m_NonInheritedData.m_ePageBreakBefore; 722 } 723 virtual FDE_CSSPAGEBREAK GetPageBreakAfter() const { 724 return (FDE_CSSPAGEBREAK)m_NonInheritedData.m_ePageBreakAfter; 725 } 726 virtual FDE_CSSPAGEBREAK GetPageBreakInside() const { 727 return (FDE_CSSPAGEBREAK)m_NonInheritedData.m_ePageBreakInside; 728 } 729 virtual int32_t GetOrphans() const { return m_InheritedData.m_iOrphans; } 730 virtual FDE_CSSLINEBREAK GetLineBreak() const { 731 return (FDE_CSSLINEBREAK)m_InheritedData.m_eLineBreak; 732 } 733 virtual FDE_CSSTEXTEMPHASISMARK GetTextEmphasisMark() const; 734 virtual FDE_CSSTEXTEMPHASISFILL GetTextEmphasisFill() const { 735 return (FDE_CSSTEXTEMPHASISFILL)m_InheritedData.m_eTextEmphasisFill; 736 } 737 virtual const FX_WCHAR* GetTextEmphasisCustom() const { 738 FXSYS_assert(m_InheritedData.m_eTextEmphasisMark == 739 FDE_CSSTEXTEMPHASISMARK_Custom); 740 return m_InheritedData.m_pszTextEmphasisCustomMark; 741 } 742 virtual FDE_CSSTEXTCOMBINE GetTextCombineType() const { 743 return (FDE_CSSTEXTCOMBINE)m_NonInheritedData.m_eTextCombine; 744 } 745 virtual FX_BOOL HasTextCombineNumber() const { 746 return m_NonInheritedData.m_bHasTextCombineNumber; 747 } 748 virtual FX_FLOAT GetTextCombineNumber() const { 749 FXSYS_assert(m_NonInheritedData.m_eTextCombine == 750 FDE_CSSTEXTCOMBINE_Horizontal); 751 return m_NonInheritedData.m_fTextCombineNumber; 752 } 753 virtual void SetLineHeight(FX_FLOAT fLineHeight) { 754 m_InheritedData.m_fLineHeight = fLineHeight; 755 } 756 virtual void SetWhiteSpace(FDE_CSSWHITESPACE eWhiteSpace) { 757 m_InheritedData.m_eWhiteSpace = eWhiteSpace; 758 } 759 virtual void SetTextIndent(const FDE_CSSLENGTH& textIndent) { 760 m_InheritedData.m_TextIndent = textIndent; 761 } 762 virtual void SetTextAlign(FDE_CSSTEXTALIGN eTextAlign) { 763 m_InheritedData.m_eTextAligh = eTextAlign; 764 } 765 virtual void SetVerticalAlign(FDE_CSSVERTICALALIGN eVerticalAlign) { 766 m_NonInheritedData.m_eVerticalAlign = eVerticalAlign; 767 } 768 virtual void SetNumberVerticalAlign(FX_FLOAT fAlign) { 769 m_NonInheritedData.m_eVerticalAlign = FDE_CSSVERTICALALIGN_Number, 770 m_NonInheritedData.m_fVerticalAlign = fAlign; 771 } 772 virtual void SetTextTransform(FDE_CSSTEXTTRANSFORM eTextTransform) { 773 m_InheritedData.m_eTextTransform = eTextTransform; 774 } 775 virtual void SetTextDecoration(FX_DWORD dwTextDecoration) { 776 m_NonInheritedData.m_dwTextDecoration = dwTextDecoration; 777 } 778 virtual void SetLetterSpacing(const FDE_CSSLENGTH& letterSpacing) { 779 m_InheritedData.m_LetterSpacing = letterSpacing; 780 } 781 virtual void SetWordSpacing(const FDE_CSSLENGTH& wordSpacing) { 782 m_InheritedData.m_WordSpacing = wordSpacing; 783 } 784 virtual void SetWritingMode(FDE_CSSWRITINGMODE eWritingMode) { 785 m_InheritedData.m_eWritingMode = eWritingMode; 786 } 787 virtual void SetWordBreak(FDE_CSSWORDBREAK eWordBreak) { 788 m_InheritedData.m_eWordBreak = eWordBreak; 789 } 790 virtual void SetWidows(int32_t iWidows) { 791 m_InheritedData.m_iWidows = iWidows; 792 } 793 virtual void SetTextEmphasisColor(FX_ARGB dwTextEmphasisColor) { 794 m_InheritedData.m_dwTextEmphasisColor = dwTextEmphasisColor, 795 m_InheritedData.m_bTextEmphasisColorCurrent = FALSE; 796 } 797 virtual void SetPageBreakBefore(FDE_CSSPAGEBREAK ePageBreakBefore) { 798 m_NonInheritedData.m_ePageBreakBefore = ePageBreakBefore; 799 } 800 virtual void SetPageBreakAfter(FDE_CSSPAGEBREAK ePageBreakAfter) { 801 m_NonInheritedData.m_ePageBreakAfter = ePageBreakAfter; 802 } 803 virtual void SetPageBreakInside(FDE_CSSPAGEBREAK ePageBreakInside) { 804 m_NonInheritedData.m_ePageBreakInside = ePageBreakInside; 805 } 806 virtual void SetOrphans(int32_t iOrphans) { 807 m_InheritedData.m_iOrphans = iOrphans; 808 } 809 virtual void SetLineBreak(FDE_CSSLINEBREAK eLineBreak) { 810 m_InheritedData.m_eLineBreak = eLineBreak; 811 } 812 virtual FX_ARGB GetBKGColor() const { 813 return m_NonInheritedData.m_dwBKGColor; 814 } 815 virtual const FX_WCHAR* GetBKGImage() const { 816 return m_NonInheritedData.m_pszBKGImage; 817 } 818 virtual const FDE_CSSPOINT& GetBKGPosition() const { 819 return m_NonInheritedData.m_BKGPosition; 820 } 821 virtual FDE_CSSBKGREPEAT GetBKGRepeat() const { 822 return (FDE_CSSBKGREPEAT)m_NonInheritedData.m_eBKGRepeat; 823 } 824 virtual FDE_CSSBKGATTACHMENT GetBKGAttachment() const { 825 return (FDE_CSSBKGATTACHMENT)m_NonInheritedData.m_eBKGAttachment; 826 } 827 virtual void SetBKGColor(FX_ARGB dwBKGColor) { 828 m_NonInheritedData.m_dwBKGColor = dwBKGColor; 829 } 830 virtual void SetBKGPosition(const FDE_CSSPOINT& bkgPosition) { 831 m_NonInheritedData.m_BKGPosition = bkgPosition; 832 } 833 virtual FDE_CSSVISIBILITY GetVisibility() const { 834 return (FDE_CSSVISIBILITY)m_InheritedData.m_eVisibility; 835 } 836 virtual FDE_CSSOVERFLOW GetOverflowX() const { 837 return (FDE_CSSOVERFLOW)m_NonInheritedData.m_eOverflowX; 838 } 839 virtual FDE_CSSOVERFLOW GetOverflowY() const { 840 return (FDE_CSSOVERFLOW)m_NonInheritedData.m_eOverflowY; 841 } 842 virtual int32_t CountCursorUrls() const { 843 return m_InheritedData.m_pCursorUris == NULL 844 ? 0 845 : m_InheritedData.m_pCursorUris->CountValues(); 846 } 847 virtual const FX_WCHAR* GetCursorUrl(int32_t index) const { 848 FXSYS_assert(m_InheritedData.m_pCursorUris != NULL); 849 return ((IFDE_CSSPrimitiveValue*)(m_InheritedData.m_pCursorUris->GetValue( 850 index))) 851 ->GetString(index); 852 } 853 virtual FDE_CSSCURSOR GetCursorType() const { 854 return m_InheritedData.m_eCursor; 855 } 856 virtual void SetVisibility(FDE_CSSVISIBILITY eVisibility) { 857 m_InheritedData.m_eVisibility = eVisibility; 858 } 859 virtual FDE_CSSLISTSTYLETYPE GetListStyleType() const { 860 return (FDE_CSSLISTSTYLETYPE)m_NonInheritedData.m_eListStyleType; 861 } 862 virtual FDE_CSSLISTSTYLEPOSITION GetListStylePosition() const { 863 return (FDE_CSSLISTSTYLEPOSITION)m_NonInheritedData.m_eListStylePosition; 864 } 865 virtual const FX_WCHAR* GetListStyleImage() const { 866 return m_InheritedData.m_pszListStyleImage; 867 } 868 virtual void SetListStyleType(FDE_CSSLISTSTYLETYPE eListStyleType) { 869 m_NonInheritedData.m_eListStyleType = eListStyleType; 870 } 871 virtual void SetListStylePosition( 872 FDE_CSSLISTSTYLEPOSITION eListStylePosition) { 873 m_NonInheritedData.m_eListStylePosition = eListStylePosition; 874 } 875 void AddCustomStyle(const CFX_WideString& wsName, 876 const CFX_WideString& wsValue) { 877 m_CustomProperties.Add(wsName); 878 m_CustomProperties.Add(wsValue); 879 } 880 FX_DWORD m_dwRefCount; 881 IFX_MEMAllocator* m_pAllocator; 882 CFDE_CSSInheritedData m_InheritedData; 883 CFDE_CSSNonInheritedData m_NonInheritedData; 884 CFX_WideStringArray m_CustomProperties; 885 }; 886 #endif 887