| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
| 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
| 4 * (C) 2001 Dirk Mueller (mueller@kde.org) | 4 * (C) 2001 Dirk Mueller (mueller@kde.org) |
| 5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserv
ed. | 5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserv
ed. |
| 6 * | 6 * |
| 7 * This library is free software; you can redistribute it and/or | 7 * This library is free software; you can redistribute it and/or |
| 8 * modify it under the terms of the GNU Library General Public | 8 * modify it under the terms of the GNU Library General Public |
| 9 * License as published by the Free Software Foundation; either | 9 * License as published by the Free Software Foundation; either |
| 10 * version 2 of the License, or (at your option) any later version. | 10 * version 2 of the License, or (at your option) any later version. |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 | 22 |
| 23 #include "config.h" | 23 #include "config.h" |
| 24 #include "core/html/HTMLScriptElement.h" | 24 #include "core/html/HTMLScriptElement.h" |
| 25 | 25 |
| 26 #include "HTMLNames.h" | 26 #include "HTMLNames.h" |
| 27 #include "bindings/v8/ScriptEventListener.h" | 27 #include "bindings/v8/ScriptEventListener.h" |
| 28 #include "core/dom/Attribute.h" | 28 #include "core/dom/Attribute.h" |
| 29 #include "core/dom/Document.h" | 29 #include "core/dom/Document.h" |
| 30 #include "core/dom/Event.h" | 30 #include "core/dom/Event.h" |
| 31 #include "core/dom/EventNames.h" | 31 #include "core/dom/EventNames.h" |
| 32 #include "core/dom/ScriptLoader.h" |
| 32 #include "core/dom/Text.h" | 33 #include "core/dom/Text.h" |
| 33 | 34 |
| 34 namespace WebCore { | 35 namespace WebCore { |
| 35 | 36 |
| 36 using namespace HTMLNames; | 37 using namespace HTMLNames; |
| 37 | 38 |
| 38 inline HTMLScriptElement::HTMLScriptElement(const QualifiedName& tagName, Docume
nt* document, bool wasInsertedByParser, bool alreadyStarted) | 39 inline HTMLScriptElement::HTMLScriptElement(const QualifiedName& tagName, Docume
nt* document, bool wasInsertedByParser, bool alreadyStarted) |
| 39 : HTMLElement(tagName, document) | 40 : HTMLElement(tagName, document) |
| 40 , m_scriptElement(ScriptElement::create(this, wasInsertedByParser, alreadySt
arted)) | 41 , m_loader(ScriptLoader::create(this, wasInsertedByParser, alreadyStarted)) |
| 41 { | 42 { |
| 42 ASSERT(hasTagName(scriptTag)); | 43 ASSERT(hasTagName(scriptTag)); |
| 43 ScriptWrappable::init(this); | 44 ScriptWrappable::init(this); |
| 44 } | 45 } |
| 45 | 46 |
| 46 PassRefPtr<HTMLScriptElement> HTMLScriptElement::create(const QualifiedName& tag
Name, Document* document, bool wasInsertedByParser, bool alreadyStarted) | 47 PassRefPtr<HTMLScriptElement> HTMLScriptElement::create(const QualifiedName& tag
Name, Document* document, bool wasInsertedByParser, bool alreadyStarted) |
| 47 { | 48 { |
| 48 return adoptRef(new HTMLScriptElement(tagName, document, wasInsertedByParser
, alreadyStarted)); | 49 return adoptRef(new HTMLScriptElement(tagName, document, wasInsertedByParser
, alreadyStarted)); |
| 49 } | 50 } |
| 50 | 51 |
| 51 bool HTMLScriptElement::isURLAttribute(const Attribute& attribute) const | 52 bool HTMLScriptElement::isURLAttribute(const Attribute& attribute) const |
| 52 { | 53 { |
| 53 return attribute.name() == srcAttr || HTMLElement::isURLAttribute(attribute)
; | 54 return attribute.name() == srcAttr || HTMLElement::isURLAttribute(attribute)
; |
| 54 } | 55 } |
| 55 | 56 |
| 56 void HTMLScriptElement::childrenChanged(bool changedByParser, Node* beforeChange
, Node* afterChange, int childCountDelta) | 57 void HTMLScriptElement::childrenChanged(bool changedByParser, Node* beforeChange
, Node* afterChange, int childCountDelta) |
| 57 { | 58 { |
| 58 HTMLElement::childrenChanged(changedByParser, beforeChange, afterChange, chi
ldCountDelta); | 59 HTMLElement::childrenChanged(changedByParser, beforeChange, afterChange, chi
ldCountDelta); |
| 59 m_scriptElement->childrenChanged(); | 60 m_loader->childrenChanged(); |
| 60 } | 61 } |
| 61 | 62 |
| 62 void HTMLScriptElement::parseAttribute(const QualifiedName& name, const AtomicSt
ring& value) | 63 void HTMLScriptElement::parseAttribute(const QualifiedName& name, const AtomicSt
ring& value) |
| 63 { | 64 { |
| 64 if (name == srcAttr) | 65 if (name == srcAttr) |
| 65 m_scriptElement->handleSourceAttribute(value); | 66 m_loader->handleSourceAttribute(value); |
| 66 else if (name == asyncAttr) | 67 else if (name == asyncAttr) |
| 67 m_scriptElement->handleAsyncAttribute(); | 68 m_loader->handleAsyncAttribute(); |
| 68 else if (name == onbeforeloadAttr) | 69 else if (name == onbeforeloadAttr) |
| 69 setAttributeEventListener(eventNames().beforeloadEvent, createAttributeE
ventListener(this, name, value)); | 70 setAttributeEventListener(eventNames().beforeloadEvent, createAttributeE
ventListener(this, name, value)); |
| 70 else | 71 else |
| 71 HTMLElement::parseAttribute(name, value); | 72 HTMLElement::parseAttribute(name, value); |
| 72 } | 73 } |
| 73 | 74 |
| 74 Node::InsertionNotificationRequest HTMLScriptElement::insertedInto(ContainerNode
* insertionPoint) | 75 Node::InsertionNotificationRequest HTMLScriptElement::insertedInto(ContainerNode
* insertionPoint) |
| 75 { | 76 { |
| 76 HTMLElement::insertedInto(insertionPoint); | 77 HTMLElement::insertedInto(insertionPoint); |
| 77 m_scriptElement->insertedInto(insertionPoint); | 78 m_loader->insertedInto(insertionPoint); |
| 78 return InsertionDone; | 79 return InsertionDone; |
| 79 } | 80 } |
| 80 | 81 |
| 81 void HTMLScriptElement::setText(const String &value) | 82 void HTMLScriptElement::setText(const String &value) |
| 82 { | 83 { |
| 83 RefPtr<Node> protectFromMutationEvents(this); | 84 RefPtr<Node> protectFromMutationEvents(this); |
| 84 | 85 |
| 85 int numChildren = childNodeCount(); | 86 int numChildren = childNodeCount(); |
| 86 | 87 |
| 87 if (numChildren == 1 && firstChild()->isTextNode()) { | 88 if (numChildren == 1 && firstChild()->isTextNode()) { |
| 88 toText(firstChild())->setData(value); | 89 toText(firstChild())->setData(value); |
| 89 return; | 90 return; |
| 90 } | 91 } |
| 91 | 92 |
| 92 if (numChildren > 0) | 93 if (numChildren > 0) |
| 93 removeChildren(); | 94 removeChildren(); |
| 94 | 95 |
| 95 appendChild(document()->createTextNode(value.impl()), IGNORE_EXCEPTION); | 96 appendChild(document()->createTextNode(value.impl()), IGNORE_EXCEPTION); |
| 96 } | 97 } |
| 97 | 98 |
| 98 void HTMLScriptElement::setAsync(bool async) | 99 void HTMLScriptElement::setAsync(bool async) |
| 99 { | 100 { |
| 100 setBooleanAttribute(asyncAttr, async); | 101 setBooleanAttribute(asyncAttr, async); |
| 101 m_scriptElement->handleAsyncAttribute(); | 102 m_loader->handleAsyncAttribute(); |
| 102 } | 103 } |
| 103 | 104 |
| 104 bool HTMLScriptElement::async() const | 105 bool HTMLScriptElement::async() const |
| 105 { | 106 { |
| 106 return fastHasAttribute(asyncAttr) || (m_scriptElement->forceAsync()); | 107 return fastHasAttribute(asyncAttr) || (m_loader->forceAsync()); |
| 107 } | 108 } |
| 108 | 109 |
| 109 KURL HTMLScriptElement::src() const | 110 KURL HTMLScriptElement::src() const |
| 110 { | 111 { |
| 111 return document()->completeURL(sourceAttributeValue()); | 112 return document()->completeURL(sourceAttributeValue()); |
| 112 } | 113 } |
| 113 | 114 |
| 114 void HTMLScriptElement::addSubresourceAttributeURLs(ListHashSet<KURL>& urls) con
st | 115 void HTMLScriptElement::addSubresourceAttributeURLs(ListHashSet<KURL>& urls) con
st |
| 115 { | 116 { |
| 116 HTMLElement::addSubresourceAttributeURLs(urls); | 117 HTMLElement::addSubresourceAttributeURLs(urls); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 return fastHasAttribute(srcAttr); | 164 return fastHasAttribute(srcAttr); |
| 164 } | 165 } |
| 165 | 166 |
| 166 void HTMLScriptElement::dispatchLoadEvent() | 167 void HTMLScriptElement::dispatchLoadEvent() |
| 167 { | 168 { |
| 168 dispatchEvent(Event::create(eventNames().loadEvent, false, false)); | 169 dispatchEvent(Event::create(eventNames().loadEvent, false, false)); |
| 169 } | 170 } |
| 170 | 171 |
| 171 PassRefPtr<Element> HTMLScriptElement::cloneElementWithoutAttributesAndChildren(
) | 172 PassRefPtr<Element> HTMLScriptElement::cloneElementWithoutAttributesAndChildren(
) |
| 172 { | 173 { |
| 173 return adoptRef(new HTMLScriptElement(tagQName(), document(), false, m_scrip
tElement->alreadyStarted())); | 174 return adoptRef(new HTMLScriptElement(tagQName(), document(), false, m_loade
r->alreadyStarted())); |
| 174 } | 175 } |
| 175 | 176 |
| 176 } | 177 } |
| OLD | NEW |