summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--xfa/fde/css/fde_css.h438
-rw-r--r--xfa/fde/css/fde_cssdeclaration.h35
-rw-r--r--xfa/fde/css/fde_cssstyleselector.cpp54
-rw-r--r--xfa/fde/css/fde_cssstyleselector.h66
-rw-r--r--xfa/fde/css/fde_cssstylesheet.cpp36
-rw-r--r--xfa/fde/css/fde_cssstylesheet.h42
-rw-r--r--xfa/fde/css/fde_csssyntax.cpp3
-rw-r--r--xfa/fde/css/fde_csssyntax.h26
-rw-r--r--xfa/fxfa/app/xfa_textlayout.cpp13
-rw-r--r--xfa/fxfa/app/xfa_textlayout.h11
10 files changed, 351 insertions, 373 deletions
diff --git a/xfa/fde/css/fde_css.h b/xfa/fde/css/fde_css.h
index a5573d702b..b949ace778 100644
--- a/xfa/fde/css/fde_css.h
+++ b/xfa/fde/css/fde_css.h
@@ -13,26 +13,38 @@
#include "xfa/fgas/font/fgas_font.h"
class CFDE_CSSAccelerator;
+class CFDE_CSSDeclaration;
+class CFDE_CSSSelector;
class CXFA_CSSTagProvider;
class IFDE_CSSBoundaryStyle;
class IFDE_CSSComputedStyle;
-class IFDE_CSSDeclaration;
class IFDE_CSSFontStyle;
class IFDE_CSSParagraphStyle;
class IFDE_CSSPositionStyle;
class IFDE_CSSRule;
-class IFDE_CSSSelector;
-class IFDE_CSSStyleSelector;
class IFDE_CSSStyleSheet;
-class IFDE_CSSSyntaxParser;
class IFDE_CSSValue;
class IFDE_CSSValueList;
+#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
+
+#define FDE_CSSUNITBITS (3)
+#define FDE_CSSUNITMASK ((1 << FDE_CSSUNITBITS) - 1)
+
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,
@@ -51,6 +63,7 @@ enum FDE_CSSPRIMITIVETYPE {
FDE_CSSPRIMITIVETYPE_Enum,
FDE_CSSPRIMITIVETYPE_Function,
};
+
enum FDE_CSSPROPERTYVALUE {
FDE_CSSPROPERTYVALUE_Bolder,
FDE_CSSPROPERTYVALUE_LowerLatin,
@@ -215,31 +228,7 @@ enum FDE_CSSPROPERTYVALUE {
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,
@@ -354,22 +343,7 @@ enum FDE_CSSPROPERTY {
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,
@@ -382,75 +356,13 @@ enum FDE_CSSSELECTORTYPE {
FDE_CSSSELECTORTYPE_Persudo,
FDE_CSSSELECTORTYPE_ID,
};
-class IFDE_CSSSelector {
- public:
- virtual ~IFDE_CSSSelector() {}
- virtual FDE_CSSSELECTORTYPE GetType() const = 0;
- virtual uint32_t 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 uint32_t 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,
- uint16_t wCodePage,
- uint32_t dwMediaList = FDE_CSSMEDIATYPE_ALL);
- static IFDE_CSSStyleSheet* LoadFromBuffer(
- const CFX_WideString& szUrl,
- const FX_WCHAR* pBuffer,
- int32_t iBufSize,
- uint16_t wCodePage,
- uint32_t dwMediaList = FDE_CSSMEDIATYPE_ALL);
- virtual FX_BOOL GetUrl(CFX_WideString& szUrl) = 0;
- virtual uint32_t GetMediaList() const = 0;
- virtual uint16_t GetCodePage() const = 0;
-
- virtual int32_t CountRules() const = 0;
- virtual IFDE_CSSRule* GetRule(int32_t index) = 0;
-};
-typedef CFX_ArrayTemplate<IFDE_CSSStyleSheet*> CFDE_CSSStyleSheetArray;
enum FDE_CSSSYNTAXSTATUS {
FDE_CSSSYNTAXSTATUS_Error,
@@ -471,23 +383,7 @@ enum FDE_CSSSYNTAXSTATUS {
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,
@@ -495,80 +391,19 @@ enum FDE_CSSLENGTHUNIT {
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,
@@ -581,12 +416,14 @@ enum FDE_CSSBORDERSTYLE {
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,
@@ -610,31 +447,37 @@ enum FDE_CSSDISPLAY {
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,
@@ -642,6 +485,7 @@ enum FDE_CSSPAGEBREAK {
FDE_CSSPAGEBREAK_Left,
FDE_CSSPAGEBREAK_Right,
};
+
enum FDE_CSSOVERFLOW {
FDE_CSSOVERFLOW_Visible,
FDE_CSSOVERFLOW_Hidden,
@@ -650,16 +494,19 @@ enum FDE_CSSOVERFLOW {
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,
@@ -670,10 +517,12 @@ enum FDE_CSSTEXTEMPHASISMARK {
FDE_CSSTEXTEMPHASISMARK_Sesame,
FDE_CSSTEXTEMPHASISMARK_Custom,
};
+
enum FDE_CSSTEXTCOMBINE {
FDE_CSSTEXTCOMBINE_Horizontal,
FDE_CSSTEXTCOMBINE_None,
};
+
enum FDE_CSSCURSOR {
FDE_CSSCURSOR_Auto,
FDE_CSSCURSOR_Crosshair,
@@ -693,12 +542,14 @@ enum FDE_CSSCURSOR {
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,
@@ -707,6 +558,7 @@ enum FDE_CSSCAPTIONSIDE {
FDE_CSSCAPTIONSIDE_Before,
FDE_CSSCAPTIONSIDE_After,
};
+
enum FDE_CSSRUBYALIGN {
FDE_CSSRUBYALIGN_Auto,
FDE_CSSRUBYALIGN_Start,
@@ -718,22 +570,26 @@ enum FDE_CSSRUBYALIGN {
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,
@@ -741,6 +597,7 @@ enum FDE_CSSTEXTALIGN {
FDE_CSSTEXTALIGN_Justify,
FDE_CSSTEXTALIGN_JustifyAll,
};
+
enum FDE_CSSVERTICALALIGN {
FDE_CSSVERTICALALIGN_Baseline,
FDE_CSSVERTICALALIGN_Sub,
@@ -752,6 +609,7 @@ enum FDE_CSSVERTICALALIGN {
FDE_CSSVERTICALALIGN_TextBottom,
FDE_CSSVERTICALALIGN_Number,
};
+
enum FDE_CSSLISTSTYLETYPE {
FDE_CSSLISTSTYLETYPE_Disc,
FDE_CSSLISTSTYLETYPE_Circle,
@@ -775,10 +633,12 @@ enum FDE_CSSLISTSTYLETYPE {
FDE_CSSLISTSTYLETYPE_Katakana,
FDE_CSSLISTSTYLETYPE_KatakanaIroha,
};
+
enum FDE_CSSLISTSTYLEPOSITION {
FDE_CSSLISTSTYLEPOSITION_Outside,
FDE_CSSLISTSTYLEPOSITION_Inside,
};
+
enum FDE_CSSWHITESPACE {
FDE_CSSWHITESPACE_Normal,
FDE_CSSWHITESPACE_Pre,
@@ -786,16 +646,19 @@ enum FDE_CSSWHITESPACE {
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,
@@ -805,6 +668,166 @@ enum FDE_CSSTEXTDECORATION {
FDE_CSSTEXTDECORATION_Double = 16,
};
+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_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;
+};
+
+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 CFDE_CSSSelector* GetSelectorList(int32_t index) const = 0;
+ virtual CFDE_CSSDeclaration* GetDeclaration() = 0;
+};
+
+class IFDE_CSSMediaRule : public IFDE_CSSRule {
+ public:
+ virtual FDE_CSSRULETYPE GetType() const { return FDE_CSSRULETYPE_Media; }
+ virtual uint32_t 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 CFDE_CSSDeclaration* GetDeclaration() = 0;
+};
+
+class IFDE_CSSStyleSheet : public IFX_Unknown {
+ public:
+ static IFDE_CSSStyleSheet* LoadHTMLStandardStyleSheet();
+ static IFDE_CSSStyleSheet* LoadFromStream(
+ const CFX_WideString& szUrl,
+ IFX_Stream* pStream,
+ uint16_t wCodePage,
+ uint32_t dwMediaList = FDE_CSSMEDIATYPE_ALL);
+ static IFDE_CSSStyleSheet* LoadFromBuffer(
+ const CFX_WideString& szUrl,
+ const FX_WCHAR* pBuffer,
+ int32_t iBufSize,
+ uint16_t wCodePage,
+ uint32_t dwMediaList = FDE_CSSMEDIATYPE_ALL);
+ virtual FX_BOOL GetUrl(CFX_WideString& szUrl) = 0;
+ virtual uint32_t GetMediaList() const = 0;
+ virtual uint16_t GetCodePage() const = 0;
+
+ virtual int32_t CountRules() const = 0;
+ virtual IFDE_CSSRule* GetRule(int32_t index) = 0;
+};
+typedef CFX_ArrayTemplate<IFDE_CSSStyleSheet*> CFDE_CSSStyleSheetArray;
+
+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;
+};
+
class IFDE_CSSFontStyle {
public:
virtual ~IFDE_CSSFontStyle() {}
@@ -869,44 +892,5 @@ class IFDE_CSSComputedStyle : public IFX_Unknown {
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_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(uint32_t dwMediaList) = 0;
- virtual CFDE_CSSAccelerator* InitAccelerator() = 0;
- virtual IFDE_CSSComputedStyle* CreateComputedStyle(
- IFDE_CSSComputedStyle* pParentStyle) = 0;
- virtual int32_t MatchDeclarations(
- CXFA_CSSTagProvider* pTag,
- CFDE_CSSDeclarationArray& matchedDecls,
- FDE_CSSPERSUDO ePersudoType = FDE_CSSPERSUDO_NONE) = 0;
- virtual void ComputeStyle(CXFA_CSSTagProvider* pTag,
- const IFDE_CSSDeclaration** ppDeclArray,
- int32_t iDeclCount,
- IFDE_CSSComputedStyle* pDestStyle) = 0;
-};
#endif // XFA_FDE_CSS_FDE_CSS_H_
diff --git a/xfa/fde/css/fde_cssdeclaration.h b/xfa/fde/css/fde_cssdeclaration.h
index 2a3031ea69..d9bacd0e4f 100644
--- a/xfa/fde/css/fde_cssdeclaration.h
+++ b/xfa/fde/css/fde_cssdeclaration.h
@@ -30,24 +30,25 @@ struct FDE_CSSPROPERTYARGS {
FDE_LPCCSSPROPERTYTABLE pProperty;
};
-class CFDE_CSSDeclaration : public IFDE_CSSDeclaration, public CFX_Target {
+class CFDE_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;
+ : m_pFirstProperty(nullptr),
+ m_pLastProperty(nullptr),
+ m_pFirstCustom(nullptr),
+ m_pLastCustom(nullptr) {}
+
+ IFDE_CSSValue* GetProperty(FDE_CSSPROPERTY eProperty,
+ FX_BOOL& bImportant) const;
+ FX_POSITION GetStartPosition() const;
+ void GetNextProperty(FX_POSITION& pos,
+ FDE_CSSPROPERTY& eProperty,
+ IFDE_CSSValue*& pValue,
+ FX_BOOL& bImportant) const;
+ FX_POSITION GetStartCustom() const;
+ 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);
@@ -149,10 +150,12 @@ class CFDE_CSSDeclaration : public IFDE_CSSDeclaration, public CFX_Target {
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;
};
+using CFDE_CSSDeclarationArray = CFX_ArrayTemplate<CFDE_CSSDeclaration*>;
#endif // XFA_FDE_CSS_FDE_CSSDECLARATION_H_
diff --git a/xfa/fde/css/fde_cssstyleselector.cpp b/xfa/fde/css/fde_cssstyleselector.cpp
index b172d71ebf..8ea85b9257 100644
--- a/xfa/fde/css/fde_cssstyleselector.cpp
+++ b/xfa/fde/css/fde_cssstyleselector.cpp
@@ -10,6 +10,8 @@
#include "xfa/fde/css/fde_csscache.h"
#include "xfa/fde/css/fde_cssdeclaration.h"
+#include "xfa/fde/css/fde_cssstylesheet.h"
+#include "xfa/fde/css/fde_csssyntax.h"
#include "xfa/fxfa/app/xfa_textlayout.h"
#define FDE_CSSUNIVERSALHASH ('*')
@@ -78,8 +80,8 @@ void CFDE_CSSCounterStyle::UpdateIndex() {
m_bIndexDirty = FALSE;
}
-FDE_CSSRuleData::FDE_CSSRuleData(IFDE_CSSSelector* pSel,
- IFDE_CSSDeclaration* pDecl,
+FDE_CSSRuleData::FDE_CSSRuleData(CFDE_CSSSelector* pSel,
+ CFDE_CSSDeclaration* pDecl,
uint32_t dwPos)
: pSelector(pSel), pDeclaration(pDecl), dwPriority(dwPos), pNext(NULL) {
static const uint32_t s_Specific[5] = {0x00010000, 0x00010000, 0x00100000,
@@ -121,10 +123,10 @@ void CFDE_CSSRuleCollection::AddRulesFrom(IFDE_CSSStyleSheet* pStyleSheet,
switch (pRule->GetType()) {
case FDE_CSSRULETYPE_Style: {
IFDE_CSSStyleRule* pStyleRule = (IFDE_CSSStyleRule*)pRule;
- IFDE_CSSDeclaration* pDeclaration = pStyleRule->GetDeclaration();
+ CFDE_CSSDeclaration* pDeclaration = pStyleRule->GetDeclaration();
int32_t iSelectors = pStyleRule->CountSelectorLists();
for (int32_t i = 0; i < iSelectors; ++i) {
- IFDE_CSSSelector* pSelector = pStyleRule->GetSelectorList(i);
+ CFDE_CSSSelector* pSelector = pStyleRule->GetSelectorList(i);
if (pSelector->GetType() == FDE_CSSSELECTORTYPE_Persudo) {
FDE_CSSRuleData* pData = NewRuleData(pSelector, pDeclaration);
AddRuleTo(m_pPersudoRules, pData);
@@ -135,8 +137,8 @@ void CFDE_CSSRuleCollection::AddRulesFrom(IFDE_CSSStyleSheet* pStyleSheet,
pDeclaration);
continue;
}
- IFDE_CSSSelector* pNext = pSelector->GetNextSelector();
- if (pNext == NULL) {
+ CFDE_CSSSelector* pNext = pSelector->GetNextSelector();
+ if (!pNext) {
FDE_CSSRuleData* pData = NewRuleData(pSelector, pDeclaration);
AddRuleTo(m_pUniversalRules, pData);
continue;
@@ -175,8 +177,8 @@ void CFDE_CSSRuleCollection::AddRulesFrom(IFDE_CSSStyleSheet* pStyleSheet,
}
void CFDE_CSSRuleCollection::AddRuleTo(CFX_MapPtrToPtr& map,
uint32_t dwKey,
- IFDE_CSSSelector* pSel,
- IFDE_CSSDeclaration* pDecl) {
+ CFDE_CSSSelector* pSel,
+ CFDE_CSSDeclaration* pDecl) {
void* pKey = (void*)(uintptr_t)dwKey;
FDE_CSSRuleData* pData = NewRuleData(pSel, pDecl);
FDE_CSSRuleData* pList = NULL;
@@ -200,15 +202,12 @@ FX_BOOL CFDE_CSSRuleCollection::AddRuleTo(FDE_CSSRuleData*& pList,
}
FDE_CSSRuleData* CFDE_CSSRuleCollection::NewRuleData(
- IFDE_CSSSelector* pSel,
- IFDE_CSSDeclaration* pDecl) {
+ CFDE_CSSSelector* pSel,
+ CFDE_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),
@@ -367,7 +366,7 @@ void CFDE_CSSStyleSelector::MatchRules(FDE_CSSTagCache* pCache,
}
FX_BOOL CFDE_CSSStyleSelector::MatchSelector(FDE_CSSTagCache* pCache,
- IFDE_CSSSelector* pSel,
+ CFDE_CSSSelector* pSel,
FDE_CSSPERSUDO ePersudoType) {
uint32_t dwHash;
while (pSel != NULL && pCache != NULL) {
@@ -418,7 +417,7 @@ FX_BOOL CFDE_CSSStyleSelector::MatchSelector(FDE_CSSTagCache* pCache,
void CFDE_CSSStyleSelector::ComputeStyle(
CXFA_CSSTagProvider* pTag,
- const IFDE_CSSDeclaration** ppDeclArray,
+ const CFDE_CSSDeclaration** ppDeclArray,
int32_t iDeclCount,
IFDE_CSSComputedStyle* pDestStyle) {
ASSERT(iDeclCount >= 0);
@@ -456,13 +455,14 @@ void CFDE_CSSStyleSelector::ComputeStyle(
if (pDecl) {
CFDE_CSSDeclarationArray decls;
decls.SetSize(iDeclCount + 1);
- IFDE_CSSDeclaration** ppInline = decls.GetData();
+ CFDE_CSSDeclaration** ppInline = decls.GetData();
FXSYS_memcpy(ppInline, ppDeclArray,
- iDeclCount * sizeof(IFDE_CSSDeclaration*));
+ iDeclCount * sizeof(CFDE_CSSDeclaration*));
ppInline[iDeclCount++] = pDecl;
- ApplyDeclarations(TRUE, (const IFDE_CSSDeclaration**)ppInline, iDeclCount,
- pDestStyle);
- ApplyDeclarations(FALSE, (const IFDE_CSSDeclaration**)ppInline,
+ ApplyDeclarations(TRUE, const_cast<const CFDE_CSSDeclaration**>(ppInline),
+ iDeclCount, pDestStyle);
+ ApplyDeclarations(FALSE,
+ const_cast<const CFDE_CSSDeclaration**>(ppInline),
iDeclCount, pDestStyle);
return;
}
@@ -478,7 +478,7 @@ void CFDE_CSSStyleSelector::ComputeStyle(
void CFDE_CSSStyleSelector::ApplyDeclarations(
FX_BOOL bPriority,
- const IFDE_CSSDeclaration** ppDeclArray,
+ const CFDE_CSSDeclaration** ppDeclArray,
int32_t iDeclCount,
IFDE_CSSComputedStyle* pDestStyle) {
CFDE_CSSComputedStyle* pComputedStyle = (CFDE_CSSComputedStyle*)pDestStyle;
@@ -504,7 +504,7 @@ void CFDE_CSSStyleSelector::ApplyDeclarations(
}
} else {
CFDE_CSSDeclarationArray importants;
- const IFDE_CSSDeclaration* pDecl = NULL;
+ const CFDE_CSSDeclaration* pDecl = nullptr;
FDE_CSSPROPERTY eProp;
FX_POSITION pos;
for (i = 0; i < iDeclCount; ++i) {
@@ -518,7 +518,7 @@ void CFDE_CSSStyleSelector::ApplyDeclarations(
ApplyProperty(eProp, pVal, pComputedStyle);
} else if (importants.GetSize() == 0 ||
importants[importants.GetUpperBound()] != pDecl) {
- importants.Add((IFDE_CSSDeclaration*)pDecl);
+ importants.Add(const_cast<CFDE_CSSDeclaration*>(pDecl));
}
}
}
@@ -544,11 +544,9 @@ void CFDE_CSSStyleSelector::ApplyDeclarations(
void CFDE_CSSStyleSelector::AppendInlineStyle(CFDE_CSSDeclaration* pDecl,
const FX_WCHAR* psz,
int32_t iLen) {
- ASSERT(pDecl != NULL && psz != NULL && iLen > 0);
- IFDE_CSSSyntaxParser* pSyntax = IFDE_CSSSyntaxParser::Create();
- if (pSyntax == NULL) {
- return;
- }
+ ASSERT(pDecl && psz && iLen > 0);
+
+ CFDE_CSSSyntaxParser* pSyntax = new CFDE_CSSSyntaxParser;
if (pSyntax->Init(psz, iLen, 32, TRUE)) {
int32_t iLen;
const FX_WCHAR* psz;
diff --git a/xfa/fde/css/fde_cssstyleselector.h b/xfa/fde/css/fde_cssstyleselector.h
index 8df8bd0250..faadb4e4e4 100644
--- a/xfa/fde/css/fde_cssstyleselector.h
+++ b/xfa/fde/css/fde_cssstyleselector.h
@@ -22,12 +22,12 @@ class CXFA_CSSTagProvider;
class FDE_CSSRuleData : public CFX_Target {
public:
- FDE_CSSRuleData(IFDE_CSSSelector* pSel,
- IFDE_CSSDeclaration* pDecl,
+ FDE_CSSRuleData(CFDE_CSSSelector* pSel,
+ CFDE_CSSDeclaration* pDecl,
uint32_t dwPos);
- IFDE_CSSSelector* pSelector;
- IFDE_CSSDeclaration* pDeclaration;
+ CFDE_CSSSelector* pSelector;
+ CFDE_CSSDeclaration* pDeclaration;
uint32_t dwPriority;
FDE_CSSRuleData* pNext;
};
@@ -77,11 +77,11 @@ class CFDE_CSSRuleCollection : public CFX_Target {
IFX_FontMgr* pFontMgr);
void AddRuleTo(CFX_MapPtrToPtr& map,
uint32_t dwKey,
- IFDE_CSSSelector* pSel,
- IFDE_CSSDeclaration* pDecl);
+ CFDE_CSSSelector* pSel,
+ CFDE_CSSDeclaration* pDecl);
FX_BOOL AddRuleTo(FDE_CSSRuleData*& pList, FDE_CSSRuleData* pData);
- FDE_CSSRuleData* NewRuleData(IFDE_CSSSelector* pSel,
- IFDE_CSSDeclaration* pDecl);
+ FDE_CSSRuleData* NewRuleData(CFDE_CSSSelector* pSel,
+ CFDE_CSSDeclaration* pDecl);
CFX_MapPtrToPtr m_IDRules;
CFX_MapPtrToPtr m_TagRules;
CFX_MapPtrToPtr m_ClassRules;
@@ -90,33 +90,33 @@ class CFDE_CSSRuleCollection : public CFX_Target {
int32_t m_iSelectors;
};
-class CFDE_CSSStyleSelector : public IFDE_CSSStyleSelector, public CFX_Target {
+class CFDE_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(uint32_t dwMediaList);
- virtual CFDE_CSSAccelerator* InitAccelerator();
- virtual IFDE_CSSComputedStyle* CreateComputedStyle(
+
+ void Release() { delete this; }
+
+ void SetFontMgr(IFX_FontMgr* pFontMgr);
+ void SetDefFontSize(FX_FLOAT fFontSize);
+
+ FX_BOOL SetStyleSheet(FDE_CSSSTYLESHEETGROUP eType,
+ IFDE_CSSStyleSheet* pSheet);
+ FX_BOOL SetStyleSheets(FDE_CSSSTYLESHEETGROUP eType,
+ const CFDE_CSSStyleSheetArray* pArray);
+ void SetStylePriority(FDE_CSSSTYLESHEETGROUP eType,
+ FDE_CSSSTYLESHEETPRIORITY ePriority);
+ void UpdateStyleIndex(uint32_t dwMediaList);
+ CFDE_CSSAccelerator* InitAccelerator();
+ IFDE_CSSComputedStyle* CreateComputedStyle(
IFDE_CSSComputedStyle* pParentStyle);
- virtual int32_t MatchDeclarations(
- CXFA_CSSTagProvider* pTag,
- CFDE_CSSDeclarationArray& matchedDecls,
- FDE_CSSPERSUDO ePersudoType = FDE_CSSPERSUDO_NONE);
- virtual void ComputeStyle(CXFA_CSSTagProvider* pTag,
- const IFDE_CSSDeclaration** ppDeclArray,
- int32_t iDeclCount,
- IFDE_CSSComputedStyle* pDestStyle);
+ int32_t MatchDeclarations(CXFA_CSSTagProvider* pTag,
+ CFDE_CSSDeclarationArray& matchedDecls,
+ FDE_CSSPERSUDO ePersudoType = FDE_CSSPERSUDO_NONE);
+ void ComputeStyle(CXFA_CSSTagProvider* pTag,
+ const CFDE_CSSDeclaration** ppDeclArray,
+ int32_t iDeclCount,
+ IFDE_CSSComputedStyle* pDestStyle);
protected:
void Reset();
@@ -124,13 +124,13 @@ class CFDE_CSSStyleSelector : public IFDE_CSSStyleSelector, public CFX_Target {
FDE_CSSRuleData* pList,
FDE_CSSPERSUDO ePersudoType);
FX_BOOL MatchSelector(FDE_CSSTagCache* pCache,
- IFDE_CSSSelector* pSel,
+ CFDE_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,
+ const CFDE_CSSDeclaration** ppDeclArray,
int32_t iDeclCount,
IFDE_CSSComputedStyle* pDestStyle);
void ApplyProperty(FDE_CSSPROPERTY eProperty,
diff --git a/xfa/fde/css/fde_cssstylesheet.cpp b/xfa/fde/css/fde_cssstylesheet.cpp
index 4f2930dd0e..7a661af1c0 100644
--- a/xfa/fde/css/fde_cssstylesheet.cpp
+++ b/xfa/fde/css/fde_cssstylesheet.cpp
@@ -125,11 +125,7 @@ IFDE_CSSRule* CFDE_CSSStyleSheet::GetRule(int32_t index) {
FX_BOOL CFDE_CSSStyleSheet::LoadFromStream(const CFX_WideString& szUrl,
IFX_Stream* pStream,
uint16_t wCodePage) {
- ASSERT(pStream != NULL);
- IFDE_CSSSyntaxParser* pSyntax = IFDE_CSSSyntaxParser::Create();
- if (pSyntax == NULL) {
- return FALSE;
- }
+ CFDE_CSSSyntaxParser* pSyntax = new CFDE_CSSSyntaxParser;
if (pStream->GetCodePage() != wCodePage) {
pStream->SetCodePage(wCodePage);
}
@@ -143,18 +139,16 @@ FX_BOOL CFDE_CSSStyleSheet::LoadFromBuffer(const CFX_WideString& szUrl,
const FX_WCHAR* pBuffer,
int32_t iBufSize,
uint16_t wCodePage) {
- ASSERT(pBuffer != NULL && iBufSize > 0);
- IFDE_CSSSyntaxParser* pSyntax = IFDE_CSSSyntaxParser::Create();
- if (pSyntax == NULL) {
- return FALSE;
- }
+ ASSERT(pBuffer && iBufSize > 0);
+
+ CFDE_CSSSyntaxParser* pSyntax = new CFDE_CSSSyntaxParser;
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) {
+FX_BOOL CFDE_CSSStyleSheet::LoadFromSyntax(CFDE_CSSSyntaxParser* pSyntax) {
Reset();
m_pAllocator = FX_CreateAllocator(FX_ALLOCTYPE_Static, 1024, 0);
if (m_pAllocator == NULL) {
@@ -187,7 +181,7 @@ FX_BOOL CFDE_CSSStyleSheet::LoadFromSyntax(IFDE_CSSSyntaxParser* pSyntax) {
return eStatus != FDE_CSSSYNTAXSTATUS_Error;
}
FDE_CSSSYNTAXSTATUS CFDE_CSSStyleSheet::LoadMediaRule(
- IFDE_CSSSyntaxParser* pSyntax) {
+ CFDE_CSSSyntaxParser* pSyntax) {
uint32_t dwMediaList = 0;
CFDE_CSSMediaRule* pMediaRule = NULL;
for (;;) {
@@ -226,7 +220,7 @@ FDE_CSSSYNTAXSTATUS CFDE_CSSStyleSheet::LoadMediaRule(
}
}
FDE_CSSSYNTAXSTATUS CFDE_CSSStyleSheet::LoadStyleRule(
- IFDE_CSSSyntaxParser* pSyntax,
+ CFDE_CSSSyntaxParser* pSyntax,
CFDE_CSSRuleArray& ruleArray) {
m_Selectors.RemoveAt(0, m_Selectors.GetSize());
CFDE_CSSStyleRule* pStyleRule = NULL;
@@ -241,7 +235,7 @@ FDE_CSSSYNTAXSTATUS CFDE_CSSStyleSheet::LoadStyleRule(
switch (pSyntax->DoSyntaxParse()) {
case FDE_CSSSYNTAXSTATUS_Selector: {
pszValue = pSyntax->GetCurrentString(iValueLen);
- IFDE_CSSSelector* pSelector =
+ CFDE_CSSSelector* pSelector =
CFDE_CSSSelector::FromString(m_pAllocator, pszValue, iValueLen);
if (pSelector != NULL) {
m_Selectors.Add(pSelector);
@@ -293,7 +287,7 @@ FDE_CSSSYNTAXSTATUS CFDE_CSSStyleSheet::LoadStyleRule(
}
}
FDE_CSSSYNTAXSTATUS CFDE_CSSStyleSheet::LoadFontFaceRule(
- IFDE_CSSSyntaxParser* pSyntax,
+ CFDE_CSSSyntaxParser* pSyntax,
CFDE_CSSRuleArray& ruleArray) {
CFDE_CSSFontFaceRule* pFontFaceRule = NULL;
const FX_WCHAR* pszValue = NULL;
@@ -332,7 +326,7 @@ FDE_CSSSYNTAXSTATUS CFDE_CSSStyleSheet::LoadFontFaceRule(
return FDE_CSSSYNTAXSTATUS_None;
}
FDE_CSSSYNTAXSTATUS CFDE_CSSStyleSheet::LoadImportRule(
- IFDE_CSSSyntaxParser* pSyntax) {
+ CFDE_CSSSyntaxParser* pSyntax) {
for (;;) {
switch (pSyntax->DoSyntaxParse()) {
case FDE_CSSSYNTAXSTATUS_ImportClose:
@@ -344,11 +338,11 @@ FDE_CSSSYNTAXSTATUS CFDE_CSSStyleSheet::LoadImportRule(
}
}
FDE_CSSSYNTAXSTATUS CFDE_CSSStyleSheet::LoadPageRule(
- IFDE_CSSSyntaxParser* pSyntax) {
+ CFDE_CSSSyntaxParser* pSyntax) {
return SkipRuleSet(pSyntax);
}
FDE_CSSSYNTAXSTATUS CFDE_CSSStyleSheet::SkipRuleSet(
- IFDE_CSSSyntaxParser* pSyntax) {
+ CFDE_CSSSyntaxParser* pSyntax) {
for (;;) {
switch (pSyntax->DoSyntaxParse()) {
case FDE_CSSSYNTAXSTATUS_Selector:
@@ -367,8 +361,8 @@ void CFDE_CSSStyleRule::SetSelector(IFX_MEMAllocator* pStaticStore,
const CFDE_CSSSelectorArray& list) {
ASSERT(m_ppSelector == NULL);
m_iSelectors = list.GetSize();
- m_ppSelector = (IFDE_CSSSelector**)pStaticStore->Alloc(
- m_iSelectors * sizeof(IFDE_CSSSelector*));
+ m_ppSelector = static_cast<CFDE_CSSSelector**>(
+ pStaticStore->Alloc(m_iSelectors * sizeof(CFDE_CSSSelector*)));
for (int32_t i = 0; i < m_iSelectors; ++i) {
m_ppSelector[i] = list.GetAt(i);
}
@@ -415,7 +409,7 @@ int32_t FDE_GetCSSNameLen(const FX_WCHAR* psz, const FX_WCHAR* pEnd) {
}
return psz - pStart;
}
-IFDE_CSSSelector* CFDE_CSSSelector::FromString(IFX_MEMAllocator* pStaticStore,
+CFDE_CSSSelector* CFDE_CSSSelector::FromString(IFX_MEMAllocator* pStaticStore,
const FX_WCHAR* psz,
int32_t iLen) {
ASSERT(pStaticStore != NULL && psz != NULL && iLen > 0);
diff --git a/xfa/fde/css/fde_cssstylesheet.h b/xfa/fde/css/fde_cssstylesheet.h
index 21770bfe2b..2a337d0a24 100644
--- a/xfa/fde/css/fde_cssstylesheet.h
+++ b/xfa/fde/css/fde_cssstylesheet.h
@@ -10,7 +10,9 @@
#include "core/fxcrt/include/fx_ext.h"
#include "xfa/fde/css/fde_cssdeclaration.h"
-class CFDE_CSSSelector : public IFDE_CSSSelector, public CFX_Target {
+class CFDE_CSSSyntaxParser;
+
+class CFDE_CSSSelector : public CFX_Target {
public:
CFDE_CSSSelector(FDE_CSSSELECTORTYPE eType,
const FX_WCHAR* psz,
@@ -23,11 +25,11 @@ class CFDE_CSSSelector : public IFDE_CSSSelector, public CFX_Target {
virtual uint32_t GetNameHash() const { return m_dwHash; }
- virtual IFDE_CSSSelector* GetNextSelector() const { return m_pNext; }
- static IFDE_CSSSelector* FromString(IFX_MEMAllocator* pStaticStore,
+ virtual CFDE_CSSSelector* GetNextSelector() const { return m_pNext; }
+ static CFDE_CSSSelector* FromString(IFX_MEMAllocator* pStaticStore,
const FX_WCHAR* psz,
int32_t iLen);
- void SetNext(IFDE_CSSSelector* pNext) { m_pNext = pNext; }
+ void SetNext(CFDE_CSSSelector* pNext) { m_pNext = pNext; }
protected:
static CFDE_CSSSelector* ParseSelector(IFX_MEMAllocator* pStaticStore,
@@ -38,28 +40,26 @@ class CFDE_CSSSelector : public IFDE_CSSSelector, public CFX_Target {
void SetType(FDE_CSSSELECTORTYPE eType) { m_eType = eType; }
FDE_CSSSELECTORTYPE m_eType;
uint32_t m_dwHash;
- IFDE_CSSSelector* m_pNext;
+ CFDE_CSSSelector* m_pNext;
};
-typedef CFX_ArrayTemplate<IFDE_CSSSelector*> CFDE_CSSSelectorArray;
+typedef CFX_ArrayTemplate<CFDE_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 {
+ int32_t CountSelectorLists() const override { return m_iSelectors; }
+ CFDE_CSSSelector* GetSelectorList(int32_t index) const override {
return m_ppSelector[index];
}
- virtual IFDE_CSSDeclaration* GetDeclaration() const {
- return (IFDE_CSSDeclaration*)&m_Declaration;
- }
+ CFDE_CSSDeclaration* GetDeclaration() override { return &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;
+ CFDE_CSSSelector** m_ppSelector;
int32_t m_iSelectors;
};
class CFDE_CSSMediaRule : public IFDE_CSSMediaRule, public CFX_Target {
@@ -81,9 +81,7 @@ class CFDE_CSSMediaRule : public IFDE_CSSMediaRule, public CFX_Target {
};
class CFDE_CSSFontFaceRule : public IFDE_CSSFontFaceRule, public CFX_Target {
public:
- virtual IFDE_CSSDeclaration* GetDeclaration() const {
- return (IFDE_CSSDeclaration*)&m_Declaration;
- }
+ CFDE_CSSDeclaration* GetDeclaration() override { return &m_Declaration; }
CFDE_CSSDeclaration& GetDeclImp() { return m_Declaration; }
protected:
@@ -120,15 +118,15 @@ class CFDE_CSSStyleSheet : public IFDE_CSSStyleSheet, public CFX_Target {
protected:
void Reset();
- FX_BOOL LoadFromSyntax(IFDE_CSSSyntaxParser* pSyntax);
- FDE_CSSSYNTAXSTATUS LoadStyleRule(IFDE_CSSSyntaxParser* pSyntax,
+ FX_BOOL LoadFromSyntax(CFDE_CSSSyntaxParser* pSyntax);
+ FDE_CSSSYNTAXSTATUS LoadStyleRule(CFDE_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,
+ FDE_CSSSYNTAXSTATUS LoadImportRule(CFDE_CSSSyntaxParser* pSyntax);
+ FDE_CSSSYNTAXSTATUS LoadPageRule(CFDE_CSSSyntaxParser* pSyntax);
+ FDE_CSSSYNTAXSTATUS LoadMediaRule(CFDE_CSSSyntaxParser* pSyntax);
+ FDE_CSSSYNTAXSTATUS LoadFontFaceRule(CFDE_CSSSyntaxParser* pSyntax,
CFDE_CSSRuleArray& ruleArray);
- FDE_CSSSYNTAXSTATUS SkipRuleSet(IFDE_CSSSyntaxParser* pSyntax);
+ FDE_CSSSYNTAXSTATUS SkipRuleSet(CFDE_CSSSyntaxParser* pSyntax);
uint16_t m_wCodePage;
uint16_t m_wRefCount;
uint32_t m_dwMediaList;
diff --git a/xfa/fde/css/fde_csssyntax.cpp b/xfa/fde/css/fde_csssyntax.cpp
index 4cc890c96b..26ddaf727a 100644
--- a/xfa/fde/css/fde_csssyntax.cpp
+++ b/xfa/fde/css/fde_csssyntax.cpp
@@ -22,9 +22,6 @@ inline FX_BOOL FDE_IsSelectorStart(FX_WCHAR wch) {
};
#endif
-IFDE_CSSSyntaxParser* IFDE_CSSSyntaxParser::Create() {
- return new CFDE_CSSSyntaxParser;
-}
CFDE_CSSSyntaxParser::CFDE_CSSSyntaxParser()
: m_pStream(NULL),
m_iStreamPos(0),
diff --git a/xfa/fde/css/fde_csssyntax.h b/xfa/fde/css/fde_csssyntax.h
index 0f97604073..d14f81ea7a 100644
--- a/xfa/fde/css/fde_csssyntax.h
+++ b/xfa/fde/css/fde_csssyntax.h
@@ -74,21 +74,22 @@ enum FDE_CSSSYNTAXMODE {
FDE_CSSSYNTAXMODE_PropertyValue,
};
-class CFDE_CSSSyntaxParser : public IFDE_CSSSyntaxParser, public CFX_Target {
+class CFDE_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;
+
+ void Release() { delete this; }
+ FX_BOOL Init(IFX_Stream* pStream,
+ int32_t iCSSPlaneSize,
+ int32_t iTextDataSize = 32,
+ FX_BOOL bOnlyDeclaration = FALSE);
+ FX_BOOL Init(const FX_WCHAR* pBuffer,
+ int32_t iBufferSize,
+ int32_t iTextDatSize = 32,
+ FX_BOOL bOnlyDeclaration = FALSE);
+ FDE_CSSSYNTAXSTATUS DoSyntaxParse();
+ const FX_WCHAR* GetCurrentString(int32_t& iLength) const;
protected:
void Reset(FX_BOOL bOnlyDeclaration);
@@ -104,6 +105,7 @@ class CFDE_CSSSyntaxParser : public IFDE_CSSSyntaxParser, public CFX_Target {
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;
diff --git a/xfa/fxfa/app/xfa_textlayout.cpp b/xfa/fxfa/app/xfa_textlayout.cpp
index e210418337..f2479b7d2f 100644
--- a/xfa/fxfa/app/xfa_textlayout.cpp
+++ b/xfa/fxfa/app/xfa_textlayout.cpp
@@ -11,6 +11,7 @@
#include "core/fxcrt/include/fx_ext.h"
#include "xfa/fde/cfde_path.h"
#include "xfa/fde/css/fde_csscache.h"
+#include "xfa/fde/css/fde_cssstyleselector.h"
#include "xfa/fde/fde_gedevice.h"
#include "xfa/fde/fde_object.h"
#include "xfa/fde/xml/fde_xml_imp.h"
@@ -21,15 +22,15 @@
#include "xfa/fxfa/include/xfa_ffdoc.h"
#include "xfa/fxfa/include/xfa_fontmgr.h"
-void CXFA_TextParseContext::SetDecls(const IFDE_CSSDeclaration** ppDeclArray,
+void CXFA_TextParseContext::SetDecls(const CFDE_CSSDeclaration** ppDeclArray,
int32_t iDeclCount) {
if (iDeclCount <= 0 || !ppDeclArray)
return;
m_dwMatchedDecls = iDeclCount;
- m_ppMatchedDecls = FX_Alloc(IFDE_CSSDeclaration*, iDeclCount);
+ m_ppMatchedDecls = FX_Alloc(CFDE_CSSDeclaration*, iDeclCount);
FXSYS_memcpy(m_ppMatchedDecls, ppDeclArray,
- iDeclCount * sizeof(IFDE_CSSDeclaration*));
+ iDeclCount * sizeof(CFDE_CSSDeclaration*));
}
CXFA_TextParser::~CXFA_TextParser() {
if (m_pUASheet)
@@ -71,7 +72,7 @@ void CXFA_TextParser::InitCSSData(CXFA_TextProvider* pTextProvider) {
CXFA_FFDoc* pDoc = pTextProvider->GetDocNode();
IFX_FontMgr* pFontMgr = pDoc->GetApp()->GetFDEFontMgr();
ASSERT(pFontMgr);
- m_pSelector = IFDE_CSSStyleSelector::Create();
+ m_pSelector = new CFDE_CSSStyleSelector;
m_pSelector->SetFontMgr(pFontMgr);
FX_FLOAT fFontSize = 10;
CXFA_Font font = pTextProvider->GetFontNode();
@@ -241,8 +242,8 @@ void CXFA_TextParser::ParseRichText(CFDE_XMLNode* pXMLNode,
CFDE_CSSDeclarationArray DeclArray;
int32_t iMatchedDecls =
m_pSelector->MatchDeclarations(&tagProvider, DeclArray);
- const IFDE_CSSDeclaration** ppMatchDecls =
- (const IFDE_CSSDeclaration**)DeclArray.GetData();
+ const CFDE_CSSDeclaration** ppMatchDecls =
+ const_cast<const CFDE_CSSDeclaration**>(DeclArray.GetData());
m_pSelector->ComputeStyle(&tagProvider, ppMatchDecls, iMatchedDecls,
pNewStyle);
pCSSAccel->OnLeaveTag(&tagProvider);
diff --git a/xfa/fxfa/app/xfa_textlayout.h b/xfa/fxfa/app/xfa_textlayout.h
index e823448105..bc6719a4df 100644
--- a/xfa/fxfa/app/xfa_textlayout.h
+++ b/xfa/fxfa/app/xfa_textlayout.h
@@ -17,6 +17,7 @@
#define XFA_LOADERCNTXTFLG_FILTERSPACE 0x001
+class CFDE_CSSStyleSelector;
class CXFA_Para;
class CXFA_Font;
class CXFA_TextProvider;
@@ -63,15 +64,15 @@ class CXFA_TextParseContext : public CFX_Target {
}
void SetDisplay(FDE_CSSDISPLAY eDisplay) { m_eDisplay = eDisplay; }
FDE_CSSDISPLAY GetDisplay() const { return m_eDisplay; }
- void SetDecls(const IFDE_CSSDeclaration** ppDeclArray, int32_t iDeclCount);
- const IFDE_CSSDeclaration** GetDecls() {
- return (const IFDE_CSSDeclaration**)m_ppMatchedDecls;
+ void SetDecls(const CFDE_CSSDeclaration** ppDeclArray, int32_t iDeclCount);
+ const CFDE_CSSDeclaration** GetDecls() {
+ return const_cast<const CFDE_CSSDeclaration**>(m_ppMatchedDecls);
}
uint32_t CountDecls() const { return m_dwMatchedDecls; }
IFDE_CSSComputedStyle* m_pParentStyle;
protected:
- IFDE_CSSDeclaration** m_ppMatchedDecls;
+ CFDE_CSSDeclaration** m_ppMatchedDecls;
uint32_t m_dwMatchedDecls;
FDE_CSSDISPLAY m_eDisplay;
};
@@ -130,7 +131,7 @@ class CXFA_TextParser {
IFDE_CSSStyleSheet* LoadDefaultSheetStyle();
IFDE_CSSComputedStyle* CreateStyle(IFDE_CSSComputedStyle* pParentStyle);
IFX_MEMAllocator* m_pAllocator;
- IFDE_CSSStyleSelector* m_pSelector;
+ CFDE_CSSStyleSelector* m_pSelector;
IFDE_CSSStyleSheet* m_pUASheet;
CFX_MapPtrTemplate<CFDE_XMLNode*, CXFA_TextParseContext*>
m_mapXMLNodeToParseContext;