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