summaryrefslogtreecommitdiff
path: root/Source/WebCore/html/HTMLScriptElement.cpp
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@lorry>2017-06-27 06:07:23 +0000
committerLorry Tar Creator <lorry-tar-importer@lorry>2017-06-27 06:07:23 +0000
commit1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c (patch)
tree46dcd36c86e7fbc6e5df36deb463b33e9967a6f7 /Source/WebCore/html/HTMLScriptElement.cpp
parent32761a6cee1d0dee366b885b7b9c777e67885688 (diff)
downloadWebKitGtk-tarball-master.tar.gz
Diffstat (limited to 'Source/WebCore/html/HTMLScriptElement.cpp')
-rw-r--r--Source/WebCore/html/HTMLScriptElement.cpp80
1 files changed, 41 insertions, 39 deletions
diff --git a/Source/WebCore/html/HTMLScriptElement.cpp b/Source/WebCore/html/HTMLScriptElement.cpp
index 50e1a1335..a8e14b4f8 100644
--- a/Source/WebCore/html/HTMLScriptElement.cpp
+++ b/Source/WebCore/html/HTMLScriptElement.cpp
@@ -2,7 +2,7 @@
* Copyright (C) 1999 Lars Knoll (knoll@kde.org)
* (C) 1999 Antti Koivisto (koivisto@kde.org)
* (C) 2001 Dirk Mueller (mueller@kde.org)
- * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2003-2017 Apple Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -23,11 +23,11 @@
#include "config.h"
#include "HTMLScriptElement.h"
-#include "Attribute.h"
#include "Document.h"
#include "Event.h"
#include "EventNames.h"
#include "HTMLNames.h"
+#include "HTMLParserIdioms.h"
#include "Text.h"
#include <wtf/Ref.h>
@@ -37,14 +37,14 @@ using namespace HTMLNames;
inline HTMLScriptElement::HTMLScriptElement(const QualifiedName& tagName, Document& document, bool wasInsertedByParser, bool alreadyStarted)
: HTMLElement(tagName, document)
- , ScriptElement(this, wasInsertedByParser, alreadyStarted)
+ , ScriptElement(*this, wasInsertedByParser, alreadyStarted)
{
ASSERT(hasTagName(scriptTag));
}
-PassRefPtr<HTMLScriptElement> HTMLScriptElement::create(const QualifiedName& tagName, Document& document, bool wasInsertedByParser, bool alreadyStarted)
+Ref<HTMLScriptElement> HTMLScriptElement::create(const QualifiedName& tagName, Document& document, bool wasInsertedByParser, bool alreadyStarted)
{
- return adoptRef(new HTMLScriptElement(tagName, document, wasInsertedByParser, alreadyStarted));
+ return adoptRef(*new HTMLScriptElement(tagName, document, wasInsertedByParser, alreadyStarted));
}
bool HTMLScriptElement::isURLAttribute(const Attribute& attribute) const
@@ -55,7 +55,7 @@ bool HTMLScriptElement::isURLAttribute(const Attribute& attribute) const
void HTMLScriptElement::childrenChanged(const ChildChange& change)
{
HTMLElement::childrenChanged(change);
- ScriptElement::childrenChanged();
+ ScriptElement::childrenChanged(change);
}
void HTMLScriptElement::parseAttribute(const QualifiedName& name, const AtomicString& value)
@@ -64,8 +64,6 @@ void HTMLScriptElement::parseAttribute(const QualifiedName& name, const AtomicSt
handleSourceAttribute(value);
else if (name == asyncAttr)
handleAsyncAttribute();
- else if (name == onbeforeloadAttr)
- setAttributeEventListener(eventNames().beforeloadEvent, name, value);
else
HTMLElement::parseAttribute(name, value);
}
@@ -73,29 +71,18 @@ void HTMLScriptElement::parseAttribute(const QualifiedName& name, const AtomicSt
Node::InsertionNotificationRequest HTMLScriptElement::insertedInto(ContainerNode& insertionPoint)
{
HTMLElement::insertedInto(insertionPoint);
- return shouldNotifySubtreeInsertions(insertionPoint) ? InsertionShouldCallDidNotifySubtreeInsertions : InsertionDone;
+ return shouldCallFinishedInsertingSubtree(insertionPoint) ? InsertionShouldCallFinishedInsertingSubtree : InsertionDone;
}
-void HTMLScriptElement::didNotifySubtreeInsertions(ContainerNode* node)
+void HTMLScriptElement::finishedInsertingSubtree()
{
- ScriptElement::didNotifySubtreeInsertions(node);
+ ScriptElement::finishedInsertingSubtree();
}
-void HTMLScriptElement::setText(const String &value)
+// https://html.spec.whatwg.org/multipage/scripting.html#dom-script-text
+void HTMLScriptElement::setText(const String& value)
{
- Ref<HTMLScriptElement> protectFromMutationEvents(*this);
-
- int numChildren = childNodeCount();
-
- if (numChildren == 1 && firstChild()->isTextNode()) {
- toText(firstChild())->setData(value, IGNORE_EXCEPTION);
- return;
- }
-
- if (numChildren > 0)
- removeChildren();
-
- appendChild(document().createTextNode(value.impl()), IGNORE_EXCEPTION);
+ setTextContent(value);
}
void HTMLScriptElement::setAsync(bool async)
@@ -106,7 +93,17 @@ void HTMLScriptElement::setAsync(bool async)
bool HTMLScriptElement::async() const
{
- return fastHasAttribute(asyncAttr) || forceAsync();
+ return hasAttributeWithoutSynchronization(asyncAttr) || forceAsync();
+}
+
+void HTMLScriptElement::setCrossOrigin(const AtomicString& value)
+{
+ setAttributeWithoutSynchronization(crossoriginAttr, value);
+}
+
+String HTMLScriptElement::crossOrigin() const
+{
+ return parseCORSSettingsAttribute(attributeWithoutSynchronization(crossoriginAttr));
}
URL HTMLScriptElement::src() const
@@ -123,47 +120,52 @@ void HTMLScriptElement::addSubresourceAttributeURLs(ListHashSet<URL>& urls) cons
String HTMLScriptElement::sourceAttributeValue() const
{
- return getAttribute(srcAttr).string();
+ return attributeWithoutSynchronization(srcAttr).string();
}
String HTMLScriptElement::charsetAttributeValue() const
{
- return getAttribute(charsetAttr).string();
+ return attributeWithoutSynchronization(charsetAttr).string();
}
String HTMLScriptElement::typeAttributeValue() const
{
- return getAttribute(typeAttr).string();
+ return attributeWithoutSynchronization(typeAttr).string();
}
String HTMLScriptElement::languageAttributeValue() const
{
- return getAttribute(languageAttr).string();
+ return attributeWithoutSynchronization(languageAttr).string();
}
String HTMLScriptElement::forAttributeValue() const
{
- return getAttribute(forAttr).string();
+ return attributeWithoutSynchronization(forAttr).string();
}
String HTMLScriptElement::eventAttributeValue() const
{
- return getAttribute(eventAttr).string();
+ return attributeWithoutSynchronization(eventAttr).string();
+}
+
+bool HTMLScriptElement::hasAsyncAttribute() const
+{
+ return hasAttributeWithoutSynchronization(asyncAttr);
}
-bool HTMLScriptElement::asyncAttributeValue() const
+bool HTMLScriptElement::hasDeferAttribute() const
{
- return fastHasAttribute(asyncAttr);
+ return hasAttributeWithoutSynchronization(deferAttr);
}
-bool HTMLScriptElement::deferAttributeValue() const
+bool HTMLScriptElement::hasNoModuleAttribute() const
{
- return fastHasAttribute(deferAttr);
+ return hasAttributeWithoutSynchronization(nomoduleAttr);
}
bool HTMLScriptElement::hasSourceAttribute() const
{
- return fastHasAttribute(srcAttr);
+ return hasAttributeWithoutSynchronization(srcAttr);
}
void HTMLScriptElement::dispatchLoadEvent()
@@ -174,9 +176,9 @@ void HTMLScriptElement::dispatchLoadEvent()
dispatchEvent(Event::create(eventNames().loadEvent, false, false));
}
-PassRefPtr<Element> HTMLScriptElement::cloneElementWithoutAttributesAndChildren()
+Ref<Element> HTMLScriptElement::cloneElementWithoutAttributesAndChildren(Document& targetDocument)
{
- return adoptRef(new HTMLScriptElement(tagQName(), document(), false, alreadyStarted()));
+ return adoptRef(*new HTMLScriptElement(tagQName(), targetDocument, false, alreadyStarted()));
}
}