webengine/wmlengine/src/css/include/CSSSelector.h
changeset 74 91031d3aab7d
parent 68 92a765b5b3e7
child 85 e358f2276d3f
equal deleted inserted replaced
68:92a765b5b3e7 74:91031d3aab7d
     1 /*
       
     2 * Copyright (c) 2003 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of the License "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Represent the CSS Selector
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef CCSSSelector_H
       
    20 #define CCSSSelector_H
       
    21 
       
    22 //  INCLUDES
       
    23 //#include "CSSEventListener.h"
       
    24 //#include "CSSBufferList.h"
       
    25 //#include "nw_wbxml_dictionary.h"
       
    26 //#include "nw_css_processori.h"
       
    27 //#include "CSSPatternMatcher.h"
       
    28 
       
    29 #include <e32base.h>
       
    30 
       
    31 // CONSTANTS
       
    32 
       
    33 // MACROS
       
    34 
       
    35 // DATA TYPES
       
    36 
       
    37 // FUNCTION PROTOTYPES
       
    38 
       
    39 // FORWARD DECLARATIONS
       
    40 
       
    41 
       
    42 // CLASS DECLARATION
       
    43 
       
    44 // CLASS DECLARATION
       
    45 
       
    46 
       
    47 /**
       
    48 *  This class represents the CSS Condition
       
    49 *  @lib css.lib
       
    50 *  @since 2.1
       
    51 */
       
    52 class CCSSCondition : public CBase
       
    53 {
       
    54 public:
       
    55   // constructor
       
    56 	CCSSCondition(TUint8 aConditionType) 
       
    57     {  
       
    58       iConditionType = aConditionType;
       
    59       iValue1 = NULL;
       
    60       iValue2 = NULL;
       
    61     }
       
    62 
       
    63   // destructor
       
    64 	virtual ~CCSSCondition()
       
    65 	{
       
    66     if (iValue1)
       
    67     {
       
    68       NW_Mem_Free(iValue1);
       
    69     }
       
    70     if (iValue2)
       
    71     {
       
    72       NW_Mem_Free(iValue2);
       
    73     }
       
    74   }
       
    75   public: // New functions
       
    76         
       
    77   public:
       
    78  
       
    79   // condition type
       
    80   NW_Uint8 iConditionType;
       
    81 
       
    82   // value1 - in case of class and id it is the value of attribute
       
    83   // in case of attribute selector, it is attribute name
       
    84   NW_Ucs2 *iValue1;
       
    85 
       
    86   // NULL in case of id and class selectors, in case of attribute selector
       
    87   // it is the value of the attribute
       
    88   NW_Ucs2 *iValue2;
       
    89 };
       
    90 
       
    91 typedef CArrayPtrFlat<CCSSCondition> CCSSConditionList;
       
    92 
       
    93 /**
       
    94 *  This class represents the CSS Simple Selector
       
    95 *  @lib css.lib
       
    96 *  @since 2.1
       
    97 */
       
    98 class CCSSSimpleSelector : public CBase
       
    99 {
       
   100 public:
       
   101   // constructor
       
   102 	CCSSSimpleSelector(TUint16 aElementToken) 
       
   103     {  
       
   104       iElementToken = aElementToken;
       
   105       iConditionList = NULL;
       
   106     }
       
   107 
       
   108   // destructor
       
   109 	virtual ~CCSSSimpleSelector()
       
   110 	{
       
   111     if (iConditionList)
       
   112     {
       
   113       iConditionList->ResetAndDestroy();
       
   114       delete iConditionList;
       
   115     }
       
   116   }
       
   117   public: // New functions
       
   118         
       
   119   public:
       
   120 
       
   121   // element token
       
   122   TUint16 iElementToken;
       
   123   // array of rules that apply to element represented by iElementToken
       
   124   CCSSConditionList* iConditionList;
       
   125 };
       
   126 
       
   127 typedef CArrayPtrFlat<CCSSSimpleSelector> CCSSSimpleSelectorList;
       
   128 
       
   129 // CLASS DECLARATION
       
   130 
       
   131 /**
       
   132 *  This class represents the CSS Selector
       
   133 *
       
   134 *  @lib css.lib
       
   135 *  @since 2.1
       
   136 */
       
   137 class CCSSSelector : public CBase
       
   138 {
       
   139   public:  // Constructors and destructor
       
   140         
       
   141     // constructor
       
   142 	  CCSSSelector(TText8* aSelector, TUint16 aSpecificity, TInt aBufferIndex) 
       
   143     {  
       
   144       iSelector = aSelector;
       
   145       iSpecificity = aSpecificity;
       
   146       iBufferIndex = aBufferIndex;
       
   147       iSimpleSelectorList = NULL;
       
   148     }
       
   149 
       
   150         // constructor
       
   151 	  CCSSSelector() 
       
   152     {  
       
   153       iSelector = NULL;
       
   154       iSpecificity = 0;
       
   155       iBufferIndex = 0;
       
   156       iSimpleSelectorList = NULL;
       
   157     }
       
   158 
       
   159 
       
   160     /**
       
   161     * Destructor.
       
   162     */
       
   163     virtual ~CCSSSelector()
       
   164 	  {
       
   165       if (iSimpleSelectorList)
       
   166       {
       
   167         iSimpleSelectorList->ResetAndDestroy();
       
   168         delete iSimpleSelectorList;
       
   169       }
       
   170     }
       
   171 
       
   172   public: // New functions
       
   173 
       
   174     // constructor
       
   175 	  void Init(TText8* aSelector, TUint16 aSpecificity, TInt aBufferIndex) 
       
   176     {  
       
   177       iSelector = aSelector;
       
   178       iSpecificity = aSpecificity;
       
   179       iBufferIndex = aBufferIndex;
       
   180     }
       
   181     
       
   182   private:
       
   183  
       
   184   public:    // Data
       
   185 
       
   186     // pointer to selector start in the CSS buffer. This is not owned by this class
       
   187     TText8* iSelector;
       
   188 
       
   189     // selector specoficity
       
   190     TUint16 iSpecificity; 
       
   191 
       
   192     // index of the CSS buffer in the buffer lits
       
   193     TInt iBufferIndex;
       
   194 
       
   195     // simple selector list in the selector
       
   196     CCSSSimpleSelectorList* iSimpleSelectorList;
       
   197 };
       
   198 
       
   199 #endif /* CCSSRule_H */