css_stylesheet.cpp Source File (khtml Library)

| # khtml Library API Documentation
Overview | Class Hierarchy | Classes | Classes (annotated) | Members | Source Files

# css_stylesheet.cpp

    00001
    00023 #include "dom/dom_exception.h"
    00024 #include "dom/css_rule.h"
    00025 #include "dom/dom_doc.h"
    00026
    00027 #include "xml/dom_docimpl.h"
    00028
    00029 #include "html/html_headimpl.h"
    00030
    00031 #include "css/css_stylesheetimpl.h"
    00032 #include "misc/htmlhashes.h"
    00033
    00034 #include <stdio.h>
    00035
    00036 using namespace DOM;
    00037
    00038 StyleSheet::StyleSheet()
    00039 {
    00040     impl = 0;
    00041 }
    00042
    00043 StyleSheet::StyleSheet(const StyleSheet &other)
    00044 {
    00045     impl = other.impl;
    00046     if(impl) impl->ref();
    00047 }
    00048
    00049 StyleSheet::StyleSheet(StyleSheetImpl *i)
    00050 {
    00051     impl = i;
    00052     if(impl) impl->ref();
    00053 }
    00054
    00055 StyleSheet &StyleSheet::operator = (const StyleSheet &other)
    00056 {
    00057     if ( impl != other.impl ) {
    00058         if(impl) impl->deref();
    00059         impl = other.impl;
    00060         if(impl) impl->ref();
    00061     }
    00062     return *this;
    00063 }
    00064
    00065 StyleSheet::~StyleSheet()
    00066 {
    00067     if(impl) impl->deref();
    00068 }
    00069
    00070 DOMString StyleSheet::type() const
    00071 {
    00072     if(!impl) return DOMString();
    00073     return ((StyleSheetImpl *)impl)->type();
    00074 }
    00075
    00076 bool StyleSheet::disabled() const
    00077 {
    00078     if(!impl) return 0;
    00079     return ((StyleSheetImpl *)impl)->disabled();
    00080 }
    00081
    00082 void StyleSheet::setDisabled( bool _disabled )
    00083 {
    00084     if(impl)
    00085         ((StyleSheetImpl *)impl)->setDisabled( _disabled );
    00086 }
    00087
    00088 DOM::Node StyleSheet::ownerNode() const
    00089 {
    00090     if(!impl) return Node();
    00091     return ((StyleSheetImpl *)impl)->ownerNode();
    00092 }
    00093
    00094 StyleSheet StyleSheet::parentStyleSheet() const
    00095 {
    00096     if(!impl) return 0;
    00097     return ((StyleSheetImpl *)impl)->parentStyleSheet();
    00098 }
    00099
    00100 DOMString StyleSheet::href() const
    00101 {
    00102     if(!impl) return DOMString();
    00103     return ((StyleSheetImpl *)impl)->href();
    00104 }
    00105
    00106 DOMString StyleSheet::title() const
    00107 {
    00108     if(!impl) return DOMString();
    00109     return ((StyleSheetImpl *)impl)->title();
    00110 }
    00111
    00112 MediaList StyleSheet::media() const
    00113 {
    00114     if(!impl) return 0;
    00115     return ((StyleSheetImpl *)impl)->media();
    00116 }
    00117
    00118 bool StyleSheet::isCSSStyleSheet() const
    00119 {
    00120     if(!impl) return false;
    00121     return ((StyleSheetImpl *)impl)->isCSSStyleSheet();
    00122 }
    00123
    00124 bool StyleSheet::isNull() const
    00125 {
    00126     return (impl == 0);
    00127 }
    00128
    00129
    00130
    00131 CSSStyleSheet::CSSStyleSheet() : StyleSheet()
    00132 {
    00133 }
    00134
    00135 CSSStyleSheet::CSSStyleSheet(const CSSStyleSheet &other) : StyleSheet(other)
    00136 {
    00137 }
    00138
    00139 CSSStyleSheet::CSSStyleSheet(const StyleSheet &other)
    00140 {
    00141     if (!other.isCSSStyleSheet())
    00142         impl = 0;
    00143     else
    00144         operator=(other);
    00145 }
    00146
    00147 CSSStyleSheet::CSSStyleSheet(CSSStyleSheetImpl *impl) : StyleSheet(impl)
    00148 {
    00149 }
    00150
    00151 CSSStyleSheet &CSSStyleSheet::operator = (const CSSStyleSheet &other)
    00152 {
    00153     StyleSheet::operator = (other);
    00154     return *this;
    00155 }
    00156
    00157 CSSStyleSheet &CSSStyleSheet::operator = (const StyleSheet &other)
    00158 {
    00159     if(!other.handle()->isCSSStyleSheet())
    00160     {
    00161         if(impl) impl->deref();
    00162         impl = 0;
    00163     } else {
    00164     StyleSheet::operator = (other);
    00165     }
    00166     return *this;
    00167 }
    00168
    00169 CSSStyleSheet::~CSSStyleSheet()
    00170 {
    00171 }
    00172
    00173 CSSRule CSSStyleSheet::ownerRule() const
    00174 {
    00175     if(!impl) return 0;
    00176     return ((CSSStyleSheetImpl *)impl)->ownerRule();
    00177 }
    00178
    00179 CSSRuleList CSSStyleSheet::cssRules() const
    00180 {
    00181     if(!impl) return (CSSRuleListImpl*)0;
    00182     return ((CSSStyleSheetImpl *)impl)->cssRules();
    00183 }
    00184
    00185 unsigned long CSSStyleSheet::insertRule( const DOMString &rule, unsigned long index )
    00186 {
    00187     int exceptioncode = 0;
    00188     if(!impl) return 0;
    00189     unsigned long retval = ((CSSStyleSheetImpl *)impl)->insertRule( rule, index, exceptioncode );
    00190     if ( exceptioncode >= CSSException::_EXCEPTION_OFFSET )
    00191         throw CSSException( exceptioncode - CSSException::_EXCEPTION_OFFSET );
    00192     if ( exceptioncode )
    00193         throw DOMException( exceptioncode );
    00194     return retval;
    00195 }
    00196
    00197 void CSSStyleSheet::deleteRule( unsigned long index )
    00198 {
    00199     int exceptioncode = 0;
    00200     if(impl)
    00201         ((CSSStyleSheetImpl *)impl)->deleteRule( index, exceptioncode );
    00202     if ( exceptioncode >= CSSException::_EXCEPTION_OFFSET )
    00203         throw CSSException( exceptioncode - CSSException::_EXCEPTION_OFFSET );
    00204     if ( exceptioncode )
    00205         throw DOMException( exceptioncode );
    00206 }
    00207
    00208
    00209
    00210 StyleSheetList::StyleSheetList()
    00211 {
    00212     impl = 0;
    00213 }
    00214
    00215 StyleSheetList::StyleSheetList(const StyleSheetList &other)
    00216 {
    00217     impl = other.impl;
    00218     if(impl) impl->ref();
    00219 }
    00220
    00221 StyleSheetList::StyleSheetList(StyleSheetListImpl *i)
    00222 {
    00223     impl = i;
    00224     if(impl) impl->ref();
    00225 }
    00226
    00227 StyleSheetList &StyleSheetList::operator = (const StyleSheetList &other)
    00228 {
    00229     if ( impl != other.impl ) {
    00230         if(impl) impl->deref();
    00231         impl = other.impl;
    00232         if(impl) impl->ref();
    00233     }
    00234     return *this;
    00235 }
    00236
    00237 StyleSheetList::~StyleSheetList()
    00238 {
    00239     if(impl) impl->deref();
    00240 }
    00241
    00242 unsigned long StyleSheetList::length() const
    00243 {
    00244     if(!impl) return 0;
    00245     return ((StyleSheetListImpl *)impl)->length();
    00246 }
    00247
    00248 StyleSheet StyleSheetList::item( unsigned long index )
    00249 {
    00250     if(!impl) return StyleSheet();
    00251     return ((StyleSheetListImpl *)impl)->item( index );
    00252 }
    00253
    00254 StyleSheetListImpl *StyleSheetList::handle() const
    00255 {
    00256     return impl;
    00257 }
    00258
    00259 bool StyleSheetList::isNull() const
    00260 {
    00261     return (impl == 0);
    00262 }
    00263
    00264 // ----------------------------------------------------------
    00265
    00266 MediaList::MediaList()
    00267 {
    00268     impl = 0;
    00269 }
    00270
    00271 MediaList::MediaList(const MediaList &other)
    00272 {
    00273     impl = other.impl;
    00274     if(impl) impl->ref();
    00275 }
    00276
    00277 MediaList::MediaList(MediaListImpl *i)
    00278 {
    00279     impl = i;
    00280     if(impl) impl->ref();
    00281 }
    00282
    00283 MediaList &MediaList::operator = (const MediaList &other)
    00284 {
    00285     if ( impl != other.impl ) {
    00286         if(impl) impl->deref();
    00287         impl = other.impl;
    00288         if(impl) impl->ref();
    00289     }
    00290     return *this;
    00291 }
    00292
    00293 MediaList::~MediaList()
    00294 {
    00295     if(impl) impl->deref();
    00296 }
    00297
    00298 DOM::DOMString MediaList::mediaText() const
    00299 {
    00300     if(!impl) return DOMString();
    00301     return static_cast<MediaListImpl *>(impl)->mediaText();
    00302 }
    00303
    00304 void MediaList::setMediaText(const DOM::DOMString &value )
    00305 {
    00306     if(impl)
    00307         static_cast<MediaListImpl *>(impl)->setMediaText( value );
    00308 }
    00309
    00310 unsigned long MediaList::length() const
    00311 {
    00312     if(!impl) return 0;
    00313     return ((MediaListImpl *)impl)->length();
    00314 }
    00315
    00316 DOM::DOMString MediaList::item(unsigned long index) const
    00317 {
    00318     if(!impl) return DOMString();
    00319     return ((MediaListImpl *)impl)->item( index );
    00320 }
    00321
    00322 void MediaList::deleteMedium(const DOM::DOMString &oldMedium)
    00323 {
    00324     if(impl)
    00325         ((MediaListImpl *)impl)->deleteMedium( oldMedium );
    00326 }
    00327
    00328 void MediaList::appendMedium(const DOM::DOMString &newMedium)
    00329 {
    00330     if(impl)
    00331         ((MediaListImpl *)impl)->appendMedium( newMedium );
    00332 }
    00333
    00334 MediaListImpl *MediaList::handle() const
    00335 {
    00336     return impl;
    00337 }
    00338
    00339 bool MediaList::isNull() const
    00340 {
    00341     return (impl == 0);
    00342 }
    00343
    00344 // ----------------------------------------------------------
    00345
    00346 LinkStyle::LinkStyle()
    00347 {
    00348     node = 0;
    00349 }
    00350
    00351 LinkStyle::LinkStyle(const LinkStyle &other)
    00352 {
    00353     node = other.node;
    00354     if(node) node->ref();
    00355 }
    00356
    00357 LinkStyle & LinkStyle::operator = (const LinkStyle &other)
    00358 {
    00359     if ( node != other.node ) {
    00360         if(node) node->deref();
    00361         node = other.node;
    00362         if(node) node->ref();
    00363     }
    00364     return *this;
    00365 }
    00366
    00367 LinkStyle & LinkStyle::operator = (const Node &other)
    00368 {
    00369     if(node) node->deref();
    00370     node = 0;
    00371     // ### add processing instructions
    00372     NodeImpl *n = other.handle();
    00373
    00374     // ### check link is really linking a style sheet
    00375     if( n && n->isElementNode() &&
    00376         (n->id() == ID_STYLE || n->id() == ID_LINK) ) {
    00377     node = n;
    00378     if(node) node->ref();
    00379     }
    00380     return *this;
    00381 }
    00382
    00383 LinkStyle::~LinkStyle()
    00384 {
    00385     if(node) node->deref();
    00386 }
    00387
    00388 StyleSheet LinkStyle::sheet()
    00389 {
    00390     int id = node ? node->id() : 0;
    00391     // ### add PI
    00392     return
    00393         ( id == ID_STYLE) ?
    00394         static_cast<HTMLStyleElementImpl *>(node)->sheet()
    00395         : ( (id == ID_LINK) ?
    00396             static_cast<HTMLLinkElementImpl *>(node)->sheet()
    00397             : StyleSheet() );
    00398 }
    00399
    00400 bool LinkStyle::isNull() const
    00401 {
    00402     return (node == 0);
    00403 }
    00404
    00405
    00406 // ----------------------------------------------------------
    00407
    00408 DocumentStyle::DocumentStyle()
    00409 {
    00410     doc = 0;
    00411 }
    00412
    00413 DocumentStyle::DocumentStyle(const DocumentStyle &other)
    00414 {
    00415     doc = other.doc;
    00416     if(doc) doc->ref();
    00417 }
    00418
    00419 DocumentStyle & DocumentStyle::operator = (const DocumentStyle &other)
    00420 {
    00421     if ( doc != other.doc ) {
    00422         if(doc) doc->deref();
    00423         doc = other.doc;
    00424         if(doc) doc->ref();
    00425     }
    00426     return *this;
    00427 }
    00428
    00429 DocumentStyle & DocumentStyle::operator = (const Document &other)
    00430 {
    00431     DocumentImpl *odoc = static_cast<DocumentImpl *>(other.handle());
    00432     if ( doc != odoc ) {
    00433     if(doc) doc->deref();
    00434         doc = odoc;
    00435     if(doc) doc->ref();
    00436     }
    00437     return *this;
    00438 }
    00439
    00440 DocumentStyle::~DocumentStyle()
    00441 {
    00442     if(doc) doc->deref();
    00443 }
    00444
    00445 StyleSheetList DocumentStyle::styleSheets()
    00446 {
    00447     return doc->styleSheets();
    00448 }
    00449
    00450 bool DocumentStyle::isNull() const
    00451 {
    00452     return (doc == 0);
    00453 }
    00454

This file is part of the documentation for kdelibs Version 3.1.5.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Wed Jan 28 13:33:32 2004 by doxygen 1.3.4 written by Dimitri van Heesch, © 1997-2001