Home | History | Annotate | Download | only in css
      1 // Copyright 2014 PDFium Authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style license that can be
      3 // found in the LICENSE file.
      4 
      5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
      6 
      7 #ifndef _FDE_CSSDECLARATION
      8 #define _FDE_CSSDECLARATION
      9 #include "fde_cssdatatable.h"
     10 typedef struct _FDE_CSSPROPERTYHOLDER : public CFX_Target {
     11   int16_t eProperty;
     12   int16_t bImportant;
     13   IFDE_CSSValue* pValue;
     14   _FDE_CSSPROPERTYHOLDER* pNext;
     15 } FDE_CSSPROPERTYHOLDER, *FDE_LPCSSPROPERTYHOLDER;
     16 typedef struct _FDE_CSSCUSTOMPROPERTY : public CFX_Target {
     17   const FX_WCHAR* pwsName;
     18   const FX_WCHAR* pwsValue;
     19   _FDE_CSSCUSTOMPROPERTY* pNext;
     20 } FDE_CSSCUSTOMPROPERTY, *FDE_LPCSSCUSTOMPROPERTY;
     21 typedef struct _FDE_CSSPROPERTYARGS : public CFX_Target {
     22   IFX_MEMAllocator* pStaticStore;
     23   CFX_MapPtrToPtr* pStringCache;
     24   FDE_LPCCSSPROPERTYTABLE pProperty;
     25 } FDE_CSSPROPERTYARGS;
     26 typedef FDE_CSSPROPERTYARGS const* FDE_LPCCSSPROPERTYARGS;
     27 class CFDE_CSSDeclaration : public IFDE_CSSDeclaration, public CFX_Target {
     28  public:
     29   CFDE_CSSDeclaration()
     30       : m_pFirstProperty(NULL),
     31         m_pLastProperty(NULL),
     32         m_pFirstCustom(NULL),
     33         m_pLastCustom(NULL) {}
     34   virtual IFDE_CSSValue* GetProperty(FDE_CSSPROPERTY eProperty,
     35                                      FX_BOOL& bImportant) const;
     36   virtual FX_POSITION GetStartPosition() const;
     37   virtual void GetNextProperty(FX_POSITION& pos,
     38                                FDE_CSSPROPERTY& eProperty,
     39                                IFDE_CSSValue*& pValue,
     40                                FX_BOOL& bImportant) const;
     41   virtual FX_POSITION GetStartCustom() const;
     42   virtual void GetNextCustom(FX_POSITION& pos,
     43                              CFX_WideString& wsName,
     44                              CFX_WideString& wsValue) const;
     45   FX_BOOL AddProperty(FDE_LPCCSSPROPERTYARGS pArgs,
     46                       const FX_WCHAR* pszValue,
     47                       int32_t iValueLen);
     48   FX_BOOL AddProperty(FDE_LPCCSSPROPERTYARGS pArgs,
     49                       const FX_WCHAR* pszName,
     50                       int32_t iNameLen,
     51                       const FX_WCHAR* pszValue,
     52                       int32_t iValueLen);
     53 
     54  protected:
     55   FX_BOOL ParseTextEmphasisProperty(FDE_LPCCSSPROPERTYARGS pArgs,
     56                                     const FX_WCHAR* pszValue,
     57                                     int32_t iValueLen,
     58                                     FX_BOOL bImportant);
     59   FX_BOOL ParseColumnsProperty(FDE_LPCCSSPROPERTYARGS pArgs,
     60                                const FX_WCHAR* pszValue,
     61                                int32_t iValueLen,
     62                                FX_BOOL bImportant);
     63   FX_BOOL ParseColumnRuleProperty(FDE_LPCCSSPROPERTYARGS pArgs,
     64                                   const FX_WCHAR* pszValue,
     65                                   int32_t iValueLen,
     66                                   FX_BOOL bImportant);
     67   FX_BOOL ParseOverflowProperty(FDE_LPCCSSPROPERTYARGS pArgs,
     68                                 const FX_WCHAR* pszValue,
     69                                 int32_t iValueLen,
     70                                 FX_BOOL bImportant);
     71   FX_BOOL ParseFontProperty(FDE_LPCCSSPROPERTYARGS pArgs,
     72                             const FX_WCHAR* pszValue,
     73                             int32_t iValueLen,
     74                             FX_BOOL bImportant);
     75   FX_BOOL ParseBackgroundProperty(FDE_LPCCSSPROPERTYARGS pArgs,
     76                                   const FX_WCHAR* pszValue,
     77                                   int32_t iValueLen,
     78                                   FX_BOOL bImportant);
     79   FX_BOOL ParseListStyleProperty(FDE_LPCCSSPROPERTYARGS pArgs,
     80                                  const FX_WCHAR* pszValue,
     81                                  int32_t iValueLen,
     82                                  FX_BOOL bImportant);
     83   FX_BOOL ParseBorderPropoerty(IFX_MEMAllocator* pStaticStore,
     84                                const FX_WCHAR* pszValue,
     85                                int32_t iValueLen,
     86                                IFDE_CSSValue*& pColor,
     87                                IFDE_CSSValue*& pStyle,
     88                                IFDE_CSSValue*& pWidth) const;
     89   void AddBorderProperty(IFX_MEMAllocator* pStaticStore,
     90                          IFDE_CSSValue* pColor,
     91                          IFDE_CSSValue* pStyle,
     92                          IFDE_CSSValue* pWidth,
     93                          FX_BOOL bImportant,
     94                          FDE_CSSPROPERTY eColor,
     95                          FDE_CSSPROPERTY eStyle,
     96                          FDE_CSSPROPERTY eWidth);
     97   FX_BOOL ParseContentProperty(FDE_LPCCSSPROPERTYARGS pArgs,
     98                                const FX_WCHAR* pszValue,
     99                                int32_t iValueLen,
    100                                FX_BOOL bImportant);
    101   FX_BOOL ParseCounterProperty(FDE_LPCCSSPROPERTYARGS pArgs,
    102                                const FX_WCHAR* pszValue,
    103                                int32_t iValueLen,
    104                                FX_BOOL bImportant);
    105   FX_BOOL ParseValueListProperty(FDE_LPCCSSPROPERTYARGS pArgs,
    106                                  const FX_WCHAR* pszValue,
    107                                  int32_t iValueLen,
    108                                  FX_BOOL bImportant);
    109   FX_BOOL Add4ValuesProperty(IFX_MEMAllocator* pStaticStore,
    110                              const CFDE_CSSValueArray& list,
    111                              FX_BOOL bImportant,
    112                              FDE_CSSPROPERTY eLeft,
    113                              FDE_CSSPROPERTY eTop,
    114                              FDE_CSSPROPERTY eRight,
    115                              FDE_CSSPROPERTY eBottom);
    116   IFDE_CSSValue* ParseNumber(FDE_LPCCSSPROPERTYARGS pArgs,
    117                              const FX_WCHAR* pszValue,
    118                              int32_t iValueLen);
    119   IFDE_CSSValue* ParseEnum(FDE_LPCCSSPROPERTYARGS pArgs,
    120                            const FX_WCHAR* pszValue,
    121                            int32_t iValueLen);
    122   IFDE_CSSValue* ParseColor(FDE_LPCCSSPROPERTYARGS pArgs,
    123                             const FX_WCHAR* pszValue,
    124                             int32_t iValueLen);
    125   IFDE_CSSValue* ParseURI(FDE_LPCCSSPROPERTYARGS pArgs,
    126                           const FX_WCHAR* pszValue,
    127                           int32_t iValueLen);
    128   IFDE_CSSValue* ParseString(FDE_LPCCSSPROPERTYARGS pArgs,
    129                              const FX_WCHAR* pszValue,
    130                              int32_t iValueLen);
    131   IFDE_CSSValue* ParseFunction(FDE_LPCCSSPROPERTYARGS pArgs,
    132                                const FX_WCHAR* pszValue,
    133                                int32_t iValueLen);
    134   const FX_WCHAR* CopyToLocal(FDE_LPCCSSPROPERTYARGS pArgs,
    135                               const FX_WCHAR* pszValue,
    136                               int32_t iValueLen);
    137   void AddPropertyHolder(IFX_MEMAllocator* pStaticStore,
    138                          FDE_CSSPROPERTY eProperty,
    139                          IFDE_CSSValue* pValue,
    140                          FX_BOOL bImportant);
    141   IFDE_CSSPrimitiveValue* NewNumberValue(IFX_MEMAllocator* pStaticStore,
    142                                          FDE_CSSPRIMITIVETYPE eUnit,
    143                                          FX_FLOAT fValue) const;
    144   IFDE_CSSPrimitiveValue* NewEnumValue(IFX_MEMAllocator* pStaticStore,
    145                                        FDE_CSSPROPERTYVALUE eValue) const;
    146   FDE_LPCSSPROPERTYHOLDER m_pFirstProperty;
    147   FDE_LPCSSPROPERTYHOLDER m_pLastProperty;
    148   FDE_LPCSSCUSTOMPROPERTY m_pFirstCustom;
    149   FDE_LPCSSCUSTOMPROPERTY m_pLastCustom;
    150 };
    151 #endif
    152