• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2     Copyright (C) 2004, 2005 Nikolas Zimmermann <wildfox@kde.org>
3                   2004, 2005, 2006, 2007 Rob Buis <buis@kde.org>
4     Copyright (C) 2006 Apple Computer, Inc.
5 
6     This file is part of the KDE project
7 
8     This library is free software; you can redistribute it and/or
9     modify it under the terms of the GNU Library General Public
10     License as published by the Free Software Foundation; either
11     version 2 of the License, or (at your option) any later version.
12 
13     This library is distributed in the hope that it will be useful,
14     but WITHOUT ANY WARRANTY; without even the implied warranty of
15     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16     Library General Public License for more details.
17 
18     You should have received a copy of the GNU Library General Public License
19     along with this library; see the file COPYING.LIB.  If not, write to
20     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21     Boston, MA 02110-1301, USA.
22 */
23 
24 #include "config.h"
25 
26 #if ENABLE(SVG)
27 #include "SVGStyleElement.h"
28 
29 #include "CSSStyleSheet.h"
30 #include "Document.h"
31 #include "ExceptionCode.h"
32 #include "HTMLNames.h"
33 #include "MappedAttribute.h"
34 #include "XMLNames.h"
35 #include <wtf/StdLibExtras.h>
36 
37 namespace WebCore {
38 
39 using namespace HTMLNames;
40 
SVGStyleElement(const QualifiedName & tagName,Document * doc,bool createdByParser)41 SVGStyleElement::SVGStyleElement(const QualifiedName& tagName, Document* doc, bool createdByParser)
42      : SVGElement(tagName, doc)
43      , m_createdByParser(createdByParser)
44 {
45 }
46 
xmlspace() const47 const AtomicString& SVGStyleElement::xmlspace() const
48 {
49     return getAttribute(XMLNames::spaceAttr);
50 }
51 
setXmlspace(const AtomicString &,ExceptionCode & ec)52 void SVGStyleElement::setXmlspace(const AtomicString&, ExceptionCode& ec)
53 {
54     ec = NO_MODIFICATION_ALLOWED_ERR;
55 }
56 
type() const57 const AtomicString& SVGStyleElement::type() const
58 {
59     DEFINE_STATIC_LOCAL(const AtomicString, defaultValue, ("text/css"));
60     const AtomicString& n = getAttribute(typeAttr);
61     return n.isNull() ? defaultValue : n;
62 }
63 
setType(const AtomicString &,ExceptionCode & ec)64 void SVGStyleElement::setType(const AtomicString&, ExceptionCode& ec)
65 {
66     ec = NO_MODIFICATION_ALLOWED_ERR;
67 }
68 
media() const69 const AtomicString& SVGStyleElement::media() const
70 {
71     DEFINE_STATIC_LOCAL(const AtomicString, defaultValue, ("all"));
72     const AtomicString& n = getAttribute(mediaAttr);
73     return n.isNull() ? defaultValue : n;
74 }
75 
setMedia(const AtomicString &,ExceptionCode & ec)76 void SVGStyleElement::setMedia(const AtomicString&, ExceptionCode& ec)
77 {
78     ec = NO_MODIFICATION_ALLOWED_ERR;
79 }
80 
title() const81 String SVGStyleElement::title() const
82 {
83     return getAttribute(titleAttr);
84 }
85 
setTitle(const AtomicString &,ExceptionCode & ec)86 void SVGStyleElement::setTitle(const AtomicString&, ExceptionCode& ec)
87 {
88     ec = NO_MODIFICATION_ALLOWED_ERR;
89 }
90 
parseMappedAttribute(MappedAttribute * attr)91 void SVGStyleElement::parseMappedAttribute(MappedAttribute* attr)
92 {
93     if (attr->name() == titleAttr && m_sheet)
94         m_sheet->setTitle(attr->value());
95     else
96         SVGElement::parseMappedAttribute(attr);
97 }
98 
finishParsingChildren()99 void SVGStyleElement::finishParsingChildren()
100 {
101     StyleElement::sheet(this);
102     m_createdByParser = false;
103     SVGElement::finishParsingChildren();
104 }
105 
insertedIntoDocument()106 void SVGStyleElement::insertedIntoDocument()
107 {
108     SVGElement::insertedIntoDocument();
109     document()->addStyleSheetCandidateNode(this, m_createdByParser);
110     if (!m_createdByParser)
111         StyleElement::insertedIntoDocument(document(), this);
112 }
113 
removedFromDocument()114 void SVGStyleElement::removedFromDocument()
115 {
116     SVGElement::removedFromDocument();
117     if (document()->renderer())
118         document()->removeStyleSheetCandidateNode(this);
119     StyleElement::removedFromDocument(document());
120 }
121 
childrenChanged(bool changedByParser,Node * beforeChange,Node * afterChange,int childCountDelta)122 void SVGStyleElement::childrenChanged(bool changedByParser, Node* beforeChange, Node* afterChange, int childCountDelta)
123 {
124     SVGElement::childrenChanged(changedByParser, beforeChange, afterChange, childCountDelta);
125     StyleElement::process(this);
126 }
127 
sheet()128 StyleSheet* SVGStyleElement::sheet()
129 {
130     return StyleElement::sheet(this);
131 }
132 
sheetLoaded()133 bool SVGStyleElement::sheetLoaded()
134 {
135     document()->removePendingSheet();
136     return true;
137 }
138 
139 }
140 
141 // vim:ts=4:noet
142 #endif // ENABLE(SVG)
143