KHTML
css_value.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #include "dom/css_rule.h"
00024 #include "dom/dom_exception.h"
00025
00026 #include "css/css_renderstyledeclarationimpl.h"
00027 #include "css/css_valueimpl.h"
00028
00029 namespace DOM {
00030
00031 CSSStyleDeclaration::CSSStyleDeclaration()
00032 {
00033 impl = 0;
00034 }
00035
00036 CSSStyleDeclaration::CSSStyleDeclaration(const CSSStyleDeclaration &other)
00037 {
00038 impl = other.impl;
00039 if(impl) impl->ref();
00040 }
00041
00042 CSSStyleDeclaration::CSSStyleDeclaration(CSSStyleDeclarationImpl *i)
00043 {
00044 impl = i;
00045 if(impl) impl->ref();
00046 }
00047
00048 CSSStyleDeclaration &CSSStyleDeclaration::operator = (const CSSStyleDeclaration &other)
00049 {
00050 if ( impl != other.impl ) {
00051 if(impl) impl->deref();
00052 impl = other.impl;
00053 if(impl) impl->ref();
00054 }
00055 return *this;
00056 }
00057
00058 CSSStyleDeclaration::~CSSStyleDeclaration()
00059 {
00060 if(impl) impl->deref();
00061 }
00062
00063 DOMString CSSStyleDeclaration::cssText() const
00064 {
00065 if(!impl) return DOMString();
00066 return static_cast<CSSStyleDeclarationImpl *>(impl)->cssText();
00067 }
00068
00069 void CSSStyleDeclaration::setCssText( const DOMString &value )
00070 {
00071 if(!impl) return;
00072 impl->setCssText(value);
00073 }
00074
00075 DOMString CSSStyleDeclaration::getPropertyValue( const DOMString &propertyName ) const
00076 {
00077 if(!impl) return DOMString();
00078 return static_cast<CSSStyleDeclarationImpl *>(impl)->getPropertyValue(propertyName);
00079 }
00080
00081 CSSValue CSSStyleDeclaration::getPropertyCSSValue( const DOMString &propertyName ) const
00082 {
00083 if(!impl) return 0;
00084 return static_cast<CSSStyleDeclarationImpl *>(impl)->getPropertyCSSValue(propertyName);
00085 }
00086
00087 DOMString CSSStyleDeclaration::removeProperty( const DOMString &propertyName )
00088 {
00089 if(!impl) return DOMString();
00090 return static_cast<CSSStyleDeclarationImpl *>(impl)->removeProperty(propertyName);
00091 }
00092
00093 DOMString CSSStyleDeclaration::getPropertyPriority( const DOMString &propertyName ) const
00094 {
00095 if(!impl) return DOMString();
00096 return impl->getPropertyPriority(propertyName);
00097 }
00098
00099 void CSSStyleDeclaration::setProperty( const DOMString &propName, const DOMString &value, const DOMString &priority )
00100 {
00101 if(!impl) return;
00102 static_cast<CSSStyleDeclarationImpl *>(impl)->setProperty( propName, value, priority );
00103 }
00104
00105 unsigned long CSSStyleDeclaration::length() const
00106 {
00107 if(!impl) return 0;
00108 return static_cast<CSSStyleDeclarationImpl *>(impl)->length();
00109 }
00110
00111 DOMString CSSStyleDeclaration::item( unsigned long index )
00112 {
00113 return const_cast<const CSSStyleDeclaration*>( this )->item( index );
00114 }
00115
00116 DOMString CSSStyleDeclaration::item( unsigned long index ) const
00117 {
00118 if(!impl) return DOMString();
00119 return static_cast<CSSStyleDeclarationImpl *>(impl)->item( index );
00120 }
00121 CSSRule CSSStyleDeclaration::parentRule() const
00122 {
00123 if(!impl) return 0;
00124 return static_cast<CSSStyleDeclarationImpl *>(impl)->parentRule();
00125 }
00126
00127 CSSStyleDeclarationImpl *CSSStyleDeclaration::handle() const
00128 {
00129 return impl;
00130 }
00131
00132 bool CSSStyleDeclaration::isNull() const
00133 {
00134 return (impl == 0);
00135 }
00136
00137
00138
00139 CSSValue::CSSValue()
00140 {
00141 impl = 0;
00142 }
00143
00144 CSSValue::CSSValue(const CSSValue &other)
00145 {
00146 impl = other.impl;
00147 if(impl) impl->ref();
00148 }
00149
00150 CSSValue::CSSValue(CSSValueImpl *i)
00151 {
00152 impl = i;
00153 if(impl) impl->ref();
00154 }
00155
00156 CSSValue &CSSValue::operator = (const CSSValue &other)
00157 {
00158 if ( impl != other.impl ) {
00159 if(impl) impl->deref();
00160 impl = other.impl;
00161 if(impl) impl->ref();
00162 }
00163 return *this;
00164 }
00165
00166 CSSValue::~CSSValue()
00167 {
00168 if(impl) impl->deref();
00169 }
00170
00171 DOMString CSSValue::cssText() const
00172 {
00173 if(!impl) return DOMString();
00174 return ((CSSValueImpl *)impl)->cssText();
00175 }
00176
00177 void CSSValue::setCssText(const DOMString &value)
00178 {
00179 if(!impl) return;
00180 ((CSSValueImpl *)impl)->setCssText(value);
00181 }
00182
00183 unsigned short CSSValue::cssValueType() const
00184 {
00185 if(!impl) return 0;
00186 return ((CSSValueImpl *)impl)->cssValueType();
00187 }
00188
00189 bool CSSValue::isCSSValueList() const
00190 {
00191 if(!impl) return false;
00192 return ((CSSValueImpl *)impl)->isValueList();
00193 }
00194
00195 bool CSSValue::isCSSPrimitiveValue() const
00196 {
00197 if(!impl) return false;
00198 return ((CSSValueImpl *)impl)->isPrimitiveValue();
00199 }
00200
00201 CSSValueImpl *CSSValue::handle() const
00202 {
00203 return impl;
00204 }
00205
00206 bool CSSValue::isNull() const
00207 {
00208 return (impl == 0);
00209 }
00210
00211
00212
00213 CSSValueList::CSSValueList() : CSSValue()
00214 {
00215 }
00216
00217 CSSValueList::CSSValueList(const CSSValueList &other) : CSSValue(other)
00218 {
00219 }
00220
00221 CSSValueList::CSSValueList(const CSSValue &other)
00222 {
00223 impl = 0;
00224 operator=(other);
00225 }
00226
00227 CSSValueList::CSSValueList(CSSValueListImpl *impl) : CSSValue(impl)
00228 {
00229 }
00230
00231 CSSValueList &CSSValueList::operator = (const CSSValueList &other)
00232 {
00233 if ( impl != other.impl ) {
00234 if (impl) impl->deref();
00235 impl = other.handle();
00236 if (impl) impl->ref();
00237 }
00238 return *this;
00239 }
00240
00241 CSSValueList &CSSValueList::operator = (const CSSValue &other)
00242 {
00243 CSSValueImpl *ohandle = other.handle() ;
00244 if ( impl != ohandle ) {
00245 if (impl) impl->deref();
00246 if (!other.isNull() && !other.isCSSValueList()) {
00247 impl = 0;
00248 } else {
00249 impl = ohandle;
00250 if (impl) impl->ref();
00251 }
00252 }
00253 return *this;
00254 }
00255
00256 CSSValueList::~CSSValueList()
00257 {
00258 }
00259
00260 unsigned long CSSValueList::length() const
00261 {
00262 if(!impl) return 0;
00263 return ((CSSValueListImpl *)impl)->length();
00264 }
00265
00266 CSSValue CSSValueList::item( unsigned long index )
00267 {
00268 if(!impl) return 0;
00269 return ((CSSValueListImpl *)impl)->item( index );
00270 }
00271
00272
00273
00274 CSSPrimitiveValue::CSSPrimitiveValue() : CSSValue()
00275 {
00276 }
00277
00278 CSSPrimitiveValue::CSSPrimitiveValue(const CSSPrimitiveValue &other) : CSSValue(other)
00279 {
00280 }
00281
00282 CSSPrimitiveValue::CSSPrimitiveValue(const CSSValue &other) : CSSValue(other)
00283 {
00284 impl = 0;
00285 operator=(other);
00286 }
00287
00288 CSSPrimitiveValue::CSSPrimitiveValue(CSSPrimitiveValueImpl *impl) : CSSValue(impl)
00289 {
00290 }
00291
00292 CSSPrimitiveValue &CSSPrimitiveValue::operator = (const CSSPrimitiveValue &other)
00293 {
00294 if ( impl != other.impl ) {
00295 if (impl) impl->deref();
00296 impl = other.handle();
00297 if (impl) impl->ref();
00298 }
00299 return *this;
00300 }
00301
00302 CSSPrimitiveValue &CSSPrimitiveValue::operator = (const CSSValue &other)
00303 {
00304 CSSValueImpl *ohandle = other.handle();
00305 if ( impl != ohandle ) {
00306 if (impl) impl->deref();
00307 if (!other.isNull() && !other.isCSSPrimitiveValue()) {
00308 impl = 0;
00309 } else {
00310 impl = ohandle;
00311 if (impl) impl->ref();
00312 }
00313 }
00314 return *this;
00315 }
00316
00317 CSSPrimitiveValue::~CSSPrimitiveValue()
00318 {
00319 }
00320
00321 unsigned short CSSPrimitiveValue::primitiveType() const
00322 {
00323 if(!impl) return 0;
00324 return ((CSSPrimitiveValueImpl *)impl)->primitiveType();
00325 }
00326
00327 void CSSPrimitiveValue::setFloatValue( unsigned short unitType, float floatValue )
00328 {
00329 if(!impl) return;
00330 int exceptioncode = 0;
00331 ((CSSPrimitiveValueImpl *)impl)->setFloatValue( unitType, floatValue, exceptioncode );
00332 if ( exceptioncode >= CSSException::_EXCEPTION_OFFSET )
00333 throw CSSException( exceptioncode - CSSException::_EXCEPTION_OFFSET );
00334 if ( exceptioncode )
00335 throw DOMException( exceptioncode );
00336 }
00337
00338 float CSSPrimitiveValue::getFloatValue( unsigned short unitType ) const
00339 {
00340 if(!impl) return 0;
00341
00342 if(primitiveType() != unitType)
00343 throw CSSException(CSSException::SYNTAX_ERR);
00344 return ((CSSPrimitiveValueImpl *)impl)->floatValue( unitType );
00345 }
00346
00347 void CSSPrimitiveValue::setStringValue( unsigned short stringType, const DOMString &stringValue )
00348 {
00349 int exceptioncode = 0;
00350 if(impl)
00351 ((CSSPrimitiveValueImpl *)impl)->setStringValue( stringType, stringValue, exceptioncode );
00352 if ( exceptioncode >= CSSException::_EXCEPTION_OFFSET )
00353 throw CSSException( exceptioncode - CSSException::_EXCEPTION_OFFSET );
00354 if ( exceptioncode )
00355 throw DOMException( exceptioncode );
00356
00357 }
00358
00359 DOMString CSSPrimitiveValue::getStringValue( ) const
00360 {
00361 if(!impl) return DOMString();
00362 return ((CSSPrimitiveValueImpl *)impl)->getStringValue( );
00363 }
00364
00365 Counter CSSPrimitiveValue::getCounterValue( ) const
00366 {
00367 if(!impl) return Counter();
00368 return ((CSSPrimitiveValueImpl *)impl)->getCounterValue( );
00369 }
00370
00371 Rect CSSPrimitiveValue::getRectValue( ) const
00372 {
00373 if(!impl) return Rect();
00374 return ((CSSPrimitiveValueImpl *)impl)->getRectValue( );
00375 }
00376
00377 RGBColor CSSPrimitiveValue::getRGBColorValue( ) const
00378 {
00379
00380 return RGBColor();
00381
00382
00383 }
00384
00385
00386
00387 Counter::Counter()
00388 {
00389 }
00390
00391 Counter::Counter(const Counter &)
00392 {
00393 impl = 0;
00394 }
00395
00396 Counter &Counter::operator = (const Counter &other)
00397 {
00398 if ( impl != other.impl ) {
00399 if (impl) impl->deref();
00400 impl = other.impl;
00401 if (impl) impl->ref();
00402 }
00403 return *this;
00404 }
00405
00406 Counter::Counter(CounterImpl *i)
00407 {
00408 impl = i;
00409 if (impl) impl->ref();
00410 }
00411
00412 Counter::~Counter()
00413 {
00414 if (impl) impl->deref();
00415 }
00416
00417 DOMString Counter::identifier() const
00418 {
00419 if (!impl) return DOMString();
00420 return impl->identifier();
00421 }
00422
00423 DOMString Counter::listStyle() const
00424 {
00425 if (!impl) return DOMString();
00426 return khtml::stringForListStyleType((khtml::EListStyleType)impl->listStyle());
00427 }
00428
00429 DOMString Counter::separator() const
00430 {
00431 if (!impl) return DOMString();
00432 return impl->separator();
00433 }
00434
00435 CounterImpl *Counter::handle() const
00436 {
00437 return impl;
00438 }
00439
00440 bool Counter::isNull() const
00441 {
00442 return (impl == 0);
00443 }
00444
00445
00446
00447 RGBColor::RGBColor()
00448 {
00449 }
00450
00451 RGBColor::RGBColor(const RGBColor &other)
00452 {
00453 m_color = other.m_color;
00454 }
00455
00456 RGBColor::RGBColor(QRgb color)
00457 {
00458 m_color = color;
00459 }
00460
00461 RGBColor &RGBColor::operator = (const RGBColor &other)
00462 {
00463 m_color = other.m_color;
00464 return *this;
00465 }
00466
00467 RGBColor::~RGBColor()
00468 {
00469 }
00470
00471 CSSPrimitiveValue RGBColor::red() const
00472 {
00473 return new CSSPrimitiveValueImpl(float(qAlpha(m_color) ? qRed(m_color) : 0), CSSPrimitiveValue::CSS_DIMENSION);
00474 }
00475
00476 CSSPrimitiveValue RGBColor::green() const
00477 {
00478 return new CSSPrimitiveValueImpl(float(qAlpha(m_color) ? qGreen(m_color) : 0), CSSPrimitiveValue::CSS_DIMENSION);
00479 }
00480
00481 CSSPrimitiveValue RGBColor::blue() const
00482 {
00483 return new CSSPrimitiveValueImpl(float(qAlpha(m_color) ? qBlue(m_color) : 0), CSSPrimitiveValue::CSS_DIMENSION);
00484 }
00485
00486
00487
00488
00489 Rect::Rect()
00490 {
00491 impl = 0;
00492 }
00493
00494 Rect::Rect(const Rect &other)
00495 {
00496 impl = other.impl;
00497 if (impl) impl->ref();
00498 }
00499
00500 Rect::Rect(RectImpl *i)
00501 {
00502 impl = i;
00503 if (impl) impl->ref();
00504 }
00505
00506 Rect &Rect::operator = (const Rect &other)
00507 {
00508 if ( impl != other.impl ) {
00509 if (impl) impl->deref();
00510 impl = other.impl;
00511 if (impl) impl->ref();
00512 }
00513 return *this;
00514 }
00515
00516 Rect::~Rect()
00517 {
00518 if (impl) impl->deref();
00519 }
00520
00521 CSSPrimitiveValue Rect::top() const
00522 {
00523 if (!impl) return 0;
00524 return impl->top();
00525 }
00526
00527 CSSPrimitiveValue Rect::right() const
00528 {
00529 if (!impl) return 0;
00530 return impl->right();
00531 }
00532
00533 CSSPrimitiveValue Rect::bottom() const
00534 {
00535 if (!impl) return 0;
00536 return impl->bottom();
00537 }
00538
00539 CSSPrimitiveValue Rect::left() const
00540 {
00541 if (!impl) return 0;
00542 return impl->left();
00543 }
00544
00545 RectImpl *Rect::handle() const
00546 {
00547 return impl;
00548 }
00549
00550 bool Rect::isNull() const
00551 {
00552 return (impl == 0);
00553 }
00554
00555 }
00556
00557