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 DOM::DOMString removeProperty( int propertyID, bool NonCSSHints = false );
00060 bool setProperty ( int propertyId, const DOM::DOMString &value, bool important = false, bool nonCSSHint = false);
00061 void setProperty ( int propertyId, int value, bool important = false, bool nonCSSHint = false);
00062
00063
00064 void setLengthProperty(int id, const DOM::DOMString &value, bool important, bool nonCSSHint = true, bool multiLength = false);
00065
00066
00067 void setProperty ( const DOMString &propertyString);
00068 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 CSSValueImpl *getPropertyCSSValue( int propertyID ) const;
00077 DOMString getPropertyValue( int propertyID ) const;
00078 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 { return CSSValue::CSS_INHERIT; }
00119 virtual DOM::DOMString cssText() const;
00120 };
00121
00122
00123 class CSSValueListImpl : public CSSValueImpl
00124 {
00125 public:
00126 CSSValueListImpl() : CSSValueImpl() {}
00127
00128 virtual ~CSSValueListImpl();
00129
00130 unsigned long length() const { return m_values.count(); }
00131 CSSValueImpl *item ( unsigned long index ) { return m_values.at(index); }
00132
00133 virtual bool isValueList() const { return true; }
00134
00135 virtual unsigned short cssValueType() const;
00136
00137 void append(CSSValueImpl *val);
00138 virtual DOM::DOMString cssText() const;
00139
00140 protected:
00141 QPtrList<CSSValueImpl> m_values;
00142 };
00143
00144
00145 class Counter;
00146 class RGBColor;
00147 class Rect;
00148
00149 class CSSPrimitiveValueImpl : public CSSValueImpl
00150 {
00151 public:
00152 CSSPrimitiveValueImpl();
00153 CSSPrimitiveValueImpl(int ident);
00154 CSSPrimitiveValueImpl(double num, CSSPrimitiveValue::UnitTypes type);
00155 CSSPrimitiveValueImpl(const DOMString &str, CSSPrimitiveValue::UnitTypes type);
00156 CSSPrimitiveValueImpl(const Counter &c);
00157 CSSPrimitiveValueImpl( RectImpl *r);
00158 CSSPrimitiveValueImpl(QRgb color);
00159
00160 virtual ~CSSPrimitiveValueImpl();
00161
00162 void cleanup();
00163
00164 unsigned short primitiveType() const { return m_type; }
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176 int computeLength( khtml::RenderStyle *style, QPaintDeviceMetrics *devMetrics );
00177
00178 double computeLengthFloat( khtml::RenderStyle *style, QPaintDeviceMetrics *devMetrics );
00179
00180
00181 void setPrimitiveType(unsigned short type) { m_type = type; }
00182 void setFloatValue ( unsigned short unitType, double floatValue, int &exceptioncode );
00183 double floatValue ( unsigned short) const { return m_value.num; }
00184
00185 void setStringValue ( unsigned short stringType, const DOM::DOMString &stringValue, int &exceptioncode );
00186 DOM::DOMStringImpl *getStringValue () const {
00187 return ( ( m_type < CSSPrimitiveValue::CSS_STRING ||
00188 m_type > CSSPrimitiveValue::CSS_ATTR ||
00189 m_type == CSSPrimitiveValue::CSS_IDENT ) ?
00190 0 : m_value.string );
00191 }
00192 CounterImpl *getCounterValue () const {
00193 return ( m_type != CSSPrimitiveValue::CSS_COUNTER ? 0 : m_value.counter );
00194 }
00195
00196 RectImpl *getRectValue () const {
00197 return ( m_type != CSSPrimitiveValue::CSS_RECT ? 0 : m_value.rect );
00198 }
00199
00200 QRgb getRGBColorValue () const {
00201 return ( m_type != CSSPrimitiveValue::CSS_RGBCOLOR ? 0 : m_value.rgbcolor );
00202 }
00203
00204 virtual bool isPrimitiveValue() const { return true; }
00205 virtual unsigned short cssValueType() const;
00206
00207 int getIdent();
00208
00209 virtual bool parseString( const DOMString &string, bool = false);
00210 virtual DOM::DOMString cssText() const;
00211
00212 virtual bool isQuirkValue() const { return false; }
00213
00214 protected:
00215 int m_type;
00216 union {
00217 int ident;
00218 double num;
00219 DOM::DOMStringImpl *string;
00220 CounterImpl *counter;
00221 RectImpl *rect;
00222 QRgb rgbcolor;
00223 } m_value;
00224 };
00225
00226
00227
00228
00229
00230 class CSSQuirkPrimitiveValueImpl : public CSSPrimitiveValueImpl
00231 {
00232 public:
00233 CSSQuirkPrimitiveValueImpl(double num, CSSPrimitiveValue::UnitTypes type)
00234 :CSSPrimitiveValueImpl(num, type) {}
00235
00236 virtual ~CSSQuirkPrimitiveValueImpl() {}
00237
00238 virtual bool isQuirkValue() const { return true; }
00239 };
00240
00241 class CounterImpl : public khtml::Shared<CounterImpl> {
00242 public:
00243 CounterImpl() { }
00244 DOMString identifier() const { return m_identifier; }
00245 DOMString listStyle() const { return m_listStyle; }
00246 DOMString separator() const { return m_separator; }
00247
00248 DOMString m_identifier;
00249 DOMString m_listStyle;
00250 DOMString m_separator;
00251 };
00252
00253 class RectImpl : public khtml::Shared<RectImpl> {
00254 public:
00255 RectImpl();
00256 ~RectImpl();
00257
00258 CSSPrimitiveValueImpl *top() const { return m_top; }
00259 CSSPrimitiveValueImpl *right() const { return m_right; }
00260 CSSPrimitiveValueImpl *bottom() const { return m_bottom; }
00261 CSSPrimitiveValueImpl *left() const { return m_left; }
00262
00263 void setTop( CSSPrimitiveValueImpl *top );
00264 void setRight( CSSPrimitiveValueImpl *right );
00265 void setBottom( CSSPrimitiveValueImpl *bottom );
00266 void setLeft( CSSPrimitiveValueImpl *left );
00267 protected:
00268 CSSPrimitiveValueImpl *m_top;
00269 CSSPrimitiveValueImpl *m_right;
00270 CSSPrimitiveValueImpl *m_bottom;
00271 CSSPrimitiveValueImpl *m_left;
00272 };
00273
00274 class CSSImageValueImpl : public CSSPrimitiveValueImpl, public khtml::CachedObjectClient
00275 {
00276 public:
00277 CSSImageValueImpl(const DOMString &url, const StyleBaseImpl *style);
00278 CSSImageValueImpl();
00279 virtual ~CSSImageValueImpl();
00280
00281 khtml::CachedImage *image() { return m_image; }
00282 protected:
00283 khtml::CachedImage *m_image;
00284 };
00285
00286 class FontFamilyValueImpl : public CSSPrimitiveValueImpl
00287 {
00288 public:
00289 FontFamilyValueImpl( const QString &string);
00290 const QString &fontName() const { return parsedFontName; }
00291 int genericFamilyType() const { return _genericFamilyType; }
00292 protected:
00293 QString parsedFontName;
00294 private:
00295 int _genericFamilyType;
00296 };
00297
00298 class FontValueImpl : public CSSValueImpl
00299 {
00300 public:
00301 FontValueImpl();
00302 virtual ~FontValueImpl();
00303
00304 virtual unsigned short cssValueType() const { return CSSValue::CSS_CUSTOM; }
00305
00306 virtual DOM::DOMString cssText() const;
00307
00308 virtual bool isFontValue() const { return true; }
00309
00310 CSSPrimitiveValueImpl *style;
00311 CSSPrimitiveValueImpl *variant;
00312 CSSPrimitiveValueImpl *weight;
00313 CSSPrimitiveValueImpl *size;
00314 CSSPrimitiveValueImpl *lineHeight;
00315 CSSValueListImpl *family;
00316 };
00317
00318
00319
00320
00321 class CSSProperty
00322 {
00323 public:
00324 CSSProperty()
00325 {
00326 m_id = -1;
00327 m_bImportant = false;
00328 nonCSSHint = false;
00329 m_value = 0;
00330 }
00331 CSSProperty(const CSSProperty& o)
00332 {
00333 m_id = o.m_id;
00334 m_bImportant = o.m_bImportant;
00335 nonCSSHint = o.nonCSSHint;
00336 m_value = o.m_value;
00337 if (m_value) m_value->ref();
00338 }
00339 ~CSSProperty() {
00340 if(m_value) m_value->deref();
00341 }
00342
00343 void setValue(CSSValueImpl *val) {
00344 if ( val != m_value ) {
00345 if(m_value) m_value->deref();
00346 m_value = val;
00347 if(m_value) m_value->ref();
00348 }
00349 }
00350
00351 CSSValueImpl *value() const { return m_value; }
00352
00353 DOM::DOMString cssText() const;
00354
00355
00356 signed int m_id : 29;
00357 bool m_bImportant : 1;
00358 bool nonCSSHint : 1;
00359 protected:
00360 CSSValueImpl *m_value;
00361 };
00362
00363
00364 }
00365
00366 #endif
This file is part of the documentation for khtml Library Version 3.2.0.