| 1 | /* |
| 2 | * Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org> |
| 3 | * Copyright (C) 2004, 2005, 2007 Rob Buis <buis@kde.org> |
| 4 | * Copyright (C) 2008-2018 Apple Inc. All rights reserved. |
| 5 | * |
| 6 | * This library is free software; you can redistribute it and/or |
| 7 | * modify it under the terms of the GNU Library General Public |
| 8 | * License as published by the Free Software Foundation; either |
| 9 | * version 2 of the License, or (at your option) any later version. |
| 10 | * |
| 11 | * This library is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 14 | * Library General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU Library General Public License |
| 17 | * along with this library; see the file COPYING.LIB. If not, write to |
| 18 | * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 19 | * Boston, MA 02110-1301, USA. |
| 20 | */ |
| 21 | |
| 22 | #pragma once |
| 23 | |
| 24 | #include "SVGElement.h" |
| 25 | #include "SVGExternalResourcesRequired.h" |
| 26 | #include "SVGURIReference.h" |
| 27 | #include "ScriptElement.h" |
| 28 | #include "XLinkNames.h" |
| 29 | |
| 30 | namespace WebCore { |
| 31 | |
| 32 | class SVGScriptElement final : public SVGElement, public SVGExternalResourcesRequired, public SVGURIReference, public ScriptElement { |
| 33 | WTF_MAKE_ISO_ALLOCATED(SVGScriptElement); |
| 34 | public: |
| 35 | static Ref<SVGScriptElement> create(const QualifiedName&, Document&, bool wasInsertedByParser); |
| 36 | |
| 37 | using SVGElement::ref; |
| 38 | using SVGElement::deref; |
| 39 | |
| 40 | private: |
| 41 | SVGScriptElement(const QualifiedName&, Document&, bool wasInsertedByParser, bool alreadyStarted); |
| 42 | |
| 43 | using PropertyRegistry = SVGPropertyOwnerRegistry<SVGScriptElement, SVGElement, SVGExternalResourcesRequired, SVGURIReference>; |
| 44 | const SVGPropertyRegistry& propertyRegistry() const final { return m_propertyRegistry; } |
| 45 | |
| 46 | void parseAttribute(const QualifiedName&, const AtomicString&) final; |
| 47 | void svgAttributeChanged(const QualifiedName&) final; |
| 48 | |
| 49 | InsertedIntoAncestorResult insertedIntoAncestor(InsertionType, ContainerNode&) final; |
| 50 | void didFinishInsertingNode() final; |
| 51 | void childrenChanged(const ChildChange&) final; |
| 52 | |
| 53 | bool isURLAttribute(const Attribute& attribute) const final { return attribute.name() == sourceAttributeValue(); } |
| 54 | void finishParsingChildren() final; |
| 55 | void addSubresourceAttributeURLs(ListHashSet<URL>&) const final; |
| 56 | |
| 57 | bool haveLoadedRequiredResources() final { return SVGExternalResourcesRequired::haveLoadedRequiredResources(); } |
| 58 | |
| 59 | String sourceAttributeValue() const final { return href(); } |
| 60 | String charsetAttributeValue() const final { return String(); } |
| 61 | String typeAttributeValue() const final { return getAttribute(SVGNames::typeAttr).string(); } |
| 62 | String languageAttributeValue() const final { return String(); } |
| 63 | String forAttributeValue() const final { return String(); } |
| 64 | String eventAttributeValue() const final { return String(); } |
| 65 | bool hasAsyncAttribute() const final { return false; } |
| 66 | bool hasDeferAttribute() const final { return false; } |
| 67 | bool hasNoModuleAttribute() const final { return false; } |
| 68 | bool hasSourceAttribute() const final { return hasAttribute(SVGNames::hrefAttr) || hasAttribute(XLinkNames::hrefAttr); } |
| 69 | |
| 70 | void dispatchLoadEvent() final { SVGExternalResourcesRequired::dispatchLoadEvent(); } |
| 71 | |
| 72 | Ref<Element> cloneElementWithoutAttributesAndChildren(Document&) final; |
| 73 | bool rendererIsNeeded(const RenderStyle&) final { return false; } |
| 74 | |
| 75 | // SVGExternalResourcesRequired |
| 76 | void setHaveFiredLoadEvent(bool haveFiredLoadEvent) final { ScriptElement::setHaveFiredLoadEvent(haveFiredLoadEvent); } |
| 77 | bool isParserInserted() const final { return ScriptElement::isParserInserted(); } |
| 78 | bool haveFiredLoadEvent() const final { return ScriptElement::haveFiredLoadEvent(); } |
| 79 | Timer* svgLoadEventTimer() final { return &m_svgLoadEventTimer; } |
| 80 | |
| 81 | #ifndef NDEBUG |
| 82 | bool filterOutAnimatableAttribute(const QualifiedName& name) const final { return name == SVGNames::typeAttr; } |
| 83 | #endif |
| 84 | |
| 85 | PropertyRegistry m_propertyRegistry { *this }; |
| 86 | Timer m_svgLoadEventTimer; |
| 87 | }; |
| 88 | |
| 89 | } // namespace WebCore |
| 90 | |