File indexing completed on 2024-04-28 15:24:41
0001 /* 0002 Copyright (C) 2004, 2005 Nikolas Zimmermann <wildfox@kde.org> 0003 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org> 0004 Copyright (C) 2006 Apple Computer, Inc. 0005 0006 This file is part of the KDE project 0007 0008 This library is free software; you can redistribute it and/or 0009 modify it under the terms of the GNU Library General Public 0010 License as published by the Free Software Foundation; either 0011 version 2 of the License, or (at your option) any later version. 0012 0013 This library is distributed in the hope that it will be useful, 0014 but WITHOUT ANY WARRANTY; without even the implied warranty of 0015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0016 Library General Public License for more details. 0017 0018 You should have received a copy of the GNU Library General Public License 0019 along with this library; see the file COPYING.LIB. If not, write to 0020 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0021 Boston, MA 02110-1301, USA. 0022 */ 0023 0024 #include "wtf/Platform.h" 0025 #if ENABLE(SVG) 0026 #include "SVGStyleElement.h" 0027 0028 //#include "CSSStyleSheet.h" 0029 #include "Document.h" 0030 #include "ExceptionCode.h" 0031 //#include "HTMLNames.h" 0032 //#include "XMLNames.h" 0033 0034 namespace WebCore 0035 { 0036 0037 //using namespace HTMLNames; 0038 0039 SVGStyleElement::SVGStyleElement(const QualifiedName &tagName, Document *doc) 0040 : SVGElement(tagName, doc) 0041 , m_createdByParser(false) 0042 , m_sheet(nullptr) 0043 { 0044 } 0045 0046 DOMString SVGStyleElement::xmlspace() const 0047 { 0048 // ### shouldn't this provide default? 0049 return getAttribute(ATTR_XML_SPACE); 0050 } 0051 0052 void SVGStyleElement::setXmlspace(const DOMString &, ExceptionCode &ec) 0053 { 0054 ec = DOMException::NO_MODIFICATION_ALLOWED_ERR; 0055 } 0056 0057 const DOMString SVGStyleElement::type() const 0058 { 0059 static const DOMString defaultValue("text/css"); 0060 DOMString n = getAttribute(ATTR_TYPE); 0061 return n.isNull() ? defaultValue : n; 0062 } 0063 0064 void SVGStyleElement::setType(const DOMString &, ExceptionCode &ec) 0065 { 0066 ec = DOMException::NO_MODIFICATION_ALLOWED_ERR; 0067 } 0068 0069 const DOMString SVGStyleElement::media() const 0070 { 0071 static const DOMString defaultValue("all"); 0072 DOMString n = getAttribute(ATTR_MEDIA); 0073 return n.isNull() ? defaultValue : n; 0074 } 0075 0076 void SVGStyleElement::setMedia(const DOMString &, ExceptionCode &ec) 0077 { 0078 ec = DOMException::NO_MODIFICATION_ALLOWED_ERR; 0079 } 0080 0081 String SVGStyleElement::title() const 0082 { 0083 return getAttribute(ATTR_TITLE); 0084 } 0085 0086 void SVGStyleElement::setTitle(const DOMString &, ExceptionCode &ec) 0087 { 0088 ec = DOMException::NO_MODIFICATION_ALLOWED_ERR; 0089 } 0090 0091 void SVGStyleElement::parseMappedAttribute(MappedAttribute *attr) 0092 { 0093 // qCDebug(KHTML_LOG) << "parse: " << attr->id() << attr->localName() << attr->value(); 0094 if (/*attr->name() == titleAttr*/attr->id() == ATTR_TITLE && m_sheet) 0095 ;//FIXME m_sheet->setTitle(attr->value()); 0096 else { 0097 SVGElement::parseMappedAttribute(attr); 0098 } 0099 } 0100 0101 void SVGStyleElement::finishParsingChildren() 0102 { 0103 //StyleElement::sheet(this); 0104 m_createdByParser = false; 0105 SVGElement::finishParsingChildren(); 0106 } 0107 0108 void SVGStyleElement::insertedIntoDocument() 0109 { 0110 SVGElement::insertedIntoDocument(); 0111 0112 /*if (!m_createdByParser) 0113 StyleElement::insertedIntoDocument(document(), this);*/ 0114 // Copy implementation from HTMLStyleElementImpl for KHTML 0115 // qCDebug(KHTML_LOG) << "not implemented"; 0116 } 0117 0118 void SVGStyleElement::removedFromDocument() 0119 { 0120 SVGElement::removedFromDocument(); 0121 /*StyleElement::removedFromDocument(document());*/ 0122 // Copy implementation from HTMLStyleElementImpl for KHTML 0123 // qCDebug(KHTML_LOG) << "not implemented"; 0124 } 0125 0126 void SVGStyleElement::childrenChanged(bool changedByParser, Node *beforeChange, Node *afterChange, int childCountDelta) 0127 { 0128 Q_UNUSED(changedByParser); 0129 Q_UNUSED(beforeChange); 0130 Q_UNUSED(afterChange); 0131 Q_UNUSED(childCountDelta); 0132 //SVGElement::childrenChanged(changedByParser, beforeChange, afterChange, childCountDelta); 0133 SVGElement::childrenChanged(); 0134 /*StyleElement::process(this);*/ 0135 // Copy implementation from HTMLStyleElementImpl for KHTML 0136 // qCDebug(KHTML_LOG) << "not implemented"; 0137 } 0138 0139 StyleSheet *SVGStyleElement::sheet() 0140 { 0141 //return StyleElement::sheet(this); 0142 return m_sheet; 0143 } 0144 0145 bool SVGStyleElement::sheetLoaded() 0146 { 0147 //document()->removePendingSheet(); 0148 document()->styleSheetLoaded(); 0149 return true; 0150 } 0151 0152 // khtml compatibility methods: 0153 quint32 SVGStyleElement::id() const 0154 { 0155 return SVGNames::styleTag.id(); 0156 } 0157 0158 } 0159 0160 #endif // ENABLE(SVG)