Changeset 81198 in webkit


Ignore:
Timestamp:
Mar 15, 2011 5:00:09 PM (13 years ago)
Author:
simonjam@chromium.org
Message:

2011-03-15 James Simonsen <simonjam@chromium.org>

Reviewed by Tony Gentilcore.

Need different behavior for ensuring execution order of dynamically loaded scripts
https://bugs.webkit.org/show_bug.cgi?id=50115

Dynamically added scripts with async=false will load in parallel, but execute in order.
See: http://www.whatwg.org/specs/web-apps/current-work/multipage/scripting-1.html#force-async

  • fast/dom/HTMLScriptElement/script-async-attr-expected.txt: Added test cases for forceAsync.
  • fast/dom/HTMLScriptElement/script-async-attr.html: Ditto.
  • http/tests/misc/script-async-load-execute-in-order-expected.txt: Added.
  • http/tests/misc/script-async-load-execute-in-order.html: Added.

2011-03-15 James Simonsen <simonjam@chromium.org>

Reviewed by Tony Gentilcore.

Need different behavior for ensuring execution order of dynamically loaded scripts
https://bugs.webkit.org/show_bug.cgi?id=50115

Dynamically added scripts with async=false will load in parallel, but execute in order.
See: http://www.whatwg.org/specs/web-apps/current-work/multipage/scripting-1.html#force-async

Tests: fast/dom/HTMLScriptElement/script-async-attr.html

http/tests/misc/script-async-load-execute-in-order.html

  • Android.mk: Rename AsyncScriptRunner -> ScriptRunner.
  • CMakeLists.txt: Ditto.
  • GNUmakefile.am: Ditto.
  • WebCore.gypi: Ditto.
  • WebCore.pro: Ditto.
  • WebCore.vcproj/WebCore.vcproj: Ditto.
  • WebCore.xcodeproj/project.pbxproj: Ditto.
  • dom/DOMAllInOne.cpp: Ditto.
  • dom/Document.cpp: (WebCore::Document::Document): Ditto. (WebCore::Document::~Document): Ditto.
  • dom/Document.h: (WebCore::Document::scriptRunner): Ditto.
  • dom/ScriptElement.cpp: (WebCore::ScriptElement::ScriptElement): Added forceAsync and willExecuteInOrder. (WebCore::ScriptElement::handleAsyncAttribute): Called by HTMLScriptElement when async attribute changes. (WebCore::ScriptElement::prepareScript): Added support for forceAsync. (WebCore::ScriptElement::notifyFinished): Tell ScriptRunner to execute in order if needed.
  • dom/ScriptElement.h: (WebCore::ScriptElement::forceAsync): Added.
  • dom/ScriptRunner.cpp: Renamed from Source/WebCore/dom/AsyncScriptRunner.cpp. (WebCore::ScriptRunner::ScriptRunner): Added in-order script queue. (WebCore::ScriptRunner::~ScriptRunner): Ditto. (WebCore::ScriptRunner::executeScriptSoon): (WebCore::ScriptRunner::queueScriptForInOrderExecution): Added. (WebCore::ScriptRunner::suspend): (WebCore::ScriptRunner::resume): (WebCore::ScriptRunner::timerFired): Execute in-order scripts if ready.
  • dom/ScriptRunner.h: Renamed from Source/WebCore/dom/AsyncScriptRunner.h. (WebCore::ScriptRunner::create): (WebCore::ScriptRunner::hasPendingScripts): Check for in-order scripts too.
  • html/HTMLScriptElement.cpp: (WebCore::HTMLScriptElement::attributeChanged): Notify ScriptElement when async changes. (WebCore::HTMLScriptElement::setAsync): Ditto. (WebCore::HTMLScriptElement::async): Include forceAsync in calculation.
  • html/HTMLScriptElement.h:
  • html/HTMLScriptElement.idl: Removed Reflect from async for custom behavior.
  • page/PageGroupLoadDeferrer.cpp: (WebCore::PageGroupLoadDeferrer::PageGroupLoadDeferrer): Rename AsyncScriptRunner -> ScriptRunner. (WebCore::PageGroupLoadDeferrer::~PageGroupLoadDeferrer): Ditto.
Location:
trunk
Files:
5 added
20 edited
2 moved

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r81195 r81198  
     12011-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
    1162011-03-15  Martin Robinson  <mrobinson@igalia.com>
    217
  • trunk/LayoutTests/fast/dom/HTMLScriptElement/script-async-attr-expected.txt

    r61518 r81198  
    99PASS isAsync('s3') is true
    1010PASS isAsync('s4') is true
     11PASS isAsync('s5') is true
     12PASS isAsync('s6') is true
     13PASS isAsync('s7') is true
     14PASS isAsync('s8') is false
    1115PASS isDynamicallyInsertedScriptAsync(true) is true
    1216PASS isDynamicallyInsertedScriptAsync(false) is false
     17PASS isDynamicallyInsertedScriptAsync("async") is true
     18PASS isDynamicallyInsertedScriptAsync(null) is true
    1319PASS successfullyParsed is true
    1420
  • trunk/LayoutTests/fast/dom/HTMLScriptElement/script-async-attr.html

    r61518 r81198  
    1313<script id="s3" src="ignored.js" async="ASYNC"></script>
    1414<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>
    1519
    1620<script>
    1721description('This test checks for proper parsing of the async attribute on HTML script tags.');
    1822
    19 var nextScriptID = 0;
     23var nextScriptID = 9;
    2024
    2125function isAsync(id)
     
    3034    script.id = id;
    3135    script.src = "resources/script-load.js";
    32     if (async)
    33         script.async = "async";
     36    if (async != null)
     37        script.async = async;
    3438    document.getElementsByTagName("head")[0].appendChild(script);
    3539    return isAsync(id);
    3640}
     41
     42document.getElementById("s8").removeAttribute("async");
    3743
    3844shouldBeFalse("isAsync('s0')");
     
    4147shouldBeTrue("isAsync('s3')");
    4248shouldBeTrue("isAsync('s4')");
     49shouldBeTrue("isAsync('s5')");
     50shouldBeTrue("isAsync('s6')");
     51shouldBeTrue("isAsync('s7')");
     52shouldBeFalse("isAsync('s8')");
    4353shouldBeTrue("isDynamicallyInsertedScriptAsync(true)");
    4454shouldBeFalse("isDynamicallyInsertedScriptAsync(false)");
     55shouldBeTrue("isDynamicallyInsertedScriptAsync(\"async\")");
     56shouldBeTrue("isDynamicallyInsertedScriptAsync(null)");
    4557
    4658var successfullyParsed = true;
  • trunk/Source/WebCore/Android.mk

    r80900 r81198  
    9696        \
    9797        dom/ActiveDOMObject.cpp \
    98         dom/AsyncScriptRunner.cpp \
    9998        dom/Attr.cpp \
    10099        dom/Attribute.cpp \
     
    173172        dom/ScriptElement.cpp \
    174173        dom/ScriptExecutionContext.cpp \
     174        dom/ScriptRunner.cpp \
    175175        dom/SelectElement.cpp \
    176176        dom/SelectorNodeList.cpp \
  • trunk/Source/WebCore/CMakeLists.txt

    r80929 r81198  
    689689
    690690    dom/ActiveDOMObject.cpp
    691     dom/AsyncScriptRunner.cpp
    692691    dom/Attr.cpp
    693692    dom/Attribute.cpp
     
    770769    dom/ScriptElement.cpp
    771770    dom/ScriptExecutionContext.cpp
     771    dom/ScriptRunner.cpp
    772772    dom/SelectElement.cpp
    773773    dom/SelectorNodeList.cpp
  • trunk/Source/WebCore/ChangeLog

    r81194 r81198  
     12011-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
    1552011-03-15  Tony Chang  <tony@chromium.org>
    256
  • trunk/Source/WebCore/GNUmakefile.am

    r81166 r81198  
    11181118        Source/WebCore/dom/ActiveDOMObject.cpp \
    11191119        Source/WebCore/dom/ActiveDOMObject.h \
    1120         Source/WebCore/dom/AsyncScriptRunner.cpp \
    1121         Source/WebCore/dom/AsyncScriptRunner.h \
    11221120        Source/WebCore/dom/Attr.cpp \
    11231121        Source/WebCore/dom/Attr.h \
     
    13091307        Source/WebCore/dom/ScriptExecutionContext.cpp \
    13101308        Source/WebCore/dom/ScriptExecutionContext.h \
     1309        Source/WebCore/dom/ScriptRunner.cpp \
     1310        Source/WebCore/dom/ScriptRunner.h \
    13111311        Source/WebCore/dom/SelectElement.cpp \
    13121312        Source/WebCore/dom/SelectElement.h \
  • trunk/Source/WebCore/WebCore.gypi

    r81181 r81198  
    13791379            'dom/ActiveDOMObject.cpp',
    13801380            'dom/ActiveDOMObject.h',
    1381             'dom/AsyncScriptRunner.cpp',
    1382             'dom/AsyncScriptRunner.h',
    13831381            'dom/Attr.cpp',
    13841382            'dom/Attr.h',
     
    15721570            'dom/ScriptExecutionContext.cpp',
    15731571            'dom/ScriptExecutionContext.h',
     1572            'dom/ScriptRunner.cpp',
     1573            'dom/ScriptRunner.h',
    15741574            'dom/ScriptableDocumentParser.cpp',
    15751575            'dom/ScriptableDocumentParser.h',
  • trunk/Source/WebCore/WebCore.pro

    r81069 r81198  
    441441    css/WebKitCSSTransformValue.cpp \
    442442    dom/ActiveDOMObject.cpp \
    443     dom/AsyncScriptRunner.cpp \
    444443    dom/Attr.cpp \
    445444    dom/Attribute.cpp \
     
    525524    dom/ScriptElement.cpp \
    526525    dom/ScriptExecutionContext.cpp \
     526    dom/ScriptRunner.cpp \
    527527    dom/SelectElement.cpp \
    528528    dom/SelectorNodeList.cpp \
  • trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj

    r81065 r81198  
    4168741687                        </File>
    4168841688                        <File
    41689                                 RelativePath="..\dom\AsyncScriptRunner.cpp"
    41690                                 >
    41691                                 <FileConfiguration
    41692                                         Name="Debug|Win32"
    41693                                         ExcludedFromBuild="true"
    41694                                         >
    41695                                         <Tool
    41696                                                 Name="VCCLCompilerTool"
    41697                                         />
    41698                                 </FileConfiguration>
    41699                                 <FileConfiguration
    41700                                         Name="Release|Win32"
    41701                                         ExcludedFromBuild="true"
    41702                                         >
    41703                                         <Tool
    41704                                                 Name="VCCLCompilerTool"
    41705                                         />
    41706                                 </FileConfiguration>
    41707                                 <FileConfiguration
    41708                                         Name="Debug_Cairo_CFLite|Win32"
    41709                                         ExcludedFromBuild="true"
    41710                                         >
    41711                                         <Tool
    41712                                                 Name="VCCLCompilerTool"
    41713                                         />
    41714                                 </FileConfiguration>
    41715                                 <FileConfiguration
    41716                                         Name="Release_Cairo_CFLite|Win32"
    41717                                         ExcludedFromBuild="true"
    41718                                         >
    41719                                         <Tool
    41720                                                 Name="VCCLCompilerTool"
    41721                                         />
    41722                                 </FileConfiguration>
    41723                                 <FileConfiguration
    41724                                         Name="Debug_All|Win32"
    41725                                         ExcludedFromBuild="true"
    41726                                         >
    41727                                         <Tool
    41728                                                 Name="VCCLCompilerTool"
    41729                                         />
    41730                                 </FileConfiguration>
    41731                                 <FileConfiguration
    41732                                         Name="Release_LTCG|Win32"
    41733                                         ExcludedFromBuild="true"
    41734                                         >
    41735                                         <Tool
    41736                                                 Name="VCCLCompilerTool"
    41737                                         />
    41738                                 </FileConfiguration>
    41739                         </File>
    41740                         <File
    41741                                 RelativePath="..\dom\AsyncScriptRunner.h"
    41742                                 >
    41743                         </File>
    41744                         <File
    4174541689                                RelativePath="..\dom\AtomicStringList.h"
    4174641690                                >
     
    4629246236                        <File
    4629346237                                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"
    4629446294                                >
    4629546295                        </File>
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r81173 r81198  
    27382738                8A12E35D11FA33280025836A /* DocumentLoadTiming.h in Headers */ = {isa = PBXBuildFile; fileRef = 8A12E35C11FA33280025836A /* DocumentLoadTiming.h */; settings = {ATTRIBUTES = (Private, ); }; };
    27392739                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 */; };
    27422742                8A7CC96B12076D73001D4588 /* PendingScript.h in Headers */ = {isa = PBXBuildFile; fileRef = 8A7CC96A12076D73001D4588 /* PendingScript.h */; settings = {ATTRIBUTES = (Private, ); }; };
    27432743                8A7CC97012076F8A001D4588 /* PendingScript.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8A7CC96F12076F8A001D4588 /* PendingScript.cpp */; };
     
    92189218                8A12E35C11FA33280025836A /* DocumentLoadTiming.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DocumentLoadTiming.h; sourceTree = "<group>"; };
    92199219                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>"; };
    92229222                8A7CC96A12076D73001D4588 /* PendingScript.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PendingScript.h; sourceTree = "<group>"; };
    92239223                8A7CC96F12076F8A001D4588 /* PendingScript.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PendingScript.cpp; sourceTree = "<group>"; };
     
    1907819078                                E1C4DE6D0EA75C650023CCD6 /* ActiveDOMObject.cpp */,
    1907919079                                E1C4DE680EA75C1E0023CCD6 /* ActiveDOMObject.h */,
    19080                                 8A413ADF1207BBA50082016E /* AsyncScriptRunner.cpp */,
    19081                                 8A413ADE1207BBA50082016E /* AsyncScriptRunner.h */,
    1908219080                                A8C4A7FC09D563270003AC8D /* Attr.cpp */,
    1908319081                                A8C4A7FB09D563270003AC8D /* Attr.h */,
     
    1932219320                                E11C9DAF0EB3699500E409DB /* ScriptExecutionContext.cpp */,
    1932319321                                E11C9D9A0EB3681200E409DB /* ScriptExecutionContext.h */,
     19322                                8A413ADF1207BBA50082016E /* ScriptRunner.cpp */,
     19323                                8A413ADE1207BBA50082016E /* ScriptRunner.h */,
    1932419324                                084AEBE20FB505FA0038483E /* SelectElement.cpp */,
    1932519325                                084AEBE30FB505FA0038483E /* SelectElement.h */,
     
    1968019680                                976D6C93122B8A3D001FD1F7 /* AsyncFileWriterClient.h in Headers */,
    1968119681                                B0149E7E11A4B21500196A7B /* AsyncImageResizer.h in Headers */,
    19682                                 8A413AE01207BBA50082016E /* AsyncScriptRunner.h in Headers */,
    1968319682                                37C61F0112095C87007A3C67 /* AtomicStringKeyedMRUCache.h in Headers */,
    1968419683                                A8C4A80D09D563270003AC8D /* Attr.h in Headers */,
     
    2205822057                                9FA37EE41172FC8000C4CD55 /* ScriptProfileNode.h in Headers */,
    2205922058                                9F72305111184B4100AD0126 /* ScriptProfiler.h in Headers */,
     22059                                8A413AE01207BBA50082016E /* ScriptRunner.h in Headers */,
    2206022060                                934CC10A0EDB223900A658F2 /* ScriptSourceCode.h in Headers */,
    2206122061                                CE54FD381016D9A6008B44C8 /* ScriptSourceProvider.h in Headers */,
     
    2301323013                                89D08D9F12228451001241DF /* AsyncFileSystem.cpp in Sources */,
    2301423014                                B0149E7D11A4B21500196A7B /* AsyncImageResizer.cpp in Sources */,
    23015                                 8A413AE11207BBA50082016E /* AsyncScriptRunner.cpp in Sources */,
    2301623015                                A8C4A80E09D563270003AC8D /* Attr.cpp in Sources */,
    2301723016                                A8C4A80C09D563270003AC8D /* Attribute.cpp in Sources */,
     
    2485124850                                F33F0282120947F200E5743A /* ScriptProfile.cpp in Sources */,
    2485224851                                9F72305011184B4100AD0126 /* ScriptProfiler.cpp in Sources */,
     24852                                8A413AE11207BBA50082016E /* ScriptRunner.cpp in Sources */,
    2485324853                                4127D5370F8AAB1D00E424F5 /* ScriptState.cpp in Sources */,
    2485424854                                934CC0E10ED39D6F00A658F2 /* ScriptValue.cpp in Sources */,
  • trunk/Source/WebCore/dom/DOMAllInOne.cpp

    r77239 r81198  
    2727
    2828#include "ActiveDOMObject.cpp"
    29 #include "AsyncScriptRunner.cpp"
    3029#include "Attr.cpp"
    3130#include "Attribute.cpp"
     
    105104#include "ScriptElement.cpp"
    106105#include "ScriptExecutionContext.cpp"
     106#include "ScriptRunner.cpp"
    107107#include "ScriptableDocumentParser.cpp"
    108108#include "SelectElement.cpp"
  • trunk/Source/WebCore/dom/Document.cpp

    r81185 r81198  
    3030#include "AXObjectCache.h"
    3131#include "AnimationController.h"
    32 #include "AsyncScriptRunner.h"
    3332#include "Attr.h"
    3433#include "Attribute.h"
     
    129128#include "ScriptElement.h"
    130129#include "ScriptEventListener.h"
     130#include "ScriptRunner.h"
    131131#include "SecurityOrigin.h"
    132132#include "SegmentedString.h"
     
    396396    , m_overMinimumLayoutThreshold(false)
    397397    , m_extraLayoutDelay(0)
    398     , m_asyncScriptRunner(AsyncScriptRunner::create(this))
     398    , m_scriptRunner(ScriptRunner::create(this))
    399399    , m_xmlVersion("1.0")
    400400    , m_xmlStandalone(false)
     
    567567    ASSERT(!m_styleRecalcTimer.isActive());
    568568
    569     m_asyncScriptRunner.clear();
     569    m_scriptRunner.clear();
    570570
    571571    removeAllEventListeners();
  • trunk/Source/WebCore/dom/Document.h

    r81185 r81198  
    5252namespace WebCore {
    5353
    54 class AsyncScriptRunner;
    5554class Attr;
    5655class AXObjectCache;
     
    116115class ScriptableDocumentParser;
    117116class ScriptElementData;
     117class ScriptRunner;
    118118class SecurityOrigin;
    119119class SerializedScriptValue;
     
    903903    int docID() const { return m_docID; }
    904904   
    905     AsyncScriptRunner* asyncScriptRunner() { return m_asyncScriptRunner.get(); }
     905    ScriptRunner* scriptRunner() { return m_scriptRunner.get(); }
    906906
    907907#if ENABLE(XSLT)
     
    13201320    int m_extraLayoutDelay;
    13211321   
    1322     OwnPtr<AsyncScriptRunner> m_asyncScriptRunner;
     1322    OwnPtr<ScriptRunner> m_scriptRunner;
    13231323
    13241324#if ENABLE(XSLT)
  • trunk/Source/WebCore/dom/ScriptElement.cpp

    r79114 r81198  
    2525#include "ScriptElement.h"
    2626
    27 #include "AsyncScriptRunner.h"
    2827#include "CachedScript.h"
    2928#include "CachedResourceLoader.h"
     
    3837#include "Page.h"
    3938#include "ScriptController.h"
     39#include "ScriptRunner.h"
    4040#include "ScriptSourceCode.h"
    4141#include "ScriptValue.h"
     
    6262    , m_readyToBeParserExecuted(false)
    6363    , m_willExecuteWhenDocumentFinishedParsing(false)
     64    , m_forceAsync(!parserInserted)
     65    , m_willExecuteInOrder(false)
    6466{
    6567    ASSERT(m_element);
     
    9597
    9698    prepareScript(); // FIXME: Provide a real starting line number here.
     99}
     100
     101void ScriptElement::handleAsyncAttribute()
     102{
     103    m_forceAsync = false;
    97104}
    98105
     
    160167        wasParserInserted = false;
    161168
    162     // FIXME: HTML5 spec says we should set forceAsync.
     169    if (wasParserInserted && !asyncAttributeValue())
     170        m_forceAsync = true;
    163171
    164172    // FIXME: HTML5 spec says we should check that all children are either comments or empty text nodes.
     
    172180        return false;
    173181
    174     if (wasParserInserted)
     182    if (wasParserInserted) {
    175183        m_parserInserted = true;
     184        m_forceAsync = false;
     185    }
    176186
    177187    m_alreadyStarted = true;
     
    208218        m_willBeParserExecuted = true;
    209219        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);
    210224    } else if (hasSourceAttribute())
    211225        m_cachedScript->addClient(this);
     
    287301    ASSERT(!m_willBeParserExecuted);
    288302    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);
    290307    m_cachedScript = 0;
    291308}
  • trunk/Source/WebCore/dom/ScriptElement.h

    r79114 r81198  
    6464    bool isParserInserted() const { return m_parserInserted; }
    6565    bool alreadyStarted() const { return m_alreadyStarted; }
     66    bool forceAsync() const { return m_forceAsync; }
    6667
    6768    // Helper functions used by our parent classes.
     
    7071    void childrenChanged();
    7172    void handleSourceAttribute(const String& sourceUrl);
     73    void handleAsyncAttribute();
    7274
    7375private:
     
    99101    bool m_readyToBeParserExecuted : 1;
    100102    bool m_willExecuteWhenDocumentFinishedParsing : 1;
     103    bool m_forceAsync : 1;
     104    bool m_willExecuteInOrder : 1;
    101105    String m_characterEncoding;
    102106    String m_fallbackCharacterEncoding;
  • trunk/Source/WebCore/dom/ScriptRunner.cpp

    • Property svn:eol-style set to LF
    r81195 r81198  
    2525
    2626#include "config.h"
    27 #include "AsyncScriptRunner.h"
     27#include "ScriptRunner.h"
    2828
    2929#include "CachedScript.h"
     
    3535namespace WebCore {
    3636
    37 AsyncScriptRunner::AsyncScriptRunner(Document* document)
     37ScriptRunner::ScriptRunner(Document* document)
    3838    : m_document(document)
    39     , m_timer(this, &AsyncScriptRunner::timerFired)
     39    , m_timer(this, &ScriptRunner::timerFired)
    4040{
    4141    ASSERT(document);
    4242}
    4343
    44 AsyncScriptRunner::~AsyncScriptRunner()
     44ScriptRunner::~ScriptRunner()
    4545{
    4646    for (size_t i = 0; i < m_scriptsToExecuteSoon.size(); ++i)
    4747        m_document->decrementLoadEventDelayCount();
     48    for (size_t i = 0; i < m_scriptsToExecuteInOrder.size(); ++i)
     49        m_document->decrementLoadEventDelayCount();
    4850}
    4951
    50 void AsyncScriptRunner::executeScriptSoon(ScriptElement* scriptElement, CachedResourceHandle<CachedScript> cachedScript)
     52void ScriptRunner::queueScriptForExecution(ScriptElement* scriptElement, CachedResourceHandle<CachedScript> cachedScript, ExecutionType executionType)
    5153{
    52     ASSERT_ARG(scriptElement, scriptElement);
     54    ASSERT(scriptElement);
    5355
    5456    Element* element = scriptElement->element();
     
    5759
    5860    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    }
    6276}
    6377
    64 void AsyncScriptRunner::suspend()
     78void ScriptRunner::suspend()
    6579{
    6680    m_timer.stop();
    6781}
    6882
    69 void AsyncScriptRunner::resume()
     83void ScriptRunner::resume()
    7084{
    7185    if (hasPendingScripts())
     
    7387}
    7488
    75 void AsyncScriptRunner::timerFired(Timer<AsyncScriptRunner>* timer)
     89void ScriptRunner::notifyInOrderScriptReady()
     90{
     91    ASSERT(!m_scriptsToExecuteInOrder.isEmpty());
     92    m_timer.startOneShot(0);
     93}
     94
     95void ScriptRunner::timerFired(Timer<ScriptRunner>* timer)
    7696{
    7797    ASSERT_UNUSED(timer, timer == &m_timer);
    7898
    7999    RefPtr<Document> protect(m_document);
    80    
     100
    81101    Vector<PendingScript> scripts;
    82102    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
    83110    size_t size = scripts.size();
    84111    for (size_t i = 0; i < size; ++i) {
  • trunk/Source/WebCore/dom/ScriptRunner.h

    • Property svn:eol-style set to LF
    r81195 r81198  
    2424 */
    2525
    26 #ifndef AsyncScriptRunner_h
    27 #define AsyncScriptRunner_h
     26#ifndef ScriptRunner_h
     27#define ScriptRunner_h
    2828
    2929#include "CachedResourceHandle.h"
     
    3939class PendingScript;
    4040class ScriptElement;
    41    
    42 class AsyncScriptRunner {
    43     WTF_MAKE_NONCOPYABLE(AsyncScriptRunner); WTF_MAKE_FAST_ALLOCATED;
     41
     42class ScriptRunner {
     43    WTF_MAKE_NONCOPYABLE(ScriptRunner); WTF_MAKE_FAST_ALLOCATED;
    4444public:
    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();
    4747
    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(); }
    5051    void suspend();
    5152    void resume();
     53    void notifyInOrderScriptReady();
    5254
    5355private:
    54     AsyncScriptRunner(Document*);
     56    ScriptRunner(Document*);
    5557
    56     void timerFired(Timer<AsyncScriptRunner>*);
     58    void timerFired(Timer<ScriptRunner>*);
    5759
    5860    Document* m_document;
     61    Vector<PendingScript> m_scriptsToExecuteInOrder;
    5962    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;
    6164};
    6265
  • trunk/Source/WebCore/html/HTMLScriptElement.cpp

    r79114 r81198  
    5959}
    6060
     61void HTMLScriptElement::attributeChanged(Attribute* attr, bool preserveDecls)
     62{
     63    if (attr->name() == asyncAttr)
     64        handleAsyncAttribute();
     65    HTMLElement::attributeChanged(attr, preserveDecls);
     66}
     67
    6168void HTMLScriptElement::parseMappedAttribute(Attribute* attr)
    6269{
     
    101108
    102109    appendChild(document()->createTextNode(value.impl()), ec);
     110}
     111
     112void HTMLScriptElement::setAsync(bool async)
     113{
     114    setBooleanAttribute(asyncAttr, async);
     115    handleAsyncAttribute();
     116}
     117
     118bool HTMLScriptElement::async() const
     119{
     120    return fastHasAttribute(asyncAttr) || forceAsync();
    103121}
    104122
  • trunk/Source/WebCore/html/HTMLScriptElement.h

    r79114 r81198  
    3939    KURL src() const;
    4040
     41    void setAsync(bool);
     42    bool async() const;
     43
    4144private:
    4245    HTMLScriptElement(const QualifiedName&, Document*, bool wasInsertedByParser, bool alreadyStarted);
     
    4649    virtual void removedFromDocument();
    4750    virtual void childrenChanged(bool changedByParser = false, Node* beforeChange = 0, Node* afterChange = 0, int childCountDelta = 0);
     51    virtual void attributeChanged(Attribute*, bool preserveDecls = false);
    4852
    4953    virtual bool isURLAttribute(Attribute*) const;
  • trunk/Source/WebCore/html/HTMLScriptElement.idl

    r66327 r81198  
    2525        attribute [Reflect] DOMString event;
    2626        attribute [Reflect] DOMString charset;
    27         attribute [Reflect] boolean async;
     27        attribute boolean async;
    2828        attribute [Reflect] boolean defer;
    2929        attribute [Reflect, URL] DOMString src;
  • trunk/Source/WebCore/page/PageGroupLoadDeferrer.cpp

    r80718 r81198  
    2222#include "PageGroupLoadDeferrer.h"
    2323
    24 #include "AsyncScriptRunner.h"
    2524#include "DocumentParser.h"
    2625#include "Frame.h"
    2726#include "Page.h"
    2827#include "PageGroup.h"
     28#include "ScriptRunner.h"
    2929#include <wtf/HashSet.h>
    3030
     
    5151                    frame->document()->suspendScriptedAnimationControllerCallbacks();
    5252                    frame->document()->suspendActiveDOMObjects(ActiveDOMObject::WillShowDialog);
    53                     frame->document()->asyncScriptRunner()->suspend();
     53                    frame->document()->scriptRunner()->suspend();
    5454                    if (DocumentParser* parser = frame->document()->parser())
    5555                        parser->suspendScheduledTasks();
     
    7474                frame->document()->resumeActiveDOMObjects();
    7575                frame->document()->resumeScriptedAnimationControllerCallbacks();
    76                 frame->document()->asyncScriptRunner()->resume();
     76                frame->document()->scriptRunner()->resume();
    7777                if (DocumentParser* parser = frame->document()->parser())
    7878                    parser->resumeScheduledTasks();
Note: See TracChangeset for help on using the changeset viewer.