Changeset 180911 in webkit


Ignore:
Timestamp:
Mar 2, 2015 5:04:40 PM (9 years ago)
Author:
yoav@yoav.ws
Message:

Add a microtask abstraction
https://bugs.webkit.org/show_bug.cgi?id=137496

Reviewed by Sam Weinig.

Source/WebCore:

This patch adds a microtask abstraction: https://html.spec.whatwg.org/multipage/webappapis.html#microtask
That abstraction is required in order to enable async loading of images,
which is in turn required to enable support for the picture element, as well as
to make sure that the order of properties set on HTMLImageElement has no implications.

  • WebCore.vcxproj/WebCore.vcxproj: Add MicroTask.{h,cpp} to the project.
  • WebCore.vcxproj/WebCoreTestSupport.vcxproj: Add MicroTaskTest.{h,cpp} to the project.
  • WebCore.vcxproj/WebCore.vcxproj.filters: Add MicroTask.{h,cpp} to the project.
  • WebCore.vcxproj/WebCoreTestSupport.vcxproj.filters: Add MicroTaskTest.{h,cpp} to the project.
  • WebCore.xcodeproj/project.pbxproj: Add MicroTask{,Test}.{h,cpp} to the project.
  • dom/Document.h: Add WEBCORE_EXPORT to addConsoleMessage, so it can be used in MicroTaskTest that's in WebCoreTestSupport..
  • dom/MicroTask.h: Add a MicroTask interface class. Add a MicroTaskQueue singleton.

(WebCore::MicroTask::~MicroTask):
(WebCore::MicroTask::run): Run the microtask.

  • dom/MicroTask.cpp: Implement the MicroTaskQueue singleton.

(WebCore::MicroTaskQueue::singleton): Get a singleton instance of MicroTaskQueue.
(WebCore::MicroTaskQueue::queueMicroTask): Add a microtask to the queue.
(WebCore::MicroTaskQueue::runMicroTasks): Run all the microtasks in the queue and clear it.

  • dom/ScriptRunner.cpp: Trigger running of all microtasks in queue.

(WebCore::ScriptRunner::timerFired):

  • html/parser/HTMLScriptRunner.cpp: Trigger running of all microtasks in queue.

(WebCore::HTMLScriptRunner::executePendingScriptAndDispatchEvent):
(WebCore::HTMLScriptRunner::executeScriptsWaitingForParsing):
(WebCore::HTMLScriptRunner::runScript):

  • testing/Internals.cpp: Add a method to queue a test microtask.

(WebCore::Internals::queueMicroTask):

  • testing/Internals.h: Add a method to queue a test microtask.

(WebCore::Internals::queueMicroTask):

  • testing/Internals.idl: Expose test microtask queueing to test JS.
  • testing/MicroTaskTest.cpp: Add a test class that implements a microtask and prints to the console when it runs.

(WebCore::MicroTaskTest::run): Run the microtask
(WebCore::MicroTaskTest::create): Create a test microtask.

  • testing/MicroTaskTest.h: Add a test class that implements a microtask.

(WebCore::MicroTaskTest::run):
(WebCore::MicroTaskTest::create):

LayoutTests:

Adding a test for microtask abstraction.

  • fast/dom/microtask-detach.html: Added.
  • fast/dom/microtask-detach-expected.txt: Added.
  • fast/dom/microtask-inorder.html: Added.
  • fast/dom/microtask-inorder-expected.txt: Added.
  • fast/dom/microtask-reverse.html: Added.
  • fast/dom/microtask-reverse-expected.txt: Added.
Location:
trunk
Files:
10 added
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r180907 r180911  
     12015-03-02   Yoav Weiss  <yoav@yoav.ws>
     2
     3        Add a microtask abstraction
     4        https://bugs.webkit.org/show_bug.cgi?id=137496
     5
     6        Reviewed by Sam Weinig.
     7
     8        Adding a test for microtask abstraction.
     9
     10        * fast/dom/microtask-detach.html: Added.
     11        * fast/dom/microtask-detach-expected.txt: Added.
     12        * fast/dom/microtask-inorder.html: Added.
     13        * fast/dom/microtask-inorder-expected.txt: Added.
     14        * fast/dom/microtask-reverse.html: Added.
     15        * fast/dom/microtask-reverse-expected.txt: Added.
     16
    1172015-03-02  Myles C. Maxfield  <mmaxfield@apple.com>
    218
  • trunk/Source/WebCore/CMakeLists.txt

    r180601 r180911  
    13711371    dom/MessagePort.cpp
    13721372    dom/MessagePortChannel.cpp
     1373    dom/MicroTask.cpp
    13731374    dom/MouseEvent.cpp
    13741375    dom/MouseRelatedEvent.cpp
     
    31553156    testing/Internals.cpp
    31563157
     3158    testing/MicroTaskTest.cpp
    31573159    testing/MockPageOverlayClient.cpp
    31583160
  • trunk/Source/WebCore/ChangeLog

    r180910 r180911  
     12015-03-02  Yoav Weiss  <yoav@yoav.ws>
     2
     3        Add a microtask abstraction
     4        https://bugs.webkit.org/show_bug.cgi?id=137496
     5
     6        Reviewed by Sam Weinig.
     7
     8        This patch adds a microtask abstraction: https://html.spec.whatwg.org/multipage/webappapis.html#microtask
     9        That abstraction is required in order to enable async loading of images,
     10        which is in turn required to enable support for the picture element, as well as
     11        to make sure that the order of properties set on HTMLImageElement has no implications.
     12
     13        * WebCore.vcxproj/WebCore.vcxproj: Add MicroTask.{h,cpp} to the project.
     14        * WebCore.vcxproj/WebCoreTestSupport.vcxproj: Add MicroTaskTest.{h,cpp} to the project.
     15        * WebCore.vcxproj/WebCore.vcxproj.filters: Add MicroTask.{h,cpp} to the project.
     16        * WebCore.vcxproj/WebCoreTestSupport.vcxproj.filters: Add MicroTaskTest.{h,cpp} to the project.
     17        * WebCore.xcodeproj/project.pbxproj: Add MicroTask{,Test}.{h,cpp} to the project.
     18        * dom/Document.h: Add WEBCORE_EXPORT to addConsoleMessage, so it can be used in MicroTaskTest that's in WebCoreTestSupport..
     19        * dom/MicroTask.h: Add a MicroTask interface class. Add a MicroTaskQueue singleton.
     20        (WebCore::MicroTask::~MicroTask):
     21        (WebCore::MicroTask::run): Run the microtask.
     22        * dom/MicroTask.cpp: Implement the MicroTaskQueue singleton.
     23        (WebCore::MicroTaskQueue::singleton): Get a singleton instance of MicroTaskQueue.
     24        (WebCore::MicroTaskQueue::queueMicroTask): Add a microtask to the queue.
     25        (WebCore::MicroTaskQueue::runMicroTasks): Run all the microtasks in the queue and clear it.
     26        * dom/ScriptRunner.cpp: Trigger running of all microtasks in queue.
     27        (WebCore::ScriptRunner::timerFired):
     28        * html/parser/HTMLScriptRunner.cpp: Trigger running of all microtasks in queue.
     29        (WebCore::HTMLScriptRunner::executePendingScriptAndDispatchEvent):
     30        (WebCore::HTMLScriptRunner::executeScriptsWaitingForParsing):
     31        (WebCore::HTMLScriptRunner::runScript):
     32        * testing/Internals.cpp: Add a method to queue a test microtask.
     33        (WebCore::Internals::queueMicroTask):
     34        * testing/Internals.h: Add a method to queue a test microtask.
     35        (WebCore::Internals::queueMicroTask):
     36        * testing/Internals.idl: Expose test microtask queueing to test JS.
     37        * testing/MicroTaskTest.cpp: Add a test class that implements a microtask and prints to the console when it runs.
     38        (WebCore::MicroTaskTest::run): Run the microtask
     39        (WebCore::MicroTaskTest::create): Create a test microtask.
     40        * testing/MicroTaskTest.h: Add a test class that implements a microtask.
     41        (WebCore::MicroTaskTest::run):
     42        (WebCore::MicroTaskTest::create):
     43
    1442015-03-02  Jeremy Jones  <jeremyj@apple.com>
    245
  • trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj

    r180765 r180911  
    1343513435      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|x64'">true</ExcludedFromBuild>
    1343613436    </ClCompile>
     13437    <ClCompile Include="..\dom\MicroTask.cpp" />
    1343713438    <ClCompile Include="..\dom\MouseEvent.cpp">
    1343813439      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
     
    2062520626    <ClInclude Include="..\dom\MessagePort.h" />
    2062620627    <ClInclude Include="..\dom\MessagePortChannel.h" />
     20628    <ClInclude Include="..\dom\MicroTask.h" />
    2062720629    <ClInclude Include="..\dom\MouseEvent.h" />
    2062820630    <ClInclude Include="..\dom\MouseRelatedEvent.h" />
  • trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters

    r180765 r180911  
    32023202      <Filter>dom</Filter>
    32033203    </ClCompile>
     3204    <ClCompile Include="..\dom\MicroTask.cpp">
     3205      <Filter>dom</Filter>
     3206    </ClCompile>
    32043207    <ClCompile Include="..\dom\MouseEvent.cpp">
    32053208      <Filter>dom</Filter>
     
    1026810271    </ClInclude>
    1026910272    <ClInclude Include="..\dom\MessagePortChannel.h">
     10273      <Filter>dom</Filter>
     10274    </ClInclude>
     10275    <ClInclude Include="..\dom\MicroTask.h">
    1027010276      <Filter>dom</Filter>
    1027110277    </ClInclude>
  • trunk/Source/WebCore/WebCore.vcxproj/WebCoreTestSupport.vcxproj

    r180653 r180911  
    276276      </ForcedIncludeFiles>
    277277    </ClCompile>
     278    <ClCompile Include="..\testing\MicroTaskTest.cpp" />
    278279    <ClCompile Include="..\testing\MockPageOverlayClient.cpp" />
    279280    <ClCompile Include="..\testing\InternalSettings.cpp" />
     
    292293    <ClInclude Include="..\testing\MallocStatistics.h" />
    293294    <ClInclude Include="..\testing\MemoryInfo.h" />
     295    <ClInclude Include="..\testing\MicroTaskTest.h" />
    294296    <ClInclude Include="..\testing\MockCDM.h" />
    295297    <ClInclude Include="..\testing\MockPageOverlayClient.h" />
  • trunk/Source/WebCore/WebCore.vcxproj/WebCoreTestSupport.vcxproj.filters

    r180653 r180911  
    3838    </ClCompile>
    3939    <ClCompile Include="..\testing\js\WebCoreTestSupport.cpp">
     40      <Filter>testing</Filter>
     41    </ClCompile>
     42    <ClCompile Include="..\testing\MicroTaskTest.cpp">
    4043      <Filter>testing</Filter>
    4144    </ClCompile>
     
    9194    </ClInclude>
    9295    <ClInclude Include="..\config.h" />
     96    <ClInclude Include="..\testing\MicroTaskTest.h">
     97      <Filter>testing</Filter>
     98    </ClInclude>
    9399    <ClInclude Include="..\testing\MockCDM.h">
    94100      <Filter>testing</Filter>
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r180902 r180911  
    20792079                536D5A25193F40FC00CE4CAB /* SourceSizeList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 536D5A24193F40FC00CE4CAB /* SourceSizeList.cpp */; };
    20802080                536D5A27193F410B00CE4CAB /* SourceSizeList.h in Headers */ = {isa = PBXBuildFile; fileRef = 536D5A26193F410B00CE4CAB /* SourceSizeList.h */; settings = {ATTRIBUTES = (Private, ); }; };
     2081                53B895AF19DC7ED9009CAA93 /* MicroTask.h in Headers */ = {isa = PBXBuildFile; fileRef = 53B895AD19DC7C37009CAA93 /* MicroTask.h */; settings = {ATTRIBUTES = (Public, ); }; };
    20812082                53C8298D13D8D92700DE2DEB /* RenderFlexibleBox.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 53C8298B13D8D92700DE2DEB /* RenderFlexibleBox.cpp */; };
    20822083                53C8298E13D8D92700DE2DEB /* RenderFlexibleBox.h in Headers */ = {isa = PBXBuildFile; fileRef = 53C8298C13D8D92700DE2DEB /* RenderFlexibleBox.h */; settings = {ATTRIBUTES = (Private, ); }; };
     
    56225623                CAE9F90F146441F000C245B0 /* CSSAspectRatioValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CAE9F90D146441F000C245B0 /* CSSAspectRatioValue.cpp */; };
    56235624                CAE9F910146441F000C245B0 /* CSSAspectRatioValue.h in Headers */ = {isa = PBXBuildFile; fileRef = CAE9F90E146441F000C245B0 /* CSSAspectRatioValue.h */; };
     5625                CB8CF0181A9358D4000D510B /* MicroTask.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CB8CF0151A934B43000D510B /* MicroTask.cpp */; };
     5626                CB8CF01D1A95DE42000D510B /* MicroTaskTest.h in Headers */ = {isa = PBXBuildFile; fileRef = CB8CF01C1A95DE42000D510B /* MicroTaskTest.h */; };
     5627                CB8CF01F1A95DE59000D510B /* MicroTaskTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CB8CF01E1A95DE59000D510B /* MicroTaskTest.cpp */; };
    56245628                CCC2B51415F613060048CDD6 /* DeviceClient.h in Headers */ = {isa = PBXBuildFile; fileRef = CCC2B51015F613060048CDD6 /* DeviceClient.h */; settings = {ATTRIBUTES = (Private, ); }; };
    56255629                CCC2B51515F613060048CDD6 /* DeviceController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CCC2B51115F613060048CDD6 /* DeviceController.cpp */; };
     
    92289232                536D5A24193F40FC00CE4CAB /* SourceSizeList.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SourceSizeList.cpp; sourceTree = "<group>"; };
    92299233                536D5A26193F410B00CE4CAB /* SourceSizeList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SourceSizeList.h; sourceTree = "<group>"; };
     9234                53B895AD19DC7C37009CAA93 /* MicroTask.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MicroTask.h; sourceTree = "<group>"; };
    92309235                53C8298B13D8D92700DE2DEB /* RenderFlexibleBox.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderFlexibleBox.cpp; sourceTree = "<group>"; };
    92319236                53C8298C13D8D92700DE2DEB /* RenderFlexibleBox.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderFlexibleBox.h; sourceTree = "<group>"; };
     
    1308813093                CAE9F90D146441F000C245B0 /* CSSAspectRatioValue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CSSAspectRatioValue.cpp; sourceTree = "<group>"; };
    1308913094                CAE9F90E146441F000C245B0 /* CSSAspectRatioValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSSAspectRatioValue.h; sourceTree = "<group>"; };
     13095                CB8CF0151A934B43000D510B /* MicroTask.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MicroTask.cpp; sourceTree = "<group>"; };
     13096                CB8CF01C1A95DE42000D510B /* MicroTaskTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MicroTaskTest.h; sourceTree = "<group>"; };
     13097                CB8CF01E1A95DE59000D510B /* MicroTaskTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MicroTaskTest.cpp; sourceTree = "<group>"; };
    1309013098                CCC2B51015F613060048CDD6 /* DeviceClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DeviceClient.h; sourceTree = "<group>"; };
    1309113099                CCC2B51115F613060048CDD6 /* DeviceController.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DeviceController.cpp; sourceTree = "<group>"; };
     
    1567215680                                A7BF7EDE14C9175A0014489D /* InternalSettings.idl */,
    1567315681                                A7BE7EDD14C9175A0014489D /* MallocStatistics.h */,
     15682                                CB8CF01E1A95DE59000D510B /* MicroTaskTest.cpp */,
     15683                                CB8CF01C1A95DE42000D510B /* MicroTaskTest.h */,
    1567415684                                A7BE7EDE14C9175A0014489D /* MallocStatistics.idl */,
    1567515685                                CD5393CB175DCCE600C07123 /* MemoryInfo.h */,
     
    2288022890                                E1ADECC60E76AD1F004A1A5E /* MessagePort.idl */,
    2288122891                                41BF700A0FE86F49005E8DEC /* MessagePortChannel.h */,
     22892                                53B895AD19DC7C37009CAA93 /* MicroTask.h */,
     22893                                CB8CF0151A934B43000D510B /* MicroTask.cpp */,
    2288222894                                85031B2F0A44EFC700F992E0 /* MouseEvent.cpp */,
    2288322895                                85031B300A44EFC700F992E0 /* MouseEvent.h */,
     
    2344423456                                A740B59514C935AB00A77FA4 /* JSMallocStatistics.h in Headers */,
    2344523457                                CD5393D4175E018600C07123 /* JSMemoryInfo.h in Headers */,
     23458                                CB8CF01D1A95DE42000D510B /* MicroTaskTest.h in Headers */,
    2344623459                                EBF5121D1696496C0056BD25 /* JSTypeConversions.h in Headers */,
    2344723460                                CDC26B41160A8CCE0026757B /* MockCDM.h in Headers */,
     
    2586825881                                508CCA4F13CF106B003151F3 /* RenderFlowThread.h in Headers */,
    2586925882                                A871DED30A1530C700B12A68 /* RenderFrame.h in Headers */,
     25883                                53B895AF19DC7ED9009CAA93 /* MicroTask.h in Headers */,
    2587025884                                0FD3080F117CF7E700A791F7 /* RenderFrameBase.h in Headers */,
    2587125885                                A871DED10A1530C700B12A68 /* RenderFrameSet.h in Headers */,
     
    2719427208                                417DA71D13735DFA007C57FB /* JSInternals.cpp in Sources */,
    2719527209                                A740B5A714C935AF00A77FA4 /* JSInternalSettings.cpp in Sources */,
     27210                                CB8CF01F1A95DE59000D510B /* MicroTaskTest.cpp in Sources */,
    2719627211                                53ED3FDE167A88E7006762E6 /* JSInternalSettingsGenerated.cpp in Sources */,
    2719727212                                A740B59714C935AF00A77FA4 /* JSMallocStatistics.cpp in Sources */,
     
    2982929844                                B2227A930D00BF220071B782 /* SVGPolylineElement.cpp in Sources */,
    2983029845                                B2227A960D00BF220071B782 /* SVGPreserveAspectRatio.cpp in Sources */,
     29846                                CB8CF0181A9358D4000D510B /* MicroTask.cpp in Sources */,
    2983129847                                B543B85717EB758F003BE93A /* SVGPropertyInfo.cpp in Sources */,
    2983229848                                B2227A990D00BF220071B782 /* SVGRadialGradientElement.cpp in Sources */,
  • trunk/Source/WebCore/dom/Document.h

    r180867 r180911  
    12631263    void removeDisabledFieldsetElement() { ASSERT(m_disabledFieldsetElementsCount); m_disabledFieldsetElementsCount--; }
    12641264
    1265     virtual void addConsoleMessage(MessageSource, MessageLevel, const String& message, unsigned long requestIdentifier = 0) override final;
     1265    WEBCORE_EXPORT virtual void addConsoleMessage(MessageSource, MessageLevel, const String& message, unsigned long requestIdentifier = 0) override final;
    12661266
    12671267    WEBCORE_EXPORT virtual SecurityOrigin* topOrigin() const override final;
     
    12891289    WEBCORE_EXPORT void updateIsPlayingAudio();
    12901290    void pageMutedStateDidChange();
     1291    WeakPtr<Document> createWeakPtr() { return m_weakFactory.createWeakPtr(); }
    12911292
    12921293protected:
  • trunk/Source/WebCore/dom/ScriptRunner.cpp

    r176459 r180911  
    2929#include "CachedScript.h"
    3030#include "Element.h"
     31#include "MicroTask.h"
    3132#include "PendingScript.h"
    3233#include "ScriptElement.h"
     
    117118        m_document.decrementLoadEventDelayCount();
    118119    }
     120    MicroTaskQueue::singleton().runMicroTasks();
    119121}
    120122
  • trunk/Source/WebCore/html/parser/HTMLScriptRunner.cpp

    r157363 r180911  
    3737#include "HTMLScriptRunnerHost.h"
    3838#include "IgnoreDestructiveWriteCountIncrementer.h"
     39#include "MicroTask.h"
    3940#include "MutationObserver.h"
    4041#include "NestingLevelIncrementer.h"
     
    130131        stopWatchingForLoad(pendingScript);
    131132
    132     if (!isExecutingScript())
     133    if (!isExecutingScript()) {
    133134        MutationObserver::deliverAllMutations();
     135        MicroTaskQueue::singleton().runMicroTasks();
     136    }
    134137
    135138    // Clear the pending script before possible rentrancy from executeScript()
     
    232235            return false;
    233236    }
     237    if (!isExecutingScript())
     238        MicroTaskQueue::singleton().runMicroTasks();
    234239    return true;
    235240}
     
    294299        // unfortuantely no obvious way to tell if prepareScript is going to
    295300        // execute the script from out here.
    296         if (!isExecutingScript())
     301        if (!isExecutingScript()) {
    297302            MutationObserver::deliverAllMutations();
     303            MicroTaskQueue::singleton().runMicroTasks();
     304        }
    298305
    299306        InsertionPointRecord insertionPointRecord(m_host.inputStream());
  • trunk/Source/WebCore/testing/Internals.cpp

    r180712 r180911  
    8080#include "MemoryCache.h"
    8181#include "MemoryInfo.h"
     82#include "MicroTask.h"
     83#include "MicroTaskTest.h"
    8284#include "MockPageOverlayClient.h"
    8385#include "Page.h"
     
    25332535}
    25342536
    2535 }
     2537void Internals::queueMicroTask(int testNumber)
     2538{
     2539    if (contextDocument())
     2540        MicroTaskQueue::singleton().queueMicroTask(MicroTaskTest::create(contextDocument()->createWeakPtr(), testNumber));
     2541}
     2542
     2543}
  • trunk/Source/WebCore/testing/Internals.h

    r180653 r180911  
    367367
    368368    RefPtr<File> createFile(const String&);
     369    void queueMicroTask(int);
    369370
    370371private:
  • trunk/Source/WebCore/testing/Internals.idl

    r180601 r180911  
    323323   
    324324    File createFile(DOMString url);
     325    void queueMicroTask(long testNumber);
    325326};
Note: See TracChangeset for help on using the changeset viewer.