📄 css_stylesheet.cpp
字号:
/** * This file is part of the DOM implementation for KDE. * * (C) 1999 Lars Knoll (knoll@kde.org) * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public License * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. * * $Id: css_stylesheet.cpp,v 1.1.1.1 2002/01/16 10:39:55 ymwei Exp $ */#include "render_interface.h"#include "css_stylesheet.h"#include "css_stylesheetimpl.h"#include "css_rule.h"#include "dom_node.h"#include "dom_string.h"#include "htmlhashes.h"#include "html_headimpl.h"#include "dom_docimpl.h"#include "dom_doc.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) impl->deref(); impl = other.impl; if(impl) impl->ref(); return *this;}StyleSheet::~StyleSheet(){ if(impl) impl->deref();}DOMString StyleSheet::type() const{ if(!impl) return 0; 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 0; return ((StyleSheetImpl *)impl)->href();}DOMString StyleSheet::title() const{ if(!impl) return 0; return ((StyleSheetImpl *)impl)->title();}MediaList StyleSheet::media() const{ if(!impl) return 0; return ((StyleSheetImpl *)impl)->media();}CSSStyleSheet::CSSStyleSheet() : StyleSheet(){}CSSStyleSheet::CSSStyleSheet(const CSSStyleSheet &other) : StyleSheet(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; return *this; } 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 ){ if(!impl) return 0; return ((CSSStyleSheetImpl *)impl)->insertRule( rule, index );}void CSSStyleSheet::deleteRule( unsigned long index ){ if(impl) ((CSSStyleSheetImpl *)impl)->deleteRule( index );}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) 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 );}// ----------------------------------------------------------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) impl->deref(); impl = other.impl; if(impl) impl->ref(); return *this;}MediaList::~MediaList(){ if(impl) impl->deref();}DOM::DOMString MediaList::mediaText(){ // ### if(!impl) return 0; //return ((ElementImpl *)impl)->getAttribute("cssText"); return 0;}void MediaList::setMediaText(const DOM::DOMString &/*value*/){ // ### //if(impl) ((ElementImpl *)impl)->setAttribute("cssText", value);}unsigned long MediaList::length(){ if(!impl) return 0; return ((MediaListImpl *)impl)->length();}DOM::DOMString MediaList::item(unsigned long index){ if(!impl) return 0; return ((MediaListImpl *)impl)->item( index );}void MediaList::deleteMedium(const DOM::DOMString &oldMedium){ if(impl) ((MediaListImpl *)impl)->del( oldMedium );}void MediaList::appendMedium(const DOM::DOMString &newMedium){ if(impl) ((MediaListImpl *)impl)->append( newMedium );}// ----------------------------------------------------------LinkStyle::LinkStyle(){ node = 0;}LinkStyle::LinkStyle(const LinkStyle &other){ node = other.node; if(node) node->ref();}LinkStyle & LinkStyle::operator = (const LinkStyle &other){ 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(); if(!n || !n->isElementNode()) return *this; // ### check link is really linking a style sheet if(n->id() != ID_STYLE || n->id() != ID_LINK) return *this; node = n; if(node) node->ref(); return *this;}LinkStyle::~LinkStyle(){ if(node) node->deref();}StyleSheet LinkStyle::sheet(){ if(!node) return StyleSheet(); if(node->id() == ID_STYLE) return static_cast<HTMLStyleElementImpl *>(node)->sheet(); else if(node->id() == ID_LINK) return static_cast<HTMLLinkElementImpl *>(node)->sheet(); // ### add PI return 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) doc->deref(); doc = other.doc; if(doc) doc->ref(); return *this;}DocumentStyle & DocumentStyle::operator = (const Document &other){ if(doc) doc->deref(); doc = static_cast<DocumentImpl *>(other.handle()); if(doc) doc->ref(); return *this;}DocumentStyle::~DocumentStyle(){ if(doc) doc->deref();}StyleSheetList DocumentStyle::styleSheets(){ return doc->styleSheets();}bool DocumentStyle::isNull() const{ return (doc == 0);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -