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.
24 #include "MediaList.h"
25 #include "DOMException.h"
26 #include "CSSMediaRule.h"
27 #include "DOMExceptionImpl.h"
28 #include "CSSMediaRuleImpl.h"
30 #include "kdom/data/CSSConstants.h"
31 #include "CSSMediaRule.lut.h"
36 @begin CSSMediaRule::s_hashTable 3
37 media CSSMediaRuleConstants::Media DontDelete|ReadOnly
38 cssRules CSSMediaRuleConstants::CssRules DontDelete|ReadOnly
40 @begin CSSMediaRuleProto::s_hashTable 3
41 insertRule CSSMediaRuleConstants::InsertRule DontDelete|Function 2
42 deleteRule CSSMediaRuleConstants::DeleteRule DontDelete|Function 1
46 KDOM_IMPLEMENT_PROTOTYPE("CSSMediaRule", CSSMediaRuleProto, CSSMediaRuleProtoFunc)
48 Value CSSMediaRule::getValueProperty(ExecState *exec, int token) const
52 case CSSMediaRuleConstants::Media:
53 return safe_cache<MediaList>(exec, media());
54 case CSSMediaRuleConstants::CssRules:
55 return safe_cache<CSSRuleList>(exec, cssRules());
57 kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl;
63 Value CSSMediaRuleProtoFunc::call(ExecState *exec, Object &thisObj, const List &args)
65 KDOM_CHECK_THIS(CSSMediaRule)
70 case CSSMediaRuleConstants::InsertRule:
72 DOMString rule = toDOMString(exec, args[0]);
73 unsigned long index = args[1].toUInt32(exec);
74 return Number(obj.insertRule(rule, index));
76 case CSSMediaRuleConstants::DeleteRule:
78 unsigned long index = args[0].toUInt32(exec);
79 obj.deleteRule(index);
83 kdWarning() << "Unhandled function id in " << k_funcinfo << " : " << id << endl;
86 KDOM_LEAVE_SAFE(DOMException)
91 #define impl (static_cast<CSSMediaRuleImpl *>(d))
93 CSSMediaRule CSSMediaRule::null;
95 CSSMediaRule::CSSMediaRule() : CSSRule()
99 CSSMediaRule::CSSMediaRule(const CSSMediaRule &other) : CSSRule()
104 CSSMediaRule::CSSMediaRule(const CSSRule &other) : CSSRule()
109 CSSMediaRule::CSSMediaRule(CSSMediaRuleImpl *i) : CSSRule(i)
113 CSSMediaRule::~CSSMediaRule()
117 CSSMediaRule &CSSMediaRule::operator=(const CSSMediaRule &other)
119 CSSRule::operator=(other);
123 KDOM_CSSRULE_DERIVED_ASSIGN_OP(CSSMediaRule, MEDIA_RULE)
125 MediaList CSSMediaRule::media() const
128 return MediaList::null;
130 return MediaList(impl->media());
133 CSSRuleList CSSMediaRule::cssRules() const
136 return CSSRuleList::null;
138 return CSSRuleList(impl->cssRules());
141 unsigned long CSSMediaRule::insertRule(const DOMString &rule, unsigned long index)
146 return impl->insertRule(rule, index);
149 void CSSMediaRule::deleteRule(unsigned long index)
152 return impl->deleteRule(index);