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 "wtf/Platform.h"
25 #if ENABLE(SVG)
26 #include "SVGStyleElement.h"
27 
28 //#include "CSSStyleSheet.h"
29 #include "Document.h"
30 #include "ExceptionCode.h"
31 //#include "HTMLNames.h"
32 //#include "XMLNames.h"
33 
34 namespace WebCore
35 {
36 
37 //using namespace HTMLNames;
38 
SVGStyleElement(const QualifiedName & tagName,Document * doc)39 SVGStyleElement::SVGStyleElement(const QualifiedName &tagName, Document *doc)
40     : SVGElement(tagName, doc)
41     , m_createdByParser(false)
42     , m_sheet(nullptr)
43 {
44 }
45 
xmlspace() const46 DOMString SVGStyleElement::xmlspace() const
47 {
48     // ### shouldn't this provide default?
49     return getAttribute(ATTR_XML_SPACE);
50 }
51 
setXmlspace(const DOMString &,ExceptionCode & ec)52 void SVGStyleElement::setXmlspace(const DOMString &, ExceptionCode &ec)
53 {
54     ec = DOMException::NO_MODIFICATION_ALLOWED_ERR;
55 }
56 
type() const57 const DOMString SVGStyleElement::type() const
58 {
59     static const DOMString defaultValue("text/css");
60     DOMString n = getAttribute(ATTR_TYPE);
61     return n.isNull() ? defaultValue : n;
62 }
63 
setType(const DOMString &,ExceptionCode & ec)64 void SVGStyleElement::setType(const DOMString &, ExceptionCode &ec)
65 {
66     ec = DOMException::NO_MODIFICATION_ALLOWED_ERR;
67 }
68 
media() const69 const DOMString SVGStyleElement::media() const
70 {
71     static const DOMString defaultValue("all");
72     DOMString n = getAttribute(ATTR_MEDIA);
73     return n.isNull() ? defaultValue : n;
74 }
75 
setMedia(const DOMString &,ExceptionCode & ec)76 void SVGStyleElement::setMedia(const DOMString &, ExceptionCode &ec)
77 {
78     ec = DOMException::NO_MODIFICATION_ALLOWED_ERR;
79 }
80 
title() const81 String SVGStyleElement::title() const
82 {
83     return getAttribute(ATTR_TITLE);
84 }
85 
setTitle(const DOMString &,ExceptionCode & ec)86 void SVGStyleElement::setTitle(const DOMString &, ExceptionCode &ec)
87 {
88     ec = DOMException::NO_MODIFICATION_ALLOWED_ERR;
89 }
90 
parseMappedAttribute(MappedAttribute * attr)91 void SVGStyleElement::parseMappedAttribute(MappedAttribute *attr)
92 {
93     // qCDebug(KHTML_LOG) << "parse: " << attr->id() << attr->localName() << attr->value();
94     if (/*attr->name() == titleAttr*/attr->id() == ATTR_TITLE && m_sheet)
95         ;//FIXME m_sheet->setTitle(attr->value());
96     else {
97         SVGElement::parseMappedAttribute(attr);
98     }
99 }
100 
finishParsingChildren()101 void SVGStyleElement::finishParsingChildren()
102 {
103     //StyleElement::sheet(this);
104     m_createdByParser = false;
105     SVGElement::finishParsingChildren();
106 }
107 
insertedIntoDocument()108 void SVGStyleElement::insertedIntoDocument()
109 {
110     SVGElement::insertedIntoDocument();
111 
112     /*if (!m_createdByParser)
113         StyleElement::insertedIntoDocument(document(), this);*/
114     // Copy implementation from HTMLStyleElementImpl for KHTML
115     // qCDebug(KHTML_LOG) << "not implemented";
116 }
117 
removedFromDocument()118 void SVGStyleElement::removedFromDocument()
119 {
120     SVGElement::removedFromDocument();
121     /*StyleElement::removedFromDocument(document());*/
122     // Copy implementation from HTMLStyleElementImpl for KHTML
123     // qCDebug(KHTML_LOG) << "not implemented";
124 }
125 
childrenChanged(bool changedByParser,Node * beforeChange,Node * afterChange,int childCountDelta)126 void SVGStyleElement::childrenChanged(bool changedByParser, Node *beforeChange, Node *afterChange, int childCountDelta)
127 {
128     Q_UNUSED(changedByParser);
129     Q_UNUSED(beforeChange);
130     Q_UNUSED(afterChange);
131     Q_UNUSED(childCountDelta);
132     //SVGElement::childrenChanged(changedByParser, beforeChange, afterChange, childCountDelta);
133     SVGElement::childrenChanged();
134     /*StyleElement::process(this);*/
135     // Copy implementation from HTMLStyleElementImpl for KHTML
136     // qCDebug(KHTML_LOG) << "not implemented";
137 }
138 
sheet()139 StyleSheet *SVGStyleElement::sheet()
140 {
141     //return StyleElement::sheet(this);
142     return m_sheet;
143 }
144 
sheetLoaded()145 bool SVGStyleElement::sheetLoaded()
146 {
147     //document()->removePendingSheet();
148     document()->styleSheetLoaded();
149     return true;
150 }
151 
152 // khtml compatibility methods:
id() const153 quint32 SVGStyleElement::id() const
154 {
155     return SVGNames::styleTag.id();
156 }
157 
158 }
159 
160 #endif // ENABLE(SVG)
161