00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
#ifndef _CSS_BASE_H
00026
#define _CSS_BASE_H
00027
00028
#include "dom/dom_string.h"
00029
#include "dom/dom_misc.h"
00030
#include "xml/dom_nodeimpl.h"
00031
#include "misc/shared.h"
00032
#include <kdemacros.h>
00033
#include <qdatetime.h>
00034
#include <qptrlist.h>
00035
00036 namespace DOM {
00037
00038
class StyleSheetImpl;
00039
class MediaList;
00040
00041
class CSSSelector;
00042
class CSSProperty;
00043
class CSSValueImpl;
00044
class CSSPrimitiveValueImpl;
00045
class CSSStyleDeclarationImpl;
00046
class CSSRuleImpl;
00047
class CSSStyleRuleImpl;
00048
00049
class DocumentImpl;
00050
00051
00052
class CSSSelector
00053 {
00054
public:
00055 CSSSelector()
00056 : tagHistory(0), simpleSelector(0), attr(0), tag(0xffff), relation( Descendant ),
00057 match( None ), nonCSSHint(
false ), pseudoId( 0 ), _pseudoType(PseudoNotParsed)
00058 {}
00059
00060 ~CSSSelector() {
00061
delete tagHistory;
00062
delete simpleSelector;
00063 }
00064
00068
void print();
00069
00073
DOMString selectorText()
const;
00074
00075
00076
bool operator == (
const CSSSelector &other )
const;
00077
00078
00079
00080
unsigned int specificity()
const;
00081
00082
00083
enum Match
00084 {
00085 None = 0,
00086 Id,
00087 Exact,
00088 Set,
00089 List,
00090 Hyphen,
00091 Pseudo,
00092 Contain,
00093 Begin,
00094 End
00095 };
00096
00097
enum Relation
00098 {
00099 Descendant = 0,
00100 Child,
00101 Sibling,
00102 SubSelector
00103 };
00104
00105
enum PseudoType
00106 {
00107 PseudoNotParsed = 0,
00108 PseudoOther,
00109 PseudoEmpty,
00110 PseudoFirstChild,
00111 PseudoLastChild,
00112 PseudoOnlyChild,
00113 PseudoFirstLine,
00114 PseudoFirstLetter,
00115 PseudoLink,
00116 PseudoVisited,
00117 PseudoHover,
00118 PseudoFocus,
00119 PseudoActive,
00120 PseudoTarget,
00121 PseudoBefore,
00122 PseudoAfter,
00123 PseudoLang,
00124 PseudoNot,
00125 PseudoRoot,
00126 PseudoSelection
00127 };
00128
00129 PseudoType pseudoType()
const {
00130
if (_pseudoType == PseudoNotParsed)
00131 extractPseudoType();
00132
return _pseudoType;
00133 }
00134
00135
mutable DOM::DOMString value;
00136 CSSSelector *tagHistory;
00137 CSSSelector* simpleSelector;
00138 DOM::NodeImpl::Id attr;
00139 DOM::NodeImpl::Id tag;
00140
00141 Relation relation : 2;
00142 Match match : 4;
00143
bool nonCSSHint : 1;
00144
unsigned int pseudoId : 3;
00145
mutable PseudoType _pseudoType : 5;
00146
00147
private:
00148
void extractPseudoType()
const;
00149 };
00150
00151
00152
class StyleBaseImpl :
public khtml::TreeShared<StyleBaseImpl>
00153 {
00154
public:
00155 StyleBaseImpl() { m_parent = 0; hasInlinedDecl =
false; strictParsing =
true; multiLength =
false; }
00156 StyleBaseImpl(StyleBaseImpl *p) {
00157 m_parent = p; hasInlinedDecl =
false;
00158 strictParsing = (m_parent ? m_parent->useStrictParsing() :
true);
00159 multiLength =
false;
00160 }
00161
00162
virtual ~StyleBaseImpl() {}
00163
00164
00165
00166
KURL baseURL();
00167
00168
virtual bool isStyleSheet()
const {
return false; }
00169
virtual bool isCSSStyleSheet()
const {
return false; }
00170
virtual bool isStyleSheetList()
const {
return false; }
00171
virtual bool isMediaList()
const {
return false; }
00172
virtual bool isRuleList()
const {
return false; }
00173
virtual bool isRule()
const {
return false; }
00174
virtual bool isStyleRule()
const {
return false; }
00175
virtual bool isCharetRule()
const {
return false; }
00176
virtual bool isImportRule()
const {
return false; }
00177
virtual bool isMediaRule()
const {
return false; }
00178
virtual bool isFontFaceRule()
const {
return false; }
00179
virtual bool isPageRule()
const {
return false; }
00180
virtual bool isUnknownRule()
const {
return false; }
00181
virtual bool isStyleDeclaration()
const {
return false; }
00182
virtual bool isValue()
const {
return false; }
00183
virtual bool isPrimitiveValue()
const {
return false; }
00184
virtual bool isValueList()
const {
return false; }
00185
virtual bool isValueCustom()
const {
return false; }
00186
00187
void setParent(StyleBaseImpl *parent) { m_parent = parent; }
00188
00189
static void setParsedValue(
int propId,
const CSSValueImpl *parsedValue,
00190
bool important,
bool nonCSSHint,
QPtrList<CSSProperty> *propList);
00191
00192
virtual bool parseString(
const DOMString &,
bool =
false) {
return false; }
00193
00194
virtual void checkLoaded()
const;
00195
00196
void setStrictParsing(
bool b ) { strictParsing = b; }
00197
bool useStrictParsing()
const {
return strictParsing; }
00198
00199
00200 StyleSheetImpl* stylesheet();
00201
00202
protected:
00203
bool hasInlinedDecl : 1;
00204
bool strictParsing : 1;
00205
bool multiLength : 1;
00206 };
00207
00208
00209
class StyleListImpl :
public StyleBaseImpl
00210 {
00211
public:
00212 StyleListImpl() : StyleBaseImpl() { m_lstChildren = 0; }
00213 StyleListImpl(StyleBaseImpl *parent) : StyleBaseImpl(parent) { m_lstChildren = 0; }
00214
virtual ~StyleListImpl();
00215
00216
unsigned long length()
const {
return m_lstChildren->count(); }
00217 StyleBaseImpl *item(
unsigned long num)
const {
return m_lstChildren->at(num); }
00218
00219
void append(StyleBaseImpl *item) { m_lstChildren->append(item); }
00220
00221
protected:
00222
QPtrList<StyleBaseImpl> *m_lstChildren;
00223 };
00224
00225 KDE_NO_EXPORT
int getPropertyID(
const char *tagStr,
int len);
00226
00227 }
00228
00229
#endif