summaryrefslogtreecommitdiff
path: root/Source/WebCore/svg/SVGScriptElement.cpp
diff options
context:
space:
mode:
authorKonstantin Tokarev <annulen@yandex.ru>2016-08-25 19:20:41 +0300
committerKonstantin Tokarev <annulen@yandex.ru>2017-02-02 12:30:55 +0000
commit6882a04fb36642862b11efe514251d32070c3d65 (patch)
treeb7959826000b061fd5ccc7512035c7478742f7b0 /Source/WebCore/svg/SVGScriptElement.cpp
parentab6df191029eeeb0b0f16f127d553265659f739e (diff)
downloadqtwebkit-6882a04fb36642862b11efe514251d32070c3d65.tar.gz
Imported QtWebKit TP3 (git b57bc6801f1876c3220d5a4bfea33d620d477443)
Change-Id: I3b1d8a2808782c9f34d50240000e20cb38d3680f Reviewed-by: Konstantin Tokarev <annulen@yandex.ru>
Diffstat (limited to 'Source/WebCore/svg/SVGScriptElement.cpp')
-rw-r--r--Source/WebCore/svg/SVGScriptElement.cpp111
1 files changed, 33 insertions, 78 deletions
diff --git a/Source/WebCore/svg/SVGScriptElement.cpp b/Source/WebCore/svg/SVGScriptElement.cpp
index a8b0a1eed..8adfcfa41 100644
--- a/Source/WebCore/svg/SVGScriptElement.cpp
+++ b/Source/WebCore/svg/SVGScriptElement.cpp
@@ -19,19 +19,15 @@
*/
#include "config.h"
-
-#if ENABLE(SVG)
#include "SVGScriptElement.h"
-#include "Attribute.h"
#include "Document.h"
#include "Event.h"
#include "EventNames.h"
#include "HTMLNames.h"
#include "SVGAnimatedStaticPropertyTearOff.h"
-#include "SVGElementInstance.h"
-#include "ScriptEventListener.h"
#include "XLinkNames.h"
+#include <wtf/NeverDestroyed.h>
namespace WebCore {
@@ -44,92 +40,56 @@ BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGScriptElement)
REGISTER_LOCAL_ANIMATED_PROPERTY(externalResourcesRequired)
END_REGISTER_ANIMATED_PROPERTIES
-inline SVGScriptElement::SVGScriptElement(const QualifiedName& tagName, Document* document, bool wasInsertedByParser, bool alreadyStarted)
+inline SVGScriptElement::SVGScriptElement(const QualifiedName& tagName, Document& document, bool wasInsertedByParser, bool alreadyStarted)
: SVGElement(tagName, document)
- , ScriptElement(this, wasInsertedByParser, alreadyStarted)
- , m_svgLoadEventTimer(this, &SVGElement::svgLoadEventTimerFired)
+ , ScriptElement(*this, wasInsertedByParser, alreadyStarted)
+ , m_svgLoadEventTimer(*this, &SVGElement::svgLoadEventTimerFired)
{
ASSERT(hasTagName(SVGNames::scriptTag));
registerAnimatedPropertiesForSVGScriptElement();
}
-PassRefPtr<SVGScriptElement> SVGScriptElement::create(const QualifiedName& tagName, Document* document, bool insertedByParser)
+Ref<SVGScriptElement> SVGScriptElement::create(const QualifiedName& tagName, Document& document, bool insertedByParser)
{
- return adoptRef(new SVGScriptElement(tagName, document, insertedByParser, false));
-}
-
-bool SVGScriptElement::isSupportedAttribute(const QualifiedName& attrName)
-{
- DEFINE_STATIC_LOCAL(HashSet<QualifiedName>, supportedAttributes, ());
- if (supportedAttributes.isEmpty()) {
- SVGURIReference::addSupportedAttributes(supportedAttributes);
- SVGExternalResourcesRequired::addSupportedAttributes(supportedAttributes);
- supportedAttributes.add(SVGNames::typeAttr);
- supportedAttributes.add(HTMLNames::onerrorAttr);
- }
- return supportedAttributes.contains<SVGAttributeHashTranslator>(attrName);
+ return adoptRef(*new SVGScriptElement(tagName, document, insertedByParser, false));
}
void SVGScriptElement::parseAttribute(const QualifiedName& name, const AtomicString& value)
{
- if (!isSupportedAttribute(name)) {
- SVGElement::parseAttribute(name, value);
- return;
- }
-
- if (name == SVGNames::typeAttr) {
- setType(value);
- return;
- }
-
- if (name == HTMLNames::onerrorAttr) {
- setAttributeEventListener(eventNames().errorEvent, createAttributeEventListener(this, name, value));
- return;
- }
-
- if (SVGURIReference::parseAttribute(name, value))
- return;
- if (SVGExternalResourcesRequired::parseAttribute(name, value))
- return;
-
- ASSERT_NOT_REACHED();
+ SVGElement::parseAttribute(name, value);
+ SVGURIReference::parseAttribute(name, value);
+ SVGExternalResourcesRequired::parseAttribute(name, value);
}
void SVGScriptElement::svgAttributeChanged(const QualifiedName& attrName)
{
- if (!isSupportedAttribute(attrName)) {
- SVGElement::svgAttributeChanged(attrName);
- return;
- }
-
- SVGElementInstance::InvalidationGuard invalidationGuard(this);
-
- if (attrName == SVGNames::typeAttr || attrName == HTMLNames::onerrorAttr)
- return;
+ InstanceInvalidationGuard guard(*this);
if (SVGURIReference::isKnownAttribute(attrName)) {
handleSourceAttribute(href());
return;
}
- if (SVGExternalResourcesRequired::handleAttributeChange(this, attrName))
- return;
-
- ASSERT_NOT_REACHED();
+ SVGExternalResourcesRequired::handleAttributeChange(this, attrName);
+ SVGElement::svgAttributeChanged(attrName);
}
-Node::InsertionNotificationRequest SVGScriptElement::insertedInto(ContainerNode* rootParent)
+Node::InsertionNotificationRequest SVGScriptElement::insertedInto(ContainerNode& rootParent)
{
SVGElement::insertedInto(rootParent);
- ScriptElement::insertedInto(rootParent);
- if (rootParent->inDocument())
+ if (rootParent.inDocument())
SVGExternalResourcesRequired::insertedIntoDocument(this);
- return InsertionDone;
+ return shouldCallFinishedInsertingSubtree(rootParent) ? InsertionShouldCallFinishedInsertingSubtree : InsertionDone;
+}
+
+void SVGScriptElement::finishedInsertingSubtree()
+{
+ ScriptElement::finishedInsertingSubtree();
}
-void SVGScriptElement::childrenChanged(bool changedByParser, Node* beforeChange, Node* afterChange, int childCountDelta)
+void SVGScriptElement::childrenChanged(const ChildChange& change)
{
- SVGElement::childrenChanged(changedByParser, beforeChange, afterChange, childCountDelta);
+ SVGElement::childrenChanged(change);
ScriptElement::childrenChanged();
}
@@ -144,21 +104,11 @@ void SVGScriptElement::finishParsingChildren()
SVGExternalResourcesRequired::finishParsingChildren();
}
-String SVGScriptElement::type() const
-{
- return m_type;
-}
-
-void SVGScriptElement::setType(const String& type)
-{
- m_type = type;
-}
-
-void SVGScriptElement::addSubresourceAttributeURLs(ListHashSet<KURL>& urls) const
+void SVGScriptElement::addSubresourceAttributeURLs(ListHashSet<URL>& urls) const
{
SVGElement::addSubresourceAttributeURLs(urls);
- addSubresourceURL(urls, document()->completeURL(href()));
+ addSubresourceURL(urls, document().completeURL(href()));
}
String SVGScriptElement::sourceAttributeValue() const
@@ -173,7 +123,7 @@ String SVGScriptElement::charsetAttributeValue() const
String SVGScriptElement::typeAttributeValue() const
{
- return type();
+ return getAttribute(SVGNames::typeAttr).string();
}
String SVGScriptElement::languageAttributeValue() const
@@ -206,11 +156,16 @@ bool SVGScriptElement::hasSourceAttribute() const
return hasAttribute(XLinkNames::hrefAttr);
}
-PassRefPtr<Element> SVGScriptElement::cloneElementWithoutAttributesAndChildren()
+Ref<Element> SVGScriptElement::cloneElementWithoutAttributesAndChildren(Document& targetDocument)
{
- return adoptRef(new SVGScriptElement(tagQName(), document(), false, alreadyStarted()));
+ return adoptRef(*new SVGScriptElement(tagQName(), targetDocument, false, alreadyStarted()));
}
+#ifndef NDEBUG
+bool SVGScriptElement::filterOutAnimatableAttribute(const QualifiedName& name) const
+{
+ return name == SVGNames::typeAttr;
}
+#endif
-#endif // ENABLE(SVG)
+}