• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdelibs-4.14.38 API Reference
  • KDE Home
  • Contact Us
 

KHTML

  • khtml
  • dom
css_stylesheet.cpp
Go to the documentation of this file.
1
24#include "dom/dom_exception.h"
25#include "dom/css_rule.h"
26#include "dom/dom_doc.h"
27
28#include "xml/dom_docimpl.h"
29
30#include "html/html_headimpl.h"
31
32#include "css/css_stylesheetimpl.h"
33
34#include <stdio.h>
35
36using namespace DOM;
37
38StyleSheet::StyleSheet()
39{
40 impl = 0;
41}
42
43StyleSheet::StyleSheet(const StyleSheet &other)
44{
45 impl = other.impl;
46 if(impl) impl->ref();
47}
48
49StyleSheet::StyleSheet(StyleSheetImpl *i)
50{
51 impl = i;
52 if(impl) impl->ref();
53}
54
55StyleSheet &StyleSheet::operator = (const StyleSheet &other)
56{
57 if ( impl != other.impl ) {
58 if(impl) impl->deref();
59 impl = other.impl;
60 if(impl) impl->ref();
61 }
62 return *this;
63}
64
65StyleSheet::~StyleSheet()
66{
67 if(impl) impl->deref();
68}
69
70DOMString StyleSheet::type() const
71{
72 if(!impl) return DOMString();
73 return ((StyleSheetImpl *)impl)->type();
74}
75
76bool StyleSheet::disabled() const
77{
78 if(!impl) return 0;
79 return ((StyleSheetImpl *)impl)->disabled();
80}
81
82void StyleSheet::setDisabled( bool _disabled )
83{
84 if(impl)
85 ((StyleSheetImpl *)impl)->setDisabled( _disabled );
86}
87
88DOM::Node StyleSheet::ownerNode() const
89{
90 if(!impl) return Node();
91 return ((StyleSheetImpl *)impl)->ownerNode();
92}
93
94StyleSheet StyleSheet::parentStyleSheet() const
95{
96 if(!impl) return 0;
97 return ((StyleSheetImpl *)impl)->parentStyleSheet();
98}
99
100DOMString StyleSheet::href() const
101{
102 if(!impl) return DOMString();
103 return ((StyleSheetImpl *)impl)->href();
104}
105
106DOMString StyleSheet::title() const
107{
108 if(!impl) return DOMString();
109 return ((StyleSheetImpl *)impl)->title();
110}
111
112MediaList StyleSheet::media() const
113{
114 if(!impl) return 0;
115 return ((StyleSheetImpl *)impl)->media();
116}
117
118bool StyleSheet::isCSSStyleSheet() const
119{
120 if(!impl) return false;
121 return ((StyleSheetImpl *)impl)->isCSSStyleSheet();
122}
123
124KUrl StyleSheet::baseUrl() {
125 if(!impl) return KUrl();
126 return ((StyleSheetImpl *)impl)->baseURL();
127}
128
129DOMString CSSException::codeAsString() const
130{
131 return codeAsString(code);
132}
133
134bool CSSException::isCSSExceptionCode(int exceptioncode)
135{
136 return exceptioncode >= _EXCEPTION_OFFSET && exceptioncode < _EXCEPTION_MAX;
137}
138
139DOMString CSSException::codeAsString(int code)
140{
141 switch ( code ) {
142 case SYNTAX_ERR:
143 return DOMString( "SYNTAX_ERR" );
144 case INVALID_MODIFICATION_ERR:
145 return DOMString( "INVALID_MODIFICATION_ERR" );
146 default:
147 return DOMString( "(unknown exception code)" );
148 }
149}
150
151CSSStyleSheet::CSSStyleSheet() : StyleSheet()
152{
153}
154
155CSSStyleSheet::CSSStyleSheet(const CSSStyleSheet &other) : StyleSheet(other)
156{
157}
158
159CSSStyleSheet::CSSStyleSheet(const StyleSheet &other)
160{
161 if (!other.isCSSStyleSheet())
162 impl = 0;
163 else
164 operator=(other);
165}
166
167CSSStyleSheet::CSSStyleSheet(CSSStyleSheetImpl *impl) : StyleSheet(impl)
168{
169}
170
171CSSStyleSheet &CSSStyleSheet::operator = (const CSSStyleSheet &other)
172{
173 StyleSheet::operator = (other);
174 return *this;
175}
176
177CSSStyleSheet &CSSStyleSheet::operator = (const StyleSheet &other)
178{
179 if(!other.handle()->isCSSStyleSheet())
180 {
181 if(impl) impl->deref();
182 impl = 0;
183 } else {
184 StyleSheet::operator = (other);
185 }
186 return *this;
187}
188
189CSSStyleSheet::~CSSStyleSheet()
190{
191}
192
193CSSRule CSSStyleSheet::ownerRule() const
194{
195 if(!impl) return 0;
196 return ((CSSStyleSheetImpl *)impl)->ownerRule();
197}
198
199CSSRuleList CSSStyleSheet::cssRules() const
200{
201 if(!impl) return (CSSRuleListImpl*)0;
202 return ((CSSStyleSheetImpl *)impl)->cssRules();
203}
204
205unsigned long CSSStyleSheet::insertRule( const DOMString &rule, unsigned long index )
206{
207 int exceptioncode = 0;
208 if(!impl) return 0;
209 unsigned long retval = ((CSSStyleSheetImpl *)impl)->insertRule( rule, index, exceptioncode );
210 if ( exceptioncode >= CSSException::_EXCEPTION_OFFSET )
211 throw CSSException( exceptioncode - CSSException::_EXCEPTION_OFFSET );
212 if ( exceptioncode )
213 throw DOMException( exceptioncode );
214 return retval;
215}
216
217void CSSStyleSheet::deleteRule( unsigned long index )
218{
219 int exceptioncode = 0;
220 if(impl)
221 ((CSSStyleSheetImpl *)impl)->deleteRule( index, exceptioncode );
222 if ( exceptioncode >= CSSException::_EXCEPTION_OFFSET )
223 throw CSSException( exceptioncode - CSSException::_EXCEPTION_OFFSET );
224 if ( exceptioncode )
225 throw DOMException( exceptioncode );
226}
227
228DOM::DOMString CSSStyleSheet::charset() const {
229 if(!impl) return DOMString();
230 return static_cast<CSSStyleSheetImpl *>(impl)->charset();
231}
232
233
234StyleSheetList::StyleSheetList()
235{
236 impl = 0;
237}
238
239StyleSheetList::StyleSheetList(const StyleSheetList &other)
240{
241 impl = other.impl;
242 if(impl) impl->ref();
243}
244
245StyleSheetList::StyleSheetList(StyleSheetListImpl *i)
246{
247 impl = i;
248 if(impl) impl->ref();
249}
250
251StyleSheetList &StyleSheetList::operator = (const StyleSheetList &other)
252{
253 if ( impl != other.impl ) {
254 if(impl) impl->deref();
255 impl = other.impl;
256 if(impl) impl->ref();
257 }
258 return *this;
259}
260
261StyleSheetList::~StyleSheetList()
262{
263 if(impl) impl->deref();
264}
265
266unsigned long StyleSheetList::length() const
267{
268 if(!impl) return 0;
269 return ((StyleSheetListImpl *)impl)->length();
270}
271
272StyleSheet StyleSheetList::item( unsigned long index )
273{
274 if(!impl) return StyleSheet();
275 return ((StyleSheetListImpl *)impl)->item( index );
276}
277
278StyleSheetListImpl *StyleSheetList::handle() const
279{
280 return impl;
281}
282
283bool StyleSheetList::isNull() const
284{
285 return (impl == 0);
286}
287
288// ----------------------------------------------------------
289
290MediaList::MediaList()
291{
292 impl = 0;
293}
294
295MediaList::MediaList(const MediaList &other)
296{
297 impl = other.impl;
298 if(impl) impl->ref();
299}
300
301MediaList::MediaList(MediaListImpl *i)
302{
303 impl = i;
304 if(impl) impl->ref();
305}
306
307MediaList &MediaList::operator = (const MediaList &other)
308{
309 if ( impl != other.impl ) {
310 if(impl) impl->deref();
311 impl = other.impl;
312 if(impl) impl->ref();
313 }
314 return *this;
315}
316
317MediaList::~MediaList()
318{
319 if(impl) impl->deref();
320}
321
322DOM::DOMString MediaList::mediaText() const
323{
324 if(!impl) return DOMString();
325 return static_cast<MediaListImpl *>(impl)->mediaText();
326}
327
328void MediaList::setMediaText(const DOM::DOMString &value )
329{
330 if(!impl)
331 return;
332 int exceptioncode = 0;
333 static_cast<MediaListImpl *>(impl)->setMediaText( value, exceptioncode );
334 if ( exceptioncode )
335 throw DOMException( exceptioncode );
336}
337
338unsigned long MediaList::length() const
339{
340 if(!impl) return 0;
341 return ((MediaListImpl *)impl)->length();
342}
343
344DOM::DOMString MediaList::item(unsigned long index) const
345{
346 if(!impl) return DOMString();
347 return ((MediaListImpl *)impl)->item( index );
348}
349
350void MediaList::deleteMedium(const DOM::DOMString &oldMedium)
351{
352 if(!impl)
353 return;
354 int exceptioncode = 0;
355 ((MediaListImpl *)impl)->deleteMedium( oldMedium, exceptioncode );
356 if ( exceptioncode )
357 throw DOMException( exceptioncode );
358}
359
360void MediaList::appendMedium(const DOM::DOMString &newMedium)
361{
362 if(!impl)
363 return;
364 int exceptioncode = 0;
365 ((MediaListImpl *)impl)->appendMedium( newMedium, exceptioncode );
366 if ( exceptioncode )
367 throw DOMException( exceptioncode );
368}
369
370MediaListImpl *MediaList::handle() const
371{
372 return impl;
373}
374
375bool MediaList::isNull() const
376{
377 return (impl == 0);
378}
379
380// ----------------------------------------------------------
381
382LinkStyle::LinkStyle()
383{
384 node = 0;
385}
386
387LinkStyle::LinkStyle(const LinkStyle &other)
388{
389 node = other.node;
390 if(node) node->ref();
391}
392
393LinkStyle & LinkStyle::operator = (const LinkStyle &other)
394{
395 if ( node != other.node ) {
396 if(node) node->deref();
397 node = other.node;
398 if(node) node->ref();
399 }
400 return *this;
401}
402
403LinkStyle & LinkStyle::operator = (const Node &other)
404{
405 if(node) node->deref();
406 node = 0;
407 // ### add processing instructions
408 NodeImpl *n = other.handle();
409
410 // ### check link is really linking a style sheet
411 if( n && n->isElementNode() &&
412 (n->id() == ID_STYLE || n->id() == ID_LINK) ) {
413 node = n;
414 if(node) node->ref();
415 }
416 return *this;
417}
418
419LinkStyle::~LinkStyle()
420{
421 if(node) node->deref();
422}
423
424StyleSheet LinkStyle::sheet()
425{
426 int id = node ? node->id() : 0;
427 // ### add PI
428 return
429 ( id == ID_STYLE) ?
430 static_cast<HTMLStyleElementImpl *>(node)->sheet()
431 : ( (id == ID_LINK) ?
432 static_cast<HTMLLinkElementImpl *>(node)->sheet()
433 : StyleSheet() );
434}
435
436bool LinkStyle::isNull() const
437{
438 return (node == 0);
439}
440
441
442// ----------------------------------------------------------
443
444DocumentStyle::DocumentStyle()
445{
446 doc = 0;
447}
448
449DocumentStyle::DocumentStyle(const DocumentStyle &other)
450{
451 doc = other.doc;
452 if(doc) doc->ref();
453}
454
455DocumentStyle & DocumentStyle::operator = (const DocumentStyle &other)
456{
457 if ( doc != other.doc ) {
458 if(doc) doc->deref();
459 doc = other.doc;
460 if(doc) doc->ref();
461 }
462 return *this;
463}
464
465DocumentStyle & DocumentStyle::operator = (const Document &other)
466{
467 DocumentImpl *odoc = static_cast<DocumentImpl *>(other.handle());
468 if ( doc != odoc ) {
469 if(doc) doc->deref();
470 doc = odoc;
471 if(doc) doc->ref();
472 }
473 return *this;
474}
475
476DocumentStyle::~DocumentStyle()
477{
478 if(doc) doc->deref();
479}
480
481StyleSheetList DocumentStyle::styleSheets() const
482{
483 return doc->styleSheets();
484}
485
486DOMString DocumentStyle::preferredStylesheetSet() const
487{
488 return doc->preferredStylesheetSet();
489}
490
491void DocumentStyle::setSelectedStylesheetSet(const DOMString& aStr)
492{
493 return doc->setSelectedStylesheetSet(aStr);
494}
495
496DOMString DocumentStyle::selectedStylesheetSet() const
497{
498 return doc->selectedStylesheetSet();
499}
DOM::CSSException
This exception is raised when a specific CSS operation is impossible to perform.
Definition: css_stylesheet.h:175
DOM::CSSException::INVALID_MODIFICATION_ERR
@ INVALID_MODIFICATION_ERR
Definition: css_stylesheet.h:193
DOM::CSSException::_EXCEPTION_OFFSET
@ _EXCEPTION_OFFSET
Definition: css_stylesheet.h:194
DOM::CSSException::SYNTAX_ERR
@ SYNTAX_ERR
Definition: css_stylesheet.h:192
DOM::CSSException::_EXCEPTION_MAX
@ _EXCEPTION_MAX
Definition: css_stylesheet.h:195
DOM::CSSException::isCSSExceptionCode
static bool isCSSExceptionCode(int exceptioncode)
Definition: css_stylesheet.cpp:134
DOM::CSSException::code
unsigned short code
An integer indicating the type of error generated.
Definition: css_stylesheet.h:188
DOM::CSSException::codeAsString
DOMString codeAsString() const
Returns the name of this error.
Definition: css_stylesheet.cpp:129
DOM::CSSRuleList
The CSSRuleList interface provides the abstraction of an ordered collection of CSS rules.
Definition: css_rule.h:513
DOM::CSSRule
The CSSRule interface is the abstract base interface for any type of CSS statement .
Definition: css_rule.h:53
DOM::CSSStyleSheet
The CSSStyleSheet interface is a concrete interface used to represent a CSS style sheet i....
Definition: css_stylesheet.h:219
DOM::CSSStyleSheet::ownerRule
CSSRule ownerRule() const
If this style sheet comes from an @import rule, the ownerRule attribute will contain the CSSImportRul...
Definition: css_stylesheet.cpp:193
DOM::CSSStyleSheet::operator=
CSSStyleSheet & operator=(const CSSStyleSheet &other)
Definition: css_stylesheet.cpp:171
DOM::CSSStyleSheet::deleteRule
void deleteRule(unsigned long index)
Used to delete a rule from the style sheet.
Definition: css_stylesheet.cpp:217
DOM::CSSStyleSheet::CSSStyleSheet
CSSStyleSheet()
Definition: css_stylesheet.cpp:151
DOM::CSSStyleSheet::cssRules
CSSRuleList cssRules() const
The list of all CSS rules contained within the style sheet.
Definition: css_stylesheet.cpp:199
DOM::CSSStyleSheet::insertRule
unsigned long insertRule(const DOM::DOMString &rule, unsigned long index)
Used to insert a new rule into the style sheet.
Definition: css_stylesheet.cpp:205
DOM::CSSStyleSheet::charset
DOM::DOMString charset() const
Definition: css_stylesheet.cpp:228
DOM::CSSStyleSheet::~CSSStyleSheet
~CSSStyleSheet()
Definition: css_stylesheet.cpp:189
DOM::DOMException
DOM operations only raise exceptions in "exceptional" circumstances, i.e., when an operation is impos...
Definition: dom_exception.h:59
DOM::DOMString
This class implements the basic string we use in the DOM.
Definition: dom_string.h:44
DOM::DocumentStyle
Definition: css_stylesheet.h:484
DOM::DocumentStyle::setSelectedStylesheetSet
void setSelectedStylesheetSet(const DOMString &aString)
Definition: css_stylesheet.cpp:491
DOM::DocumentStyle::styleSheets
StyleSheetList styleSheets() const
Definition: css_stylesheet.cpp:481
DOM::DocumentStyle::operator=
DocumentStyle & operator=(const DocumentStyle &other)
Definition: css_stylesheet.cpp:455
DOM::DocumentStyle::selectedStylesheetSet
DOMString selectedStylesheetSet() const
Definition: css_stylesheet.cpp:496
DOM::DocumentStyle::preferredStylesheetSet
DOMString preferredStylesheetSet() const
Definition: css_stylesheet.cpp:486
DOM::DocumentStyle::doc
DOM::DocumentImpl * doc
Definition: css_stylesheet.h:503
DOM::DocumentStyle::~DocumentStyle
~DocumentStyle()
Definition: css_stylesheet.cpp:476
DOM::DocumentStyle::DocumentStyle
DocumentStyle()
Definition: css_stylesheet.cpp:444
DOM::Document
The Document interface represents the entire HTML or XML document.
Definition: dom_doc.h:246
DOM::LinkStyle
Definition: css_stylesheet.h:462
DOM::LinkStyle::LinkStyle
LinkStyle()
Definition: css_stylesheet.cpp:382
DOM::LinkStyle::node
DOM::NodeImpl * node
Definition: css_stylesheet.h:477
DOM::LinkStyle::~LinkStyle
~LinkStyle()
Definition: css_stylesheet.cpp:419
DOM::LinkStyle::isNull
bool isNull() const
Definition: css_stylesheet.cpp:436
DOM::LinkStyle::sheet
StyleSheet sheet()
Definition: css_stylesheet.cpp:424
DOM::LinkStyle::operator=
LinkStyle & operator=(const LinkStyle &other)
Definition: css_stylesheet.cpp:393
DOM::MediaList
The MediaList interface provides the abstraction of an ordered collection of media,...
Definition: css_stylesheet.h:378
DOM::MediaList::setMediaText
void setMediaText(const DOM::DOMString &value)
see mediaText
Definition: css_stylesheet.cpp:328
DOM::MediaList::~MediaList
~MediaList()
Definition: css_stylesheet.cpp:317
DOM::MediaList::impl
MediaListImpl * impl
Definition: css_stylesheet.h:456
DOM::MediaList::mediaText
DOM::DOMString mediaText() const
The parsable textual representation of the media list.
Definition: css_stylesheet.cpp:322
DOM::MediaList::operator=
MediaList & operator=(const MediaList &other)
Definition: css_stylesheet.cpp:307
DOM::MediaList::length
unsigned long length() const
The number of media in the list.
Definition: css_stylesheet.cpp:338
DOM::MediaList::appendMedium
void appendMedium(const DOM::DOMString &newMedium)
Adds the medium newMedium to the end of the list.
Definition: css_stylesheet.cpp:360
DOM::MediaList::item
DOM::DOMString item(unsigned long index) const
Returns the indexth in the list.
Definition: css_stylesheet.cpp:344
DOM::MediaList::isNull
bool isNull() const
Definition: css_stylesheet.cpp:375
DOM::MediaList::deleteMedium
void deleteMedium(const DOM::DOMString &oldMedium)
Deletes the medium indicated by oldMedium from the list.
Definition: css_stylesheet.cpp:350
DOM::MediaList::MediaList
MediaList()
Definition: css_stylesheet.cpp:290
DOM::MediaList::handle
MediaListImpl * handle() const
Definition: css_stylesheet.cpp:370
DOM::Node
The Node interface is the primary datatype for the entire Document Object Model.
Definition: dom_node.h:271
DOM::Node::handle
NodeImpl * handle() const
Definition: dom_node.h:925
DOM::StyleSheetList
The StyleSheetList interface provides the abstraction of an ordered collection of style sheets.
Definition: css_stylesheet.h:324
DOM::StyleSheetList::StyleSheetList
StyleSheetList()
Definition: css_stylesheet.cpp:234
DOM::StyleSheetList::operator=
StyleSheetList & operator=(const StyleSheetList &other)
Definition: css_stylesheet.cpp:251
DOM::StyleSheetList::length
unsigned long length() const
The number of StyleSheet in the list.
Definition: css_stylesheet.cpp:266
DOM::StyleSheetList::isNull
bool isNull() const
Definition: css_stylesheet.cpp:283
DOM::StyleSheetList::impl
StyleSheetListImpl * impl
Definition: css_stylesheet.h:362
DOM::StyleSheetList::handle
StyleSheetListImpl * handle() const
Definition: css_stylesheet.cpp:278
DOM::StyleSheetList::~StyleSheetList
~StyleSheetList()
Definition: css_stylesheet.cpp:261
DOM::StyleSheetList::item
StyleSheet item(unsigned long index)
Used to retrieve a style sheet by ordinal index.
Definition: css_stylesheet.cpp:272
DOM::StyleSheet
The StyleSheet interface is the abstract base interface for any type of style sheet.
Definition: css_stylesheet.h:59
DOM::StyleSheet::href
DOM::DOMString href() const
If the style sheet is a linked style sheet, the value of its attribute is its location.
Definition: css_stylesheet.cpp:100
DOM::StyleSheet::media
MediaList media() const
The intended destination media for style information.
Definition: css_stylesheet.cpp:112
DOM::StyleSheet::baseUrl
KUrl baseUrl()
Definition: css_stylesheet.cpp:124
DOM::StyleSheet::isCSSStyleSheet
bool isCSSStyleSheet() const
Definition: css_stylesheet.cpp:118
DOM::StyleSheet::parentStyleSheet
StyleSheet parentStyleSheet() const
For style sheet languages that support the concept of style sheet inclusion, this attribute represent...
Definition: css_stylesheet.cpp:94
DOM::StyleSheet::disabled
bool disabled() const
false if the style sheet is applied to the document.
Definition: css_stylesheet.cpp:76
DOM::StyleSheet::setDisabled
void setDisabled(bool)
see disabled
Definition: css_stylesheet.cpp:82
DOM::StyleSheet::StyleSheet
StyleSheet()
Definition: css_stylesheet.cpp:38
DOM::StyleSheet::title
DOM::DOMString title() const
The advisory title.
Definition: css_stylesheet.cpp:106
DOM::StyleSheet::operator=
StyleSheet & operator=(const StyleSheet &other)
Definition: css_stylesheet.cpp:55
DOM::StyleSheet::type
DOM::DOMString type() const
This specifies the style sheet language for this style sheet.
Definition: css_stylesheet.cpp:70
DOM::StyleSheet::ownerNode
DOM::Node ownerNode() const
The node that associates this style sheet with the document.
Definition: css_stylesheet.cpp:88
DOM::StyleSheet::impl
StyleSheetImpl * impl
Definition: css_stylesheet.h:166
DOM::StyleSheet::~StyleSheet
~StyleSheet()
Definition: css_stylesheet.cpp:65
DOM::StyleSheet::handle
StyleSheetImpl * handle() const
Definition: css_stylesheet.h:163
KUrl
css_rule.h
dom_doc.h
dom_exception.h
DOM
This library provides a full-featured HTML parser and widget.
Definition: design.h:55
rule
The CSSNamespaceRule interface represents an.
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Feb 20 2023 00:00:00 by doxygen 1.9.6 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KHTML

Skip menu "KHTML"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdelibs-4.14.38 API Reference

Skip menu "kdelibs-4.14.38 API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal