Changeset 36699 in webkit
- Timestamp:
- Sep 19, 2008 8:33:43 PM (16 years ago)
- Location:
- trunk
- Files:
-
- 39 added
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r36687 r36699 1 2008-09-19 Nikolas Zimmermann <zimmermann@kde.org> 2 3 Reviewed by Antti & Eric. 4 5 Fixes: https://bugs.webkit.org/show_bug.cgi?id=20372 6 7 Add new test fast/dom/HTMLScriptElement/script-reexecution.html, verifying that 8 appending a <script>, removing and reappending doesn't reexecute the script. 9 10 Fix obvious errors in tests contained in fast/dom/HTMLScriptElement/. 11 Use these tests as skeleton for a series of SVGScriptElement tests. 12 Especially tests SVG's SVGLoad/SVGError event support, as well as the 13 influence of externalResourcesRequired attribute. 14 15 * fast/dom/HTMLScriptElement/resources/script-reexecution-pass.js: Added. 16 * fast/dom/HTMLScriptElement/script-load-events.html: 17 * fast/dom/HTMLScriptElement/script-reexecution-expected.txt: Added. 18 * fast/dom/HTMLScriptElement/script-reexecution.html: Added. 19 * fast/dom/HTMLScriptElement/script-set-src.html: 20 * platform/mac/svg/dom/SVGScriptElement: Added. 21 * platform/mac/svg/dom/SVGScriptElement/script-change-externalResourcesRequired-while-loading-expected.checksum: Added. 22 * platform/mac/svg/dom/SVGScriptElement/script-change-externalResourcesRequired-while-loading-expected.png: Added. 23 * platform/mac/svg/dom/SVGScriptElement/script-load-and-error-events-expected.checksum: Added. 24 * platform/mac/svg/dom/SVGScriptElement/script-load-and-error-events-expected.png: Added. 25 * platform/mac/svg/dom/SVGScriptElement/script-reexecution-expected.checksum: Added. 26 * platform/mac/svg/dom/SVGScriptElement/script-reexecution-expected.png: Added. 27 * platform/mac/svg/dom/SVGScriptElement/script-set-href-expected.checksum: Added. 28 * platform/mac/svg/dom/SVGScriptElement/script-set-href-expected.png: Added. 29 * svg/dom/SVGScriptElement: Added. 30 * svg/dom/SVGScriptElement/resources: Added. 31 * svg/dom/SVGScriptElement/resources/script-load.js: Added. 32 * svg/dom/SVGScriptElement/resources/script-load2.js: Added. 33 * svg/dom/SVGScriptElement/resources/script-load3.js: Added. 34 * svg/dom/SVGScriptElement/resources/script-load4.js: Added. 35 * svg/dom/SVGScriptElement/resources/script-reexecution.js: Added. 36 * svg/dom/SVGScriptElement/resources/script-set-href-p1fail.js: Added. 37 * svg/dom/SVGScriptElement/resources/script-set-href-p2fail.js: Added. 38 * svg/dom/SVGScriptElement/resources/script-set-href-p3pass.js: Added. 39 * svg/dom/SVGScriptElement/resources/script-set-href-p4pass.js: Added. 40 * svg/dom/SVGScriptElement/resources/script-set-href-p5fail.js: Added. 41 * svg/dom/SVGScriptElement/resources/script-set-href-p5pass.js: Added. 42 * svg/dom/SVGScriptElement/resources/script-set-href-p6pass.js: Added. 43 * svg/dom/SVGScriptElement/resources/script-set-href-p7pass.js: Added. 44 * svg/dom/SVGScriptElement/resources/script-set-href-p8pass.js: Added. 45 * svg/dom/SVGScriptElement/resources/script-set-href-p9failAfter.js: Added. 46 * svg/dom/SVGScriptElement/resources/script-set-href-p9failBefore.js: Added. 47 * svg/dom/SVGScriptElement/resources/script-set-href-p9pass.js: Added. 48 * svg/dom/SVGScriptElement/script-change-externalResourcesRequired-while-loading-expected.txt: Added. 49 * svg/dom/SVGScriptElement/script-change-externalResourcesRequired-while-loading.svg: Added. 50 * svg/dom/SVGScriptElement/script-load-and-error-events-expected.txt: Added. 51 * svg/dom/SVGScriptElement/script-load-and-error-events.svg: Added. 52 * svg/dom/SVGScriptElement/script-reexecution-expected.txt: Added. 53 * svg/dom/SVGScriptElement/script-reexecution.svg: Added. 54 * svg/dom/SVGScriptElement/script-set-href-expected.txt: Added. 55 * svg/dom/SVGScriptElement/script-set-href.svg: Added. 56 1 57 2008-09-19 Chris Marrin <cmarrin@apple.com> 2 58 -
trunk/LayoutTests/fast/dom/HTMLScriptElement/script-load-events.html
r30238 r36699 64 64 <script type="text/javascript" onload="loaded(1)" onerror="erred(1)" src="resources/certainlydoesnotexist.js"></script> 65 65 <script type="text/javascript" onload="loaded(2)" onerror="erred(2)" src="resources/script-load.js"></script> 66 <script type="text/javascript" onload="loaded(3)" onerror="erred(3)" src="resources/script-load.js" ></script>66 <script type="text/javascript" onload="loaded(3)" onerror="erred(3)" src="resources/script-load.js"/> 67 67 <script type="text/javascript"> 68 68 document.write('<script type="text/javascript" onload="loaded(4)" onerror="erred(4)" src="resources/script-load.js"></script'+'>'); -
trunk/LayoutTests/fast/dom/HTMLScriptElement/script-set-src.html
r21591 r36699 31 31 var e3 = document.createElement( "script" ); 32 32 e3.type = "text/javascript"; 33 e3.src = "resources/script-set-src-p 8failBefore.js";33 e3.src = "resources/script-set-src-p9failBefore.js"; 34 34 e3.src = "resources/script-set-src-p9pass.js"; 35 35 document.getElementsByTagName("head")[0].appendChild(e3); … … 44 44 <script type="text/javascript" id="s5" src="resources/script-set-src-p5pass.js"></script> 45 45 <script type="text/javascript" id="s3"></script> 46 <script type="text/javascript" id="s4" ></script>46 <script type="text/javascript" id="s4"/> 47 47 <script type="text/javascript" id="s6"></script> 48 48 </head> -
trunk/WebCore/ChangeLog
r36698 r36699 1 2008-09-19 Nikolas Zimmermann <zimmermann@kde.org> 2 3 Reviewed by Antti & Eric. 4 5 Fixes: https://bugs.webkit.org/show_bug.cgi?id=20372 6 7 Finish HTMLScriptElement / SVGScriptElement unification. 8 SVG <script> support is complete now, full SVGLoad event 9 respecting the influence of the externalResourcesRequired attribute 10 as well as SVGError event support. All other features shared with HTML. 11 12 Tests: fast/dom/HTMLScriptElement/script-reexecution.html 13 svg/dom/SVGScriptElement/script-change-externalResourcesRequired-while-loading.svg 14 svg/dom/SVGScriptElement/script-load-and-error-events.svg 15 svg/dom/SVGScriptElement/script-reexecution.svg 16 svg/dom/SVGScriptElement/script-set-href.svg 17 18 * dom/ScriptElement.cpp: 19 (WebCore::ScriptElementData::ScriptElementData): 20 (WebCore::ScriptElementData::requestScript): 21 * dom/ScriptElement.h: 22 (WebCore::ScriptElementData::haveFiredLoadEvent): 23 (WebCore::ScriptElementData::setHaveFiredLoadEvent): 24 * dom/XMLTokenizer.cpp: 25 (WebCore::XMLTokenizer::notifyFinished): 26 * html/HTMLScriptElement.cpp: 27 (WebCore::HTMLScriptElement::dispatchLoadEvent): 28 * svg/SVGScriptElement.cpp: 29 (WebCore::SVGScriptElement::setCreatedByParser): 30 (WebCore::SVGScriptElement::parseMappedAttribute): 31 (WebCore::SVGScriptElement::svgAttributeChanged): 32 (WebCore::SVGScriptElement::insertedIntoDocument): 33 (WebCore::SVGScriptElement::removedFromDocument): 34 (WebCore::SVGScriptElement::childrenChanged): 35 (WebCore::SVGScriptElement::isURLAttribute): 36 (WebCore::SVGScriptElement::finishParsingChildren): 37 (WebCore::SVGScriptElement::type): 38 (WebCore::SVGScriptElement::setType): 39 (WebCore::SVGScriptElement::haveLoadedRequiredResources): 40 (WebCore::SVGScriptElement::dispatchLoadEvent): 41 (WebCore::SVGScriptElement::dispatchErrorEvent): 42 * svg/SVGScriptElement.h: 43 1 44 2008-09-19 Dan Bernstein <mitz@apple.com> 2 45 -
trunk/WebCore/dom/ScriptElement.cpp
r35744 r36699 119 119 , m_createdByParser(false) 120 120 , m_evaluated(false) 121 , m_firedLoad(false) 121 122 { 122 123 ASSERT(m_scriptElement); … … 141 142 ASSERT(!m_cachedScript); 142 143 m_cachedScript = document->docLoader()->requestScript(sourceUrl, scriptCharset()); 144 145 // m_createdByParser is never reset - always resied at the initial value set while parsing. 146 // m_evaluated is left untouched as well to avoid script reexecution, if a <script> element 147 // is removed and reappended to the document. 148 m_firedLoad = false; 143 149 144 150 if (m_cachedScript) { -
trunk/WebCore/dom/ScriptElement.h
r36109 r36699 71 71 bool createdByParser() const { return m_createdByParser; } 72 72 void setCreatedByParser(bool value) { m_createdByParser = value; } 73 bool haveFiredLoadEvent() const { return m_firedLoad; } 74 void setHaveFiredLoadEvent(bool firedLoad) { m_firedLoad = firedLoad; } 73 75 74 76 void requestScript(const String& sourceUrl); … … 85 87 bool m_createdByParser; 86 88 bool m_evaluated; 89 bool m_firedLoad; 87 90 }; 88 91 -
trunk/WebCore/dom/XMLTokenizer.cpp
r36630 r36699 34 34 #include "DocumentFragment.h" 35 35 #include "DocumentType.h" 36 #include "EventNames.h"37 36 #include "Frame.h" 38 37 #include "FrameLoader.h" … … 65 64 namespace WebCore { 66 65 67 using namespace EventNames;68 69 66 const int maxErrors = 25; 70 67 … … 318 315 RefPtr<Element> e = m_scriptElement; 319 316 m_scriptElement = 0; 320 317 318 ScriptElement* scriptElement = castToScriptElement(e.get()); 319 ASSERT(scriptElement); 320 321 321 if (errorOccurred) 322 EventTargetNodeCast(e.get())->dispatchEventForType(errorEvent, true, false);322 scriptElement->dispatchErrorEvent(); 323 323 else { 324 324 m_view->frame()->loader()->executeScript(cachedScriptUrl, 1, scriptSource); 325 EventTargetNodeCast(e.get())->dispatchEventForType(loadEvent, false, false);325 scriptElement->dispatchLoadEvent(); 326 326 } 327 327 -
trunk/WebCore/html/HTMLScriptElement.cpp
r36466 r36699 215 215 void HTMLScriptElement::dispatchLoadEvent() 216 216 { 217 ASSERT(!m_data.haveFiredLoadEvent()); 218 m_data.setHaveFiredLoadEvent(true); 219 217 220 dispatchEventForType(loadEvent, false, false); 218 221 } -
trunk/WebCore/svg/SVGScriptElement.cpp
r35744 r36699 25 25 #if ENABLE(SVG) 26 26 #include "SVGScriptElement.h" 27 28 #include "EventNames.h" 27 29 #include "SVGNames.h" 28 30 … … 41 43 } 42 44 43 String SVGScriptElement::type() const 44 { 45 return m_type; 46 } 47 48 void SVGScriptElement::setType(const String& type) 49 { 50 m_type = type; 45 void SVGScriptElement::setCreatedByParser(bool createdByParser) 46 { 47 m_data.setCreatedByParser(createdByParser); 51 48 } 52 49 … … 58 55 void SVGScriptElement::parseMappedAttribute(MappedAttribute* attr) 59 56 { 60 if (attr->name() == SVGNames::typeAttr) 57 const QualifiedName& attrName = attr->name(); 58 59 if (attrName == SVGNames::typeAttr) 61 60 setType(attr->value()); 62 61 else { … … 70 69 } 71 70 71 void SVGScriptElement::svgAttributeChanged(const QualifiedName& attrName) 72 { 73 SVGElement::svgAttributeChanged(attrName); 74 75 if (SVGURIReference::isKnownAttribute(attrName)) 76 handleSourceAttribute(m_data, href()); 77 else if (SVGExternalResourcesRequired::isKnownAttribute(attrName)) { 78 // Handle dynamic updates of the 'externalResourcesRequired' attribute. Only possible case: changing from 'true' to 'false' 79 // causes an immediate dispatch of the SVGLoad event. If the attribute value was 'false' before inserting the script element 80 // in the document, the SVGLoad event has already been dispatched. 81 if (!externalResourcesRequiredBaseValue() && !m_data.haveFiredLoadEvent() && !m_data.createdByParser()) { 82 m_data.setHaveFiredLoadEvent(true); 83 ASSERT(haveLoadedRequiredResources()); 84 85 sendSVGLoadEventIfPossible(); 86 } 87 } 88 } 89 90 void SVGScriptElement::insertedIntoDocument() 91 { 92 SVGElement::insertedIntoDocument(); 93 ScriptElement::insertedIntoDocument(m_data, sourceAttributeValue()); 94 95 if (m_data.createdByParser()) 96 return; 97 98 // Eventually send SVGLoad event now for the dynamically inserted script element 99 if (!externalResourcesRequiredBaseValue()) { 100 m_data.setHaveFiredLoadEvent(true); 101 sendSVGLoadEventIfPossible(); 102 } 103 } 104 105 void SVGScriptElement::removedFromDocument() 106 { 107 SVGElement::removedFromDocument(); 108 ScriptElement::removedFromDocument(m_data); 109 } 110 111 void SVGScriptElement::childrenChanged(bool changedByParser, Node* beforeChange, Node* afterChange, int childCountDelta) 112 { 113 ScriptElement::childrenChanged(m_data); 114 SVGElement::childrenChanged(changedByParser, beforeChange, afterChange, childCountDelta); 115 } 116 117 bool SVGScriptElement::isURLAttribute(Attribute* attr) const 118 { 119 return attr->name() == sourceAttributeValue(); 120 } 121 122 void SVGScriptElement::finishParsingChildren() 123 { 124 ScriptElement::finishParsingChildren(m_data, sourceAttributeValue()); 125 SVGElement::finishParsingChildren(); 126 127 // A SVGLoad event has been fired by SVGElement::finishParsingChildren. 128 if (!externalResourcesRequiredBaseValue()) 129 m_data.setHaveFiredLoadEvent(true); 130 } 131 132 String SVGScriptElement::type() const 133 { 134 return m_type; 135 } 136 137 void SVGScriptElement::setType(const String& type) 138 { 139 m_type = type; 140 } 141 72 142 void SVGScriptElement::getSubresourceAttributeStrings(Vector<String>& urls) const 73 143 { … … 75 145 } 76 146 147 bool SVGScriptElement::haveLoadedRequiredResources() 148 { 149 return !externalResourcesRequiredBaseValue() || m_data.haveFiredLoadEvent(); 150 } 151 77 152 String SVGScriptElement::sourceAttributeValue() const 78 153 { … … 97 172 void SVGScriptElement::dispatchLoadEvent() 98 173 { 99 // TODO! 100 // dispatchSVGEvent(loadEvent, false, false); 174 bool externalResourcesRequired = externalResourcesRequiredBaseValue(); 175 176 if (m_data.createdByParser()) 177 ASSERT(externalResourcesRequired != m_data.haveFiredLoadEvent()); 178 else if (m_data.haveFiredLoadEvent()) { 179 // If we've already fired an load event and externalResourcesRequired is set to 'true' 180 // externalResourcesRequired has been modified while loading the <script>. Don't dispatch twice. 181 if (externalResourcesRequired) 182 return; 183 } 184 185 // HTML and SVG differ completly in the 'onload' event handling of <script> elements. 186 // HTML fires the 'load' event after it sucessfully loaded a remote resource, otherwhise an error event. 187 // SVG fires the SVGLoad event immediately after parsing the <script> element, if externalResourcesRequired 188 // is set to 'false', otherwhise it dispatches the 'SVGLoad' event just after loading the remote resource. 189 if (externalResourcesRequired) { 190 ASSERT(!m_data.haveFiredLoadEvent()); 191 192 // Dispatch SVGLoad event 193 m_data.setHaveFiredLoadEvent(true); 194 ASSERT(haveLoadedRequiredResources()); 195 196 sendSVGLoadEventIfPossible(); 197 } 101 198 } 102 199 103 200 void SVGScriptElement::dispatchErrorEvent() 104 201 { 105 // TODO!106 // dispatchSVGEvent(errorEvent, true, false); 107 } 202 dispatchEventForType(EventNames::errorEvent, true, false); 203 } 204 108 205 } 109 206 -
trunk/WebCore/svg/SVGScriptElement.h
r35744 r36699 40 40 virtual ~SVGScriptElement(); 41 41 42 void setCreatedByParser(bool) { }42 void setCreatedByParser(bool); 43 43 virtual String scriptContent() const; 44 45 virtual void parseMappedAttribute(MappedAttribute*); 46 virtual void insertedIntoDocument(); 47 virtual void removedFromDocument(); 48 virtual void childrenChanged(bool changedByParser = false, Node* beforeChange = 0, Node* afterChange = 0, int childCountDelta = 0); 49 50 virtual void svgAttributeChanged(const QualifiedName&); 51 virtual bool isURLAttribute(Attribute*) const; 52 virtual void finishParsingChildren(); 44 53 45 54 String type() const; 46 55 void setType(const String&); 47 56 48 virtual void parseMappedAttribute(MappedAttribute *attr);49 57 virtual void getSubresourceAttributeStrings(Vector<String>&) const; 50 58 51 59 protected: 52 60 virtual const SVGElement* contextElement() const { return this; } 61 virtual bool haveLoadedRequiredResources(); 53 62 54 63 virtual String sourceAttributeValue() const;
Note: See TracChangeset
for help on using the changeset viewer.