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 DirectAdjacent,
00102 IndirectAdjacent,
00103 SubSelector
00104 };
00105
00106
enum PseudoType
00107 {
00108 PseudoNotParsed = 0,
00109 PseudoOther,
00110 PseudoEmpty,
00111 PseudoFirstChild,
00112 PseudoLastChild,
00113 PseudoNthChild,
00114 PseudoNthLastChild,
00115 PseudoOnlyChild,
00116 PseudoFirstOfType,
00117 PseudoLastOfType,
00118 PseudoNthOfType,
00119 PseudoNthLastOfType,
00120 PseudoOnlyOfType,
00121 PseudoFirstLine,
00122 PseudoFirstLetter,
00123 PseudoLink,
00124 PseudoVisited,
00125 PseudoHover,
00126 PseudoFocus,
00127 PseudoActive,
00128 PseudoTarget,
00129 PseudoBefore,
00130 PseudoAfter,
00131 PseudoLang,
00132 PseudoNot,
00133 PseudoContains,
00134 PseudoRoot,
00135 PseudoSelection,
00136 PseudoEnabled,
00137 PseudoDisabled,
00138 PseudoChecked,
00139 PseudoIndeterminate
00140 };
00141
00142 PseudoType pseudoType()
const {
00143
if (_pseudoType == PseudoNotParsed)
00144 extractPseudoType();
00145
return _pseudoType;
00146 }
00147
00148
mutable DOM::DOMString value;
00149 CSSSelector *tagHistory;
00150 CSSSelector* simpleSelector;
00151
DOM::DOMString string_arg;
00152 DOM::NodeImpl::Id attr;
00153 DOM::NodeImpl::Id tag;
00154
00155 Relation relation : 3;
00156 Match match : 4;
00157
bool nonCSSHint : 1;
00158
unsigned int pseudoId : 3;
00159
mutable PseudoType _pseudoType : 5;
00160
00161
private:
00162
void extractPseudoType()
const;
00163 };
00164
00165
00166
class StyleBaseImpl :
public khtml::TreeShared<StyleBaseImpl>
00167 {
00168
public:
00169 StyleBaseImpl() { m_parent = 0; hasInlinedDecl =
false; strictParsing =
true; multiLength =
false; }
00170 StyleBaseImpl(StyleBaseImpl *p) {
00171 m_parent = p; hasInlinedDecl =
false;
00172 strictParsing = (m_parent ? m_parent->useStrictParsing() :
true);
00173 multiLength =
false;
00174 }
00175
00176
virtual ~StyleBaseImpl() {}
00177
00178
00179
00180
KURL baseURL();
00181
00182
virtual bool isStyleSheet()
const {
return false; }
00183
virtual bool isCSSStyleSheet()
const {
return false; }
00184
virtual bool isStyleSheetList()
const {
return false; }
00185
virtual bool isMediaList()
const {
return false; }
00186
virtual bool isRuleList()
const {
return false; }
00187
virtual bool isRule()
const {
return false; }
00188
virtual bool isStyleRule()
const {
return false; }
00189
virtual bool isCharetRule()
const {
return false; }
00190
virtual bool isImportRule()
const {
return false; }
00191
virtual bool isMediaRule()
const {
return false; }
00192
virtual bool isFontFaceRule()
const {
return false; }
00193
virtual bool isPageRule()
const {
return false; }
00194
virtual bool isUnknownRule()
const {
return false; }
00195
virtual bool isStyleDeclaration()
const {
return false; }
00196
virtual bool isValue()
const {
return false; }
00197
virtual bool isPrimitiveValue()
const {
return false; }
00198
virtual bool isValueList()
const {
return false; }
00199
virtual bool isValueCustom()
const {
return false; }
00200
00201
void setParent(StyleBaseImpl *parent) { m_parent = parent; }
00202
00203
static void setParsedValue(
int propId,
const CSSValueImpl *parsedValue,
00204
bool important,
bool nonCSSHint,
QPtrList<CSSProperty> *propList);
00205
00206
virtual bool parseString(
const DOMString &,
bool =
false) {
return false; }
00207
00208
virtual void checkLoaded()
const;
00209
00210
void setStrictParsing(
bool b ) { strictParsing = b; }
00211
bool useStrictParsing()
const {
return strictParsing; }
00212
00213
00214 StyleSheetImpl* stylesheet();
00215
00216
protected:
00217
bool hasInlinedDecl : 1;
00218
bool strictParsing : 1;
00219
bool multiLength : 1;
00220 };
00221
00222
00223
class StyleListImpl :
public StyleBaseImpl
00224 {
00225
public:
00226 StyleListImpl() : StyleBaseImpl() { m_lstChildren = 0; }
00227 StyleListImpl(StyleBaseImpl *parent) : StyleBaseImpl(parent) { m_lstChildren = 0; }
00228
virtual ~StyleListImpl();
00229
00230
unsigned long length()
const {
return m_lstChildren->count(); }
00231 StyleBaseImpl *item(
unsigned long num)
const {
return m_lstChildren->at(num); }
00232
00233
void append(StyleBaseImpl *item) { m_lstChildren->append(item); }
00234
00235
protected:
00236
QPtrList<StyleBaseImpl> *m_lstChildren;
00237 };
00238
00239 KDE_NO_EXPORT
int getPropertyID(
const char *tagStr,
int len);
00240
00241 }
00242
00243
#endif