cssparser.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef _CSS_cssparser_h_
00024 #define _CSS_cssparser_h_
00025
00026 #include <qstring.h>
00027 #include <dom/dom_string.h>
00028
00029 namespace DOM {
00030 class StyleListImpl;
00031 class CSSStyleSheetImpl;
00032 class CSSRuleImpl;
00033 class CSSStyleRuleImpl;
00034 class DocumentImpl;
00035 class CSSValueImpl;
00036 class CSSValueListImpl;
00037 class CSSPrimitiveValueImpl;
00038 class CSSStyleDeclarationImpl;
00039 class CSSProperty;
00040 class CSSRuleListImpl;
00041
00042
00043 struct ParseString {
00044 unsigned short *string;
00045 int length;
00046 };
00047
00048 struct Value;
00049 class ValueList;
00050
00051 struct Function {
00052 ParseString name;
00053 ValueList *args;
00054 };
00055
00056 struct Value {
00057 int id;
00058 union {
00059 double fValue;
00060 int iValue;
00061 ParseString string;
00062 struct Function *function;
00063 };
00064 enum {
00065 Operator = 0x100000,
00066 Function = 0x100001,
00067 Q_EMS = 0x100002
00068 };
00069
00070 int unit;
00071 };
00072
00073 static inline QString qString( const ParseString &ps ) {
00074 return QString( (QChar *)ps.string, ps.length );
00075 }
00076 static inline DOMString domString( const ParseString &ps ) {
00077 return DOMString( (QChar *)ps.string, ps.length );
00078 }
00079
00080 class ValueList {
00081 public:
00082 ValueList();
00083 ~ValueList();
00084 void addValue( const Value &val );
00085 Value *current() { return currentValue < numValues ? values + currentValue : 0; }
00086 Value *next() { ++currentValue; return current(); }
00087 Value *values;
00088 int numValues;
00089 int maxValues;
00090 int currentValue;
00091 };
00092
00093 class CSSParser
00094 {
00095 public:
00096 CSSParser( bool strictParsing = true );
00097 ~CSSParser();
00098
00099 void parseSheet( DOM::CSSStyleSheetImpl *sheet, const DOM::DOMString &string );
00100 DOM::CSSRuleImpl *parseRule( DOM::CSSStyleSheetImpl *sheet, const DOM::DOMString &string );
00101 bool parseValue( DOM::CSSStyleDeclarationImpl *decls, int id, const DOM::DOMString &string,
00102 bool _important, bool _nonCSSHint );
00103 bool parseDeclaration( DOM::CSSStyleDeclarationImpl *decls, const DOM::DOMString &string,
00104 bool _nonCSSHint );
00105
00106 static CSSParser *current() { return currentParser; }
00107
00108
00109 DOM::DocumentImpl *document() const;
00110
00111 void addProperty( int propId, CSSValueImpl *value, bool important );
00112 bool hasProperties() const { return numParsedProperties > 0; }
00113 CSSStyleDeclarationImpl *createStyleDeclaration( CSSStyleRuleImpl *rule );
00114 void clearProperties();
00115
00116 bool parseValue( int propId, bool important );
00117 bool parseShortHand( const int *properties, int numProperties, bool important );
00118 bool parse4Values( const int *properties, bool important );
00119 bool parseContent( int propId, bool important );
00120 bool parseShape( int propId, bool important );
00121 bool parseFont(bool important);
00122 CSSValueListImpl *parseFontFamily();
00123 CSSPrimitiveValueImpl *parseColor();
00124
00125 public:
00126 bool strict;
00127 bool important;
00128 bool nonCSSHint;
00129 unsigned int id;
00130 DOM::StyleListImpl* styleElement;
00131 DOM::CSSRuleImpl *rule;
00132 ValueList *valueList;
00133 CSSProperty **parsedProperties;
00134 int numParsedProperties;
00135 int maxParsedProperties;
00136 bool inParseShortHand;
00137 unsigned int defaultNamespace;
00138 static CSSParser *currentParser;
00139
00140
00141 public:
00142 int lex( void *yylval );
00143 int token() { return yyTok; }
00144 unsigned short *text( int *length);
00145 int lex();
00146 private:
00147 int yyparse();
00148 void runParser(int length);
00149
00150 unsigned short *data;
00151 unsigned short *yytext;
00152 unsigned short *yy_c_buf_p;
00153 unsigned short yy_hold_char;
00154 int yy_last_accepting_state;
00155 unsigned short *yy_last_accepting_cpos;
00156 int block_nesting;
00157 int yyleng;
00158 int yyTok;
00159 int yy_start;
00160 };
00161
00162 }
00163 #endif
This file is part of the documentation for khtml Library Version 3.2.1.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Thu Mar 4 22:45:39 2004 by
doxygen 1.3.6-20040222 written by
Dimitri van Heesch, © 1997-2003