summaryrefslogtreecommitdiff
path: root/xfa/src/fde/css
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2016-03-14 14:14:16 -0400
committerDan Sinclair <dsinclair@chromium.org>2016-03-14 14:14:16 -0400
commit1770c021cf998ff1b33855b1397f6ea8ff9f7cd7 (patch)
tree285e39abd4b5872d8cd632b9e331b0667fdc3eae /xfa/src/fde/css
parentf766ad219f66543654520f6a1955836f519e26d1 (diff)
downloadpdfium-1770c021cf998ff1b33855b1397f6ea8ff9f7cd7.tar.xz
Move xfa/src up to xfa/.
This CL moves the xfa/src files up to the xfa/ directory and fixes the includes, include guards, and build files. R=tsepez@chromium.org Review URL: https://codereview.chromium.org/1803723002 .
Diffstat (limited to 'xfa/src/fde/css')
-rw-r--r--xfa/src/fde/css/fde_css.h1082
-rw-r--r--xfa/src/fde/css/fde_csscache.cpp149
-rw-r--r--xfa/src/fde/css/fde_csscache.h85
-rw-r--r--xfa/src/fde/css/fde_cssdatatable.cpp889
-rw-r--r--xfa/src/fde/css/fde_cssdatatable.h200
-rw-r--r--xfa/src/fde/css/fde_cssdeclaration.cpp1377
-rw-r--r--xfa/src/fde/css/fde_cssdeclaration.h158
-rw-r--r--xfa/src/fde/css/fde_cssstyleselector.cpp1794
-rw-r--r--xfa/src/fde/css/fde_cssstyleselector.h901
-rw-r--r--xfa/src/fde/css/fde_cssstylesheet.cpp509
-rw-r--r--xfa/src/fde/css/fde_cssstylesheet.h141
-rw-r--r--xfa/src/fde/css/fde_csssyntax.cpp487
-rw-r--r--xfa/src/fde/css/fde_csssyntax.h119
13 files changed, 0 insertions, 7891 deletions
diff --git a/xfa/src/fde/css/fde_css.h b/xfa/src/fde/css/fde_css.h
deleted file mode 100644
index 1e62b66c9a..0000000000
--- a/xfa/src/fde/css/fde_css.h
+++ /dev/null
@@ -1,1082 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifndef XFA_SRC_FDE_CSS_FDE_CSS_H_
-#define XFA_SRC_FDE_CSS_FDE_CSS_H_
-
-#include "core/include/fxge/fx_dib.h"
-#include "xfa/src/fgas/font/fgas_font.h"
-#include "xfa/src/fgas/crt/fgas_stream.h"
-#include "xfa/src/fgas/crt/fgas_utils.h"
-
-class IFDE_CSSValue;
-class IFDE_CSSValueList;
-class IFDE_CSSDeclaration;
-class IFDE_CSSSelector;
-class IFDE_CSSRule;
-class IFDE_CSSStyleSheet;
-class IFDE_CSSStyleSheetCache;
-class IFDE_CSSSyntaxParser;
-class IFDE_CSSRubyStyle;
-class IFDE_CSSMultiColumnStyle;
-class IFDE_CSSGeneratedContentStyle;
-class IFDE_CSSFontStyle;
-class IFDE_CSSBoundaryStyle;
-class IFDE_CSSPositionStyle;
-class IFDE_CSSParagraphStyle;
-class IFDE_CSSBackgroundStyle;
-class IFDE_CSSListStyle;
-class IFDE_CSSTableStyle;
-class IFDE_CSSVisualStyle;
-class IFDE_CSSComputedStyle;
-class IFDE_CSSTagProvider;
-class IFDE_CSSAccelerator;
-class IFDE_CSSStyleSelector;
-
-enum FDE_CSSVALUETYPE {
- FDE_CSSVALUETYPE_Primitive = 1,
- FDE_CSSVALUETYPE_List = 2,
- FDE_CSSVALUETYPE_Shorthand,
-};
-enum FDE_CSSPRIMITIVETYPE {
- FDE_CSSPRIMITIVETYPE_Unknown = 0,
- FDE_CSSPRIMITIVETYPE_Number = 1,
- FDE_CSSPRIMITIVETYPE_Percent = 2,
- FDE_CSSPRIMITIVETYPE_EMS = 3,
- FDE_CSSPRIMITIVETYPE_EXS = 4,
- FDE_CSSPRIMITIVETYPE_PX = 5,
- FDE_CSSPRIMITIVETYPE_CM = 6,
- FDE_CSSPRIMITIVETYPE_MM = 7,
- FDE_CSSPRIMITIVETYPE_IN = 8,
- FDE_CSSPRIMITIVETYPE_PT = 9,
- FDE_CSSPRIMITIVETYPE_PC = 10,
- FDE_CSSPRIMITIVETYPE_String = 19,
- FDE_CSSPRIMITIVETYPE_URI = 20,
- FDE_CSSPRIMITIVETYPE_RGB = 25,
- FDE_CSSPRIMITIVETYPE_Enum,
- FDE_CSSPRIMITIVETYPE_Function,
-};
-enum FDE_CSSPROPERTYVALUE {
- FDE_CSSPROPERTYVALUE_Bolder,
- FDE_CSSPROPERTYVALUE_LowerLatin,
- FDE_CSSPROPERTYVALUE_Lowercase,
- FDE_CSSPROPERTYVALUE_LowerGreek,
- FDE_CSSPROPERTYVALUE_Sesame,
- FDE_CSSPROPERTYVALUE_None,
- FDE_CSSPROPERTYVALUE_NwResize,
- FDE_CSSPROPERTYVALUE_WResize,
- FDE_CSSPROPERTYVALUE_Dot,
- FDE_CSSPROPERTYVALUE_End,
- FDE_CSSPROPERTYVALUE_Ltr,
- FDE_CSSPROPERTYVALUE_Pre,
- FDE_CSSPROPERTYVALUE_Rtl,
- FDE_CSSPROPERTYVALUE_Sub,
- FDE_CSSPROPERTYVALUE_Top,
- FDE_CSSPROPERTYVALUE_Visible,
- FDE_CSSPROPERTYVALUE_Filled,
- FDE_CSSPROPERTYVALUE_SwResize,
- FDE_CSSPROPERTYVALUE_NoRepeat,
- FDE_CSSPROPERTYVALUE_Default,
- FDE_CSSPROPERTYVALUE_Transparent,
- FDE_CSSPROPERTYVALUE_Ridge,
- FDE_CSSPROPERTYVALUE_Right,
- FDE_CSSPROPERTYVALUE_HorizontalTb,
- FDE_CSSPROPERTYVALUE_DistributeLetter,
- FDE_CSSPROPERTYVALUE_DoubleCircle,
- FDE_CSSPROPERTYVALUE_Ruby,
- FDE_CSSPROPERTYVALUE_Collapse,
- FDE_CSSPROPERTYVALUE_Normal,
- FDE_CSSPROPERTYVALUE_Avoid,
- FDE_CSSPROPERTYVALUE_UpperRoman,
- FDE_CSSPROPERTYVALUE_Auto,
- FDE_CSSPROPERTYVALUE_Text,
- FDE_CSSPROPERTYVALUE_XSmall,
- FDE_CSSPROPERTYVALUE_Thin,
- FDE_CSSPROPERTYVALUE_Repeat,
- FDE_CSSPROPERTYVALUE_Small,
- FDE_CSSPROPERTYVALUE_NeResize,
- FDE_CSSPROPERTYVALUE_NoContent,
- FDE_CSSPROPERTYVALUE_Outside,
- FDE_CSSPROPERTYVALUE_EResize,
- FDE_CSSPROPERTYVALUE_TableRow,
- FDE_CSSPROPERTYVALUE_Bottom,
- FDE_CSSPROPERTYVALUE_Underline,
- FDE_CSSPROPERTYVALUE_CjkIdeographic,
- FDE_CSSPROPERTYVALUE_SeResize,
- FDE_CSSPROPERTYVALUE_Fixed,
- FDE_CSSPROPERTYVALUE_Double,
- FDE_CSSPROPERTYVALUE_Solid,
- FDE_CSSPROPERTYVALUE_RubyBaseGroup,
- FDE_CSSPROPERTYVALUE_OpenQuote,
- FDE_CSSPROPERTYVALUE_Lighter,
- FDE_CSSPROPERTYVALUE_LowerRoman,
- FDE_CSSPROPERTYVALUE_Strict,
- FDE_CSSPROPERTYVALUE_TableCaption,
- FDE_CSSPROPERTYVALUE_Oblique,
- FDE_CSSPROPERTYVALUE_Decimal,
- FDE_CSSPROPERTYVALUE_Loose,
- FDE_CSSPROPERTYVALUE_Hebrew,
- FDE_CSSPROPERTYVALUE_Hidden,
- FDE_CSSPROPERTYVALUE_Dashed,
- FDE_CSSPROPERTYVALUE_Embed,
- FDE_CSSPROPERTYVALUE_TableRowGroup,
- FDE_CSSPROPERTYVALUE_TableColumn,
- FDE_CSSPROPERTYVALUE_Static,
- FDE_CSSPROPERTYVALUE_Outset,
- FDE_CSSPROPERTYVALUE_DecimalLeadingZero,
- FDE_CSSPROPERTYVALUE_KeepWords,
- FDE_CSSPROPERTYVALUE_KatakanaIroha,
- FDE_CSSPROPERTYVALUE_Super,
- FDE_CSSPROPERTYVALUE_Center,
- FDE_CSSPROPERTYVALUE_TableHeaderGroup,
- FDE_CSSPROPERTYVALUE_Inside,
- FDE_CSSPROPERTYVALUE_XxLarge,
- FDE_CSSPROPERTYVALUE_Triangle,
- FDE_CSSPROPERTYVALUE_RubyTextGroup,
- FDE_CSSPROPERTYVALUE_Circle,
- FDE_CSSPROPERTYVALUE_Hiragana,
- FDE_CSSPROPERTYVALUE_RepeatX,
- FDE_CSSPROPERTYVALUE_RepeatY,
- FDE_CSSPROPERTYVALUE_Move,
- FDE_CSSPROPERTYVALUE_HiraganaIroha,
- FDE_CSSPROPERTYVALUE_RubyBase,
- FDE_CSSPROPERTYVALUE_Scroll,
- FDE_CSSPROPERTYVALUE_Smaller,
- FDE_CSSPROPERTYVALUE_TableFooterGroup,
- FDE_CSSPROPERTYVALUE_Baseline,
- FDE_CSSPROPERTYVALUE_Separate,
- FDE_CSSPROPERTYVALUE_Armenian,
- FDE_CSSPROPERTYVALUE_Open,
- FDE_CSSPROPERTYVALUE_Relative,
- FDE_CSSPROPERTYVALUE_Thick,
- FDE_CSSPROPERTYVALUE_Justify,
- FDE_CSSPROPERTYVALUE_Middle,
- FDE_CSSPROPERTYVALUE_Always,
- FDE_CSSPROPERTYVALUE_DistributeSpace,
- FDE_CSSPROPERTYVALUE_LineEdge,
- FDE_CSSPROPERTYVALUE_PreWrap,
- FDE_CSSPROPERTYVALUE_Medium,
- FDE_CSSPROPERTYVALUE_NResize,
- FDE_CSSPROPERTYVALUE_ListItem,
- FDE_CSSPROPERTYVALUE_Show,
- FDE_CSSPROPERTYVALUE_Currentcolor,
- FDE_CSSPROPERTYVALUE_NoCloseQuote,
- FDE_CSSPROPERTYVALUE_VerticalLr,
- FDE_CSSPROPERTYVALUE_VerticalRl,
- FDE_CSSPROPERTYVALUE_Pointer,
- FDE_CSSPROPERTYVALUE_XxSmall,
- FDE_CSSPROPERTYVALUE_Bold,
- FDE_CSSPROPERTYVALUE_Both,
- FDE_CSSPROPERTYVALUE_SmallCaps,
- FDE_CSSPROPERTYVALUE_Katakana,
- FDE_CSSPROPERTYVALUE_After,
- FDE_CSSPROPERTYVALUE_Horizontal,
- FDE_CSSPROPERTYVALUE_Dotted,
- FDE_CSSPROPERTYVALUE_Disc,
- FDE_CSSPROPERTYVALUE_Georgian,
- FDE_CSSPROPERTYVALUE_Inline,
- FDE_CSSPROPERTYVALUE_Overline,
- FDE_CSSPROPERTYVALUE_Wait,
- FDE_CSSPROPERTYVALUE_BreakAll,
- FDE_CSSPROPERTYVALUE_UpperAlpha,
- FDE_CSSPROPERTYVALUE_Capitalize,
- FDE_CSSPROPERTYVALUE_Nowrap,
- FDE_CSSPROPERTYVALUE_TextBottom,
- FDE_CSSPROPERTYVALUE_NoOpenQuote,
- FDE_CSSPROPERTYVALUE_Groove,
- FDE_CSSPROPERTYVALUE_Progress,
- FDE_CSSPROPERTYVALUE_Larger,
- FDE_CSSPROPERTYVALUE_CloseQuote,
- FDE_CSSPROPERTYVALUE_TableCell,
- FDE_CSSPROPERTYVALUE_PreLine,
- FDE_CSSPROPERTYVALUE_Absolute,
- FDE_CSSPROPERTYVALUE_InlineTable,
- FDE_CSSPROPERTYVALUE_BidiOverride,
- FDE_CSSPROPERTYVALUE_InlineBlock,
- FDE_CSSPROPERTYVALUE_Inset,
- FDE_CSSPROPERTYVALUE_Crosshair,
- FDE_CSSPROPERTYVALUE_UpperLatin,
- FDE_CSSPROPERTYVALUE_Help,
- FDE_CSSPROPERTYVALUE_Hide,
- FDE_CSSPROPERTYVALUE_Uppercase,
- FDE_CSSPROPERTYVALUE_SResize,
- FDE_CSSPROPERTYVALUE_Table,
- FDE_CSSPROPERTYVALUE_Blink,
- FDE_CSSPROPERTYVALUE_Block,
- FDE_CSSPROPERTYVALUE_Start,
- FDE_CSSPROPERTYVALUE_TableColumnGroup,
- FDE_CSSPROPERTYVALUE_Italic,
- FDE_CSSPROPERTYVALUE_LineThrough,
- FDE_CSSPROPERTYVALUE_KeepAll,
- FDE_CSSPROPERTYVALUE_LowerAlpha,
- FDE_CSSPROPERTYVALUE_RunIn,
- FDE_CSSPROPERTYVALUE_Square,
- FDE_CSSPROPERTYVALUE_XLarge,
- FDE_CSSPROPERTYVALUE_Large,
- FDE_CSSPROPERTYVALUE_Before,
- FDE_CSSPROPERTYVALUE_Left,
- FDE_CSSPROPERTYVALUE_TextTop,
- FDE_CSSPROPERTYVALUE_RubyText,
- FDE_CSSPROPERTYVALUE_NoDisplay,
- FDE_CSSPROPERTYVALUE_MAX
-};
-class IFDE_CSSValue {
- public:
- virtual ~IFDE_CSSValue() {}
- virtual FDE_CSSVALUETYPE GetType() const = 0;
-};
-class IFDE_CSSPrimitiveValue : public IFDE_CSSValue {
- public:
- virtual FDE_CSSVALUETYPE GetType() const {
- return FDE_CSSVALUETYPE_Primitive;
- }
- virtual FDE_CSSPRIMITIVETYPE GetPrimitiveType() const = 0;
- virtual FX_ARGB GetRGBColor() const = 0;
- virtual FX_FLOAT GetFloat() const = 0;
- virtual const FX_WCHAR* GetString(int32_t& iLength) const = 0;
- virtual FDE_CSSPROPERTYVALUE GetEnum() const = 0;
- virtual const FX_WCHAR* GetFuncName() const = 0;
- virtual int32_t CountArgs() const = 0;
- virtual IFDE_CSSValue* GetArgs(int32_t index) const = 0;
-};
-class IFDE_CSSValueList : public IFDE_CSSValue {
- public:
- virtual FDE_CSSVALUETYPE GetType() const { return FDE_CSSVALUETYPE_List; }
- virtual int32_t CountValues() const = 0;
- virtual IFDE_CSSValue* GetValue(int32_t index) const = 0;
-};
-enum FDE_CSSPROPERTY {
- FDE_CSSPROPERTY_WritingMode,
- FDE_CSSPROPERTY_ColumnRuleWidth,
- FDE_CSSPROPERTY_BorderLeft,
- FDE_CSSPROPERTY_ColumnRule,
- FDE_CSSPROPERTY_Height,
- FDE_CSSPROPERTY_CounterReset,
- FDE_CSSPROPERTY_Content,
- FDE_CSSPROPERTY_RubyPosition,
- FDE_CSSPROPERTY_BackgroundColor,
- FDE_CSSPROPERTY_Width,
- FDE_CSSPROPERTY_Src,
- FDE_CSSPROPERTY_Top,
- FDE_CSSPROPERTY_Margin,
- FDE_CSSPROPERTY_BorderColor,
- FDE_CSSPROPERTY_Widows,
- FDE_CSSPROPERTY_BorderBottomColor,
- FDE_CSSPROPERTY_TextIndent,
- FDE_CSSPROPERTY_Right,
- FDE_CSSPROPERTY_TextEmphasisStyle,
- FDE_CSSPROPERTY_PaddingLeft,
- FDE_CSSPROPERTY_ColumnWidth,
- FDE_CSSPROPERTY_MarginLeft,
- FDE_CSSPROPERTY_Border,
- FDE_CSSPROPERTY_BorderTop,
- FDE_CSSPROPERTY_RubyOverhang,
- FDE_CSSPROPERTY_PageBreakBefore,
- FDE_CSSPROPERTY_MaxHeight,
- FDE_CSSPROPERTY_MinWidth,
- FDE_CSSPROPERTY_BorderLeftColor,
- FDE_CSSPROPERTY_Bottom,
- FDE_CSSPROPERTY_Quotes,
- FDE_CSSPROPERTY_MaxWidth,
- FDE_CSSPROPERTY_PaddingRight,
- FDE_CSSPROPERTY_ListStyleImage,
- FDE_CSSPROPERTY_WhiteSpace,
- FDE_CSSPROPERTY_BorderBottom,
- FDE_CSSPROPERTY_ListStyleType,
- FDE_CSSPROPERTY_WordBreak,
- FDE_CSSPROPERTY_OverflowX,
- FDE_CSSPROPERTY_OverflowY,
- FDE_CSSPROPERTY_BorderTopColor,
- FDE_CSSPROPERTY_FontFamily,
- FDE_CSSPROPERTY_Cursor,
- FDE_CSSPROPERTY_RubyAlign,
- FDE_CSSPROPERTY_ColumnRuleColor,
- FDE_CSSPROPERTY_FontWeight,
- FDE_CSSPROPERTY_BorderRightStyle,
- FDE_CSSPROPERTY_MinHeight,
- FDE_CSSPROPERTY_Color,
- FDE_CSSPROPERTY_LetterSpacing,
- FDE_CSSPROPERTY_EmptyCells,
- FDE_CSSPROPERTY_TextAlign,
- FDE_CSSPROPERTY_RubySpan,
- FDE_CSSPROPERTY_Position,
- FDE_CSSPROPERTY_BorderStyle,
- FDE_CSSPROPERTY_BorderBottomStyle,
- FDE_CSSPROPERTY_BorderCollapse,
- FDE_CSSPROPERTY_ColumnCount,
- FDE_CSSPROPERTY_BorderRightWidth,
- FDE_CSSPROPERTY_UnicodeBidi,
- FDE_CSSPROPERTY_VerticalAlign,
- FDE_CSSPROPERTY_PaddingTop,
- FDE_CSSPROPERTY_Columns,
- FDE_CSSPROPERTY_Overflow,
- FDE_CSSPROPERTY_TableLayout,
- FDE_CSSPROPERTY_FontVariant,
- FDE_CSSPROPERTY_ListStyle,
- FDE_CSSPROPERTY_BackgroundPosition,
- FDE_CSSPROPERTY_BorderWidth,
- FDE_CSSPROPERTY_TextEmphasisColor,
- FDE_CSSPROPERTY_BorderLeftStyle,
- FDE_CSSPROPERTY_PageBreakInside,
- FDE_CSSPROPERTY_TextEmphasis,
- FDE_CSSPROPERTY_BorderBottomWidth,
- FDE_CSSPROPERTY_ColumnGap,
- FDE_CSSPROPERTY_Orphans,
- FDE_CSSPROPERTY_BorderRight,
- FDE_CSSPROPERTY_FontSize,
- FDE_CSSPROPERTY_PageBreakAfter,
- FDE_CSSPROPERTY_CaptionSide,
- FDE_CSSPROPERTY_BackgroundRepeat,
- FDE_CSSPROPERTY_BorderTopStyle,
- FDE_CSSPROPERTY_BorderSpacing,
- FDE_CSSPROPERTY_TextTransform,
- FDE_CSSPROPERTY_FontStyle,
- FDE_CSSPROPERTY_Font,
- FDE_CSSPROPERTY_LineHeight,
- FDE_CSSPROPERTY_MarginRight,
- FDE_CSSPROPERTY_Float,
- FDE_CSSPROPERTY_BorderLeftWidth,
- FDE_CSSPROPERTY_Display,
- FDE_CSSPROPERTY_Clear,
- FDE_CSSPROPERTY_ColumnRuleStyle,
- FDE_CSSPROPERTY_TextCombine,
- FDE_CSSPROPERTY_ListStylePosition,
- FDE_CSSPROPERTY_Visibility,
- FDE_CSSPROPERTY_PaddingBottom,
- FDE_CSSPROPERTY_BackgroundAttachment,
- FDE_CSSPROPERTY_BackgroundImage,
- FDE_CSSPROPERTY_LineBreak,
- FDE_CSSPROPERTY_Background,
- FDE_CSSPROPERTY_BorderTopWidth,
- FDE_CSSPROPERTY_WordSpacing,
- FDE_CSSPROPERTY_BorderRightColor,
- FDE_CSSPROPERTY_CounterIncrement,
- FDE_CSSPROPERTY_Left,
- FDE_CSSPROPERTY_TextDecoration,
- FDE_CSSPROPERTY_Padding,
- FDE_CSSPROPERTY_MarginBottom,
- FDE_CSSPROPERTY_MarginTop,
- FDE_CSSPROPERTY_Direction,
- FDE_CSSPROPERTY_MAX
-};
-class IFDE_CSSDeclaration {
- public:
- virtual ~IFDE_CSSDeclaration() {}
- virtual IFDE_CSSValue* GetProperty(FDE_CSSPROPERTY eProperty,
- FX_BOOL& bImportant) const = 0;
- virtual FX_POSITION GetStartPosition() const = 0;
- virtual void GetNextProperty(FX_POSITION& pos,
- FDE_CSSPROPERTY& eProperty,
- IFDE_CSSValue*& pValue,
- FX_BOOL& bImportant) const = 0;
- virtual FX_POSITION GetStartCustom() const = 0;
- virtual void GetNextCustom(FX_POSITION& pos,
- CFX_WideString& wsName,
- CFX_WideString& wsValue) const = 0;
-};
-typedef CFX_ArrayTemplate<IFDE_CSSDeclaration*> CFDE_CSSDeclarationArray;
-enum FDE_CSSPERSUDO {
- FDE_CSSPERSUDO_After,
- FDE_CSSPERSUDO_Before,
- FDE_CSSPERSUDO_NONE
-};
-enum FDE_CSSSELECTORTYPE {
- FDE_CSSSELECTORTYPE_Element,
- FDE_CSSSELECTORTYPE_Descendant,
- FDE_CSSSELECTORTYPE_Class,
- FDE_CSSSELECTORTYPE_Persudo,
- FDE_CSSSELECTORTYPE_ID,
-};
-class IFDE_CSSSelector {
- public:
- virtual ~IFDE_CSSSelector() {}
- virtual FDE_CSSSELECTORTYPE GetType() const = 0;
- virtual FX_DWORD GetNameHash() const = 0;
- virtual IFDE_CSSSelector* GetNextSelector() const = 0;
-};
-#define FDE_CSSMEDIATYPE_Braille 0x01
-#define FDE_CSSMEDIATYPE_Emboss 0x02
-#define FDE_CSSMEDIATYPE_Handheld 0x04
-#define FDE_CSSMEDIATYPE_Print 0x08
-#define FDE_CSSMEDIATYPE_Projection 0x10
-#define FDE_CSSMEDIATYPE_Screen 0x20
-#define FDE_CSSMEDIATYPE_TTY 0x40
-#define FDE_CSSMEDIATYPE_TV 0x80
-#define FDE_CSSMEDIATYPE_ALL 0xFF
-enum FDE_CSSRULETYPE {
- FDE_CSSRULETYPE_Unknown = 0,
- FDE_CSSRULETYPE_Style = 1,
- FDE_CSSRULETYPE_Media = 4,
- FDE_CSSRULETYPE_FontFace = 5,
-};
-class IFDE_CSSRule {
- public:
- virtual ~IFDE_CSSRule() {}
- virtual FDE_CSSRULETYPE GetType() const = 0;
-};
-typedef CFX_MassArrayTemplate<IFDE_CSSRule*> CFDE_CSSRuleArray;
-class IFDE_CSSStyleRule : public IFDE_CSSRule {
- public:
- virtual FDE_CSSRULETYPE GetType() const { return FDE_CSSRULETYPE_Style; }
- virtual int32_t CountSelectorLists() const = 0;
- virtual IFDE_CSSSelector* GetSelectorList(int32_t index) const = 0;
- virtual IFDE_CSSDeclaration* GetDeclaration() const = 0;
-};
-class IFDE_CSSMediaRule : public IFDE_CSSRule {
- public:
- virtual FDE_CSSRULETYPE GetType() const { return FDE_CSSRULETYPE_Media; }
- virtual FX_DWORD GetMediaList() const = 0;
- virtual int32_t CountRules() const = 0;
- virtual IFDE_CSSRule* GetRule(int32_t index) = 0;
-};
-class IFDE_CSSFontFaceRule : public IFDE_CSSRule {
- public:
- virtual FDE_CSSRULETYPE GetType() const { return FDE_CSSRULETYPE_FontFace; }
- virtual IFDE_CSSDeclaration* GetDeclaration() const = 0;
-};
-class IFDE_CSSStyleSheet : public IFX_Unknown {
- public:
- static IFDE_CSSStyleSheet* LoadHTMLStandardStyleSheet();
- static IFDE_CSSStyleSheet* LoadFromStream(
- const CFX_WideString& szUrl,
- IFX_Stream* pStream,
- FX_WORD wCodePage,
- FX_DWORD dwMediaList = FDE_CSSMEDIATYPE_ALL);
- static IFDE_CSSStyleSheet* LoadFromBuffer(
- const CFX_WideString& szUrl,
- const FX_WCHAR* pBuffer,
- int32_t iBufSize,
- FX_WORD wCodePage,
- FX_DWORD dwMediaList = FDE_CSSMEDIATYPE_ALL);
- virtual FX_BOOL GetUrl(CFX_WideString& szUrl) = 0;
- virtual FX_DWORD GetMediaList() const = 0;
- virtual FX_WORD GetCodePage() const = 0;
-
- virtual int32_t CountRules() const = 0;
- virtual IFDE_CSSRule* GetRule(int32_t index) = 0;
-};
-typedef CFX_ArrayTemplate<IFDE_CSSStyleSheet*> CFDE_CSSStyleSheetArray;
-#define FDE_CSSUSERSTYLESHEET (FX_BSTRC("#USERSHEET"))
-#define FDE_CSSUAGENTSTYLESHEET (FX_BSTRC("#AGENTSHEET"))
-class IFDE_CSSStyleSheetCache {
- public:
- static IFDE_CSSStyleSheetCache* Create();
- virtual ~IFDE_CSSStyleSheetCache() {}
- virtual void Release() = 0;
- virtual void SetMaxItems(int32_t iMaxCount = 5) = 0;
- virtual void AddStyleSheet(const CFX_ByteStringC& szKey,
- IFDE_CSSStyleSheet* pStyleSheet) = 0;
- virtual IFDE_CSSStyleSheet* GetStyleSheet(
- const CFX_ByteStringC& szKey) const = 0;
- virtual void RemoveStyleSheet(const CFX_ByteStringC& szKey) = 0;
-};
-enum FDE_CSSSYNTAXSTATUS {
- FDE_CSSSYNTAXSTATUS_Error,
- FDE_CSSSYNTAXSTATUS_EOS,
- FDE_CSSSYNTAXSTATUS_None,
- FDE_CSSSYNTAXSTATUS_Charset,
- FDE_CSSSYNTAXSTATUS_ImportRule,
- FDE_CSSSYNTAXSTATUS_ImportClose,
- FDE_CSSSYNTAXSTATUS_PageRule,
- FDE_CSSSYNTAXSTATUS_StyleRule,
- FDE_CSSSYNTAXSTATUS_FontFaceRule,
- FDE_CSSSYNTAXSTATUS_MediaRule,
- FDE_CSSSYNTAXSTATUS_MediaType,
- FDE_CSSSYNTAXSTATUS_URI,
- FDE_CSSSYNTAXSTATUS_Selector,
- FDE_CSSSYNTAXSTATUS_DeclOpen,
- FDE_CSSSYNTAXSTATUS_DeclClose,
- FDE_CSSSYNTAXSTATUS_PropertyName,
- FDE_CSSSYNTAXSTATUS_PropertyValue,
-};
-class IFDE_CSSSyntaxParser {
- public:
- static IFDE_CSSSyntaxParser* Create();
- virtual ~IFDE_CSSSyntaxParser() {}
- virtual void Release() = 0;
- virtual FX_BOOL Init(IFX_Stream* pStream,
- int32_t iCSSPlaneSize,
- int32_t iTextDataSize = 32,
- FX_BOOL bOnlyDeclaration = FALSE) = 0;
- virtual FX_BOOL Init(const FX_WCHAR* pBuffer,
- int32_t iBufferSize,
- int32_t iTextDatSize = 32,
- FX_BOOL bOnlyDeclaration = FALSE) = 0;
-
- virtual FDE_CSSSYNTAXSTATUS DoSyntaxParse() = 0;
- virtual const FX_WCHAR* GetCurrentString(int32_t& iLength) const = 0;
-};
-enum FDE_CSSLENGTHUNIT {
- FDE_CSSLENGTHUNIT_Auto,
- FDE_CSSLENGTHUNIT_None,
- FDE_CSSLENGTHUNIT_Normal,
- FDE_CSSLENGTHUNIT_Point,
- FDE_CSSLENGTHUNIT_Percent,
-};
-#define FDE_CSSUNITBITS (3)
-#define FDE_CSSUNITMASK ((1 << FDE_CSSUNITBITS) - 1)
-struct FDE_CSSLENGTH {
- FDE_CSSLENGTH& Set(FDE_CSSLENGTHUNIT eUnit) {
- m_iData = eUnit;
- return *this;
- }
- FDE_CSSLENGTH& Set(FDE_CSSLENGTHUNIT eUnit, FX_FLOAT fValue) {
- m_iData = ((intptr_t)(fValue * 1024.0f) << FDE_CSSUNITBITS) | eUnit;
- return *this;
- }
- FDE_CSSLENGTHUNIT GetUnit() const {
- return (FDE_CSSLENGTHUNIT)(m_iData & FDE_CSSUNITMASK);
- }
- FX_FLOAT GetValue() const { return (m_iData >> FDE_CSSUNITBITS) / 1024.0f; }
- FX_BOOL NonZero() const { return (m_iData >> FDE_CSSUNITBITS) != 0; }
-
- private:
- intptr_t m_iData;
-};
-struct FDE_CSSPOINT {
- FDE_CSSPOINT& Set(FDE_CSSLENGTHUNIT eUnit) {
- x.Set(eUnit);
- y.Set(eUnit);
- return *this;
- }
- FDE_CSSPOINT& Set(FDE_CSSLENGTHUNIT eUnit, FX_FLOAT fValue) {
- x.Set(eUnit, fValue);
- y.Set(eUnit, fValue);
- return *this;
- }
- FDE_CSSLENGTH x, y;
-};
-struct FDE_CSSSIZE {
- FDE_CSSSIZE& Set(FDE_CSSLENGTHUNIT eUnit) {
- cx.Set(eUnit);
- cy.Set(eUnit);
- return *this;
- }
- FDE_CSSSIZE& Set(FDE_CSSLENGTHUNIT eUnit, FX_FLOAT fValue) {
- cx.Set(eUnit, fValue);
- cy.Set(eUnit, fValue);
- return *this;
- }
- FDE_CSSLENGTH cx, cy;
-};
-struct FDE_CSSRECT {
- FDE_CSSRECT& Set(FDE_CSSLENGTHUNIT eUnit) {
- left.Set(eUnit);
- top.Set(eUnit);
- right.Set(eUnit);
- bottom.Set(eUnit);
- return *this;
- }
- FDE_CSSRECT& Set(FDE_CSSLENGTHUNIT eUnit, FX_FLOAT fValue) {
- left.Set(eUnit, fValue);
- top.Set(eUnit, fValue);
- right.Set(eUnit, fValue);
- bottom.Set(eUnit, fValue);
- return *this;
- }
-
- FDE_CSSLENGTH left, top, right, bottom;
-};
-enum FDE_CSSBKGATTACHMENT {
- FDE_CSSBKGATTACHMENT_Scroll,
- FDE_CSSBKGATTACHMENT_Fixed,
-};
-enum FDE_CSSBKGREPEAT {
- FDE_CSSBKGREPEAT_Repeat,
- FDE_CSSBKGREPEAT_RepeatX,
- FDE_CSSBKGREPEAT_RepeatY,
- FDE_CSSBKGREPEAT_NoRepeat,
-};
-enum FDE_CSSBORDERSTYLE {
- FDE_CSSBORDERSTYLE_None,
- FDE_CSSBORDERSTYLE_Hidden,
- FDE_CSSBORDERSTYLE_Dotted,
- FDE_CSSBORDERSTYLE_Dashed,
- FDE_CSSBORDERSTYLE_Solid,
- FDE_CSSBORDERSTYLE_Double,
- FDE_CSSBORDERSTYLE_Groove,
- FDE_CSSBORDERSTYLE_Ridge,
- FDE_CSSBORDERSTYLE_Inset,
- FDE_CSSBORDERSTYLE_outset,
-};
-enum FDE_CSSCLEAR {
- FDE_CSSCLEAR_None,
- FDE_CSSCLEAR_Left,
- FDE_CSSCLEAR_Right,
- FDE_CSSCLEAR_Both,
-};
-enum FDE_CSSDISPLAY {
- FDE_CSSDISPLAY_None,
- FDE_CSSDISPLAY_ListItem,
- FDE_CSSDISPLAY_RunIn,
- FDE_CSSDISPLAY_Block,
- FDE_CSSDISPLAY_Inline,
- FDE_CSSDISPLAY_InlineBlock,
- FDE_CSSDISPLAY_InlineTable,
- FDE_CSSDISPLAY_Table,
- FDE_CSSDISPLAY_TableRow,
- FDE_CSSDISPLAY_TableCell,
- FDE_CSSDISPLAY_TableCaption,
- FDE_CSSDISPLAY_TableColumn,
- FDE_CSSDISPLAY_TableRowGroup,
- FDE_CSSDISPLAY_TableColumnGroup,
- FDE_CSSDISPLAY_TableHeaderGroup,
- FDE_CSSDISPLAY_TableFooterGroup,
- FDE_CSSDISPLAY_Ruby,
- FDE_CSSDISPLAY_RubyBase,
- FDE_CSSDISPLAY_RubyText,
- FDE_CSSDISPLSY_RubyBaseGroup,
- FDE_CSSDISPLAY_RubyTextGroup,
-};
-enum FDE_CSSVISIBILITY {
- FDE_CSSVISIBILITY_Visible,
- FDE_CSSVISIBILITY_Hidden,
- FDE_CSSVISIBILITY_Collapse,
-};
-enum FDE_CSSFONTSTYLE {
- FDE_CSSFONTSTYLE_Normal,
- FDE_CSSFONTSTYLE_Italic,
-};
-enum FDE_CSSFLOAT {
- FDE_CSSFLOAT_None,
- FDE_CSSFLOAT_Left,
- FDE_CSSFLOAT_Right,
-};
-enum FDE_CSSWRITINGMODE {
- FDE_CSSWRITINGMODE_HorizontalTb,
- FDE_CSSWRITINGMODE_VerticalRl,
- FDE_CSSWRITINGMODE_VerticalLr,
-};
-enum FDE_CSSWORDBREAK {
- FDE_CSSWORDBREAK_Normal,
- FDE_CSSWORDBREAK_KeepAll,
- FDE_CSSWORDBREAK_BreakAll,
- FDE_CSSWORDBREAK_KeepWords,
-};
-enum FDE_CSSPAGEBREAK {
- FDE_CSSPAGEBREAK_Auto,
- FDE_CSSPAGEBREAK_Always,
- FDE_CSSPAGEBREAK_Avoid,
- FDE_CSSPAGEBREAK_Left,
- FDE_CSSPAGEBREAK_Right,
-};
-enum FDE_CSSOVERFLOW {
- FDE_CSSOVERFLOW_Visible,
- FDE_CSSOVERFLOW_Hidden,
- FDE_CSSOVERFLOW_Scroll,
- FDE_CSSOVERFLOW_Auto,
- FDE_CSSOVERFLOW_NoDisplay,
- FDE_CSSOVERFLOW_NoContent,
-};
-enum FDE_CSSLINEBREAK {
- FDE_CSSLINEBREAK_Auto,
- FDE_CSSLINEBREAK_Loose,
- FDE_CSSLINEBREAK_Normal,
- FDE_CSSLINEBREAK_Strict,
-};
-enum FDE_CSSTEXTEMPHASISFILL {
- FDE_CSSTEXTEMPHASISFILL_Filled,
- FDE_CSSTEXTEMPHASISFILL_Open,
-};
-enum FDE_CSSTEXTEMPHASISMARK {
- FDE_CSSTEXTEMPHASISMARK_None,
- FDE_CSSTEXTEMPHASISMARK_Auto,
- FDE_CSSTEXTEMPHASISMARK_Dot,
- FDE_CSSTEXTEMPHASISMARK_Circle,
- FDE_CSSTEXTEMPHASISMARK_DoubleCircle,
- FDE_CSSTEXTEMPHASISMARK_Triangle,
- FDE_CSSTEXTEMPHASISMARK_Sesame,
- FDE_CSSTEXTEMPHASISMARK_Custom,
-};
-enum FDE_CSSTEXTCOMBINE {
- FDE_CSSTEXTCOMBINE_Horizontal,
- FDE_CSSTEXTCOMBINE_None,
-};
-enum FDE_CSSCURSOR {
- FDE_CSSCURSOR_Auto,
- FDE_CSSCURSOR_Crosshair,
- FDE_CSSCURSOR_Default,
- FDE_CSSCURSOR_Pointer,
- FDE_CSSCURSOR_Move,
- FDE_CSSCURSOR_EResize,
- FDE_CSSCURSOR_NeResize,
- FDE_CSSCURSOR_NwResize,
- FDE_CSSCURSOR_NResize,
- FDE_CSSCURSOR_SeResize,
- FDE_CSSCURSOR_SwResize,
- FDE_CSSCURSOR_SResize,
- FDE_CSSCURSOR_WResize,
- FDE_CSSCURSOR_Text,
- FDE_CSSCURSOR_Wait,
- FDE_CSSCURSOR_Help,
- FDE_CSSCURSOR_Progress,
-};
-enum FDE_CSSPOSITION {
- FDE_CSSPOSITION_Static,
- FDE_CSSPOSITION_Relative,
- FDE_CSSPOSITION_Absolute,
- FDE_CSSPOSITION_Fixed,
-};
-enum FDE_CSSCAPTIONSIDE {
- FDE_CSSCAPTIONSIDE_Top,
- FDE_CSSCAPTIONSIDE_Bottom,
- FDE_CSSCAPTIONSIDE_Left,
- FDE_CSSCAPTIONSIDE_Right,
- FDE_CSSCAPTIONSIDE_Before,
- FDE_CSSCAPTIONSIDE_After,
-};
-enum FDE_CSSRUBYALIGN {
- FDE_CSSRUBYALIGN_Auto,
- FDE_CSSRUBYALIGN_Start,
- FDE_CSSRUBYALIGN_Left,
- FDE_CSSRUBYALIGN_Center,
- FDE_CSSRUBYALIGN_End,
- FDE_CSSRUBYALIGN_Right,
- FDE_CSSRUBYALIGN_DistributeLetter,
- FDE_CSSRUBYALIGN_DistributeSpace,
- FDE_CSSRUBYALIGN_LineEdge,
-};
-enum FDE_CSSRUBYOVERHANG {
- FDE_CSSRUBYOVERHANG_Auto,
- FDE_CSSRUBYOVERHANG_Start,
- FDE_CSSRUBYOVERHANG_End,
- FDE_CSSRUBYOVERHANG_None,
-};
-enum FDE_CSSRUBYPOSITION {
- FDE_CSSRUBYPOSITION_Before,
- FDE_CSSRUBYPOSITION_After,
- FDE_CSSRUBYPOSITION_Right,
- FDE_CSSRUBYPOSITION_Inline,
-};
-enum FDE_CSSRUBYSPAN {
- FDE_CSSRUBYSPAN_None,
- FDE_CSSRUBYSPAN_Attr,
-};
-enum FDE_CSSTEXTALIGN {
- FDE_CSSTEXTALIGN_Left,
- FDE_CSSTEXTALIGN_Right,
- FDE_CSSTEXTALIGN_Center,
- FDE_CSSTEXTALIGN_Justify,
- FDE_CSSTEXTALIGN_JustifyAll,
-};
-enum FDE_CSSVERTICALALIGN {
- FDE_CSSVERTICALALIGN_Baseline,
- FDE_CSSVERTICALALIGN_Sub,
- FDE_CSSVERTICALALIGN_Super,
- FDE_CSSVERTICALALIGN_Top,
- FDE_CSSVERTICALALIGN_TextTop,
- FDE_CSSVERTICALALIGN_Middle,
- FDE_CSSVERTICALALIGN_Bottom,
- FDE_CSSVERTICALALIGN_TextBottom,
- FDE_CSSVERTICALALIGN_Number,
-};
-enum FDE_CSSLISTSTYLETYPE {
- FDE_CSSLISTSTYLETYPE_Disc,
- FDE_CSSLISTSTYLETYPE_Circle,
- FDE_CSSLISTSTYLETYPE_Square,
- FDE_CSSLISTSTYLETYPE_Decimal,
- FDE_CSSLISTSTYLETYPE_DecimalLeadingZero,
- FDE_CSSLISTSTYLETYPE_LowerRoman,
- FDE_CSSLISTSTYLETYPE_UpperRoman,
- FDE_CSSLISTSTYLETYPE_LowerGreek,
- FDE_CSSLISTSTYLETYPE_LowerLatin,
- FDE_CSSLISTSTYLETYPE_UpperLatin,
- FDE_CSSLISTSTYLETYPE_Armenian,
- FDE_CSSLISTSTYLETYPE_Georgian,
- FDE_CSSLISTSTYLETYPE_LowerAlpha,
- FDE_CSSLISTSTYLETYPE_UpperAlpha,
- FDE_CSSLISTSTYLETYPE_None,
- FDE_CSSLISTSTYLETYPE_CjkIdeographic,
- FDE_CSSLISTSTYLETYPE_Hebrew,
- FDE_CSSLISTSTYLETYPE_Hiragana,
- FDE_CSSLISTSTYLETYPE_HiraganaIroha,
- FDE_CSSLISTSTYLETYPE_Katakana,
- FDE_CSSLISTSTYLETYPE_KatakanaIroha,
-};
-enum FDE_CSSLISTSTYLEPOSITION {
- FDE_CSSLISTSTYLEPOSITION_Outside,
- FDE_CSSLISTSTYLEPOSITION_Inside,
-};
-enum FDE_CSSWHITESPACE {
- FDE_CSSWHITESPACE_Normal,
- FDE_CSSWHITESPACE_Pre,
- FDE_CSSWHITESPACE_Nowrap,
- FDE_CSSWHITESPACE_PreWrap,
- FDE_CSSWHITESPACE_PreLine,
-};
-enum FDE_CSSFONTVARIANT {
- FDE_CSSFONTVARIANT_Normal,
- FDE_CSSFONTVARIANT_SmallCaps,
-};
-enum FDE_CSSTEXTTRANSFORM {
- FDE_CSSTEXTTRANSFORM_None,
- FDE_CSSTEXTTRANSFORM_Capitalize,
- FDE_CSSTEXTTRANSFORM_UpperCase,
- FDE_CSSTEXTTRANSFORM_LowerCase,
-};
-enum FDE_CSSTEXTDECORATION {
- FDE_CSSTEXTDECORATION_None = 0,
- FDE_CSSTEXTDECORATION_Underline = 1,
- FDE_CSSTEXTDECORATION_Overline = 2,
- FDE_CSSTEXTDECORATION_LineThrough = 4,
- FDE_CSSTEXTDECORATION_Blink = 8,
- FDE_CSSTEXTDECORATION_Double = 16,
-};
-class IFDE_CSSRubyStyle {
- public:
- virtual ~IFDE_CSSRubyStyle() {}
- virtual FDE_CSSRUBYALIGN GetRubyAlign() const = 0;
- virtual FDE_CSSRUBYOVERHANG GetRubyOverhang() const = 0;
- virtual FDE_CSSRUBYPOSITION GetRubyPosition() const = 0;
- virtual FDE_CSSRUBYSPAN GetRubySpanType() const = 0;
- virtual IFDE_CSSValue* GetRubySpanAttr() const = 0;
-};
-class IFDE_CSSMultiColumnStyle {
- public:
- virtual ~IFDE_CSSMultiColumnStyle() {}
- virtual const FDE_CSSLENGTH& GetColumnCount() const = 0;
- virtual const FDE_CSSLENGTH& GetColumnGap() const = 0;
- virtual FX_ARGB GetColumnRuleColor() const = 0;
- virtual FDE_CSSBORDERSTYLE GetColumnRuleStyle() const = 0;
- virtual const FDE_CSSLENGTH& GetColumnRuleWidth() const = 0;
- virtual const FDE_CSSLENGTH& GetColumnWidth() const = 0;
- virtual void SetColumnCount(const FDE_CSSLENGTH& columnCount) = 0;
- virtual void SetColumnGap(const FDE_CSSLENGTH& columnGap) = 0;
- virtual void SetColumnRuleColor(FX_ARGB dwColumnRuleColor) = 0;
- virtual void SetColumnRuleStyle(FDE_CSSBORDERSTYLE eColumnRuleStyle) = 0;
- virtual void SetColumnRuleWidth(const FDE_CSSLENGTH& columnRuleWidth) = 0;
- virtual void SetColumnWidth(const FDE_CSSLENGTH& columnWidth) = 0;
-};
-class IFDE_CSSGeneratedContentStyle {
- public:
- virtual ~IFDE_CSSGeneratedContentStyle() {}
- virtual int32_t CountCounters() = 0;
- virtual const FX_WCHAR* GetCounterIdentifier(int32_t index) = 0;
- virtual FX_BOOL GetCounterReset(int32_t index, int32_t& iValue) = 0;
- virtual FX_BOOL GetCounterIncrement(int32_t index, int32_t& iValue) = 0;
- virtual IFDE_CSSValueList* GetContent() const = 0;
- virtual int32_t CountQuotes() const = 0;
- virtual const FX_WCHAR* GetQuotes(int32_t index) const = 0;
-};
-class IFDE_CSSFontStyle {
- public:
- virtual ~IFDE_CSSFontStyle() {}
- virtual int32_t CountFontFamilies() const = 0;
- virtual const FX_WCHAR* GetFontFamily(int32_t index) const = 0;
- virtual FX_WORD GetFontWeight() const = 0;
- virtual FDE_CSSFONTVARIANT GetFontVariant() const = 0;
- virtual FDE_CSSFONTSTYLE GetFontStyle() const = 0;
- virtual FX_FLOAT GetFontSize() const = 0;
- virtual FX_ARGB GetColor() const = 0;
- virtual void SetFontWeight(FX_WORD wFontWeight) = 0;
- virtual void SetFontVariant(FDE_CSSFONTVARIANT eFontVariant) = 0;
- virtual void SetFontStyle(FDE_CSSFONTSTYLE eFontStyle) = 0;
- virtual void SetFontSize(FX_FLOAT fFontSize) = 0;
- virtual void SetColor(FX_ARGB dwFontColor) = 0;
-};
-class IFDE_CSSBoundaryStyle {
- public:
- virtual ~IFDE_CSSBoundaryStyle() {}
- virtual FX_ARGB GetBorderLeftColor() const = 0;
- virtual FX_ARGB GetBorderTopColor() const = 0;
- virtual FX_ARGB GetBorderRightColor() const = 0;
- virtual FX_ARGB GetBorderBottomColor() const = 0;
- virtual FDE_CSSBORDERSTYLE GetBorderLeftStyle() const = 0;
- virtual FDE_CSSBORDERSTYLE GetBorderTopStyle() const = 0;
- virtual FDE_CSSBORDERSTYLE GetBorderRightStyle() const = 0;
- virtual FDE_CSSBORDERSTYLE GetBorderBottomStyle() const = 0;
- virtual const FDE_CSSRECT* GetBorderWidth() const = 0;
- virtual const FDE_CSSRECT* GetMarginWidth() const = 0;
- virtual const FDE_CSSRECT* GetPaddingWidth() const = 0;
- virtual void SetBorderLeftColor(FX_ARGB dwBorderColor) = 0;
- virtual void SetBorderTopColor(FX_ARGB dwBorderColor) = 0;
- virtual void SetBorderRightColor(FX_ARGB dwBorderColor) = 0;
- virtual void SetBorderBottomColor(FX_ARGB dwBorderColor) = 0;
-
- virtual void SetBorderLeftStyle(FDE_CSSBORDERSTYLE eBorderStyle) = 0;
- virtual void SetBorderTopStyle(FDE_CSSBORDERSTYLE eBorderStyle) = 0;
- virtual void SetBorderRightStyle(FDE_CSSBORDERSTYLE eBorderStyle) = 0;
- virtual void SetBorderBottomStyle(FDE_CSSBORDERSTYLE eBorderStyle) = 0;
-
- virtual void SetBorderWidth(const FDE_CSSRECT& rect) = 0;
- virtual void SetMarginWidth(const FDE_CSSRECT& rect) = 0;
- virtual void SetPaddingWidth(const FDE_CSSRECT& rect) = 0;
-};
-class IFDE_CSSPositionStyle {
- public:
- virtual ~IFDE_CSSPositionStyle() {}
- virtual FDE_CSSDISPLAY GetDisplay() const = 0;
- virtual const FDE_CSSSIZE& GetBoxSize() const = 0;
- virtual const FDE_CSSSIZE& GetMinBoxSize() const = 0;
- virtual const FDE_CSSSIZE& GetMaxBoxSize() const = 0;
- virtual FDE_CSSFLOAT GetFloat() const = 0;
- virtual FDE_CSSCLEAR GetClear() const = 0;
- virtual FDE_CSSPOSITION GetPosition() const = 0;
- virtual FDE_CSSLENGTH GetTop() const = 0;
- virtual FDE_CSSLENGTH GetBottom() const = 0;
- virtual FDE_CSSLENGTH GetLeft() const = 0;
- virtual FDE_CSSLENGTH GetRight() const = 0;
- virtual void SetDisplay(FDE_CSSDISPLAY eDisplay) = 0;
- virtual void SetBoxSize(const FDE_CSSSIZE& boxSize) = 0;
- virtual void SetMinBoxSize(const FDE_CSSSIZE& minBoxSize) = 0;
- virtual void SetMaxBoxSize(const FDE_CSSSIZE& maxBoxSize) = 0;
- virtual void SetFloat(FDE_CSSFLOAT eFloat) = 0;
- virtual void SetClear(FDE_CSSCLEAR eClear) = 0;
-};
-class IFDE_CSSParagraphStyle {
- public:
- virtual ~IFDE_CSSParagraphStyle() {}
- virtual FX_FLOAT GetLineHeight() const = 0;
- virtual FDE_CSSWHITESPACE GetWhiteSpace() const = 0;
- virtual const FDE_CSSLENGTH& GetTextIndent() const = 0;
- virtual FDE_CSSTEXTALIGN GetTextAlign() const = 0;
- virtual FDE_CSSVERTICALALIGN GetVerticalAlign() const = 0;
- virtual FX_FLOAT GetNumberVerticalAlign() const = 0;
- virtual FDE_CSSTEXTTRANSFORM GetTextTransform() const = 0;
- virtual FX_DWORD GetTextDecoration() const = 0;
- virtual const FDE_CSSLENGTH& GetLetterSpacing() const = 0;
- virtual const FDE_CSSLENGTH& GetWordSpacing() const = 0;
- virtual FDE_CSSWRITINGMODE GetWritingMode() const = 0;
- virtual FDE_CSSWORDBREAK GetWordBreak() const = 0;
- virtual int32_t GetWidows() const = 0;
- virtual FX_ARGB GetTextEmphasisColor() const = 0;
- virtual FDE_CSSPAGEBREAK GetPageBreakBefore() const = 0;
- virtual FDE_CSSPAGEBREAK GetPageBreakAfter() const = 0;
- virtual FDE_CSSPAGEBREAK GetPageBreakInside() const = 0;
- virtual int32_t GetOrphans() const = 0;
- virtual FDE_CSSLINEBREAK GetLineBreak() const = 0;
- virtual FDE_CSSTEXTEMPHASISMARK GetTextEmphasisMark() const = 0;
- virtual FDE_CSSTEXTEMPHASISFILL GetTextEmphasisFill() const = 0;
- virtual const FX_WCHAR* GetTextEmphasisCustom() const = 0;
- virtual FDE_CSSTEXTCOMBINE GetTextCombineType() const = 0;
- virtual FX_BOOL HasTextCombineNumber() const = 0;
- virtual FX_FLOAT GetTextCombineNumber() const = 0;
- virtual void SetLineHeight(FX_FLOAT fLineHeight) = 0;
- virtual void SetWhiteSpace(FDE_CSSWHITESPACE eWhiteSpace) = 0;
- virtual void SetTextIndent(const FDE_CSSLENGTH& textIndent) = 0;
- virtual void SetTextAlign(FDE_CSSTEXTALIGN eTextAlign) = 0;
- virtual void SetVerticalAlign(FDE_CSSVERTICALALIGN eVerticalAlign) = 0;
- virtual void SetNumberVerticalAlign(FX_FLOAT fAlign) = 0;
- virtual void SetTextTransform(FDE_CSSTEXTTRANSFORM eTextTransform) = 0;
- virtual void SetTextDecoration(FX_DWORD dwTextDecoration) = 0;
- virtual void SetLetterSpacing(const FDE_CSSLENGTH& letterSpacing) = 0;
- virtual void SetWordSpacing(const FDE_CSSLENGTH& wordSpacing) = 0;
- virtual void SetWritingMode(FDE_CSSWRITINGMODE eWritingMode) = 0;
- virtual void SetWordBreak(FDE_CSSWORDBREAK eWordBreak) = 0;
- virtual void SetWidows(int32_t iWidows) = 0;
- virtual void SetTextEmphasisColor(FX_ARGB dwTextEmphasisColor) = 0;
- virtual void SetPageBreakBefore(FDE_CSSPAGEBREAK ePageBreakBefore) = 0;
- virtual void SetPageBreakAfter(FDE_CSSPAGEBREAK ePageBreakAfter) = 0;
- virtual void SetPageBreakInside(FDE_CSSPAGEBREAK ePageBreakInside) = 0;
- virtual void SetOrphans(int32_t iOrphans) = 0;
- virtual void SetLineBreak(FDE_CSSLINEBREAK eLineBreak) = 0;
-};
-class IFDE_CSSBackgroundStyle {
- public:
- virtual ~IFDE_CSSBackgroundStyle() {}
- virtual FX_ARGB GetBKGColor() const = 0;
- virtual const FX_WCHAR* GetBKGImage() const = 0;
- virtual FDE_CSSBKGREPEAT GetBKGRepeat() const = 0;
- virtual FDE_CSSBKGATTACHMENT GetBKGAttachment() const = 0;
- virtual const FDE_CSSPOINT& GetBKGPosition() const = 0;
- virtual void SetBKGColor(FX_ARGB dwBKGColor) = 0;
- virtual void SetBKGPosition(const FDE_CSSPOINT& bkgPosition) = 0;
-};
-class IFDE_CSSListStyle {
- public:
- virtual ~IFDE_CSSListStyle() {}
- virtual FDE_CSSLISTSTYLETYPE GetListStyleType() const = 0;
- virtual FDE_CSSLISTSTYLEPOSITION GetListStylePosition() const = 0;
- virtual const FX_WCHAR* GetListStyleImage() const = 0;
- virtual void SetListStyleType(FDE_CSSLISTSTYLETYPE eListStyleType) = 0;
- virtual void SetListStylePosition(
- FDE_CSSLISTSTYLEPOSITION eListStylePosition) = 0;
-};
-class IFDE_CSSTableStyle {
- public:
- virtual ~IFDE_CSSTableStyle() {}
- virtual FDE_CSSCAPTIONSIDE GetCaptionSide() const = 0;
-};
-class IFDE_CSSVisualStyle {
- public:
- virtual ~IFDE_CSSVisualStyle() {}
- virtual FDE_CSSVISIBILITY GetVisibility() const = 0;
- virtual FDE_CSSOVERFLOW GetOverflowX() const = 0;
- virtual FDE_CSSOVERFLOW GetOverflowY() const = 0;
- virtual void SetVisibility(FDE_CSSVISIBILITY eVisibility) = 0;
-};
-class IFDE_CSSComputedStyle : public IFX_Unknown {
- public:
- virtual void Reset() = 0;
- virtual IFDE_CSSFontStyle* GetFontStyles() const = 0;
- virtual IFDE_CSSBoundaryStyle* GetBoundaryStyles() const = 0;
- virtual IFDE_CSSPositionStyle* GetPositionStyles() const = 0;
- virtual IFDE_CSSParagraphStyle* GetParagraphStyles() const = 0;
- virtual IFDE_CSSBackgroundStyle* GetBackgroundStyles() const = 0;
- virtual IFDE_CSSVisualStyle* GetVisualStyles() const = 0;
- virtual IFDE_CSSListStyle* GetListStyles() const = 0;
- virtual IFDE_CSSMultiColumnStyle* GetMultiColumnStyle() const = 0;
- virtual IFDE_CSSTableStyle* GetTableStyle() const = 0;
- virtual IFDE_CSSGeneratedContentStyle* GetGeneratedContentStyle() const = 0;
- virtual IFDE_CSSRubyStyle* GetRubyStyle() const = 0;
- virtual FX_BOOL GetCustomStyle(const CFX_WideStringC& wsName,
- CFX_WideString& wsValue) const = 0;
-};
-enum FDE_CSSSTYLESHEETGROUP {
- FDE_CSSSTYLESHEETGROUP_UserAgent,
- FDE_CSSSTYLESHEETGROUP_User,
- FDE_CSSSTYLESHEETGROUP_Author,
- FDE_CSSSTYLESHEETGROUP_MAX,
-};
-enum FDE_CSSSTYLESHEETPRIORITY {
- FDE_CSSSTYLESHEETPRIORITY_High,
- FDE_CSSSTYLESHEETPRIORITY_Mid,
- FDE_CSSSTYLESHEETPRIORITY_Low,
- FDE_CSSSTYLESHEETPRIORITY_MAX,
-};
-class IFDE_CSSTagProvider {
- public:
- virtual ~IFDE_CSSTagProvider() {}
- virtual CFX_WideStringC GetTagName() = 0;
- virtual FX_POSITION GetFirstAttribute() = 0;
- virtual void GetNextAttribute(FX_POSITION& pos,
- CFX_WideStringC& wsAttr,
- CFX_WideStringC& wsValue) = 0;
-};
-class IFDE_CSSAccelerator {
- public:
- virtual ~IFDE_CSSAccelerator() {}
- virtual void OnEnterTag(IFDE_CSSTagProvider* pTag) = 0;
- virtual void OnLeaveTag(IFDE_CSSTagProvider* pTag) = 0;
-};
-class IFDE_CSSStyleSelector {
- public:
- static IFDE_CSSStyleSelector* Create();
- virtual ~IFDE_CSSStyleSelector() {}
- virtual void Release() = 0;
- virtual void SetFontMgr(IFX_FontMgr* pFontMgr) = 0;
- virtual void SetDefFontSize(FX_FLOAT fFontSize) = 0;
- virtual FX_BOOL SetStyleSheet(FDE_CSSSTYLESHEETGROUP eType,
- IFDE_CSSStyleSheet* pSheet) = 0;
- virtual FX_BOOL SetStyleSheets(FDE_CSSSTYLESHEETGROUP eType,
- const CFDE_CSSStyleSheetArray* pArray) = 0;
- virtual void SetStylePriority(FDE_CSSSTYLESHEETGROUP eType,
- FDE_CSSSTYLESHEETPRIORITY ePriority) = 0;
- virtual void UpdateStyleIndex(FX_DWORD dwMediaList) = 0;
- virtual IFDE_CSSAccelerator* InitAccelerator() = 0;
- virtual IFDE_CSSComputedStyle* CreateComputedStyle(
- IFDE_CSSComputedStyle* pParentStyle) = 0;
- virtual int32_t MatchDeclarations(
- IFDE_CSSTagProvider* pTag,
- CFDE_CSSDeclarationArray& matchedDecls,
- FDE_CSSPERSUDO ePersudoType = FDE_CSSPERSUDO_NONE) = 0;
- virtual void ComputeStyle(IFDE_CSSTagProvider* pTag,
- const IFDE_CSSDeclaration** ppDeclArray,
- int32_t iDeclCount,
- IFDE_CSSComputedStyle* pDestStyle) = 0;
-};
-
-#endif // XFA_SRC_FDE_CSS_FDE_CSS_H_
diff --git a/xfa/src/fde/css/fde_csscache.cpp b/xfa/src/fde/css/fde_csscache.cpp
deleted file mode 100644
index 012585bfd0..0000000000
--- a/xfa/src/fde/css/fde_csscache.cpp
+++ /dev/null
@@ -1,149 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#include "xfa/src/fde/css/fde_csscache.h"
-
-#include <algorithm>
-
-#include "core/include/fxcrt/fx_ext.h"
-
-FDE_CSSCacheItem::FDE_CSSCacheItem(IFDE_CSSStyleSheet* p)
- : pStylesheet(p), dwActivity(0) {
- FXSYS_assert(pStylesheet);
- pStylesheet->AddRef();
-}
-FDE_CSSCacheItem::~FDE_CSSCacheItem() {
- pStylesheet->Release();
-}
-IFDE_CSSStyleSheetCache* IFDE_CSSStyleSheetCache::Create() {
- return new CFDE_CSSStyleSheetCache;
-}
-
-CFDE_CSSStyleSheetCache::CFDE_CSSStyleSheetCache()
- : m_pFixedStore(NULL), m_iMaxItems(5) {}
-
-CFDE_CSSStyleSheetCache::~CFDE_CSSStyleSheetCache() {
- for (const auto& pair : m_Stylesheets) {
- FXTARGET_DeleteWith(FDE_CSSCacheItem, m_pFixedStore, pair.second);
- }
- m_Stylesheets.clear();
- if (m_pFixedStore) {
- m_pFixedStore->Release();
- }
-}
-void CFDE_CSSStyleSheetCache::AddStyleSheet(const CFX_ByteStringC& szKey,
- IFDE_CSSStyleSheet* pStyleSheet) {
- FXSYS_assert(pStyleSheet != NULL);
- if (m_pFixedStore == NULL) {
- m_pFixedStore =
- FX_CreateAllocator(FX_ALLOCTYPE_Fixed, std::max(10, m_iMaxItems),
- sizeof(FDE_CSSCacheItem));
- FXSYS_assert(m_pFixedStore != NULL);
- }
- auto it = m_Stylesheets.find(szKey);
- if (it != m_Stylesheets.end()) {
- FDE_CSSCacheItem* pItem = it->second;
- if (pItem->pStylesheet != pStyleSheet) {
- pItem->pStylesheet->Release();
- pItem->pStylesheet = pStyleSheet;
- pItem->pStylesheet->AddRef();
- pItem->dwActivity = 0;
- }
- } else {
- while (static_cast<int32_t>(m_Stylesheets.size()) >= m_iMaxItems) {
- RemoveLowestActivityItem();
- }
- m_Stylesheets[szKey] =
- FXTARGET_NewWith(m_pFixedStore) FDE_CSSCacheItem(pStyleSheet);
- }
-}
-IFDE_CSSStyleSheet* CFDE_CSSStyleSheetCache::GetStyleSheet(
- const CFX_ByteStringC& szKey) const {
- auto it = m_Stylesheets.find(szKey);
- if (it == m_Stylesheets.end()) {
- return nullptr;
- }
- FDE_CSSCacheItem* pItem = it->second;
- pItem->dwActivity++;
- pItem->pStylesheet->AddRef();
- return pItem->pStylesheet;
-}
-void CFDE_CSSStyleSheetCache::RemoveStyleSheet(const CFX_ByteStringC& szKey) {
- auto it = m_Stylesheets.find(szKey);
- if (it == m_Stylesheets.end()) {
- return;
- }
- FXTARGET_DeleteWith(FDE_CSSCacheItem, m_pFixedStore, it->second);
- m_Stylesheets.erase(it);
-}
-void CFDE_CSSStyleSheetCache::RemoveLowestActivityItem() {
- auto found = m_Stylesheets.end();
- for (auto it = m_Stylesheets.begin(); it != m_Stylesheets.end(); ++it) {
- switch (it->first.GetID()) {
- case FXBSTR_ID('#', 'U', 'S', 'E'):
- case FXBSTR_ID('#', 'A', 'G', 'E'):
- continue;
- }
- if (found == m_Stylesheets.end() ||
- it->second->dwActivity > found->second->dwActivity) {
- found = it;
- }
- }
- if (found != m_Stylesheets.end()) {
- FXTARGET_DeleteWith(FDE_CSSCacheItem, m_pFixedStore, found->second);
- m_Stylesheets.erase(found);
- }
-}
-FDE_CSSTagCache::FDE_CSSTagCache(FDE_CSSTagCache* parent,
- IFDE_CSSTagProvider* tag)
- : pTag(tag),
- pParent(parent),
- dwIDHash(0),
- dwTagHash(0),
- iClassIndex(0),
- dwClassHashs(1) {
- FXSYS_assert(pTag != NULL);
- CFX_WideStringC wsValue, wsName = pTag->GetTagName();
- dwTagHash =
- FX_HashCode_String_GetW(wsName.GetPtr(), wsName.GetLength(), TRUE);
- FX_POSITION pos = pTag->GetFirstAttribute();
- while (pos != NULL) {
- pTag->GetNextAttribute(pos, wsName, wsValue);
- FX_DWORD dwNameHash =
- FX_HashCode_String_GetW(wsName.GetPtr(), wsName.GetLength(), TRUE);
- static const FX_DWORD s_dwIDHash = FX_HashCode_String_GetW(L"id", 2, TRUE);
- static const FX_DWORD s_dwClassHash =
- FX_HashCode_String_GetW(L"class", 5, TRUE);
- if (dwNameHash == s_dwClassHash) {
- FX_DWORD dwHash =
- FX_HashCode_String_GetW(wsValue.GetPtr(), wsValue.GetLength());
- dwClassHashs.Add(dwHash);
- } else if (dwNameHash == s_dwIDHash) {
- dwIDHash = FX_HashCode_String_GetW(wsValue.GetPtr(), wsValue.GetLength());
- }
- }
-}
-FDE_CSSTagCache::FDE_CSSTagCache(const FDE_CSSTagCache& it)
- : pTag(it.pTag),
- pParent(it.pParent),
- dwIDHash(it.dwIDHash),
- dwTagHash(it.dwTagHash),
- iClassIndex(0),
- dwClassHashs(1) {
- if (it.dwClassHashs.GetSize() > 0) {
- dwClassHashs.Copy(it.dwClassHashs);
- }
-}
-void CFDE_CSSAccelerator::OnEnterTag(IFDE_CSSTagProvider* pTag) {
- FDE_CSSTagCache* pTop = GetTopElement();
- FDE_CSSTagCache item(pTop, pTag);
- m_Stack.Push(item);
-}
-void CFDE_CSSAccelerator::OnLeaveTag(IFDE_CSSTagProvider* pTag) {
- FXSYS_assert(m_Stack.GetTopElement());
- FXSYS_assert(m_Stack.GetTopElement()->GetTag() == pTag);
- m_Stack.Pop();
-}
diff --git a/xfa/src/fde/css/fde_csscache.h b/xfa/src/fde/css/fde_csscache.h
deleted file mode 100644
index e10bea77f5..0000000000
--- a/xfa/src/fde/css/fde_csscache.h
+++ /dev/null
@@ -1,85 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifndef XFA_SRC_FDE_CSS_FDE_CSSCACHE_H_
-#define XFA_SRC_FDE_CSS_FDE_CSSCACHE_H_
-
-#include <map>
-
-#include "xfa/src/fde/css/fde_css.h"
-#include "xfa/src/fgas/crt/fgas_memory.h"
-
-class FDE_CSSCacheItem : public CFX_Target {
- public:
- explicit FDE_CSSCacheItem(IFDE_CSSStyleSheet* p);
- ~FDE_CSSCacheItem();
-
- IFDE_CSSStyleSheet* pStylesheet;
- FX_DWORD dwActivity;
-};
-
-class CFDE_CSSStyleSheetCache : public IFDE_CSSStyleSheetCache,
- public CFX_Target {
- public:
- CFDE_CSSStyleSheetCache();
- ~CFDE_CSSStyleSheetCache();
- virtual void Release() { delete this; }
-
- virtual void SetMaxItems(int32_t iMaxCount = 5) {
- FXSYS_assert(iMaxCount >= 3);
- m_iMaxItems = iMaxCount;
- }
-
- virtual void AddStyleSheet(const CFX_ByteStringC& szKey,
- IFDE_CSSStyleSheet* pStyleSheet);
- virtual IFDE_CSSStyleSheet* GetStyleSheet(const CFX_ByteStringC& szKey) const;
- virtual void RemoveStyleSheet(const CFX_ByteStringC& szKey);
-
- protected:
- void RemoveLowestActivityItem();
- std::map<CFX_ByteString, FDE_CSSCacheItem*> m_Stylesheets;
- IFX_MEMAllocator* m_pFixedStore;
- int32_t m_iMaxItems;
-};
-
-class FDE_CSSTagCache : public CFX_Target {
- public:
- FDE_CSSTagCache(FDE_CSSTagCache* parent, IFDE_CSSTagProvider* tag);
- FDE_CSSTagCache(const FDE_CSSTagCache& it);
- FDE_CSSTagCache* GetParent() const { return pParent; }
- IFDE_CSSTagProvider* GetTag() const { return pTag; }
- FX_DWORD HashID() const { return dwIDHash; }
- FX_DWORD HashTag() const { return dwTagHash; }
- int32_t CountHashClass() const { return dwClassHashs.GetSize(); }
- void SetClassIndex(int32_t index) { iClassIndex = index; }
- FX_DWORD HashClass() const {
- return iClassIndex < dwClassHashs.GetSize()
- ? dwClassHashs.GetAt(iClassIndex)
- : 0;
- }
-
- protected:
- IFDE_CSSTagProvider* pTag;
- FDE_CSSTagCache* pParent;
- FX_DWORD dwIDHash;
- FX_DWORD dwTagHash;
- int32_t iClassIndex;
- CFDE_DWordArray dwClassHashs;
-};
-typedef CFX_ObjectStackTemplate<FDE_CSSTagCache> CFDE_CSSTagStack;
-
-class CFDE_CSSAccelerator : public IFDE_CSSAccelerator, public CFX_Target {
- public:
- virtual void OnEnterTag(IFDE_CSSTagProvider* pTag);
- virtual void OnLeaveTag(IFDE_CSSTagProvider* pTag);
- void Clear() { m_Stack.RemoveAll(); }
- FDE_CSSTagCache* GetTopElement() const { return m_Stack.GetTopElement(); }
-
- protected:
- CFDE_CSSTagStack m_Stack;
-};
-
-#endif // XFA_SRC_FDE_CSS_FDE_CSSCACHE_H_
diff --git a/xfa/src/fde/css/fde_cssdatatable.cpp b/xfa/src/fde/css/fde_cssdatatable.cpp
deleted file mode 100644
index 5ad83e7b25..0000000000
--- a/xfa/src/fde/css/fde_cssdatatable.cpp
+++ /dev/null
@@ -1,889 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#include "xfa/src/fde/css/fde_cssdatatable.h"
-
-#include "core/include/fxcrt/fx_ext.h"
-#include "xfa/src/fgas/crt/fgas_algorithm.h"
-#include "xfa/src/fgas/crt/fgas_codepage.h"
-#include "xfa/src/fgas/crt/fgas_system.h"
-
-FX_BOOL FDE_CSSLengthToFloat(const FDE_CSSLENGTH& len,
- FX_FLOAT fPercentBase,
- FX_FLOAT& fResult) {
- switch (len.GetUnit()) {
- case FDE_CSSLENGTHUNIT_Point:
- fResult = len.GetValue();
- return TRUE;
- case FDE_CSSLENGTHUNIT_Percent:
- fResult = len.GetValue() * fPercentBase;
- return TRUE;
- default:
- return FALSE;
- }
-}
-CFX_FloatRect FDE_CSSBoundaryToRect(IFDE_CSSBoundaryStyle* pBoundStyle,
- FX_FLOAT fContainerWidth,
- FX_BOOL bPadding,
- FX_BOOL bBorder,
- FX_BOOL bMargin) {
- FXSYS_assert(pBoundStyle != NULL);
- FX_FLOAT fResult;
- const FDE_CSSRECT* pRect;
- CFX_FloatRect rect(0, 0, 0, 0);
- if (bPadding) {
- pRect = pBoundStyle->GetPaddingWidth();
- if (pRect != NULL) {
- if (FDE_CSSLengthToFloat(pRect->left, fContainerWidth, fResult)) {
- rect.left += fResult;
- }
- if (FDE_CSSLengthToFloat(pRect->top, fContainerWidth, fResult)) {
- rect.top += fResult;
- }
- if (FDE_CSSLengthToFloat(pRect->right, fContainerWidth, fResult)) {
- rect.right += fResult;
- }
- if (FDE_CSSLengthToFloat(pRect->bottom, fContainerWidth, fResult)) {
- rect.bottom += fResult;
- }
- }
- }
- if (bBorder) {
- pRect = pBoundStyle->GetBorderWidth();
- if (pRect != NULL) {
- if (FDE_CSSLengthToFloat(pRect->left, fContainerWidth, fResult)) {
- rect.left += fResult;
- }
- if (FDE_CSSLengthToFloat(pRect->top, fContainerWidth, fResult)) {
- rect.top += fResult;
- }
- if (FDE_CSSLengthToFloat(pRect->right, fContainerWidth, fResult)) {
- rect.right += fResult;
- }
- if (FDE_CSSLengthToFloat(pRect->bottom, fContainerWidth, fResult)) {
- rect.bottom += fResult;
- }
- }
- }
- if (bMargin) {
- pRect = pBoundStyle->GetMarginWidth();
- if (pRect != NULL) {
- if (FDE_CSSLengthToFloat(pRect->left, fContainerWidth, fResult)) {
- rect.left += fResult;
- }
- if (FDE_CSSLengthToFloat(pRect->top, fContainerWidth, fResult)) {
- rect.top += fResult;
- }
- if (FDE_CSSLengthToFloat(pRect->right, fContainerWidth, fResult)) {
- rect.right += fResult;
- }
- if (FDE_CSSLengthToFloat(pRect->bottom, fContainerWidth, fResult)) {
- rect.bottom += fResult;
- }
- }
- }
- return rect;
-}
-FX_DWORD FDE_CSSFontStyleToFDE(IFDE_CSSFontStyle* pFontStyle) {
- FXSYS_assert(pFontStyle != NULL);
- FX_DWORD dwFontStyle = FX_FONTSTYLE_Normal;
- if (pFontStyle->GetFontStyle() == FDE_CSSFONTSTYLE_Italic) {
- dwFontStyle |= FX_FONTSTYLE_Italic;
- }
- if (pFontStyle->GetFontWeight() >= 700) {
- dwFontStyle |= FX_FONTSTYLE_Bold;
- }
- return dwFontStyle;
-}
-static const FDE_CSSPROPERTYTABLE g_FDE_CSSProperties[] = {
- {FDE_CSSPROPERTY_WritingMode, L"writing-mode", 0x01878076,
- FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum},
- {FDE_CSSPROPERTY_ColumnRuleWidth, L"column-rule-width", 0x0200FB00,
- FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum |
- FDE_CSSVALUETYPE_MaybeNumber},
- {FDE_CSSPROPERTY_BorderLeft, L"border-left", 0x04080036,
- FDE_CSSVALUETYPE_Shorthand},
- {FDE_CSSPROPERTY_ColumnRule, L"column-rule", 0x04C83DF3,
- FDE_CSSVALUETYPE_Shorthand},
- {FDE_CSSPROPERTY_Height, L"height", 0x05A5C519,
- FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum |
- FDE_CSSVALUETYPE_MaybeNumber},
- {FDE_CSSPROPERTY_CounterReset, L"counter-reset", 0x0894F9B0,
- FDE_CSSVALUETYPE_List | FDE_CSSVALUETYPE_MaybeEnum |
- FDE_CSSVALUETYPE_MaybeNumber | FDE_CSSVALUETYPE_MaybeString},
- {FDE_CSSPROPERTY_Content, L"content", 0x097BE91B,
- FDE_CSSVALUETYPE_List | FDE_CSSVALUETYPE_MaybeEnum |
- FDE_CSSVALUETYPE_MaybeURI | FDE_CSSVALUETYPE_MaybeString},
- {FDE_CSSPROPERTY_RubyPosition, L"ruby-position", 0x09ACD024,
- FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum},
- {FDE_CSSPROPERTY_BackgroundColor, L"background-color", 0x09E8E8AC,
- FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum |
- FDE_CSSVALUETYPE_MaybeColor},
- {FDE_CSSPROPERTY_Width, L"width", 0x0A8A8F80,
- FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum |
- FDE_CSSVALUETYPE_MaybeNumber},
- {FDE_CSSPROPERTY_Src, L"src", 0x0BD37048,
- FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeURI},
- {FDE_CSSPROPERTY_Top, L"top", 0x0BEDAF33, FDE_CSSVALUETYPE_Primitive |
- FDE_CSSVALUETYPE_MaybeEnum |
- FDE_CSSVALUETYPE_MaybeNumber},
- {FDE_CSSPROPERTY_Margin, L"margin", 0x0CB016BE,
- FDE_CSSVALUETYPE_List | FDE_CSSVALUETYPE_MaybeEnum |
- FDE_CSSVALUETYPE_MaybeNumber},
- {FDE_CSSPROPERTY_BorderColor, L"border-color", 0x0CBB528A,
- FDE_CSSVALUETYPE_List | FDE_CSSVALUETYPE_MaybeEnum |
- FDE_CSSVALUETYPE_MaybeColor},
- {FDE_CSSPROPERTY_Widows, L"widows", 0x1026C59D,
- FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeNumber},
- {FDE_CSSPROPERTY_BorderBottomColor, L"border-bottom-color", 0x121E22EC,
- FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum |
- FDE_CSSVALUETYPE_MaybeColor},
- {FDE_CSSPROPERTY_TextIndent, L"text-indent", 0x169ADB74,
- FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeNumber},
- {FDE_CSSPROPERTY_Right, L"right", 0x193ADE3E,
- FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum |
- FDE_CSSVALUETYPE_MaybeNumber},
- {FDE_CSSPROPERTY_TextEmphasisStyle, L"text-emphasis-style", 0x20DBAF4A,
- FDE_CSSVALUETYPE_List | FDE_CSSVALUETYPE_MaybeEnum |
- FDE_CSSVALUETYPE_MaybeString},
- {FDE_CSSPROPERTY_PaddingLeft, L"padding-left", 0x228CF02F,
- FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeNumber},
- {FDE_CSSPROPERTY_ColumnWidth, L"column-width", 0x24C9AC9B,
- FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum |
- FDE_CSSVALUETYPE_MaybeNumber},
- {FDE_CSSPROPERTY_MarginLeft, L"margin-left", 0x297C5656,
- FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeNumber |
- FDE_CSSVALUETYPE_MaybeEnum},
- {FDE_CSSPROPERTY_Border, L"border", 0x2A23349E, FDE_CSSVALUETYPE_Shorthand},
- {FDE_CSSPROPERTY_BorderTop, L"border-top", 0x2B866ADE,
- FDE_CSSVALUETYPE_Shorthand},
- {FDE_CSSPROPERTY_RubyOverhang, L"ruby-overhang", 0x2CCA0D89,
- FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum},
- {FDE_CSSPROPERTY_PageBreakBefore, L"page-break-before", 0x3119B36F,
- FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum},
- {FDE_CSSPROPERTY_MaxHeight, L"max-height", 0x343597EC,
- FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeNumber},
- {FDE_CSSPROPERTY_MinWidth, L"min-width", 0x35832871,
- FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeNumber},
- {FDE_CSSPROPERTY_BorderLeftColor, L"border-left-color", 0x35C64022,
- FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum |
- FDE_CSSVALUETYPE_MaybeColor},
- {FDE_CSSPROPERTY_Bottom, L"bottom", 0x399F02B5,
- FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum |
- FDE_CSSVALUETYPE_MaybeNumber},
- {FDE_CSSPROPERTY_Quotes, L"quotes", 0x3D8C6A01,
- FDE_CSSVALUETYPE_List | FDE_CSSVALUETYPE_MaybeString},
- {FDE_CSSPROPERTY_MaxWidth, L"max-width", 0x3EA274F3,
- FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeNumber},
- {FDE_CSSPROPERTY_PaddingRight, L"padding-right", 0x3F616AC2,
- FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeNumber},
- {FDE_CSSPROPERTY_ListStyleImage, L"list-style-image", 0x42A8A86A,
- FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum |
- FDE_CSSVALUETYPE_MaybeURI},
- {FDE_CSSPROPERTY_WhiteSpace, L"white-space", 0x42F0429A,
- FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum},
- {FDE_CSSPROPERTY_BorderBottom, L"border-bottom", 0x452CE780,
- FDE_CSSVALUETYPE_Shorthand},
- {FDE_CSSPROPERTY_ListStyleType, L"list-style-type", 0x48094789,
- FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum},
- {FDE_CSSPROPERTY_WordBreak, L"word-break", 0x4D74A3CE,
- FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum},
- {FDE_CSSPROPERTY_OverflowX, L"overflow-x", 0x4ECEBF99,
- FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum},
- {FDE_CSSPROPERTY_OverflowY, L"overflow-y", 0x4ECEBF9A,
- FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum},
- {FDE_CSSPROPERTY_BorderTopColor, L"border-top-color", 0x5109B8CA,
- FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum |
- FDE_CSSVALUETYPE_MaybeColor},
- {FDE_CSSPROPERTY_FontFamily, L"font-family", 0x574686E6,
- FDE_CSSVALUETYPE_List | FDE_CSSVALUETYPE_MaybeString},
- {FDE_CSSPROPERTY_Cursor, L"cursor", 0x59DFCA5E,
- FDE_CSSVALUETYPE_List | FDE_CSSVALUETYPE_MaybeEnum |
- FDE_CSSVALUETYPE_MaybeString},
- {FDE_CSSPROPERTY_RubyAlign, L"ruby-align", 0x6077BDFA,
- FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum},
- {FDE_CSSPROPERTY_ColumnRuleColor, L"column-rule-color", 0x65DDFD9F,
- FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum |
- FDE_CSSVALUETYPE_MaybeColor},
- {FDE_CSSPROPERTY_FontWeight, L"font-weight", 0x6692F60C,
- FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum |
- FDE_CSSVALUETYPE_MaybeNumber},
- {FDE_CSSPROPERTY_BorderRightStyle, L"border-right-style", 0x6920DDA7,
- FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum},
- {FDE_CSSPROPERTY_MinHeight, L"min-height", 0x6AAE312A,
- FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeNumber},
- {FDE_CSSPROPERTY_Color, L"color", 0x6E67921F,
- FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum |
- FDE_CSSVALUETYPE_MaybeColor},
- {FDE_CSSPROPERTY_LetterSpacing, L"letter-spacing", 0x70536102,
- FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum |
- FDE_CSSVALUETYPE_MaybeNumber},
- {FDE_CSSPROPERTY_EmptyCells, L"empty-cells", 0x7531528F,
- FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum},
- {FDE_CSSPROPERTY_TextAlign, L"text-align", 0x7553F1BD,
- FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum},
- {FDE_CSSPROPERTY_RubySpan, L"ruby-span", 0x76FCFCE1,
- FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum |
- FDE_CSSVALUETYPE_MaybeFunction},
- {FDE_CSSPROPERTY_Position, L"position", 0x814F82B5,
- FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum},
- {FDE_CSSPROPERTY_BorderStyle, L"border-style", 0x82A4CD5C,
- FDE_CSSVALUETYPE_List | FDE_CSSVALUETYPE_MaybeEnum},
- {FDE_CSSPROPERTY_BorderBottomStyle, L"border-bottom-style", 0x88079DBE,
- FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum},
- {FDE_CSSPROPERTY_BorderCollapse, L"border-collapse", 0x8883C7FE,
- FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum},
- {FDE_CSSPROPERTY_ColumnCount, L"column-count", 0x89936A64,
- FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum |
- FDE_CSSVALUETYPE_MaybeNumber},
- {FDE_CSSPROPERTY_BorderRightWidth, L"border-right-width", 0x8F5A6036,
- FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum |
- FDE_CSSVALUETYPE_MaybeNumber},
- {FDE_CSSPROPERTY_UnicodeBidi, L"unicode-bidi", 0x91670F6C,
- FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum},
- {FDE_CSSPROPERTY_VerticalAlign, L"vertical-align", 0x934A87D2,
- FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum |
- FDE_CSSVALUETYPE_MaybeNumber},
- {FDE_CSSPROPERTY_PaddingTop, L"padding-top", 0x959D22B7,
- FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeNumber},
- {FDE_CSSPROPERTY_Columns, L"columns", 0x96FA5D81,
- FDE_CSSVALUETYPE_Shorthand},
- {FDE_CSSPROPERTY_Overflow, L"overflow", 0x97B76B54,
- FDE_CSSVALUETYPE_Shorthand},
- {FDE_CSSPROPERTY_TableLayout, L"table-layout", 0x9B1CB4B3,
- FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum},
- {FDE_CSSPROPERTY_FontVariant, L"font-variant", 0x9C785779,
- FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum},
- {FDE_CSSPROPERTY_ListStyle, L"list-style", 0x9E6C471A,
- FDE_CSSVALUETYPE_Shorthand},
- {FDE_CSSPROPERTY_BackgroundPosition, L"background-position", 0xA8846D22,
- FDE_CSSVALUETYPE_List | FDE_CSSVALUETYPE_MaybeEnum |
- FDE_CSSVALUETYPE_MaybeNumber},
- {FDE_CSSPROPERTY_BorderWidth, L"border-width", 0xA8DE4FEB,
- FDE_CSSVALUETYPE_List | FDE_CSSVALUETYPE_MaybeEnum |
- FDE_CSSVALUETYPE_MaybeNumber},
- {FDE_CSSPROPERTY_TextEmphasisColor, L"text-emphasis-color", 0xAAF23478,
- FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum |
- FDE_CSSVALUETYPE_MaybeColor},
- {FDE_CSSPROPERTY_BorderLeftStyle, L"border-left-style", 0xABAFBAF4,
- FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum},
- {FDE_CSSPROPERTY_PageBreakInside, L"page-break-inside", 0xACB695F8,
- FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum},
- {FDE_CSSPROPERTY_TextEmphasis, L"text-emphasis", 0xAD0E580C,
- FDE_CSSVALUETYPE_Shorthand},
- {FDE_CSSPROPERTY_BorderBottomWidth, L"border-bottom-width", 0xAE41204D,
- FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum |
- FDE_CSSVALUETYPE_MaybeNumber},
- {FDE_CSSPROPERTY_ColumnGap, L"column-gap", 0xB5C1BA73,
- FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum |
- FDE_CSSVALUETYPE_MaybeNumber},
- {FDE_CSSPROPERTY_Orphans, L"orphans", 0xB716467B,
- FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeNumber},
- {FDE_CSSPROPERTY_BorderRight, L"border-right", 0xB78E9EA9,
- FDE_CSSVALUETYPE_Shorthand},
- {FDE_CSSPROPERTY_FontSize, L"font-size", 0xB93956DF,
- FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum |
- FDE_CSSVALUETYPE_MaybeNumber},
- {FDE_CSSPROPERTY_PageBreakAfter, L"page-break-after", 0xBC358AEE,
- FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum},
- {FDE_CSSPROPERTY_CaptionSide, L"caption-side", 0xC03F3560,
- FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum},
- {FDE_CSSPROPERTY_BackgroundRepeat, L"background-repeat", 0xC2C2FDCE,
- FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum},
- {FDE_CSSPROPERTY_BorderTopStyle, L"border-top-style", 0xC6F3339C,
- FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum},
- {FDE_CSSPROPERTY_BorderSpacing, L"border-spacing", 0xC72030F0,
- FDE_CSSVALUETYPE_List | FDE_CSSVALUETYPE_MaybeNumber},
- {FDE_CSSPROPERTY_TextTransform, L"text-transform", 0xC88EEA6E,
- FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum},
- {FDE_CSSPROPERTY_FontStyle, L"font-style", 0xCB1950F5,
- FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum},
- {FDE_CSSPROPERTY_Font, L"font", 0xCD308B77, FDE_CSSVALUETYPE_Shorthand},
- {FDE_CSSPROPERTY_LineHeight, L"line-height", 0xCFCACE2E,
- FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum |
- FDE_CSSVALUETYPE_MaybeNumber},
- {FDE_CSSPROPERTY_MarginRight, L"margin-right", 0xD13C58C9,
- FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeNumber |
- FDE_CSSVALUETYPE_MaybeEnum},
- {FDE_CSSPROPERTY_Float, L"float", 0xD1532876,
- FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum},
- {FDE_CSSPROPERTY_BorderLeftWidth, L"border-left-width", 0xD1E93D83,
- FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum |
- FDE_CSSVALUETYPE_MaybeNumber},
- {FDE_CSSPROPERTY_Display, L"display", 0xD4224C36,
- FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum},
- {FDE_CSSPROPERTY_Clear, L"clear", 0xD8ED1467,
- FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum},
- {FDE_CSSPROPERTY_ColumnRuleStyle, L"column-rule-style", 0xDBC77871,
- FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum},
- {FDE_CSSPROPERTY_TextCombine, L"text-combine", 0xDC5207CF,
- FDE_CSSVALUETYPE_List | FDE_CSSVALUETYPE_MaybeEnum |
- FDE_CSSVALUETYPE_MaybeNumber},
- {FDE_CSSPROPERTY_ListStylePosition, L"list-style-position", 0xE1A1DE3C,
- FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum},
- {FDE_CSSPROPERTY_Visibility, L"visibility", 0xE29F5168,
- FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum},
- {FDE_CSSPROPERTY_PaddingBottom, L"padding-bottom", 0xE555B3B9,
- FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeNumber},
- {FDE_CSSPROPERTY_BackgroundAttachment, L"background-attachment", 0xE77981F6,
- FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum},
- {FDE_CSSPROPERTY_BackgroundImage, L"background-image", 0xE9AEB710,
- FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum |
- FDE_CSSVALUETYPE_MaybeURI},
- {FDE_CSSPROPERTY_LineBreak, L"line-break", 0xEA2D1D9A,
- FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum},
- {FDE_CSSPROPERTY_Background, L"background", 0xEB49DD40,
- FDE_CSSVALUETYPE_Shorthand},
- {FDE_CSSPROPERTY_BorderTopWidth, L"border-top-width", 0xED2CB62B,
- FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum |
- FDE_CSSVALUETYPE_MaybeNumber},
- {FDE_CSSPROPERTY_WordSpacing, L"word-spacing", 0xEDA63BAE,
- FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum |
- FDE_CSSVALUETYPE_MaybeNumber},
- {FDE_CSSPROPERTY_BorderRightColor, L"border-right-color", 0xF33762D5,
- FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum |
- FDE_CSSVALUETYPE_MaybeColor},
- {FDE_CSSPROPERTY_CounterIncrement, L"counter-increment", 0xF4CFB1B2,
- FDE_CSSVALUETYPE_List | FDE_CSSVALUETYPE_MaybeEnum |
- FDE_CSSVALUETYPE_MaybeNumber | FDE_CSSVALUETYPE_MaybeString},
- {FDE_CSSPROPERTY_Left, L"left", 0xF5AD782B,
- FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum |
- FDE_CSSVALUETYPE_MaybeNumber},
- {FDE_CSSPROPERTY_TextDecoration, L"text-decoration", 0xF7C634BA,
- FDE_CSSVALUETYPE_List | FDE_CSSVALUETYPE_MaybeEnum},
- {FDE_CSSPROPERTY_Padding, L"padding", 0xF8C373F7,
- FDE_CSSVALUETYPE_List | FDE_CSSVALUETYPE_MaybeNumber},
- {FDE_CSSPROPERTY_MarginBottom, L"margin-bottom", 0xF93485A0,
- FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeNumber |
- FDE_CSSVALUETYPE_MaybeEnum},
- {FDE_CSSPROPERTY_MarginTop, L"margin-top", 0xFE51DCFE,
- FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeNumber |
- FDE_CSSVALUETYPE_MaybeEnum},
- {FDE_CSSPROPERTY_Direction, L"direction", 0xFE746E61,
- FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum},
-};
-static const FDE_CSSPROPERTYVALUETABLE g_FDE_CSSPropertyValues[] = {
- {FDE_CSSPROPERTYVALUE_Bolder, L"bolder", 0x009F1058},
- {FDE_CSSPROPERTYVALUE_LowerLatin, L"lower-latin", 0x016014CE},
- {FDE_CSSPROPERTYVALUE_Lowercase, L"lowercase", 0x02ACB805},
- {FDE_CSSPROPERTYVALUE_LowerGreek, L"lower-greek", 0x03D81D64},
- {FDE_CSSPROPERTYVALUE_Sesame, L"sesame", 0x0432ECDE},
- {FDE_CSSPROPERTYVALUE_None, L"none", 0x048B6670},
- {FDE_CSSPROPERTYVALUE_NwResize, L"nw-resize", 0x054B4BE4},
- {FDE_CSSPROPERTYVALUE_WResize, L"w-resize", 0x0A2F8D76},
- {FDE_CSSPROPERTYVALUE_Dot, L"dot", 0x0A48CB27},
- {FDE_CSSPROPERTYVALUE_End, L"end", 0x0A631437},
- {FDE_CSSPROPERTYVALUE_Ltr, L"ltr", 0x0B1B56D2},
- {FDE_CSSPROPERTYVALUE_Pre, L"pre", 0x0B848587},
- {FDE_CSSPROPERTYVALUE_Rtl, L"rtl", 0x0BB92C52},
- {FDE_CSSPROPERTYVALUE_Sub, L"sub", 0x0BD37FAA},
- {FDE_CSSPROPERTYVALUE_Top, L"top", 0x0BEDAF33},
- {FDE_CSSPROPERTYVALUE_Visible, L"visible", 0x0F55D7EE},
- {FDE_CSSPROPERTYVALUE_Filled, L"filled", 0x10827DD0},
- {FDE_CSSPROPERTYVALUE_SwResize, L"sw-resize", 0x10B548E9},
- {FDE_CSSPROPERTYVALUE_NoRepeat, L"no-repeat", 0x1235C18B},
- {FDE_CSSPROPERTYVALUE_Default, L"default", 0x14DA2125},
- {FDE_CSSPROPERTYVALUE_Transparent, L"transparent", 0x17B64DB2},
- {FDE_CSSPROPERTYVALUE_Ridge, L"ridge", 0x18EBEE4B},
- {FDE_CSSPROPERTYVALUE_Right, L"right", 0x193ADE3E},
- {FDE_CSSPROPERTYVALUE_HorizontalTb, L"horizontal-tb", 0x1A66A86D},
- {FDE_CSSPROPERTYVALUE_DistributeLetter, L"distribute-letter", 0x1EDBD75C},
- {FDE_CSSPROPERTYVALUE_DoubleCircle, L"double-circle", 0x1FF082BA},
- {FDE_CSSPROPERTYVALUE_Ruby, L"ruby", 0x20D66C02},
- {FDE_CSSPROPERTYVALUE_Collapse, L"collapse", 0x2128D673},
- {FDE_CSSPROPERTYVALUE_Normal, L"normal", 0x247CF3E9},
- {FDE_CSSPROPERTYVALUE_Avoid, L"avoid", 0x24E684B3},
- {FDE_CSSPROPERTYVALUE_UpperRoman, L"upper-roman", 0x28BAC2B6},
- {FDE_CSSPROPERTYVALUE_Auto, L"auto", 0x2B35B6D9},
- {FDE_CSSPROPERTYVALUE_Text, L"text", 0x2D08AF85},
- {FDE_CSSPROPERTYVALUE_XSmall, L"x-small", 0x2D2FCAFE},
- {FDE_CSSPROPERTYVALUE_Thin, L"thin", 0x2D574D53},
- {FDE_CSSPROPERTYVALUE_Repeat, L"repeat", 0x306614A1},
- {FDE_CSSPROPERTYVALUE_Small, L"small", 0x316A3739},
- {FDE_CSSPROPERTYVALUE_NeResize, L"ne-resize", 0x31FD5E12},
- {FDE_CSSPROPERTYVALUE_NoContent, L"no-content", 0x33A1C545},
- {FDE_CSSPROPERTYVALUE_Outside, L"outside", 0x36DF693D},
- {FDE_CSSPROPERTYVALUE_EResize, L"e-resize", 0x36E19FA4},
- {FDE_CSSPROPERTYVALUE_TableRow, L"table-row", 0x3912A02D},
- {FDE_CSSPROPERTYVALUE_Bottom, L"bottom", 0x399F02B5},
- {FDE_CSSPROPERTYVALUE_Underline, L"underline", 0x3A0273A6},
- {FDE_CSSPROPERTYVALUE_CjkIdeographic, L"cjk-ideographic", 0x3A641CC4},
- {FDE_CSSPROPERTYVALUE_SeResize, L"se-resize", 0x3D675B17},
- {FDE_CSSPROPERTYVALUE_Fixed, L"fixed", 0x3D7DEB10},
- {FDE_CSSPROPERTYVALUE_Double, L"double", 0x3D98515B},
- {FDE_CSSPROPERTYVALUE_Solid, L"solid", 0x40623B5B},
- {FDE_CSSPROPERTYVALUE_RubyBaseGroup, L"ruby-base-group", 0x41014E84},
- {FDE_CSSPROPERTYVALUE_OpenQuote, L"open-quote", 0x44A41E8D},
- {FDE_CSSPROPERTYVALUE_Lighter, L"lighter", 0x45BEB7AF},
- {FDE_CSSPROPERTYVALUE_LowerRoman, L"lower-roman", 0x5044D253},
- {FDE_CSSPROPERTYVALUE_Strict, L"strict", 0x52F4EBD9},
- {FDE_CSSPROPERTYVALUE_TableCaption, L"table-caption", 0x5325CD63},
- {FDE_CSSPROPERTYVALUE_Oblique, L"oblique", 0x53EBDDB1},
- {FDE_CSSPROPERTYVALUE_Decimal, L"decimal", 0x54034C2F},
- {FDE_CSSPROPERTYVALUE_Loose, L"loose", 0x54D3A1E2},
- {FDE_CSSPROPERTYVALUE_Hebrew, L"hebrew", 0x565792DD},
- {FDE_CSSPROPERTYVALUE_Hidden, L"hidden", 0x573CB40C},
- {FDE_CSSPROPERTYVALUE_Dashed, L"dashed", 0x58A3DD29},
- {FDE_CSSPROPERTYVALUE_Embed, L"embed", 0x59C8F27D},
- {FDE_CSSPROPERTYVALUE_TableRowGroup, L"table-row-group", 0x5A43BD07},
- {FDE_CSSPROPERTYVALUE_TableColumn, L"table-column", 0x5E705DA3},
- {FDE_CSSPROPERTYVALUE_Static, L"static", 0x5E7555E8},
- {FDE_CSSPROPERTYVALUE_Outset, L"outset", 0x61236164},
- {FDE_CSSPROPERTYVALUE_DecimalLeadingZero, L"decimal-leading-zero",
- 0x61DFC55D},
- {FDE_CSSPROPERTYVALUE_KeepWords, L"keep-words", 0x63964801},
- {FDE_CSSPROPERTYVALUE_KatakanaIroha, L"katakana-iroha", 0x65D7C91C},
- {FDE_CSSPROPERTYVALUE_Super, L"super", 0x6A4F842F},
- {FDE_CSSPROPERTYVALUE_Center, L"center", 0x6C51AFC1},
- {FDE_CSSPROPERTYVALUE_TableHeaderGroup, L"table-header-group", 0x706103D8},
- {FDE_CSSPROPERTYVALUE_Inside, L"inside", 0x709CB0FC},
- {FDE_CSSPROPERTYVALUE_XxLarge, L"xx-large", 0x70BB1508},
- {FDE_CSSPROPERTYVALUE_Triangle, L"triangle", 0x7524EDF6},
- {FDE_CSSPROPERTYVALUE_RubyTextGroup, L"ruby-text-group", 0x78C2B98E},
- {FDE_CSSPROPERTYVALUE_Circle, L"circle", 0x7ABEC0D2},
- {FDE_CSSPROPERTYVALUE_Hiragana, L"hiragana", 0x7BF5E25B},
- {FDE_CSSPROPERTYVALUE_RepeatX, L"repeat-x", 0x7C8F3226},
- {FDE_CSSPROPERTYVALUE_RepeatY, L"repeat-y", 0x7C8F3227},
- {FDE_CSSPROPERTYVALUE_Move, L"move", 0x7DA03417},
- {FDE_CSSPROPERTYVALUE_HiraganaIroha, L"hiragana-iroha", 0x7EE863FB},
- {FDE_CSSPROPERTYVALUE_RubyBase, L"ruby-base", 0x7FD1B1EA},
- {FDE_CSSPROPERTYVALUE_Scroll, L"scroll", 0x84787AEF},
- {FDE_CSSPROPERTYVALUE_Smaller, L"smaller", 0x849769F0},
- {FDE_CSSPROPERTYVALUE_TableFooterGroup, L"table-footer-group", 0x85BDD97E},
- {FDE_CSSPROPERTYVALUE_Baseline, L"baseline", 0x87436BA3},
- {FDE_CSSPROPERTYVALUE_Separate, L"separate", 0x877C66B5},
- {FDE_CSSPROPERTYVALUE_Armenian, L"armenian", 0x889BE4EB},
- {FDE_CSSPROPERTYVALUE_Open, L"open", 0x8B90E1F2},
- {FDE_CSSPROPERTYVALUE_Relative, L"relative", 0x8C995B5C},
- {FDE_CSSPROPERTYVALUE_Thick, L"thick", 0x8CC35EB3},
- {FDE_CSSPROPERTYVALUE_Justify, L"justify", 0x8D269CAE},
- {FDE_CSSPROPERTYVALUE_Middle, L"middle", 0x947FA00F},
- {FDE_CSSPROPERTYVALUE_Always, L"always", 0x959AB231},
- {FDE_CSSPROPERTYVALUE_DistributeSpace, L"distribute-space", 0x97A20E58},
- {FDE_CSSPROPERTYVALUE_LineEdge, L"line-edge", 0x9A845D2A},
- {FDE_CSSPROPERTYVALUE_PreWrap, L"pre-wrap", 0x9D59588E},
- {FDE_CSSPROPERTYVALUE_Medium, L"medium", 0xA084A381},
- {FDE_CSSPROPERTYVALUE_NResize, L"n-resize", 0xA088968D},
- {FDE_CSSPROPERTYVALUE_ListItem, L"list-item", 0xA32382B8},
- {FDE_CSSPROPERTYVALUE_Show, L"show", 0xA66C10C1},
- {FDE_CSSPROPERTYVALUE_Currentcolor, L"currentColor", 0xA7883922},
- {FDE_CSSPROPERTYVALUE_NoCloseQuote, L"no-close-quote", 0xA79CBFFB},
- {FDE_CSSPROPERTYVALUE_VerticalLr, L"vertical-lr", 0xA8673F65},
- {FDE_CSSPROPERTYVALUE_VerticalRl, L"vertical-rl", 0xA8675E25},
- {FDE_CSSPROPERTYVALUE_Pointer, L"pointer", 0xA90929C1},
- {FDE_CSSPROPERTYVALUE_XxSmall, L"xx-small", 0xADE1FC76},
- {FDE_CSSPROPERTYVALUE_Bold, L"bold", 0xB18313A1},
- {FDE_CSSPROPERTYVALUE_Both, L"both", 0xB1833CAD},
- {FDE_CSSPROPERTYVALUE_SmallCaps, L"small-caps", 0xB299428D},
- {FDE_CSSPROPERTYVALUE_Katakana, L"katakana", 0xB421A4BC},
- {FDE_CSSPROPERTYVALUE_After, L"after", 0xB6B44172},
- {FDE_CSSPROPERTYVALUE_Horizontal, L"horizontal", 0xB7732DEA},
- {FDE_CSSPROPERTYVALUE_Dotted, L"dotted", 0xB88652A4},
- {FDE_CSSPROPERTYVALUE_Disc, L"disc", 0xBEBC18C3},
- {FDE_CSSPROPERTYVALUE_Georgian, L"georgian", 0xBEF99E8C},
- {FDE_CSSPROPERTYVALUE_Inline, L"inline", 0xC02D649F},
- {FDE_CSSPROPERTYVALUE_Overline, L"overline", 0xC0EC9FA4},
- {FDE_CSSPROPERTYVALUE_Wait, L"wait", 0xC1613BB5},
- {FDE_CSSPROPERTYVALUE_BreakAll, L"break-all", 0xC3145BAB},
- {FDE_CSSPROPERTYVALUE_UpperAlpha, L"upper-alpha", 0xC52D4A9F},
- {FDE_CSSPROPERTYVALUE_Capitalize, L"capitalize", 0xC5321D46},
- {FDE_CSSPROPERTYVALUE_Nowrap, L"nowrap", 0xC7994417},
- {FDE_CSSPROPERTYVALUE_TextBottom, L"text-bottom", 0xC7D08D87},
- {FDE_CSSPROPERTYVALUE_NoOpenQuote, L"no-open-quote", 0xC8CD7877},
- {FDE_CSSPROPERTYVALUE_Groove, L"groove", 0xCB24A412},
- {FDE_CSSPROPERTYVALUE_Progress, L"progress", 0xCD1D9835},
- {FDE_CSSPROPERTYVALUE_Larger, L"larger", 0xCD3C409D},
- {FDE_CSSPROPERTYVALUE_CloseQuote, L"close-quote", 0xCF8696D1},
- {FDE_CSSPROPERTYVALUE_TableCell, L"table-cell", 0xCFB5E595},
- {FDE_CSSPROPERTYVALUE_PreLine, L"pre-line", 0xD04FEDBC},
- {FDE_CSSPROPERTYVALUE_Absolute, L"absolute", 0xD0B2D55F},
- {FDE_CSSPROPERTYVALUE_InlineTable, L"inline-table", 0xD131F494},
- {FDE_CSSPROPERTYVALUE_BidiOverride, L"bidi-override", 0xD161FDE5},
- {FDE_CSSPROPERTYVALUE_InlineBlock, L"inline-block", 0xD26A8BD7},
- {FDE_CSSPROPERTYVALUE_Inset, L"inset", 0xD6F23243},
- {FDE_CSSPROPERTYVALUE_Crosshair, L"crosshair", 0xD6F8018E},
- {FDE_CSSPROPERTYVALUE_UpperLatin, L"upper-latin", 0xD9D60531},
- {FDE_CSSPROPERTYVALUE_Help, L"help", 0xDA002969},
- {FDE_CSSPROPERTYVALUE_Hide, L"hide", 0xDA69395A},
- {FDE_CSSPROPERTYVALUE_Uppercase, L"uppercase", 0xDAD595A8},
- {FDE_CSSPROPERTYVALUE_SResize, L"s-resize", 0xDB3AADF2},
- {FDE_CSSPROPERTYVALUE_Table, L"table", 0xDB9BE968},
- {FDE_CSSPROPERTYVALUE_Blink, L"blink", 0xDC36E390},
- {FDE_CSSPROPERTYVALUE_Block, L"block", 0xDCD480AB},
- {FDE_CSSPROPERTYVALUE_Start, L"start", 0xE1D9D5AE},
- {FDE_CSSPROPERTYVALUE_TableColumnGroup, L"table-column-group", 0xE2258EFD},
- {FDE_CSSPROPERTYVALUE_Italic, L"italic", 0xE31D5396},
- {FDE_CSSPROPERTYVALUE_LineThrough, L"line-through", 0xE4C5A276},
- {FDE_CSSPROPERTYVALUE_KeepAll, L"keep-all", 0xE704A72B},
- {FDE_CSSPROPERTYVALUE_LowerAlpha, L"lower-alpha", 0xECB75A3C},
- {FDE_CSSPROPERTYVALUE_RunIn, L"run-in", 0xEEC930B9},
- {FDE_CSSPROPERTYVALUE_Square, L"square", 0xEF85D351},
- {FDE_CSSPROPERTYVALUE_XLarge, L"x-large", 0xF008E390},
- {FDE_CSSPROPERTYVALUE_Large, L"large", 0xF4434FCB},
- {FDE_CSSPROPERTYVALUE_Before, L"before", 0xF4FFCE73},
- {FDE_CSSPROPERTYVALUE_Left, L"left", 0xF5AD782B},
- {FDE_CSSPROPERTYVALUE_TextTop, L"text-top", 0xFCB58D45},
- {FDE_CSSPROPERTYVALUE_RubyText, L"ruby-text", 0xFCC77174},
- {FDE_CSSPROPERTYVALUE_NoDisplay, L"no-display", 0xFE482860},
-};
-static const FDE_CSSMEDIATYPETABLE g_FDE_CSSMediaTypes[] = {
- {0xF09, 0x02}, {0x4880, 0x20}, {0x536A, 0x80},
- {0x741D, 0x10}, {0x76ED, 0x08}, {0x7CFB, 0x01},
- {0x9578, 0x04}, {0xC8E1, 0x40}, {0xD0F9, 0xFF},
-};
-static const FDE_CSSLENGTHUNITTABLE g_FDE_CSSLengthUnits[] = {
- {0x0672, 3}, {0x067D, 4}, {0x1AF7, 8}, {0x2F7A, 7},
- {0x3ED3, 10}, {0x3EE4, 9}, {0x3EE8, 5}, {0xFC30, 6},
-};
-static const FDE_CSSCOLORTABLE g_FDE_CSSColors[] = {
- {0x031B47FE, 0xff000080}, {0x0BB8DF5B, 0xffff0000},
- {0x0D82A78C, 0xff800000}, {0x2ACC82E8, 0xff00ffff},
- {0x2D083986, 0xff008080}, {0x4A6A6195, 0xffc0c0c0},
- {0x546A8EF3, 0xff808080}, {0x65C9169C, 0xffffa500},
- {0x8422BB61, 0xffffffff}, {0x9271A558, 0xff800080},
- {0xA65A3EE3, 0xffff00ff}, {0xB1345708, 0xff0000ff},
- {0xB6D2CF1F, 0xff808000}, {0xD19B5E1C, 0xffffff00},
- {0xDB64391D, 0xff000000}, {0xF616D507, 0xff00ff00},
- {0xF6EFFF31, 0xff008000},
-};
-static const FDE_CSSPERSUDOTABLE g_FDE_CSSPersudoType[] = {
- {FDE_CSSPERSUDO_After, L":after", 0x16EE1FEC},
- {FDE_CSSPERSUDO_Before, L":before", 0x7DCDDE2D},
-};
-FDE_LPCCSSPERSUDOTABLE FDE_GetCSSPersudoByEnum(FDE_CSSPERSUDO ePersudo) {
- return (ePersudo < FDE_CSSPERSUDO_NONE) ? (g_FDE_CSSPersudoType + ePersudo)
- : NULL;
-}
-FDE_LPCCSSPROPERTYTABLE FDE_GetCSSPropertyByName(const FX_WCHAR* pszName,
- int32_t iLength) {
- FXSYS_assert(pszName != NULL && iLength > 0);
- FX_DWORD dwHash = FX_HashCode_String_GetW(pszName, iLength, TRUE);
- int32_t iEnd = FDE_CSSPROPERTY_MAX - 1;
- int32_t iMid, iStart = 0;
- FX_DWORD dwMid;
- do {
- iMid = (iStart + iEnd) / 2;
- dwMid = g_FDE_CSSProperties[iMid].dwHash;
- if (dwHash == dwMid) {
- return g_FDE_CSSProperties + iMid;
- } else if (dwHash > dwMid) {
- iStart = iMid + 1;
- } else {
- iEnd = iMid - 1;
- }
- } while (iStart <= iEnd);
- return NULL;
-}
-FDE_LPCCSSPROPERTYTABLE FDE_GetCSSPropertyByEnum(FDE_CSSPROPERTY eName) {
- return (eName < FDE_CSSPROPERTY_MAX) ? (g_FDE_CSSProperties + eName) : NULL;
-}
-FDE_LPCCSSPROPERTYVALUETABLE FDE_GetCSSPropertyValueByName(
- const FX_WCHAR* pszName,
- int32_t iLength) {
- FXSYS_assert(pszName != NULL && iLength > 0);
- FX_DWORD dwHash = FX_HashCode_String_GetW(pszName, iLength, TRUE);
- int32_t iEnd = FDE_CSSPROPERTYVALUE_MAX - 1;
- int32_t iMid, iStart = 0;
- FX_DWORD dwMid;
- do {
- iMid = (iStart + iEnd) / 2;
- dwMid = g_FDE_CSSPropertyValues[iMid].dwHash;
- if (dwHash == dwMid) {
- return g_FDE_CSSPropertyValues + iMid;
- } else if (dwHash > dwMid) {
- iStart = iMid + 1;
- } else {
- iEnd = iMid - 1;
- }
- } while (iStart <= iEnd);
- return NULL;
-}
-FDE_LPCCSSPROPERTYVALUETABLE FDE_GetCSSPropertyValueByEnum(
- FDE_CSSPROPERTYVALUE eName) {
- return (eName < FDE_CSSPROPERTYVALUE_MAX) ? (g_FDE_CSSPropertyValues + eName)
- : NULL;
-}
-FDE_LPCCSSMEDIATYPETABLE FDE_GetCSSMediaTypeByName(const FX_WCHAR* pszName,
- int32_t iLength) {
- FXSYS_assert(pszName != NULL && iLength > 0);
- FX_WORD wHash = (FX_WORD)FX_HashCode_String_GetW(pszName, iLength, TRUE);
- int32_t iEnd =
- sizeof(g_FDE_CSSMediaTypes) / sizeof(FDE_CSSMEDIATYPETABLE) - 1;
- int32_t iMid, iStart = 0;
- FX_WORD uMid;
- do {
- iMid = (iStart + iEnd) / 2;
- uMid = g_FDE_CSSMediaTypes[iMid].wHash;
- if (wHash == uMid) {
- return g_FDE_CSSMediaTypes + iMid;
- } else if (wHash > uMid) {
- iStart = iMid + 1;
- } else {
- iEnd = iMid - 1;
- }
- } while (iStart <= iEnd);
- return NULL;
-}
-FDE_LPCCSSLENGTHUNITTABLE FDE_GetCSSLengthUnitByName(const FX_WCHAR* pszName,
- int32_t iLength) {
- FXSYS_assert(pszName != NULL && iLength > 0);
- FX_WORD wHash = (FX_WORD)FX_HashCode_String_GetW(pszName, iLength, TRUE);
- int32_t iEnd =
- sizeof(g_FDE_CSSLengthUnits) / sizeof(FDE_CSSLENGTHUNITTABLE) - 1;
- int32_t iMid, iStart = 0;
- FX_WORD wMid;
- do {
- iMid = (iStart + iEnd) / 2;
- wMid = g_FDE_CSSLengthUnits[iMid].wHash;
- if (wHash == wMid) {
- return g_FDE_CSSLengthUnits + iMid;
- } else if (wHash > wMid) {
- iStart = iMid + 1;
- } else {
- iEnd = iMid - 1;
- }
- } while (iStart <= iEnd);
- return NULL;
-}
-FDE_LPCCSSCOLORTABLE FDE_GetCSSColorByName(const FX_WCHAR* pszName,
- int32_t iLength) {
- FXSYS_assert(pszName != NULL && iLength > 0);
- FX_DWORD dwHash = FX_HashCode_String_GetW(pszName, iLength, TRUE);
- int32_t iEnd = sizeof(g_FDE_CSSColors) / sizeof(FDE_CSSCOLORTABLE) - 1;
- int32_t iMid, iStart = 0;
- FX_DWORD dwMid;
- do {
- iMid = (iStart + iEnd) / 2;
- dwMid = g_FDE_CSSColors[iMid].dwHash;
- if (dwHash == dwMid) {
- return g_FDE_CSSColors + iMid;
- } else if (dwHash > dwMid) {
- iStart = iMid + 1;
- } else {
- iEnd = iMid - 1;
- }
- } while (iStart <= iEnd);
- return NULL;
-}
-FX_BOOL FDE_ParseCSSNumber(const FX_WCHAR* pszValue,
- int32_t iValueLen,
- FX_FLOAT& fValue,
- FDE_CSSPRIMITIVETYPE& eUnit) {
- FXSYS_assert(pszValue != NULL && iValueLen > 0);
- int32_t iUsedLen = 0;
- fValue = FX_wcstof(pszValue, iValueLen, &iUsedLen);
- if (iUsedLen <= 0) {
- return FALSE;
- }
- iValueLen -= iUsedLen;
- pszValue += iUsedLen;
- eUnit = FDE_CSSPRIMITIVETYPE_Number;
- if (iValueLen >= 1 && *pszValue == '%') {
- eUnit = FDE_CSSPRIMITIVETYPE_Percent;
- } else if (iValueLen == 2) {
- FDE_LPCCSSLENGTHUNITTABLE pUnit = FDE_GetCSSLengthUnitByName(pszValue, 2);
- if (pUnit != NULL) {
- eUnit = (FDE_CSSPRIMITIVETYPE)pUnit->wValue;
- }
- }
- return TRUE;
-}
-
-FX_BOOL FDE_ParseCSSString(const FX_WCHAR* pszValue,
- int32_t iValueLen,
- int32_t& iOffset,
- int32_t& iLength) {
- FXSYS_assert(pszValue != NULL && iValueLen > 0);
- iOffset = 0;
- iLength = iValueLen;
- if (iValueLen >= 2) {
- FX_WCHAR first = pszValue[0], last = pszValue[iValueLen - 1];
- if ((first == '\"' && last == '\"') || (first == '\'' && last == '\'')) {
- iOffset = 1, iLength -= 2;
- }
- }
- return iValueLen > 0;
-}
-
-FX_BOOL FDE_ParseCSSURI(const FX_WCHAR* pszValue,
- int32_t iValueLen,
- int32_t& iOffset,
- int32_t& iLength) {
- FXSYS_assert(pszValue != NULL && iValueLen > 0);
- if (iValueLen < 6 || pszValue[iValueLen - 1] != ')' ||
- FX_wcsnicmp(L"url(", pszValue, 4)) {
- return FALSE;
- }
- if (FDE_ParseCSSString(pszValue + 4, iValueLen - 5, iOffset, iLength)) {
- iOffset += 4;
- return TRUE;
- }
- return FALSE;
-}
-
-FX_BOOL FDE_ParseCSSColor(const FX_WCHAR* pszValue,
- int32_t iValueLen,
- FX_ARGB& dwColor) {
- FXSYS_assert(pszValue != NULL && iValueLen > 0);
- if (*pszValue == '#') {
- switch (iValueLen) {
- case 4: {
- uint8_t red = FX_Hex2Dec((uint8_t)pszValue[1], (uint8_t)pszValue[1]);
- uint8_t green = FX_Hex2Dec((uint8_t)pszValue[2], (uint8_t)pszValue[2]);
- uint8_t blue = FX_Hex2Dec((uint8_t)pszValue[3], (uint8_t)pszValue[3]);
- dwColor = ArgbEncode(255, red, green, blue);
- }
- return TRUE;
- case 7: {
- uint8_t red = FX_Hex2Dec((uint8_t)pszValue[1], (uint8_t)pszValue[2]);
- uint8_t green = FX_Hex2Dec((uint8_t)pszValue[3], (uint8_t)pszValue[4]);
- uint8_t blue = FX_Hex2Dec((uint8_t)pszValue[5], (uint8_t)pszValue[6]);
- dwColor = ArgbEncode(255, red, green, blue);
- }
- return TRUE;
- }
- } else if (iValueLen >= 10) {
- if (pszValue[iValueLen - 1] != ')' || FX_wcsnicmp(L"rgb(", pszValue, 4)) {
- return FALSE;
- }
- uint8_t rgb[3] = {0};
- FX_FLOAT fValue;
- FDE_CSSPRIMITIVETYPE eType;
- CFDE_CSSValueListParser list(pszValue + 4, iValueLen - 5, ',');
- for (int32_t i = 0; i < 3; ++i) {
- if (!list.NextValue(eType, pszValue, iValueLen)) {
- return FALSE;
- }
- if (eType != FDE_CSSPRIMITIVETYPE_Number) {
- return FALSE;
- }
- if (!FDE_ParseCSSNumber(pszValue, iValueLen, fValue, eType)) {
- return FALSE;
- }
- rgb[i] = eType == FDE_CSSPRIMITIVETYPE_Percent
- ? FXSYS_round(fValue * 2.55f)
- : FXSYS_round(fValue);
- }
- dwColor = ArgbEncode(255, rgb[0], rgb[1], rgb[2]);
- return TRUE;
- } else {
- FDE_LPCCSSCOLORTABLE pColor = FDE_GetCSSColorByName(pszValue, iValueLen);
- if (pColor != NULL) {
- dwColor = pColor->dwValue;
- return TRUE;
- }
- }
- return FALSE;
-}
-
-CFDE_CSSValueList::CFDE_CSSValueList(IFX_MEMAllocator* pStaticStore,
- const CFDE_CSSValueArray& list) {
- m_iCount = list.GetSize();
- int32_t iByteCount = m_iCount * sizeof(IFDE_CSSValue*);
- m_ppList = (IFDE_CSSValue**)pStaticStore->Alloc(iByteCount);
- FXSYS_memcpy(m_ppList, list.GetData(), iByteCount);
-}
-FX_BOOL CFDE_CSSValueListParser::NextValue(FDE_CSSPRIMITIVETYPE& eType,
- const FX_WCHAR*& pStart,
- int32_t& iLength) {
- while (m_pCur < m_pEnd && (*m_pCur <= ' ' || *m_pCur == m_Separator)) {
- ++m_pCur;
- }
- if (m_pCur >= m_pEnd) {
- return FALSE;
- }
- eType = FDE_CSSPRIMITIVETYPE_Unknown;
- pStart = m_pCur;
- iLength = 0;
- FX_WCHAR wch = *m_pCur;
- if (wch == '#') {
- iLength = SkipTo(' ');
- if (iLength == 4 || iLength == 7) {
- eType = FDE_CSSPRIMITIVETYPE_RGB;
- }
- } else if ((wch >= '0' && wch <= '9') || wch == '.' || wch == '-' ||
- wch == '+') {
- while (m_pCur < m_pEnd && (*m_pCur > ' ' && *m_pCur != m_Separator)) {
- ++m_pCur;
- }
- iLength = m_pCur - pStart;
- if (iLength > 0) {
- eType = FDE_CSSPRIMITIVETYPE_Number;
- }
- } else if (wch == '\"' || wch == '\'') {
- pStart++;
- iLength = SkipTo(wch) - 1;
- m_pCur++;
- eType = FDE_CSSPRIMITIVETYPE_String;
- } else if (m_pEnd - m_pCur > 5 && m_pCur[3] == '(') {
- if (FX_wcsnicmp(L"url", m_pCur, 3) == 0) {
- wch = m_pCur[4];
- if (wch == '\"' || wch == '\'') {
- pStart += 5;
- iLength = SkipTo(wch) - 6;
- m_pCur += 2;
- } else {
- pStart += 4;
- iLength = SkipTo(')') - 4;
- m_pCur++;
- }
- eType = FDE_CSSPRIMITIVETYPE_URI;
- } else if (FX_wcsnicmp(L"rgb", m_pCur, 3) == 0) {
- iLength = SkipTo(')') + 1;
- m_pCur++;
- eType = FDE_CSSPRIMITIVETYPE_RGB;
- }
- } else {
- iLength = SkipTo(m_Separator, TRUE, TRUE);
- eType = FDE_CSSPRIMITIVETYPE_String;
- }
- return m_pCur <= m_pEnd && iLength > 0;
-}
-int32_t CFDE_CSSValueListParser::SkipTo(FX_WCHAR wch,
- FX_BOOL bWSSeparator,
- FX_BOOL bBrContinue) {
- const FX_WCHAR* pStart = m_pCur;
- if (!bBrContinue) {
- if (bWSSeparator) {
- while ((++m_pCur < m_pEnd) && (*m_pCur != wch) && (*m_pCur > ' ')) {
- continue;
- }
- } else {
- while (++m_pCur < m_pEnd && *m_pCur != wch) {
- continue;
- }
- }
-
- } else {
- int32_t iBracketCount = 0;
- if (bWSSeparator) {
- while ((m_pCur < m_pEnd) && (*m_pCur != wch) && (*m_pCur > ' ')) {
- if (*m_pCur == '(') {
- iBracketCount++;
- } else if (*m_pCur == ')') {
- iBracketCount--;
- }
- m_pCur++;
- }
- } else {
- while (m_pCur < m_pEnd && *m_pCur != wch) {
- if (*m_pCur == '(') {
- iBracketCount++;
- } else if (*m_pCur == ')') {
- iBracketCount--;
- }
- m_pCur++;
- }
- }
- while (iBracketCount > 0 && m_pCur < m_pEnd) {
- if (*m_pCur == ')') {
- iBracketCount--;
- }
- m_pCur++;
- }
- }
- return m_pCur - pStart;
-}
diff --git a/xfa/src/fde/css/fde_cssdatatable.h b/xfa/src/fde/css/fde_cssdatatable.h
deleted file mode 100644
index 950b8d358d..0000000000
--- a/xfa/src/fde/css/fde_cssdatatable.h
+++ /dev/null
@@ -1,200 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifndef XFA_SRC_FDE_CSS_FDE_CSSDATATABLE_H_
-#define XFA_SRC_FDE_CSS_FDE_CSSDATATABLE_H_
-
-#include "core/include/fxcrt/fx_system.h"
-#include "xfa/src/fde/css/fde_css.h"
-#include "xfa/src/fgas/crt/fgas_memory.h"
-
-class CFDE_CSSFunction : public CFX_Target {
- public:
- CFDE_CSSFunction(const FX_WCHAR* pszFuncName, IFDE_CSSValueList* pArgList)
- : m_pArgList(pArgList), m_pszFuncName(pszFuncName) {
- FXSYS_assert(pArgList != NULL);
- }
- int32_t CountArgs() const { return m_pArgList->CountValues(); }
- IFDE_CSSValue* GetArgs(int32_t index) const {
- return m_pArgList->GetValue(index);
- }
- const FX_WCHAR* GetFuncName() const { return m_pszFuncName; }
-
- protected:
- IFDE_CSSValueList* m_pArgList;
- const FX_WCHAR* m_pszFuncName;
-};
-class CFDE_CSSPrimitiveValue : public IFDE_CSSPrimitiveValue,
- public CFX_Target {
- public:
- CFDE_CSSPrimitiveValue(const CFDE_CSSPrimitiveValue& src) { *this = src; }
- CFDE_CSSPrimitiveValue(FX_ARGB color)
- : m_eType(FDE_CSSPRIMITIVETYPE_RGB), m_dwColor(color) {}
- CFDE_CSSPrimitiveValue(FDE_CSSPROPERTYVALUE eValue)
- : m_eType(FDE_CSSPRIMITIVETYPE_Enum), m_eEnum(eValue) {}
- CFDE_CSSPrimitiveValue(FDE_CSSPRIMITIVETYPE eType, FX_FLOAT fValue)
- : m_eType(eType), m_fNumber(fValue) {}
- CFDE_CSSPrimitiveValue(FDE_CSSPRIMITIVETYPE eType, const FX_WCHAR* pValue)
- : m_eType(eType), m_pString(pValue) {
- FXSYS_assert(m_pString != NULL);
- }
- CFDE_CSSPrimitiveValue(CFDE_CSSFunction* pFunction)
- : m_eType(FDE_CSSPRIMITIVETYPE_Function), m_pFunction(pFunction) {}
-
- virtual FDE_CSSPRIMITIVETYPE GetPrimitiveType() const { return m_eType; }
-
- virtual FX_ARGB GetRGBColor() const {
- FXSYS_assert(m_eType == FDE_CSSPRIMITIVETYPE_RGB);
- return m_dwColor;
- }
- virtual FX_FLOAT GetFloat() const {
- FXSYS_assert(m_eType >= FDE_CSSPRIMITIVETYPE_Number &&
- m_eType <= FDE_CSSPRIMITIVETYPE_PC);
- return m_fNumber;
- }
- virtual const FX_WCHAR* GetString(int32_t& iLength) const {
- FXSYS_assert(m_eType >= FDE_CSSPRIMITIVETYPE_String &&
- m_eType <= FDE_CSSPRIMITIVETYPE_URI);
- iLength = FXSYS_wcslen(m_pString);
- return m_pString;
- }
- virtual FDE_CSSPROPERTYVALUE GetEnum() const {
- FXSYS_assert(m_eType == FDE_CSSPRIMITIVETYPE_Enum);
- return m_eEnum;
- }
- virtual const FX_WCHAR* GetFuncName() const {
- FXSYS_assert(m_eType == FDE_CSSPRIMITIVETYPE_Function);
- return m_pFunction->GetFuncName();
- }
- virtual int32_t CountArgs() const {
- FXSYS_assert(m_eType == FDE_CSSPRIMITIVETYPE_Function);
- return m_pFunction->CountArgs();
- }
- virtual IFDE_CSSValue* GetArgs(int32_t index) const {
- FXSYS_assert(m_eType == FDE_CSSPRIMITIVETYPE_Function);
- return m_pFunction->GetArgs(index);
- }
-
- FDE_CSSPRIMITIVETYPE m_eType;
- union {
- FX_ARGB m_dwColor;
- FX_FLOAT m_fNumber;
- const FX_WCHAR* m_pString;
- FDE_CSSPROPERTYVALUE m_eEnum;
- CFDE_CSSFunction* m_pFunction;
- };
-};
-typedef CFX_ArrayTemplate<IFDE_CSSPrimitiveValue*> CFDE_CSSPrimitiveArray;
-typedef CFX_ArrayTemplate<IFDE_CSSValue*> CFDE_CSSValueArray;
-class CFDE_CSSValueList : public IFDE_CSSValueList, public CFX_Target {
- public:
- CFDE_CSSValueList(IFX_MEMAllocator* pStaticStore,
- const CFDE_CSSValueArray& list);
- virtual int32_t CountValues() const { return m_iCount; }
- virtual IFDE_CSSValue* GetValue(int32_t index) const {
- return m_ppList[index];
- }
-
- protected:
- IFDE_CSSValue** m_ppList;
- int32_t m_iCount;
-};
-class CFDE_CSSValueListParser : public CFX_Target {
- public:
- CFDE_CSSValueListParser(const FX_WCHAR* psz, int32_t iLen, FX_WCHAR separator)
- : m_Separator(separator), m_pCur(psz), m_pEnd(psz + iLen) {
- FXSYS_assert(psz != NULL && iLen > 0);
- }
- FX_BOOL NextValue(FDE_CSSPRIMITIVETYPE& eType,
- const FX_WCHAR*& pStart,
- int32_t& iLength);
- FX_WCHAR m_Separator;
-
- protected:
- int32_t SkipTo(FX_WCHAR wch,
- FX_BOOL bWSSeparator = FALSE,
- FX_BOOL bBrContinue = FALSE);
- const FX_WCHAR* m_pCur;
- const FX_WCHAR* m_pEnd;
-};
-
-#define FDE_CSSVALUETYPE_MaybeNumber 0x0100
-#define FDE_CSSVALUETYPE_MaybeEnum 0x0200
-#define FDE_CSSVALUETYPE_MaybeURI 0x0400
-#define FDE_CSSVALUETYPE_MaybeString 0x0800
-#define FDE_CSSVALUETYPE_MaybeColor 0x1000
-#define FDE_CSSVALUETYPE_MaybeFunction 0x2000
-#define FDE_IsOnlyValue(type, enum) \
- (((type) & ~(enum)) == FDE_CSSVALUETYPE_Primitive)
-struct FDE_CSSPROPERTYTABLE {
- FDE_CSSPROPERTY eName;
- const FX_WCHAR* pszName;
- FX_DWORD dwHash;
- FX_DWORD dwType;
-};
-typedef FDE_CSSPROPERTYTABLE const* FDE_LPCCSSPROPERTYTABLE;
-
-FDE_LPCCSSPROPERTYTABLE FDE_GetCSSPropertyByName(const FX_WCHAR* pszName,
- int32_t iLength);
-FDE_LPCCSSPROPERTYTABLE FDE_GetCSSPropertyByEnum(FDE_CSSPROPERTY eName);
-struct FDE_CSSPROPERTYVALUETABLE {
- FDE_CSSPROPERTYVALUE eName;
- const FX_WCHAR* pszName;
- FX_DWORD dwHash;
-};
-typedef FDE_CSSPROPERTYVALUETABLE const* FDE_LPCCSSPROPERTYVALUETABLE;
-
-FDE_LPCCSSPROPERTYVALUETABLE FDE_GetCSSPropertyValueByName(
- const FX_WCHAR* pszName,
- int32_t iLength);
-FDE_LPCCSSPROPERTYVALUETABLE FDE_GetCSSPropertyValueByEnum(
- FDE_CSSPROPERTYVALUE eName);
-struct FDE_CSSMEDIATYPETABLE {
- FX_WORD wHash;
- FX_WORD wValue;
-};
-typedef FDE_CSSMEDIATYPETABLE const* FDE_LPCCSSMEDIATYPETABLE;
-FDE_LPCCSSMEDIATYPETABLE FDE_GetCSSMediaTypeByName(const FX_WCHAR* pszName,
- int32_t iLength);
-struct FDE_CSSLENGTHUNITTABLE {
- FX_WORD wHash;
- FX_WORD wValue;
-};
-typedef FDE_CSSLENGTHUNITTABLE const* FDE_LPCCSSLENGTHUNITTABLE;
-FDE_LPCCSSLENGTHUNITTABLE FDE_GetCSSLengthUnitByName(const FX_WCHAR* pszName,
- int32_t iLength);
-struct FDE_CSSCOLORTABLE {
- FX_DWORD dwHash;
- FX_ARGB dwValue;
-};
-typedef FDE_CSSCOLORTABLE const* FDE_LPCCSSCOLORTABLE;
-FDE_LPCCSSCOLORTABLE FDE_GetCSSColorByName(const FX_WCHAR* pszName,
- int32_t iLength);
-struct FDE_CSSPERSUDOTABLE {
- FDE_CSSPERSUDO eName;
- const FX_WCHAR* pszName;
- FX_DWORD dwHash;
-};
-typedef FDE_CSSPERSUDOTABLE const* FDE_LPCCSSPERSUDOTABLE;
-
-FDE_LPCCSSPERSUDOTABLE FDE_GetCSSPersudoByEnum(FDE_CSSPERSUDO ePersudo);
-FX_BOOL FDE_ParseCSSNumber(const FX_WCHAR* pszValue,
- int32_t iValueLen,
- FX_FLOAT& fValue,
- FDE_CSSPRIMITIVETYPE& eUnit);
-FX_BOOL FDE_ParseCSSString(const FX_WCHAR* pszValue,
- int32_t iValueLen,
- int32_t& iOffset,
- int32_t& iLength);
-FX_BOOL FDE_ParseCSSColor(const FX_WCHAR* pszValue,
- int32_t iValueLen,
- FX_ARGB& dwColor);
-FX_BOOL FDE_ParseCSSURI(const FX_WCHAR* pszValue,
- int32_t iValueLen,
- int32_t& iOffset,
- int32_t& iLength);
-
-#endif // XFA_SRC_FDE_CSS_FDE_CSSDATATABLE_H_
diff --git a/xfa/src/fde/css/fde_cssdeclaration.cpp b/xfa/src/fde/css/fde_cssdeclaration.cpp
deleted file mode 100644
index 073c14d414..0000000000
--- a/xfa/src/fde/css/fde_cssdeclaration.cpp
+++ /dev/null
@@ -1,1377 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#include "xfa/src/fde/css/fde_cssdeclaration.h"
-
-#include "core/include/fxcrt/fx_ext.h"
-#include "xfa/src/fgas/crt/fgas_system.h"
-
-IFDE_CSSValue* CFDE_CSSDeclaration::GetProperty(FDE_CSSPROPERTY eProperty,
- FX_BOOL& bImportant) const {
- for (const FDE_CSSPropertyHolder* pHolder = m_pFirstProperty; pHolder;
- pHolder = pHolder->pNext) {
- if (pHolder->eProperty == eProperty) {
- bImportant = pHolder->bImportant;
- return pHolder->pValue;
- }
- }
- return NULL;
-}
-FX_POSITION CFDE_CSSDeclaration::GetStartPosition() const {
- return (FX_POSITION)m_pFirstProperty;
-}
-void CFDE_CSSDeclaration::GetNextProperty(FX_POSITION& pos,
- FDE_CSSPROPERTY& eProperty,
- IFDE_CSSValue*& pValue,
- FX_BOOL& bImportant) const {
- const FDE_CSSPropertyHolder* pHolder = (const FDE_CSSPropertyHolder*)pos;
- FXSYS_assert(pHolder != NULL);
- bImportant = pHolder->bImportant;
- eProperty = (FDE_CSSPROPERTY)pHolder->eProperty;
- pValue = pHolder->pValue;
- pos = (FX_POSITION)pHolder->pNext;
-}
-FX_POSITION CFDE_CSSDeclaration::GetStartCustom() const {
- return (FX_POSITION)m_pFirstCustom;
-}
-void CFDE_CSSDeclaration::GetNextCustom(FX_POSITION& pos,
- CFX_WideString& wsName,
- CFX_WideString& wsValue) const {
- const FDE_CSSCustomProperty* pProperty = (const FDE_CSSCustomProperty*)pos;
- if (pProperty == NULL) {
- return;
- }
- wsName = pProperty->pwsName;
- wsValue = pProperty->pwsValue;
- pos = (FX_POSITION)pProperty->pNext;
-}
-const FX_WCHAR* CFDE_CSSDeclaration::CopyToLocal(
- const FDE_CSSPROPERTYARGS* pArgs,
- const FX_WCHAR* pszValue,
- int32_t iValueLen) {
- FXSYS_assert(iValueLen > 0);
- CFX_MapPtrToPtr* pCache = pArgs->pStringCache;
- void* pKey = NULL;
- if (pCache) {
- void* pszCached = NULL;
- pKey =
- (void*)(uintptr_t)FX_HashCode_String_GetW(pszValue, iValueLen, FALSE);
- if (pCache->Lookup(pKey, pszCached)) {
- return (const FX_WCHAR*)pszCached;
- }
- }
- FX_WCHAR* psz =
- (FX_WCHAR*)pArgs->pStaticStore->Alloc((iValueLen + 1) * sizeof(FX_WCHAR));
- if (psz == NULL) {
- return NULL;
- }
- FXSYS_wcsncpy(psz, pszValue, iValueLen);
- psz[iValueLen] = '\0';
- if (pCache) {
- pCache->SetAt(pKey, psz);
- }
- return psz;
-}
-IFDE_CSSPrimitiveValue* CFDE_CSSDeclaration::NewNumberValue(
- IFX_MEMAllocator* pStaticStore,
- FDE_CSSPRIMITIVETYPE eUnit,
- FX_FLOAT fValue) const {
- static CFDE_CSSPrimitiveValue s_ZeroValue(FDE_CSSPRIMITIVETYPE_Number, 0.0f);
- if (eUnit == FDE_CSSPRIMITIVETYPE_Number && FXSYS_fabs(fValue) < 0.001f) {
- return &s_ZeroValue;
- }
- return FXTARGET_NewWith(pStaticStore) CFDE_CSSPrimitiveValue(eUnit, fValue);
-}
-inline IFDE_CSSPrimitiveValue* CFDE_CSSDeclaration::NewEnumValue(
- IFX_MEMAllocator* pStaticStore,
- FDE_CSSPROPERTYVALUE eValue) const {
- return FXTARGET_NewWith(pStaticStore) CFDE_CSSPrimitiveValue(eValue);
-}
-void CFDE_CSSDeclaration::AddPropertyHolder(IFX_MEMAllocator* pStaticStore,
- FDE_CSSPROPERTY eProperty,
- IFDE_CSSValue* pValue,
- FX_BOOL bImportant) {
- FDE_CSSPropertyHolder* pHolder =
- FXTARGET_NewWith(pStaticStore) FDE_CSSPropertyHolder;
- pHolder->bImportant = bImportant;
- pHolder->eProperty = eProperty;
- pHolder->pValue = pValue;
- pHolder->pNext = NULL;
- if (m_pLastProperty == NULL) {
- m_pLastProperty = m_pFirstProperty = pHolder;
- } else {
- m_pLastProperty->pNext = pHolder;
- m_pLastProperty = pHolder;
- }
-}
-FX_BOOL CFDE_CSSDeclaration::AddProperty(const FDE_CSSPROPERTYARGS* pArgs,
- const FX_WCHAR* pszValue,
- int32_t iValueLen) {
- FXSYS_assert(iValueLen > 0);
- FX_BOOL bImportant = FALSE;
- if (iValueLen >= 10 && pszValue[iValueLen - 10] == '!' &&
- FX_wcsnicmp(L"important", pszValue + iValueLen - 9, 9) == 0) {
- if ((iValueLen -= 10) == 0) {
- return FALSE;
- }
- bImportant = TRUE;
- }
- const FX_DWORD dwType = pArgs->pProperty->dwType;
- switch (dwType & 0x0F) {
- case FDE_CSSVALUETYPE_Primitive: {
- static const FX_DWORD g_ValueGuessOrder[] = {
- FDE_CSSVALUETYPE_MaybeNumber, FDE_CSSVALUETYPE_MaybeEnum,
- FDE_CSSVALUETYPE_MaybeColor, FDE_CSSVALUETYPE_MaybeURI,
- FDE_CSSVALUETYPE_MaybeFunction, FDE_CSSVALUETYPE_MaybeString,
- };
- static const int32_t g_ValueGuessCount =
- sizeof(g_ValueGuessOrder) / sizeof(FX_DWORD);
- for (int32_t i = 0; i < g_ValueGuessCount; ++i) {
- const FX_DWORD dwMatch = dwType & g_ValueGuessOrder[i];
- if (dwMatch == 0) {
- continue;
- }
- IFDE_CSSValue* pCSSValue = NULL;
- switch (dwMatch) {
- case FDE_CSSVALUETYPE_MaybeFunction:
- pCSSValue = ParseFunction(pArgs, pszValue, iValueLen);
- break;
- case FDE_CSSVALUETYPE_MaybeNumber:
- pCSSValue = ParseNumber(pArgs, pszValue, iValueLen);
- break;
- case FDE_CSSVALUETYPE_MaybeEnum:
- pCSSValue = ParseEnum(pArgs, pszValue, iValueLen);
- break;
- case FDE_CSSVALUETYPE_MaybeColor:
- pCSSValue = ParseColor(pArgs, pszValue, iValueLen);
- break;
- case FDE_CSSVALUETYPE_MaybeURI:
- pCSSValue = ParseURI(pArgs, pszValue, iValueLen);
- break;
- case FDE_CSSVALUETYPE_MaybeString:
- pCSSValue = ParseString(pArgs, pszValue, iValueLen);
- break;
- default:
- break;
- }
- if (pCSSValue != NULL) {
- AddPropertyHolder(pArgs->pStaticStore, pArgs->pProperty->eName,
- pCSSValue, bImportant);
- return TRUE;
- }
- if (FDE_IsOnlyValue(dwType, g_ValueGuessOrder[i])) {
- return FALSE;
- }
- }
- } break;
- case FDE_CSSVALUETYPE_Shorthand: {
- IFX_MEMAllocator* pStaticStore = pArgs->pStaticStore;
- IFDE_CSSValue *pColor, *pStyle, *pWidth;
- switch (pArgs->pProperty->eName) {
- case FDE_CSSPROPERTY_Font:
- return ParseFontProperty(pArgs, pszValue, iValueLen, bImportant);
- case FDE_CSSPROPERTY_Background:
- return ParseBackgroundProperty(pArgs, pszValue, iValueLen,
- bImportant);
- case FDE_CSSPROPERTY_ListStyle:
- return ParseListStyleProperty(pArgs, pszValue, iValueLen, bImportant);
- case FDE_CSSPROPERTY_Border:
- if (ParseBorderPropoerty(pStaticStore, pszValue, iValueLen, pColor,
- pStyle, pWidth)) {
- AddBorderProperty(pStaticStore, pColor, pStyle, pWidth, bImportant,
- FDE_CSSPROPERTY_BorderLeftColor,
- FDE_CSSPROPERTY_BorderLeftStyle,
- FDE_CSSPROPERTY_BorderLeftWidth);
- AddBorderProperty(pStaticStore, pColor, pStyle, pWidth, bImportant,
- FDE_CSSPROPERTY_BorderTopColor,
- FDE_CSSPROPERTY_BorderTopStyle,
- FDE_CSSPROPERTY_BorderTopWidth);
- AddBorderProperty(pStaticStore, pColor, pStyle, pWidth, bImportant,
- FDE_CSSPROPERTY_BorderRightColor,
- FDE_CSSPROPERTY_BorderRightStyle,
- FDE_CSSPROPERTY_BorderRightWidth);
- AddBorderProperty(pStaticStore, pColor, pStyle, pWidth, bImportant,
- FDE_CSSPROPERTY_BorderBottomColor,
- FDE_CSSPROPERTY_BorderBottomStyle,
- FDE_CSSPROPERTY_BorderBottomWidth);
- return TRUE;
- }
- break;
- case FDE_CSSPROPERTY_BorderLeft:
- if (ParseBorderPropoerty(pStaticStore, pszValue, iValueLen, pColor,
- pStyle, pWidth)) {
- AddBorderProperty(pStaticStore, pColor, pStyle, pWidth, bImportant,
- FDE_CSSPROPERTY_BorderLeftColor,
- FDE_CSSPROPERTY_BorderLeftStyle,
- FDE_CSSPROPERTY_BorderLeftWidth);
- return TRUE;
- }
- break;
- case FDE_CSSPROPERTY_BorderTop:
- if (ParseBorderPropoerty(pStaticStore, pszValue, iValueLen, pColor,
- pStyle, pWidth)) {
- AddBorderProperty(pStaticStore, pColor, pStyle, pWidth, bImportant,
- FDE_CSSPROPERTY_BorderTopColor,
- FDE_CSSPROPERTY_BorderTopStyle,
- FDE_CSSPROPERTY_BorderTopWidth);
- return TRUE;
- }
- break;
- case FDE_CSSPROPERTY_BorderRight:
- if (ParseBorderPropoerty(pStaticStore, pszValue, iValueLen, pColor,
- pStyle, pWidth)) {
- AddBorderProperty(pStaticStore, pColor, pStyle, pWidth, bImportant,
- FDE_CSSPROPERTY_BorderRightColor,
- FDE_CSSPROPERTY_BorderRightStyle,
- FDE_CSSPROPERTY_BorderRightWidth);
- return TRUE;
- }
- break;
- case FDE_CSSPROPERTY_BorderBottom:
- if (ParseBorderPropoerty(pStaticStore, pszValue, iValueLen, pColor,
- pStyle, pWidth)) {
- AddBorderProperty(pStaticStore, pColor, pStyle, pWidth, bImportant,
- FDE_CSSPROPERTY_BorderBottomColor,
- FDE_CSSPROPERTY_BorderBottomStyle,
- FDE_CSSPROPERTY_BorderBottomWidth);
- return TRUE;
- }
- break;
- case FDE_CSSPROPERTY_Overflow:
- return ParseOverflowProperty(pArgs, pszValue, iValueLen, bImportant);
- case FDE_CSSPROPERTY_ColumnRule:
- return ParseColumnRuleProperty(pArgs, pszValue, iValueLen,
- bImportant);
- default:
- break;
- }
- } break;
- case FDE_CSSVALUETYPE_List:
- switch (pArgs->pProperty->eName) {
- case FDE_CSSPROPERTY_CounterIncrement:
- case FDE_CSSPROPERTY_CounterReset:
- return ParseCounterProperty(pArgs, pszValue, iValueLen, bImportant);
- case FDE_CSSPROPERTY_Content:
- return ParseContentProperty(pArgs, pszValue, iValueLen, bImportant);
- default:
- return ParseValueListProperty(pArgs, pszValue, iValueLen, bImportant);
- }
- default:
- FXSYS_assert(FALSE);
- break;
- }
- return FALSE;
-}
-FX_BOOL CFDE_CSSDeclaration::AddProperty(const FDE_CSSPROPERTYARGS* pArgs,
- const FX_WCHAR* pszName,
- int32_t iNameLen,
- const FX_WCHAR* pszValue,
- int32_t iValueLen) {
- FDE_CSSCustomProperty* pProperty =
- FXTARGET_NewWith(pArgs->pStaticStore) FDE_CSSCustomProperty;
- pProperty->pwsName = CopyToLocal(pArgs, pszName, iNameLen);
- pProperty->pwsValue = CopyToLocal(pArgs, pszValue, iValueLen);
- pProperty->pNext = NULL;
- if (m_pLastCustom == NULL) {
- m_pLastCustom = m_pFirstCustom = pProperty;
- } else {
- m_pLastCustom->pNext = pProperty;
- m_pLastCustom = pProperty;
- }
- return TRUE;
-}
-IFDE_CSSValue* CFDE_CSSDeclaration::ParseNumber(
- const FDE_CSSPROPERTYARGS* pArgs,
- const FX_WCHAR* pszValue,
- int32_t iValueLen) {
- FX_FLOAT fValue;
- FDE_CSSPRIMITIVETYPE eUnit;
- if (!FDE_ParseCSSNumber(pszValue, iValueLen, fValue, eUnit)) {
- return NULL;
- }
- return NewNumberValue(pArgs->pStaticStore, eUnit, fValue);
-}
-IFDE_CSSValue* CFDE_CSSDeclaration::ParseEnum(const FDE_CSSPROPERTYARGS* pArgs,
- const FX_WCHAR* pszValue,
- int32_t iValueLen) {
- const FDE_CSSPROPERTYVALUETABLE* pValue =
- FDE_GetCSSPropertyValueByName(pszValue, iValueLen);
- return pValue ? NewEnumValue(pArgs->pStaticStore, pValue->eName) : NULL;
-}
-IFDE_CSSValue* CFDE_CSSDeclaration::ParseColor(const FDE_CSSPROPERTYARGS* pArgs,
- const FX_WCHAR* pszValue,
- int32_t iValueLen) {
- FX_ARGB dwColor;
- if (!FDE_ParseCSSColor(pszValue, iValueLen, dwColor)) {
- return NULL;
- }
- return FXTARGET_NewWith(pArgs->pStaticStore) CFDE_CSSPrimitiveValue(dwColor);
-}
-IFDE_CSSValue* CFDE_CSSDeclaration::ParseURI(const FDE_CSSPROPERTYARGS* pArgs,
- const FX_WCHAR* pszValue,
- int32_t iValueLen) {
- int32_t iOffset;
- if (!FDE_ParseCSSURI(pszValue, iValueLen, iOffset, iValueLen)) {
- return NULL;
- }
- if (iValueLen <= 0) {
- return NULL;
- }
- pszValue = CopyToLocal(pArgs, pszValue + iOffset, iValueLen);
- return pszValue
- ? FXTARGET_NewWith(pArgs->pStaticStore)
- CFDE_CSSPrimitiveValue(FDE_CSSPRIMITIVETYPE_URI, pszValue)
- : NULL;
-}
-IFDE_CSSValue* CFDE_CSSDeclaration::ParseString(
- const FDE_CSSPROPERTYARGS* pArgs,
- const FX_WCHAR* pszValue,
- int32_t iValueLen) {
- int32_t iOffset;
- if (!FDE_ParseCSSString(pszValue, iValueLen, iOffset, iValueLen)) {
- return NULL;
- }
- if (iValueLen <= 0) {
- return NULL;
- }
- pszValue = CopyToLocal(pArgs, pszValue + iOffset, iValueLen);
- return pszValue
- ? FXTARGET_NewWith(pArgs->pStaticStore)
- CFDE_CSSPrimitiveValue(FDE_CSSPRIMITIVETYPE_String, pszValue)
- : NULL;
-}
-IFDE_CSSValue* CFDE_CSSDeclaration::ParseFunction(
- const FDE_CSSPROPERTYARGS* pArgs,
- const FX_WCHAR* pszValue,
- int32_t iValueLen) {
- if (pszValue[iValueLen - 1] != ')') {
- return NULL;
- }
- int32_t iStartBracket = 0;
- while (pszValue[iStartBracket] != '(') {
- if (iStartBracket < iValueLen) {
- iStartBracket++;
- } else {
- return NULL;
- }
- }
- if (iStartBracket == 0) {
- return NULL;
- }
- const FX_WCHAR* pszFuncName = CopyToLocal(pArgs, pszValue, iStartBracket);
- pszValue += (iStartBracket + 1);
- iValueLen -= (iStartBracket + 2);
- CFDE_CSSValueArray argumentArr;
- CFDE_CSSValueListParser parser(pszValue, iValueLen, ',');
- FDE_CSSPRIMITIVETYPE ePrimitiveType;
- while (parser.NextValue(ePrimitiveType, pszValue, iValueLen)) {
- switch (ePrimitiveType) {
- case FDE_CSSPRIMITIVETYPE_String: {
- const FDE_CSSPROPERTYVALUETABLE* pPropertyValue =
- FDE_GetCSSPropertyValueByName(pszValue, iValueLen);
- if (pPropertyValue != NULL) {
- argumentArr.Add(
- NewEnumValue(pArgs->pStaticStore, pPropertyValue->eName));
- continue;
- }
- IFDE_CSSValue* pFunctionValue =
- ParseFunction(pArgs, pszValue, iValueLen);
- if (pFunctionValue != NULL) {
- argumentArr.Add(pFunctionValue);
- continue;
- }
- argumentArr.Add(FXTARGET_NewWith(pArgs->pStaticStore)
- CFDE_CSSPrimitiveValue(
- FDE_CSSPRIMITIVETYPE_String,
- CopyToLocal(pArgs, pszValue, iValueLen)));
- } break;
- case FDE_CSSPRIMITIVETYPE_Number: {
- FX_FLOAT fValue;
- if (FDE_ParseCSSNumber(pszValue, iValueLen, fValue, ePrimitiveType)) {
- argumentArr.Add(
- NewNumberValue(pArgs->pStaticStore, ePrimitiveType, fValue));
- }
- } break;
- default:
- argumentArr.Add(FXTARGET_NewWith(pArgs->pStaticStore)
- CFDE_CSSPrimitiveValue(
- FDE_CSSPRIMITIVETYPE_String,
- CopyToLocal(pArgs, pszValue, iValueLen)));
- break;
- }
- }
- IFDE_CSSValueList* pArgumentList = FXTARGET_NewWith(pArgs->pStaticStore)
- CFDE_CSSValueList(pArgs->pStaticStore, argumentArr);
- CFDE_CSSFunction* pFunction = FXTARGET_NewWith(pArgs->pStaticStore)
- CFDE_CSSFunction(pszFuncName, pArgumentList);
- return FXTARGET_NewWith(pArgs->pStaticStore)
- CFDE_CSSPrimitiveValue(pFunction);
-}
-FX_BOOL CFDE_CSSDeclaration::ParseContentProperty(
- const FDE_CSSPROPERTYARGS* pArgs,
- const FX_WCHAR* pszValue,
- int32_t iValueLen,
- FX_BOOL bImportant) {
- IFX_MEMAllocator* pStaticStore = (IFX_MEMAllocator*)pArgs->pStaticStore;
- CFDE_CSSValueListParser parser(pszValue, iValueLen, ' ');
- FDE_CSSPRIMITIVETYPE eType;
- CFDE_CSSValueArray list;
- while (parser.NextValue(eType, pszValue, iValueLen)) {
- switch (eType) {
- case FDE_CSSPRIMITIVETYPE_URI:
- list.Add(FXTARGET_NewWith(pStaticStore) CFDE_CSSPrimitiveValue(
- eType, CopyToLocal(pArgs, pszValue, iValueLen)));
- break;
- case FDE_CSSPRIMITIVETYPE_Number:
- return FALSE;
- case FDE_CSSPRIMITIVETYPE_String: {
- const FDE_CSSPROPERTYVALUETABLE* pValue =
- FDE_GetCSSPropertyValueByName(pszValue, iValueLen);
- if (pValue != NULL) {
- switch (pValue->eName) {
- case FDE_CSSPROPERTYVALUE_Normal:
- case FDE_CSSPROPERTYVALUE_None: {
- if (list.GetSize() == 0) {
- list.Add(NewEnumValue(pStaticStore, pValue->eName));
- } else {
- return FALSE;
- }
- } break;
- case FDE_CSSPROPERTYVALUE_OpenQuote:
- case FDE_CSSPROPERTYVALUE_CloseQuote:
- case FDE_CSSPROPERTYVALUE_NoOpenQuote:
- case FDE_CSSPROPERTYVALUE_NoCloseQuote:
- list.Add(NewEnumValue(pStaticStore, pValue->eName));
- break;
- default:
- return FALSE;
- }
- continue;
- }
- IFDE_CSSValue* pFunction = ParseFunction(pArgs, pszValue, iValueLen);
- if (pFunction != NULL) {
- list.Add(pFunction);
- continue;
- }
- list.Add(FXTARGET_NewWith(pStaticStore) CFDE_CSSPrimitiveValue(
- eType, CopyToLocal(pArgs, pszValue, iValueLen)));
- } break;
- case FDE_CSSPRIMITIVETYPE_RGB:
- return FALSE;
- default:
- break;
- }
- }
- if (list.GetSize() == 0) {
- return FALSE;
- }
- AddPropertyHolder(pStaticStore, pArgs->pProperty->eName,
- FXTARGET_NewWith(pStaticStore)
- CFDE_CSSValueList(pStaticStore, list),
- bImportant);
- return TRUE;
-}
-FX_BOOL CFDE_CSSDeclaration::ParseCounterProperty(
- const FDE_CSSPROPERTYARGS* pArgs,
- const FX_WCHAR* pszValue,
- int32_t iValueLen,
- FX_BOOL bImportant) {
- IFX_MEMAllocator* pStaticStore = pArgs->pStaticStore;
- CFDE_CSSValueListParser parser(pszValue, iValueLen, ' ');
- CFDE_CSSValueArray list;
- CFDE_CSSValueArray listFull;
- FDE_CSSPRIMITIVETYPE eType;
- while (parser.NextValue(eType, pszValue, iValueLen)) {
- switch (eType) {
- case FDE_CSSPRIMITIVETYPE_Number: {
- FX_FLOAT fValue;
- if (FDE_ParseCSSNumber(pszValue, iValueLen, fValue, eType)) {
- if (list.GetSize() == 1) {
- list.Add(NewNumberValue(pStaticStore, eType, fValue));
- listFull.Add(FXTARGET_NewWith(pStaticStore)
- CFDE_CSSValueList(pStaticStore, list));
- list.RemoveAll();
- } else {
- return FALSE;
- }
- }
- } break;
- case FDE_CSSPRIMITIVETYPE_String: {
- if (list.GetSize() == 0) {
- pszValue = CopyToLocal(pArgs, pszValue, iValueLen);
- list.Add(FXTARGET_NewWith(pStaticStore) CFDE_CSSPrimitiveValue(
- FDE_CSSPRIMITIVETYPE_String, pszValue));
- } else {
- listFull.Add(FXTARGET_NewWith(pStaticStore)
- CFDE_CSSValueList(pStaticStore, list));
- list.RemoveAll();
- pszValue = CopyToLocal(pArgs, pszValue, iValueLen);
- list.Add(FXTARGET_NewWith(pStaticStore) CFDE_CSSPrimitiveValue(
- FDE_CSSPRIMITIVETYPE_String, pszValue));
- }
- } break;
- default:
- break;
- }
- }
- if (list.GetSize() == 1) {
- listFull.Add(FXTARGET_NewWith(pStaticStore)
- CFDE_CSSValueList(pStaticStore, list));
- }
- if (listFull.GetSize() == 0) {
- return FALSE;
- }
- AddPropertyHolder(pStaticStore, pArgs->pProperty->eName,
- FXTARGET_NewWith(pStaticStore)
- CFDE_CSSValueList(pStaticStore, listFull),
- bImportant);
- return TRUE;
-}
-FX_BOOL CFDE_CSSDeclaration::ParseValueListProperty(
- const FDE_CSSPROPERTYARGS* pArgs,
- const FX_WCHAR* pszValue,
- int32_t iValueLen,
- FX_BOOL bImportant) {
- IFX_MEMAllocator* pStaticStore = pArgs->pStaticStore;
- FX_WCHAR separator =
- (pArgs->pProperty->eName == FDE_CSSPROPERTY_FontFamily) ? ',' : ' ';
- CFDE_CSSValueListParser parser(pszValue, iValueLen, separator);
- const FX_DWORD dwType = pArgs->pProperty->dwType;
- FDE_CSSPRIMITIVETYPE eType;
- CFDE_CSSValueArray list;
- while (parser.NextValue(eType, pszValue, iValueLen)) {
- switch (eType) {
- case FDE_CSSPRIMITIVETYPE_Number:
- if (dwType & FDE_CSSVALUETYPE_MaybeNumber) {
- FX_FLOAT fValue;
- if (FDE_ParseCSSNumber(pszValue, iValueLen, fValue, eType)) {
- list.Add(NewNumberValue(pStaticStore, eType, fValue));
- }
- }
- break;
- case FDE_CSSPRIMITIVETYPE_String:
- if (dwType & FDE_CSSVALUETYPE_MaybeColor) {
- FX_ARGB dwColor;
- if (FDE_ParseCSSColor(pszValue, iValueLen, dwColor)) {
- list.Add(FXTARGET_NewWith(pStaticStore)
- CFDE_CSSPrimitiveValue(dwColor));
- continue;
- }
- }
- if (dwType & FDE_CSSVALUETYPE_MaybeEnum) {
- const FDE_CSSPROPERTYVALUETABLE* pValue =
- FDE_GetCSSPropertyValueByName(pszValue, iValueLen);
- if (pValue != NULL) {
- list.Add(NewEnumValue(pStaticStore, pValue->eName));
- continue;
- }
- }
- if (dwType & FDE_CSSVALUETYPE_MaybeString) {
- pszValue = CopyToLocal(pArgs, pszValue, iValueLen);
- list.Add(FXTARGET_NewWith(pStaticStore) CFDE_CSSPrimitiveValue(
- FDE_CSSPRIMITIVETYPE_String, pszValue));
- }
- break;
- case FDE_CSSPRIMITIVETYPE_RGB:
- if (dwType & FDE_CSSVALUETYPE_MaybeColor) {
- FX_ARGB dwColor;
- if (FDE_ParseCSSColor(pszValue, iValueLen, dwColor)) {
- list.Add(FXTARGET_NewWith(pStaticStore)
- CFDE_CSSPrimitiveValue(dwColor));
- }
- }
- break;
- default:
- break;
- }
- }
- if (list.GetSize() == 0) {
- return FALSE;
- }
- switch (pArgs->pProperty->eName) {
- case FDE_CSSPROPERTY_BorderColor:
- return Add4ValuesProperty(
- pStaticStore, list, bImportant, FDE_CSSPROPERTY_BorderLeftColor,
- FDE_CSSPROPERTY_BorderTopColor, FDE_CSSPROPERTY_BorderRightColor,
- FDE_CSSPROPERTY_BorderBottomColor);
- case FDE_CSSPROPERTY_BorderStyle:
- return Add4ValuesProperty(
- pStaticStore, list, bImportant, FDE_CSSPROPERTY_BorderLeftStyle,
- FDE_CSSPROPERTY_BorderTopStyle, FDE_CSSPROPERTY_BorderRightStyle,
- FDE_CSSPROPERTY_BorderBottomStyle);
- case FDE_CSSPROPERTY_BorderWidth:
- return Add4ValuesProperty(
- pStaticStore, list, bImportant, FDE_CSSPROPERTY_BorderLeftWidth,
- FDE_CSSPROPERTY_BorderTopWidth, FDE_CSSPROPERTY_BorderRightWidth,
- FDE_CSSPROPERTY_BorderBottomWidth);
- case FDE_CSSPROPERTY_Margin:
- return Add4ValuesProperty(
- pStaticStore, list, bImportant, FDE_CSSPROPERTY_MarginLeft,
- FDE_CSSPROPERTY_MarginTop, FDE_CSSPROPERTY_MarginRight,
- FDE_CSSPROPERTY_MarginBottom);
- case FDE_CSSPROPERTY_Padding:
- return Add4ValuesProperty(
- pStaticStore, list, bImportant, FDE_CSSPROPERTY_PaddingLeft,
- FDE_CSSPROPERTY_PaddingTop, FDE_CSSPROPERTY_PaddingRight,
- FDE_CSSPROPERTY_PaddingBottom);
- default: {
- CFDE_CSSValueList* pList =
- FXTARGET_NewWith(pStaticStore) CFDE_CSSValueList(pStaticStore, list);
- AddPropertyHolder(pStaticStore, pArgs->pProperty->eName, pList,
- bImportant);
- return TRUE;
- } break;
- }
- return FALSE;
-}
-FX_BOOL CFDE_CSSDeclaration::Add4ValuesProperty(IFX_MEMAllocator* pStaticStore,
- const CFDE_CSSValueArray& list,
- FX_BOOL bImportant,
- FDE_CSSPROPERTY eLeft,
- FDE_CSSPROPERTY eTop,
- FDE_CSSPROPERTY eRight,
- FDE_CSSPROPERTY eBottom) {
- switch (list.GetSize()) {
- case 1:
- AddPropertyHolder(pStaticStore, eLeft, list[0], bImportant);
- AddPropertyHolder(pStaticStore, eTop, list[0], bImportant);
- AddPropertyHolder(pStaticStore, eRight, list[0], bImportant);
- AddPropertyHolder(pStaticStore, eBottom, list[0], bImportant);
- return TRUE;
- case 2:
- AddPropertyHolder(pStaticStore, eLeft, list[1], bImportant);
- AddPropertyHolder(pStaticStore, eTop, list[0], bImportant);
- AddPropertyHolder(pStaticStore, eRight, list[1], bImportant);
- AddPropertyHolder(pStaticStore, eBottom, list[0], bImportant);
- return TRUE;
- case 3:
- AddPropertyHolder(pStaticStore, eLeft, list[1], bImportant);
- AddPropertyHolder(pStaticStore, eTop, list[0], bImportant);
- AddPropertyHolder(pStaticStore, eRight, list[1], bImportant);
- AddPropertyHolder(pStaticStore, eBottom, list[2], bImportant);
- return TRUE;
- case 4:
- AddPropertyHolder(pStaticStore, eLeft, list[3], bImportant);
- AddPropertyHolder(pStaticStore, eTop, list[0], bImportant);
- AddPropertyHolder(pStaticStore, eRight, list[1], bImportant);
- AddPropertyHolder(pStaticStore, eBottom, list[2], bImportant);
- return TRUE;
- default:
- break;
- }
- return FALSE;
-}
-FX_BOOL CFDE_CSSDeclaration::ParseBorderPropoerty(
- IFX_MEMAllocator* pStaticStore,
- const FX_WCHAR* pszValue,
- int32_t iValueLen,
- IFDE_CSSValue*& pColor,
- IFDE_CSSValue*& pStyle,
- IFDE_CSSValue*& pWidth) const {
- pColor = pStyle = pWidth = NULL;
- CFDE_CSSValueListParser parser(pszValue, iValueLen, ' ');
- FDE_CSSPRIMITIVETYPE eType;
- while (parser.NextValue(eType, pszValue, iValueLen)) {
- switch (eType) {
- case FDE_CSSPRIMITIVETYPE_Number:
- if (pWidth == NULL) {
- FX_FLOAT fValue;
- if (FDE_ParseCSSNumber(pszValue, iValueLen, fValue, eType)) {
- pWidth = NewNumberValue(pStaticStore, eType, fValue);
- }
- }
- break;
- case FDE_CSSPRIMITIVETYPE_RGB:
- if (pColor == NULL) {
- FX_ARGB dwColor;
- if (FDE_ParseCSSColor(pszValue, iValueLen, dwColor)) {
- pColor =
- FXTARGET_NewWith(pStaticStore) CFDE_CSSPrimitiveValue(dwColor);
- }
- }
- break;
- case FDE_CSSPRIMITIVETYPE_String: {
- const FDE_CSSCOLORTABLE* pColorItem =
- FDE_GetCSSColorByName(pszValue, iValueLen);
- if (pColorItem != NULL) {
- if (pColor == NULL) {
- pColor = FXTARGET_NewWith(pStaticStore)
- CFDE_CSSPrimitiveValue(pColorItem->dwValue);
- }
- continue;
- }
- const FDE_CSSPROPERTYVALUETABLE* pValue =
- FDE_GetCSSPropertyValueByName(pszValue, iValueLen);
- if (pValue == NULL) {
- continue;
- }
- switch (pValue->eName) {
- case FDE_CSSPROPERTYVALUE_Transparent:
- if (pColor == NULL) {
- pColor = FXTARGET_NewWith(pStaticStore)
- CFDE_CSSPrimitiveValue((FX_ARGB)0);
- }
- break;
- case FDE_CSSPROPERTYVALUE_Thin:
- case FDE_CSSPROPERTYVALUE_Thick:
- case FDE_CSSPROPERTYVALUE_Medium:
- if (pWidth == NULL) {
- pWidth = NewEnumValue(pStaticStore, pValue->eName);
- }
- break;
- case FDE_CSSPROPERTYVALUE_None:
- case FDE_CSSPROPERTYVALUE_Hidden:
- case FDE_CSSPROPERTYVALUE_Dotted:
- case FDE_CSSPROPERTYVALUE_Dashed:
- case FDE_CSSPROPERTYVALUE_Solid:
- case FDE_CSSPROPERTYVALUE_Double:
- case FDE_CSSPROPERTYVALUE_Groove:
- case FDE_CSSPROPERTYVALUE_Ridge:
- case FDE_CSSPROPERTYVALUE_Inset:
- case FDE_CSSPROPERTYVALUE_Outset:
- if (pStyle == NULL) {
- pStyle = NewEnumValue(pStaticStore, pValue->eName);
- }
- break;
- default:
- break;
- }
- }; break;
- default:
- break;
- }
- }
- if (pColor == NULL) {
- pColor = FXTARGET_NewWith(pStaticStore) CFDE_CSSPrimitiveValue((FX_ARGB)0);
- }
- if (pStyle == NULL) {
- pStyle = NewEnumValue(pStaticStore, FDE_CSSPROPERTYVALUE_None);
- }
- if (pWidth == NULL) {
- pWidth = NewNumberValue(pStaticStore, FDE_CSSPRIMITIVETYPE_Number, 0.0f);
- }
- return TRUE;
-}
-void CFDE_CSSDeclaration::AddBorderProperty(IFX_MEMAllocator* pStaticStore,
- IFDE_CSSValue* pColor,
- IFDE_CSSValue* pStyle,
- IFDE_CSSValue* pWidth,
- FX_BOOL bImportant,
- FDE_CSSPROPERTY eColor,
- FDE_CSSPROPERTY eStyle,
- FDE_CSSPROPERTY eWidth) {
- AddPropertyHolder(pStaticStore, eStyle, pStyle, bImportant);
- AddPropertyHolder(pStaticStore, eWidth, pWidth, bImportant);
- AddPropertyHolder(pStaticStore, eColor, pColor, bImportant);
-}
-FX_BOOL CFDE_CSSDeclaration::ParseListStyleProperty(
- const FDE_CSSPROPERTYARGS* pArgs,
- const FX_WCHAR* pszValue,
- int32_t iValueLen,
- FX_BOOL bImportant) {
- IFX_MEMAllocator* pStaticStore = pArgs->pStaticStore;
- CFDE_CSSValueListParser parser(pszValue, iValueLen, ' ');
- IFDE_CSSPrimitiveValue *pType = NULL, *pImage = NULL, *pPosition = NULL;
- FDE_CSSPRIMITIVETYPE eType;
- while (parser.NextValue(eType, pszValue, iValueLen)) {
- switch (eType) {
- case FDE_CSSPRIMITIVETYPE_URI:
- if (pImage == NULL) {
- pImage = FXTARGET_NewWith(pStaticStore) CFDE_CSSPrimitiveValue(
- eType, CopyToLocal(pArgs, pszValue, iValueLen));
- }
- break;
- case FDE_CSSPRIMITIVETYPE_String: {
- const FDE_CSSPROPERTYVALUETABLE* pValue =
- FDE_GetCSSPropertyValueByName(pszValue, iValueLen);
- if (pValue == NULL) {
- break;
- }
- switch (pValue->eName) {
- case FDE_CSSPROPERTYVALUE_None:
- if (pImage == NULL) {
- pImage = NewEnumValue(pStaticStore, pValue->eName);
- } else if (pType == NULL) {
- pImage = NewEnumValue(pStaticStore, pValue->eName);
- }
- break;
- case FDE_CSSPROPERTYVALUE_Inside:
- case FDE_CSSPROPERTYVALUE_Outside:
- if (pPosition == NULL) {
- pPosition = NewEnumValue(pStaticStore, pValue->eName);
- }
- break;
- case FDE_CSSPROPERTYVALUE_Disc:
- case FDE_CSSPROPERTYVALUE_Circle:
- case FDE_CSSPROPERTYVALUE_Square:
- case FDE_CSSPROPERTYVALUE_Decimal:
- case FDE_CSSPROPERTYVALUE_DecimalLeadingZero:
- case FDE_CSSPROPERTYVALUE_LowerRoman:
- case FDE_CSSPROPERTYVALUE_UpperRoman:
- case FDE_CSSPROPERTYVALUE_LowerGreek:
- case FDE_CSSPROPERTYVALUE_LowerLatin:
- case FDE_CSSPROPERTYVALUE_UpperLatin:
- case FDE_CSSPROPERTYVALUE_Armenian:
- case FDE_CSSPROPERTYVALUE_Georgian:
- case FDE_CSSPROPERTYVALUE_LowerAlpha:
- case FDE_CSSPROPERTYVALUE_UpperAlpha:
- if (pType == NULL) {
- pType = NewEnumValue(pStaticStore, pValue->eName);
- }
- break;
- default:
- break;
- }
- }; break;
- default:
- break;
- }
- }
- if (pPosition == NULL) {
- pPosition = NewEnumValue(pStaticStore, FDE_CSSPROPERTYVALUE_Outside);
- }
- if (pImage == NULL) {
- pImage = NewEnumValue(pStaticStore, FDE_CSSPROPERTYVALUE_None);
- }
- if (pType == NULL) {
- pType = NewEnumValue(pStaticStore, FDE_CSSPROPERTYVALUE_None);
- }
- AddPropertyHolder(pStaticStore, FDE_CSSPROPERTY_ListStylePosition, pPosition,
- bImportant);
- AddPropertyHolder(pStaticStore, FDE_CSSPROPERTY_ListStyleImage, pImage,
- bImportant);
- AddPropertyHolder(pStaticStore, FDE_CSSPROPERTY_ListStyleType, pType,
- bImportant);
- return TRUE;
-}
-FX_BOOL CFDE_CSSDeclaration::ParseBackgroundProperty(
- const FDE_CSSPROPERTYARGS* pArgs,
- const FX_WCHAR* pszValue,
- int32_t iValueLen,
- FX_BOOL bImportant) {
- IFX_MEMAllocator* pStaticStore = pArgs->pStaticStore;
- CFDE_CSSValueListParser parser(pszValue, iValueLen, ' ');
- IFDE_CSSPrimitiveValue *pColor = NULL, *pImage = NULL, *pRepeat = NULL;
- IFDE_CSSPrimitiveValue *pPosX = NULL, *pPosY = NULL, *pAttachment = NULL;
- FDE_CSSPRIMITIVETYPE eType;
- while (parser.NextValue(eType, pszValue, iValueLen)) {
- switch (eType) {
- case FDE_CSSPRIMITIVETYPE_URI:
- if (pImage == NULL) {
- pImage = FXTARGET_NewWith(pStaticStore) CFDE_CSSPrimitiveValue(
- eType, CopyToLocal(pArgs, pszValue, iValueLen));
- }
- break;
- case FDE_CSSPRIMITIVETYPE_Number: {
- FX_FLOAT fValue;
- if (!FDE_ParseCSSNumber(pszValue, iValueLen, fValue, eType)) {
- break;
- }
- if (pPosX == NULL) {
- pPosX = NewNumberValue(pStaticStore, eType, fValue);
- } else if (pPosY == NULL) {
- pPosY = NewNumberValue(pStaticStore, eType, fValue);
- }
- } break;
- case FDE_CSSPRIMITIVETYPE_String: {
- const FDE_CSSPROPERTYVALUETABLE* pValue =
- FDE_GetCSSPropertyValueByName(pszValue, iValueLen);
- if (pValue != NULL) {
- switch (pValue->eName) {
- case FDE_CSSPROPERTYVALUE_None:
- if (pImage == NULL) {
- pImage = NewEnumValue(pStaticStore, pValue->eName);
- }
- break;
- case FDE_CSSPROPERTYVALUE_Transparent:
- if (pColor == NULL) {
- pColor = FXTARGET_NewWith(pStaticStore)
- CFDE_CSSPrimitiveValue((FX_ARGB)0);
- }
- break;
- case FDE_CSSPROPERTYVALUE_Fixed:
- case FDE_CSSPROPERTYVALUE_Scroll:
- if (pAttachment == NULL) {
- pAttachment = NewEnumValue(pStaticStore, pValue->eName);
- }
- break;
- case FDE_CSSPROPERTYVALUE_Repeat:
- case FDE_CSSPROPERTYVALUE_RepeatX:
- case FDE_CSSPROPERTYVALUE_RepeatY:
- case FDE_CSSPROPERTYVALUE_NoRepeat:
- if (pRepeat == NULL) {
- pRepeat = NewEnumValue(pStaticStore, pValue->eName);
- }
- break;
- case FDE_CSSPROPERTYVALUE_Left:
- case FDE_CSSPROPERTYVALUE_Right:
- if (pPosX == NULL) {
- pPosX = NewEnumValue(pStaticStore, pValue->eName);
- }
- break;
- case FDE_CSSPROPERTYVALUE_Top:
- case FDE_CSSPROPERTYVALUE_Bottom:
- if (pPosY == NULL) {
- pPosX = NewEnumValue(pStaticStore, pValue->eName);
- }
- break;
- case FDE_CSSPROPERTYVALUE_Center:
- if (pPosX == NULL) {
- pPosX = NewEnumValue(pStaticStore, pValue->eName);
- } else if (pPosY == NULL) {
- pPosX = NewEnumValue(pStaticStore, pValue->eName);
- }
- break;
- default:
- break;
- }
- break;
- }
- const FDE_CSSCOLORTABLE* pColorItem =
- FDE_GetCSSColorByName(pszValue, iValueLen);
- if (pColorItem != NULL) {
- if (pColor == NULL) {
- pColor = FXTARGET_NewWith(pStaticStore)
- CFDE_CSSPrimitiveValue(pColorItem->dwValue);
- }
- }
- } break;
- case FDE_CSSPRIMITIVETYPE_RGB:
- if (pColor == NULL) {
- FX_ARGB dwColor;
- if (FDE_ParseCSSColor(pszValue, iValueLen, dwColor)) {
- pColor =
- FXTARGET_NewWith(pStaticStore) CFDE_CSSPrimitiveValue(dwColor);
- }
- }
- break;
- default:
- break;
- }
- }
- if (pColor == NULL) {
- pColor = FXTARGET_NewWith(pStaticStore) CFDE_CSSPrimitiveValue((FX_ARGB)0);
- }
- if (pImage == NULL) {
- pImage = NewEnumValue(pStaticStore, FDE_CSSPROPERTYVALUE_None);
- }
- if (pRepeat == NULL) {
- pRepeat = NewEnumValue(pStaticStore, FDE_CSSPROPERTYVALUE_Repeat);
- }
- if (pAttachment == NULL) {
- pAttachment = NewEnumValue(pStaticStore, FDE_CSSPROPERTYVALUE_Scroll);
- }
- if (pPosX == NULL) {
- pPosX = NewNumberValue(pStaticStore, FDE_CSSPRIMITIVETYPE_Number, 0.0f);
- pPosY = NewNumberValue(pStaticStore, FDE_CSSPRIMITIVETYPE_Number, 0.0f);
- } else if (pPosY == NULL) {
- pPosY = NewNumberValue(pStaticStore, FDE_CSSPRIMITIVETYPE_Number, 0.0f);
- }
- CFDE_CSSValueArray position;
- position.Add(pPosX);
- position.Add(pPosY);
- CFDE_CSSValueList* pPosList =
- FXTARGET_NewWith(pStaticStore) CFDE_CSSValueList(pStaticStore, position);
- AddPropertyHolder(pStaticStore, FDE_CSSPROPERTY_BackgroundColor, pColor,
- bImportant);
- AddPropertyHolder(pStaticStore, FDE_CSSPROPERTY_BackgroundImage, pImage,
- bImportant);
- AddPropertyHolder(pStaticStore, FDE_CSSPROPERTY_BackgroundRepeat, pRepeat,
- bImportant);
- AddPropertyHolder(pStaticStore, FDE_CSSPROPERTY_BackgroundPosition, pPosList,
- bImportant);
- AddPropertyHolder(pStaticStore, FDE_CSSPROPERTY_BackgroundAttachment,
- pAttachment, bImportant);
- return TRUE;
-}
-FX_BOOL CFDE_CSSDeclaration::ParseFontProperty(const FDE_CSSPROPERTYARGS* pArgs,
- const FX_WCHAR* pszValue,
- int32_t iValueLen,
- FX_BOOL bImportant) {
- IFX_MEMAllocator* pStaticStore = pArgs->pStaticStore;
- CFDE_CSSValueListParser parser(pszValue, iValueLen, '/');
- IFDE_CSSPrimitiveValue *pStyle = NULL, *pVariant = NULL, *pWeight = NULL;
- IFDE_CSSPrimitiveValue *pFontSize = NULL, *pLineHeight = NULL;
- CFDE_CSSValueArray familyList;
- FDE_CSSPRIMITIVETYPE eType;
- while (parser.NextValue(eType, pszValue, iValueLen)) {
- switch (eType) {
- case FDE_CSSPRIMITIVETYPE_String: {
- const FDE_CSSPROPERTYVALUETABLE* pValue =
- FDE_GetCSSPropertyValueByName(pszValue, iValueLen);
- if (pValue != NULL) {
- switch (pValue->eName) {
- case FDE_CSSPROPERTYVALUE_XxSmall:
- case FDE_CSSPROPERTYVALUE_XSmall:
- case FDE_CSSPROPERTYVALUE_Small:
- case FDE_CSSPROPERTYVALUE_Medium:
- case FDE_CSSPROPERTYVALUE_Large:
- case FDE_CSSPROPERTYVALUE_XLarge:
- case FDE_CSSPROPERTYVALUE_XxLarge:
- case FDE_CSSPROPERTYVALUE_Smaller:
- case FDE_CSSPROPERTYVALUE_Larger:
- if (pFontSize == NULL) {
- pFontSize = NewEnumValue(pStaticStore, pValue->eName);
- }
- continue;
- case FDE_CSSPROPERTYVALUE_Bold:
- case FDE_CSSPROPERTYVALUE_Bolder:
- case FDE_CSSPROPERTYVALUE_Lighter:
- if (pWeight == NULL) {
- pWeight = NewEnumValue(pStaticStore, pValue->eName);
- }
- continue;
- case FDE_CSSPROPERTYVALUE_Italic:
- case FDE_CSSPROPERTYVALUE_Oblique:
- if (pStyle == NULL) {
- pStyle = NewEnumValue(pStaticStore, pValue->eName);
- }
- continue;
- case FDE_CSSPROPERTYVALUE_SmallCaps:
- if (pVariant == NULL) {
- pVariant = NewEnumValue(pStaticStore, pValue->eName);
- }
- continue;
- case FDE_CSSPROPERTYVALUE_Normal:
- if (pStyle == NULL) {
- pStyle = NewEnumValue(pStaticStore, pValue->eName);
- } else if (pVariant == NULL) {
- pVariant = NewEnumValue(pStaticStore, pValue->eName);
- } else if (pWeight == NULL) {
- pWeight = NewEnumValue(pStaticStore, pValue->eName);
- } else if (pFontSize == NULL) {
- pFontSize = NewEnumValue(pStaticStore, pValue->eName);
- } else if (pLineHeight == NULL) {
- pLineHeight = NewEnumValue(pStaticStore, pValue->eName);
- }
- continue;
- default:
- break;
- }
- }
- if (pFontSize != NULL) {
- familyList.Add(FXTARGET_NewWith(pStaticStore) CFDE_CSSPrimitiveValue(
- eType, CopyToLocal(pArgs, pszValue, iValueLen)));
- }
- parser.m_Separator = ',';
- } break;
- case FDE_CSSPRIMITIVETYPE_Number: {
- FX_FLOAT fValue;
- if (!FDE_ParseCSSNumber(pszValue, iValueLen, fValue, eType)) {
- break;
- }
- if (eType == FDE_CSSPRIMITIVETYPE_Number) {
- switch ((int32_t)fValue) {
- case 100:
- case 200:
- case 300:
- case 400:
- case 500:
- case 600:
- case 700:
- case 800:
- case 900:
- if (pWeight == NULL) {
- pWeight = NewNumberValue(pStaticStore,
- FDE_CSSPRIMITIVETYPE_Number, fValue);
- }
- continue;
- }
- }
- if (pFontSize == NULL) {
- pFontSize = NewNumberValue(pStaticStore, eType, fValue);
- } else if (pLineHeight == NULL) {
- pLineHeight = NewNumberValue(pStaticStore, eType, fValue);
- }
- } break;
- default:
- break;
- }
- }
- if (pStyle == NULL) {
- pStyle = NewEnumValue(pStaticStore, FDE_CSSPROPERTYVALUE_Normal);
- }
- if (pVariant == NULL) {
- pVariant = NewEnumValue(pStaticStore, FDE_CSSPROPERTYVALUE_Normal);
- }
- if (pWeight == NULL) {
- pWeight = NewEnumValue(pStaticStore, FDE_CSSPROPERTYVALUE_Normal);
- }
- if (pFontSize == NULL) {
- pFontSize = NewEnumValue(pStaticStore, FDE_CSSPROPERTYVALUE_Medium);
- }
- if (pLineHeight == NULL) {
- pLineHeight = NewEnumValue(pStaticStore, FDE_CSSPROPERTYVALUE_Normal);
- }
- AddPropertyHolder(pStaticStore, FDE_CSSPROPERTY_FontStyle, pStyle,
- bImportant);
- AddPropertyHolder(pStaticStore, FDE_CSSPROPERTY_FontVariant, pVariant,
- bImportant);
- AddPropertyHolder(pStaticStore, FDE_CSSPROPERTY_FontWeight, pWeight,
- bImportant);
- AddPropertyHolder(pStaticStore, FDE_CSSPROPERTY_FontSize, pFontSize,
- bImportant);
- AddPropertyHolder(pStaticStore, FDE_CSSPROPERTY_LineHeight, pLineHeight,
- bImportant);
- if (familyList.GetSize() > 0) {
- CFDE_CSSValueList* pList = FXTARGET_NewWith(pStaticStore)
- CFDE_CSSValueList(pStaticStore, familyList);
- AddPropertyHolder(pStaticStore, FDE_CSSPROPERTY_FontFamily, pList,
- bImportant);
- }
- return TRUE;
-}
-FX_BOOL CFDE_CSSDeclaration::ParseColumnRuleProperty(
- const FDE_CSSPROPERTYARGS* pArgs,
- const FX_WCHAR* pszValue,
- int32_t iValueLen,
- FX_BOOL bImportant) {
- IFX_MEMAllocator* pStaticStore = pArgs->pStaticStore;
- CFDE_CSSValueListParser parser(pszValue, iValueLen, ' ');
- IFDE_CSSPrimitiveValue* pColumnRuleWidth = NULL;
- IFDE_CSSPrimitiveValue* pColumnRuleStyle = NULL;
- IFDE_CSSPrimitiveValue* pColumnRuleColor = NULL;
- FDE_CSSPRIMITIVETYPE eType;
- while (parser.NextValue(eType, pszValue, iValueLen)) {
- switch (eType) {
- case FDE_CSSPRIMITIVETYPE_String: {
- const FDE_CSSPROPERTYVALUETABLE* pValue =
- FDE_GetCSSPropertyValueByName(pszValue, iValueLen);
- if (pValue != NULL) {
- switch (pValue->eName) {
- case FDE_CSSPROPERTYVALUE_None:
- case FDE_CSSPROPERTYVALUE_Hidden:
- case FDE_CSSPROPERTYVALUE_Dotted:
- case FDE_CSSPROPERTYVALUE_Dashed:
- case FDE_CSSPROPERTYVALUE_Solid:
- case FDE_CSSPROPERTYVALUE_Double:
- case FDE_CSSPROPERTYVALUE_Groove:
- case FDE_CSSPROPERTYVALUE_Ridge:
- case FDE_CSSPROPERTYVALUE_Inset:
- case FDE_CSSPROPERTYVALUE_Outset:
- if (pColumnRuleStyle == NULL) {
- pColumnRuleStyle = NewEnumValue(pStaticStore, pValue->eName);
- }
- break;
- case FDE_CSSPROPERTYVALUE_Transparent:
- if (pColumnRuleColor == NULL) {
- pColumnRuleColor = NewEnumValue(pStaticStore, pValue->eName);
- }
- break;
- case FDE_CSSPROPERTYVALUE_Thin:
- case FDE_CSSPROPERTYVALUE_Medium:
- case FDE_CSSPROPERTYVALUE_Thick:
- if (pColumnRuleWidth == NULL) {
- pColumnRuleWidth = NewEnumValue(pStaticStore, pValue->eName);
- }
- break;
- default:
- break;
- }
- continue;
- }
- FX_ARGB dwColor;
- if (FDE_ParseCSSColor(pszValue, iValueLen, dwColor) &&
- pColumnRuleColor == NULL) {
- pColumnRuleColor = FXTARGET_NewWith(pStaticStore)
- CFDE_CSSPrimitiveValue((FX_ARGB)dwColor);
- continue;
- }
- } break;
- case FDE_CSSPRIMITIVETYPE_Number: {
- FX_FLOAT fValue;
- if (FDE_ParseCSSNumber(pszValue, iValueLen, fValue, eType) &&
- pColumnRuleWidth == NULL) {
- pColumnRuleWidth = NewNumberValue(pStaticStore, eType, fValue);
- }
- } break;
- case FDE_CSSPRIMITIVETYPE_RGB: {
- FX_ARGB dwColor;
- if (pColumnRuleColor == NULL &&
- FDE_ParseCSSColor(pszValue, iValueLen, dwColor)) {
- pColumnRuleColor = FXTARGET_NewWith(pStaticStore)
- CFDE_CSSPrimitiveValue((FX_ARGB)dwColor);
- }
- } break;
- default:
- break;
- }
- }
- if (pColumnRuleColor == NULL && pColumnRuleStyle == NULL &&
- pColumnRuleWidth == NULL) {
- return FALSE;
- }
- if (pColumnRuleStyle == NULL) {
- pColumnRuleStyle = NewEnumValue(pStaticStore, FDE_CSSPROPERTYVALUE_None);
- }
- if (pColumnRuleWidth == NULL) {
- pColumnRuleWidth = NewEnumValue(pStaticStore, FDE_CSSPROPERTYVALUE_Medium);
- }
- if (pColumnRuleColor == NULL) {
- pColumnRuleColor =
- FXTARGET_NewWith(pStaticStore) CFDE_CSSPrimitiveValue((FX_ARGB)0);
- }
- AddPropertyHolder(pStaticStore, FDE_CSSPROPERTY_ColumnRuleStyle,
- pColumnRuleStyle, bImportant);
- AddPropertyHolder(pStaticStore, FDE_CSSPROPERTY_ColumnRuleWidth,
- pColumnRuleWidth, bImportant);
- AddPropertyHolder(pStaticStore, FDE_CSSPROPERTY_ColumnRuleColor,
- pColumnRuleColor, bImportant);
- return TRUE;
-}
-FX_BOOL CFDE_CSSDeclaration::ParseTextEmphasisProperty(
- FDE_CSSPROPERTYARGS* pArgs,
- const FX_WCHAR* pszValue,
- int32_t iValueLen,
- FX_BOOL bImportant) {
- IFX_MEMAllocator* pStaticStore = pArgs->pStaticStore;
- CFDE_CSSValueListParser parser(pszValue, iValueLen, ' ');
- CFDE_CSSValueArray arrEmphasisStyle;
- FDE_CSSPRIMITIVETYPE eType;
- IFDE_CSSPrimitiveValue* pEmphasisColor = NULL;
- while (parser.NextValue(eType, pszValue, iValueLen)) {
- switch (eType) {
- case FDE_CSSPRIMITIVETYPE_String: {
- const FDE_CSSPROPERTYVALUETABLE* pValue =
- FDE_GetCSSPropertyValueByName(pszValue, iValueLen);
- if (pValue != NULL) {
- arrEmphasisStyle.Add(NewEnumValue(pStaticStore, pValue->eName));
- continue;
- }
- FX_ARGB dwColor;
- if (FDE_ParseCSSColor(pszValue, iValueLen, dwColor)) {
- pEmphasisColor =
- FXTARGET_NewWith(pStaticStore) CFDE_CSSPrimitiveValue(dwColor);
- continue;
- }
- pszValue = CopyToLocal(pArgs, pszValue, iValueLen);
- arrEmphasisStyle.Add(
- FXTARGET_NewWith(pStaticStore)
- CFDE_CSSPrimitiveValue(FDE_CSSPRIMITIVETYPE_String, pszValue));
- } break;
- case FDE_CSSPRIMITIVETYPE_RGB: {
- FX_ARGB dwColor;
- if (FDE_ParseCSSColor(pszValue, iValueLen, dwColor)) {
- pEmphasisColor =
- FXTARGET_NewWith(pStaticStore) CFDE_CSSPrimitiveValue(dwColor);
- }
- } break;
- default:
- break;
- }
- }
- if (arrEmphasisStyle.GetSize() != 0) {
- AddPropertyHolder(pStaticStore, FDE_CSSPROPERTY_TextEmphasisStyle,
- FXTARGET_NewWith(pStaticStore)
- CFDE_CSSValueList(pStaticStore, arrEmphasisStyle),
- bImportant);
- }
- if (pEmphasisColor != NULL) {
- AddPropertyHolder(pStaticStore, FDE_CSSPROPERTY_TextEmphasisColor,
- pEmphasisColor, bImportant);
- }
- return TRUE;
-}
-FX_BOOL CFDE_CSSDeclaration::ParseColumnsProperty(
- const FDE_CSSPROPERTYARGS* pArgs,
- const FX_WCHAR* pszValue,
- int32_t iValueLen,
- FX_BOOL bImportant) {
- IFX_MEMAllocator* pStaticStore = pArgs->pStaticStore;
- CFDE_CSSValueListParser parser(pszValue, iValueLen, ' ');
- IFDE_CSSPrimitiveValue* pColumnWidth = NULL;
- IFDE_CSSPrimitiveValue* pColumnCount = NULL;
- FDE_CSSPRIMITIVETYPE eType;
- while (parser.NextValue(eType, pszValue, iValueLen)) {
- switch (eType) {
- case FDE_CSSPRIMITIVETYPE_String: {
- const FDE_CSSPROPERTYVALUETABLE* pValue =
- FDE_GetCSSPropertyValueByName(pszValue, iValueLen);
- if (pValue == NULL && pValue->eName == FDE_CSSPROPERTYVALUE_Auto) {
- pColumnWidth = NewEnumValue(pStaticStore, pValue->eName);
- }
- } break;
- case FDE_CSSPRIMITIVETYPE_Number: {
- FX_FLOAT fValue;
- if (FDE_ParseCSSNumber(pszValue, iValueLen, fValue, eType)) {
- switch (eType) {
- case FDE_CSSPRIMITIVETYPE_Number:
- if (pColumnCount == NULL) {
- pColumnCount = NewNumberValue(pStaticStore, eType, fValue);
- }
- break;
- default:
- if (pColumnWidth == NULL) {
- pColumnWidth = NewNumberValue(pStaticStore, eType, fValue);
- }
- break;
- }
- }
- } break;
- default:
- break;
- }
- }
- if (pColumnWidth == NULL && pColumnCount == NULL) {
- return FALSE;
- } else if (pColumnWidth == NULL) {
- pColumnWidth = NewEnumValue(pStaticStore, FDE_CSSPROPERTYVALUE_Auto);
- } else if (pColumnCount == NULL) {
- pColumnCount = NewEnumValue(pStaticStore, FDE_CSSPROPERTYVALUE_Auto);
- }
- AddPropertyHolder(pStaticStore, FDE_CSSPROPERTY_ColumnWidth, pColumnWidth,
- bImportant);
- AddPropertyHolder(pStaticStore, FDE_CSSPROPERTY_ColumnCount, pColumnCount,
- bImportant);
- return TRUE;
-}
-FX_BOOL CFDE_CSSDeclaration::ParseOverflowProperty(
- const FDE_CSSPROPERTYARGS* pArgs,
- const FX_WCHAR* pszValue,
- int32_t iValueLen,
- FX_BOOL bImportant) {
- IFX_MEMAllocator* pStaticStore = pArgs->pStaticStore;
- CFDE_CSSValueListParser parser(pszValue, iValueLen, ' ');
- IFDE_CSSPrimitiveValue* pOverflowX = NULL;
- IFDE_CSSPrimitiveValue* pOverflowY = NULL;
- FDE_CSSPRIMITIVETYPE eType;
- while (parser.NextValue(eType, pszValue, iValueLen)) {
- if (eType == FDE_CSSPRIMITIVETYPE_String) {
- const FDE_CSSPROPERTYVALUETABLE* pValue =
- FDE_GetCSSPropertyValueByName(pszValue, iValueLen);
- if (pValue != NULL) {
- switch (pValue->eName) {
- case FDE_CSSOVERFLOW_Visible:
- case FDE_CSSOVERFLOW_Hidden:
- case FDE_CSSOVERFLOW_Scroll:
- case FDE_CSSOVERFLOW_Auto:
- case FDE_CSSOVERFLOW_NoDisplay:
- case FDE_CSSOVERFLOW_NoContent:
- if (pOverflowX != NULL && pOverflowY != NULL) {
- return FALSE;
- } else if (pOverflowX == NULL) {
- pOverflowX = NewEnumValue(pStaticStore, pValue->eName);
- } else if (pOverflowY == NULL) {
- pOverflowY = NewEnumValue(pStaticStore, pValue->eName);
- }
- break;
- default:
- break;
- }
- }
- }
- }
- if (pOverflowX == NULL && pOverflowY == NULL) {
- return FALSE;
- } else if (pOverflowY == NULL) {
- pOverflowY = NewEnumValue(pStaticStore, pOverflowX->GetEnum());
- }
- AddPropertyHolder(pStaticStore, FDE_CSSPROPERTY_OverflowX, pOverflowX,
- bImportant);
- AddPropertyHolder(pStaticStore, FDE_CSSPROPERTY_OverflowY, pOverflowY,
- bImportant);
- return TRUE;
-}
diff --git a/xfa/src/fde/css/fde_cssdeclaration.h b/xfa/src/fde/css/fde_cssdeclaration.h
deleted file mode 100644
index 9866b20f4c..0000000000
--- a/xfa/src/fde/css/fde_cssdeclaration.h
+++ /dev/null
@@ -1,158 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifndef XFA_SRC_FDE_CSS_FDE_CSSDECLARATION_H_
-#define XFA_SRC_FDE_CSS_FDE_CSSDECLARATION_H_
-
-#include "xfa/src/fde/css/fde_cssdatatable.h"
-
-class FDE_CSSPropertyHolder : public CFX_Target {
- public:
- int16_t eProperty;
- int16_t bImportant;
- IFDE_CSSValue* pValue;
- FDE_CSSPropertyHolder* pNext;
-};
-
-class FDE_CSSCustomProperty : public CFX_Target {
- public:
- const FX_WCHAR* pwsName;
- const FX_WCHAR* pwsValue;
- FDE_CSSCustomProperty* pNext;
-};
-
-struct FDE_CSSPROPERTYARGS {
- IFX_MEMAllocator* pStaticStore;
- CFX_MapPtrToPtr* pStringCache;
- FDE_LPCCSSPROPERTYTABLE pProperty;
-};
-
-class CFDE_CSSDeclaration : public IFDE_CSSDeclaration, public CFX_Target {
- public:
- CFDE_CSSDeclaration()
- : m_pFirstProperty(NULL),
- m_pLastProperty(NULL),
- m_pFirstCustom(NULL),
- m_pLastCustom(NULL) {}
- virtual IFDE_CSSValue* GetProperty(FDE_CSSPROPERTY eProperty,
- FX_BOOL& bImportant) const;
- virtual FX_POSITION GetStartPosition() const;
- virtual void GetNextProperty(FX_POSITION& pos,
- FDE_CSSPROPERTY& eProperty,
- IFDE_CSSValue*& pValue,
- FX_BOOL& bImportant) const;
- virtual FX_POSITION GetStartCustom() const;
- virtual void GetNextCustom(FX_POSITION& pos,
- CFX_WideString& wsName,
- CFX_WideString& wsValue) const;
- FX_BOOL AddProperty(const FDE_CSSPROPERTYARGS* pArgs,
- const FX_WCHAR* pszValue,
- int32_t iValueLen);
- FX_BOOL AddProperty(const FDE_CSSPROPERTYARGS* pArgs,
- const FX_WCHAR* pszName,
- int32_t iNameLen,
- const FX_WCHAR* pszValue,
- int32_t iValueLen);
-
- protected:
- FX_BOOL ParseTextEmphasisProperty(FDE_CSSPROPERTYARGS* pArgs,
- const FX_WCHAR* pszValue,
- int32_t iValueLen,
- FX_BOOL bImportant);
- FX_BOOL ParseColumnsProperty(const FDE_CSSPROPERTYARGS* pArgs,
- const FX_WCHAR* pszValue,
- int32_t iValueLen,
- FX_BOOL bImportant);
- FX_BOOL ParseColumnRuleProperty(const FDE_CSSPROPERTYARGS* pArgs,
- const FX_WCHAR* pszValue,
- int32_t iValueLen,
- FX_BOOL bImportant);
- FX_BOOL ParseOverflowProperty(const FDE_CSSPROPERTYARGS* pArgs,
- const FX_WCHAR* pszValue,
- int32_t iValueLen,
- FX_BOOL bImportant);
- FX_BOOL ParseFontProperty(const FDE_CSSPROPERTYARGS* pArgs,
- const FX_WCHAR* pszValue,
- int32_t iValueLen,
- FX_BOOL bImportant);
- FX_BOOL ParseBackgroundProperty(const FDE_CSSPROPERTYARGS* pArgs,
- const FX_WCHAR* pszValue,
- int32_t iValueLen,
- FX_BOOL bImportant);
- FX_BOOL ParseListStyleProperty(const FDE_CSSPROPERTYARGS* pArgs,
- const FX_WCHAR* pszValue,
- int32_t iValueLen,
- FX_BOOL bImportant);
- FX_BOOL ParseBorderPropoerty(IFX_MEMAllocator* pStaticStore,
- const FX_WCHAR* pszValue,
- int32_t iValueLen,
- IFDE_CSSValue*& pColor,
- IFDE_CSSValue*& pStyle,
- IFDE_CSSValue*& pWidth) const;
- void AddBorderProperty(IFX_MEMAllocator* pStaticStore,
- IFDE_CSSValue* pColor,
- IFDE_CSSValue* pStyle,
- IFDE_CSSValue* pWidth,
- FX_BOOL bImportant,
- FDE_CSSPROPERTY eColor,
- FDE_CSSPROPERTY eStyle,
- FDE_CSSPROPERTY eWidth);
- FX_BOOL ParseContentProperty(const FDE_CSSPROPERTYARGS* pArgs,
- const FX_WCHAR* pszValue,
- int32_t iValueLen,
- FX_BOOL bImportant);
- FX_BOOL ParseCounterProperty(const FDE_CSSPROPERTYARGS* pArgs,
- const FX_WCHAR* pszValue,
- int32_t iValueLen,
- FX_BOOL bImportant);
- FX_BOOL ParseValueListProperty(const FDE_CSSPROPERTYARGS* pArgs,
- const FX_WCHAR* pszValue,
- int32_t iValueLen,
- FX_BOOL bImportant);
- FX_BOOL Add4ValuesProperty(IFX_MEMAllocator* pStaticStore,
- const CFDE_CSSValueArray& list,
- FX_BOOL bImportant,
- FDE_CSSPROPERTY eLeft,
- FDE_CSSPROPERTY eTop,
- FDE_CSSPROPERTY eRight,
- FDE_CSSPROPERTY eBottom);
- IFDE_CSSValue* ParseNumber(const FDE_CSSPROPERTYARGS* pArgs,
- const FX_WCHAR* pszValue,
- int32_t iValueLen);
- IFDE_CSSValue* ParseEnum(const FDE_CSSPROPERTYARGS* pArgs,
- const FX_WCHAR* pszValue,
- int32_t iValueLen);
- IFDE_CSSValue* ParseColor(const FDE_CSSPROPERTYARGS* pArgs,
- const FX_WCHAR* pszValue,
- int32_t iValueLen);
- IFDE_CSSValue* ParseURI(const FDE_CSSPROPERTYARGS* pArgs,
- const FX_WCHAR* pszValue,
- int32_t iValueLen);
- IFDE_CSSValue* ParseString(const FDE_CSSPROPERTYARGS* pArgs,
- const FX_WCHAR* pszValue,
- int32_t iValueLen);
- IFDE_CSSValue* ParseFunction(const FDE_CSSPROPERTYARGS* pArgs,
- const FX_WCHAR* pszValue,
- int32_t iValueLen);
- const FX_WCHAR* CopyToLocal(const FDE_CSSPROPERTYARGS* pArgs,
- const FX_WCHAR* pszValue,
- int32_t iValueLen);
- void AddPropertyHolder(IFX_MEMAllocator* pStaticStore,
- FDE_CSSPROPERTY eProperty,
- IFDE_CSSValue* pValue,
- FX_BOOL bImportant);
- IFDE_CSSPrimitiveValue* NewNumberValue(IFX_MEMAllocator* pStaticStore,
- FDE_CSSPRIMITIVETYPE eUnit,
- FX_FLOAT fValue) const;
- IFDE_CSSPrimitiveValue* NewEnumValue(IFX_MEMAllocator* pStaticStore,
- FDE_CSSPROPERTYVALUE eValue) const;
- FDE_CSSPropertyHolder* m_pFirstProperty;
- FDE_CSSPropertyHolder* m_pLastProperty;
- FDE_CSSCustomProperty* m_pFirstCustom;
- FDE_CSSCustomProperty* m_pLastCustom;
-};
-
-#endif // XFA_SRC_FDE_CSS_FDE_CSSDECLARATION_H_
diff --git a/xfa/src/fde/css/fde_cssstyleselector.cpp b/xfa/src/fde/css/fde_cssstyleselector.cpp
deleted file mode 100644
index ff82f9d956..0000000000
--- a/xfa/src/fde/css/fde_cssstyleselector.cpp
+++ /dev/null
@@ -1,1794 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#include "xfa/src/fde/css/fde_cssstyleselector.h"
-
-#include <algorithm>
-
-#include "xfa/src/fde/css/fde_csscache.h"
-#include "xfa/src/fde/css/fde_cssdeclaration.h"
-
-int32_t CFDE_CSSCounterStyle::FindIndex(const FX_WCHAR* pszIdentifier) {
- int32_t iCount = m_arrCounterData.GetSize();
- for (int32_t i = 0; i < iCount; i++) {
- if (FXSYS_wcscmp(pszIdentifier, m_arrCounterData.ElementAt(i).m_pszIdent) ==
- 0) {
- return i;
- }
- }
- return -1;
-}
-void CFDE_CSSCounterStyle::DoUpdateIndex(IFDE_CSSValueList* pList) {
- if (pList == NULL) {
- return;
- }
- int32_t iCount = pList->CountValues();
- FX_FLOAT fDefValue = 1.0;
- FX_BOOL bDefIncrement = TRUE;
- if (pList == m_pCounterReset) {
- fDefValue = 0.0;
- bDefIncrement = FALSE;
- }
- for (int32_t i = 0; i < iCount; i++) {
- IFDE_CSSValueList* pCounter = (IFDE_CSSValueList*)pList->GetValue(i);
- int32_t iLen;
- const FX_WCHAR* pszIdentifier =
- ((IFDE_CSSPrimitiveValue*)(pCounter->GetValue(0)))->GetString(iLen);
- FX_FLOAT fValue = fDefValue;
- if (pCounter->CountValues() > 1) {
- fValue = ((IFDE_CSSPrimitiveValue*)(pCounter->GetValue(1)))->GetFloat();
- }
- int32_t iIndex = FindIndex(pszIdentifier);
- if (iIndex == -1) {
- FDE_CSSCOUNTERDATA data;
- data.m_pszIdent = pszIdentifier;
- if (bDefIncrement) {
- data.m_bIncrement = TRUE;
- data.m_iIncVal = (int32_t)fValue;
- } else {
- data.m_iResetVal = (int32_t)fValue;
- data.m_bReset = TRUE;
- }
- m_arrCounterData.Add(data);
- } else {
- FDE_CSSCOUNTERDATA& data = m_arrCounterData.ElementAt(iIndex);
- if (bDefIncrement) {
- data.m_bIncrement = TRUE;
- data.m_iIncVal += (int32_t)fValue;
- } else {
- data.m_bReset = TRUE;
- data.m_iResetVal = (int32_t)fValue;
- }
- }
- }
-}
-void CFDE_CSSCounterStyle::UpdateIndex() {
- if (!m_bIndexDirty) {
- return;
- }
- m_arrCounterData.RemoveAll();
- DoUpdateIndex(m_pCounterInc);
- DoUpdateIndex(m_pCounterReset);
- m_bIndexDirty = FALSE;
-}
-FDE_CSSTEXTEMPHASISMARK CFDE_CSSComputedStyle::GetTextEmphasisMark() const {
- if (m_InheritedData.m_eTextEmphasisMark != FDE_CSSTEXTEMPHASISMARK_Auto) {
- return (FDE_CSSTEXTEMPHASISMARK)m_InheritedData.m_eTextEmphasisMark;
- }
- if (m_InheritedData.m_eWritingMode == FDE_CSSWRITINGMODE_HorizontalTb) {
- return FDE_CSSTEXTEMPHASISMARK_Dot;
- }
- return FDE_CSSTEXTEMPHASISMARK_Sesame;
-}
-FDE_CSSRuleData::FDE_CSSRuleData(IFDE_CSSSelector* pSel,
- IFDE_CSSDeclaration* pDecl,
- FX_DWORD dwPos)
- : pSelector(pSel), pDeclaration(pDecl), dwPriority(dwPos), pNext(NULL) {
- static const FX_DWORD s_Specific[5] = {0x00010000, 0x00010000, 0x00100000,
- 0x00100000, 0x01000000};
- for (; pSel != NULL; pSel = pSel->GetNextSelector()) {
- FDE_CSSSELECTORTYPE eType = pSel->GetType();
- if (eType > FDE_CSSSELECTORTYPE_Descendant ||
- pSel->GetNameHash() != FDE_CSSUNIVERSALHASH) {
- dwPriority += s_Specific[eType];
- }
- }
-}
-void CFDE_CSSRuleCollection::Clear() {
- m_IDRules.RemoveAll();
- m_TagRules.RemoveAll();
- m_ClassRules.RemoveAll();
- m_pUniversalRules = NULL;
- m_pStaticStore = NULL;
- m_iSelectors = 0;
-}
-void CFDE_CSSRuleCollection::AddRulesFrom(const CFDE_CSSStyleSheetArray& sheets,
- FX_DWORD dwMediaList,
- IFX_FontMgr* pFontMgr) {
- int32_t iSheets = sheets.GetSize();
- for (int32_t i = 0; i < iSheets; ++i) {
- IFDE_CSSStyleSheet* pSheet = sheets.GetAt(i);
- if (FX_DWORD dwMatchMedia = pSheet->GetMediaList() & dwMediaList) {
- int32_t iRules = pSheet->CountRules();
- for (int32_t j = 0; j < iRules; j++) {
- AddRulesFrom(pSheet, pSheet->GetRule(j), dwMatchMedia, pFontMgr);
- }
- }
- }
-}
-void CFDE_CSSRuleCollection::AddRulesFrom(IFDE_CSSStyleSheet* pStyleSheet,
- IFDE_CSSRule* pRule,
- FX_DWORD dwMediaList,
- IFX_FontMgr* pFontMgr) {
- switch (pRule->GetType()) {
- case FDE_CSSRULETYPE_Style: {
- IFDE_CSSStyleRule* pStyleRule = (IFDE_CSSStyleRule*)pRule;
- IFDE_CSSDeclaration* pDeclaration = pStyleRule->GetDeclaration();
- int32_t iSelectors = pStyleRule->CountSelectorLists();
- for (int32_t i = 0; i < iSelectors; ++i) {
- IFDE_CSSSelector* pSelector = pStyleRule->GetSelectorList(i);
- if (pSelector->GetType() == FDE_CSSSELECTORTYPE_Persudo) {
- FDE_CSSRuleData* pData = NewRuleData(pSelector, pDeclaration);
- AddRuleTo(m_pPersudoRules, pData);
- continue;
- }
- if (pSelector->GetNameHash() != FDE_CSSUNIVERSALHASH) {
- AddRuleTo(m_TagRules, pSelector->GetNameHash(), pSelector,
- pDeclaration);
- continue;
- }
- IFDE_CSSSelector* pNext = pSelector->GetNextSelector();
- if (pNext == NULL) {
- FDE_CSSRuleData* pData = NewRuleData(pSelector, pDeclaration);
- AddRuleTo(m_pUniversalRules, pData);
- continue;
- }
- switch (pNext->GetType()) {
- case FDE_CSSSELECTORTYPE_ID:
- AddRuleTo(m_IDRules, pNext->GetNameHash(), pSelector, pDeclaration);
- break;
- case FDE_CSSSELECTORTYPE_Class:
- AddRuleTo(m_ClassRules, pNext->GetNameHash(), pSelector,
- pDeclaration);
- break;
- case FDE_CSSSELECTORTYPE_Descendant:
- case FDE_CSSSELECTORTYPE_Element:
- AddRuleTo(m_pUniversalRules, NewRuleData(pSelector, pDeclaration));
- break;
- default:
- FXSYS_assert(FALSE);
- break;
- }
- }
- } break;
- case FDE_CSSRULETYPE_Media: {
- IFDE_CSSMediaRule* pMediaRule = (IFDE_CSSMediaRule*)pRule;
- if (pMediaRule->GetMediaList() & dwMediaList) {
- int32_t iRules = pMediaRule->CountRules();
- for (int32_t i = 0; i < iRules; ++i) {
- AddRulesFrom(pStyleSheet, pMediaRule->GetRule(i), dwMediaList,
- pFontMgr);
- }
- }
- } break;
- default:
- break;
- }
-}
-void CFDE_CSSRuleCollection::AddRuleTo(CFX_MapPtrToPtr& map,
- FX_DWORD dwKey,
- IFDE_CSSSelector* pSel,
- IFDE_CSSDeclaration* pDecl) {
- void* pKey = (void*)(uintptr_t)dwKey;
- FDE_CSSRuleData* pData = NewRuleData(pSel, pDecl);
- FDE_CSSRuleData* pList = NULL;
- if (!map.Lookup(pKey, (void*&)pList)) {
- map.SetAt(pKey, pData);
- } else if (AddRuleTo(pList, pData)) {
- map.SetAt(pKey, pList);
- }
-}
-
-FX_BOOL CFDE_CSSRuleCollection::AddRuleTo(FDE_CSSRuleData*& pList,
- FDE_CSSRuleData* pData) {
- if (pList) {
- pData->pNext = pList->pNext;
- pList->pNext = pData;
- return FALSE;
- }
-
- pList = pData;
- return TRUE;
-}
-
-FDE_CSSRuleData* CFDE_CSSRuleCollection::NewRuleData(
- IFDE_CSSSelector* pSel,
- IFDE_CSSDeclaration* pDecl) {
- return FXTARGET_NewWith(m_pStaticStore)
- FDE_CSSRuleData(pSel, pDecl, ++m_iSelectors);
-}
-
-IFDE_CSSStyleSelector* IFDE_CSSStyleSelector::Create() {
- return new CFDE_CSSStyleSelector;
-}
-CFDE_CSSStyleSelector::CFDE_CSSStyleSelector()
- : m_pFontMgr(NULL),
- m_fDefFontSize(12.0f),
- m_pRuleDataStore(NULL),
- m_pInlineStyleStore(NULL),
- m_pFixedStyleStore(NULL),
- m_pAccelerator(NULL) {
- m_ePriorities[FDE_CSSSTYLESHEETPRIORITY_High] = FDE_CSSSTYLESHEETGROUP_Author;
- m_ePriorities[FDE_CSSSTYLESHEETPRIORITY_Mid] = FDE_CSSSTYLESHEETGROUP_User;
- m_ePriorities[FDE_CSSSTYLESHEETPRIORITY_Low] =
- FDE_CSSSTYLESHEETGROUP_UserAgent;
-}
-CFDE_CSSStyleSelector::~CFDE_CSSStyleSelector() {
- Reset();
- if (m_pInlineStyleStore != NULL) {
- m_pInlineStyleStore->Release();
- }
- if (m_pFixedStyleStore != NULL) {
- m_pFixedStyleStore->Release();
- }
- if (m_pAccelerator != NULL) {
- delete m_pAccelerator;
- }
-}
-void CFDE_CSSStyleSelector::SetFontMgr(IFX_FontMgr* pFontMgr) {
- m_pFontMgr = pFontMgr;
-}
-void CFDE_CSSStyleSelector::SetDefFontSize(FX_FLOAT fFontSize) {
- FXSYS_assert(fFontSize > 0);
- m_fDefFontSize = fFontSize;
-}
-IFDE_CSSAccelerator* CFDE_CSSStyleSelector::InitAccelerator() {
- if (m_pAccelerator == NULL) {
- m_pAccelerator = new CFDE_CSSAccelerator;
- FXSYS_assert(m_pAccelerator != NULL);
- }
- m_pAccelerator->Clear();
- return m_pAccelerator;
-}
-IFDE_CSSComputedStyle* CFDE_CSSStyleSelector::CreateComputedStyle(
- IFDE_CSSComputedStyle* pParentStyle) {
- if (m_pFixedStyleStore == NULL) {
- m_pFixedStyleStore = FX_CreateAllocator(FX_ALLOCTYPE_Fixed, 16,
- sizeof(CFDE_CSSComputedStyle));
- FXSYS_assert(m_pFixedStyleStore != NULL);
- }
- CFDE_CSSComputedStyle* pStyle = FXTARGET_NewWith(m_pFixedStyleStore)
- CFDE_CSSComputedStyle(m_pFixedStyleStore);
- if (pParentStyle) {
- pStyle->m_InheritedData =
- ((CFDE_CSSComputedStyle*)pParentStyle)->m_InheritedData;
- } else {
- pStyle->m_InheritedData.Reset();
- }
- pStyle->m_NonInheritedData.Reset();
- return pStyle;
-}
-FX_BOOL CFDE_CSSStyleSelector::SetStyleSheet(FDE_CSSSTYLESHEETGROUP eType,
- IFDE_CSSStyleSheet* pSheet) {
- FXSYS_assert(eType < FDE_CSSSTYLESHEETGROUP_MAX);
- CFDE_CSSStyleSheetArray& dest = m_SheetGroups[eType];
- dest.RemoveAt(0, dest.GetSize());
- if (pSheet != NULL) {
- dest.Add(pSheet);
- }
- return TRUE;
-}
-FX_BOOL CFDE_CSSStyleSelector::SetStyleSheets(
- FDE_CSSSTYLESHEETGROUP eType,
- const CFDE_CSSStyleSheetArray* pArray) {
- FXSYS_assert(eType < FDE_CSSSTYLESHEETGROUP_MAX);
- CFDE_CSSStyleSheetArray& dest = m_SheetGroups[eType];
- if (pArray == NULL) {
- dest.RemoveAt(0, dest.GetSize());
- } else {
- dest.Copy(*pArray);
- }
- return TRUE;
-}
-void CFDE_CSSStyleSelector::SetStylePriority(
- FDE_CSSSTYLESHEETGROUP eType,
- FDE_CSSSTYLESHEETPRIORITY ePriority) {
- m_ePriorities[ePriority] = eType;
-}
-void CFDE_CSSStyleSelector::UpdateStyleIndex(FX_DWORD dwMediaList) {
- Reset();
- m_pRuleDataStore = FX_CreateAllocator(FX_ALLOCTYPE_Static, 1024, 0);
- FXSYS_assert(m_pRuleDataStore != NULL);
- for (int32_t iGroup = 0; iGroup < FDE_CSSSTYLESHEETGROUP_MAX; ++iGroup) {
- CFDE_CSSRuleCollection& rules = m_RuleCollection[iGroup];
- rules.m_pStaticStore = m_pRuleDataStore;
- rules.AddRulesFrom(m_SheetGroups[iGroup], dwMediaList, m_pFontMgr);
- }
-}
-void CFDE_CSSStyleSelector::Reset() {
- for (int32_t iGroup = 0; iGroup < FDE_CSSSTYLESHEETGROUP_MAX; ++iGroup) {
- m_RuleCollection[iGroup].Clear();
- }
- if (m_pRuleDataStore != NULL) {
- m_pRuleDataStore->Release();
- m_pRuleDataStore = NULL;
- }
-}
-int32_t CFDE_CSSStyleSelector::MatchDeclarations(
- IFDE_CSSTagProvider* pTag,
- CFDE_CSSDeclarationArray& matchedDecls,
- FDE_CSSPERSUDO ePersudoType) {
- FXSYS_assert(m_pAccelerator != NULL && pTag != NULL);
- FDE_CSSTagCache* pCache = m_pAccelerator->GetTopElement();
- FXSYS_assert(pCache != NULL && pCache->GetTag() == pTag);
- matchedDecls.RemoveAt(0, matchedDecls.GetSize());
- for (int32_t ePriority = FDE_CSSSTYLESHEETPRIORITY_MAX - 1; ePriority >= 0;
- --ePriority) {
- FDE_CSSSTYLESHEETGROUP eGroup = m_ePriorities[ePriority];
- CFDE_CSSRuleCollection& rules = m_RuleCollection[eGroup];
- if (rules.CountSelectors() == 0) {
- continue;
- }
- if (ePersudoType == FDE_CSSPERSUDO_NONE) {
- MatchRules(pCache, rules.GetUniversalRuleData(), ePersudoType);
- if (pCache->HashTag()) {
- MatchRules(pCache, rules.GetTagRuleData(pCache->HashTag()),
- ePersudoType);
- }
- int32_t iCount = pCache->CountHashClass();
- for (int32_t i = 0; i < iCount; i++) {
- pCache->SetClassIndex(i);
- MatchRules(pCache, rules.GetClassRuleData(pCache->HashClass()),
- ePersudoType);
- }
- } else {
- MatchRules(pCache, rules.GetPersudoRuleData(), ePersudoType);
- }
-
- std::sort(m_MatchedRules.begin(), m_MatchedRules.end(),
- [](const FDE_CSSRuleData* p1, const FDE_CSSRuleData* p2) {
- return p1->dwPriority < p2->dwPriority;
- });
- for (const auto& rule : m_MatchedRules)
- matchedDecls.Add(rule->pDeclaration);
- m_MatchedRules.clear();
- }
- return matchedDecls.GetSize();
-}
-
-void CFDE_CSSStyleSelector::MatchRules(FDE_CSSTagCache* pCache,
- FDE_CSSRuleData* pList,
- FDE_CSSPERSUDO ePersudoType) {
- while (pList) {
- if (MatchSelector(pCache, pList->pSelector, ePersudoType))
- m_MatchedRules.push_back(pList);
- pList = pList->pNext;
- }
-}
-
-FX_BOOL CFDE_CSSStyleSelector::MatchSelector(FDE_CSSTagCache* pCache,
- IFDE_CSSSelector* pSel,
- FDE_CSSPERSUDO ePersudoType) {
- FX_DWORD dwHash;
- while (pSel != NULL && pCache != NULL) {
- switch (pSel->GetType()) {
- case FDE_CSSSELECTORTYPE_Descendant:
- dwHash = pSel->GetNameHash();
- while ((pCache = pCache->GetParent()) != NULL) {
- if (dwHash != FDE_CSSUNIVERSALHASH && dwHash != pCache->HashTag()) {
- continue;
- }
- if (MatchSelector(pCache, pSel->GetNextSelector(), ePersudoType)) {
- return TRUE;
- }
- }
- return FALSE;
- case FDE_CSSSELECTORTYPE_ID:
- dwHash = pCache->HashID();
- if (dwHash != pSel->GetNameHash()) {
- return FALSE;
- }
- break;
- case FDE_CSSSELECTORTYPE_Class:
- dwHash = pCache->HashClass();
- if (dwHash != pSel->GetNameHash()) {
- return FALSE;
- }
- break;
- case FDE_CSSSELECTORTYPE_Element:
- dwHash = pSel->GetNameHash();
- if (dwHash != FDE_CSSUNIVERSALHASH && dwHash != pCache->HashTag()) {
- return FALSE;
- }
- break;
- case FDE_CSSSELECTORTYPE_Persudo:
- dwHash = FDE_GetCSSPersudoByEnum(ePersudoType)->dwHash;
- if (dwHash != pSel->GetNameHash()) {
- return FALSE;
- }
- break;
- default:
- FXSYS_assert(FALSE);
- break;
- }
- pSel = pSel->GetNextSelector();
- }
- return pSel == NULL && pCache != NULL;
-}
-
-void CFDE_CSSStyleSelector::ComputeStyle(
- IFDE_CSSTagProvider* pTag,
- const IFDE_CSSDeclaration** ppDeclArray,
- int32_t iDeclCount,
- IFDE_CSSComputedStyle* pDestStyle) {
- FXSYS_assert(iDeclCount >= 0);
- FXSYS_assert(pDestStyle);
- FX_POSITION pos = pTag->GetFirstAttribute();
- if (pos != NULL) {
- if (m_pInlineStyleStore == NULL) {
- m_pInlineStyleStore = FX_CreateAllocator(FX_ALLOCTYPE_Static, 2048, 0);
- }
- CFDE_CSSDeclaration* pDecl = NULL;
- CFX_WideStringC wsAttri, wsValue;
- FX_DWORD dwAttriHash;
- do {
- pTag->GetNextAttribute(pos, wsAttri, wsValue);
- dwAttriHash =
- FX_HashCode_String_GetW(wsAttri.GetPtr(), wsAttri.GetLength(), TRUE);
- static const FX_DWORD s_dwStyleHash =
- FX_HashCode_String_GetW(L"style", 5, TRUE);
- static const FX_DWORD s_dwAlignHash =
- FX_HashCode_String_GetW(L"align", 5, TRUE);
- if (dwAttriHash == s_dwStyleHash) {
- if (pDecl == NULL) {
- pDecl = FXTARGET_NewWith(m_pInlineStyleStore) CFDE_CSSDeclaration;
- }
- AppendInlineStyle(pDecl, wsValue.GetPtr(), wsValue.GetLength());
- } else if (dwAttriHash == s_dwAlignHash) {
- if (pDecl == NULL) {
- pDecl = FXTARGET_NewWith(m_pInlineStyleStore) CFDE_CSSDeclaration;
- }
- FDE_CSSPROPERTYARGS args;
- args.pStringCache = NULL;
- args.pStaticStore = m_pInlineStyleStore;
- args.pProperty = FDE_GetCSSPropertyByEnum(FDE_CSSPROPERTY_TextAlign);
- pDecl->AddProperty(&args, wsValue.GetPtr(), wsValue.GetLength());
- }
- } while (pos != NULL);
- if (pDecl != NULL) {
- CFDE_CSSDeclarationArray decls;
- decls.SetSize(iDeclCount + 1);
- IFDE_CSSDeclaration** ppInline = decls.GetData();
- FXSYS_memcpy(ppInline, ppDeclArray,
- iDeclCount * sizeof(IFDE_CSSDeclaration*));
- ppInline[iDeclCount++] = pDecl;
- ApplyDeclarations(TRUE, (const IFDE_CSSDeclaration**)ppInline, iDeclCount,
- pDestStyle);
- ApplyDeclarations(FALSE, (const IFDE_CSSDeclaration**)ppInline,
- iDeclCount, pDestStyle);
- return;
- }
- }
- if (iDeclCount > 0) {
- FXSYS_assert(ppDeclArray != NULL);
- ApplyDeclarations(TRUE, ppDeclArray, iDeclCount, pDestStyle);
- ApplyDeclarations(FALSE, ppDeclArray, iDeclCount, pDestStyle);
- }
-}
-void CFDE_CSSStyleSelector::ApplyDeclarations(
- FX_BOOL bPriority,
- const IFDE_CSSDeclaration** ppDeclArray,
- int32_t iDeclCount,
- IFDE_CSSComputedStyle* pDestStyle) {
- CFDE_CSSComputedStyle* pComputedStyle = (CFDE_CSSComputedStyle*)pDestStyle;
- IFDE_CSSValue* pVal;
- FX_BOOL bImportant;
- int32_t i;
- if (bPriority) {
- IFDE_CSSValue *pLastest = NULL, *pImportant = NULL;
- for (i = 0; i < iDeclCount; ++i) {
- pVal = ppDeclArray[i]->GetProperty(FDE_CSSPROPERTY_FontSize, bImportant);
- if (pVal == NULL) {
- continue;
- } else if (bImportant) {
- pImportant = pVal;
- } else {
- pLastest = pVal;
- }
- }
- if (pImportant) {
- ApplyProperty(FDE_CSSPROPERTY_FontSize, pImportant, pComputedStyle);
- } else if (pLastest) {
- ApplyProperty(FDE_CSSPROPERTY_FontSize, pLastest, pComputedStyle);
- }
- } else {
- CFDE_CSSDeclarationArray importants;
- const IFDE_CSSDeclaration* pDecl = NULL;
- FDE_CSSPROPERTY eProp;
- FX_POSITION pos;
- for (i = 0; i < iDeclCount; ++i) {
- pDecl = ppDeclArray[i];
- pos = pDecl->GetStartPosition();
- while (pos != NULL) {
- pDecl->GetNextProperty(pos, eProp, pVal, bImportant);
- if (eProp == FDE_CSSPROPERTY_FontSize) {
- continue;
- } else if (!bImportant) {
- ApplyProperty(eProp, pVal, pComputedStyle);
- } else if (importants.GetSize() == 0 ||
- importants[importants.GetUpperBound()] != pDecl) {
- importants.Add((IFDE_CSSDeclaration*)pDecl);
- }
- }
- }
- iDeclCount = importants.GetSize();
- for (i = 0; i < iDeclCount; ++i) {
- pDecl = importants[i];
- pos = pDecl->GetStartPosition();
- while (pos != NULL) {
- pDecl->GetNextProperty(pos, eProp, pVal, bImportant);
- if (bImportant && eProp != FDE_CSSPROPERTY_FontSize) {
- ApplyProperty(eProp, pVal, pComputedStyle);
- }
- }
- }
- CFX_WideString wsName, wsValue;
- pos = pDecl->GetStartCustom();
- while (pos) {
- pDecl->GetNextCustom(pos, wsName, wsValue);
- pComputedStyle->AddCustomStyle(wsName, wsValue);
- }
- }
-}
-void CFDE_CSSStyleSelector::AppendInlineStyle(CFDE_CSSDeclaration* pDecl,
- const FX_WCHAR* psz,
- int32_t iLen) {
- FXSYS_assert(pDecl != NULL && psz != NULL && iLen > 0);
- IFDE_CSSSyntaxParser* pSyntax = IFDE_CSSSyntaxParser::Create();
- if (pSyntax == NULL) {
- return;
- }
- if (pSyntax->Init(psz, iLen, 32, TRUE)) {
- int32_t iLen;
- const FX_WCHAR* psz;
- FDE_CSSPROPERTYARGS args;
- args.pStringCache = NULL;
- args.pStaticStore = m_pInlineStyleStore;
- args.pProperty = NULL;
- CFX_WideString wsName;
- for (;;) {
- FDE_CSSSYNTAXSTATUS eStatus = pSyntax->DoSyntaxParse();
- if (eStatus == FDE_CSSSYNTAXSTATUS_PropertyName) {
- psz = pSyntax->GetCurrentString(iLen);
- args.pProperty = FDE_GetCSSPropertyByName(psz, iLen);
- if (args.pProperty == NULL) {
- wsName = CFX_WideStringC(psz, iLen);
- }
- } else if (eStatus == FDE_CSSSYNTAXSTATUS_PropertyValue) {
- if (args.pProperty != NULL) {
- psz = pSyntax->GetCurrentString(iLen);
- if (iLen > 0) {
- pDecl->AddProperty(&args, psz, iLen);
- }
- } else if (iLen > 0) {
- psz = pSyntax->GetCurrentString(iLen);
- if (iLen > 0) {
- pDecl->AddProperty(&args, wsName, wsName.GetLength(), psz, iLen);
- }
- }
- } else {
- break;
- }
- }
- }
- pSyntax->Release();
-}
-#define FDE_CSSNONINHERITS (pComputedStyle->m_NonInheritedData)
-#define FDE_CSSINHERITS (pComputedStyle->m_InheritedData)
-#define FDE_CSSFONTSIZE (FDE_CSSINHERITS.m_fFontSize)
-void CFDE_CSSStyleSelector::ApplyProperty(
- FDE_CSSPROPERTY eProperty,
- IFDE_CSSValue* pValue,
- CFDE_CSSComputedStyle* pComputedStyle) {
- if (pValue->GetType() == FDE_CSSVALUETYPE_Primitive) {
- IFDE_CSSPrimitiveValue* pPrimitive = (IFDE_CSSPrimitiveValue*)pValue;
- FDE_CSSPRIMITIVETYPE eType = pPrimitive->GetPrimitiveType();
- switch (eProperty) {
- case FDE_CSSPROPERTY_Display:
- if (eType == FDE_CSSPRIMITIVETYPE_Enum) {
- FDE_CSSNONINHERITS.m_eDisplay = ToDisplay(pPrimitive->GetEnum());
- }
- break;
- case FDE_CSSPROPERTY_FontSize: {
- FX_FLOAT& fFontSize = FDE_CSSFONTSIZE;
- if (eType >= FDE_CSSPRIMITIVETYPE_Number &&
- eType <= FDE_CSSPRIMITIVETYPE_PC) {
- fFontSize = ApplyNumber(eType, pPrimitive->GetFloat(), fFontSize);
- } else if (eType == FDE_CSSPRIMITIVETYPE_Enum) {
- fFontSize = ToFontSize(pPrimitive->GetEnum(), fFontSize);
- }
- } break;
- case FDE_CSSPROPERTY_LineHeight:
- if (eType == FDE_CSSPRIMITIVETYPE_Number) {
- FDE_CSSINHERITS.m_fLineHeight =
- pPrimitive->GetFloat() * FDE_CSSFONTSIZE;
- } else if (eType > FDE_CSSPRIMITIVETYPE_Number &&
- eType <= FDE_CSSPRIMITIVETYPE_PC) {
- FDE_CSSINHERITS.m_fLineHeight =
- ApplyNumber(eType, pPrimitive->GetFloat(), FDE_CSSFONTSIZE);
- }
- break;
- case FDE_CSSPROPERTY_TextAlign:
- if (eType == FDE_CSSPRIMITIVETYPE_Enum) {
- FDE_CSSINHERITS.m_eTextAligh = ToTextAlign(pPrimitive->GetEnum());
- }
- break;
- case FDE_CSSPROPERTY_TextIndent:
- SetLengthWithPercent(FDE_CSSINHERITS.m_TextIndent, eType, pPrimitive,
- FDE_CSSFONTSIZE);
- break;
- case FDE_CSSPROPERTY_FontWeight:
- if (eType == FDE_CSSPRIMITIVETYPE_Enum) {
- FDE_CSSINHERITS.m_wFontWeight = ToFontWeight(pPrimitive->GetEnum());
- } else if (eType == FDE_CSSPRIMITIVETYPE_Number) {
- int32_t iValue = (int32_t)pPrimitive->GetFloat() / 100;
- if (iValue >= 1 && iValue <= 9) {
- FDE_CSSINHERITS.m_wFontWeight = iValue * 100;
- }
- }
- break;
- case FDE_CSSPROPERTY_FontStyle:
- if (eType == FDE_CSSPRIMITIVETYPE_Enum) {
- FDE_CSSINHERITS.m_eFontStyle = ToFontStyle(pPrimitive->GetEnum());
- }
- break;
- case FDE_CSSPROPERTY_Color:
- if (eType == FDE_CSSPRIMITIVETYPE_RGB) {
- FDE_CSSINHERITS.m_dwFontColor = pPrimitive->GetRGBColor();
- }
- break;
- case FDE_CSSPROPERTY_MarginLeft:
- FDE_CSSNONINHERITS.m_bHasMargin |=
- SetLengthWithPercent(FDE_CSSNONINHERITS.m_MarginWidth.left, eType,
- pPrimitive, FDE_CSSFONTSIZE);
- break;
- case FDE_CSSPROPERTY_MarginTop:
- FDE_CSSNONINHERITS.m_bHasMargin |=
- SetLengthWithPercent(FDE_CSSNONINHERITS.m_MarginWidth.top, eType,
- pPrimitive, FDE_CSSFONTSIZE);
- break;
- case FDE_CSSPROPERTY_MarginRight:
- FDE_CSSNONINHERITS.m_bHasMargin |=
- SetLengthWithPercent(FDE_CSSNONINHERITS.m_MarginWidth.right, eType,
- pPrimitive, FDE_CSSFONTSIZE);
- break;
- case FDE_CSSPROPERTY_MarginBottom:
- FDE_CSSNONINHERITS.m_bHasMargin |=
- SetLengthWithPercent(FDE_CSSNONINHERITS.m_MarginWidth.bottom, eType,
- pPrimitive, FDE_CSSFONTSIZE);
- break;
- case FDE_CSSPROPERTY_PaddingLeft:
- FDE_CSSNONINHERITS.m_bHasPadding |=
- SetLengthWithPercent(FDE_CSSNONINHERITS.m_PaddingWidth.left, eType,
- pPrimitive, FDE_CSSFONTSIZE);
- break;
- case FDE_CSSPROPERTY_PaddingTop:
- FDE_CSSNONINHERITS.m_bHasPadding |=
- SetLengthWithPercent(FDE_CSSNONINHERITS.m_PaddingWidth.top, eType,
- pPrimitive, FDE_CSSFONTSIZE);
- break;
- case FDE_CSSPROPERTY_PaddingRight:
- FDE_CSSNONINHERITS.m_bHasPadding |=
- SetLengthWithPercent(FDE_CSSNONINHERITS.m_PaddingWidth.right, eType,
- pPrimitive, FDE_CSSFONTSIZE);
- break;
- case FDE_CSSPROPERTY_PaddingBottom:
- FDE_CSSNONINHERITS.m_bHasPadding |=
- SetLengthWithPercent(FDE_CSSNONINHERITS.m_PaddingWidth.bottom,
- eType, pPrimitive, FDE_CSSFONTSIZE);
- break;
- case FDE_CSSPROPERTY_BorderLeftWidth:
- FDE_CSSNONINHERITS.m_bHasBorder |=
- SetLengthWithPercent(FDE_CSSNONINHERITS.m_BorderWidth.left, eType,
- pPrimitive, FDE_CSSFONTSIZE);
- break;
- case FDE_CSSPROPERTY_BorderTopWidth:
- FDE_CSSNONINHERITS.m_bHasBorder |=
- SetLengthWithPercent(FDE_CSSNONINHERITS.m_BorderWidth.top, eType,
- pPrimitive, FDE_CSSFONTSIZE);
- break;
- case FDE_CSSPROPERTY_BorderRightWidth:
- FDE_CSSNONINHERITS.m_bHasBorder |=
- SetLengthWithPercent(FDE_CSSNONINHERITS.m_BorderWidth.right, eType,
- pPrimitive, FDE_CSSFONTSIZE);
- break;
- case FDE_CSSPROPERTY_BorderBottomWidth:
- FDE_CSSNONINHERITS.m_bHasBorder |=
- SetLengthWithPercent(FDE_CSSNONINHERITS.m_BorderWidth.bottom, eType,
- pPrimitive, FDE_CSSFONTSIZE);
- break;
- case FDE_CSSPROPERTY_BorderLeftStyle:
- if (eType == FDE_CSSPRIMITIVETYPE_Enum) {
- FDE_CSSNONINHERITS.m_eBDRLeftStyle =
- ToBorderStyle(pPrimitive->GetEnum());
- }
- break;
- case FDE_CSSPROPERTY_BorderTopStyle:
- if (eType == FDE_CSSPRIMITIVETYPE_Enum) {
- FDE_CSSNONINHERITS.m_eBDRTopStyle =
- ToBorderStyle(pPrimitive->GetEnum());
- }
- break;
- case FDE_CSSPROPERTY_BorderRightStyle:
- if (eType == FDE_CSSPRIMITIVETYPE_Enum) {
- FDE_CSSNONINHERITS.m_eBDRRightStyle =
- ToBorderStyle(pPrimitive->GetEnum());
- }
- break;
- case FDE_CSSPROPERTY_BorderBottomStyle:
- if (eType == FDE_CSSPRIMITIVETYPE_Enum) {
- FDE_CSSNONINHERITS.m_eBDRBottomStyle =
- ToBorderStyle(pPrimitive->GetEnum());
- }
- break;
- case FDE_CSSPROPERTY_BorderLeftColor:
- if (eType == FDE_CSSPRIMITIVETYPE_RGB) {
- FDE_CSSNONINHERITS.m_dwBDRLeftColor = pPrimitive->GetRGBColor();
- }
- break;
- case FDE_CSSPROPERTY_BorderTopColor:
- if (eType == FDE_CSSPRIMITIVETYPE_RGB) {
- FDE_CSSNONINHERITS.m_dwBDRTopColor = pPrimitive->GetRGBColor();
- }
- break;
- case FDE_CSSPROPERTY_BorderRightColor:
- if (eType == FDE_CSSPRIMITIVETYPE_RGB) {
- FDE_CSSNONINHERITS.m_dwBDRRightColor = pPrimitive->GetRGBColor();
- }
- break;
- case FDE_CSSPROPERTY_BorderBottomColor:
- if (eType == FDE_CSSPRIMITIVETYPE_RGB) {
- FDE_CSSNONINHERITS.m_dwBDRBottomColor = pPrimitive->GetRGBColor();
- }
- break;
- case FDE_CSSPROPERTY_ListStyleType:
- if (eType == FDE_CSSPRIMITIVETYPE_Enum) {
- FDE_CSSNONINHERITS.m_eListStyleType =
- ToListStyleType(pPrimitive->GetEnum());
- }
- break;
- case FDE_CSSPROPERTY_ListStylePosition:
- if (eType == FDE_CSSPRIMITIVETYPE_Enum) {
- FDE_CSSNONINHERITS.m_eListStylePosition =
- ToListStylePosition(pPrimitive->GetEnum());
- }
- break;
- case FDE_CSSPROPERTY_BackgroundColor:
- if (eType == FDE_CSSPRIMITIVETYPE_RGB) {
- FDE_CSSNONINHERITS.m_dwBKGColor = pPrimitive->GetRGBColor();
- } else if (eType == FDE_CSSPRIMITIVETYPE_Enum) {
- FDE_CSSNONINHERITS.m_dwBKGColor = 0;
- }
- break;
- case FDE_CSSPROPERTY_Visibility:
- if (eType == FDE_CSSPRIMITIVETYPE_Enum) {
- FDE_CSSINHERITS.m_eVisibility = ToVisibility(pPrimitive->GetEnum());
- }
- break;
- case FDE_CSSPROPERTY_Width:
- SetLengthWithPercent(FDE_CSSNONINHERITS.m_BoxSize.cx, eType, pPrimitive,
- FDE_CSSFONTSIZE);
- break;
- case FDE_CSSPROPERTY_Height:
- SetLengthWithPercent(FDE_CSSNONINHERITS.m_BoxSize.cy, eType, pPrimitive,
- FDE_CSSFONTSIZE);
- break;
- case FDE_CSSPROPERTY_MinWidth:
- SetLengthWithPercent(FDE_CSSNONINHERITS.m_MinBoxSize.cx, eType,
- pPrimitive, FDE_CSSFONTSIZE);
- break;
- case FDE_CSSPROPERTY_MinHeight:
- SetLengthWithPercent(FDE_CSSNONINHERITS.m_MinBoxSize.cy, eType,
- pPrimitive, FDE_CSSFONTSIZE);
- break;
- case FDE_CSSPROPERTY_MaxWidth:
- SetLengthWithPercent(FDE_CSSNONINHERITS.m_MaxBoxSize.cx, eType,
- pPrimitive, FDE_CSSFONTSIZE);
- break;
- case FDE_CSSPROPERTY_MaxHeight:
- SetLengthWithPercent(FDE_CSSNONINHERITS.m_MaxBoxSize.cy, eType,
- pPrimitive, FDE_CSSFONTSIZE);
- break;
- case FDE_CSSPROPERTY_VerticalAlign:
- if (eType == FDE_CSSPRIMITIVETYPE_Enum) {
- FDE_CSSNONINHERITS.m_eVerticalAlign =
- ToVerticalAlign(pPrimitive->GetEnum());
- } else if (eType >= FDE_CSSPRIMITIVETYPE_Number &&
- eType <= FDE_CSSPRIMITIVETYPE_PC) {
- FDE_CSSNONINHERITS.m_eVerticalAlign = FDE_CSSVERTICALALIGN_Number;
- FDE_CSSNONINHERITS.m_fVerticalAlign =
- ApplyNumber(eType, pPrimitive->GetFloat(), FDE_CSSFONTSIZE);
- }
- break;
- case FDE_CSSPROPERTY_WhiteSpace:
- if (eType == FDE_CSSPRIMITIVETYPE_Enum) {
- FDE_CSSINHERITS.m_eWhiteSpace = ToWhiteSpace(pPrimitive->GetEnum());
- }
- break;
- case FDE_CSSPROPERTY_TextTransform:
- if (eType == FDE_CSSPRIMITIVETYPE_Enum) {
- FDE_CSSINHERITS.m_eTextTransform =
- ToTextTransform(pPrimitive->GetEnum());
- }
- break;
- case FDE_CSSPROPERTY_FontVariant:
- if (eType == FDE_CSSPRIMITIVETYPE_Enum) {
- FDE_CSSINHERITS.m_eFontVariant = ToFontVariant(pPrimitive->GetEnum());
- }
- break;
- case FDE_CSSPROPERTY_LetterSpacing:
- if (eType == FDE_CSSPRIMITIVETYPE_Percent) {
- break;
- } else if (eType == FDE_CSSPRIMITIVETYPE_Enum) {
- FDE_CSSINHERITS.m_LetterSpacing.Set(FDE_CSSLENGTHUNIT_Normal);
- } else if (eType >= FDE_CSSPRIMITIVETYPE_Number &&
- eType <= FDE_CSSPRIMITIVETYPE_PC) {
- SetLengthWithPercent(FDE_CSSINHERITS.m_LetterSpacing, eType,
- pPrimitive, FDE_CSSFONTSIZE);
- }
- break;
- case FDE_CSSPROPERTY_WordSpacing:
- if (eType == FDE_CSSPRIMITIVETYPE_Percent) {
- break;
- } else if (eType == FDE_CSSPRIMITIVETYPE_Enum) {
- FDE_CSSINHERITS.m_WordSpacing.Set(FDE_CSSLENGTHUNIT_Normal);
- } else if (eType >= FDE_CSSPRIMITIVETYPE_Number &&
- eType <= FDE_CSSPRIMITIVETYPE_PC) {
- SetLengthWithPercent(FDE_CSSINHERITS.m_WordSpacing, eType, pPrimitive,
- FDE_CSSFONTSIZE);
- }
- break;
- case FDE_CSSPROPERTY_Float:
- if (eType == FDE_CSSPRIMITIVETYPE_Enum) {
- FDE_CSSNONINHERITS.m_eFloat = ToFloat(pPrimitive->GetEnum());
- }
- break;
- case FDE_CSSPROPERTY_Clear:
- if (eType == FDE_CSSPRIMITIVETYPE_Enum) {
- FDE_CSSNONINHERITS.m_eClear = ToClear(pPrimitive->GetEnum());
- }
- break;
- case FDE_CSSPROPERTY_WritingMode:
- if (eType == FDE_CSSPRIMITIVETYPE_Enum) {
- FDE_CSSINHERITS.m_eWritingMode = ToWritingMode(pPrimitive->GetEnum());
- }
- break;
- case FDE_CSSPROPERTY_WordBreak:
- if (eType == FDE_CSSPRIMITIVETYPE_Enum) {
- FDE_CSSINHERITS.m_eWordBreak = ToWordBreak(pPrimitive->GetEnum());
- }
- break;
- case FDE_CSSPROPERTY_Widows:
- if (eType == FDE_CSSPRIMITIVETYPE_Number) {
- FDE_CSSINHERITS.m_iWidows = (int32_t)pPrimitive->GetFloat();
- }
- break;
- case FDE_CSSPROPERTY_Orphans:
- if (eType == FDE_CSSPRIMITIVETYPE_Number) {
- FDE_CSSINHERITS.m_iOrphans = (int32_t)pPrimitive->GetFloat();
- }
- break;
- case FDE_CSSPROPERTY_TextEmphasisColor:
- if (eType == FDE_CSSPRIMITIVETYPE_Enum) {
- switch (pPrimitive->GetEnum()) {
- case FDE_CSSPROPERTYVALUE_Transparent:
- FDE_CSSINHERITS.m_dwTextEmphasisColor = 0;
- FDE_CSSINHERITS.m_bTextEmphasisColorCurrent = FALSE;
- break;
- case FDE_CSSPROPERTYVALUE_Currentcolor:
- FDE_CSSINHERITS.m_bTextEmphasisColorCurrent = TRUE;
- break;
- default:
- break;
- }
- } else if (eType == FDE_CSSPRIMITIVETYPE_RGB) {
- FDE_CSSINHERITS.m_dwTextEmphasisColor = pPrimitive->GetRGBColor();
- FDE_CSSINHERITS.m_bTextEmphasisColorCurrent = FALSE;
- }
- break;
- case FDE_CSSPROPERTY_PageBreakBefore:
- if (eType == FDE_CSSPRIMITIVETYPE_Enum) {
- FDE_CSSNONINHERITS.m_ePageBreakBefore =
- ToPageBreak(pPrimitive->GetEnum());
- }
- break;
- case FDE_CSSPROPERTY_PageBreakAfter:
- if (eType == FDE_CSSPRIMITIVETYPE_Enum) {
- FDE_CSSNONINHERITS.m_ePageBreakAfter =
- ToPageBreak(pPrimitive->GetEnum());
- }
- break;
- case FDE_CSSPROPERTY_PageBreakInside:
- if (eType == FDE_CSSPRIMITIVETYPE_Enum) {
- FDE_CSSNONINHERITS.m_ePageBreakInside =
- ToPageBreak(pPrimitive->GetEnum());
- }
- break;
- case FDE_CSSPROPERTY_OverflowX:
- if (eType == FDE_CSSPRIMITIVETYPE_Enum) {
- FDE_CSSNONINHERITS.m_eOverflowX = ToOverflow(pPrimitive->GetEnum());
- }
- break;
- case FDE_CSSPROPERTY_OverflowY:
- if (eType == FDE_CSSPRIMITIVETYPE_Enum) {
- FDE_CSSNONINHERITS.m_eOverflowY = ToOverflow(pPrimitive->GetEnum());
- }
- break;
- case FDE_CSSPROPERTY_LineBreak:
- if (eType == FDE_CSSPRIMITIVETYPE_Enum) {
- FDE_CSSINHERITS.m_eLineBreak = ToLineBreak(pPrimitive->GetEnum());
- }
- break;
- case FDE_CSSPROPERTY_ColumnCount:
- if (eType == FDE_CSSPRIMITIVETYPE_Enum) {
- FDE_CSSNONINHERITS.m_ColumnCount.Set(FDE_CSSLENGTHUNIT_Auto);
- } else if (eType == FDE_CSSPRIMITIVETYPE_Number) {
- FDE_CSSNONINHERITS.m_ColumnCount.Set(FDE_CSSLENGTHUNIT_Point,
- pPrimitive->GetFloat());
- }
- break;
- case FDE_CSSPROPERTY_ColumnGap:
- SetLengthWithPercent(FDE_CSSNONINHERITS.m_ColumnGap, eType, pPrimitive,
- FDE_CSSFONTSIZE);
- break;
- case FDE_CSSPROPERTY_ColumnRuleColor:
- if (eType == FDE_CSSPRIMITIVETYPE_RGB) {
- FDE_CSSNONINHERITS.m_dwColumnRuleColor = pPrimitive->GetRGBColor();
- FDE_CSSNONINHERITS.m_bColumnRuleColorSame = FALSE;
- }
- break;
- case FDE_CSSPROPERTY_ColumnRuleStyle:
- if (eType == FDE_CSSPRIMITIVETYPE_Enum) {
- FDE_CSSNONINHERITS.m_eColumnRuleStyle =
- ToBorderStyle(pPrimitive->GetEnum());
- }
- break;
- case FDE_CSSPROPERTY_ColumnRuleWidth:
- SetLengthWithPercent(FDE_CSSNONINHERITS.m_ColumnRuleWidth, eType,
- pPrimitive, FDE_CSSFONTSIZE);
- break;
- case FDE_CSSPROPERTY_ColumnWidth:
- SetLengthWithPercent(FDE_CSSNONINHERITS.m_ColumnWidth, eType,
- pPrimitive, FDE_CSSFONTSIZE);
- break;
- case FDE_CSSPROPERTY_BackgroundImage:
- if (eType == FDE_CSSPRIMITIVETYPE_Enum) {
- FDE_CSSNONINHERITS.m_pszBKGImage = NULL;
- } else if (eType == FDE_CSSPRIMITIVETYPE_URI) {
- int32_t iLength;
- FDE_CSSNONINHERITS.m_pszBKGImage = pPrimitive->GetString(iLength);
- }
- break;
- case FDE_CSSPROPERTY_Position:
- if (eType == FDE_CSSPRIMITIVETYPE_Enum) {
- FDE_CSSNONINHERITS.m_ePosition = ToPosition(pPrimitive->GetEnum());
- }
- break;
- case FDE_CSSPROPERTY_Top:
- SetLengthWithPercent(FDE_CSSNONINHERITS.m_Top, eType, pPrimitive,
- FDE_CSSFONTSIZE);
- break;
- case FDE_CSSPROPERTY_Bottom:
- SetLengthWithPercent(FDE_CSSNONINHERITS.m_Bottom, eType, pPrimitive,
- FDE_CSSFONTSIZE);
- break;
- case FDE_CSSPROPERTY_Left:
- SetLengthWithPercent(FDE_CSSNONINHERITS.m_Left, eType, pPrimitive,
- FDE_CSSFONTSIZE);
- break;
- case FDE_CSSPROPERTY_Right:
- SetLengthWithPercent(FDE_CSSNONINHERITS.m_Right, eType, pPrimitive,
- FDE_CSSFONTSIZE);
- break;
- case FDE_CSSPROPERTY_ListStyleImage:
- if (eType == FDE_CSSPRIMITIVETYPE_Enum) {
- FDE_CSSINHERITS.m_pszListStyleImage = NULL;
- } else if (eType == FDE_CSSPRIMITIVETYPE_URI) {
- int32_t iLength;
- FDE_CSSINHERITS.m_pszListStyleImage = pPrimitive->GetString(iLength);
- }
- break;
- case FDE_CSSPROPERTY_CaptionSide:
- if (eType == FDE_CSSPRIMITIVETYPE_Enum) {
- FDE_CSSINHERITS.m_eCaptionSide = ToCaptionSide(pPrimitive->GetEnum());
- }
- break;
- case FDE_CSSPROPERTY_BackgroundRepeat:
- if (eType == FDE_CSSPRIMITIVETYPE_Enum) {
- FDE_CSSNONINHERITS.m_eBKGRepeat = ToBKGRepeat(pPrimitive->GetEnum());
- }
- break;
- case FDE_CSSPROPERTY_BackgroundAttachment:
- if (eType == FDE_CSSPRIMITIVETYPE_Enum) {
- FDE_CSSNONINHERITS.m_eBKGAttachment =
- ToBKGAttachment(pPrimitive->GetEnum());
- }
- break;
- case FDE_CSSPROPERTY_RubyAlign:
- if (eType == FDE_CSSPRIMITIVETYPE_Enum) {
- FDE_CSSINHERITS.m_eRubyAlign = ToRubyAlign(pPrimitive->GetEnum());
- }
- break;
- case FDE_CSSPROPERTY_RubyOverhang:
- if (eType == FDE_CSSPRIMITIVETYPE_Enum) {
- FDE_CSSINHERITS.m_eRubyOverhang =
- ToRubyOverhang(pPrimitive->GetEnum());
- }
- break;
- case FDE_CSSPROPERTY_RubyPosition:
- if (eType == FDE_CSSPRIMITIVETYPE_Enum) {
- FDE_CSSINHERITS.m_eRubyPosition =
- ToRubyPosition(pPrimitive->GetEnum());
- }
- break;
- case FDE_CSSPROPERTY_RubySpan:
- FDE_CSSNONINHERITS.m_pRubySpan = pPrimitive;
- break;
- default:
- break;
- }
- } else if (pValue->GetType() == FDE_CSSVALUETYPE_List) {
- IFDE_CSSValueList* pList = (IFDE_CSSValueList*)pValue;
- int32_t iCount = pList->CountValues();
- if (iCount > 0) {
- switch (eProperty) {
- case FDE_CSSPROPERTY_FontFamily:
- FDE_CSSINHERITS.m_pFontFamily = pList;
- break;
- case FDE_CSSPROPERTY_TextDecoration:
- FDE_CSSNONINHERITS.m_dwTextDecoration = ToTextDecoration(pList);
- break;
- case FDE_CSSPROPERTY_CounterIncrement: {
- if (FDE_CSSNONINHERITS.m_pCounterStyle == NULL) {
- FDE_CSSNONINHERITS.m_pCounterStyle = new CFDE_CSSCounterStyle;
- }
- FDE_CSSNONINHERITS.m_pCounterStyle->SetCounterIncrementList(pList);
- } break;
- case FDE_CSSPROPERTY_CounterReset: {
- if (FDE_CSSNONINHERITS.m_pCounterStyle == NULL) {
- FDE_CSSNONINHERITS.m_pCounterStyle = new CFDE_CSSCounterStyle;
- }
- FDE_CSSNONINHERITS.m_pCounterStyle->SetCounterResetList(pList);
- } break;
- case FDE_CSSPROPERTY_Content:
- FDE_CSSNONINHERITS.m_pContentList = pList;
- break;
- case FDE_CSSPROPERTY_Quotes:
- FDE_CSSINHERITS.m_pQuotes = pList;
- break;
- case FDE_CSSPROPERTY_TextCombine: {
- for (int32_t i = 0; i < pList->CountValues(); i++) {
- IFDE_CSSPrimitiveValue* pVal =
- (IFDE_CSSPrimitiveValue*)pList->GetValue(i);
- switch (pVal->GetPrimitiveType()) {
- case FDE_CSSPRIMITIVETYPE_Enum: {
- switch (pVal->GetEnum()) {
- case FDE_CSSPROPERTYVALUE_None: {
- FDE_CSSNONINHERITS.m_eTextCombine = FDE_CSSTEXTCOMBINE_None;
- FDE_CSSNONINHERITS.m_bHasTextCombineNumber = FALSE;
- } break;
- case FDE_CSSPROPERTYVALUE_Horizontal: {
- FDE_CSSNONINHERITS.m_eTextCombine =
- FDE_CSSTEXTCOMBINE_Horizontal;
- FDE_CSSNONINHERITS.m_bHasTextCombineNumber = FALSE;
- } break;
- default:
- break;
- }
- } break;
- case FDE_CSSPRIMITIVETYPE_Number:
- FDE_CSSNONINHERITS.m_fTextCombineNumber = pVal->GetFloat();
- break;
- default:
- break;
- }
- }
- } break;
- case FDE_CSSPROPERTY_TextEmphasisStyle: {
- FDE_CSSTEXTEMPHASISFILL eFill;
- FDE_CSSTEXTEMPHASISMARK eMark;
- for (int32_t i = 0; i < pList->CountValues(); i++) {
- IFDE_CSSPrimitiveValue* pVal =
- (IFDE_CSSPrimitiveValue*)pList->GetValue(i);
- switch (pVal->GetPrimitiveType()) {
- case FDE_CSSPRIMITIVETYPE_Enum: {
- if (ToTextEmphasisFill(pVal->GetEnum(), eFill)) {
- FDE_CSSINHERITS.m_eTextEmphasisFill = eFill;
- continue;
- } else if (ToTextEmphasisMark(pVal->GetEnum(), eMark)) {
- FDE_CSSINHERITS.m_eTextEmphasisMark = eMark;
- }
- } break;
- case FDE_CSSPRIMITIVETYPE_String: {
- FDE_CSSINHERITS.m_eTextEmphasisMark =
- FDE_CSSTEXTEMPHASISMARK_Custom;
- int32_t iLen;
- FDE_CSSINHERITS.m_pszTextEmphasisCustomMark =
- pVal->GetString(iLen);
- } break;
- default:
- break;
- }
- }
- } break;
- default:
- break;
- }
- }
- } else {
- FXSYS_assert(FALSE);
- }
-}
-FX_FLOAT CFDE_CSSStyleSelector::ApplyNumber(FDE_CSSPRIMITIVETYPE eUnit,
- FX_FLOAT fValue,
- FX_FLOAT fPercentBase) {
- switch (eUnit) {
- case FDE_CSSPRIMITIVETYPE_PX:
- case FDE_CSSPRIMITIVETYPE_Number:
- return fValue * 72 / 96;
- case FDE_CSSPRIMITIVETYPE_PT:
- return fValue;
- case FDE_CSSPRIMITIVETYPE_EMS:
- case FDE_CSSPRIMITIVETYPE_EXS:
- return fValue * fPercentBase;
- case FDE_CSSPRIMITIVETYPE_Percent:
- return fValue * fPercentBase / 100.0f;
- case FDE_CSSPRIMITIVETYPE_CM:
- return fValue * 28.3464f;
- case FDE_CSSPRIMITIVETYPE_MM:
- return fValue * 2.8346f;
- case FDE_CSSPRIMITIVETYPE_IN:
- return fValue * 72.0f;
- case FDE_CSSPRIMITIVETYPE_PC:
- return fValue / 12.0f;
- default:
- return fValue;
- }
-}
-FDE_CSSRUBYSPAN CFDE_CSSStyleSelector::ToRubySpan(FDE_CSSPROPERTYVALUE eValue) {
- switch (eValue) {
- case FDE_CSSPROPERTYVALUE_None:
- default:
- return FDE_CSSRUBYSPAN_None;
- }
-}
-FDE_CSSRUBYPOSITION CFDE_CSSStyleSelector::ToRubyPosition(
- FDE_CSSPROPERTYVALUE eValue) {
- switch (eValue) {
- case FDE_CSSPROPERTYVALUE_Before:
- return FDE_CSSRUBYPOSITION_Before;
- case FDE_CSSPROPERTYVALUE_After:
- return FDE_CSSRUBYPOSITION_After;
- case FDE_CSSPROPERTYVALUE_Right:
- return FDE_CSSRUBYPOSITION_Right;
- case FDE_CSSPROPERTYVALUE_Inline:
- return FDE_CSSRUBYPOSITION_Inline;
- default:
- return FDE_CSSRUBYPOSITION_Before;
- }
-}
-FDE_CSSRUBYOVERHANG CFDE_CSSStyleSelector::ToRubyOverhang(
- FDE_CSSPROPERTYVALUE eValue) {
- switch (eValue) {
- case FDE_CSSPROPERTYVALUE_Auto:
- return FDE_CSSRUBYOVERHANG_Auto;
- case FDE_CSSPROPERTYVALUE_Start:
- return FDE_CSSRUBYOVERHANG_Start;
- case FDE_CSSPROPERTYVALUE_End:
- return FDE_CSSRUBYOVERHANG_End;
- case FDE_CSSPROPERTYVALUE_None:
- default:
- return FDE_CSSRUBYOVERHANG_None;
- }
-}
-FDE_CSSRUBYALIGN CFDE_CSSStyleSelector::ToRubyAlign(
- FDE_CSSPROPERTYVALUE eValue) {
- switch (eValue) {
- case FDE_CSSPROPERTYVALUE_Auto:
- return FDE_CSSRUBYALIGN_Auto;
- case FDE_CSSPROPERTYVALUE_Start:
- return FDE_CSSRUBYALIGN_Start;
- case FDE_CSSPROPERTYVALUE_Left:
- return FDE_CSSRUBYALIGN_End;
- case FDE_CSSPROPERTYVALUE_Center:
- return FDE_CSSRUBYALIGN_Center;
- case FDE_CSSPROPERTYVALUE_End:
- return FDE_CSSRUBYALIGN_End;
- case FDE_CSSPROPERTYVALUE_Right:
- return FDE_CSSRUBYALIGN_Right;
- case FDE_CSSPROPERTYVALUE_DistributeLetter:
- return FDE_CSSRUBYALIGN_DistributeLetter;
- case FDE_CSSPROPERTYVALUE_DistributeSpace:
- return FDE_CSSRUBYALIGN_DistributeSpace;
- case FDE_CSSPROPERTYVALUE_LineEdge:
- return FDE_CSSRUBYALIGN_LineEdge;
- default:
- return FDE_CSSRUBYALIGN_Auto;
- }
-}
-FX_BOOL CFDE_CSSStyleSelector::ToTextEmphasisMark(
- FDE_CSSPROPERTYVALUE eValue,
- FDE_CSSTEXTEMPHASISMARK& eMark) {
- switch (eValue) {
- case FDE_CSSPROPERTYVALUE_None:
- eMark = FDE_CSSTEXTEMPHASISMARK_None;
- return TRUE;
- case FDE_CSSPROPERTYVALUE_Dot:
- eMark = FDE_CSSTEXTEMPHASISMARK_Dot;
- return TRUE;
- case FDE_CSSPROPERTYVALUE_Circle:
- eMark = FDE_CSSTEXTEMPHASISMARK_Circle;
- return TRUE;
- case FDE_CSSPROPERTYVALUE_DoubleCircle:
- eMark = FDE_CSSTEXTEMPHASISMARK_DoubleCircle;
- return TRUE;
- case FDE_CSSPROPERTYVALUE_Triangle:
- eMark = FDE_CSSTEXTEMPHASISMARK_Triangle;
- return TRUE;
- case FDE_CSSPROPERTYVALUE_Sesame:
- eMark = FDE_CSSTEXTEMPHASISMARK_Sesame;
- return TRUE;
- default:
- return FALSE;
- }
-}
-FX_BOOL CFDE_CSSStyleSelector::ToTextEmphasisFill(
- FDE_CSSPROPERTYVALUE eValue,
- FDE_CSSTEXTEMPHASISFILL& eFill) {
- switch (eValue) {
- case FDE_CSSPROPERTYVALUE_Filled:
- eFill = FDE_CSSTEXTEMPHASISFILL_Filled;
- return TRUE;
- case FDE_CSSPROPERTYVALUE_Open:
- eFill = FDE_CSSTEXTEMPHASISFILL_Open;
- return TRUE;
- default:
- return FALSE;
- }
-}
-FDE_CSSBKGATTACHMENT CFDE_CSSStyleSelector::ToBKGAttachment(
- FDE_CSSPROPERTYVALUE eValue) {
- switch (eValue) {
- case FDE_CSSPROPERTYVALUE_Fixed:
- return FDE_CSSBKGATTACHMENT_Fixed;
- case FDE_CSSPROPERTYVALUE_Scroll:
- return FDE_CSSBKGATTACHMENT_Scroll;
- default:
- return FDE_CSSBKGATTACHMENT_Fixed;
- }
-}
-FDE_CSSCAPTIONSIDE CFDE_CSSStyleSelector::ToCaptionSide(
- FDE_CSSPROPERTYVALUE eValue) {
- switch (eValue) {
- case FDE_CSSPROPERTYVALUE_Top:
- return FDE_CSSCAPTIONSIDE_Top;
- case FDE_CSSPROPERTYVALUE_Bottom:
- return FDE_CSSCAPTIONSIDE_Bottom;
- case FDE_CSSPROPERTYVALUE_Left:
- return FDE_CSSCAPTIONSIDE_Left;
- case FDE_CSSPROPERTYVALUE_Right:
- return FDE_CSSCAPTIONSIDE_Right;
- case FDE_CSSPROPERTYVALUE_Before:
- return FDE_CSSCAPTIONSIDE_Before;
- case FDE_CSSPROPERTYVALUE_After:
- return FDE_CSSCAPTIONSIDE_After;
- default:
- return FDE_CSSCAPTIONSIDE_Top;
- }
-}
-FDE_CSSPOSITION CFDE_CSSStyleSelector::ToPosition(FDE_CSSPROPERTYVALUE eValue) {
- switch (eValue) {
- case FDE_CSSPROPERTYVALUE_Static:
- return FDE_CSSPOSITION_Static;
- case FDE_CSSPROPERTYVALUE_Relative:
- return FDE_CSSPOSITION_Relative;
- case FDE_CSSPROPERTYVALUE_Fixed:
- return FDE_CSSPOSITION_Fixed;
- case FDE_CSSPROPERTYVALUE_Absolute:
- return FDE_CSSPOSITION_Absolute;
- default:
- return FDE_CSSPOSITION_Static;
- }
-}
-FDE_CSSCURSOR CFDE_CSSStyleSelector::ToCursor(FDE_CSSPROPERTYVALUE eValue) {
- switch (eValue) {
- case FDE_CSSPROPERTYVALUE_Auto:
- return FDE_CSSCURSOR_Auto;
- case FDE_CSSPROPERTYVALUE_Crosshair:
- return FDE_CSSCURSOR_Crosshair;
- case FDE_CSSPROPERTYVALUE_Default:
- return FDE_CSSCURSOR_Default;
- case FDE_CSSPROPERTYVALUE_Pointer:
- return FDE_CSSCURSOR_Pointer;
- case FDE_CSSPROPERTYVALUE_Move:
- return FDE_CSSCURSOR_Move;
- case FDE_CSSPROPERTYVALUE_EResize:
- return FDE_CSSCURSOR_EResize;
- case FDE_CSSPROPERTYVALUE_NeResize:
- return FDE_CSSCURSOR_NeResize;
- case FDE_CSSPROPERTYVALUE_NwResize:
- return FDE_CSSCURSOR_NwResize;
- case FDE_CSSPROPERTYVALUE_NResize:
- return FDE_CSSCURSOR_NResize;
- case FDE_CSSPROPERTYVALUE_SeResize:
- return FDE_CSSCURSOR_SeResize;
- case FDE_CSSPROPERTYVALUE_SwResize:
- return FDE_CSSCURSOR_SwResize;
- default:
- return FDE_CSSCURSOR_Auto;
- }
-}
-FDE_CSSBKGREPEAT CFDE_CSSStyleSelector::ToBKGRepeat(
- FDE_CSSPROPERTYVALUE eValue) {
- switch (eValue) {
- case FDE_CSSPROPERTYVALUE_Repeat:
- return FDE_CSSBKGREPEAT_Repeat;
- case FDE_CSSPROPERTYVALUE_RepeatX:
- return FDE_CSSBKGREPEAT_RepeatX;
- case FDE_CSSPROPERTYVALUE_RepeatY:
- return FDE_CSSBKGREPEAT_RepeatY;
- case FDE_CSSPROPERTYVALUE_NoRepeat:
- return FDE_CSSBKGREPEAT_NoRepeat;
- default:
- return FDE_CSSBKGREPEAT_Repeat;
- }
-}
-FDE_CSSTEXTCOMBINE CFDE_CSSStyleSelector::ToTextCombine(
- FDE_CSSPROPERTYVALUE eValue) {
- switch (eValue) {
- case FDE_CSSPROPERTYVALUE_Horizontal:
- return FDE_CSSTEXTCOMBINE_Horizontal;
- case FDE_CSSPROPERTYVALUE_None:
- default:
- return FDE_CSSTEXTCOMBINE_None;
- }
-}
-FDE_CSSLINEBREAK CFDE_CSSStyleSelector::ToLineBreak(
- FDE_CSSPROPERTYVALUE eValue) {
- switch (eValue) {
- case FDE_CSSPROPERTYVALUE_Auto:
- return FDE_CSSLINEBREAK_Auto;
- case FDE_CSSPROPERTYVALUE_Loose:
- return FDE_CSSLINEBREAK_Loose;
- case FDE_CSSPROPERTYVALUE_Normal:
- return FDE_CSSLINEBREAK_Normal;
- case FDE_CSSPROPERTYVALUE_Strict:
- return FDE_CSSLINEBREAK_Strict;
- default:
- return FDE_CSSLINEBREAK_Auto;
- }
-}
-FDE_CSSOVERFLOW CFDE_CSSStyleSelector::ToOverflow(FDE_CSSPROPERTYVALUE eValue) {
- switch (eValue) {
- case FDE_CSSPROPERTYVALUE_Visible:
- return FDE_CSSOVERFLOW_Visible;
- case FDE_CSSPROPERTYVALUE_Hidden:
- return FDE_CSSOVERFLOW_Hidden;
- case FDE_CSSPROPERTYVALUE_Scroll:
- return FDE_CSSOVERFLOW_Scroll;
- case FDE_CSSPROPERTYVALUE_Auto:
- return FDE_CSSOVERFLOW_Auto;
- case FDE_CSSPROPERTYVALUE_NoDisplay:
- return FDE_CSSOVERFLOW_NoDisplay;
- case FDE_CSSPROPERTYVALUE_NoContent:
- return FDE_CSSOVERFLOW_NoContent;
- default:
- return FDE_CSSOVERFLOW_Visible;
- }
-}
-FDE_CSSWRITINGMODE CFDE_CSSStyleSelector::ToWritingMode(
- FDE_CSSPROPERTYVALUE eValue) {
- switch (eValue) {
- case FDE_CSSPROPERTYVALUE_HorizontalTb:
- return FDE_CSSWRITINGMODE_HorizontalTb;
- case FDE_CSSPROPERTYVALUE_VerticalRl:
- return FDE_CSSWRITINGMODE_VerticalRl;
- case FDE_CSSPROPERTYVALUE_VerticalLr:
- return FDE_CSSWRITINGMODE_VerticalLr;
- default:
- return FDE_CSSWRITINGMODE_HorizontalTb;
- }
-}
-FDE_CSSWORDBREAK CFDE_CSSStyleSelector::ToWordBreak(
- FDE_CSSPROPERTYVALUE eValue) {
- switch (eValue) {
- case FDE_CSSPROPERTYVALUE_Normal:
- return FDE_CSSWORDBREAK_Normal;
- case FDE_CSSPROPERTYVALUE_KeepAll:
- return FDE_CSSWORDBREAK_KeepAll;
- case FDE_CSSPROPERTYVALUE_BreakAll:
- return FDE_CSSWORDBREAK_BreakAll;
- case FDE_CSSPROPERTYVALUE_KeepWords:
- return FDE_CSSWORDBREAK_KeepWords;
- default:
- return FDE_CSSWORDBREAK_Normal;
- }
-}
-FDE_CSSFLOAT CFDE_CSSStyleSelector::ToFloat(FDE_CSSPROPERTYVALUE eValue) {
- switch (eValue) {
- case FDE_CSSPROPERTYVALUE_Left:
- return FDE_CSSFLOAT_Left;
- case FDE_CSSPROPERTYVALUE_Right:
- return FDE_CSSFLOAT_Right;
- case FDE_CSSPROPERTYVALUE_None:
- return FDE_CSSFLOAT_None;
- default:
- return FDE_CSSFLOAT_None;
- }
-}
-FDE_CSSCLEAR CFDE_CSSStyleSelector::ToClear(FDE_CSSPROPERTYVALUE eValue) {
- switch (eValue) {
- case FDE_CSSPROPERTYVALUE_None:
- return FDE_CSSCLEAR_None;
- case FDE_CSSPROPERTYVALUE_Left:
- return FDE_CSSCLEAR_Left;
- case FDE_CSSPROPERTYVALUE_Right:
- return FDE_CSSCLEAR_Right;
- case FDE_CSSPROPERTYVALUE_Both:
- return FDE_CSSCLEAR_Both;
- default:
- return FDE_CSSCLEAR_None;
- }
-}
-FDE_CSSPAGEBREAK CFDE_CSSStyleSelector::ToPageBreak(
- FDE_CSSPROPERTYVALUE eValue) {
- switch (eValue) {
- case FDE_CSSPROPERTYVALUE_Avoid:
- return FDE_CSSPAGEBREAK_Avoid;
- case FDE_CSSPROPERTYVALUE_Auto:
- return FDE_CSSPAGEBREAK_Auto;
- case FDE_CSSPROPERTYVALUE_Always:
- return FDE_CSSPAGEBREAK_Always;
- case FDE_CSSPROPERTYVALUE_Left:
- return FDE_CSSPAGEBREAK_Left;
- case FDE_CSSPROPERTYVALUE_Right:
- return FDE_CSSPAGEBREAK_Right;
- default:
- return FDE_CSSPAGEBREAK_Auto;
- }
-}
-FDE_CSSDISPLAY CFDE_CSSStyleSelector::ToDisplay(FDE_CSSPROPERTYVALUE eValue) {
- switch (eValue) {
- case FDE_CSSPROPERTYVALUE_Inline:
- return FDE_CSSDISPLAY_Inline;
- case FDE_CSSPROPERTYVALUE_Block:
- return FDE_CSSDISPLAY_Block;
- case FDE_CSSPROPERTYVALUE_None:
- return FDE_CSSDISPLAY_None;
- case FDE_CSSPROPERTYVALUE_ListItem:
- return FDE_CSSDISPLAY_ListItem;
- case FDE_CSSPROPERTYVALUE_TableCell:
- return FDE_CSSDISPLAY_TableCell;
- case FDE_CSSPROPERTYVALUE_TableRow:
- return FDE_CSSDISPLAY_TableRow;
- case FDE_CSSPROPERTYVALUE_Table:
- return FDE_CSSDISPLAY_Table;
- case FDE_CSSPROPERTYVALUE_TableCaption:
- return FDE_CSSDISPLAY_TableCaption;
- case FDE_CSSPROPERTYVALUE_TableRowGroup:
- return FDE_CSSDISPLAY_TableRowGroup;
- case FDE_CSSPROPERTYVALUE_TableHeaderGroup:
- return FDE_CSSDISPLAY_TableHeaderGroup;
- case FDE_CSSPROPERTYVALUE_TableFooterGroup:
- return FDE_CSSDISPLAY_TableFooterGroup;
- case FDE_CSSPROPERTYVALUE_TableColumnGroup:
- return FDE_CSSDISPLAY_TableColumnGroup;
- case FDE_CSSPROPERTYVALUE_TableColumn:
- return FDE_CSSDISPLAY_TableColumn;
- case FDE_CSSPROPERTYVALUE_InlineTable:
- return FDE_CSSDISPLAY_InlineTable;
- case FDE_CSSPROPERTYVALUE_InlineBlock:
- return FDE_CSSDISPLAY_InlineBlock;
- case FDE_CSSPROPERTYVALUE_RunIn:
- return FDE_CSSDISPLAY_RunIn;
- case FDE_CSSPROPERTYVALUE_Ruby:
- return FDE_CSSDISPLAY_Ruby;
- case FDE_CSSPROPERTYVALUE_RubyBase:
- return FDE_CSSDISPLAY_RubyBase;
- case FDE_CSSPROPERTYVALUE_RubyText:
- return FDE_CSSDISPLAY_RubyText;
- case FDE_CSSPROPERTYVALUE_RubyBaseGroup:
- return FDE_CSSDISPLSY_RubyBaseGroup;
- case FDE_CSSPROPERTYVALUE_RubyTextGroup:
- return FDE_CSSDISPLAY_RubyTextGroup;
- default:
- return FDE_CSSDISPLAY_Inline;
- }
-}
-FDE_CSSTEXTALIGN CFDE_CSSStyleSelector::ToTextAlign(
- FDE_CSSPROPERTYVALUE eValue) {
- switch (eValue) {
- case FDE_CSSPROPERTYVALUE_Left:
- return FDE_CSSTEXTALIGN_Left;
- case FDE_CSSPROPERTYVALUE_Center:
- return FDE_CSSTEXTALIGN_Center;
- case FDE_CSSPROPERTYVALUE_Right:
- return FDE_CSSTEXTALIGN_Right;
- case FDE_CSSPROPERTYVALUE_Justify:
- return FDE_CSSTEXTALIGN_Justify;
- default:
- return FDE_CSSTEXTALIGN_Left;
- }
-}
-FX_WORD CFDE_CSSStyleSelector::ToFontWeight(FDE_CSSPROPERTYVALUE eValue) {
- switch (eValue) {
- case FDE_CSSPROPERTYVALUE_Normal:
- return 400;
- case FDE_CSSPROPERTYVALUE_Bold:
- return 700;
- case FDE_CSSPROPERTYVALUE_Bolder:
- return 900;
- case FDE_CSSPROPERTYVALUE_Lighter:
- return 200;
- default:
- return 400;
- }
-}
-FDE_CSSFONTSTYLE CFDE_CSSStyleSelector::ToFontStyle(
- FDE_CSSPROPERTYVALUE eValue) {
- switch (eValue) {
- case FDE_CSSPROPERTYVALUE_Italic:
- case FDE_CSSPROPERTYVALUE_Oblique:
- return FDE_CSSFONTSTYLE_Italic;
- default:
- return FDE_CSSFONTSTYLE_Normal;
- }
-}
-FDE_CSSBORDERSTYLE CFDE_CSSStyleSelector::ToBorderStyle(
- FDE_CSSPROPERTYVALUE eValue) {
- switch (eValue) {
- case FDE_CSSPROPERTYVALUE_None:
- return FDE_CSSBORDERSTYLE_None;
- case FDE_CSSPROPERTYVALUE_Solid:
- return FDE_CSSBORDERSTYLE_Solid;
- case FDE_CSSPROPERTYVALUE_Hidden:
- return FDE_CSSBORDERSTYLE_Hidden;
- case FDE_CSSPROPERTYVALUE_Dotted:
- return FDE_CSSBORDERSTYLE_Dotted;
- case FDE_CSSPROPERTYVALUE_Dashed:
- return FDE_CSSBORDERSTYLE_Dashed;
- case FDE_CSSPROPERTYVALUE_Double:
- return FDE_CSSBORDERSTYLE_Double;
- case FDE_CSSPROPERTYVALUE_Groove:
- return FDE_CSSBORDERSTYLE_Groove;
- case FDE_CSSPROPERTYVALUE_Ridge:
- return FDE_CSSBORDERSTYLE_Ridge;
- case FDE_CSSPROPERTYVALUE_Inset:
- return FDE_CSSBORDERSTYLE_Inset;
- case FDE_CSSPROPERTYVALUE_Outset:
- return FDE_CSSBORDERSTYLE_outset;
- default:
- return FDE_CSSBORDERSTYLE_None;
- }
-}
-FX_BOOL CFDE_CSSStyleSelector::SetLengthWithPercent(
- FDE_CSSLENGTH& width,
- FDE_CSSPRIMITIVETYPE eType,
- IFDE_CSSPrimitiveValue* pPrimitive,
- FX_FLOAT fFontSize) {
- if (eType == FDE_CSSPRIMITIVETYPE_Percent) {
- width.Set(FDE_CSSLENGTHUNIT_Percent, pPrimitive->GetFloat() / 100.0f);
- return width.NonZero();
- } else if (eType >= FDE_CSSPRIMITIVETYPE_Number &&
- eType <= FDE_CSSPRIMITIVETYPE_PC) {
- FX_FLOAT fValue = ApplyNumber(eType, pPrimitive->GetFloat(), fFontSize);
- width.Set(FDE_CSSLENGTHUNIT_Point, fValue);
- return width.NonZero();
- } else if (eType == FDE_CSSPRIMITIVETYPE_Enum) {
- switch (pPrimitive->GetEnum()) {
- case FDE_CSSPROPERTYVALUE_Auto:
- width.Set(FDE_CSSLENGTHUNIT_Auto);
- return TRUE;
- case FDE_CSSPROPERTYVALUE_None:
- width.Set(FDE_CSSLENGTHUNIT_None);
- return TRUE;
- case FDE_CSSPROPERTYVALUE_Thin:
- width.Set(FDE_CSSLENGTHUNIT_Point, 2);
- return TRUE;
- case FDE_CSSPROPERTYVALUE_Medium:
- width.Set(FDE_CSSLENGTHUNIT_Point, 3);
- return TRUE;
- case FDE_CSSPROPERTYVALUE_Thick:
- width.Set(FDE_CSSLENGTHUNIT_Point, 4);
- return TRUE;
- default:
- return FALSE;
- }
- }
- return FALSE;
-}
-FX_FLOAT CFDE_CSSStyleSelector::ToFontSize(FDE_CSSPROPERTYVALUE eValue,
- FX_FLOAT fCurFontSize) {
- switch (eValue) {
- case FDE_CSSPROPERTYVALUE_XxSmall:
- return m_fDefFontSize / 1.2f / 1.2f / 1.2f;
- case FDE_CSSPROPERTYVALUE_XSmall:
- return m_fDefFontSize / 1.2f / 1.2f;
- case FDE_CSSPROPERTYVALUE_Small:
- return m_fDefFontSize / 1.2f;
- case FDE_CSSPROPERTYVALUE_Medium:
- return m_fDefFontSize;
- case FDE_CSSPROPERTYVALUE_Large:
- return m_fDefFontSize * 1.2f;
- case FDE_CSSPROPERTYVALUE_XLarge:
- return m_fDefFontSize * 1.2f * 1.2f;
- case FDE_CSSPROPERTYVALUE_XxLarge:
- return m_fDefFontSize * 1.2f * 1.2f * 1.2f;
- case FDE_CSSPROPERTYVALUE_Larger:
- return fCurFontSize * 1.2f;
- case FDE_CSSPROPERTYVALUE_Smaller:
- return fCurFontSize / 1.2f;
- default:
- return fCurFontSize;
- }
-}
-FDE_CSSVERTICALALIGN CFDE_CSSStyleSelector::ToVerticalAlign(
- FDE_CSSPROPERTYVALUE eValue) {
- switch (eValue) {
- case FDE_CSSPROPERTYVALUE_Baseline:
- return FDE_CSSVERTICALALIGN_Baseline;
- case FDE_CSSPROPERTYVALUE_Middle:
- return FDE_CSSVERTICALALIGN_Middle;
- case FDE_CSSPROPERTYVALUE_Bottom:
- return FDE_CSSVERTICALALIGN_Bottom;
- case FDE_CSSPROPERTYVALUE_Super:
- return FDE_CSSVERTICALALIGN_Super;
- case FDE_CSSPROPERTYVALUE_Sub:
- return FDE_CSSVERTICALALIGN_Sub;
- case FDE_CSSPROPERTYVALUE_Top:
- return FDE_CSSVERTICALALIGN_Top;
- case FDE_CSSPROPERTYVALUE_TextTop:
- return FDE_CSSVERTICALALIGN_TextTop;
- case FDE_CSSPROPERTYVALUE_TextBottom:
- return FDE_CSSVERTICALALIGN_TextBottom;
- default:
- return FDE_CSSVERTICALALIGN_Baseline;
- }
-}
-FDE_CSSLISTSTYLETYPE CFDE_CSSStyleSelector::ToListStyleType(
- FDE_CSSPROPERTYVALUE eValue) {
- switch (eValue) {
- case FDE_CSSPROPERTYVALUE_None:
- return FDE_CSSLISTSTYLETYPE_None;
- case FDE_CSSPROPERTYVALUE_Disc:
- return FDE_CSSLISTSTYLETYPE_Disc;
- case FDE_CSSPROPERTYVALUE_Circle:
- return FDE_CSSLISTSTYLETYPE_Circle;
- case FDE_CSSPROPERTYVALUE_Square:
- return FDE_CSSLISTSTYLETYPE_Square;
- case FDE_CSSPROPERTYVALUE_Decimal:
- return FDE_CSSLISTSTYLETYPE_Decimal;
- case FDE_CSSPROPERTYVALUE_DecimalLeadingZero:
- return FDE_CSSLISTSTYLETYPE_DecimalLeadingZero;
- case FDE_CSSPROPERTYVALUE_LowerRoman:
- return FDE_CSSLISTSTYLETYPE_LowerRoman;
- case FDE_CSSPROPERTYVALUE_UpperRoman:
- return FDE_CSSLISTSTYLETYPE_UpperRoman;
- case FDE_CSSPROPERTYVALUE_LowerGreek:
- return FDE_CSSLISTSTYLETYPE_LowerGreek;
- case FDE_CSSPROPERTYVALUE_LowerLatin:
- return FDE_CSSLISTSTYLETYPE_LowerLatin;
- case FDE_CSSPROPERTYVALUE_UpperLatin:
- return FDE_CSSLISTSTYLETYPE_UpperLatin;
- case FDE_CSSPROPERTYVALUE_Armenian:
- return FDE_CSSLISTSTYLETYPE_Armenian;
- case FDE_CSSPROPERTYVALUE_Georgian:
- return FDE_CSSLISTSTYLETYPE_Georgian;
- case FDE_CSSPROPERTYVALUE_LowerAlpha:
- return FDE_CSSLISTSTYLETYPE_LowerAlpha;
- case FDE_CSSPROPERTYVALUE_UpperAlpha:
- return FDE_CSSLISTSTYLETYPE_UpperAlpha;
- case FDE_CSSPROPERTYVALUE_CjkIdeographic:
- return FDE_CSSLISTSTYLETYPE_CjkIdeographic;
- case FDE_CSSPROPERTYVALUE_Hebrew:
- return FDE_CSSLISTSTYLETYPE_Hebrew;
- case FDE_CSSLISTSTYLETYPE_Hiragana:
- return FDE_CSSLISTSTYLETYPE_Hiragana;
- case FDE_CSSLISTSTYLETYPE_HiraganaIroha:
- return FDE_CSSLISTSTYLETYPE_HiraganaIroha;
- case FDE_CSSLISTSTYLETYPE_Katakana:
- return FDE_CSSLISTSTYLETYPE_Katakana;
- case FDE_CSSLISTSTYLETYPE_KatakanaIroha:
- return FDE_CSSLISTSTYLETYPE_KatakanaIroha;
- default:
- return FDE_CSSLISTSTYLETYPE_Disc;
- }
-}
-FDE_CSSLISTSTYLEPOSITION CFDE_CSSStyleSelector::ToListStylePosition(
- FDE_CSSPROPERTYVALUE eValue) {
- return eValue == FDE_CSSPROPERTYVALUE_Inside
- ? FDE_CSSLISTSTYLEPOSITION_Inside
- : FDE_CSSLISTSTYLEPOSITION_Outside;
-}
-FDE_CSSVISIBILITY CFDE_CSSStyleSelector::ToVisibility(
- FDE_CSSPROPERTYVALUE eValue) {
- switch (eValue) {
- case FDE_CSSPROPERTYVALUE_Visible:
- return FDE_CSSVISIBILITY_Visible;
- case FDE_CSSPROPERTYVALUE_Hidden:
- return FDE_CSSVISIBILITY_Hidden;
- case FDE_CSSPROPERTYVALUE_Collapse:
- return FDE_CSSVISIBILITY_Collapse;
- default:
- return FDE_CSSVISIBILITY_Visible;
- }
-}
-FDE_CSSWHITESPACE CFDE_CSSStyleSelector::ToWhiteSpace(
- FDE_CSSPROPERTYVALUE eValue) {
- switch (eValue) {
- case FDE_CSSPROPERTYVALUE_Normal:
- return FDE_CSSWHITESPACE_Normal;
- case FDE_CSSPROPERTYVALUE_Pre:
- return FDE_CSSWHITESPACE_Pre;
- case FDE_CSSPROPERTYVALUE_Nowrap:
- return FDE_CSSWHITESPACE_Nowrap;
- case FDE_CSSPROPERTYVALUE_PreWrap:
- return FDE_CSSWHITESPACE_PreWrap;
- case FDE_CSSPROPERTYVALUE_PreLine:
- return FDE_CSSWHITESPACE_PreLine;
- default:
- return FDE_CSSWHITESPACE_Normal;
- }
-}
-FX_DWORD CFDE_CSSStyleSelector::ToTextDecoration(IFDE_CSSValueList* pValue) {
- FX_DWORD dwDecoration = 0;
- for (int32_t i = pValue->CountValues() - 1; i >= 0; --i) {
- IFDE_CSSPrimitiveValue* pPrimitive =
- (IFDE_CSSPrimitiveValue*)pValue->GetValue(i);
- if (pPrimitive->GetPrimitiveType() == FDE_CSSPRIMITIVETYPE_Enum) {
- switch (pPrimitive->GetEnum()) {
- case FDE_CSSPROPERTYVALUE_Underline:
- dwDecoration |= FDE_CSSTEXTDECORATION_Underline;
- break;
- case FDE_CSSPROPERTYVALUE_LineThrough:
- dwDecoration |= FDE_CSSTEXTDECORATION_LineThrough;
- break;
- case FDE_CSSPROPERTYVALUE_Overline:
- dwDecoration |= FDE_CSSTEXTDECORATION_Overline;
- break;
- case FDE_CSSPROPERTYVALUE_Blink:
- dwDecoration |= FDE_CSSTEXTDECORATION_Blink;
- break;
- case FDE_CSSPROPERTYVALUE_Double:
- dwDecoration |= FDE_CSSTEXTDECORATION_Double;
- break;
- default:
- break;
- }
- }
- }
- return dwDecoration;
-}
-FDE_CSSTEXTTRANSFORM CFDE_CSSStyleSelector::ToTextTransform(
- FDE_CSSPROPERTYVALUE eValue) {
- switch (eValue) {
- case FDE_CSSPROPERTYVALUE_None:
- return FDE_CSSTEXTTRANSFORM_None;
- case FDE_CSSPROPERTYVALUE_Capitalize:
- return FDE_CSSTEXTTRANSFORM_Capitalize;
- case FDE_CSSPROPERTYVALUE_Uppercase:
- return FDE_CSSTEXTTRANSFORM_UpperCase;
- case FDE_CSSPROPERTYVALUE_Lowercase:
- return FDE_CSSTEXTTRANSFORM_LowerCase;
- default:
- return FDE_CSSTEXTTRANSFORM_None;
- }
-}
-FDE_CSSFONTVARIANT CFDE_CSSStyleSelector::ToFontVariant(
- FDE_CSSPROPERTYVALUE eValue) {
- return eValue == FDE_CSSPROPERTYVALUE_SmallCaps ? FDE_CSSFONTVARIANT_SmallCaps
- : FDE_CSSFONTVARIANT_Normal;
-}
diff --git a/xfa/src/fde/css/fde_cssstyleselector.h b/xfa/src/fde/css/fde_cssstyleselector.h
deleted file mode 100644
index 5f5ee095be..0000000000
--- a/xfa/src/fde/css/fde_cssstyleselector.h
+++ /dev/null
@@ -1,901 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifndef XFA_SRC_FDE_CSS_FDE_CSSSTYLESELECTOR_H_
-#define XFA_SRC_FDE_CSS_FDE_CSSSTYLESELECTOR_H_
-
-#include <vector>
-
-#include "core/include/fxcrt/fx_ext.h"
-#include "xfa/src/fde/css/fde_css.h"
-#include "xfa/src/fde/css/fde_csscache.h"
-#include "xfa/src/fde/css/fde_cssdeclaration.h"
-#include "xfa/src/fgas/crt/fgas_memory.h"
-#include "xfa/src/fgas/crt/fgas_system.h"
-
-#define FDE_CSSUNIVERSALHASH ('*')
-
-class FDE_CSSRuleData : public CFX_Target {
- public:
- FDE_CSSRuleData(IFDE_CSSSelector* pSel,
- IFDE_CSSDeclaration* pDecl,
- FX_DWORD dwPos);
-
- IFDE_CSSSelector* pSelector;
- IFDE_CSSDeclaration* pDeclaration;
- FX_DWORD dwPriority;
- FDE_CSSRuleData* pNext;
-};
-
-class CFDE_CSSRuleCollection : public CFX_Target {
- public:
- CFDE_CSSRuleCollection()
- : m_pStaticStore(nullptr),
- m_pUniversalRules(nullptr),
- m_pPersudoRules(nullptr),
- m_iSelectors(0) {}
- ~CFDE_CSSRuleCollection() { Clear(); }
- void AddRulesFrom(const CFDE_CSSStyleSheetArray& sheets,
- FX_DWORD dwMediaList,
- IFX_FontMgr* pFontMgr);
- void Clear();
-
- int32_t CountSelectors() const { return m_iSelectors; }
- FDE_CSSRuleData* GetIDRuleData(FX_DWORD dwIDHash) {
- void* pData;
- return m_IDRules.Lookup((void*)(uintptr_t)dwIDHash, pData)
- ? (FDE_CSSRuleData*)pData
- : NULL;
- }
- FDE_CSSRuleData* GetTagRuleData(FX_DWORD dwTagHasn) {
- void* pData;
- return m_TagRules.Lookup((void*)(uintptr_t)dwTagHasn, pData)
- ? (FDE_CSSRuleData*)pData
- : NULL;
- }
- FDE_CSSRuleData* GetClassRuleData(FX_DWORD dwIDHash) {
- void* pData;
- return m_ClassRules.Lookup((void*)(uintptr_t)dwIDHash, pData)
- ? (FDE_CSSRuleData*)pData
- : NULL;
- }
- FDE_CSSRuleData* GetUniversalRuleData() { return m_pUniversalRules; }
- FDE_CSSRuleData* GetPersudoRuleData() { return m_pPersudoRules; }
- IFX_MEMAllocator* m_pStaticStore;
-
- protected:
- void AddRulesFrom(IFDE_CSSStyleSheet* pStyleSheet,
- IFDE_CSSRule* pRule,
- FX_DWORD dwMediaList,
- IFX_FontMgr* pFontMgr);
- void AddRuleTo(CFX_MapPtrToPtr& map,
- FX_DWORD dwKey,
- IFDE_CSSSelector* pSel,
- IFDE_CSSDeclaration* pDecl);
- FX_BOOL AddRuleTo(FDE_CSSRuleData*& pList, FDE_CSSRuleData* pData);
- FDE_CSSRuleData* NewRuleData(IFDE_CSSSelector* pSel,
- IFDE_CSSDeclaration* pDecl);
- CFX_MapPtrToPtr m_IDRules;
- CFX_MapPtrToPtr m_TagRules;
- CFX_MapPtrToPtr m_ClassRules;
- FDE_CSSRuleData* m_pUniversalRules;
- FDE_CSSRuleData* m_pPersudoRules;
- int32_t m_iSelectors;
-};
-class CFDE_CSSAccelerator;
-class CFDE_CSSComputedStyle;
-class CFDE_CSSStyleSelector : public IFDE_CSSStyleSelector, public CFX_Target {
- public:
- CFDE_CSSStyleSelector();
- ~CFDE_CSSStyleSelector();
- virtual void Release() { delete this; }
-
- virtual void SetFontMgr(IFX_FontMgr* pFontMgr);
- virtual void SetDefFontSize(FX_FLOAT fFontSize);
-
- virtual FX_BOOL SetStyleSheet(FDE_CSSSTYLESHEETGROUP eType,
- IFDE_CSSStyleSheet* pSheet);
- virtual FX_BOOL SetStyleSheets(FDE_CSSSTYLESHEETGROUP eType,
- const CFDE_CSSStyleSheetArray* pArray);
- virtual void SetStylePriority(FDE_CSSSTYLESHEETGROUP eType,
- FDE_CSSSTYLESHEETPRIORITY ePriority);
- virtual void UpdateStyleIndex(FX_DWORD dwMediaList);
- virtual IFDE_CSSAccelerator* InitAccelerator();
- virtual IFDE_CSSComputedStyle* CreateComputedStyle(
- IFDE_CSSComputedStyle* pParentStyle);
- virtual int32_t MatchDeclarations(
- IFDE_CSSTagProvider* pTag,
- CFDE_CSSDeclarationArray& matchedDecls,
- FDE_CSSPERSUDO ePersudoType = FDE_CSSPERSUDO_NONE);
- virtual void ComputeStyle(IFDE_CSSTagProvider* pTag,
- const IFDE_CSSDeclaration** ppDeclArray,
- int32_t iDeclCount,
- IFDE_CSSComputedStyle* pDestStyle);
-
- protected:
- void Reset();
- void MatchRules(FDE_CSSTagCache* pCache,
- FDE_CSSRuleData* pList,
- FDE_CSSPERSUDO ePersudoType);
- FX_BOOL MatchSelector(FDE_CSSTagCache* pCache,
- IFDE_CSSSelector* pSel,
- FDE_CSSPERSUDO ePersudoType);
- void AppendInlineStyle(CFDE_CSSDeclaration* pDecl,
- const FX_WCHAR* psz,
- int32_t iLen);
- void ApplyDeclarations(FX_BOOL bPriority,
- const IFDE_CSSDeclaration** ppDeclArray,
- int32_t iDeclCount,
- IFDE_CSSComputedStyle* pDestStyle);
- void ApplyProperty(FDE_CSSPROPERTY eProperty,
- IFDE_CSSValue* pValue,
- CFDE_CSSComputedStyle* pComputedStyle);
-
- FX_FLOAT ApplyNumber(FDE_CSSPRIMITIVETYPE eUnit,
- FX_FLOAT fValue,
- FX_FLOAT fPercentBase);
- FX_BOOL SetLengthWithPercent(FDE_CSSLENGTH& width,
- FDE_CSSPRIMITIVETYPE eType,
- IFDE_CSSPrimitiveValue* pPrimitive,
- FX_FLOAT fFontSize);
- FX_FLOAT ToFontSize(FDE_CSSPROPERTYVALUE eValue, FX_FLOAT fCurFontSize);
- FDE_CSSDISPLAY ToDisplay(FDE_CSSPROPERTYVALUE eValue);
- FDE_CSSTEXTALIGN ToTextAlign(FDE_CSSPROPERTYVALUE eValue);
- FX_WORD ToFontWeight(FDE_CSSPROPERTYVALUE eValue);
- FDE_CSSFONTSTYLE ToFontStyle(FDE_CSSPROPERTYVALUE eValue);
- FDE_CSSBORDERSTYLE ToBorderStyle(FDE_CSSPROPERTYVALUE eValue);
- FDE_CSSVERTICALALIGN ToVerticalAlign(FDE_CSSPROPERTYVALUE eValue);
- FDE_CSSLISTSTYLETYPE ToListStyleType(FDE_CSSPROPERTYVALUE eValue);
- FDE_CSSLISTSTYLEPOSITION ToListStylePosition(FDE_CSSPROPERTYVALUE eValue);
- FDE_CSSVISIBILITY ToVisibility(FDE_CSSPROPERTYVALUE eValue);
- FDE_CSSWHITESPACE ToWhiteSpace(FDE_CSSPROPERTYVALUE eValue);
- FX_DWORD ToTextDecoration(IFDE_CSSValueList* pList);
- FDE_CSSTEXTTRANSFORM ToTextTransform(FDE_CSSPROPERTYVALUE eValue);
- FDE_CSSFONTVARIANT ToFontVariant(FDE_CSSPROPERTYVALUE eValue);
- FDE_CSSFLOAT ToFloat(FDE_CSSPROPERTYVALUE eValue);
- FDE_CSSCLEAR ToClear(FDE_CSSPROPERTYVALUE eValue);
- FDE_CSSWRITINGMODE ToWritingMode(FDE_CSSPROPERTYVALUE eValue);
- FDE_CSSWORDBREAK ToWordBreak(FDE_CSSPROPERTYVALUE eValue);
- FDE_CSSPAGEBREAK ToPageBreak(FDE_CSSPROPERTYVALUE eValue);
- FDE_CSSOVERFLOW ToOverflow(FDE_CSSPROPERTYVALUE eValue);
- FDE_CSSLINEBREAK ToLineBreak(FDE_CSSPROPERTYVALUE eValue);
- FDE_CSSTEXTCOMBINE ToTextCombine(FDE_CSSPROPERTYVALUE eValue);
- FX_BOOL ToTextEmphasisMark(FDE_CSSPROPERTYVALUE eValue,
- FDE_CSSTEXTEMPHASISMARK& eMark);
- FX_BOOL ToTextEmphasisFill(FDE_CSSPROPERTYVALUE eValue,
- FDE_CSSTEXTEMPHASISFILL& eFill);
- FDE_CSSCURSOR ToCursor(FDE_CSSPROPERTYVALUE eValue);
- FDE_CSSPOSITION ToPosition(FDE_CSSPROPERTYVALUE eValue);
- FDE_CSSCAPTIONSIDE ToCaptionSide(FDE_CSSPROPERTYVALUE eValue);
- FDE_CSSBKGREPEAT ToBKGRepeat(FDE_CSSPROPERTYVALUE eValue);
- FDE_CSSBKGATTACHMENT ToBKGAttachment(FDE_CSSPROPERTYVALUE eValue);
- FDE_CSSRUBYALIGN ToRubyAlign(FDE_CSSPROPERTYVALUE eValue);
- FDE_CSSRUBYOVERHANG ToRubyOverhang(FDE_CSSPROPERTYVALUE eValue);
- FDE_CSSRUBYPOSITION ToRubyPosition(FDE_CSSPROPERTYVALUE eValue);
- FDE_CSSRUBYSPAN ToRubySpan(FDE_CSSPROPERTYVALUE eValue);
- IFX_FontMgr* m_pFontMgr;
- FX_FLOAT m_fDefFontSize;
- IFX_MEMAllocator* m_pRuleDataStore;
- CFDE_CSSStyleSheetArray m_SheetGroups[FDE_CSSSTYLESHEETGROUP_MAX];
- CFDE_CSSRuleCollection m_RuleCollection[FDE_CSSSTYLESHEETGROUP_MAX];
- FDE_CSSSTYLESHEETGROUP m_ePriorities[FDE_CSSSTYLESHEETPRIORITY_MAX];
- IFX_MEMAllocator* m_pInlineStyleStore;
- IFX_MEMAllocator* m_pFixedStyleStore;
- CFDE_CSSAccelerator* m_pAccelerator;
- std::vector<FDE_CSSRuleData*> m_MatchedRules;
-};
-
-struct FDE_CSSCOUNTERDATA {
- public:
- FDE_CSSCOUNTERDATA() { FXSYS_memset(this, 0, sizeof(FDE_CSSCOUNTERDATA)); }
- FX_BOOL GetCounterIncrement(int32_t& iValue) {
- iValue = m_iIncVal;
- return m_bIncrement;
- }
- FX_BOOL GetCounterReset(int32_t& iValue) {
- iValue = m_iResetVal;
- return m_bReset;
- }
-
- const FX_WCHAR* m_pszIdent;
- FX_BOOL m_bIncrement;
- FX_BOOL m_bReset;
- int32_t m_iIncVal;
- int32_t m_iResetVal;
-};
-
-class CFDE_CSSCounterStyle {
- public:
- CFDE_CSSCounterStyle() : m_pCounterInc(NULL), m_pCounterReset(NULL) {}
- void SetCounterIncrementList(IFDE_CSSValueList* pList) {
- m_pCounterInc = pList;
- m_bIndexDirty = TRUE;
- }
- void SetCounterResetList(IFDE_CSSValueList* pList) {
- m_pCounterReset = pList;
- m_bIndexDirty = TRUE;
- }
- int32_t CountCounters() {
- UpdateIndex();
- return m_arrCounterData.GetSize();
- }
- FX_BOOL GetCounterIncrement(int32_t index, int32_t& iValue) {
- UpdateIndex();
- return m_arrCounterData.ElementAt(index).GetCounterIncrement(iValue);
- }
- FX_BOOL GetCounterReset(int32_t index, int32_t& iValue) {
- UpdateIndex();
- return m_arrCounterData.ElementAt(index).GetCounterReset(iValue);
- }
- const FX_WCHAR* GetCounterIdentifier(int32_t index) {
- UpdateIndex();
- return m_arrCounterData.ElementAt(index).m_pszIdent;
- }
-
- protected:
- void UpdateIndex();
- void DoUpdateIndex(IFDE_CSSValueList* pList);
- int32_t FindIndex(const FX_WCHAR* pszIdentifier);
- IFDE_CSSValueList* m_pCounterInc;
- IFDE_CSSValueList* m_pCounterReset;
- CFX_ArrayTemplate<FDE_CSSCOUNTERDATA> m_arrCounterData;
- FX_BOOL m_bIndexDirty;
-};
-class CFDE_CSSInheritedData {
- public:
- void Reset() {
- FXSYS_memset(this, 0, sizeof(CFDE_CSSInheritedData));
- m_LetterSpacing.Set(FDE_CSSLENGTHUNIT_Normal);
- m_WordSpacing.Set(FDE_CSSLENGTHUNIT_Normal);
- m_TextIndent.Set(FDE_CSSLENGTHUNIT_Point, 0);
- m_fFontSize = 12.0f;
- m_fLineHeight = 14.0f;
- m_wFontWeight = 400;
- m_dwFontColor = 0xFF000000;
- m_iWidows = 2;
- m_bTextEmphasisColorCurrent = TRUE;
- m_iOrphans = 2;
- }
- const FX_WCHAR* m_pszListStyleImage;
- FDE_CSSLENGTH m_LetterSpacing;
- FDE_CSSLENGTH m_WordSpacing;
- FDE_CSSLENGTH m_TextIndent;
- IFDE_CSSValueList* m_pFontFamily;
- IFDE_CSSValueList* m_pQuotes;
- IFDE_CSSValueList* m_pCursorUris;
- FDE_CSSCURSOR m_eCursor;
- FX_FLOAT m_fFontSize;
- FX_FLOAT m_fLineHeight;
- FX_ARGB m_dwFontColor;
- FX_ARGB m_dwTextEmphasisColor;
- FX_WORD m_wFontWeight;
- int32_t m_iWidows;
- int32_t m_iOrphans;
- const FX_WCHAR* m_pszTextEmphasisCustomMark;
- FX_WORD m_eFontVariant : 1;
- FX_WORD m_eFontStyle : 1;
- FX_WORD m_bTextEmphasisColorCurrent : 1;
- FX_WORD m_eTextAligh : 2;
- FX_WORD m_eVisibility : 2;
- FX_WORD m_eWhiteSpace : 3;
- FX_WORD m_eTextTransform : 2;
- FX_WORD m_eWritingMode : 2;
- FX_WORD m_eWordBreak : 2;
- FX_WORD m_eLineBreak : 2;
- FX_WORD m_eTextEmphasisFill : 1;
- FX_WORD m_eTextEmphasisMark : 3;
- FX_WORD m_eCaptionSide : 3;
-
- FX_WORD m_eRubyAlign : 4;
- FX_WORD m_eRubyOverhang : 2;
- FX_WORD m_eRubyPosition : 2;
-};
-class CFDE_CSSNonInheritedData {
- public:
- void Reset() {
- FXSYS_memset(this, 0, sizeof(CFDE_CSSNonInheritedData));
- m_MarginWidth = m_BorderWidth =
- m_PaddingWidth.Set(FDE_CSSLENGTHUNIT_Point, 0);
- m_MinBoxSize.Set(FDE_CSSLENGTHUNIT_Point, 0);
- m_MaxBoxSize.Set(FDE_CSSLENGTHUNIT_None);
- m_eDisplay = FDE_CSSDISPLAY_Inline;
- m_fVerticalAlign = 0.0f;
- m_ColumnCount.Set(FDE_CSSLENGTHUNIT_Auto);
- m_ColumnGap.Set(FDE_CSSLENGTHUNIT_Normal);
- m_bColumnRuleColorSame = TRUE;
- m_ColumnWidth.Set(FDE_CSSLENGTHUNIT_Auto);
- m_ColumnRuleWidth.Set(FDE_CSSLENGTHUNIT_Auto);
- m_eTextCombine = FDE_CSSTEXTCOMBINE_None;
- }
-
- IFDE_CSSValueList* m_pContentList;
- CFDE_CSSCounterStyle* m_pCounterStyle;
- FDE_CSSRECT m_MarginWidth;
- FDE_CSSRECT m_BorderWidth;
- FDE_CSSRECT m_PaddingWidth;
- FDE_CSSSIZE m_BoxSize;
- FDE_CSSSIZE m_MinBoxSize;
- FDE_CSSSIZE m_MaxBoxSize;
- FDE_CSSPOINT m_BKGPosition;
- const FX_WCHAR* m_pszBKGImage;
- FX_ARGB m_dwBKGColor;
- FX_ARGB m_dwBDRLeftColor;
- FX_ARGB m_dwBDRTopColor;
- FX_ARGB m_dwBDRRightColor;
- FX_ARGB m_dwBDRBottomColor;
- IFDE_CSSValue* m_pRubySpan;
- FDE_CSSLENGTH m_ColumnCount;
- FDE_CSSLENGTH m_ColumnGap;
- FDE_CSSLENGTH m_ColumnRuleWidth;
- FDE_CSSLENGTH m_ColumnWidth;
- FX_ARGB m_dwColumnRuleColor;
- FDE_CSSLENGTH m_Top;
- FDE_CSSLENGTH m_Bottom;
- FDE_CSSLENGTH m_Left;
- FDE_CSSLENGTH m_Right;
-
- FX_FLOAT m_fVerticalAlign;
- FX_FLOAT m_fTextCombineNumber;
- FX_DWORD m_eBDRLeftStyle : 4;
- FX_DWORD m_eBDRTopStyle : 4;
- FX_DWORD m_eBDRRightStyle : 4;
- FX_DWORD m_eBDRBottomStyle : 4;
- FX_DWORD m_eDisplay : 5;
- FX_DWORD m_eVerticalAlign : 4;
- FX_DWORD m_eListStyleType : 5;
- FX_DWORD m_eColumnRuleStyle : 4;
- FX_DWORD m_ePageBreakInside : 3;
- FX_DWORD m_ePageBreakAfter : 3;
- FX_DWORD m_ePageBreakBefore : 3;
- FX_DWORD m_ePosition : 2;
- FX_DWORD m_eBKGRepeat : 2;
- FX_DWORD m_eFloat : 2;
- FX_DWORD m_eClear : 2;
- FX_DWORD m_eOverflowX : 3;
- FX_DWORD m_eOverflowY : 3;
- FX_DWORD m_eListStylePosition : 1;
- FX_DWORD m_eBKGAttachment : 1;
- FX_DWORD m_bHasMargin : 1;
- FX_DWORD m_bHasBorder : 1;
- FX_DWORD m_bHasPadding : 1;
- FX_DWORD m_dwTextDecoration : 5;
- FX_DWORD m_eTextCombine : 1;
- FX_DWORD m_bColumnRuleColorSame : 1;
- FX_DWORD m_bHasTextCombineNumber : 1;
-};
-class CFDE_CSSComputedStyle : public IFDE_CSSComputedStyle,
- public IFDE_CSSFontStyle,
- public IFDE_CSSBoundaryStyle,
- public IFDE_CSSPositionStyle,
- public IFDE_CSSParagraphStyle,
- public IFDE_CSSBackgroundStyle,
- public IFDE_CSSVisualStyle,
- public IFDE_CSSListStyle,
- public IFDE_CSSMultiColumnStyle,
- public IFDE_CSSGeneratedContentStyle,
- public IFDE_CSSTableStyle,
- public IFDE_CSSRubyStyle,
- public CFX_Target {
- public:
- CFDE_CSSComputedStyle(IFX_MEMAllocator* pAlloc)
- : m_dwRefCount(1), m_pAllocator(pAlloc) {}
- ~CFDE_CSSComputedStyle() {}
- virtual FX_DWORD AddRef() { return ++m_dwRefCount; }
- virtual FX_DWORD Release() {
- FX_DWORD dwRefCount = --m_dwRefCount;
- if (dwRefCount == 0) {
- if (m_NonInheritedData.m_pCounterStyle != NULL) {
- delete m_NonInheritedData.m_pCounterStyle;
- }
- FXTARGET_DeleteWith(CFDE_CSSComputedStyle, m_pAllocator, this);
- }
- return dwRefCount;
- }
-
- virtual void Reset() {
- m_InheritedData.Reset();
- m_NonInheritedData.Reset();
- }
- virtual IFDE_CSSFontStyle* GetFontStyles() const {
- return (IFDE_CSSFontStyle * const) this;
- }
- virtual IFDE_CSSBoundaryStyle* GetBoundaryStyles() const {
- return (IFDE_CSSBoundaryStyle * const) this;
- }
- virtual IFDE_CSSPositionStyle* GetPositionStyles() const {
- return (IFDE_CSSPositionStyle * const) this;
- }
- virtual IFDE_CSSParagraphStyle* GetParagraphStyles() const {
- return (IFDE_CSSParagraphStyle * const) this;
- }
- virtual IFDE_CSSBackgroundStyle* GetBackgroundStyles() const {
- return (IFDE_CSSBackgroundStyle * const) this;
- }
- virtual IFDE_CSSVisualStyle* GetVisualStyles() const {
- return (IFDE_CSSVisualStyle * const) this;
- }
- virtual IFDE_CSSListStyle* GetListStyles() const {
- return (IFDE_CSSListStyle * const) this;
- }
- virtual IFDE_CSSTableStyle* GetTableStyle() const {
- return (IFDE_CSSTableStyle * const) this;
- }
- virtual IFDE_CSSMultiColumnStyle* GetMultiColumnStyle() const {
- return (IFDE_CSSMultiColumnStyle * const) this;
- }
- virtual IFDE_CSSGeneratedContentStyle* GetGeneratedContentStyle() const {
- return (IFDE_CSSGeneratedContentStyle * const) this;
- }
- virtual IFDE_CSSRubyStyle* GetRubyStyle() const {
- return (IFDE_CSSRubyStyle * const) this;
- }
- virtual FX_BOOL GetCustomStyle(const CFX_WideStringC& wsName,
- CFX_WideString& wsValue) const {
- for (int32_t i = m_CustomProperties.GetSize() - 2; i > -1; i -= 2) {
- if (wsName == m_CustomProperties[i]) {
- wsValue = m_CustomProperties[i + 1];
- return TRUE;
- }
- }
- return FALSE;
- }
- virtual FDE_CSSRUBYALIGN GetRubyAlign() const {
- return (FDE_CSSRUBYALIGN)m_InheritedData.m_eRubyAlign;
- }
- virtual FDE_CSSRUBYPOSITION GetRubyPosition() const {
- return (FDE_CSSRUBYPOSITION)m_InheritedData.m_eRubyPosition;
- }
- virtual FDE_CSSRUBYOVERHANG GetRubyOverhang() const {
- return (FDE_CSSRUBYOVERHANG)m_InheritedData.m_eRubyOverhang;
- }
- virtual FDE_CSSRUBYSPAN GetRubySpanType() const {
- return m_NonInheritedData.m_pRubySpan == NULL ? FDE_CSSRUBYSPAN_None
- : FDE_CSSRUBYSPAN_Attr;
- }
- virtual IFDE_CSSValue* GetRubySpanAttr() const {
- return m_NonInheritedData.m_pRubySpan;
- }
- virtual FDE_CSSCAPTIONSIDE GetCaptionSide() const {
- return (FDE_CSSCAPTIONSIDE)m_InheritedData.m_eCaptionSide;
- }
- virtual int32_t CountCounters() {
- return (m_NonInheritedData.m_pCounterStyle == NULL)
- ? 0
- : m_NonInheritedData.m_pCounterStyle->CountCounters();
- }
- virtual const FX_WCHAR* GetCounterIdentifier(int32_t index) {
- return m_NonInheritedData.m_pCounterStyle->GetCounterIdentifier(index);
- }
- virtual FX_BOOL GetCounterReset(int32_t index, int32_t& iValue) {
- return m_NonInheritedData.m_pCounterStyle->GetCounterReset(index, iValue);
- }
- virtual FX_BOOL GetCounterIncrement(int32_t index, int32_t& iValue) {
- return m_NonInheritedData.m_pCounterStyle->GetCounterIncrement(index,
- iValue);
- }
- virtual IFDE_CSSValueList* GetContent() const {
- return m_NonInheritedData.m_pContentList;
- }
- virtual int32_t CountQuotes() const {
- return m_InheritedData.m_pQuotes == NULL
- ? 0
- : m_InheritedData.m_pQuotes->CountValues();
- }
- virtual const FX_WCHAR* GetQuotes(int32_t index) const {
- FXSYS_assert(m_InheritedData.m_pQuotes != NULL &&
- m_InheritedData.m_pQuotes->CountValues() > index);
- return ((IFDE_CSSPrimitiveValue*)(m_InheritedData.m_pQuotes->GetValue(
- index)))
- ->GetString(index);
- }
- virtual const FDE_CSSLENGTH& GetColumnCount() const {
- return m_NonInheritedData.m_ColumnCount;
- }
- virtual const FDE_CSSLENGTH& GetColumnGap() const {
- return m_NonInheritedData.m_ColumnGap;
- }
- virtual FX_ARGB GetColumnRuleColor() const {
- return m_NonInheritedData.m_bColumnRuleColorSame
- ? m_InheritedData.m_dwFontColor
- : m_NonInheritedData.m_dwColumnRuleColor;
- }
- virtual FDE_CSSBORDERSTYLE GetColumnRuleStyle() const {
- return (FDE_CSSBORDERSTYLE)m_NonInheritedData.m_eColumnRuleStyle;
- }
- virtual const FDE_CSSLENGTH& GetColumnRuleWidth() const {
- return m_NonInheritedData.m_ColumnRuleWidth;
- }
- virtual const FDE_CSSLENGTH& GetColumnWidth() const {
- return m_NonInheritedData.m_ColumnWidth;
- }
- virtual void SetColumnCount(const FDE_CSSLENGTH& columnCount) {
- m_NonInheritedData.m_ColumnCount = columnCount;
- }
- virtual void SetColumnGap(const FDE_CSSLENGTH& columnGap) {
- m_NonInheritedData.m_ColumnGap = columnGap;
- }
- virtual void SetColumnRuleColor(FX_ARGB dwColumnRuleColor) {
- m_NonInheritedData.m_dwColumnRuleColor = dwColumnRuleColor,
- m_NonInheritedData.m_bColumnRuleColorSame = FALSE;
- }
- virtual void SetColumnRuleStyle(FDE_CSSBORDERSTYLE eColumnRuleStyle) {
- m_NonInheritedData.m_eColumnRuleStyle = eColumnRuleStyle;
- }
- virtual void SetColumnRuleWidth(const FDE_CSSLENGTH& columnRuleWidth) {
- m_NonInheritedData.m_ColumnRuleWidth = columnRuleWidth;
- }
- virtual void SetColumnWidth(const FDE_CSSLENGTH& columnWidth) {
- m_NonInheritedData.m_ColumnWidth = columnWidth;
- }
- virtual int32_t CountFontFamilies() const {
- return m_InheritedData.m_pFontFamily
- ? m_InheritedData.m_pFontFamily->CountValues()
- : 0;
- }
- virtual const FX_WCHAR* GetFontFamily(int32_t index) const {
- return ((IFDE_CSSPrimitiveValue*)(m_InheritedData.m_pFontFamily->GetValue(
- index)))
- ->GetString(index);
- }
- virtual FX_WORD GetFontWeight() const {
- return m_InheritedData.m_wFontWeight;
- }
- virtual FDE_CSSFONTVARIANT GetFontVariant() const {
- return (FDE_CSSFONTVARIANT)m_InheritedData.m_eFontVariant;
- }
- virtual FDE_CSSFONTSTYLE GetFontStyle() const {
- return (FDE_CSSFONTSTYLE)m_InheritedData.m_eFontStyle;
- }
- virtual FX_FLOAT GetFontSize() const { return m_InheritedData.m_fFontSize; }
- virtual FX_ARGB GetColor() const { return m_InheritedData.m_dwFontColor; }
- virtual void SetFontWeight(FX_WORD wFontWeight) {
- m_InheritedData.m_wFontWeight = wFontWeight;
- }
- virtual void SetFontVariant(FDE_CSSFONTVARIANT eFontVariant) {
- m_InheritedData.m_eFontVariant = eFontVariant;
- }
- virtual void SetFontStyle(FDE_CSSFONTSTYLE eFontStyle) {
- m_InheritedData.m_eFontStyle = eFontStyle;
- }
- virtual void SetFontSize(FX_FLOAT fFontSize) {
- m_InheritedData.m_fFontSize = fFontSize;
- }
- virtual void SetColor(FX_ARGB dwFontColor) {
- m_InheritedData.m_dwFontColor = dwFontColor;
- }
- virtual FX_ARGB GetBorderLeftColor() const {
- return m_NonInheritedData.m_dwBDRLeftColor;
- }
- virtual FX_ARGB GetBorderTopColor() const {
- return m_NonInheritedData.m_dwBDRTopColor;
- }
- virtual FX_ARGB GetBorderRightColor() const {
- return m_NonInheritedData.m_dwBDRRightColor;
- }
- virtual FX_ARGB GetBorderBottomColor() const {
- return m_NonInheritedData.m_dwBDRBottomColor;
- }
-
- virtual FDE_CSSBORDERSTYLE GetBorderLeftStyle() const {
- return (FDE_CSSBORDERSTYLE)m_NonInheritedData.m_eBDRLeftStyle;
- }
- virtual FDE_CSSBORDERSTYLE GetBorderTopStyle() const {
- return (FDE_CSSBORDERSTYLE)m_NonInheritedData.m_eBDRTopStyle;
- }
- virtual FDE_CSSBORDERSTYLE GetBorderRightStyle() const {
- return (FDE_CSSBORDERSTYLE)m_NonInheritedData.m_eBDRRightStyle;
- }
- virtual FDE_CSSBORDERSTYLE GetBorderBottomStyle() const {
- return (FDE_CSSBORDERSTYLE)m_NonInheritedData.m_eBDRBottomStyle;
- }
-
- virtual const FDE_CSSRECT* GetBorderWidth() const {
- return m_NonInheritedData.m_bHasBorder ? &(m_NonInheritedData.m_BorderWidth)
- : NULL;
- }
- virtual const FDE_CSSRECT* GetMarginWidth() const {
- return m_NonInheritedData.m_bHasMargin ? &(m_NonInheritedData.m_MarginWidth)
- : NULL;
- }
- virtual const FDE_CSSRECT* GetPaddingWidth() const {
- return m_NonInheritedData.m_bHasPadding
- ? &(m_NonInheritedData.m_PaddingWidth)
- : NULL;
- }
- virtual void SetBorderLeftColor(FX_ARGB dwBorderColor) {
- m_NonInheritedData.m_dwBDRLeftColor = dwBorderColor;
- }
- virtual void SetBorderTopColor(FX_ARGB dwBorderColor) {
- m_NonInheritedData.m_dwBDRTopColor = dwBorderColor;
- }
- virtual void SetBorderRightColor(FX_ARGB dwBorderColor) {
- m_NonInheritedData.m_dwBDRRightColor = dwBorderColor;
- }
- virtual void SetBorderBottomColor(FX_ARGB dwBorderColor) {
- m_NonInheritedData.m_dwBDRBottomColor = dwBorderColor;
- }
-
- virtual void SetBorderLeftStyle(FDE_CSSBORDERSTYLE eBorderStyle) {
- m_NonInheritedData.m_eBDRLeftStyle = eBorderStyle;
- }
- virtual void SetBorderTopStyle(FDE_CSSBORDERSTYLE eBorderStyle) {
- m_NonInheritedData.m_eBDRTopStyle = eBorderStyle;
- }
- virtual void SetBorderRightStyle(FDE_CSSBORDERSTYLE eBorderStyle) {
- m_NonInheritedData.m_eBDRRightStyle = eBorderStyle;
- }
- virtual void SetBorderBottomStyle(FDE_CSSBORDERSTYLE eBorderStyle) {
- m_NonInheritedData.m_eBDRBottomStyle = eBorderStyle;
- }
-
- virtual void SetBorderWidth(const FDE_CSSRECT& rect) {
- m_NonInheritedData.m_BorderWidth = rect;
- m_NonInheritedData.m_bHasBorder = TRUE;
- }
- virtual void SetMarginWidth(const FDE_CSSRECT& rect) {
- m_NonInheritedData.m_MarginWidth = rect;
- m_NonInheritedData.m_bHasMargin = TRUE;
- }
- virtual void SetPaddingWidth(const FDE_CSSRECT& rect) {
- m_NonInheritedData.m_PaddingWidth = rect;
- m_NonInheritedData.m_bHasPadding = TRUE;
- }
- virtual FDE_CSSDISPLAY GetDisplay() const {
- return (FDE_CSSDISPLAY)m_NonInheritedData.m_eDisplay;
- }
- virtual const FDE_CSSSIZE& GetBoxSize() const {
- return m_NonInheritedData.m_BoxSize;
- }
- virtual const FDE_CSSSIZE& GetMinBoxSize() const {
- return m_NonInheritedData.m_MinBoxSize;
- }
- virtual const FDE_CSSSIZE& GetMaxBoxSize() const {
- return m_NonInheritedData.m_MaxBoxSize;
- }
- virtual FDE_CSSFLOAT GetFloat() const {
- return (FDE_CSSFLOAT)m_NonInheritedData.m_eFloat;
- }
- virtual FDE_CSSCLEAR GetClear() const {
- return (FDE_CSSCLEAR)m_NonInheritedData.m_eClear;
- }
- virtual FDE_CSSPOSITION GetPosition() const {
- return (FDE_CSSPOSITION)m_NonInheritedData.m_ePosition;
- }
- virtual FDE_CSSLENGTH GetTop() const { return m_NonInheritedData.m_Top; }
- virtual FDE_CSSLENGTH GetBottom() const {
- return m_NonInheritedData.m_Bottom;
- }
- virtual FDE_CSSLENGTH GetLeft() const { return m_NonInheritedData.m_Left; }
- virtual FDE_CSSLENGTH GetRight() const { return m_NonInheritedData.m_Right; }
-
- virtual void SetDisplay(FDE_CSSDISPLAY eDisplay) {
- m_NonInheritedData.m_eDisplay = eDisplay;
- }
- virtual void SetBoxSize(const FDE_CSSSIZE& size) {
- m_NonInheritedData.m_BoxSize = size;
- }
- virtual void SetMinBoxSize(const FDE_CSSSIZE& size) {
- m_NonInheritedData.m_MinBoxSize = size;
- }
- virtual void SetMaxBoxSize(const FDE_CSSSIZE& size) {
- m_NonInheritedData.m_MaxBoxSize = size;
- }
- virtual void SetFloat(FDE_CSSFLOAT eFloat) {
- m_NonInheritedData.m_eFloat = eFloat;
- }
- virtual void SetClear(FDE_CSSCLEAR eClear) {
- m_NonInheritedData.m_eClear = eClear;
- }
- virtual FX_FLOAT GetLineHeight() const {
- return m_InheritedData.m_fLineHeight;
- }
- virtual FDE_CSSWHITESPACE GetWhiteSpace() const {
- return (FDE_CSSWHITESPACE)m_InheritedData.m_eWhiteSpace;
- }
- virtual const FDE_CSSLENGTH& GetTextIndent() const {
- return m_InheritedData.m_TextIndent;
- }
- virtual FDE_CSSTEXTALIGN GetTextAlign() const {
- return (FDE_CSSTEXTALIGN)m_InheritedData.m_eTextAligh;
- }
- virtual FDE_CSSVERTICALALIGN GetVerticalAlign() const {
- return (FDE_CSSVERTICALALIGN)m_NonInheritedData.m_eVerticalAlign;
- }
- virtual FX_FLOAT GetNumberVerticalAlign() const {
- return m_NonInheritedData.m_fVerticalAlign;
- }
- virtual FDE_CSSTEXTTRANSFORM GetTextTransform() const {
- return (FDE_CSSTEXTTRANSFORM)m_InheritedData.m_eTextTransform;
- }
- virtual FX_DWORD GetTextDecoration() const {
- return m_NonInheritedData.m_dwTextDecoration;
- }
- virtual const FDE_CSSLENGTH& GetLetterSpacing() const {
- return m_InheritedData.m_LetterSpacing;
- }
- virtual const FDE_CSSLENGTH& GetWordSpacing() const {
- return m_InheritedData.m_WordSpacing;
- }
- virtual FDE_CSSWRITINGMODE GetWritingMode() const {
- return (FDE_CSSWRITINGMODE)m_InheritedData.m_eWritingMode;
- }
- virtual FDE_CSSWORDBREAK GetWordBreak() const {
- return (FDE_CSSWORDBREAK)m_InheritedData.m_eWordBreak;
- }
- virtual int32_t GetWidows() const { return m_InheritedData.m_iWidows; }
- virtual FX_ARGB GetTextEmphasisColor() const {
- return m_InheritedData.m_bTextEmphasisColorCurrent
- ? m_InheritedData.m_dwFontColor
- : m_InheritedData.m_dwTextEmphasisColor;
- }
- virtual FDE_CSSPAGEBREAK GetPageBreakBefore() const {
- return (FDE_CSSPAGEBREAK)m_NonInheritedData.m_ePageBreakBefore;
- }
- virtual FDE_CSSPAGEBREAK GetPageBreakAfter() const {
- return (FDE_CSSPAGEBREAK)m_NonInheritedData.m_ePageBreakAfter;
- }
- virtual FDE_CSSPAGEBREAK GetPageBreakInside() const {
- return (FDE_CSSPAGEBREAK)m_NonInheritedData.m_ePageBreakInside;
- }
- virtual int32_t GetOrphans() const { return m_InheritedData.m_iOrphans; }
- virtual FDE_CSSLINEBREAK GetLineBreak() const {
- return (FDE_CSSLINEBREAK)m_InheritedData.m_eLineBreak;
- }
- virtual FDE_CSSTEXTEMPHASISMARK GetTextEmphasisMark() const;
- virtual FDE_CSSTEXTEMPHASISFILL GetTextEmphasisFill() const {
- return (FDE_CSSTEXTEMPHASISFILL)m_InheritedData.m_eTextEmphasisFill;
- }
- virtual const FX_WCHAR* GetTextEmphasisCustom() const {
- FXSYS_assert(m_InheritedData.m_eTextEmphasisMark ==
- FDE_CSSTEXTEMPHASISMARK_Custom);
- return m_InheritedData.m_pszTextEmphasisCustomMark;
- }
- virtual FDE_CSSTEXTCOMBINE GetTextCombineType() const {
- return (FDE_CSSTEXTCOMBINE)m_NonInheritedData.m_eTextCombine;
- }
- virtual FX_BOOL HasTextCombineNumber() const {
- return m_NonInheritedData.m_bHasTextCombineNumber;
- }
- virtual FX_FLOAT GetTextCombineNumber() const {
- FXSYS_assert(m_NonInheritedData.m_eTextCombine ==
- FDE_CSSTEXTCOMBINE_Horizontal);
- return m_NonInheritedData.m_fTextCombineNumber;
- }
- virtual void SetLineHeight(FX_FLOAT fLineHeight) {
- m_InheritedData.m_fLineHeight = fLineHeight;
- }
- virtual void SetWhiteSpace(FDE_CSSWHITESPACE eWhiteSpace) {
- m_InheritedData.m_eWhiteSpace = eWhiteSpace;
- }
- virtual void SetTextIndent(const FDE_CSSLENGTH& textIndent) {
- m_InheritedData.m_TextIndent = textIndent;
- }
- virtual void SetTextAlign(FDE_CSSTEXTALIGN eTextAlign) {
- m_InheritedData.m_eTextAligh = eTextAlign;
- }
- virtual void SetVerticalAlign(FDE_CSSVERTICALALIGN eVerticalAlign) {
- m_NonInheritedData.m_eVerticalAlign = eVerticalAlign;
- }
- virtual void SetNumberVerticalAlign(FX_FLOAT fAlign) {
- m_NonInheritedData.m_eVerticalAlign = FDE_CSSVERTICALALIGN_Number,
- m_NonInheritedData.m_fVerticalAlign = fAlign;
- }
- virtual void SetTextTransform(FDE_CSSTEXTTRANSFORM eTextTransform) {
- m_InheritedData.m_eTextTransform = eTextTransform;
- }
- virtual void SetTextDecoration(FX_DWORD dwTextDecoration) {
- m_NonInheritedData.m_dwTextDecoration = dwTextDecoration;
- }
- virtual void SetLetterSpacing(const FDE_CSSLENGTH& letterSpacing) {
- m_InheritedData.m_LetterSpacing = letterSpacing;
- }
- virtual void SetWordSpacing(const FDE_CSSLENGTH& wordSpacing) {
- m_InheritedData.m_WordSpacing = wordSpacing;
- }
- virtual void SetWritingMode(FDE_CSSWRITINGMODE eWritingMode) {
- m_InheritedData.m_eWritingMode = eWritingMode;
- }
- virtual void SetWordBreak(FDE_CSSWORDBREAK eWordBreak) {
- m_InheritedData.m_eWordBreak = eWordBreak;
- }
- virtual void SetWidows(int32_t iWidows) {
- m_InheritedData.m_iWidows = iWidows;
- }
- virtual void SetTextEmphasisColor(FX_ARGB dwTextEmphasisColor) {
- m_InheritedData.m_dwTextEmphasisColor = dwTextEmphasisColor,
- m_InheritedData.m_bTextEmphasisColorCurrent = FALSE;
- }
- virtual void SetPageBreakBefore(FDE_CSSPAGEBREAK ePageBreakBefore) {
- m_NonInheritedData.m_ePageBreakBefore = ePageBreakBefore;
- }
- virtual void SetPageBreakAfter(FDE_CSSPAGEBREAK ePageBreakAfter) {
- m_NonInheritedData.m_ePageBreakAfter = ePageBreakAfter;
- }
- virtual void SetPageBreakInside(FDE_CSSPAGEBREAK ePageBreakInside) {
- m_NonInheritedData.m_ePageBreakInside = ePageBreakInside;
- }
- virtual void SetOrphans(int32_t iOrphans) {
- m_InheritedData.m_iOrphans = iOrphans;
- }
- virtual void SetLineBreak(FDE_CSSLINEBREAK eLineBreak) {
- m_InheritedData.m_eLineBreak = eLineBreak;
- }
- virtual FX_ARGB GetBKGColor() const {
- return m_NonInheritedData.m_dwBKGColor;
- }
- virtual const FX_WCHAR* GetBKGImage() const {
- return m_NonInheritedData.m_pszBKGImage;
- }
- virtual const FDE_CSSPOINT& GetBKGPosition() const {
- return m_NonInheritedData.m_BKGPosition;
- }
- virtual FDE_CSSBKGREPEAT GetBKGRepeat() const {
- return (FDE_CSSBKGREPEAT)m_NonInheritedData.m_eBKGRepeat;
- }
- virtual FDE_CSSBKGATTACHMENT GetBKGAttachment() const {
- return (FDE_CSSBKGATTACHMENT)m_NonInheritedData.m_eBKGAttachment;
- }
- virtual void SetBKGColor(FX_ARGB dwBKGColor) {
- m_NonInheritedData.m_dwBKGColor = dwBKGColor;
- }
- virtual void SetBKGPosition(const FDE_CSSPOINT& bkgPosition) {
- m_NonInheritedData.m_BKGPosition = bkgPosition;
- }
- virtual FDE_CSSVISIBILITY GetVisibility() const {
- return (FDE_CSSVISIBILITY)m_InheritedData.m_eVisibility;
- }
- virtual FDE_CSSOVERFLOW GetOverflowX() const {
- return (FDE_CSSOVERFLOW)m_NonInheritedData.m_eOverflowX;
- }
- virtual FDE_CSSOVERFLOW GetOverflowY() const {
- return (FDE_CSSOVERFLOW)m_NonInheritedData.m_eOverflowY;
- }
- virtual int32_t CountCursorUrls() const {
- return m_InheritedData.m_pCursorUris == NULL
- ? 0
- : m_InheritedData.m_pCursorUris->CountValues();
- }
- virtual const FX_WCHAR* GetCursorUrl(int32_t index) const {
- FXSYS_assert(m_InheritedData.m_pCursorUris != NULL);
- return ((IFDE_CSSPrimitiveValue*)(m_InheritedData.m_pCursorUris->GetValue(
- index)))
- ->GetString(index);
- }
- virtual FDE_CSSCURSOR GetCursorType() const {
- return m_InheritedData.m_eCursor;
- }
- virtual void SetVisibility(FDE_CSSVISIBILITY eVisibility) {
- m_InheritedData.m_eVisibility = eVisibility;
- }
- virtual FDE_CSSLISTSTYLETYPE GetListStyleType() const {
- return (FDE_CSSLISTSTYLETYPE)m_NonInheritedData.m_eListStyleType;
- }
- virtual FDE_CSSLISTSTYLEPOSITION GetListStylePosition() const {
- return (FDE_CSSLISTSTYLEPOSITION)m_NonInheritedData.m_eListStylePosition;
- }
- virtual const FX_WCHAR* GetListStyleImage() const {
- return m_InheritedData.m_pszListStyleImage;
- }
- virtual void SetListStyleType(FDE_CSSLISTSTYLETYPE eListStyleType) {
- m_NonInheritedData.m_eListStyleType = eListStyleType;
- }
- virtual void SetListStylePosition(
- FDE_CSSLISTSTYLEPOSITION eListStylePosition) {
- m_NonInheritedData.m_eListStylePosition = eListStylePosition;
- }
- void AddCustomStyle(const CFX_WideString& wsName,
- const CFX_WideString& wsValue) {
- m_CustomProperties.Add(wsName);
- m_CustomProperties.Add(wsValue);
- }
- FX_DWORD m_dwRefCount;
- IFX_MEMAllocator* m_pAllocator;
- CFDE_CSSInheritedData m_InheritedData;
- CFDE_CSSNonInheritedData m_NonInheritedData;
- CFX_WideStringArray m_CustomProperties;
-};
-
-#endif // XFA_SRC_FDE_CSS_FDE_CSSSTYLESELECTOR_H_
diff --git a/xfa/src/fde/css/fde_cssstylesheet.cpp b/xfa/src/fde/css/fde_cssstylesheet.cpp
deleted file mode 100644
index 9b18dd2552..0000000000
--- a/xfa/src/fde/css/fde_cssstylesheet.cpp
+++ /dev/null
@@ -1,509 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#include "xfa/src/fde/css/fde_cssstylesheet.h"
-
-#include "xfa/src/fde/css/fde_cssdatatable.h"
-#include "xfa/src/fde/css/fde_csssyntax.h"
-#include "xfa/src/fgas/crt/fgas_codepage.h"
-
-IFDE_CSSStyleSheet* IFDE_CSSStyleSheet::LoadHTMLStandardStyleSheet() {
- static const FX_WCHAR* s_pStyle =
- L"html,address,blockquote,body,dd,div,dl,dt,fieldset,form,frame,frameset,"
- L"h1,h2,h3,h4,h5,h6,noframes,ol,p,ul,center,dir,hr,menu,pre{display:"
- L"block}"
- L"li{display:list-item}head{display:none}table{display:table}tr{display:"
- L"table-row}thead{display:table-header-group}tbody{display:table-row-"
- L"group}tfoot{display:table-footer-group}"
- L"col{display:table-column}colgroup{display:table-column-group}td,th{"
- L"display:table-cell}caption{display:table-caption}th{font-weight:bolder;"
- L"text-align:center}caption{text-align:center}"
- L"body{margin:0}h1{font-size:2em;margin:.67em "
- L"0}h2{font-size:1.5em;margin:.75em 0}h3{font-size:1.17em;margin:.83em "
- L"0}h4,p,blockquote,ul,fieldset,form,ol,dl,dir,menu{margin:1.12em 0}"
- L"h5{font-size:.83em;margin:1.5em 0}h6{font-size:.75em;margin:1.67em "
- L"0}h1,h2,h3,h4,h5,h6,b,strong{font-weight:bolder}blockquote{margin-left:"
- L"40px;margin-right:40px}i,cite,em,var,address{font-style:italic}"
- L"pre,tt,code,kbd,samp{font-family:monospace}pre{white-space:pre}button,"
- L"textarea,input,select{display:inline-block}big{font-size:1.17em}small,"
- L"sub,sup{font-size:.83em}sub{vertical-align:sub}"
- L"sup{vertical-align:super}table{border-spacing:2px}thead,tbody,tfoot{"
- L"vertical-align:middle}td,th,tr{vertical-align:inherit}s,strike,del{"
- L"text-decoration:line-through}hr{border:1px inset silver}"
- L"ol,ul,dir,menu,dd{margin-left:40px}ol{list-style-type:decimal}ol ul,ul "
- L"ol,ul ul,ol "
- L"ol{margin-top:0;margin-bottom:0}u,ins{text-decoration:underline}center{"
- L"text-align:center}"
- L"ruby{display:ruby}rt{display:ruby-text;font-size:.5em}rb{display:ruby-"
- L"base}rbc{display:ruby-base-group}rtc{display:ruby-text-group}"
- L"q:before{content:open-quote}q:after{content:close-quote}"
- L"rp{display:none}";
- return IFDE_CSSStyleSheet::LoadFromBuffer(
- CFX_WideString(), s_pStyle, FXSYS_wcslen(s_pStyle), FX_CODEPAGE_UTF8);
-}
-
-IFDE_CSSStyleSheet* IFDE_CSSStyleSheet::LoadFromStream(
- const CFX_WideString& szUrl,
- IFX_Stream* pStream,
- FX_WORD wCodePage,
- FX_DWORD dwMediaList) {
- CFDE_CSSStyleSheet* pStyleSheet = new CFDE_CSSStyleSheet(dwMediaList);
- if (!pStyleSheet->LoadFromStream(szUrl, pStream, wCodePage)) {
- pStyleSheet->Release();
- pStyleSheet = NULL;
- }
- return pStyleSheet;
-}
-IFDE_CSSStyleSheet* IFDE_CSSStyleSheet::LoadFromBuffer(
- const CFX_WideString& szUrl,
- const FX_WCHAR* pBuffer,
- int32_t iBufSize,
- FX_WORD wCodePage,
- FX_DWORD dwMediaList) {
- CFDE_CSSStyleSheet* pStyleSheet = new CFDE_CSSStyleSheet(dwMediaList);
- if (!pStyleSheet->LoadFromBuffer(szUrl, pBuffer, iBufSize, wCodePage)) {
- pStyleSheet->Release();
- pStyleSheet = NULL;
- }
- return pStyleSheet;
-}
-CFDE_CSSStyleSheet::CFDE_CSSStyleSheet(FX_DWORD dwMediaList)
- : m_wCodePage(FX_CODEPAGE_UTF8),
- m_wRefCount(1),
- m_dwMediaList(dwMediaList),
- m_pAllocator(NULL) {
- FXSYS_assert(m_dwMediaList > 0);
-}
-CFDE_CSSStyleSheet::~CFDE_CSSStyleSheet() {
- Reset();
-}
-void CFDE_CSSStyleSheet::Reset() {
- for (int32_t i = m_RuleArray.GetSize() - 1; i >= 0; --i) {
- IFDE_CSSRule* pRule = m_RuleArray.GetAt(i);
- switch (pRule->GetType()) {
- case FDE_CSSRULETYPE_Style:
- ((CFDE_CSSStyleRule*)pRule)->~CFDE_CSSStyleRule();
- break;
- case FDE_CSSRULETYPE_Media:
- ((CFDE_CSSMediaRule*)pRule)->~CFDE_CSSMediaRule();
- break;
- case FDE_CSSRULETYPE_FontFace:
- ((CFDE_CSSFontFaceRule*)pRule)->~CFDE_CSSFontFaceRule();
- break;
- default:
- FXSYS_assert(FALSE);
- break;
- }
- }
- m_RuleArray.RemoveAll();
- m_Selectors.RemoveAll();
- m_StringCache.RemoveAll();
- if (m_pAllocator) {
- m_pAllocator->Release();
- m_pAllocator = NULL;
- }
-}
-FX_DWORD CFDE_CSSStyleSheet::AddRef() {
- return ++m_wRefCount;
-}
-FX_DWORD CFDE_CSSStyleSheet::Release() {
- FX_DWORD dwRefCount = --m_wRefCount;
- if (dwRefCount == 0) {
- delete this;
- }
- return dwRefCount;
-}
-int32_t CFDE_CSSStyleSheet::CountRules() const {
- return m_RuleArray.GetSize();
-}
-IFDE_CSSRule* CFDE_CSSStyleSheet::GetRule(int32_t index) {
- return m_RuleArray.GetAt(index);
-}
-FX_BOOL CFDE_CSSStyleSheet::LoadFromStream(const CFX_WideString& szUrl,
- IFX_Stream* pStream,
- FX_WORD wCodePage) {
- FXSYS_assert(pStream != NULL);
- IFDE_CSSSyntaxParser* pSyntax = IFDE_CSSSyntaxParser::Create();
- if (pSyntax == NULL) {
- return FALSE;
- }
- if (pStream->GetCodePage() != wCodePage) {
- pStream->SetCodePage(wCodePage);
- }
- FX_BOOL bRet = pSyntax->Init(pStream, 4096) && LoadFromSyntax(pSyntax);
- pSyntax->Release();
- m_wCodePage = wCodePage;
- m_szUrl = szUrl;
- return bRet;
-}
-FX_BOOL CFDE_CSSStyleSheet::LoadFromBuffer(const CFX_WideString& szUrl,
- const FX_WCHAR* pBuffer,
- int32_t iBufSize,
- FX_WORD wCodePage) {
- FXSYS_assert(pBuffer != NULL && iBufSize > 0);
- IFDE_CSSSyntaxParser* pSyntax = IFDE_CSSSyntaxParser::Create();
- if (pSyntax == NULL) {
- return FALSE;
- }
- FX_BOOL bRet = pSyntax->Init(pBuffer, iBufSize) && LoadFromSyntax(pSyntax);
- pSyntax->Release();
- m_wCodePage = wCodePage;
- m_szUrl = szUrl;
- return bRet;
-}
-FX_BOOL CFDE_CSSStyleSheet::LoadFromSyntax(IFDE_CSSSyntaxParser* pSyntax) {
- Reset();
- m_pAllocator = FX_CreateAllocator(FX_ALLOCTYPE_Static, 1024, 0);
- if (m_pAllocator == NULL) {
- return FALSE;
- }
- FDE_CSSSYNTAXSTATUS eStatus;
- do {
- switch (eStatus = pSyntax->DoSyntaxParse()) {
- case FDE_CSSSYNTAXSTATUS_StyleRule:
- eStatus = LoadStyleRule(pSyntax, m_RuleArray);
- break;
- case FDE_CSSSYNTAXSTATUS_MediaRule:
- eStatus = LoadMediaRule(pSyntax);
- break;
- case FDE_CSSSYNTAXSTATUS_FontFaceRule:
- eStatus = LoadFontFaceRule(pSyntax, m_RuleArray);
- break;
- case FDE_CSSSYNTAXSTATUS_ImportRule:
- eStatus = LoadImportRule(pSyntax);
- break;
- case FDE_CSSSYNTAXSTATUS_PageRule:
- eStatus = LoadPageRule(pSyntax);
- break;
- default:
- break;
- }
- } while (eStatus >= FDE_CSSSYNTAXSTATUS_None);
- m_Selectors.RemoveAll();
- m_StringCache.RemoveAll();
- return eStatus != FDE_CSSSYNTAXSTATUS_Error;
-}
-FDE_CSSSYNTAXSTATUS CFDE_CSSStyleSheet::LoadMediaRule(
- IFDE_CSSSyntaxParser* pSyntax) {
- FX_DWORD dwMediaList = 0;
- CFDE_CSSMediaRule* pMediaRule = NULL;
- for (;;) {
- switch (pSyntax->DoSyntaxParse()) {
- case FDE_CSSSYNTAXSTATUS_MediaType: {
- int32_t iLen;
- const FX_WCHAR* psz = pSyntax->GetCurrentString(iLen);
- FDE_LPCCSSMEDIATYPETABLE pMediaType =
- FDE_GetCSSMediaTypeByName(psz, iLen);
- if (pMediaType != NULL) {
- dwMediaList |= pMediaType->wValue;
- }
- } break;
- case FDE_CSSSYNTAXSTATUS_StyleRule:
- if (pMediaRule == NULL) {
- SkipRuleSet(pSyntax);
- } else {
- FDE_CSSSYNTAXSTATUS eStatus =
- LoadStyleRule(pSyntax, pMediaRule->GetArray());
- if (eStatus < FDE_CSSSYNTAXSTATUS_None) {
- return eStatus;
- }
- }
- break;
- case FDE_CSSSYNTAXSTATUS_DeclOpen:
- if ((dwMediaList & m_dwMediaList) > 0 && pMediaRule == NULL) {
- pMediaRule =
- FXTARGET_NewWith(m_pAllocator) CFDE_CSSMediaRule(dwMediaList);
- m_RuleArray.Add(pMediaRule);
- }
- break;
- case FDE_CSSSYNTAXSTATUS_DeclClose:
- return FDE_CSSSYNTAXSTATUS_None;
- FDE_CSSSWITCHDEFAULTS();
- }
- }
-}
-FDE_CSSSYNTAXSTATUS CFDE_CSSStyleSheet::LoadStyleRule(
- IFDE_CSSSyntaxParser* pSyntax,
- CFDE_CSSRuleArray& ruleArray) {
- m_Selectors.RemoveAt(0, m_Selectors.GetSize());
- CFDE_CSSStyleRule* pStyleRule = NULL;
- const FX_WCHAR* pszValue = NULL;
- int32_t iValueLen = 0;
- FDE_CSSPROPERTYARGS propertyArgs;
- propertyArgs.pStaticStore = m_pAllocator;
- propertyArgs.pStringCache = &m_StringCache;
- propertyArgs.pProperty = NULL;
- CFX_WideString wsName;
- for (;;) {
- switch (pSyntax->DoSyntaxParse()) {
- case FDE_CSSSYNTAXSTATUS_Selector: {
- pszValue = pSyntax->GetCurrentString(iValueLen);
- IFDE_CSSSelector* pSelector =
- CFDE_CSSSelector::FromString(m_pAllocator, pszValue, iValueLen);
- if (pSelector != NULL) {
- m_Selectors.Add(pSelector);
- }
- } break;
- case FDE_CSSSYNTAXSTATUS_PropertyName:
- pszValue = pSyntax->GetCurrentString(iValueLen);
- propertyArgs.pProperty = FDE_GetCSSPropertyByName(pszValue, iValueLen);
- if (propertyArgs.pProperty == NULL) {
- wsName = CFX_WideStringC(pszValue, iValueLen);
- }
- break;
- case FDE_CSSSYNTAXSTATUS_PropertyValue:
- if (propertyArgs.pProperty != NULL) {
- pszValue = pSyntax->GetCurrentString(iValueLen);
- if (iValueLen > 0) {
- pStyleRule->GetDeclImp().AddProperty(&propertyArgs, pszValue,
- iValueLen);
- }
- } else if (iValueLen > 0) {
- pszValue = pSyntax->GetCurrentString(iValueLen);
- if (iValueLen > 0) {
- pStyleRule->GetDeclImp().AddProperty(
- &propertyArgs, wsName, wsName.GetLength(), pszValue, iValueLen);
- }
- }
- break;
- case FDE_CSSSYNTAXSTATUS_DeclOpen:
- if (pStyleRule == NULL && m_Selectors.GetSize() > 0) {
- pStyleRule = FXTARGET_NewWith(m_pAllocator) CFDE_CSSStyleRule;
- pStyleRule->SetSelector(m_pAllocator, m_Selectors);
- ruleArray.Add(pStyleRule);
- } else {
- SkipRuleSet(pSyntax);
- return FDE_CSSSYNTAXSTATUS_None;
- }
- break;
- case FDE_CSSSYNTAXSTATUS_DeclClose:
- if (pStyleRule != NULL &&
- pStyleRule->GetDeclImp().GetStartPosition() == NULL) {
- pStyleRule->~CFDE_CSSStyleRule();
- ruleArray.RemoveLast(1);
- }
- return FDE_CSSSYNTAXSTATUS_None;
- FDE_CSSSWITCHDEFAULTS();
- }
- }
-}
-FDE_CSSSYNTAXSTATUS CFDE_CSSStyleSheet::LoadFontFaceRule(
- IFDE_CSSSyntaxParser* pSyntax,
- CFDE_CSSRuleArray& ruleArray) {
- CFDE_CSSFontFaceRule* pFontFaceRule = NULL;
- const FX_WCHAR* pszValue = NULL;
- int32_t iValueLen = 0;
- FDE_CSSPROPERTYARGS propertyArgs;
- propertyArgs.pStaticStore = m_pAllocator;
- propertyArgs.pStringCache = &m_StringCache;
- propertyArgs.pProperty = NULL;
- for (;;) {
- switch (pSyntax->DoSyntaxParse()) {
- case FDE_CSSSYNTAXSTATUS_PropertyName:
- pszValue = pSyntax->GetCurrentString(iValueLen);
- propertyArgs.pProperty = FDE_GetCSSPropertyByName(pszValue, iValueLen);
- break;
- case FDE_CSSSYNTAXSTATUS_PropertyValue:
- if (propertyArgs.pProperty != NULL) {
- pszValue = pSyntax->GetCurrentString(iValueLen);
- if (iValueLen > 0) {
- pFontFaceRule->GetDeclImp().AddProperty(&propertyArgs, pszValue,
- iValueLen);
- }
- }
- break;
- case FDE_CSSSYNTAXSTATUS_DeclOpen:
- if (pFontFaceRule == NULL) {
- pFontFaceRule = FXTARGET_NewWith(m_pAllocator) CFDE_CSSFontFaceRule;
- ruleArray.Add(pFontFaceRule);
- }
- break;
- case FDE_CSSSYNTAXSTATUS_DeclClose:
- return FDE_CSSSYNTAXSTATUS_None;
- FDE_CSSSWITCHDEFAULTS();
- }
- }
- return FDE_CSSSYNTAXSTATUS_None;
-}
-FDE_CSSSYNTAXSTATUS CFDE_CSSStyleSheet::LoadImportRule(
- IFDE_CSSSyntaxParser* pSyntax) {
- for (;;) {
- switch (pSyntax->DoSyntaxParse()) {
- case FDE_CSSSYNTAXSTATUS_ImportClose:
- return FDE_CSSSYNTAXSTATUS_None;
- case FDE_CSSSYNTAXSTATUS_URI:
- break;
- FDE_CSSSWITCHDEFAULTS();
- }
- }
-}
-FDE_CSSSYNTAXSTATUS CFDE_CSSStyleSheet::LoadPageRule(
- IFDE_CSSSyntaxParser* pSyntax) {
- return SkipRuleSet(pSyntax);
-}
-FDE_CSSSYNTAXSTATUS CFDE_CSSStyleSheet::SkipRuleSet(
- IFDE_CSSSyntaxParser* pSyntax) {
- for (;;) {
- switch (pSyntax->DoSyntaxParse()) {
- case FDE_CSSSYNTAXSTATUS_Selector:
- case FDE_CSSSYNTAXSTATUS_DeclOpen:
- case FDE_CSSSYNTAXSTATUS_PropertyName:
- case FDE_CSSSYNTAXSTATUS_PropertyValue:
- break;
- case FDE_CSSSYNTAXSTATUS_DeclClose:
- return FDE_CSSSYNTAXSTATUS_None;
- FDE_CSSSWITCHDEFAULTS();
- }
- }
- return FDE_CSSSYNTAXSTATUS_None;
-}
-void CFDE_CSSStyleRule::SetSelector(IFX_MEMAllocator* pStaticStore,
- const CFDE_CSSSelectorArray& list) {
- FXSYS_assert(m_ppSelector == NULL);
- m_iSelectors = list.GetSize();
- m_ppSelector = (IFDE_CSSSelector**)pStaticStore->Alloc(
- m_iSelectors * sizeof(IFDE_CSSSelector*));
- for (int32_t i = 0; i < m_iSelectors; ++i) {
- m_ppSelector[i] = list.GetAt(i);
- }
-}
-CFDE_CSSMediaRule::~CFDE_CSSMediaRule() {
- for (int32_t i = m_RuleArray.GetSize() - 1; i >= 0; --i) {
- IFDE_CSSRule* pRule = m_RuleArray.GetAt(i);
- switch (pRule->GetType()) {
- case FDE_CSSRULETYPE_Style:
- ((CFDE_CSSStyleRule*)pRule)->~CFDE_CSSStyleRule();
- break;
- default:
- FXSYS_assert(FALSE);
- break;
- }
- }
-}
-inline FX_BOOL FDE_IsCSSChar(FX_WCHAR wch) {
- return (wch >= 'a' && wch <= 'z') || (wch >= 'A' && wch <= 'Z');
-}
-int32_t FDE_GetCSSPersudoLen(const FX_WCHAR* psz, const FX_WCHAR* pEnd) {
- FXSYS_assert(*psz == ':');
- const FX_WCHAR* pStart = psz;
- while (psz < pEnd) {
- FX_WCHAR wch = *psz;
- if (FDE_IsCSSChar(wch) || wch == ':') {
- ++psz;
- } else {
- break;
- }
- }
- return psz - pStart;
-}
-int32_t FDE_GetCSSNameLen(const FX_WCHAR* psz, const FX_WCHAR* pEnd) {
- const FX_WCHAR* pStart = psz;
- while (psz < pEnd) {
- FX_WCHAR wch = *psz;
- if (FDE_IsCSSChar(wch) || (wch >= '0' && wch <= '9') || wch == '_' ||
- wch == '-') {
- ++psz;
- } else {
- break;
- }
- }
- return psz - pStart;
-}
-IFDE_CSSSelector* CFDE_CSSSelector::FromString(IFX_MEMAllocator* pStaticStore,
- const FX_WCHAR* psz,
- int32_t iLen) {
- FXSYS_assert(pStaticStore != NULL && psz != NULL && iLen > 0);
- const FX_WCHAR* pStart = psz;
- const FX_WCHAR* pEnd = psz + iLen;
- for (; psz < pEnd; ++psz) {
- switch (*psz) {
- case '>':
- case '[':
- case '+':
- return NULL;
- }
- }
- CFDE_CSSSelector *pFirst = NULL, *pLast = NULL;
- CFDE_CSSSelector *pPersudoFirst = NULL, *pPersudoLast = NULL;
- for (psz = pStart; psz < pEnd;) {
- FX_WCHAR wch = *psz;
- if (wch == '.' || wch == '#') {
- if (psz == pStart || psz[-1] == ' ') {
- CFDE_CSSSelector* p = FXTARGET_NewWith(pStaticStore)
- CFDE_CSSSelector(FDE_CSSSELECTORTYPE_Element, L"*", 1, TRUE);
- if (p == NULL) {
- return NULL;
- }
- if (pFirst != NULL) {
- pFirst->SetType(FDE_CSSSELECTORTYPE_Descendant);
- p->SetNext(pFirst);
- }
- pFirst = pLast = p;
- }
- FXSYS_assert(pLast != NULL);
- int32_t iNameLen = FDE_GetCSSNameLen(++psz, pEnd);
- if (iNameLen == 0) {
- return NULL;
- }
- FDE_CSSSELECTORTYPE eType =
- wch == '.' ? FDE_CSSSELECTORTYPE_Class : FDE_CSSSELECTORTYPE_ID;
- CFDE_CSSSelector* p = FXTARGET_NewWith(pStaticStore)
- CFDE_CSSSelector(eType, psz, iNameLen, FALSE);
- if (p == NULL) {
- return NULL;
- }
- p->SetNext(pLast->GetNextSelector());
- pLast->SetNext(p);
- pLast = p;
- psz += iNameLen;
- } else if (FDE_IsCSSChar(wch) || wch == '*') {
- int32_t iNameLen = wch == '*' ? 1 : FDE_GetCSSNameLen(psz, pEnd);
- if (iNameLen == 0) {
- return NULL;
- }
- CFDE_CSSSelector* p = FXTARGET_NewWith(pStaticStore)
- CFDE_CSSSelector(FDE_CSSSELECTORTYPE_Element, psz, iNameLen, TRUE);
- if (p == NULL) {
- return NULL;
- }
- if (pFirst == NULL) {
- pFirst = pLast = p;
- } else {
- pFirst->SetType(FDE_CSSSELECTORTYPE_Descendant);
- p->SetNext(pFirst);
- pFirst = pLast = p;
- }
- psz += iNameLen;
- } else if (wch == ':') {
- int32_t iNameLen = FDE_GetCSSPersudoLen(psz, pEnd);
- if (iNameLen == 0) {
- return NULL;
- }
- CFDE_CSSSelector* p = FXTARGET_NewWith(pStaticStore)
- CFDE_CSSSelector(FDE_CSSSELECTORTYPE_Persudo, psz, iNameLen, TRUE);
- if (p == NULL) {
- return NULL;
- }
- if (pPersudoFirst == NULL) {
- pPersudoFirst = pPersudoLast = p;
- } else {
- pPersudoLast->SetNext(p);
- pPersudoLast = p;
- }
- psz += iNameLen;
- } else if (wch == ' ') {
- psz++;
- } else {
- return NULL;
- }
- }
- if (pPersudoFirst == NULL) {
- return pFirst;
- } else {
- pPersudoLast->SetNext(pFirst);
- return pPersudoFirst;
- }
-}
diff --git a/xfa/src/fde/css/fde_cssstylesheet.h b/xfa/src/fde/css/fde_cssstylesheet.h
deleted file mode 100644
index 5e11c74b4e..0000000000
--- a/xfa/src/fde/css/fde_cssstylesheet.h
+++ /dev/null
@@ -1,141 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifndef XFA_SRC_FDE_CSS_FDE_CSSSTYLESHEET_H_
-#define XFA_SRC_FDE_CSS_FDE_CSSSTYLESHEET_H_
-
-#include "core/include/fxcrt/fx_ext.h"
-#include "xfa/src/fde/css/fde_cssdeclaration.h"
-
-class CFDE_CSSSelector : public IFDE_CSSSelector, public CFX_Target {
- public:
- CFDE_CSSSelector(FDE_CSSSELECTORTYPE eType,
- const FX_WCHAR* psz,
- int32_t iLen,
- FX_BOOL bIgnoreCase)
- : m_eType(eType),
- m_dwHash(FX_HashCode_String_GetW(psz, iLen, bIgnoreCase)),
- m_pNext(NULL) {}
- virtual FDE_CSSSELECTORTYPE GetType() const { return m_eType; }
-
- virtual FX_DWORD GetNameHash() const { return m_dwHash; }
-
- virtual IFDE_CSSSelector* GetNextSelector() const { return m_pNext; }
- static IFDE_CSSSelector* FromString(IFX_MEMAllocator* pStaticStore,
- const FX_WCHAR* psz,
- int32_t iLen);
- void SetNext(IFDE_CSSSelector* pNext) { m_pNext = pNext; }
-
- protected:
- static CFDE_CSSSelector* ParseSelector(IFX_MEMAllocator* pStaticStore,
- const FX_WCHAR* psz,
- int32_t& iOff,
- int32_t iLen,
- FDE_CSSSELECTORTYPE eType);
- void SetType(FDE_CSSSELECTORTYPE eType) { m_eType = eType; }
- FDE_CSSSELECTORTYPE m_eType;
- FX_DWORD m_dwHash;
- IFDE_CSSSelector* m_pNext;
-};
-typedef CFX_ArrayTemplate<IFDE_CSSSelector*> CFDE_CSSSelectorArray;
-class CFDE_CSSStyleRule : public IFDE_CSSStyleRule, public CFX_Target {
- public:
- CFDE_CSSStyleRule() : m_ppSelector(NULL), m_iSelectors(0) {}
- virtual int32_t CountSelectorLists() const { return m_iSelectors; }
- virtual IFDE_CSSSelector* GetSelectorList(int32_t index) const {
- return m_ppSelector[index];
- }
-
- virtual IFDE_CSSDeclaration* GetDeclaration() const {
- return (IFDE_CSSDeclaration*)&m_Declaration;
- }
- CFDE_CSSDeclaration& GetDeclImp() { return m_Declaration; }
- void SetSelector(IFX_MEMAllocator* pStaticStore,
- const CFDE_CSSSelectorArray& list);
-
- protected:
- CFDE_CSSDeclaration m_Declaration;
- IFDE_CSSSelector** m_ppSelector;
- int32_t m_iSelectors;
-};
-class CFDE_CSSMediaRule : public IFDE_CSSMediaRule, public CFX_Target {
- public:
- CFDE_CSSMediaRule(FX_DWORD dwMediaList) : m_dwMediaList(dwMediaList) {}
- ~CFDE_CSSMediaRule();
-
- virtual FX_DWORD GetMediaList() const { return m_dwMediaList; }
-
- virtual int32_t CountRules() const { return m_RuleArray.GetSize(); }
- virtual IFDE_CSSRule* GetRule(int32_t index) {
- return m_RuleArray.GetAt(index);
- }
- CFDE_CSSRuleArray& GetArray() { return m_RuleArray; }
-
- protected:
- FX_DWORD m_dwMediaList;
- CFDE_CSSRuleArray m_RuleArray;
-};
-class CFDE_CSSFontFaceRule : public IFDE_CSSFontFaceRule, public CFX_Target {
- public:
- virtual IFDE_CSSDeclaration* GetDeclaration() const {
- return (IFDE_CSSDeclaration*)&m_Declaration;
- }
- CFDE_CSSDeclaration& GetDeclImp() { return m_Declaration; }
-
- protected:
- CFDE_CSSDeclaration m_Declaration;
-};
-#define FDE_CSSSWITCHDEFAULTS() \
- case FDE_CSSSYNTAXSTATUS_EOS: \
- return FDE_CSSSYNTAXSTATUS_EOS; \
- case FDE_CSSSYNTAXSTATUS_Error: \
- default: \
- return FDE_CSSSYNTAXSTATUS_Error;
-class CFDE_CSSStyleSheet : public IFDE_CSSStyleSheet, public CFX_Target {
- public:
- CFDE_CSSStyleSheet(FX_DWORD dwMediaList);
- ~CFDE_CSSStyleSheet();
- virtual FX_DWORD AddRef();
- virtual FX_DWORD Release();
-
- virtual FX_BOOL GetUrl(CFX_WideString& szUrl) {
- szUrl = m_szUrl;
- return szUrl.GetLength() > 0;
- }
- virtual FX_DWORD GetMediaList() const { return m_dwMediaList; }
- virtual FX_WORD GetCodePage() const { return m_wCodePage; }
- virtual int32_t CountRules() const;
- virtual IFDE_CSSRule* GetRule(int32_t index);
- FX_BOOL LoadFromStream(const CFX_WideString& szUrl,
- IFX_Stream* pStream,
- FX_WORD wCodePage);
- FX_BOOL LoadFromBuffer(const CFX_WideString& szUrl,
- const FX_WCHAR* pBuffer,
- int32_t iBufSize,
- FX_WORD wCodePage);
-
- protected:
- void Reset();
- FX_BOOL LoadFromSyntax(IFDE_CSSSyntaxParser* pSyntax);
- FDE_CSSSYNTAXSTATUS LoadStyleRule(IFDE_CSSSyntaxParser* pSyntax,
- CFDE_CSSRuleArray& ruleArray);
- FDE_CSSSYNTAXSTATUS LoadImportRule(IFDE_CSSSyntaxParser* pSyntax);
- FDE_CSSSYNTAXSTATUS LoadPageRule(IFDE_CSSSyntaxParser* pSyntax);
- FDE_CSSSYNTAXSTATUS LoadMediaRule(IFDE_CSSSyntaxParser* pSyntax);
- FDE_CSSSYNTAXSTATUS LoadFontFaceRule(IFDE_CSSSyntaxParser* pSyntax,
- CFDE_CSSRuleArray& ruleArray);
- FDE_CSSSYNTAXSTATUS SkipRuleSet(IFDE_CSSSyntaxParser* pSyntax);
- FX_WORD m_wCodePage;
- FX_WORD m_wRefCount;
- FX_DWORD m_dwMediaList;
- IFX_MEMAllocator* m_pAllocator;
- CFDE_CSSRuleArray m_RuleArray;
- CFX_WideString m_szUrl;
- CFDE_CSSSelectorArray m_Selectors;
- CFX_MapPtrToPtr m_StringCache;
-};
-
-#endif // XFA_SRC_FDE_CSS_FDE_CSSSTYLESHEET_H_
diff --git a/xfa/src/fde/css/fde_csssyntax.cpp b/xfa/src/fde/css/fde_csssyntax.cpp
deleted file mode 100644
index 5fe502e8b9..0000000000
--- a/xfa/src/fde/css/fde_csssyntax.cpp
+++ /dev/null
@@ -1,487 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#include "xfa/src/fde/css/fde_csssyntax.h"
-
-#include "xfa/src/fde/css/fde_cssdatatable.h"
-#include "xfa/src/fgas/crt/fgas_codepage.h"
-
-#ifdef _cplusplus
-extern "C" {
-#endif
-
-inline FX_BOOL FDE_IsSelectorStart(FX_WCHAR wch) {
- return wch == '.' || wch == '#' || wch == '*' || (wch >= 'a' && wch <= 'z') ||
- (wch >= 'A' && wch <= 'Z');
-}
-
-#ifdef _cplusplus
-};
-#endif
-
-IFDE_CSSSyntaxParser* IFDE_CSSSyntaxParser::Create() {
- return new CFDE_CSSSyntaxParser;
-}
-CFDE_CSSSyntaxParser::CFDE_CSSSyntaxParser()
- : m_pStream(NULL),
- m_iStreamPos(0),
- m_iPlaneSize(0),
- m_iTextDatLen(0),
- m_dwCheck((FX_DWORD)-1),
- m_eMode(FDE_CSSSYNTAXMODE_RuleSet),
- m_eStatus(FDE_CSSSYNTAXSTATUS_None) {}
-CFDE_CSSSyntaxParser::~CFDE_CSSSyntaxParser() {
- m_TextData.Reset();
- m_TextPlane.Reset();
-}
-FX_BOOL CFDE_CSSSyntaxParser::Init(IFX_Stream* pStream,
- int32_t iCSSPlaneSize,
- int32_t iTextDataSize,
- FX_BOOL bOnlyDeclaration) {
- FXSYS_assert(pStream != NULL && iCSSPlaneSize > 0 && iTextDataSize > 0);
- Reset(bOnlyDeclaration);
- if (!m_TextData.EstimateSize(iTextDataSize)) {
- return FALSE;
- }
- uint8_t bom[4];
- m_pStream = pStream;
- m_iStreamPos = m_pStream->GetBOM(bom);
- m_iPlaneSize = iCSSPlaneSize;
- return TRUE;
-}
-FX_BOOL CFDE_CSSSyntaxParser::Init(const FX_WCHAR* pBuffer,
- int32_t iBufferSize,
- int32_t iTextDatSize,
- FX_BOOL bOnlyDeclaration) {
- FXSYS_assert(pBuffer != NULL && iBufferSize > 0 && iTextDatSize > 0);
- Reset(bOnlyDeclaration);
- if (!m_TextData.EstimateSize(iTextDatSize)) {
- return FALSE;
- }
- return m_TextPlane.AttachBuffer(pBuffer, iBufferSize);
-}
-void CFDE_CSSSyntaxParser::Reset(FX_BOOL bOnlyDeclaration) {
- m_TextPlane.Reset();
- m_TextData.Reset();
- m_pStream = NULL;
- m_iStreamPos = 0;
- m_iTextDatLen = 0;
- m_dwCheck = (FX_DWORD)-1;
- m_eStatus = FDE_CSSSYNTAXSTATUS_None;
- m_eMode = bOnlyDeclaration ? FDE_CSSSYNTAXMODE_PropertyName
- : FDE_CSSSYNTAXMODE_RuleSet;
-}
-FDE_CSSSYNTAXSTATUS CFDE_CSSSyntaxParser::DoSyntaxParse() {
- while (m_eStatus >= FDE_CSSSYNTAXSTATUS_None) {
- if (m_TextPlane.IsEOF()) {
- if (m_pStream == NULL) {
- if (m_eMode == FDE_CSSSYNTAXMODE_PropertyValue &&
- m_TextData.GetLength() > 0) {
- SaveTextData();
- return m_eStatus = FDE_CSSSYNTAXSTATUS_PropertyValue;
- }
- return m_eStatus = FDE_CSSSYNTAXSTATUS_EOS;
- }
- FX_BOOL bEOS;
- int32_t iLen = m_TextPlane.LoadFromStream(m_pStream, m_iStreamPos,
- m_iPlaneSize, bEOS);
- m_iStreamPos = m_pStream->GetPosition();
- if (iLen < 1) {
- if (m_eMode == FDE_CSSSYNTAXMODE_PropertyValue &&
- m_TextData.GetLength() > 0) {
- SaveTextData();
- return m_eStatus = FDE_CSSSYNTAXSTATUS_PropertyValue;
- }
- return m_eStatus = FDE_CSSSYNTAXSTATUS_EOS;
- }
- }
- FX_WCHAR wch;
- while (!m_TextPlane.IsEOF()) {
- wch = m_TextPlane.GetChar();
- switch (m_eMode) {
- case FDE_CSSSYNTAXMODE_RuleSet:
- switch (wch) {
- case '@':
- m_TextPlane.MoveNext();
- SwitchMode(FDE_CSSSYNTAXMODE_AtRule);
- break;
- case '}':
- m_TextPlane.MoveNext();
- if (RestoreMode()) {
- return FDE_CSSSYNTAXSTATUS_DeclClose;
- } else {
- return m_eStatus = FDE_CSSSYNTAXSTATUS_Error;
- }
- break;
- case '/':
- if (m_TextPlane.GetNextChar() == '*') {
- m_ModeStack.Push(m_eMode);
- SwitchMode(FDE_CSSSYNTAXMODE_Comment);
- break;
- }
- default:
- if (wch <= ' ') {
- m_TextPlane.MoveNext();
- } else if (FDE_IsSelectorStart(wch)) {
- SwitchMode(FDE_CSSSYNTAXMODE_Selector);
- return FDE_CSSSYNTAXSTATUS_StyleRule;
- } else {
- return m_eStatus = FDE_CSSSYNTAXSTATUS_Error;
- }
- break;
- }
- break;
- case FDE_CSSSYNTAXMODE_Selector:
- switch (wch) {
- case ',':
- m_TextPlane.MoveNext();
- SwitchMode(FDE_CSSSYNTAXMODE_Selector);
- if (m_iTextDatLen > 0) {
- return FDE_CSSSYNTAXSTATUS_Selector;
- }
- break;
- case '{':
- if (m_TextData.GetLength() > 0) {
- SaveTextData();
- return FDE_CSSSYNTAXSTATUS_Selector;
- } else {
- m_TextPlane.MoveNext();
- m_ModeStack.Push(FDE_CSSSYNTAXMODE_RuleSet);
- SwitchMode(FDE_CSSSYNTAXMODE_PropertyName);
- return FDE_CSSSYNTAXSTATUS_DeclOpen;
- }
- break;
- case '/':
- if (m_TextPlane.GetNextChar() == '*') {
- if (SwitchToComment() > 0) {
- return FDE_CSSSYNTAXSTATUS_Selector;
- }
- break;
- }
- default:
- AppendChar(wch);
- break;
- }
- break;
- case FDE_CSSSYNTAXMODE_PropertyName:
- switch (wch) {
- case ':':
- m_TextPlane.MoveNext();
- SwitchMode(FDE_CSSSYNTAXMODE_PropertyValue);
- return FDE_CSSSYNTAXSTATUS_PropertyName;
- case '}':
- m_TextPlane.MoveNext();
- if (RestoreMode()) {
- return FDE_CSSSYNTAXSTATUS_DeclClose;
- } else {
- return m_eStatus = FDE_CSSSYNTAXSTATUS_Error;
- }
- break;
- case '/':
- if (m_TextPlane.GetNextChar() == '*') {
- if (SwitchToComment() > 0) {
- return FDE_CSSSYNTAXSTATUS_PropertyName;
- }
- break;
- }
- default:
- AppendChar(wch);
- break;
- }
- break;
- case FDE_CSSSYNTAXMODE_PropertyValue:
- switch (wch) {
- case ';':
- m_TextPlane.MoveNext();
- case '}':
- SwitchMode(FDE_CSSSYNTAXMODE_PropertyName);
- return FDE_CSSSYNTAXSTATUS_PropertyValue;
- case '/':
- if (m_TextPlane.GetNextChar() == '*') {
- if (SwitchToComment() > 0) {
- return FDE_CSSSYNTAXSTATUS_PropertyValue;
- }
- break;
- }
- default:
- AppendChar(wch);
- break;
- }
- break;
- case FDE_CSSSYNTAXMODE_Comment:
- if (wch == '/' && m_TextData.GetLength() > 0 &&
- m_TextData.GetAt(m_TextData.GetLength() - 1) == '*') {
- RestoreMode();
- } else {
- m_TextData.AppendChar(wch);
- }
- m_TextPlane.MoveNext();
- break;
- case FDE_CSSSYNTAXMODE_MediaType:
- switch (wch) {
- case ',':
- m_TextPlane.MoveNext();
- SwitchMode(FDE_CSSSYNTAXMODE_MediaType);
- if (m_iTextDatLen > 0) {
- return FDE_CSSSYNTAXSTATUS_MediaType;
- }
- break;
- case '{': {
- FDE_CSSSYNTAXMODE* pMode = m_ModeStack.GetTopElement();
- if (pMode == NULL || *pMode != FDE_CSSSYNTAXMODE_MediaRule) {
- return m_eStatus = FDE_CSSSYNTAXSTATUS_Error;
- }
- if (m_TextData.GetLength() > 0) {
- SaveTextData();
- return FDE_CSSSYNTAXSTATUS_MediaType;
- } else {
- m_TextPlane.MoveNext();
- *pMode = FDE_CSSSYNTAXMODE_RuleSet;
- SwitchMode(FDE_CSSSYNTAXMODE_RuleSet);
- return FDE_CSSSYNTAXSTATUS_DeclOpen;
- }
- } break;
- case ';': {
- FDE_CSSSYNTAXMODE* pMode = m_ModeStack.GetTopElement();
- if (pMode == NULL || *pMode != FDE_CSSSYNTAXMODE_Import) {
- return m_eStatus = FDE_CSSSYNTAXSTATUS_Error;
- }
- if (m_TextData.GetLength() > 0) {
- SaveTextData();
- if (IsImportEnabled()) {
- return FDE_CSSSYNTAXSTATUS_MediaType;
- }
- } else {
- FX_BOOL bEnabled = IsImportEnabled();
- m_TextPlane.MoveNext();
- m_ModeStack.Pop();
- SwitchMode(FDE_CSSSYNTAXMODE_RuleSet);
- if (bEnabled) {
- DisableImport();
- return FDE_CSSSYNTAXSTATUS_ImportClose;
- }
- }
- } break;
- case '/':
- if (m_TextPlane.GetNextChar() == '*') {
- if (SwitchToComment() > 0) {
- return FDE_CSSSYNTAXSTATUS_MediaType;
- }
- break;
- }
- default:
- AppendChar(wch);
- break;
- }
- break;
- case FDE_CSSSYNTAXMODE_URI: {
- FDE_CSSSYNTAXMODE* pMode = m_ModeStack.GetTopElement();
- if (pMode == NULL || *pMode != FDE_CSSSYNTAXMODE_Import) {
- return m_eStatus = FDE_CSSSYNTAXSTATUS_Error;
- }
- if (wch <= ' ' || wch == ';') {
- int32_t iURIStart, iURILength = m_TextData.GetLength();
- if (iURILength > 0 &&
- FDE_ParseCSSURI(m_TextData.GetBuffer(), iURILength, iURIStart,
- iURILength)) {
- m_TextData.Subtract(iURIStart, iURILength);
- SwitchMode(FDE_CSSSYNTAXMODE_MediaType);
- if (IsImportEnabled()) {
- return FDE_CSSSYNTAXSTATUS_URI;
- } else {
- break;
- }
- }
- }
- AppendChar(wch);
- } break;
- case FDE_CSSSYNTAXMODE_AtRule:
- if (wch > ' ') {
- AppendChar(wch);
- } else {
- int32_t iLen = m_TextData.GetLength();
- const FX_WCHAR* psz = m_TextData.GetBuffer();
- if (FXSYS_wcsncmp(L"charset", psz, iLen) == 0) {
- SwitchMode(FDE_CSSSYNTAXMODE_Charset);
- } else if (FXSYS_wcsncmp(L"import", psz, iLen) == 0) {
- m_ModeStack.Push(FDE_CSSSYNTAXMODE_Import);
- SwitchMode(FDE_CSSSYNTAXMODE_URI);
- if (IsImportEnabled()) {
- return FDE_CSSSYNTAXSTATUS_ImportRule;
- } else {
- break;
- }
- } else if (FXSYS_wcsncmp(L"media", psz, iLen) == 0) {
- m_ModeStack.Push(FDE_CSSSYNTAXMODE_MediaRule);
- SwitchMode(FDE_CSSSYNTAXMODE_MediaType);
- return FDE_CSSSYNTAXSTATUS_MediaRule;
- } else if (FXSYS_wcsncmp(L"font-face", psz, iLen) == 0) {
- SwitchMode(FDE_CSSSYNTAXMODE_Selector);
- return FDE_CSSSYNTAXSTATUS_FontFaceRule;
- } else if (FXSYS_wcsncmp(L"page", psz, iLen) == 0) {
- SwitchMode(FDE_CSSSYNTAXMODE_Selector);
- return FDE_CSSSYNTAXSTATUS_PageRule;
- } else {
- SwitchMode(FDE_CSSSYNTAXMODE_UnknownRule);
- }
- }
- break;
- case FDE_CSSSYNTAXMODE_Charset:
- if (wch == ';') {
- m_TextPlane.MoveNext();
- SwitchMode(FDE_CSSSYNTAXMODE_RuleSet);
- if (IsCharsetEnabled()) {
- DisableCharset();
- if (m_iTextDatLen > 0) {
- if (m_pStream != NULL) {
- FX_WORD wCodePage = FX_GetCodePageFormStringW(
- m_TextData.GetBuffer(), m_iTextDatLen);
- if (wCodePage < 0xFFFF &&
- m_pStream->GetCodePage() != wCodePage) {
- m_pStream->SetCodePage(wCodePage);
- }
- }
- return FDE_CSSSYNTAXSTATUS_Charset;
- }
- }
- } else {
- AppendChar(wch);
- }
- break;
- case FDE_CSSSYNTAXMODE_UnknownRule:
- if (wch == ';') {
- SwitchMode(FDE_CSSSYNTAXMODE_RuleSet);
- }
- m_TextPlane.MoveNext();
- break;
- default:
- FXSYS_assert(FALSE);
- break;
- }
- }
- }
- return m_eStatus;
-}
-FX_BOOL CFDE_CSSSyntaxParser::IsImportEnabled() const {
- if ((m_dwCheck & FDE_CSSSYNTAXCHECK_AllowImport) == 0) {
- return FALSE;
- }
- if (m_ModeStack.GetSize() > 1) {
- return FALSE;
- }
- return TRUE;
-}
-inline FX_BOOL CFDE_CSSSyntaxParser::AppendChar(FX_WCHAR wch) {
- m_TextPlane.MoveNext();
- if (m_TextData.GetLength() > 0 || wch > ' ') {
- m_TextData.AppendChar(wch);
- return TRUE;
- }
- return FALSE;
-}
-inline int32_t CFDE_CSSSyntaxParser::SaveTextData() {
- m_iTextDatLen = m_TextData.TrimEnd();
- m_TextData.Clear();
- return m_iTextDatLen;
-}
-inline void CFDE_CSSSyntaxParser::SwitchMode(FDE_CSSSYNTAXMODE eMode) {
- m_eMode = eMode;
- SaveTextData();
-}
-inline int32_t CFDE_CSSSyntaxParser::SwitchToComment() {
- int32_t iLength = m_TextData.GetLength();
- m_ModeStack.Push(m_eMode);
- SwitchMode(FDE_CSSSYNTAXMODE_Comment);
- return iLength;
-}
-inline FX_BOOL CFDE_CSSSyntaxParser::RestoreMode() {
- FDE_CSSSYNTAXMODE* pMode = m_ModeStack.GetTopElement();
- if (pMode == NULL) {
- return FALSE;
- }
- SwitchMode(*pMode);
- m_ModeStack.Pop();
- return TRUE;
-}
-const FX_WCHAR* CFDE_CSSSyntaxParser::GetCurrentString(int32_t& iLength) const {
- iLength = m_iTextDatLen;
- return m_TextData.GetBuffer();
-}
-CFDE_CSSTextBuf::CFDE_CSSTextBuf()
- : m_bExtBuf(FALSE),
- m_pBuffer(NULL),
- m_iBufLen(0),
- m_iDatLen(0),
- m_iDatPos(0) {}
-CFDE_CSSTextBuf::~CFDE_CSSTextBuf() {
- Reset();
-}
-void CFDE_CSSTextBuf::Reset() {
- if (!m_bExtBuf) {
- FX_Free(m_pBuffer);
- m_pBuffer = NULL;
- }
- m_iDatPos = m_iDatLen = m_iBufLen;
-}
-FX_BOOL CFDE_CSSTextBuf::AttachBuffer(const FX_WCHAR* pBuffer,
- int32_t iBufLen) {
- Reset();
- m_pBuffer = (FX_WCHAR*)pBuffer;
- m_iDatLen = m_iBufLen = iBufLen;
- return m_bExtBuf = TRUE;
-}
-FX_BOOL CFDE_CSSTextBuf::EstimateSize(int32_t iAllocSize) {
- FXSYS_assert(iAllocSize > 0);
- Clear();
- m_bExtBuf = FALSE;
- return ExpandBuf(iAllocSize);
-}
-int32_t CFDE_CSSTextBuf::LoadFromStream(IFX_Stream* pTxtStream,
- int32_t iStreamOffset,
- int32_t iMaxChars,
- FX_BOOL& bEOS) {
- FXSYS_assert(iStreamOffset >= 0 && iMaxChars > 0);
- Clear();
- m_bExtBuf = FALSE;
- if (!ExpandBuf(iMaxChars)) {
- return 0;
- }
- if (pTxtStream->GetPosition() != iStreamOffset) {
- pTxtStream->Seek(FX_STREAMSEEK_Begin, iStreamOffset);
- }
- m_iDatLen = pTxtStream->ReadString(m_pBuffer, iMaxChars, bEOS);
- return m_iDatLen;
-}
-FX_BOOL CFDE_CSSTextBuf::ExpandBuf(int32_t iDesiredSize) {
- if (m_bExtBuf) {
- return FALSE;
- }
- if (!m_pBuffer) {
- m_pBuffer = FX_Alloc(FX_WCHAR, iDesiredSize);
- } else if (m_iBufLen != iDesiredSize) {
- m_pBuffer = FX_Realloc(FX_WCHAR, m_pBuffer, iDesiredSize);
- } else {
- return TRUE;
- }
- if (!m_pBuffer) {
- m_iBufLen = 0;
- return FALSE;
- }
- m_iBufLen = iDesiredSize;
- return TRUE;
-}
-void CFDE_CSSTextBuf::Subtract(int32_t iStart, int32_t iLength) {
- FXSYS_assert(iStart >= 0 && iLength > 0);
- if (iLength > m_iDatLen - iStart) {
- iLength = m_iDatLen - iStart;
- }
- if (iLength < 0) {
- iLength = 0;
- } else {
- FXSYS_memmove(m_pBuffer, m_pBuffer + iStart, iLength * sizeof(FX_WCHAR));
- }
- m_iDatLen = iLength;
-}
diff --git a/xfa/src/fde/css/fde_csssyntax.h b/xfa/src/fde/css/fde_csssyntax.h
deleted file mode 100644
index dc7acdb3d5..0000000000
--- a/xfa/src/fde/css/fde_csssyntax.h
+++ /dev/null
@@ -1,119 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifndef XFA_SRC_FDE_CSS_FDE_CSSSYNTAX_H_
-#define XFA_SRC_FDE_CSS_FDE_CSSSYNTAX_H_
-
-#include "xfa/src/fde/css/fde_css.h"
-#include "xfa/src/fgas/crt/fgas_memory.h"
-#include "xfa/src/fgas/crt/fgas_stream.h"
-
-class CFDE_CSSTextBuf : public CFX_Target {
- public:
- CFDE_CSSTextBuf();
- ~CFDE_CSSTextBuf();
- FX_BOOL AttachBuffer(const FX_WCHAR* pBuffer, int32_t iBufLen);
- FX_BOOL EstimateSize(int32_t iAllocSize);
- int32_t LoadFromStream(IFX_Stream* pTxtStream,
- int32_t iStreamOffset,
- int32_t iMaxChars,
- FX_BOOL& bEOS);
- FX_BOOL AppendChar(FX_WCHAR wch) {
- if (m_iDatLen >= m_iBufLen && !ExpandBuf(m_iBufLen * 2)) {
- return FALSE;
- }
- return (m_pBuffer[m_iDatLen++] = wch), TRUE;
- }
- void Clear() { m_iDatPos = m_iDatLen = 0; }
- void Reset();
- int32_t TrimEnd() {
- while (m_iDatLen > 0 && m_pBuffer[m_iDatLen - 1] <= ' ') {
- --m_iDatLen;
- }
- AppendChar(0);
- return --m_iDatLen;
- }
- void Subtract(int32_t iStart, int32_t iLength);
- FX_BOOL IsEOF() const { return m_iDatPos >= m_iDatLen; }
- FX_WCHAR GetAt(int32_t index) const { return m_pBuffer[index]; }
- FX_WCHAR GetChar() const { return m_pBuffer[m_iDatPos]; }
- FX_WCHAR GetNextChar() const {
- return (m_iDatPos + 1 >= m_iDatLen) ? 0 : m_pBuffer[m_iDatPos + 1];
- }
- void MoveNext() { m_iDatPos++; }
- int32_t GetLength() const { return m_iDatLen; }
- const FX_WCHAR* GetBuffer() const { return m_pBuffer; }
-
- protected:
- FX_BOOL ExpandBuf(int32_t iDesiredSize);
- FX_BOOL m_bExtBuf;
- FX_WCHAR* m_pBuffer;
- int32_t m_iBufLen;
- int32_t m_iDatLen;
- int32_t m_iDatPos;
-};
-
-#define FDE_CSSSYNTAXCHECK_AllowCharset 1
-#define FDE_CSSSYNTAXCHECK_AllowImport 2
-
-enum FDE_CSSSYNTAXMODE {
- FDE_CSSSYNTAXMODE_RuleSet,
- FDE_CSSSYNTAXMODE_Comment,
- FDE_CSSSYNTAXMODE_AtRule,
- FDE_CSSSYNTAXMODE_UnknownRule,
- FDE_CSSSYNTAXMODE_Charset,
- FDE_CSSSYNTAXMODE_Import,
- FDE_CSSSYNTAXMODE_MediaRule,
- FDE_CSSSYNTAXMODE_URI,
- FDE_CSSSYNTAXMODE_MediaType,
- FDE_CSSSYNTAXMODE_Selector,
- FDE_CSSSYNTAXMODE_PropertyName,
- FDE_CSSSYNTAXMODE_PropertyValue,
-};
-
-class CFDE_CSSSyntaxParser : public IFDE_CSSSyntaxParser, public CFX_Target {
- public:
- CFDE_CSSSyntaxParser();
- ~CFDE_CSSSyntaxParser();
- virtual void Release() { delete this; }
- virtual FX_BOOL Init(IFX_Stream* pStream,
- int32_t iCSSPlaneSize,
- int32_t iTextDataSize = 32,
- FX_BOOL bOnlyDeclaration = FALSE);
- virtual FX_BOOL Init(const FX_WCHAR* pBuffer,
- int32_t iBufferSize,
- int32_t iTextDatSize = 32,
- FX_BOOL bOnlyDeclaration = FALSE);
- virtual FDE_CSSSYNTAXSTATUS DoSyntaxParse();
- virtual const FX_WCHAR* GetCurrentString(int32_t& iLength) const;
-
- protected:
- void Reset(FX_BOOL bOnlyDeclaration);
- void SwitchMode(FDE_CSSSYNTAXMODE eMode);
- int32_t SwitchToComment();
-
- FX_BOOL RestoreMode();
- FX_BOOL AppendChar(FX_WCHAR wch);
- int32_t SaveTextData();
- FX_BOOL IsCharsetEnabled() const {
- return (m_dwCheck & FDE_CSSSYNTAXCHECK_AllowCharset) != 0;
- }
- void DisableCharset() { m_dwCheck = FDE_CSSSYNTAXCHECK_AllowImport; }
- FX_BOOL IsImportEnabled() const;
- void DisableImport() { m_dwCheck = 0; }
- IFX_Stream* m_pStream;
- int32_t m_iStreamPos;
- int32_t m_iPlaneSize;
- CFDE_CSSTextBuf m_TextData;
- CFDE_CSSTextBuf m_TextPlane;
- int32_t m_iTextDatLen;
- FX_DWORD m_dwCheck;
- FDE_CSSSYNTAXMODE m_eMode;
- FDE_CSSSYNTAXSTATUS m_eStatus;
- CFX_StackTemplate<FDE_CSSSYNTAXMODE> m_ModeStack;
-};
-
-#endif // XFA_SRC_FDE_CSS_FDE_CSSSYNTAX_H_