css_stylesheet.cpp
#include "dom/dom_exception.h"
#include "dom/css_rule.h"
#include "dom/dom_doc.h"
#include "xml/dom_docimpl.h"
#include "html/html_headimpl.h"
#include "css/css_stylesheetimpl.h"
#include "misc/htmlhashes.h"
#include <stdio.h>
using namespace DOM;
StyleSheet::StyleSheet()
{
impl = 0;
}
StyleSheet::StyleSheet(const StyleSheet &other)
{
impl = other.impl;
if(impl) impl->ref();
}
StyleSheet::StyleSheet(StyleSheetImpl *i)
{
impl = i;
if(impl) impl->ref();
}
StyleSheet &StyleSheet::operator = (const StyleSheet &other)
{
if ( impl != other.impl ) {
if(impl) impl->deref();
impl = other.impl;
if(impl) impl->ref();
}
return *this;
}
StyleSheet::~StyleSheet()
{
if(impl) impl->deref();
}
DOMString StyleSheet::type() const
{
if(!impl) return DOMString();
return ((StyleSheetImpl *)impl)->type();
}
bool StyleSheet::disabled() const
{
if(!impl) return 0;
return ((StyleSheetImpl *)impl)->disabled();
}
void StyleSheet::setDisabled( bool _disabled )
{
if(impl)
((StyleSheetImpl *)impl)->setDisabled( _disabled );
}
DOM::Node StyleSheet::ownerNode() const
{
if(!impl) return Node();
return ((StyleSheetImpl *)impl)->ownerNode();
}
StyleSheet StyleSheet::parentStyleSheet() const
{
if(!impl) return 0;
return ((StyleSheetImpl *)impl)->parentStyleSheet();
}
DOMString StyleSheet::href() const
{
if(!impl) return DOMString();
return ((StyleSheetImpl *)impl)->href();
}
DOMString StyleSheet::title() const
{
if(!impl) return DOMString();
return ((StyleSheetImpl *)impl)->title();
}
MediaList StyleSheet::media() const
{
if(!impl) return 0;
return ((StyleSheetImpl *)impl)->media();
}
bool StyleSheet::isCSSStyleSheet() const
{
if(!impl) return false;
return ((StyleSheetImpl *)impl)->isCSSStyleSheet();
}
CSSStyleSheet::CSSStyleSheet() : StyleSheet()
{
}
CSSStyleSheet::CSSStyleSheet(const CSSStyleSheet &other) : StyleSheet(other)
{
}
CSSStyleSheet::CSSStyleSheet(const StyleSheet &other)
{
if (!other.isCSSStyleSheet())
impl = 0;
else
operator=(other);
}
CSSStyleSheet::CSSStyleSheet(CSSStyleSheetImpl *impl) : StyleSheet(impl)
{
}
CSSStyleSheet &CSSStyleSheet::operator = (const CSSStyleSheet &other)
{
StyleSheet::operator = (other);
return *this;
}
CSSStyleSheet &CSSStyleSheet::operator = (const StyleSheet &other)
{
if(!other.handle()->isCSSStyleSheet())
{
if(impl) impl->deref();
impl = 0;
} else {
StyleSheet::operator = (other);
}
return *this;
}
CSSStyleSheet::~CSSStyleSheet()
{
}
CSSRule CSSStyleSheet::ownerRule() const
{
if(!impl) return 0;
return ((CSSStyleSheetImpl *)impl)->ownerRule();
}
CSSRuleList CSSStyleSheet::cssRules() const
{
if(!impl) return (CSSRuleListImpl*)0;
return ((CSSStyleSheetImpl *)impl)->cssRules();
}
unsigned long CSSStyleSheet::insertRule( const DOMString &rule, unsigned long index )
{
int exceptioncode = 0;
if(!impl) return 0;
unsigned long retval = ((CSSStyleSheetImpl *)impl)->insertRule( rule, index, exceptioncode );
if ( exceptioncode >= CSSException::_EXCEPTION_OFFSET )
throw CSSException( exceptioncode - CSSException::_EXCEPTION_OFFSET );
if ( exceptioncode )
throw DOMException( exceptioncode );
return retval;
}
void CSSStyleSheet::deleteRule( unsigned long index )
{
int exceptioncode = 0;
if(impl)
((CSSStyleSheetImpl *)impl)->deleteRule( index, exceptioncode );
if ( exceptioncode >= CSSException::_EXCEPTION_OFFSET )
throw CSSException( exceptioncode - CSSException::_EXCEPTION_OFFSET );
if ( exceptioncode )
throw DOMException( exceptioncode );
}
StyleSheetList::StyleSheetList()
{
impl = 0;
}
StyleSheetList::StyleSheetList(const StyleSheetList &other)
{
impl = other.impl;
if(impl) impl->ref();
}
StyleSheetList::StyleSheetList(StyleSheetListImpl *i)
{
impl = i;
if(impl) impl->ref();
}
StyleSheetList &StyleSheetList::operator = (const StyleSheetList &other)
{
if ( impl != other.impl ) {
if(impl) impl->deref();
impl = other.impl;
if(impl) impl->ref();
}
return *this;
}
StyleSheetList::~StyleSheetList()
{
if(impl) impl->deref();
}
unsigned long StyleSheetList::length() const
{
if(!impl) return 0;
return ((StyleSheetListImpl *)impl)->length();
}
StyleSheet StyleSheetList::item( unsigned long index )
{
if(!impl) return StyleSheet();
return ((StyleSheetListImpl *)impl)->item( index );
}
StyleSheetListImpl *StyleSheetList::handle() const
{
return impl;
}
bool StyleSheetList::isNull() const
{
return (impl == 0);
}
// ----------------------------------------------------------
MediaList::MediaList()
{
impl = 0;
}
MediaList::MediaList(const MediaList &other)
{
impl = other.impl;
if(impl) impl->ref();
}
MediaList::MediaList(MediaListImpl *i)
{
impl = i;
if(impl) impl->ref();
}
MediaList &MediaList::operator = (const MediaList &other)
{
if ( impl != other.impl ) {
if(impl) impl->deref();
impl = other.impl;
if(impl) impl->ref();
}
return *this;
}
MediaList::~MediaList()
{
if(impl) impl->deref();
}
DOM::DOMString MediaList::mediaText() const
{
if(!impl) return DOMString();
return static_cast<MediaListImpl *>(impl)->mediaText();
}
void MediaList::setMediaText(const DOM::DOMString &value )
{
if(impl)
static_cast<MediaListImpl *>(impl)->setMediaText( value );
}
unsigned long MediaList::length() const
{
if(!impl) return 0;
return ((MediaListImpl *)impl)->length();
}
DOM::DOMString MediaList::item(unsigned long index) const
{
if(!impl) return DOMString();
return ((MediaListImpl *)impl)->item( index );
}
void MediaList::deleteMedium(const DOM::DOMString &oldMedium)
{
if(impl)
((MediaListImpl *)impl)->deleteMedium( oldMedium );
}
void MediaList::appendMedium(const DOM::DOMString &newMedium)
{
if(impl)
((MediaListImpl *)impl)->appendMedium( newMedium );
}
MediaListImpl *MediaList::handle() const
{
return impl;
}
bool MediaList::isNull() const
{
return (impl == 0);
}
// ----------------------------------------------------------
LinkStyle::LinkStyle()
{
node = 0;
}
LinkStyle::LinkStyle(const LinkStyle &other)
{
node = other.node;
if(node) node->ref();
}
LinkStyle & LinkStyle::operator = (const LinkStyle &other)
{
if ( node != other.node ) {
if(node) node->deref();
node = other.node;
if(node) node->ref();
}
return *this;
}
LinkStyle & LinkStyle::operator = (const Node &other)
{
if(node) node->deref();
node = 0;
// ### add processing instructions
NodeImpl *n = other.handle();
// ### check link is really linking a style sheet
if( n && n->isElementNode() &&
(n->id() == ID_STYLE || n->id() == ID_LINK) ) {
node = n;
if(node) node->ref();
}
return *this;
}
LinkStyle::~LinkStyle()
{
if(node) node->deref();
}
StyleSheet LinkStyle::sheet()
{
int id = node ? node->id() : 0;
// ### add PI
return
( id == ID_STYLE) ?
static_cast<HTMLStyleElementImpl *>(node)->sheet()
: ( (id == ID_LINK) ?
static_cast<HTMLLinkElementImpl *>(node)->sheet()
: StyleSheet() );
}
bool LinkStyle::isNull() const
{
return (node == 0);
}
// ----------------------------------------------------------
DocumentStyle::DocumentStyle()
{
doc = 0;
}
DocumentStyle::DocumentStyle(const DocumentStyle &other)
{
doc = other.doc;
if(doc) doc->ref();
}
DocumentStyle & DocumentStyle::operator = (const DocumentStyle &other)
{
if ( doc != other.doc ) {
if(doc) doc->deref();
doc = other.doc;
if(doc) doc->ref();
}
return *this;
}
DocumentStyle & DocumentStyle::operator = (const Document &other)
{
DocumentImpl *odoc = static_cast<DocumentImpl *>(other.handle());
if ( doc != odoc ) {
if(doc) doc->deref();
doc = odoc;
if(doc) doc->ref();
}
return *this;
}
DocumentStyle::~DocumentStyle()
{
if(doc) doc->deref();
}
StyleSheetList DocumentStyle::styleSheets()
{
return doc->styleSheets();
}
DOMString DocumentStyle::preferredStylesheetSet() const
{
return doc->preferredStylesheetSet();
}
void DocumentStyle::setSelectedStylesheetSet(const DOMString& aStr)
{
return doc->setSelectedStylesheetSet(aStr);
}
DOMString DocumentStyle::selectedStylesheetSet() const
{
return doc->selectedStylesheetSet();
}
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:101
DOM::Node
The Node interface is the primary datatype for the entire Document Object Model.
Definition: dom_node.h:274
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:95
DOM::StyleSheet::disabled
bool disabled() const
false if the style sheet is applied to the document.
Definition: css_stylesheet.cpp:77
DOM::CSSStyleSheet::cssRules
CSSRuleList cssRules() const
The list of all CSS rules contained within the style sheet.
Definition: css_stylesheet.cpp:173
DOM::MediaList::setMediaText
void setMediaText(const DOM::DOMString &value)
see mediaText
Definition: css_stylesheet.cpp:298
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:167
DOM::MediaList::item
DOM::DOMString item(unsigned long index) const
Returns the indexth in the list.
Definition: css_stylesheet.cpp:310
DOM::DOMException
DOM operations only raise exceptions in "exceptional" circumstances, i.e., when an operation is impos...
Definition: dom_exception.h:57
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:179
DOM::CSSStyleSheet
The CSSStyleSheet interface is a concrete interface used to represent a CSS style sheet i...
Definition: css_stylesheet.h:207
DOM::StyleSheet::setDisabled
void setDisabled(bool)
see disabled
Definition: css_stylesheet.cpp:83
DOM::StyleSheet::media
MediaList media() const
The intended destination media for style information.
Definition: css_stylesheet.cpp:113
DOM::MediaList
The MediaList interface provides the abstraction of an ordered collection of media, without defining or constraining how this collection is implemented.
Definition: css_stylesheet.h:363
DOM::StyleSheet::title
DOM::DOMString title() const
The advisory title.
Definition: css_stylesheet.cpp:107
DOM::StyleSheetList
The StyleSheetList interface provides the abstraction of an ordered collection of style sheets...
Definition: css_stylesheet.h:309
DOM::MediaList::deleteMedium
void deleteMedium(const DOM::DOMString &oldMedium)
Deletes the medium indicated by oldMedium from the list.
Definition: css_stylesheet.cpp:316
DOM::DOMString
This class implements the basic string we use in the DOM.
Definition: dom_string.h:43
DOM::Document
The Document interface represents the entire HTML or XML document.
Definition: dom_doc.h:245
DOM::MediaList::length
unsigned long length() const
The number of media in the list.
Definition: css_stylesheet.cpp:304
DOM::CSSStyleSheet::deleteRule
void deleteRule(unsigned long index)
Used to delete a rule from the style sheet.
Definition: css_stylesheet.cpp:191
DOM::MediaList::mediaText
DOM::DOMString mediaText() const
The parsable textual representation of the media list.
Definition: css_stylesheet.cpp:292
DOM::MediaList::appendMedium
void appendMedium(const DOM::DOMString &newMedium)
Adds the medium newMedium to the end of the list.
Definition: css_stylesheet.cpp:322
DOM::CSSRuleList
The CSSRuleList interface provides the abstraction of an ordered collection of CSS rules...
Definition: css_rule.h:484
DOM::StyleSheet
The StyleSheet interface is the abstract base interface for any type of style sheet.
Definition: css_stylesheet.h:58
DOM::StyleSheet::type
DOM::DOMString type() const
This specifies the style sheet language for this style sheet.
Definition: css_stylesheet.cpp:71
DOM::StyleSheetList::length
unsigned long length() const
The number of StyleSheet in the list.
Definition: css_stylesheet.cpp:236
DOM::CSSRule
The CSSRule interface is the abstract base interface for any type of CSS statement ...
Definition: css_rule.h:52
DOM::StyleSheetList::item
StyleSheet item(unsigned long index)
Used to retrieve a style sheet by ordinal index.
Definition: css_stylesheet.cpp:242
DOM::StyleSheet::ownerNode
DOM::Node ownerNode() const
The node that associates this style sheet with the document.
Definition: css_stylesheet.cpp:89
DOM::CSSException
This exception is raised when a specific CSS operation is impossible to perform.
Definition: css_stylesheet.h:173

KDE Home | KDE Accessibility Home | Description of Access Keys