Changeset 81198 in webkit
- Timestamp:
- Mar 15, 2011 5:00:09 PM (13 years ago)
- Location:
- trunk
- Files:
-
- 5 added
- 20 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r81195 r81198 1 2011-03-15 James Simonsen <simonjam@chromium.org> 2 3 Reviewed by Tony Gentilcore. 4 5 Need different behavior for ensuring execution order of dynamically loaded scripts 6 https://bugs.webkit.org/show_bug.cgi?id=50115 7 8 Dynamically added scripts with async=false will load in parallel, but execute in order. 9 See: http://www.whatwg.org/specs/web-apps/current-work/multipage/scripting-1.html#force-async 10 11 * fast/dom/HTMLScriptElement/script-async-attr-expected.txt: Added test cases for forceAsync. 12 * fast/dom/HTMLScriptElement/script-async-attr.html: Ditto. 13 * http/tests/misc/script-async-load-execute-in-order-expected.txt: Added. 14 * http/tests/misc/script-async-load-execute-in-order.html: Added. 15 1 16 2011-03-15 Martin Robinson <mrobinson@igalia.com> 2 17 -
trunk/LayoutTests/fast/dom/HTMLScriptElement/script-async-attr-expected.txt
r61518 r81198 9 9 PASS isAsync('s3') is true 10 10 PASS isAsync('s4') is true 11 PASS isAsync('s5') is true 12 PASS isAsync('s6') is true 13 PASS isAsync('s7') is true 14 PASS isAsync('s8') is false 11 15 PASS isDynamicallyInsertedScriptAsync(true) is true 12 16 PASS isDynamicallyInsertedScriptAsync(false) is false 17 PASS isDynamicallyInsertedScriptAsync("async") is true 18 PASS isDynamicallyInsertedScriptAsync(null) is true 13 19 PASS successfullyParsed is true 14 20 -
trunk/LayoutTests/fast/dom/HTMLScriptElement/script-async-attr.html
r61518 r81198 13 13 <script id="s3" src="ignored.js" async="ASYNC"></script> 14 14 <script id="s4" src="ignored.js" async="true"></script> 15 <script id="s5" src="ignored.js" async="false"></script> 16 <script id="s6"></script> 17 <script id="s7" async></script> 18 <script id="s8" async></script> 15 19 16 20 <script> 17 21 description('This test checks for proper parsing of the async attribute on HTML script tags.'); 18 22 19 var nextScriptID = 0;23 var nextScriptID = 9; 20 24 21 25 function isAsync(id) … … 30 34 script.id = id; 31 35 script.src = "resources/script-load.js"; 32 if (async )33 script.async = "async";36 if (async != null) 37 script.async = async; 34 38 document.getElementsByTagName("head")[0].appendChild(script); 35 39 return isAsync(id); 36 40 } 41 42 document.getElementById("s8").removeAttribute("async"); 37 43 38 44 shouldBeFalse("isAsync('s0')"); … … 41 47 shouldBeTrue("isAsync('s3')"); 42 48 shouldBeTrue("isAsync('s4')"); 49 shouldBeTrue("isAsync('s5')"); 50 shouldBeTrue("isAsync('s6')"); 51 shouldBeTrue("isAsync('s7')"); 52 shouldBeFalse("isAsync('s8')"); 43 53 shouldBeTrue("isDynamicallyInsertedScriptAsync(true)"); 44 54 shouldBeFalse("isDynamicallyInsertedScriptAsync(false)"); 55 shouldBeTrue("isDynamicallyInsertedScriptAsync(\"async\")"); 56 shouldBeTrue("isDynamicallyInsertedScriptAsync(null)"); 45 57 46 58 var successfullyParsed = true; -
trunk/Source/WebCore/Android.mk
r80900 r81198 96 96 \ 97 97 dom/ActiveDOMObject.cpp \ 98 dom/AsyncScriptRunner.cpp \99 98 dom/Attr.cpp \ 100 99 dom/Attribute.cpp \ … … 173 172 dom/ScriptElement.cpp \ 174 173 dom/ScriptExecutionContext.cpp \ 174 dom/ScriptRunner.cpp \ 175 175 dom/SelectElement.cpp \ 176 176 dom/SelectorNodeList.cpp \ -
trunk/Source/WebCore/CMakeLists.txt
r80929 r81198 689 689 690 690 dom/ActiveDOMObject.cpp 691 dom/AsyncScriptRunner.cpp692 691 dom/Attr.cpp 693 692 dom/Attribute.cpp … … 770 769 dom/ScriptElement.cpp 771 770 dom/ScriptExecutionContext.cpp 771 dom/ScriptRunner.cpp 772 772 dom/SelectElement.cpp 773 773 dom/SelectorNodeList.cpp -
trunk/Source/WebCore/ChangeLog
r81194 r81198 1 2011-03-15 James Simonsen <simonjam@chromium.org> 2 3 Reviewed by Tony Gentilcore. 4 5 Need different behavior for ensuring execution order of dynamically loaded scripts 6 https://bugs.webkit.org/show_bug.cgi?id=50115 7 8 Dynamically added scripts with async=false will load in parallel, but execute in order. 9 See: http://www.whatwg.org/specs/web-apps/current-work/multipage/scripting-1.html#force-async 10 11 Tests: fast/dom/HTMLScriptElement/script-async-attr.html 12 http/tests/misc/script-async-load-execute-in-order.html 13 14 * Android.mk: Rename AsyncScriptRunner -> ScriptRunner. 15 * CMakeLists.txt: Ditto. 16 * GNUmakefile.am: Ditto. 17 * WebCore.gypi: Ditto. 18 * WebCore.pro: Ditto. 19 * WebCore.vcproj/WebCore.vcproj: Ditto. 20 * WebCore.xcodeproj/project.pbxproj: Ditto. 21 * dom/DOMAllInOne.cpp: Ditto. 22 * dom/Document.cpp: 23 (WebCore::Document::Document): Ditto. 24 (WebCore::Document::~Document): Ditto. 25 * dom/Document.h: 26 (WebCore::Document::scriptRunner): Ditto. 27 * dom/ScriptElement.cpp: 28 (WebCore::ScriptElement::ScriptElement): Added forceAsync and willExecuteInOrder. 29 (WebCore::ScriptElement::handleAsyncAttribute): Called by HTMLScriptElement when async attribute changes. 30 (WebCore::ScriptElement::prepareScript): Added support for forceAsync. 31 (WebCore::ScriptElement::notifyFinished): Tell ScriptRunner to execute in order if needed. 32 * dom/ScriptElement.h: 33 (WebCore::ScriptElement::forceAsync): Added. 34 * dom/ScriptRunner.cpp: Renamed from Source/WebCore/dom/AsyncScriptRunner.cpp. 35 (WebCore::ScriptRunner::ScriptRunner): Added in-order script queue. 36 (WebCore::ScriptRunner::~ScriptRunner): Ditto. 37 (WebCore::ScriptRunner::executeScriptSoon): 38 (WebCore::ScriptRunner::queueScriptForInOrderExecution): Added. 39 (WebCore::ScriptRunner::suspend): 40 (WebCore::ScriptRunner::resume): 41 (WebCore::ScriptRunner::timerFired): Execute in-order scripts if ready. 42 * dom/ScriptRunner.h: Renamed from Source/WebCore/dom/AsyncScriptRunner.h. 43 (WebCore::ScriptRunner::create): 44 (WebCore::ScriptRunner::hasPendingScripts): Check for in-order scripts too. 45 * html/HTMLScriptElement.cpp: 46 (WebCore::HTMLScriptElement::attributeChanged): Notify ScriptElement when async changes. 47 (WebCore::HTMLScriptElement::setAsync): Ditto. 48 (WebCore::HTMLScriptElement::async): Include forceAsync in calculation. 49 * html/HTMLScriptElement.h: 50 * html/HTMLScriptElement.idl: Removed Reflect from async for custom behavior. 51 * page/PageGroupLoadDeferrer.cpp: 52 (WebCore::PageGroupLoadDeferrer::PageGroupLoadDeferrer): Rename AsyncScriptRunner -> ScriptRunner. 53 (WebCore::PageGroupLoadDeferrer::~PageGroupLoadDeferrer): Ditto. 54 1 55 2011-03-15 Tony Chang <tony@chromium.org> 2 56 -
trunk/Source/WebCore/GNUmakefile.am
r81166 r81198 1118 1118 Source/WebCore/dom/ActiveDOMObject.cpp \ 1119 1119 Source/WebCore/dom/ActiveDOMObject.h \ 1120 Source/WebCore/dom/AsyncScriptRunner.cpp \1121 Source/WebCore/dom/AsyncScriptRunner.h \1122 1120 Source/WebCore/dom/Attr.cpp \ 1123 1121 Source/WebCore/dom/Attr.h \ … … 1309 1307 Source/WebCore/dom/ScriptExecutionContext.cpp \ 1310 1308 Source/WebCore/dom/ScriptExecutionContext.h \ 1309 Source/WebCore/dom/ScriptRunner.cpp \ 1310 Source/WebCore/dom/ScriptRunner.h \ 1311 1311 Source/WebCore/dom/SelectElement.cpp \ 1312 1312 Source/WebCore/dom/SelectElement.h \ -
trunk/Source/WebCore/WebCore.gypi
r81181 r81198 1379 1379 'dom/ActiveDOMObject.cpp', 1380 1380 'dom/ActiveDOMObject.h', 1381 'dom/AsyncScriptRunner.cpp',1382 'dom/AsyncScriptRunner.h',1383 1381 'dom/Attr.cpp', 1384 1382 'dom/Attr.h', … … 1572 1570 'dom/ScriptExecutionContext.cpp', 1573 1571 'dom/ScriptExecutionContext.h', 1572 'dom/ScriptRunner.cpp', 1573 'dom/ScriptRunner.h', 1574 1574 'dom/ScriptableDocumentParser.cpp', 1575 1575 'dom/ScriptableDocumentParser.h', -
trunk/Source/WebCore/WebCore.pro
r81069 r81198 441 441 css/WebKitCSSTransformValue.cpp \ 442 442 dom/ActiveDOMObject.cpp \ 443 dom/AsyncScriptRunner.cpp \444 443 dom/Attr.cpp \ 445 444 dom/Attribute.cpp \ … … 525 524 dom/ScriptElement.cpp \ 526 525 dom/ScriptExecutionContext.cpp \ 526 dom/ScriptRunner.cpp \ 527 527 dom/SelectElement.cpp \ 528 528 dom/SelectorNodeList.cpp \ -
trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj
r81065 r81198 41687 41687 </File> 41688 41688 <File 41689 RelativePath="..\dom\AsyncScriptRunner.cpp"41690 >41691 <FileConfiguration41692 Name="Debug|Win32"41693 ExcludedFromBuild="true"41694 >41695 <Tool41696 Name="VCCLCompilerTool"41697 />41698 </FileConfiguration>41699 <FileConfiguration41700 Name="Release|Win32"41701 ExcludedFromBuild="true"41702 >41703 <Tool41704 Name="VCCLCompilerTool"41705 />41706 </FileConfiguration>41707 <FileConfiguration41708 Name="Debug_Cairo_CFLite|Win32"41709 ExcludedFromBuild="true"41710 >41711 <Tool41712 Name="VCCLCompilerTool"41713 />41714 </FileConfiguration>41715 <FileConfiguration41716 Name="Release_Cairo_CFLite|Win32"41717 ExcludedFromBuild="true"41718 >41719 <Tool41720 Name="VCCLCompilerTool"41721 />41722 </FileConfiguration>41723 <FileConfiguration41724 Name="Debug_All|Win32"41725 ExcludedFromBuild="true"41726 >41727 <Tool41728 Name="VCCLCompilerTool"41729 />41730 </FileConfiguration>41731 <FileConfiguration41732 Name="Release_LTCG|Win32"41733 ExcludedFromBuild="true"41734 >41735 <Tool41736 Name="VCCLCompilerTool"41737 />41738 </FileConfiguration>41739 </File>41740 <File41741 RelativePath="..\dom\AsyncScriptRunner.h"41742 >41743 </File>41744 <File41745 41689 RelativePath="..\dom\AtomicStringList.h" 41746 41690 > … … 46292 46236 <File 46293 46237 RelativePath="..\dom\ScriptExecutionContext.h" 46238 > 46239 </File> 46240 <File 46241 RelativePath="..\dom\ScriptRunner.cpp" 46242 > 46243 <FileConfiguration 46244 Name="Debug|Win32" 46245 ExcludedFromBuild="true" 46246 > 46247 <Tool 46248 Name="VCCLCompilerTool" 46249 /> 46250 </FileConfiguration> 46251 <FileConfiguration 46252 Name="Release|Win32" 46253 ExcludedFromBuild="true" 46254 > 46255 <Tool 46256 Name="VCCLCompilerTool" 46257 /> 46258 </FileConfiguration> 46259 <FileConfiguration 46260 Name="Debug_Cairo_CFLite|Win32" 46261 ExcludedFromBuild="true" 46262 > 46263 <Tool 46264 Name="VCCLCompilerTool" 46265 /> 46266 </FileConfiguration> 46267 <FileConfiguration 46268 Name="Release_Cairo_CFLite|Win32" 46269 ExcludedFromBuild="true" 46270 > 46271 <Tool 46272 Name="VCCLCompilerTool" 46273 /> 46274 </FileConfiguration> 46275 <FileConfiguration 46276 Name="Debug_All|Win32" 46277 ExcludedFromBuild="true" 46278 > 46279 <Tool 46280 Name="VCCLCompilerTool" 46281 /> 46282 </FileConfiguration> 46283 <FileConfiguration 46284 Name="Release_LTCG|Win32" 46285 ExcludedFromBuild="true" 46286 > 46287 <Tool 46288 Name="VCCLCompilerTool" 46289 /> 46290 </FileConfiguration> 46291 </File> 46292 <File 46293 RelativePath="..\dom\ScriptRunner.h" 46294 46294 > 46295 46295 </File> -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r81173 r81198 2738 2738 8A12E35D11FA33280025836A /* DocumentLoadTiming.h in Headers */ = {isa = PBXBuildFile; fileRef = 8A12E35C11FA33280025836A /* DocumentLoadTiming.h */; settings = {ATTRIBUTES = (Private, ); }; }; 2739 2739 8A309C9F123950BE00CB9204 /* NestingLevelIncrementer.h in Headers */ = {isa = PBXBuildFile; fileRef = 8A309C9E123950BE00CB9204 /* NestingLevelIncrementer.h */; }; 2740 8A413AE01207BBA50082016E /* AsyncScriptRunner.h in Headers */ = {isa = PBXBuildFile; fileRef = 8A413ADE1207BBA50082016E /* AsyncScriptRunner.h */; settings = {ATTRIBUTES = (Private, ); }; };2741 8A413AE11207BBA50082016E /* AsyncScriptRunner.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8A413ADF1207BBA50082016E /* AsyncScriptRunner.cpp */; };2740 8A413AE01207BBA50082016E /* ScriptRunner.h in Headers */ = {isa = PBXBuildFile; fileRef = 8A413ADE1207BBA50082016E /* ScriptRunner.h */; settings = {ATTRIBUTES = (Private, ); }; }; 2741 8A413AE11207BBA50082016E /* ScriptRunner.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8A413ADF1207BBA50082016E /* ScriptRunner.cpp */; }; 2742 2742 8A7CC96B12076D73001D4588 /* PendingScript.h in Headers */ = {isa = PBXBuildFile; fileRef = 8A7CC96A12076D73001D4588 /* PendingScript.h */; settings = {ATTRIBUTES = (Private, ); }; }; 2743 2743 8A7CC97012076F8A001D4588 /* PendingScript.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8A7CC96F12076F8A001D4588 /* PendingScript.cpp */; }; … … 9218 9218 8A12E35C11FA33280025836A /* DocumentLoadTiming.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DocumentLoadTiming.h; sourceTree = "<group>"; }; 9219 9219 8A309C9E123950BE00CB9204 /* NestingLevelIncrementer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = NestingLevelIncrementer.h; path = parser/NestingLevelIncrementer.h; sourceTree = "<group>"; }; 9220 8A413ADE1207BBA50082016E /* AsyncScriptRunner.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AsyncScriptRunner.h; sourceTree = "<group>"; };9221 8A413ADF1207BBA50082016E /* AsyncScriptRunner.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AsyncScriptRunner.cpp; sourceTree = "<group>"; };9220 8A413ADE1207BBA50082016E /* ScriptRunner.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScriptRunner.h; sourceTree = "<group>"; }; 9221 8A413ADF1207BBA50082016E /* ScriptRunner.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ScriptRunner.cpp; sourceTree = "<group>"; }; 9222 9222 8A7CC96A12076D73001D4588 /* PendingScript.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PendingScript.h; sourceTree = "<group>"; }; 9223 9223 8A7CC96F12076F8A001D4588 /* PendingScript.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PendingScript.cpp; sourceTree = "<group>"; }; … … 19078 19078 E1C4DE6D0EA75C650023CCD6 /* ActiveDOMObject.cpp */, 19079 19079 E1C4DE680EA75C1E0023CCD6 /* ActiveDOMObject.h */, 19080 8A413ADF1207BBA50082016E /* AsyncScriptRunner.cpp */,19081 8A413ADE1207BBA50082016E /* AsyncScriptRunner.h */,19082 19080 A8C4A7FC09D563270003AC8D /* Attr.cpp */, 19083 19081 A8C4A7FB09D563270003AC8D /* Attr.h */, … … 19322 19320 E11C9DAF0EB3699500E409DB /* ScriptExecutionContext.cpp */, 19323 19321 E11C9D9A0EB3681200E409DB /* ScriptExecutionContext.h */, 19322 8A413ADF1207BBA50082016E /* ScriptRunner.cpp */, 19323 8A413ADE1207BBA50082016E /* ScriptRunner.h */, 19324 19324 084AEBE20FB505FA0038483E /* SelectElement.cpp */, 19325 19325 084AEBE30FB505FA0038483E /* SelectElement.h */, … … 19680 19680 976D6C93122B8A3D001FD1F7 /* AsyncFileWriterClient.h in Headers */, 19681 19681 B0149E7E11A4B21500196A7B /* AsyncImageResizer.h in Headers */, 19682 8A413AE01207BBA50082016E /* AsyncScriptRunner.h in Headers */,19683 19682 37C61F0112095C87007A3C67 /* AtomicStringKeyedMRUCache.h in Headers */, 19684 19683 A8C4A80D09D563270003AC8D /* Attr.h in Headers */, … … 22058 22057 9FA37EE41172FC8000C4CD55 /* ScriptProfileNode.h in Headers */, 22059 22058 9F72305111184B4100AD0126 /* ScriptProfiler.h in Headers */, 22059 8A413AE01207BBA50082016E /* ScriptRunner.h in Headers */, 22060 22060 934CC10A0EDB223900A658F2 /* ScriptSourceCode.h in Headers */, 22061 22061 CE54FD381016D9A6008B44C8 /* ScriptSourceProvider.h in Headers */, … … 23013 23013 89D08D9F12228451001241DF /* AsyncFileSystem.cpp in Sources */, 23014 23014 B0149E7D11A4B21500196A7B /* AsyncImageResizer.cpp in Sources */, 23015 8A413AE11207BBA50082016E /* AsyncScriptRunner.cpp in Sources */,23016 23015 A8C4A80E09D563270003AC8D /* Attr.cpp in Sources */, 23017 23016 A8C4A80C09D563270003AC8D /* Attribute.cpp in Sources */, … … 24851 24850 F33F0282120947F200E5743A /* ScriptProfile.cpp in Sources */, 24852 24851 9F72305011184B4100AD0126 /* ScriptProfiler.cpp in Sources */, 24852 8A413AE11207BBA50082016E /* ScriptRunner.cpp in Sources */, 24853 24853 4127D5370F8AAB1D00E424F5 /* ScriptState.cpp in Sources */, 24854 24854 934CC0E10ED39D6F00A658F2 /* ScriptValue.cpp in Sources */, -
trunk/Source/WebCore/dom/DOMAllInOne.cpp
r77239 r81198 27 27 28 28 #include "ActiveDOMObject.cpp" 29 #include "AsyncScriptRunner.cpp"30 29 #include "Attr.cpp" 31 30 #include "Attribute.cpp" … … 105 104 #include "ScriptElement.cpp" 106 105 #include "ScriptExecutionContext.cpp" 106 #include "ScriptRunner.cpp" 107 107 #include "ScriptableDocumentParser.cpp" 108 108 #include "SelectElement.cpp" -
trunk/Source/WebCore/dom/Document.cpp
r81185 r81198 30 30 #include "AXObjectCache.h" 31 31 #include "AnimationController.h" 32 #include "AsyncScriptRunner.h"33 32 #include "Attr.h" 34 33 #include "Attribute.h" … … 129 128 #include "ScriptElement.h" 130 129 #include "ScriptEventListener.h" 130 #include "ScriptRunner.h" 131 131 #include "SecurityOrigin.h" 132 132 #include "SegmentedString.h" … … 396 396 , m_overMinimumLayoutThreshold(false) 397 397 , m_extraLayoutDelay(0) 398 , m_ asyncScriptRunner(AsyncScriptRunner::create(this))398 , m_scriptRunner(ScriptRunner::create(this)) 399 399 , m_xmlVersion("1.0") 400 400 , m_xmlStandalone(false) … … 567 567 ASSERT(!m_styleRecalcTimer.isActive()); 568 568 569 m_ asyncScriptRunner.clear();569 m_scriptRunner.clear(); 570 570 571 571 removeAllEventListeners(); -
trunk/Source/WebCore/dom/Document.h
r81185 r81198 52 52 namespace WebCore { 53 53 54 class AsyncScriptRunner;55 54 class Attr; 56 55 class AXObjectCache; … … 116 115 class ScriptableDocumentParser; 117 116 class ScriptElementData; 117 class ScriptRunner; 118 118 class SecurityOrigin; 119 119 class SerializedScriptValue; … … 903 903 int docID() const { return m_docID; } 904 904 905 AsyncScriptRunner* asyncScriptRunner() { return m_asyncScriptRunner.get(); }905 ScriptRunner* scriptRunner() { return m_scriptRunner.get(); } 906 906 907 907 #if ENABLE(XSLT) … … 1320 1320 int m_extraLayoutDelay; 1321 1321 1322 OwnPtr< AsyncScriptRunner> m_asyncScriptRunner;1322 OwnPtr<ScriptRunner> m_scriptRunner; 1323 1323 1324 1324 #if ENABLE(XSLT) -
trunk/Source/WebCore/dom/ScriptElement.cpp
r79114 r81198 25 25 #include "ScriptElement.h" 26 26 27 #include "AsyncScriptRunner.h"28 27 #include "CachedScript.h" 29 28 #include "CachedResourceLoader.h" … … 38 37 #include "Page.h" 39 38 #include "ScriptController.h" 39 #include "ScriptRunner.h" 40 40 #include "ScriptSourceCode.h" 41 41 #include "ScriptValue.h" … … 62 62 , m_readyToBeParserExecuted(false) 63 63 , m_willExecuteWhenDocumentFinishedParsing(false) 64 , m_forceAsync(!parserInserted) 65 , m_willExecuteInOrder(false) 64 66 { 65 67 ASSERT(m_element); … … 95 97 96 98 prepareScript(); // FIXME: Provide a real starting line number here. 99 } 100 101 void ScriptElement::handleAsyncAttribute() 102 { 103 m_forceAsync = false; 97 104 } 98 105 … … 160 167 wasParserInserted = false; 161 168 162 // FIXME: HTML5 spec says we should set forceAsync. 169 if (wasParserInserted && !asyncAttributeValue()) 170 m_forceAsync = true; 163 171 164 172 // FIXME: HTML5 spec says we should check that all children are either comments or empty text nodes. … … 172 180 return false; 173 181 174 if (wasParserInserted) 182 if (wasParserInserted) { 175 183 m_parserInserted = true; 184 m_forceAsync = false; 185 } 176 186 177 187 m_alreadyStarted = true; … … 208 218 m_willBeParserExecuted = true; 209 219 m_readyToBeParserExecuted = true; 220 } else if (hasSourceAttribute() && !asyncAttributeValue() && !m_forceAsync) { 221 m_willExecuteInOrder = true; 222 m_element->document()->scriptRunner()->queueScriptForExecution(this, m_cachedScript, ScriptRunner::IN_ORDER_EXECUTION); 223 m_cachedScript->addClient(this); 210 224 } else if (hasSourceAttribute()) 211 225 m_cachedScript->addClient(this); … … 287 301 ASSERT(!m_willBeParserExecuted); 288 302 ASSERT_UNUSED(o, o == m_cachedScript); 289 m_element->document()->asyncScriptRunner()->executeScriptSoon(this, m_cachedScript); 303 if (m_willExecuteInOrder) 304 m_element->document()->scriptRunner()->notifyInOrderScriptReady(); 305 else 306 m_element->document()->scriptRunner()->queueScriptForExecution(this, m_cachedScript, ScriptRunner::ASYNC_EXECUTION); 290 307 m_cachedScript = 0; 291 308 } -
trunk/Source/WebCore/dom/ScriptElement.h
r79114 r81198 64 64 bool isParserInserted() const { return m_parserInserted; } 65 65 bool alreadyStarted() const { return m_alreadyStarted; } 66 bool forceAsync() const { return m_forceAsync; } 66 67 67 68 // Helper functions used by our parent classes. … … 70 71 void childrenChanged(); 71 72 void handleSourceAttribute(const String& sourceUrl); 73 void handleAsyncAttribute(); 72 74 73 75 private: … … 99 101 bool m_readyToBeParserExecuted : 1; 100 102 bool m_willExecuteWhenDocumentFinishedParsing : 1; 103 bool m_forceAsync : 1; 104 bool m_willExecuteInOrder : 1; 101 105 String m_characterEncoding; 102 106 String m_fallbackCharacterEncoding; -
trunk/Source/WebCore/dom/ScriptRunner.cpp
-
Property
svn:eol-style
set to
LF
r81195 r81198 25 25 26 26 #include "config.h" 27 #include " AsyncScriptRunner.h"27 #include "ScriptRunner.h" 28 28 29 29 #include "CachedScript.h" … … 35 35 namespace WebCore { 36 36 37 AsyncScriptRunner::AsyncScriptRunner(Document* document)37 ScriptRunner::ScriptRunner(Document* document) 38 38 : m_document(document) 39 , m_timer(this, & AsyncScriptRunner::timerFired)39 , m_timer(this, &ScriptRunner::timerFired) 40 40 { 41 41 ASSERT(document); 42 42 } 43 43 44 AsyncScriptRunner::~AsyncScriptRunner()44 ScriptRunner::~ScriptRunner() 45 45 { 46 46 for (size_t i = 0; i < m_scriptsToExecuteSoon.size(); ++i) 47 47 m_document->decrementLoadEventDelayCount(); 48 for (size_t i = 0; i < m_scriptsToExecuteInOrder.size(); ++i) 49 m_document->decrementLoadEventDelayCount(); 48 50 } 49 51 50 void AsyncScriptRunner::executeScriptSoon(ScriptElement* scriptElement, CachedResourceHandle<CachedScript> cachedScript)52 void ScriptRunner::queueScriptForExecution(ScriptElement* scriptElement, CachedResourceHandle<CachedScript> cachedScript, ExecutionType executionType) 51 53 { 52 ASSERT _ARG(scriptElement,scriptElement);54 ASSERT(scriptElement); 53 55 54 56 Element* element = scriptElement->element(); … … 57 59 58 60 m_document->incrementLoadEventDelayCount(); 59 m_scriptsToExecuteSoon.append(PendingScript(element, cachedScript.get())); 60 if (!m_timer.isActive()) 61 m_timer.startOneShot(0); 61 62 switch (executionType) { 63 case ASYNC_EXECUTION: 64 m_scriptsToExecuteSoon.append(PendingScript(element, cachedScript.get())); 65 if (!m_timer.isActive()) 66 m_timer.startOneShot(0); 67 break; 68 69 case IN_ORDER_EXECUTION: 70 m_scriptsToExecuteInOrder.append(PendingScript(element, cachedScript.get())); 71 break; 72 73 default: 74 ASSERT_NOT_REACHED(); 75 } 62 76 } 63 77 64 void AsyncScriptRunner::suspend()78 void ScriptRunner::suspend() 65 79 { 66 80 m_timer.stop(); 67 81 } 68 82 69 void AsyncScriptRunner::resume()83 void ScriptRunner::resume() 70 84 { 71 85 if (hasPendingScripts()) … … 73 87 } 74 88 75 void AsyncScriptRunner::timerFired(Timer<AsyncScriptRunner>* timer) 89 void ScriptRunner::notifyInOrderScriptReady() 90 { 91 ASSERT(!m_scriptsToExecuteInOrder.isEmpty()); 92 m_timer.startOneShot(0); 93 } 94 95 void ScriptRunner::timerFired(Timer<ScriptRunner>* timer) 76 96 { 77 97 ASSERT_UNUSED(timer, timer == &m_timer); 78 98 79 99 RefPtr<Document> protect(m_document); 80 100 81 101 Vector<PendingScript> scripts; 82 102 scripts.swap(m_scriptsToExecuteSoon); 103 104 size_t numInOrderScriptsToExecute = 0; 105 for (; numInOrderScriptsToExecute < m_scriptsToExecuteInOrder.size() && m_scriptsToExecuteInOrder[numInOrderScriptsToExecute].cachedScript()->isLoaded(); ++numInOrderScriptsToExecute) 106 scripts.append(m_scriptsToExecuteInOrder[numInOrderScriptsToExecute]); 107 if (numInOrderScriptsToExecute) 108 m_scriptsToExecuteInOrder.remove(0, numInOrderScriptsToExecute); 109 83 110 size_t size = scripts.size(); 84 111 for (size_t i = 0; i < size; ++i) { -
Property
svn:eol-style
set to
-
trunk/Source/WebCore/dom/ScriptRunner.h
-
Property
svn:eol-style
set to
LF
r81195 r81198 24 24 */ 25 25 26 #ifndef AsyncScriptRunner_h27 #define AsyncScriptRunner_h26 #ifndef ScriptRunner_h 27 #define ScriptRunner_h 28 28 29 29 #include "CachedResourceHandle.h" … … 39 39 class PendingScript; 40 40 class ScriptElement; 41 42 class AsyncScriptRunner {43 WTF_MAKE_NONCOPYABLE( AsyncScriptRunner); WTF_MAKE_FAST_ALLOCATED;41 42 class ScriptRunner { 43 WTF_MAKE_NONCOPYABLE(ScriptRunner); WTF_MAKE_FAST_ALLOCATED; 44 44 public: 45 static PassOwnPtr< AsyncScriptRunner> create(Document* document) { return new AsyncScriptRunner(document); }46 ~ AsyncScriptRunner();45 static PassOwnPtr<ScriptRunner> create(Document* document) { return new ScriptRunner(document); } 46 ~ScriptRunner(); 47 47 48 void executeScriptSoon(ScriptElement*, CachedResourceHandle<CachedScript>); 49 bool hasPendingScripts() const { return !m_scriptsToExecuteSoon.isEmpty(); } 48 enum ExecutionType { ASYNC_EXECUTION, IN_ORDER_EXECUTION }; 49 void queueScriptForExecution(ScriptElement*, CachedResourceHandle<CachedScript>, ExecutionType); 50 bool hasPendingScripts() const { return !m_scriptsToExecuteSoon.isEmpty() || !m_scriptsToExecuteInOrder.isEmpty(); } 50 51 void suspend(); 51 52 void resume(); 53 void notifyInOrderScriptReady(); 52 54 53 55 private: 54 AsyncScriptRunner(Document*);56 ScriptRunner(Document*); 55 57 56 void timerFired(Timer< AsyncScriptRunner>*);58 void timerFired(Timer<ScriptRunner>*); 57 59 58 60 Document* m_document; 61 Vector<PendingScript> m_scriptsToExecuteInOrder; 59 62 Vector<PendingScript> m_scriptsToExecuteSoon; // http://www.whatwg.org/specs/web-apps/current-work/#set-of-scripts-that-will-execute-as-soon-as-possible 60 Timer< AsyncScriptRunner> m_timer;63 Timer<ScriptRunner> m_timer; 61 64 }; 62 65 -
Property
svn:eol-style
set to
-
trunk/Source/WebCore/html/HTMLScriptElement.cpp
r79114 r81198 59 59 } 60 60 61 void HTMLScriptElement::attributeChanged(Attribute* attr, bool preserveDecls) 62 { 63 if (attr->name() == asyncAttr) 64 handleAsyncAttribute(); 65 HTMLElement::attributeChanged(attr, preserveDecls); 66 } 67 61 68 void HTMLScriptElement::parseMappedAttribute(Attribute* attr) 62 69 { … … 101 108 102 109 appendChild(document()->createTextNode(value.impl()), ec); 110 } 111 112 void HTMLScriptElement::setAsync(bool async) 113 { 114 setBooleanAttribute(asyncAttr, async); 115 handleAsyncAttribute(); 116 } 117 118 bool HTMLScriptElement::async() const 119 { 120 return fastHasAttribute(asyncAttr) || forceAsync(); 103 121 } 104 122 -
trunk/Source/WebCore/html/HTMLScriptElement.h
r79114 r81198 39 39 KURL src() const; 40 40 41 void setAsync(bool); 42 bool async() const; 43 41 44 private: 42 45 HTMLScriptElement(const QualifiedName&, Document*, bool wasInsertedByParser, bool alreadyStarted); … … 46 49 virtual void removedFromDocument(); 47 50 virtual void childrenChanged(bool changedByParser = false, Node* beforeChange = 0, Node* afterChange = 0, int childCountDelta = 0); 51 virtual void attributeChanged(Attribute*, bool preserveDecls = false); 48 52 49 53 virtual bool isURLAttribute(Attribute*) const; -
trunk/Source/WebCore/html/HTMLScriptElement.idl
r66327 r81198 25 25 attribute [Reflect] DOMString event; 26 26 attribute [Reflect] DOMString charset; 27 attribute [Reflect]boolean async;27 attribute boolean async; 28 28 attribute [Reflect] boolean defer; 29 29 attribute [Reflect, URL] DOMString src; -
trunk/Source/WebCore/page/PageGroupLoadDeferrer.cpp
r80718 r81198 22 22 #include "PageGroupLoadDeferrer.h" 23 23 24 #include "AsyncScriptRunner.h"25 24 #include "DocumentParser.h" 26 25 #include "Frame.h" 27 26 #include "Page.h" 28 27 #include "PageGroup.h" 28 #include "ScriptRunner.h" 29 29 #include <wtf/HashSet.h> 30 30 … … 51 51 frame->document()->suspendScriptedAnimationControllerCallbacks(); 52 52 frame->document()->suspendActiveDOMObjects(ActiveDOMObject::WillShowDialog); 53 frame->document()-> asyncScriptRunner()->suspend();53 frame->document()->scriptRunner()->suspend(); 54 54 if (DocumentParser* parser = frame->document()->parser()) 55 55 parser->suspendScheduledTasks(); … … 74 74 frame->document()->resumeActiveDOMObjects(); 75 75 frame->document()->resumeScriptedAnimationControllerCallbacks(); 76 frame->document()-> asyncScriptRunner()->resume();76 frame->document()->scriptRunner()->resume(); 77 77 if (DocumentParser* parser = frame->document()->parser()) 78 78 parser->resumeScheduledTasks();
Note: See TracChangeset
for help on using the changeset viewer.