diff options
Diffstat (limited to 'Source/WebCore/html/HTMLScriptElement.cpp')
-rw-r--r-- | Source/WebCore/html/HTMLScriptElement.cpp | 37 |
1 files changed, 21 insertions, 16 deletions
diff --git a/Source/WebCore/html/HTMLScriptElement.cpp b/Source/WebCore/html/HTMLScriptElement.cpp index 0ea55f5c4..50e1a1335 100644 --- a/Source/WebCore/html/HTMLScriptElement.cpp +++ b/Source/WebCore/html/HTMLScriptElement.cpp @@ -23,6 +23,7 @@ #include "config.h" #include "HTMLScriptElement.h" +#include "Attribute.h" #include "Document.h" #include "Event.h" #include "EventNames.h" @@ -36,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)); } -Ref<HTMLScriptElement> HTMLScriptElement::create(const QualifiedName& tagName, Document& document, bool wasInsertedByParser, bool alreadyStarted) +PassRefPtr<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 @@ -63,6 +64,8 @@ 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); } @@ -70,24 +73,26 @@ void HTMLScriptElement::parseAttribute(const QualifiedName& name, const AtomicSt Node::InsertionNotificationRequest HTMLScriptElement::insertedInto(ContainerNode& insertionPoint) { HTMLElement::insertedInto(insertionPoint); - return shouldCallFinishedInsertingSubtree(insertionPoint) ? InsertionShouldCallFinishedInsertingSubtree : InsertionDone; + return shouldNotifySubtreeInsertions(insertionPoint) ? InsertionShouldCallDidNotifySubtreeInsertions : InsertionDone; } -void HTMLScriptElement::finishedInsertingSubtree() +void HTMLScriptElement::didNotifySubtreeInsertions(ContainerNode* node) { - ScriptElement::finishedInsertingSubtree(); + ScriptElement::didNotifySubtreeInsertions(node); } void HTMLScriptElement::setText(const String &value) { Ref<HTMLScriptElement> protectFromMutationEvents(*this); - if (hasOneChild() && is<Text>(*firstChild())) { - downcast<Text>(*firstChild()).setData(value); + int numChildren = childNodeCount(); + + if (numChildren == 1 && firstChild()->isTextNode()) { + toText(firstChild())->setData(value, IGNORE_EXCEPTION); return; } - if (hasChildNodes()) + if (numChildren > 0) removeChildren(); appendChild(document().createTextNode(value.impl()), IGNORE_EXCEPTION); @@ -118,12 +123,12 @@ void HTMLScriptElement::addSubresourceAttributeURLs(ListHashSet<URL>& urls) cons String HTMLScriptElement::sourceAttributeValue() const { - return fastGetAttribute(srcAttr).string(); + return getAttribute(srcAttr).string(); } String HTMLScriptElement::charsetAttributeValue() const { - return fastGetAttribute(charsetAttr).string(); + return getAttribute(charsetAttr).string(); } String HTMLScriptElement::typeAttributeValue() const @@ -133,17 +138,17 @@ String HTMLScriptElement::typeAttributeValue() const String HTMLScriptElement::languageAttributeValue() const { - return fastGetAttribute(languageAttr).string(); + return getAttribute(languageAttr).string(); } String HTMLScriptElement::forAttributeValue() const { - return fastGetAttribute(forAttr).string(); + return getAttribute(forAttr).string(); } String HTMLScriptElement::eventAttributeValue() const { - return fastGetAttribute(eventAttr).string(); + return getAttribute(eventAttr).string(); } bool HTMLScriptElement::asyncAttributeValue() const @@ -169,9 +174,9 @@ void HTMLScriptElement::dispatchLoadEvent() dispatchEvent(Event::create(eventNames().loadEvent, false, false)); } -Ref<Element> HTMLScriptElement::cloneElementWithoutAttributesAndChildren(Document& targetDocument) +PassRefPtr<Element> HTMLScriptElement::cloneElementWithoutAttributesAndChildren() { - return adoptRef(*new HTMLScriptElement(tagQName(), targetDocument, false, alreadyStarted())); + return adoptRef(new HTMLScriptElement(tagQName(), document(), false, alreadyStarted())); } } |