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) 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 | #include "config.h" |
23 | #include "SVGScriptElement.h" |
24 | |
25 | #include "Document.h" |
26 | #include "Event.h" |
27 | #include <wtf/IsoMallocInlines.h> |
28 | |
29 | namespace WebCore { |
30 | |
31 | WTF_MAKE_ISO_ALLOCATED_IMPL(SVGScriptElement); |
32 | |
33 | inline SVGScriptElement::SVGScriptElement(const QualifiedName& tagName, Document& document, bool wasInsertedByParser, bool alreadyStarted) |
34 | : SVGElement(tagName, document) |
35 | , SVGExternalResourcesRequired(this) |
36 | , SVGURIReference(this) |
37 | , ScriptElement(*this, wasInsertedByParser, alreadyStarted) |
38 | , m_svgLoadEventTimer(*this, &SVGElement::svgLoadEventTimerFired) |
39 | { |
40 | ASSERT(hasTagName(SVGNames::scriptTag)); |
41 | } |
42 | |
43 | Ref<SVGScriptElement> SVGScriptElement::create(const QualifiedName& tagName, Document& document, bool insertedByParser) |
44 | { |
45 | return adoptRef(*new SVGScriptElement(tagName, document, insertedByParser, false)); |
46 | } |
47 | |
48 | void SVGScriptElement::parseAttribute(const QualifiedName& name, const AtomicString& value) |
49 | { |
50 | SVGElement::parseAttribute(name, value); |
51 | SVGURIReference::parseAttribute(name, value); |
52 | SVGExternalResourcesRequired::parseAttribute(name, value); |
53 | } |
54 | |
55 | void SVGScriptElement::svgAttributeChanged(const QualifiedName& attrName) |
56 | { |
57 | InstanceInvalidationGuard guard(*this); |
58 | |
59 | if (SVGURIReference::isKnownAttribute(attrName)) { |
60 | handleSourceAttribute(href()); |
61 | return; |
62 | } |
63 | |
64 | SVGElement::svgAttributeChanged(attrName); |
65 | SVGExternalResourcesRequired::svgAttributeChanged(attrName); |
66 | } |
67 | |
68 | Node::InsertedIntoAncestorResult SVGScriptElement::insertedIntoAncestor(InsertionType insertionType, ContainerNode& parentOfInsertedTree) |
69 | { |
70 | SVGElement::insertedIntoAncestor(insertionType, parentOfInsertedTree); |
71 | if (insertionType.connectedToDocument) |
72 | SVGExternalResourcesRequired::insertedIntoDocument(); |
73 | return ScriptElement::insertedIntoAncestor(insertionType, parentOfInsertedTree); |
74 | } |
75 | |
76 | void SVGScriptElement::didFinishInsertingNode() |
77 | { |
78 | ScriptElement::didFinishInsertingNode(); |
79 | } |
80 | |
81 | void SVGScriptElement::childrenChanged(const ChildChange& change) |
82 | { |
83 | SVGElement::childrenChanged(change); |
84 | ScriptElement::childrenChanged(change); |
85 | } |
86 | |
87 | void SVGScriptElement::finishParsingChildren() |
88 | { |
89 | SVGElement::finishParsingChildren(); |
90 | SVGExternalResourcesRequired::finishParsingChildren(); |
91 | } |
92 | |
93 | void SVGScriptElement::addSubresourceAttributeURLs(ListHashSet<URL>& urls) const |
94 | { |
95 | SVGElement::addSubresourceAttributeURLs(urls); |
96 | |
97 | addSubresourceURL(urls, document().completeURL(href())); |
98 | } |
99 | Ref<Element> SVGScriptElement::cloneElementWithoutAttributesAndChildren(Document& targetDocument) |
100 | { |
101 | return adoptRef(*new SVGScriptElement(tagQName(), targetDocument, false, alreadyStarted())); |
102 | } |
103 | |
104 | } |
105 | |