2 Copyright (C) 2004 Nikolas Zimmermann <wildfox@kde.org>
3 2004 Rob Buis <buis@kde.org>
5 This file is part of the KDE project
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Library General Public
9 License as published by the Free Software Foundation; either
10 version 2 of the License, or (at your option) any later version.
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Library General Public License for more details.
17 You should have received a copy of the GNU Library General Public License
18 along with this library; see the file COPYING.LIB. If not, write to
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA.
25 #include "CSSHelper.h"
26 #include "CSSRuleList.h"
27 #include "DOMException.h"
28 #include "CSSStyleSheet.h"
29 #include "DOMExceptionImpl.h"
30 #include "CSSStyleSheetImpl.h"
32 #include "kdom/data/CSSConstants.h"
33 #include "CSSStyleSheet.lut.h"
38 @begin CSSStyleSheet::s_hashTable 3
39 ownerRule CSSStyleSheetConstants::OwnerRule DontDelete|ReadOnly
40 cssRules CSSStyleSheetConstants::CssRules DontDelete|ReadOnly
42 @begin CSSStyleSheetProto::s_hashTable 3
43 insertRule CSSStyleSheetConstants::InsertRule DontDelete|Function 2
44 deleteRule CSSStyleSheetConstants::DeleteRule DontDelete|Function 1
48 KDOM_IMPLEMENT_PROTOTYPE("CSSStyleSheet", CSSStyleSheetProto, CSSStyleSheetProtoFunc)
50 Value CSSStyleSheet::getValueProperty(ExecState *exec, int token) const
54 case CSSStyleSheetConstants::OwnerRule:
55 return getDOMCSSRule(exec, ownerRule());
56 case CSSStyleSheetConstants::CssRules:
57 return safe_cache<CSSRuleList>(exec, cssRules());
59 kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl;
65 Value CSSStyleSheetProtoFunc::call(ExecState *exec, Object &thisObj, const List &args)
67 KDOM_CHECK_THIS(CSSStyleSheet)
72 case CSSStyleSheetConstants::InsertRule:
74 DOMString rule = toDOMString(exec, args[0]);
75 unsigned long index = args[1].toUInt32(exec);
76 obj.insertRule(rule, index);
80 kdWarning() << "Unhandled function id in " << k_funcinfo << " : " << id << endl;
83 KDOM_LEAVE_SAFE(DOMException)
88 #define impl (static_cast<CSSStyleSheetImpl *>(d))
90 CSSStyleSheet CSSStyleSheet::null;
92 CSSStyleSheet::CSSStyleSheet() : StyleSheet()
96 CSSStyleSheet::CSSStyleSheet(const CSSStyleSheet &other) : StyleSheet(other)
100 CSSStyleSheet::CSSStyleSheet(const StyleSheet &other)
102 if(!other.isCSSStyleSheet())
108 CSSStyleSheet::CSSStyleSheet(CSSStyleSheetImpl *i) : StyleSheet(i)
112 CSSStyleSheet::~CSSStyleSheet()
116 CSSStyleSheet &CSSStyleSheet::operator=(const CSSStyleSheet &other)
118 StyleSheet::operator=(other);
122 CSSStyleSheet &CSSStyleSheet::operator=(const StyleSheet &other)
124 if(!other.isCSSStyleSheet())
132 StyleSheet::operator=(other);
137 CSSRule CSSStyleSheet::ownerRule() const
140 return CSSRule::null;
142 return CSSRule(impl->ownerRule());
145 CSSRuleList CSSStyleSheet::cssRules() const
148 return CSSRuleList::null;
150 return CSSRuleList(impl->cssRules());
153 unsigned long CSSStyleSheet::insertRule(const DOMString &rule, unsigned long index)
158 return impl->insertRule(rule, index);
161 void CSSStyleSheet::deleteRule(unsigned long index)
164 impl->deleteRule(index);
167 DOMString CSSStyleSheet::type() const
172 void CSSStyleSheet::setCssText(const DOMString &cssText)
175 impl->parseString(cssText);