24 #include "dom/dom_exception.h"
25 #include "dom/css_rule.h"
26 #include "dom/dom_doc.h"
28 #include "xml/dom_docimpl.h"
30 #include "html/html_headimpl.h"
32 #include "css/css_stylesheetimpl.h"
33 #include "misc/htmlhashes.h"
39 StyleSheet::StyleSheet()
44 StyleSheet::StyleSheet(
const StyleSheet &other)
50 StyleSheet::StyleSheet(StyleSheetImpl *i)
58 if ( impl != other.impl ) {
59 if(impl) impl->deref();
66 StyleSheet::~StyleSheet()
68 if(impl) impl->deref();
74 return ((StyleSheetImpl *)impl)->type();
80 return ((StyleSheetImpl *)impl)->disabled();
86 ((StyleSheetImpl *)impl)->setDisabled( _disabled );
91 if(!impl)
return Node();
92 return ((StyleSheetImpl *)impl)->ownerNode();
104 return ((StyleSheetImpl *)impl)->href();
110 return ((StyleSheetImpl *)impl)->title();
116 return ((StyleSheetImpl *)impl)->media();
119 bool StyleSheet::isCSSStyleSheet()
const
121 if(!impl)
return false;
122 return ((StyleSheetImpl *)impl)->isCSSStyleSheet();
133 CSSStyleSheet::CSSStyleSheet(
const StyleSheet &other)
135 if (!other.isCSSStyleSheet())
141 CSSStyleSheet::CSSStyleSheet(CSSStyleSheetImpl *impl) :
StyleSheet(impl)
147 StyleSheet::operator = (other);
153 if(!other.handle()->isCSSStyleSheet())
155 if(impl) impl->deref();
158 StyleSheet::operator = (other);
163 CSSStyleSheet::~CSSStyleSheet()
170 return ((CSSStyleSheetImpl *)impl)->ownerRule();
175 if(!impl)
return (CSSRuleListImpl*)0;
176 return ((CSSStyleSheetImpl *)impl)->cssRules();
181 int exceptioncode = 0;
183 unsigned long retval = ((CSSStyleSheetImpl *)impl)->insertRule( rule, index, exceptioncode );
184 if ( exceptioncode >= CSSException::_EXCEPTION_OFFSET )
185 throw CSSException( exceptioncode - CSSException::_EXCEPTION_OFFSET );
193 int exceptioncode = 0;
195 ((CSSStyleSheetImpl *)impl)->deleteRule( index, exceptioncode );
196 if ( exceptioncode >= CSSException::_EXCEPTION_OFFSET )
197 throw CSSException( exceptioncode - CSSException::_EXCEPTION_OFFSET );
204 StyleSheetList::StyleSheetList()
212 if(impl) impl->ref();
215 StyleSheetList::StyleSheetList(StyleSheetListImpl *i)
218 if(impl) impl->ref();
223 if ( impl != other.impl ) {
224 if(impl) impl->deref();
226 if(impl) impl->ref();
231 StyleSheetList::~StyleSheetList()
233 if(impl) impl->deref();
239 return ((StyleSheetListImpl *)impl)->length();
245 return ((StyleSheetListImpl *)impl)->item( index );
248 StyleSheetListImpl *StyleSheetList::handle()
const
253 bool StyleSheetList::isNull()
const
260 MediaList::MediaList()
265 MediaList::MediaList(
const MediaList &other)
268 if(impl) impl->ref();
271 MediaList::MediaList(MediaListImpl *i)
274 if(impl) impl->ref();
279 if ( impl != other.impl ) {
280 if(impl) impl->deref();
282 if(impl) impl->ref();
287 MediaList::~MediaList()
289 if(impl) impl->deref();
295 return static_cast<MediaListImpl *
>(impl)->
mediaText();
301 static_cast<MediaListImpl *
>(impl)->
setMediaText( value );
307 return ((MediaListImpl *)impl)->length();
313 return ((MediaListImpl *)impl)->item( index );
319 ((MediaListImpl *)impl)->deleteMedium( oldMedium );
325 ((MediaListImpl *)impl)->appendMedium( newMedium );
328 MediaListImpl *MediaList::handle()
const
333 bool MediaList::isNull()
const
340 LinkStyle::LinkStyle()
345 LinkStyle::LinkStyle(
const LinkStyle &other)
348 if(node) node->ref();
351 LinkStyle & LinkStyle::operator = (
const LinkStyle &other)
353 if ( node != other.node ) {
354 if(node) node->deref();
356 if(node) node->ref();
361 LinkStyle & LinkStyle::operator = (
const Node &other)
363 if(node) node->deref();
366 NodeImpl *n = other.handle();
369 if( n && n->isElementNode() &&
370 (n->id() == ID_STYLE || n->id() == ID_LINK) ) {
372 if(node) node->ref();
377 LinkStyle::~LinkStyle()
379 if(node) node->deref();
384 int id = node ? node->id() : 0;
388 static_cast<HTMLStyleElementImpl *
>(node)->sheet()
389 : ( (
id == ID_LINK) ?
390 static_cast<HTMLLinkElementImpl *>(node)->sheet()
394 bool LinkStyle::isNull()
const
402 DocumentStyle::DocumentStyle()
407 DocumentStyle::DocumentStyle(
const DocumentStyle &other)
413 DocumentStyle & DocumentStyle::operator = (
const DocumentStyle &other)
415 if ( doc != other.doc ) {
416 if(doc) doc->deref();
423 DocumentStyle & DocumentStyle::operator = (
const Document &other)
425 DocumentImpl *odoc =
static_cast<DocumentImpl *
>(other.handle());
427 if(doc) doc->deref();
434 DocumentStyle::~DocumentStyle()
436 if(doc) doc->deref();
441 return doc->styleSheets();
444 DOMString DocumentStyle::preferredStylesheetSet()
const
446 return doc->preferredStylesheetSet();
449 void DocumentStyle::setSelectedStylesheetSet(
const DOMString& aStr)
451 return doc->setSelectedStylesheetSet(aStr);
454 DOMString DocumentStyle::selectedStylesheetSet()
const
456 return doc->selectedStylesheetSet();
DOM::DOMString href() const
If the style sheet is a linked style sheet, the value of its attribute is its location.
The Node interface is the primary datatype for the entire Document Object Model.
StyleSheet parentStyleSheet() const
For style sheet languages that support the concept of style sheet inclusion, this attribute represent...
bool disabled() const
false if the style sheet is applied to the document.
CSSRuleList cssRules() const
The list of all CSS rules contained within the style sheet.
CSSRule ownerRule() const
If this style sheet comes from an @import rule, the ownerRule attribute will contain the CSSImportRul...
DOM operations only raise exceptions in "exceptional" circumstances, i.e., when an operation is impos...
unsigned long insertRule(const DOM::DOMString &rule, unsigned long index)
Used to insert a new rule into the style sheet.
The CSSStyleSheet interface is a concrete interface used to represent a CSS style sheet i...
void setDisabled(bool)
see disabled
MediaList media() const
The intended destination media for style information.
DOM::DOMString title() const
The advisory title.
The StyleSheetList interface provides the abstraction of an ordered collection of style sheets...
This class implements the basic string we use in the DOM.
The Document interface represents the entire HTML or XML document.
void deleteRule(unsigned long index)
Used to delete a rule from the style sheet.
The CSSRuleList interface provides the abstraction of an ordered collection of CSS rules...
The StyleSheet interface is the abstract base interface for any type of style sheet.
DOM::DOMString type() const
This specifies the style sheet language for this style sheet.
unsigned long length() const
The number of StyleSheet in the list.
The CSSRule interface is the abstract base interface for any type of CSS statement ...
StyleSheet item(unsigned long index)
Used to retrieve a style sheet by ordinal index.
DOM::Node ownerNode() const
The node that associates this style sheet with the document.
This exception is raised when a specific CSS operation is impossible to perform.