diff options
author | Konstantin Tokarev <annulen@yandex.ru> | 2016-08-25 19:20:41 +0300 |
---|---|---|
committer | Konstantin Tokarev <annulen@yandex.ru> | 2017-02-02 12:30:55 +0000 |
commit | 6882a04fb36642862b11efe514251d32070c3d65 (patch) | |
tree | b7959826000b061fd5ccc7512035c7478742f7b0 /Source/WebCore/html/HTMLScriptElement.cpp | |
parent | ab6df191029eeeb0b0f16f127d553265659f739e (diff) | |
download | qtwebkit-6882a04fb36642862b11efe514251d32070c3d65.tar.gz |
Imported QtWebKit TP3 (git b57bc6801f1876c3220d5a4bfea33d620d477443)
Change-Id: I3b1d8a2808782c9f34d50240000e20cb38d3680f
Reviewed-by: Konstantin Tokarev <annulen@yandex.ru>
Diffstat (limited to 'Source/WebCore/html/HTMLScriptElement.cpp')
-rw-r--r-- | Source/WebCore/html/HTMLScriptElement.cpp | 59 |
1 files changed, 29 insertions, 30 deletions
diff --git a/Source/WebCore/html/HTMLScriptElement.cpp b/Source/WebCore/html/HTMLScriptElement.cpp index 30ae332c3..0ea55f5c4 100644 --- a/Source/WebCore/html/HTMLScriptElement.cpp +++ b/Source/WebCore/html/HTMLScriptElement.cpp @@ -23,28 +23,27 @@ #include "config.h" #include "HTMLScriptElement.h" -#include "Attribute.h" #include "Document.h" #include "Event.h" #include "EventNames.h" #include "HTMLNames.h" -#include "ScriptEventListener.h" #include "Text.h" +#include <wtf/Ref.h> namespace WebCore { using namespace HTMLNames; -inline HTMLScriptElement::HTMLScriptElement(const QualifiedName& tagName, Document* document, bool wasInsertedByParser, bool alreadyStarted) +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 @@ -52,9 +51,9 @@ bool HTMLScriptElement::isURLAttribute(const Attribute& attribute) const return attribute.name() == srcAttr || HTMLElement::isURLAttribute(attribute); } -void HTMLScriptElement::childrenChanged(bool changedByParser, Node* beforeChange, Node* afterChange, int childCountDelta) +void HTMLScriptElement::childrenChanged(const ChildChange& change) { - HTMLElement::childrenChanged(changedByParser, beforeChange, afterChange, childCountDelta); + HTMLElement::childrenChanged(change); ScriptElement::childrenChanged(); } @@ -64,34 +63,34 @@ void HTMLScriptElement::parseAttribute(const QualifiedName& name, const AtomicSt handleSourceAttribute(value); else if (name == asyncAttr) handleAsyncAttribute(); - else if (name == onbeforeloadAttr) - setAttributeEventListener(eventNames().beforeloadEvent, createAttributeEventListener(this, name, value)); else HTMLElement::parseAttribute(name, value); } -Node::InsertionNotificationRequest HTMLScriptElement::insertedInto(ContainerNode* insertionPoint) +Node::InsertionNotificationRequest HTMLScriptElement::insertedInto(ContainerNode& insertionPoint) { HTMLElement::insertedInto(insertionPoint); - ScriptElement::insertedInto(insertionPoint); - return InsertionDone; + return shouldCallFinishedInsertingSubtree(insertionPoint) ? InsertionShouldCallFinishedInsertingSubtree : InsertionDone; } -void HTMLScriptElement::setText(const String &value) +void HTMLScriptElement::finishedInsertingSubtree() { - RefPtr<Node> protectFromMutationEvents(this); + ScriptElement::finishedInsertingSubtree(); +} - int numChildren = childNodeCount(); +void HTMLScriptElement::setText(const String &value) +{ + Ref<HTMLScriptElement> protectFromMutationEvents(*this); - if (numChildren == 1 && firstChild()->isTextNode()) { - toText(firstChild())->setData(value, IGNORE_EXCEPTION); + if (hasOneChild() && is<Text>(*firstChild())) { + downcast<Text>(*firstChild()).setData(value); return; } - if (numChildren > 0) + if (hasChildNodes()) removeChildren(); - appendChild(document()->createTextNode(value.impl()), IGNORE_EXCEPTION); + appendChild(document().createTextNode(value.impl()), IGNORE_EXCEPTION); } void HTMLScriptElement::setAsync(bool async) @@ -105,12 +104,12 @@ bool HTMLScriptElement::async() const return fastHasAttribute(asyncAttr) || forceAsync(); } -KURL HTMLScriptElement::src() const +URL HTMLScriptElement::src() const { - return document()->completeURL(sourceAttributeValue()); + return document().completeURL(sourceAttributeValue()); } -void HTMLScriptElement::addSubresourceAttributeURLs(ListHashSet<KURL>& urls) const +void HTMLScriptElement::addSubresourceAttributeURLs(ListHashSet<URL>& urls) const { HTMLElement::addSubresourceAttributeURLs(urls); @@ -119,12 +118,12 @@ void HTMLScriptElement::addSubresourceAttributeURLs(ListHashSet<KURL>& urls) con String HTMLScriptElement::sourceAttributeValue() const { - return getAttribute(srcAttr).string(); + return fastGetAttribute(srcAttr).string(); } String HTMLScriptElement::charsetAttributeValue() const { - return getAttribute(charsetAttr).string(); + return fastGetAttribute(charsetAttr).string(); } String HTMLScriptElement::typeAttributeValue() const @@ -134,17 +133,17 @@ String HTMLScriptElement::typeAttributeValue() const String HTMLScriptElement::languageAttributeValue() const { - return getAttribute(languageAttr).string(); + return fastGetAttribute(languageAttr).string(); } String HTMLScriptElement::forAttributeValue() const { - return getAttribute(forAttr).string(); + return fastGetAttribute(forAttr).string(); } String HTMLScriptElement::eventAttributeValue() const { - return getAttribute(eventAttr).string(); + return fastGetAttribute(eventAttr).string(); } bool HTMLScriptElement::asyncAttributeValue() const @@ -170,9 +169,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())); } } |