css_valueimpl.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef _CSS_css_valueimpl_h_
00025 #define _CSS_css_valueimpl_h_
00026
00027 #include "dom/css_value.h"
00028 #include "dom/dom_string.h"
00029 #include "css/css_base.h"
00030 #include "misc/loader_client.h"
00031 #include "misc/shared.h"
00032
00033 #include <qintdict.h>
00034
00035 namespace khtml {
00036 class RenderStyle;
00037 class CachedImage;
00038 }
00039
00040 namespace DOM {
00041
00042 class CSSRuleImpl;
00043 class CSSValueImpl;
00044 class NodeImpl;
00045 class CounterImpl;
00046
00047
00048 class CSSStyleDeclarationImpl : public StyleBaseImpl
00049 {
00050 public:
00051 CSSStyleDeclarationImpl(CSSRuleImpl *parentRule);
00052 CSSStyleDeclarationImpl(CSSRuleImpl *parentRule, QPtrList<CSSProperty> *lstValues);
00053 virtual ~CSSStyleDeclarationImpl();
00054
00055 CSSStyleDeclarationImpl& operator=( const CSSStyleDeclarationImpl&);
00056
00057 unsigned long length() const;
00058 CSSRuleImpl *parentRule() const;
00059 virtual DOM::DOMString removeProperty( int propertyID, bool NonCSSHints = false );
00060 virtual bool setProperty ( int propertyId, const DOM::DOMString &value, bool important = false, bool nonCSSHint = false);
00061 virtual void setProperty ( int propertyId, int value, bool important = false, bool nonCSSHint = false);
00062
00063
00064 virtual void setLengthProperty(int id, const DOM::DOMString &value, bool important, bool nonCSSHint = true, bool multiLength = false);
00065
00066
00067 virtual void setProperty ( const DOMString &propertyString);
00068 virtual DOM::DOMString item ( unsigned long index ) const;
00069
00070 DOM::DOMString cssText() const;
00071 void setCssText(DOM::DOMString str);
00072
00073 virtual bool isStyleDeclaration() const { return true; }
00074 virtual bool parseString( const DOMString &string, bool = false );
00075
00076 virtual CSSValueImpl *getPropertyCSSValue( int propertyID ) const;
00077 virtual DOMString getPropertyValue( int propertyID ) const;
00078 virtual bool getPropertyPriority( int propertyID ) const;
00079
00080 QPtrList<CSSProperty> *values() const { return m_lstValues; }
00081 void setNode(NodeImpl *_node) { m_node = _node; }
00082
00083 void setChanged();
00084
00085 void removeCSSHints();
00086
00087 protected:
00088 DOMString getShortHandValue( const int* properties, int number ) const;
00089 DOMString get4Values( const int* properties ) const;
00090
00091 QPtrList<CSSProperty> *m_lstValues;
00092 NodeImpl *m_node;
00093
00094 private:
00095
00096 CSSStyleDeclarationImpl(const CSSStyleDeclarationImpl& o);
00097 };
00098
00099 class CSSValueImpl : public StyleBaseImpl
00100 {
00101 public:
00102 CSSValueImpl() : StyleBaseImpl() {}
00103
00104 virtual unsigned short cssValueType() const = 0;
00105
00106 virtual DOM::DOMString cssText() const = 0;
00107
00108 virtual bool isValue() const { return true; }
00109 virtual bool isFontValue() const { return false; }
00110 };
00111
00112 class CSSInheritedValueImpl : public CSSValueImpl
00113 {
00114 public:
00115 CSSInheritedValueImpl() : CSSValueImpl() {}
00116 virtual ~CSSInheritedValueImpl() {}
00117
00118 virtual unsigned short cssValueType() const;
00119 virtual DOM::DOMString cssText() const;
00120 };
00121
00122 class CSSInitialValueImpl : public CSSValueImpl
00123 {
00124 public:
00125 virtual unsigned short cssValueType() const;
00126 virtual DOM::DOMString cssText() const;
00127 };
00128
00129 class CSSValueListImpl : public CSSValueImpl
00130 {
00131 public:
00132 CSSValueListImpl() : CSSValueImpl() {}
00133
00134 virtual ~CSSValueListImpl();
00135
00136 unsigned long length() const { return m_values.count(); }
00137 CSSValueImpl *item ( unsigned long index ) { return m_values.at(index); }
00138
00139 virtual bool isValueList() const { return true; }
00140
00141 virtual unsigned short cssValueType() const;
00142
00143 void append(CSSValueImpl *val);
00144 virtual DOM::DOMString cssText() const;
00145
00146 protected:
00147 QPtrList<CSSValueImpl> m_values;
00148 };
00149
00150
00151 class Counter;
00152 class RGBColor;
00153 class Rect;
00154
00155 class CSSPrimitiveValueImpl : public CSSValueImpl
00156 {
00157 public:
00158 CSSPrimitiveValueImpl();
00159 CSSPrimitiveValueImpl(int ident);
00160 CSSPrimitiveValueImpl(double num, CSSPrimitiveValue::UnitTypes type);
00161 CSSPrimitiveValueImpl(const DOMString &str, CSSPrimitiveValue::UnitTypes type);
00162 CSSPrimitiveValueImpl(const Counter &c);
00163 CSSPrimitiveValueImpl( RectImpl *r);
00164 CSSPrimitiveValueImpl(QRgb color);
00165
00166 virtual ~CSSPrimitiveValueImpl();
00167
00168 void cleanup();
00169
00170 unsigned short primitiveType() const { return m_type; }
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182 int computeLength( khtml::RenderStyle *style, QPaintDeviceMetrics *devMetrics );
00183
00184 double computeLengthFloat( khtml::RenderStyle *style, QPaintDeviceMetrics *devMetrics );
00185
00186
00187 void setPrimitiveType(unsigned short type) { m_type = type; }
00188 void setFloatValue ( unsigned short unitType, double floatValue, int &exceptioncode );
00189 double floatValue ( unsigned short) const { return m_value.num; }
00190
00191 void setStringValue ( unsigned short stringType, const DOM::DOMString &stringValue, int &exceptioncode );
00192 DOM::DOMStringImpl *getStringValue () const {
00193 return ( ( m_type < CSSPrimitiveValue::CSS_STRING ||
00194 m_type > CSSPrimitiveValue::CSS_ATTR ||
00195 m_type == CSSPrimitiveValue::CSS_IDENT ) ?
00196 0 : m_value.string );
00197 }
00198 CounterImpl *getCounterValue () const {
00199 return ( m_type != CSSPrimitiveValue::CSS_COUNTER ? 0 : m_value.counter );
00200 }
00201
00202 RectImpl *getRectValue () const {
00203 return ( m_type != CSSPrimitiveValue::CSS_RECT ? 0 : m_value.rect );
00204 }
00205
00206 QRgb getRGBColorValue () const {
00207 return ( m_type != CSSPrimitiveValue::CSS_RGBCOLOR ? 0 : m_value.rgbcolor );
00208 }
00209
00210 virtual bool isPrimitiveValue() const { return true; }
00211 virtual unsigned short cssValueType() const;
00212
00213 int getIdent();
00214
00215 virtual bool parseString( const DOMString &string, bool = false);
00216 virtual DOM::DOMString cssText() const;
00217
00218 virtual bool isQuirkValue() const { return false; }
00219
00220 protected:
00221 int m_type;
00222 union {
00223 int ident;
00224 double num;
00225 DOM::DOMStringImpl *string;
00226 CounterImpl *counter;
00227 RectImpl *rect;
00228 QRgb rgbcolor;
00229 } m_value;
00230 };
00231
00232
00233
00234
00235
00236 class CSSQuirkPrimitiveValueImpl : public CSSPrimitiveValueImpl
00237 {
00238 public:
00239 CSSQuirkPrimitiveValueImpl(double num, CSSPrimitiveValue::UnitTypes type)
00240 :CSSPrimitiveValueImpl(num, type) {}
00241
00242 virtual ~CSSQuirkPrimitiveValueImpl() {}
00243
00244 virtual bool isQuirkValue() const { return true; }
00245 };
00246
00247 class CounterImpl : public khtml::Shared<CounterImpl> {
00248 public:
00249 CounterImpl() { }
00250 DOMString identifier() const { return m_identifier; }
00251 DOMString listStyle() const { return m_listStyle; }
00252 DOMString separator() const { return m_separator; }
00253
00254 DOMString m_identifier;
00255 DOMString m_listStyle;
00256 DOMString m_separator;
00257 };
00258
00259 class RectImpl : public khtml::Shared<RectImpl> {
00260 public:
00261 RectImpl();
00262 ~RectImpl();
00263
00264 CSSPrimitiveValueImpl *top() const { return m_top; }
00265 CSSPrimitiveValueImpl *right() const { return m_right; }
00266 CSSPrimitiveValueImpl *bottom() const { return m_bottom; }
00267 CSSPrimitiveValueImpl *left() const { return m_left; }
00268
00269 void setTop( CSSPrimitiveValueImpl *top );
00270 void setRight( CSSPrimitiveValueImpl *right );
00271 void setBottom( CSSPrimitiveValueImpl *bottom );
00272 void setLeft( CSSPrimitiveValueImpl *left );
00273 protected:
00274 CSSPrimitiveValueImpl *m_top;
00275 CSSPrimitiveValueImpl *m_right;
00276 CSSPrimitiveValueImpl *m_bottom;
00277 CSSPrimitiveValueImpl *m_left;
00278 };
00279
00280 class CSSImageValueImpl : public CSSPrimitiveValueImpl, public khtml::CachedObjectClient
00281 {
00282 public:
00283 CSSImageValueImpl(const DOMString &url, const StyleBaseImpl *style);
00284 CSSImageValueImpl();
00285 virtual ~CSSImageValueImpl();
00286
00287 khtml::CachedImage *image() { return m_image; }
00288 protected:
00289 khtml::CachedImage *m_image;
00290 };
00291
00292 class FontFamilyValueImpl : public CSSPrimitiveValueImpl
00293 {
00294 public:
00295 FontFamilyValueImpl( const QString &string);
00296 const QString &fontName() const { return parsedFontName; }
00297 int genericFamilyType() const { return _genericFamilyType; }
00298 protected:
00299 QString parsedFontName;
00300 private:
00301 int _genericFamilyType;
00302 };
00303
00304 class FontValueImpl : public CSSValueImpl
00305 {
00306 public:
00307 FontValueImpl();
00308 virtual ~FontValueImpl();
00309
00310 virtual unsigned short cssValueType() const { return CSSValue::CSS_CUSTOM; }
00311
00312 virtual DOM::DOMString cssText() const;
00313
00314 virtual bool isFontValue() const { return true; }
00315
00316 CSSPrimitiveValueImpl *style;
00317 CSSPrimitiveValueImpl *variant;
00318 CSSPrimitiveValueImpl *weight;
00319 CSSPrimitiveValueImpl *size;
00320 CSSPrimitiveValueImpl *lineHeight;
00321 CSSValueListImpl *family;
00322 };
00323
00324
00325
00326
00327 class CSSProperty
00328 {
00329 public:
00330 CSSProperty()
00331 {
00332 m_id = -1;
00333 m_bImportant = false;
00334 nonCSSHint = false;
00335 m_value = 0;
00336 }
00337 CSSProperty(const CSSProperty& o)
00338 {
00339 m_id = o.m_id;
00340 m_bImportant = o.m_bImportant;
00341 nonCSSHint = o.nonCSSHint;
00342 m_value = o.m_value;
00343 if (m_value) m_value->ref();
00344 }
00345 ~CSSProperty() {
00346 if(m_value) m_value->deref();
00347 }
00348
00349 void setValue(CSSValueImpl *val) {
00350 if ( val != m_value ) {
00351 if(m_value) m_value->deref();
00352 m_value = val;
00353 if(m_value) m_value->ref();
00354 }
00355 }
00356
00357 CSSValueImpl *value() const { return m_value; }
00358
00359 DOM::DOMString cssText() const;
00360
00361
00362 signed int m_id : 29;
00363 bool m_bImportant : 1;
00364 bool nonCSSHint : 1;
00365 protected:
00366 CSSValueImpl *m_value;
00367 };
00368
00369
00370 }
00371
00372 #endif
This file is part of the documentation for khtml Library Version 3.3.0.