Changeset 180996 in webkit


Ignore:
Timestamp:
Mar 3, 2015 11:55:28 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.

A similar patch was rolled back in r180914. This patch is an improved version.

  • 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.
A similar patch was rolled back in r180914.

  • 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

    r180991 r180996  
     12015-03-03   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        A similar patch was rolled back in r180914.
     10
     11        * fast/dom/microtask-detach.html: Added.
     12        * fast/dom/microtask-detach-expected.txt: Added.
     13        * fast/dom/microtask-inorder.html: Added.
     14        * fast/dom/microtask-inorder-expected.txt: Added.
     15        * fast/dom/microtask-reverse.html: Added.
     16        * fast/dom/microtask-reverse-expected.txt: Added.
     17
    1182015-03-03  Simon Fraser  <simon.fraser@apple.com>
    219
  • trunk/Source/WebCore/CMakeLists.txt

    r180978 r180996  
    13721372    dom/MessagePort.cpp
    13731373    dom/MessagePortChannel.cpp
     1374    dom/MicroTask.cpp
    13741375    dom/MouseEvent.cpp
    13751376    dom/MouseRelatedEvent.cpp
     
    31563157    testing/Internals.cpp
    31573158
     3159    testing/MicroTaskTest.cpp
    31583160    testing/MockPageOverlayClient.cpp
    31593161
  • trunk/Source/WebCore/ChangeLog

    r180987 r180996  
     12015-03-03  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        A similar patch was rolled back in r180914. This patch is an improved version.
     14
     15        * WebCore.vcxproj/WebCore.vcxproj: Add MicroTask.{h,cpp} to the project.
     16        * WebCore.vcxproj/WebCoreTestSupport.vcxproj: Add MicroTaskTest.{h,cpp} to the project.
     17        * WebCore.vcxproj/WebCore.vcxproj.filters: Add MicroTask.{h,cpp} to the project.
     18        * WebCore.vcxproj/WebCoreTestSupport.vcxproj.filters: Add MicroTaskTest.{h,cpp} to the project.
     19        * WebCore.xcodeproj/project.pbxproj: Add MicroTask{,Test}.{h,cpp} to the project.
     20        * dom/Document.h: Add WEBCORE_EXPORT to addConsoleMessage, so it can be used in MicroTaskTest that's in WebCoreTestSupport..
     21        * dom/MicroTask.h: Add a MicroTask interface class. Add a MicroTaskQueue singleton.
     22        (WebCore::MicroTask::~MicroTask):
     23        (WebCore::MicroTask::run): Run the microtask.
     24        * dom/MicroTask.cpp: Implement the MicroTaskQueue singleton.
     25        (WebCore::MicroTaskQueue::singleton): Get a singleton instance of MicroTaskQueue.
     26        (WebCore::MicroTaskQueue::queueMicroTask): Add a microtask to the queue.
     27        (WebCore::MicroTaskQueue::runMicroTasks): Run all the microtasks in the queue and clear it.
     28        * dom/ScriptRunner.cpp: Trigger running of all microtasks in queue.
     29        (WebCore::ScriptRunner::timerFired):
     30        * html/parser/HTMLScriptRunner.cpp: Trigger running of all microtasks in queue.
     31        (WebCore::HTMLScriptRunner::executePendingScriptAndDispatchEvent):
     32        (WebCore::HTMLScriptRunner::executeScriptsWaitingForParsing):
     33        (WebCore::HTMLScriptRunner::runScript):
     34        * testing/Internals.cpp: Add a method to queue a test microtask.
     35        (WebCore::Internals::queueMicroTask):
     36        * testing/Internals.h: Add a method to queue a test microtask.
     37        (WebCore::Internals::queueMicroTask):
     38        * testing/Internals.idl: Expose test microtask queueing to test JS.
     39        * testing/MicroTaskTest.cpp: Add a test class that implements a microtask and prints to the console when it runs.
     40        (WebCore::MicroTaskTest::run): Run the microtask
     41        (WebCore::MicroTaskTest::create): Create a test microtask.
     42        * testing/MicroTaskTest.h: Add a test class that implements a microtask.
     43        (WebCore::MicroTaskTest::run):
     44        (WebCore::MicroTaskTest::create):
     45
    1462015-03-03  Brent Fulgham  <bfulgham@apple.com>
    247
  • trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj

    r180914 r180996  
    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

    r180914 r180996  
    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

    r180914 r180996  
    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

    r180914 r180996  
    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

    r180985 r180996  
    20802080                536D5A25193F40FC00CE4CAB /* SourceSizeList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 536D5A24193F40FC00CE4CAB /* SourceSizeList.cpp */; };
    20812081                536D5A27193F410B00CE4CAB /* SourceSizeList.h in Headers */ = {isa = PBXBuildFile; fileRef = 536D5A26193F410B00CE4CAB /* SourceSizeList.h */; settings = {ATTRIBUTES = (Private, ); }; };
     2082                53B895AF19DC7ED9009CAA93 /* MicroTask.h in Headers */ = {isa = PBXBuildFile; fileRef = 53B895AD19DC7C37009CAA93 /* MicroTask.h */; settings = {ATTRIBUTES = (Public, ); }; };
    20822083                53C8298D13D8D92700DE2DEB /* RenderFlexibleBox.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 53C8298B13D8D92700DE2DEB /* RenderFlexibleBox.cpp */; };
    20832084                53C8298E13D8D92700DE2DEB /* RenderFlexibleBox.h in Headers */ = {isa = PBXBuildFile; fileRef = 53C8298C13D8D92700DE2DEB /* RenderFlexibleBox.h */; settings = {ATTRIBUTES = (Private, ); }; };
     
    56245625                CAE9F90F146441F000C245B0 /* CSSAspectRatioValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CAE9F90D146441F000C245B0 /* CSSAspectRatioValue.cpp */; };
    56255626                CAE9F910146441F000C245B0 /* CSSAspectRatioValue.h in Headers */ = {isa = PBXBuildFile; fileRef = CAE9F90E146441F000C245B0 /* CSSAspectRatioValue.h */; };
     5627                CB8CF0181A9358D4000D510B /* MicroTask.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CB8CF0151A934B43000D510B /* MicroTask.cpp */; };
     5628                CB8CF01D1A95DE42000D510B /* MicroTaskTest.h in Headers */ = {isa = PBXBuildFile; fileRef = CB8CF01C1A95DE42000D510B /* MicroTaskTest.h */; };
     5629                CB8CF01F1A95DE59000D510B /* MicroTaskTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CB8CF01E1A95DE59000D510B /* MicroTaskTest.cpp */; };
    56265630                CCC2B51415F613060048CDD6 /* DeviceClient.h in Headers */ = {isa = PBXBuildFile; fileRef = CCC2B51015F613060048CDD6 /* DeviceClient.h */; settings = {ATTRIBUTES = (Private, ); }; };
    56275631                CCC2B51515F613060048CDD6 /* DeviceController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CCC2B51115F613060048CDD6 /* DeviceController.cpp */; };
     
    92319235                536D5A24193F40FC00CE4CAB /* SourceSizeList.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SourceSizeList.cpp; sourceTree = "<group>"; };
    92329236                536D5A26193F410B00CE4CAB /* SourceSizeList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SourceSizeList.h; sourceTree = "<group>"; };
     9237                53B895AD19DC7C37009CAA93 /* MicroTask.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MicroTask.h; sourceTree = "<group>"; };
    92339238                53C8298B13D8D92700DE2DEB /* RenderFlexibleBox.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderFlexibleBox.cpp; sourceTree = "<group>"; };
    92349239                53C8298C13D8D92700DE2DEB /* RenderFlexibleBox.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderFlexibleBox.h; sourceTree = "<group>"; };
     
    1309213097                CAE9F90D146441F000C245B0 /* CSSAspectRatioValue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CSSAspectRatioValue.cpp; sourceTree = "<group>"; };
    1309313098                CAE9F90E146441F000C245B0 /* CSSAspectRatioValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSSAspectRatioValue.h; sourceTree = "<group>"; };
     13099                CB8CF0151A934B43000D510B /* MicroTask.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MicroTask.cpp; sourceTree = "<group>"; };
     13100                CB8CF01C1A95DE42000D510B /* MicroTaskTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MicroTaskTest.h; sourceTree = "<group>"; };
     13101                CB8CF01E1A95DE59000D510B /* MicroTaskTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MicroTaskTest.cpp; sourceTree = "<group>"; };
    1309413102                CCC2B51015F613060048CDD6 /* DeviceClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DeviceClient.h; sourceTree = "<group>"; };
    1309513103                CCC2B51115F613060048CDD6 /* DeviceController.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DeviceController.cpp; sourceTree = "<group>"; };
     
    1567715685                                A7BF7EDE14C9175A0014489D /* InternalSettings.idl */,
    1567815686                                A7BE7EDD14C9175A0014489D /* MallocStatistics.h */,
     15687                                CB8CF01E1A95DE59000D510B /* MicroTaskTest.cpp */,
     15688                                CB8CF01C1A95DE42000D510B /* MicroTaskTest.h */,
    1567915689                                A7BE7EDE14C9175A0014489D /* MallocStatistics.idl */,
    1568015690                                CD5393CB175DCCE600C07123 /* MemoryInfo.h */,
     
    2288622896                                E1ADECC60E76AD1F004A1A5E /* MessagePort.idl */,
    2288722897                                41BF700A0FE86F49005E8DEC /* MessagePortChannel.h */,
     22898                                53B895AD19DC7C37009CAA93 /* MicroTask.h */,
     22899                                CB8CF0151A934B43000D510B /* MicroTask.cpp */,
    2288822900                                85031B2F0A44EFC700F992E0 /* MouseEvent.cpp */,
    2288922901                                85031B300A44EFC700F992E0 /* MouseEvent.h */,
     
    2345023462                                A740B59514C935AB00A77FA4 /* JSMallocStatistics.h in Headers */,
    2345123463                                CD5393D4175E018600C07123 /* JSMemoryInfo.h in Headers */,
     23464                                CB8CF01D1A95DE42000D510B /* MicroTaskTest.h in Headers */,
    2345223465                                EBF5121D1696496C0056BD25 /* JSTypeConversions.h in Headers */,
    2345323466                                CDC26B41160A8CCE0026757B /* MockCDM.h in Headers */,
     
    2587525888                                508CCA4F13CF106B003151F3 /* RenderFlowThread.h in Headers */,
    2587625889                                A871DED30A1530C700B12A68 /* RenderFrame.h in Headers */,
     25890                                53B895AF19DC7ED9009CAA93 /* MicroTask.h in Headers */,
    2587725891                                0FD3080F117CF7E700A791F7 /* RenderFrameBase.h in Headers */,
    2587825892                                A871DED10A1530C700B12A68 /* RenderFrameSet.h in Headers */,
     
    2720227216                                417DA71D13735DFA007C57FB /* JSInternals.cpp in Sources */,
    2720327217                                A740B5A714C935AF00A77FA4 /* JSInternalSettings.cpp in Sources */,
     27218                                CB8CF01F1A95DE59000D510B /* MicroTaskTest.cpp in Sources */,
    2720427219                                53ED3FDE167A88E7006762E6 /* JSInternalSettingsGenerated.cpp in Sources */,
    2720527220                                A740B59714C935AF00A77FA4 /* JSMallocStatistics.cpp in Sources */,
     
    2983729852                                B2227A930D00BF220071B782 /* SVGPolylineElement.cpp in Sources */,
    2983829853                                B2227A960D00BF220071B782 /* SVGPreserveAspectRatio.cpp in Sources */,
     29854                                CB8CF0181A9358D4000D510B /* MicroTask.cpp in Sources */,
    2983929855                                B543B85717EB758F003BE93A /* SVGPropertyInfo.cpp in Sources */,
    2984029856                                B2227A990D00BF220071B782 /* SVGRadialGradientElement.cpp in Sources */,
  • trunk/Source/WebCore/dom/Document.h

    r180914 r180996  
    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

    r180914 r180996  
    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

    r180914 r180996  
    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

    r180963 r180996  
    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

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

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