webengine/wmlengine/src/css/include/CSSParser.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:  Parses CSS styles
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef TCSSParser_H
       
    20 #define TCSSParser_H
       
    21 
       
    22 //  INCLUDES
       
    23 #include "nw_object_dynamic.h"
       
    24 #include "NW_CSS_EXPORT.h"
       
    25 #include "CSSEventListener.h"
       
    26 #include "CSSReader.h"
       
    27   
       
    28 // CONSTANTS
       
    29 
       
    30 // MACROS
       
    31 
       
    32 // DATA TYPES
       
    33 
       
    34 enum TCSSConditionType
       
    35 {
       
    36   ID_CONDITION = 1,
       
    37   CLASS_CONDITION,
       
    38   ATTRIBUTE_CONDITION,
       
    39   ACTIVE_CONDITION,
       
    40   LINK_CONDITION,
       
    41   VISITED_CONDITION,
       
    42   FOCUS_CONDITION
       
    43 };
       
    44 
       
    45 // FUNCTION PROTOTYPES
       
    46 
       
    47 // FORWARD DECLARATIONS
       
    48 
       
    49 // CLASS DECLARATION
       
    50 
       
    51 /**
       
    52 *  This class is the parser for CSS
       
    53 *  @lib css.lib
       
    54 *  @since 2.1
       
    55 */
       
    56 class TCSSParser
       
    57 {
       
    58   public:
       
    59     // constructor
       
    60 	  TCSSParser(TText8* aBuffer, TUint32 aLength, TUint32 aEncoding) 
       
    61       {  
       
    62         iReader.Init(aBuffer, aLength, aEncoding);
       
    63         iEventListener = NULL;
       
    64       }
       
    65 
       
    66     TCSSParser()
       
    67       {
       
    68         iEventListener = NULL;
       
    69       } 
       
    70 
       
    71     void Init(TText8* aBuffer, TUint32 aLength, TUint32 aEncoding) 
       
    72       {  
       
    73         iReader.Init(aBuffer, aLength, aEncoding);
       
    74         iEventListener = NULL;
       
    75       }
       
    76 
       
    77   public: // New functions
       
    78 
       
    79     TBrowserStatusCode ParseStyleSheet(MCSSEventListener* aEventListener);
       
    80 
       
    81     TBrowserStatusCode SimpleSelectorListIterate(TCSSSimpleSelector* aSimpleSelector);
       
    82 
       
    83     TBrowserStatusCode ConditionListIterate(TText8* aConditionType,
       
    84                                      TCSSReaderUnit *aValue1,
       
    85                                      TCSSReaderUnit *aValue2);
       
    86 
       
    87     TBrowserStatusCode DeclarationListIterate(TCSSReaderUnit* aProperty,
       
    88                                    TCSSPropertyVal* aPropertyVal,
       
    89                                    TUint8 *aNumVals,
       
    90                                    TUint8 maxVals,
       
    91                                    TBool* aImportant);
       
    92 
       
    93 
       
    94     TBrowserStatusCode ParserRGB(TCSSPropertyVal* aRVal,
       
    95                           TCSSPropertyVal* aGVal,
       
    96                           TCSSPropertyVal* aBVal);
       
    97 
       
    98 
       
    99     TUint32 ParseCharset();
       
   100 
       
   101     void SetPosition(TText8* aPosition);
       
   102 
       
   103     inline TUint32 GetEncoding(){return iReader.GetEncoding();}
       
   104 
       
   105     inline TCSSReader* GetReader() {return &iReader;}
       
   106 
       
   107     inline TText8* GetPosition(){ return iReader.GetBufferPointer();}
       
   108 
       
   109     private: //methods
       
   110 
       
   111       TBool ParseElementName(TCSSReaderUnit* aNameSpace, TCSSReaderUnit* aElementName);
       
   112 
       
   113       TBrowserStatusCode SelectorListIterate(TCSSReaderUnit* aTargetElement,
       
   114                                       TUint32 *aSpecificity);
       
   115 
       
   116       TBrowserStatusCode ParseRule();
       
   117 
       
   118       TBool HasValidMedia();
       
   119 
       
   120       TBrowserStatusCode ParseImportRule();
       
   121 
       
   122       TBrowserStatusCode ParseMediaRule();
       
   123 
       
   124       TBrowserStatusCode ParseStyleRules();
       
   125 
       
   126       TBrowserStatusCode ParseHeader();
       
   127 
       
   128       TBrowserStatusCode ParserPropertyVal(TCSSPropertyVal* aPropertyVal);
       
   129 
       
   130     private:    // Data
       
   131 
       
   132       // lexer
       
   133       TCSSReader iReader;
       
   134       // event listener to get the CSS events like start Selector
       
   135       MCSSEventListener* iEventListener;
       
   136 };
       
   137 #endif /* TCSSParser_H */