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 19 matching lines...) Expand all Loading... | |
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/Text.h" | 32 #include "core/dom/Text.h" |
33 | 33 |
34 namespace WebCore { | 34 namespace WebCore { |
35 | 35 |
36 using namespace HTMLNames; | 36 using namespace HTMLNames; |
37 | 37 |
38 inline HTMLScriptElement::HTMLScriptElement(const QualifiedName& tagName, Docume nt* document, bool wasInsertedByParser, bool alreadyStarted) | 38 inline HTMLScriptElement::HTMLScriptElement(const QualifiedName& tagName, Docume nt* document, bool wasInsertedByParser, bool alreadyStarted) |
39 : HTMLElement(tagName, document) | 39 : HTMLElement(tagName, document) |
40 , ScriptElement(this, wasInsertedByParser, alreadyStarted) | 40 , m_scriptElement(ScriptElement::create(this, wasInsertedByParser, alreadySt arted)) |
41 { | 41 { |
42 ASSERT(hasTagName(scriptTag)); | 42 ASSERT(hasTagName(scriptTag)); |
43 ScriptWrappable::init(this); | 43 ScriptWrappable::init(this); |
44 } | 44 } |
45 | 45 |
46 PassRefPtr<HTMLScriptElement> HTMLScriptElement::create(const QualifiedName& tag Name, Document* document, bool wasInsertedByParser, bool alreadyStarted) | 46 PassRefPtr<HTMLScriptElement> HTMLScriptElement::create(const QualifiedName& tag Name, Document* document, bool wasInsertedByParser, bool alreadyStarted) |
47 { | 47 { |
48 return adoptRef(new HTMLScriptElement(tagName, document, wasInsertedByParser , alreadyStarted)); | 48 return adoptRef(new HTMLScriptElement(tagName, document, wasInsertedByParser , alreadyStarted)); |
49 } | 49 } |
50 | 50 |
51 bool HTMLScriptElement::isURLAttribute(const Attribute& attribute) const | 51 bool HTMLScriptElement::isURLAttribute(const Attribute& attribute) const |
52 { | 52 { |
53 return attribute.name() == srcAttr || HTMLElement::isURLAttribute(attribute) ; | 53 return attribute.name() == srcAttr || HTMLElement::isURLAttribute(attribute) ; |
54 } | 54 } |
55 | 55 |
56 void HTMLScriptElement::childrenChanged(bool changedByParser, Node* beforeChange , Node* afterChange, int childCountDelta) | 56 void HTMLScriptElement::childrenChanged(bool changedByParser, Node* beforeChange , Node* afterChange, int childCountDelta) |
57 { | 57 { |
58 HTMLElement::childrenChanged(changedByParser, beforeChange, afterChange, chi ldCountDelta); | 58 HTMLElement::childrenChanged(changedByParser, beforeChange, afterChange, chi ldCountDelta); |
59 ScriptElement::childrenChanged(); | 59 if (m_scriptElement) |
abarth-chromium
2013/07/08 18:47:12
When would m_scriptElement ever be zero?
| |
60 m_scriptElement->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 && m_scriptElement) |
65 handleSourceAttribute(value); | 66 m_scriptElement->handleSourceAttribute(value); |
66 else if (name == asyncAttr) | 67 else if (name == asyncAttr && m_scriptElement) |
67 handleAsyncAttribute(); | 68 m_scriptElement->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 ScriptElement::insertedInto(insertionPoint); | 78 if (m_scriptElement) |
79 m_scriptElement->insertedInto(insertionPoint); | |
78 return InsertionDone; | 80 return InsertionDone; |
79 } | 81 } |
80 | 82 |
81 void HTMLScriptElement::setText(const String &value) | 83 void HTMLScriptElement::setText(const String &value) |
82 { | 84 { |
83 RefPtr<Node> protectFromMutationEvents(this); | 85 RefPtr<Node> protectFromMutationEvents(this); |
84 | 86 |
85 int numChildren = childNodeCount(); | 87 int numChildren = childNodeCount(); |
86 | 88 |
87 if (numChildren == 1 && firstChild()->isTextNode()) { | 89 if (numChildren == 1 && firstChild()->isTextNode()) { |
88 toText(firstChild())->setData(value); | 90 toText(firstChild())->setData(value); |
89 return; | 91 return; |
90 } | 92 } |
91 | 93 |
92 if (numChildren > 0) | 94 if (numChildren > 0) |
93 removeChildren(); | 95 removeChildren(); |
94 | 96 |
95 appendChild(document()->createTextNode(value.impl()), IGNORE_EXCEPTION); | 97 appendChild(document()->createTextNode(value.impl()), IGNORE_EXCEPTION); |
96 } | 98 } |
97 | 99 |
98 void HTMLScriptElement::setAsync(bool async) | 100 void HTMLScriptElement::setAsync(bool async) |
99 { | 101 { |
100 setBooleanAttribute(asyncAttr, async); | 102 setBooleanAttribute(asyncAttr, async); |
101 handleAsyncAttribute(); | 103 if (m_scriptElement) |
104 m_scriptElement->handleAsyncAttribute(); | |
102 } | 105 } |
103 | 106 |
104 bool HTMLScriptElement::async() const | 107 bool HTMLScriptElement::async() const |
105 { | 108 { |
106 return fastHasAttribute(asyncAttr) || forceAsync(); | 109 return fastHasAttribute(asyncAttr) || (m_scriptElement && m_scriptElement->f orceAsync()); |
107 } | 110 } |
108 | 111 |
109 KURL HTMLScriptElement::src() const | 112 KURL HTMLScriptElement::src() const |
110 { | 113 { |
111 return document()->completeURL(sourceAttributeValue()); | 114 return document()->completeURL(sourceAttributeValue()); |
112 } | 115 } |
113 | 116 |
114 void HTMLScriptElement::addSubresourceAttributeURLs(ListHashSet<KURL>& urls) con st | 117 void HTMLScriptElement::addSubresourceAttributeURLs(ListHashSet<KURL>& urls) con st |
115 { | 118 { |
116 HTMLElement::addSubresourceAttributeURLs(urls); | 119 HTMLElement::addSubresourceAttributeURLs(urls); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
158 return fastHasAttribute(deferAttr); | 161 return fastHasAttribute(deferAttr); |
159 } | 162 } |
160 | 163 |
161 bool HTMLScriptElement::hasSourceAttribute() const | 164 bool HTMLScriptElement::hasSourceAttribute() const |
162 { | 165 { |
163 return fastHasAttribute(srcAttr); | 166 return fastHasAttribute(srcAttr); |
164 } | 167 } |
165 | 168 |
166 void HTMLScriptElement::dispatchLoadEvent() | 169 void HTMLScriptElement::dispatchLoadEvent() |
167 { | 170 { |
168 ASSERT(!haveFiredLoadEvent()); | |
169 setHaveFiredLoadEvent(true); | |
170 | |
171 dispatchEvent(Event::create(eventNames().loadEvent, false, false)); | 171 dispatchEvent(Event::create(eventNames().loadEvent, false, false)); |
172 } | 172 } |
173 | 173 |
174 PassRefPtr<Element> HTMLScriptElement::cloneElementWithoutAttributesAndChildren( ) | 174 PassRefPtr<Element> HTMLScriptElement::cloneElementWithoutAttributesAndChildren( ) |
175 { | 175 { |
176 return adoptRef(new HTMLScriptElement(tagQName(), document(), false, already Started())); | 176 return adoptRef(new HTMLScriptElement(tagQName(), document(), false, m_scrip tElement && m_scriptElement->alreadyStarted())); |
177 } | 177 } |
178 | 178 |
179 } | 179 } |
OLD | NEW |