diff options
Diffstat (limited to 'Source/WebCore/svg/SVGStyleElement.cpp')
-rw-r--r-- | Source/WebCore/svg/SVGStyleElement.cpp | 70 |
1 files changed, 21 insertions, 49 deletions
diff --git a/Source/WebCore/svg/SVGStyleElement.cpp b/Source/WebCore/svg/SVGStyleElement.cpp index dcc8699c7..8f8f9ef80 100644 --- a/Source/WebCore/svg/SVGStyleElement.cpp +++ b/Source/WebCore/svg/SVGStyleElement.cpp @@ -21,14 +21,10 @@ */ #include "config.h" - -#if ENABLE(SVG) #include "SVGStyleElement.h" -#include "Attribute.h" #include "CSSStyleSheet.h" #include "Document.h" -#include "ExceptionCode.h" #include "SVGNames.h" #include <wtf/StdLibExtras.h> @@ -37,19 +33,19 @@ namespace WebCore { inline SVGStyleElement::SVGStyleElement(const QualifiedName& tagName, Document& document, bool createdByParser) : SVGElement(tagName, document) , m_styleSheetOwner(document, createdByParser) - , m_svgLoadEventTimer(this, &SVGElement::svgLoadEventTimerFired) + , m_svgLoadEventTimer(*this, &SVGElement::svgLoadEventTimerFired) { ASSERT(hasTagName(SVGNames::styleTag)); } SVGStyleElement::~SVGStyleElement() { - m_styleSheetOwner.clearDocumentData(document(), *this); + m_styleSheetOwner.clearDocumentData(*this); } -PassRefPtr<SVGStyleElement> SVGStyleElement::create(const QualifiedName& tagName, Document& document, bool createdByParser) +Ref<SVGStyleElement> SVGStyleElement::create(const QualifiedName& tagName, Document& document, bool createdByParser) { - return adoptRef(new SVGStyleElement(tagName, document, createdByParser)); + return adoptRef(*new SVGStyleElement(tagName, document, createdByParser)); } bool SVGStyleElement::disabled() const @@ -65,56 +61,35 @@ void SVGStyleElement::setDisabled(bool setDisabled) const AtomicString& SVGStyleElement::type() const { - DEFINE_STATIC_LOCAL(const AtomicString, defaultValue, ("text/css", AtomicString::ConstructFromLiteral)); + static NeverDestroyed<const AtomicString> defaultValue("text/css", AtomicString::ConstructFromLiteral); const AtomicString& n = getAttribute(SVGNames::typeAttr); - return n.isNull() ? defaultValue : n; + return n.isNull() ? defaultValue.get() : n; } -void SVGStyleElement::setType(const AtomicString& type, ExceptionCode&) +void SVGStyleElement::setType(const AtomicString& type) { setAttribute(SVGNames::typeAttr, type); } const AtomicString& SVGStyleElement::media() const { - DEFINE_STATIC_LOCAL(const AtomicString, defaultValue, ("all", AtomicString::ConstructFromLiteral)); - const AtomicString& n = fastGetAttribute(SVGNames::mediaAttr); - return n.isNull() ? defaultValue : n; + static NeverDestroyed<const AtomicString> defaultValue("all", AtomicString::ConstructFromLiteral); + const AtomicString& n = attributeWithoutSynchronization(SVGNames::mediaAttr); + return n.isNull() ? defaultValue.get() : n; } -void SVGStyleElement::setMedia(const AtomicString& media, ExceptionCode&) +void SVGStyleElement::setMedia(const AtomicString& media) { - setAttribute(SVGNames::mediaAttr, media); + setAttributeWithoutSynchronization(SVGNames::mediaAttr, media); } String SVGStyleElement::title() const { - return fastGetAttribute(SVGNames::titleAttr); -} - -void SVGStyleElement::setTitle(const AtomicString& title, ExceptionCode&) -{ - setAttribute(SVGNames::titleAttr, title); -} - -bool SVGStyleElement::isSupportedAttribute(const QualifiedName& attrName) -{ - DEFINE_STATIC_LOCAL(HashSet<QualifiedName>, supportedAttributes, ()); - if (supportedAttributes.isEmpty()) { - SVGLangSpace::addSupportedAttributes(supportedAttributes); - supportedAttributes.add(SVGNames::titleAttr); - supportedAttributes.add(SVGNames::mediaAttr); - supportedAttributes.add(SVGNames::typeAttr); - } - return supportedAttributes.contains<SVGAttributeHashTranslator>(attrName); + return attributeWithoutSynchronization(SVGNames::titleAttr); } void SVGStyleElement::parseAttribute(const QualifiedName& name, const AtomicString& value) { - if (!isSupportedAttribute(name)) { - SVGElement::parseAttribute(name, value); - return; - } if (name == SVGNames::titleAttr) { if (sheet()) sheet()->setTitle(value); @@ -128,10 +103,8 @@ void SVGStyleElement::parseAttribute(const QualifiedName& name, const AtomicStri m_styleSheetOwner.setMedia(value); return; } - if (SVGLangSpace::parseAttribute(name, value)) - return; - ASSERT_NOT_REACHED(); + SVGElement::parseAttribute(name, value); } void SVGStyleElement::finishParsingChildren() @@ -142,17 +115,18 @@ void SVGStyleElement::finishParsingChildren() Node::InsertionNotificationRequest SVGStyleElement::insertedInto(ContainerNode& rootParent) { - SVGElement::insertedInto(rootParent); - if (rootParent.inDocument()) - m_styleSheetOwner.insertedIntoDocument(document(), *this); - return InsertionDone; + bool wasInDocument = isConnected(); + auto result = SVGElement::insertedInto(rootParent); + if (rootParent.isConnected() && !wasInDocument) + m_styleSheetOwner.insertedIntoDocument(*this); + return result; } void SVGStyleElement::removedFrom(ContainerNode& rootParent) { SVGElement::removedFrom(rootParent); - if (rootParent.inDocument()) - m_styleSheetOwner.removedFromDocument(document(), *this); + if (rootParent.isConnected() && !isConnected()) + m_styleSheetOwner.removedFromDocument(*this); } void SVGStyleElement::childrenChanged(const ChildChange& change) @@ -162,5 +136,3 @@ void SVGStyleElement::childrenChanged(const ChildChange& change) } } - -#endif // ENABLE(SVG) |