⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 263279 in webkit


Ignore:
Timestamp:
Jun 19, 2020, 12:39:08 PM (6 years ago)
Author:
Alan Coon
Message:

Reintroduce content to branch.

This reverts r263238.

Location:
branches/safari-610.1.17-branch
Files:
2 added
15 edited
2 moved

Legend:

Unmodified
Added
Removed
  • branches/safari-610.1.17-branch/LayoutTests/ChangeLog

    r263238 r263279  
     12020-06-18  Alan Coon  <alancoon@apple.com>
     2
     3        Cherry-pick r263128. rdar://problem/64492837
     4
     5    REGRESSION (r262643): DumpRenderTree at com.apple.WebCore: WebCore::Document::prepareCanvasesForDisplayIfNeeded
     6    https://bugs.webkit.org/show_bug.cgi?id=213221
     7    rdar://64260400
     8   
     9    Reviewed by Simon Fraser.
     10   
     11    Source/WebCore:
     12   
     13    A Document could still be holding a pointer to an HTMLCanvasElement after the
     14    canvas had been deleted because the CanvasObserver protocol was disconnected
     15    too early. The fix is to explicitly clear the canvas from the Document as it
     16    stops observing.
     17   
     18    Test: webgl/preparation-removed-from-document.html
     19   
     20    * dom/Document.cpp:
     21    (WebCore::Document::prepareCanvasesForDisplayIfNeeded): Copy the HashSet to a Vector
     22    just in case something weird happens to the set during iteration.
     23    (WebCore::Document::clearCanvasPreparation): Remove the canvas from the list of
     24    of elements that need preparation.
     25    * dom/Document.h: Add the new clearCanvasPreparation method.
     26   
     27    * html/HTMLCanvasElement.cpp:
     28    (WebCore::HTMLCanvasElement::~HTMLCanvasElement): Clear the document.
     29    (WebCore::HTMLCanvasElement::didMoveToNewDocument): Ditto.
     30    (WebCore::HTMLCanvasElement::removedFromAncestor): Ditto.
     31   
     32    LayoutTests:
     33   
     34    Test that triggers a rendering on a canvas, then rips it out of
     35    the document before drawing.
     36   
     37    * webgl/preparation-removed-from-document-expected.txt: Added.
     38    * webgl/preparation-removed-from-document.html: Added.
     39   
     40    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@263128 268f45cc-cd09-0410-ab3c-d52691b4dbfc
     41
     42    2020-06-16  Dean Jackson  <dino@apple.com>
     43
     44            REGRESSION (r262643): DumpRenderTree at com.apple.WebCore: WebCore::Document::prepareCanvasesForDisplayIfNeeded
     45            https://bugs.webkit.org/show_bug.cgi?id=213221
     46            rdar://64260400
     47
     48            Reviewed by Simon Fraser.
     49
     50            Test that triggers a rendering on a canvas, then rips it out of
     51            the document before drawing.
     52
     53            * webgl/preparation-removed-from-document-expected.txt: Added.
     54            * webgl/preparation-removed-from-document.html: Added.
     55
    1562020-06-15  Megan Gardner  <megan_gardner@apple.com>
    257
  • branches/safari-610.1.17-branch/Source/WebCore/ChangeLog

    r263238 r263279  
     12020-06-18  Alan Coon  <alancoon@apple.com>
     2
     3        Cherry-pick r263129. rdar://problem/64492826
     4
     5    FileListCreator should only be used for resolving directories
     6    https://bugs.webkit.org/show_bug.cgi?id=213259
     7    <rdar://problem/64375709>
     8   
     9    Reviewed by David Kilzer.
     10   
     11    Depending on whether directories should be resolved, FileListCreator::create would either
     12    synchronously execute its completion handler then return nullptr or asynchronously dispatch
     13    its completion handler then return a non-null RefPtr. Interfaces with sometimes-synchronous
     14    callbacks can be hard to use correctly; e.g., r262962 fixes a problem where
     15    FileInputType::m_fileListCreator was being modified in an unexpected order.
     16   
     17    This patch makes the interface between FileInputType and FileListCreator less error-prone
     18    and more explicit by renaming FileListCreator to DirectoryFileListCreator, making its job
     19    solely to create directory FileLists on a background queue, and giving it an explicit start
     20    member function. For non-directories, FileInputType::filesChosen now bypasses
     21    DirectoryFileListCreator and directly converts from Vector<FileChooserFileInfo> to FileList.
     22   
     23    Covered by existing tests.
     24   
     25    * Sources.txt:
     26    * WebCore.xcodeproj/project.pbxproj:
     27   
     28    * html/DirectoryFileListCreator.cpp: Renamed from html/FileListCreator.cpp.
     29    (WebCore::createFileList): Removed the template and ShouldResolveDirectories parameter.
     30    (WebCore::DirectoryFileListCreator::DirectoryFileListCreator): Moved the work queue
     31    dispatching to DirectoryFileListCreator::start.
     32    (WebCore::DirectoryFileListCreator::start): Added; moved the work queue dispatching here
     33    from the ctor.
     34   
     35    * html/DirectoryFileListCreator.h: Renamed from html/FileListCreator.h.
     36    (WebCore::DirectoryFileListCreator::create): Stopped performing non-directory creation and
     37    changed the return value back to Ref<>.
     38   
     39    * html/FileInputType.cpp:
     40    (WebCore::FileInputType::filesChosen): Moved most of the work done in the FileListCreator
     41    completion handler to didCreateFileList. When !FileInputType::allowsDirectories, used
     42    Vector::map to convert paths to a Vector<Ref<File>>, used that to create a FileList, then
     43    called didCreateFileList. Otherwise, created and started a DirectoryFileListCreator that
     44    calls didCreateFileList in its completion handler.
     45    (WebCore::FileInputType::didCreateFileList): Added; sets the new file list and icon and
     46    clears m_directoryFileListCreator.
     47   
     48    * html/FileInputType.h:
     49   
     50   
     51    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@263129 268f45cc-cd09-0410-ab3c-d52691b4dbfc
     52
     53    2020-06-16  Andy Estes  <aestes@apple.com>
     54
     55            FileListCreator should only be used for resolving directories
     56            https://bugs.webkit.org/show_bug.cgi?id=213259
     57            <rdar://problem/64375709>
     58
     59            Reviewed by David Kilzer.
     60
     61            Depending on whether directories should be resolved, FileListCreator::create would either
     62            synchronously execute its completion handler then return nullptr or asynchronously dispatch
     63            its completion handler then return a non-null RefPtr. Interfaces with sometimes-synchronous
     64            callbacks can be hard to use correctly; e.g., r262962 fixes a problem where
     65            FileInputType::m_fileListCreator was being modified in an unexpected order.
     66
     67            This patch makes the interface between FileInputType and FileListCreator less error-prone
     68            and more explicit by renaming FileListCreator to DirectoryFileListCreator, making its job
     69            solely to create directory FileLists on a background queue, and giving it an explicit start
     70            member function. For non-directories, FileInputType::filesChosen now bypasses
     71            DirectoryFileListCreator and directly converts from Vector<FileChooserFileInfo> to FileList.
     72
     73            Covered by existing tests.
     74
     75            * Sources.txt:
     76            * WebCore.xcodeproj/project.pbxproj:
     77
     78            * html/DirectoryFileListCreator.cpp: Renamed from html/FileListCreator.cpp.
     79            (WebCore::createFileList): Removed the template and ShouldResolveDirectories parameter.
     80            (WebCore::DirectoryFileListCreator::DirectoryFileListCreator): Moved the work queue
     81            dispatching to DirectoryFileListCreator::start.
     82            (WebCore::DirectoryFileListCreator::start): Added; moved the work queue dispatching here
     83            from the ctor.
     84
     85            * html/DirectoryFileListCreator.h: Renamed from html/FileListCreator.h.
     86            (WebCore::DirectoryFileListCreator::create): Stopped performing non-directory creation and
     87            changed the return value back to Ref<>.
     88
     89            * html/FileInputType.cpp:
     90            (WebCore::FileInputType::filesChosen): Moved most of the work done in the FileListCreator
     91            completion handler to didCreateFileList. When !FileInputType::allowsDirectories, used
     92            Vector::map to convert paths to a Vector<Ref<File>>, used that to create a FileList, then
     93            called didCreateFileList. Otherwise, created and started a DirectoryFileListCreator that
     94            calls didCreateFileList in its completion handler.
     95            (WebCore::FileInputType::didCreateFileList): Added; sets the new file list and icon and
     96            clears m_directoryFileListCreator.
     97
     98            * html/FileInputType.h:
     99
     1002020-06-18  Alan Coon  <alancoon@apple.com>
     101
     102        Cherry-pick r263128. rdar://problem/64492837
     103
     104    REGRESSION (r262643): DumpRenderTree at com.apple.WebCore: WebCore::Document::prepareCanvasesForDisplayIfNeeded
     105    https://bugs.webkit.org/show_bug.cgi?id=213221
     106    rdar://64260400
     107   
     108    Reviewed by Simon Fraser.
     109   
     110    Source/WebCore:
     111   
     112    A Document could still be holding a pointer to an HTMLCanvasElement after the
     113    canvas had been deleted because the CanvasObserver protocol was disconnected
     114    too early. The fix is to explicitly clear the canvas from the Document as it
     115    stops observing.
     116   
     117    Test: webgl/preparation-removed-from-document.html
     118   
     119    * dom/Document.cpp:
     120    (WebCore::Document::prepareCanvasesForDisplayIfNeeded): Copy the HashSet to a Vector
     121    just in case something weird happens to the set during iteration.
     122    (WebCore::Document::clearCanvasPreparation): Remove the canvas from the list of
     123    of elements that need preparation.
     124    * dom/Document.h: Add the new clearCanvasPreparation method.
     125   
     126    * html/HTMLCanvasElement.cpp:
     127    (WebCore::HTMLCanvasElement::~HTMLCanvasElement): Clear the document.
     128    (WebCore::HTMLCanvasElement::didMoveToNewDocument): Ditto.
     129    (WebCore::HTMLCanvasElement::removedFromAncestor): Ditto.
     130   
     131    LayoutTests:
     132   
     133    Test that triggers a rendering on a canvas, then rips it out of
     134    the document before drawing.
     135   
     136    * webgl/preparation-removed-from-document-expected.txt: Added.
     137    * webgl/preparation-removed-from-document.html: Added.
     138   
     139    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@263128 268f45cc-cd09-0410-ab3c-d52691b4dbfc
     140
     141    2020-06-16  Dean Jackson  <dino@apple.com>
     142
     143            REGRESSION (r262643): DumpRenderTree at com.apple.WebCore: WebCore::Document::prepareCanvasesForDisplayIfNeeded
     144            https://bugs.webkit.org/show_bug.cgi?id=213221
     145            rdar://64260400
     146
     147            Reviewed by Simon Fraser.
     148
     149            A Document could still be holding a pointer to an HTMLCanvasElement after the
     150            canvas had been deleted because the CanvasObserver protocol was disconnected
     151            too early. The fix is to explicitly clear the canvas from the Document as it
     152            stops observing.
     153
     154            Test: webgl/preparation-removed-from-document.html
     155
     156            * dom/Document.cpp:
     157            (WebCore::Document::prepareCanvasesForDisplayIfNeeded): Copy the HashSet to a Vector
     158            just in case something weird happens to the set during iteration.
     159            (WebCore::Document::clearCanvasPreparation): Remove the canvas from the list of
     160            of elements that need preparation.
     161            * dom/Document.h: Add the new clearCanvasPreparation method.
     162
     163            * html/HTMLCanvasElement.cpp:
     164            (WebCore::HTMLCanvasElement::~HTMLCanvasElement): Clear the document.
     165            (WebCore::HTMLCanvasElement::didMoveToNewDocument): Ditto.
     166            (WebCore::HTMLCanvasElement::removedFromAncestor): Ditto.
     167
     1682020-06-18  Alan Coon  <alancoon@apple.com>
     169
     170        Cherry-pick r263119. rdar://problem/64492834
     171
     172    Web Inspector: replace completion handler with a function in interception.
     173    https://bugs.webkit.org/show_bug.cgi?id=213252
     174   
     175    Patch by Pavel Feldman <pavel.feldman@gmail.com> on 2020-06-16
     176    Reviewed by Devin Rousso.
     177   
     178    Don't use a `CompletionHandler` as it asserts that it's been called when it's destroyed.
     179    Both `Network.interceptRequestWithResponse` and `Network.interceptRequestWithError` essentially
     180    "skip" the network pipeline, so the `CompletionHandler` is not invoked for those commands.
     181   
     182    * inspector/InspectorInstrumentation.cpp:
     183    (WebCore::InspectorInstrumentation::interceptRequestImpl):
     184    * inspector/InspectorInstrumentation.h:
     185    (WebCore::InspectorInstrumentation::interceptRequest):
     186    * inspector/InspectorInstrumentationWebKit.cpp:
     187    (WebCore::InspectorInstrumentationWebKit::interceptRequestInternal):
     188    * inspector/InspectorInstrumentationWebKit.h:
     189    (WebCore::InspectorInstrumentationWebKit::interceptRequest):
     190    * inspector/agents/InspectorNetworkAgent.cpp:
     191    (WebCore::InspectorNetworkAgent::interceptRequest):
     192    (WebCore::InspectorNetworkAgent::interceptRequestWithResponse):
     193    (WebCore::InspectorNetworkAgent::interceptRequestWithError):
     194    * inspector/agents/InspectorNetworkAgent.h:
     195    (WebCore::InspectorNetworkAgent::PendingInterceptRequest::PendingInterceptRequest):
     196    (WebCore::InspectorNetworkAgent::PendingInterceptRequest::continueAsHandled):
     197   
     198    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@263119 268f45cc-cd09-0410-ab3c-d52691b4dbfc
     199
     200    2020-06-16  Pavel Feldman  <pavel.feldman@gmail.com>
     201
     202            Web Inspector: replace completion handler with a function in interception.
     203            https://bugs.webkit.org/show_bug.cgi?id=213252
     204
     205            Reviewed by Devin Rousso.
     206
     207            Don't use a `CompletionHandler` as it asserts that it's been called when it's destroyed.
     208            Both `Network.interceptRequestWithResponse` and `Network.interceptRequestWithError` essentially
     209            "skip" the network pipeline, so the `CompletionHandler` is not invoked for those commands.
     210
     211            * inspector/InspectorInstrumentation.cpp:
     212            (WebCore::InspectorInstrumentation::interceptRequestImpl):
     213            * inspector/InspectorInstrumentation.h:
     214            (WebCore::InspectorInstrumentation::interceptRequest):
     215            * inspector/InspectorInstrumentationWebKit.cpp:
     216            (WebCore::InspectorInstrumentationWebKit::interceptRequestInternal):
     217            * inspector/InspectorInstrumentationWebKit.h:
     218            (WebCore::InspectorInstrumentationWebKit::interceptRequest):
     219            * inspector/agents/InspectorNetworkAgent.cpp:
     220            (WebCore::InspectorNetworkAgent::interceptRequest):
     221            (WebCore::InspectorNetworkAgent::interceptRequestWithResponse):
     222            (WebCore::InspectorNetworkAgent::interceptRequestWithError):
     223            * inspector/agents/InspectorNetworkAgent.h:
     224            (WebCore::InspectorNetworkAgent::PendingInterceptRequest::PendingInterceptRequest):
     225            (WebCore::InspectorNetworkAgent::PendingInterceptRequest::continueAsHandled):
     226
    12272020-06-15  Megan Gardner  <megan_gardner@apple.com>
    2228
  • branches/safari-610.1.17-branch/Source/WebCore/Sources.txt

    r263238 r263279  
    11351135html/DateTimeInputType.cpp
    11361136html/DateTimeLocalInputType.cpp
     1137html/DirectoryFileListCreator.cpp
    11371138html/EmailInputType.cpp
    11381139html/EnterKeyHint.cpp
    11391140html/FTPDirectoryDocument.cpp
    1140 html/FileListCreator.cpp
    11411141html/FeaturePolicy.cpp
    11421142html/FileInputType.cpp
  • branches/safari-610.1.17-branch/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r263238 r263279  
    24322432                835D2D781F5F1FBD00141DED /* HTMLInputElementEntriesAPI.h in Headers */ = {isa = PBXBuildFile; fileRef = 835D2D751F5F1FB800141DED /* HTMLInputElementEntriesAPI.h */; };
    24332433                835D363719FF6193004C93AB /* StyleBuilderCustom.h in Headers */ = {isa = PBXBuildFile; fileRef = 835D363619FF6193004C93AB /* StyleBuilderCustom.h */; };
    2434                 835D54C51F4DE53800E60671 /* FileListCreator.h in Headers */ = {isa = PBXBuildFile; fileRef = 835D54C21F4DE53400E60671 /* FileListCreator.h */; };
     2434                835D54C51F4DE53800E60671 /* DirectoryFileListCreator.h in Headers */ = {isa = PBXBuildFile; fileRef = 835D54C21F4DE53400E60671 /* DirectoryFileListCreator.h */; };
    24352435                8362E8C120CEF9CB00245886 /* ShouldTreatAsContinuingLoad.h in Headers */ = {isa = PBXBuildFile; fileRef = 8362E8BF20CEF9CB00245886 /* ShouldTreatAsContinuingLoad.h */; settings = {ATTRIBUTES = (Private, ); }; };
    24362436                836589DE1F54A76900DC31F4 /* JSFileSystemDirectoryReader.h in Headers */ = {isa = PBXBuildFile; fileRef = 836589D91F54A76200DC31F4 /* JSFileSystemDirectoryReader.h */; };
     
    1035910359                835D2D761F5F1FB800141DED /* HTMLInputElementEntriesAPI.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HTMLInputElementEntriesAPI.cpp; sourceTree = "<group>"; };
    1036010360                835D363619FF6193004C93AB /* StyleBuilderCustom.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StyleBuilderCustom.h; sourceTree = "<group>"; };
    10361                 835D54C11F4DE53400E60671 /* FileListCreator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FileListCreator.cpp; sourceTree = "<group>"; };
    10362                 835D54C21F4DE53400E60671 /* FileListCreator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FileListCreator.h; sourceTree = "<group>"; };
     10361                835D54C11F4DE53400E60671 /* DirectoryFileListCreator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DirectoryFileListCreator.cpp; sourceTree = "<group>"; };
     10362                835D54C21F4DE53400E60671 /* DirectoryFileListCreator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DirectoryFileListCreator.h; sourceTree = "<group>"; };
    1036310363                835F8B261D2D90BA00E408EC /* Slotable.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = Slotable.idl; sourceTree = "<group>"; };
    1036410364                8362E8BF20CEF9CB00245886 /* ShouldTreatAsContinuingLoad.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ShouldTreatAsContinuingLoad.h; sourceTree = "<group>"; };
     
    2225822258                                F55B3D851251F12D003EF269 /* DateTimeLocalInputType.cpp */,
    2225922259                                F55B3D861251F12D003EF269 /* DateTimeLocalInputType.h */,
     22260                                835D54C11F4DE53400E60671 /* DirectoryFileListCreator.cpp */,
     22261                                835D54C21F4DE53400E60671 /* DirectoryFileListCreator.h */,
    2226022262                                2ED609BA1145B07100C8684E /* DOMFormData.cpp */,
    2226122263                                2ED609BB1145B07100C8684E /* DOMFormData.h */,
     
    2227522277                                F55B3D891251F12D003EF269 /* FileInputType.cpp */,
    2227622278                                F55B3D8A1251F12D003EF269 /* FileInputType.h */,
    22277                                 835D54C11F4DE53400E60671 /* FileListCreator.cpp */,
    22278                                 835D54C21F4DE53400E60671 /* FileListCreator.h */,
    2227922279                                4A0DA2FC129B241900AB61E1 /* FormAssociatedElement.cpp */,
    2228022280                                4A0DA2FD129B241900AB61E1 /* FormAssociatedElement.h */,
     
    2999329993                                7CAC6AE9247F082F00E61D59 /* ColorMatrix.h in Headers */,
    2999429994                                9382DF5810A8D5C900925652 /* ColorSpace.h in Headers */,
     29995                                7C029C6E2493C8F800268204 /* ColorTypes.h in Headers */,
    2999529996                                0FEAF66B23BFC39E004030DA /* ColorUtilities.h in Headers */,
    2999629997                                BCDD454E1236C95C009A7985 /* ColumnInfo.h in Headers */,
     
    3035730358                                2D5646B01B8F8493003C4994 /* DictionaryPopupInfo.h in Headers */,
    3035830359                                FDAF19991513D131008DB0C3 /* DirectConvolver.h in Headers */,
     30360                                835D54C51F4DE53800E60671 /* DirectoryFileListCreator.h in Headers */,
    3035930361                                F47A09D120A93A9700240FAE /* DisabledAdaptations.h in Headers */,
    3036030362                                7EDAAFC919A2CCDC0034DFD1 /* DiskCacheMonitorCocoa.h in Headers */,
     
    3058930591                                F55B3DBE1251F12D003EF269 /* FileInputType.h in Headers */,
    3059030592                                976D6C86122B8A3D001FD1F7 /* FileList.h in Headers */,
    30591                                 835D54C51F4DE53800E60671 /* FileListCreator.h in Headers */,
    3059230593                                7A09CEF11F02069B00E93BDB /* FileMonitor.h in Headers */,
    3059330594                                976D6C89122B8A3D001FD1F7 /* FileReader.h in Headers */,
     
    3311133112                                FE36FD1716C7826500F887C1 /* SQLTransactionStateMachine.h in Headers */,
    3311233113                                1A2E6E5A0CC55213004A2062 /* SQLValue.h in Headers */,
    33113                                 7C029C6E2493C8F800268204 /* ColorTypes.h in Headers */,
    3311433114                                93F1996308245E59001E9ABC /* SSLKeyGenerator.h in Headers */,
    3311533115                                26B999911803B3C900D01121 /* StackAllocator.h in Headers */,
  • branches/safari-610.1.17-branch/Source/WebCore/dom/Document.cpp

    r263238 r263279  
    85908590    // Some canvas contexts need to do work when rendering has finished but
    85918591    // before their content is composited.
    8592     for (auto* canvas : m_canvasesNeedingDisplayPreparation) {
     8592    for (auto* canvas : copyToVector(m_canvasesNeedingDisplayPreparation)) {
    85938593        // However, if they are not in the document body, then they won't
    85948594        // be composited and thus don't need preparation. Unfortunately they
     
    86048604}
    86058605
     8606void Document::clearCanvasPreparation(HTMLCanvasElement* canvas)
     8607{
     8608    m_canvasesNeedingDisplayPreparation.remove(canvas);
     8609}
     8610
    86068611void Document::canvasChanged(CanvasBase& canvasBase, const FloatRect&)
    86078612{
  • branches/safari-610.1.17-branch/Source/WebCore/dom/Document.h

    r263238 r263279  
    15971597
    15981598    void prepareCanvasesForDisplayIfNeeded();
     1599    void clearCanvasPreparation(HTMLCanvasElement*);
    15991600    void canvasChanged(CanvasBase&, const FloatRect&) final;
    16001601    void canvasResized(CanvasBase&) final { };
  • branches/safari-610.1.17-branch/Source/WebCore/html/DirectoryFileListCreator.cpp

    r263239 r263279  
    2525
    2626#include "config.h"
    27 #include "FileListCreator.h"
     27#include "DirectoryFileListCreator.h"
    2828
    2929#include "FileChooser.h"
     
    3535namespace WebCore {
    3636
    37 FileListCreator::~FileListCreator()
     37DirectoryFileListCreator::~DirectoryFileListCreator()
    3838{
    3939    ASSERT(!m_completionHandler);
     
    5858}
    5959
    60 template<FileListCreator::ShouldResolveDirectories shouldResolveDirectories>
    6160static Ref<FileList> createFileList(const Vector<FileChooserFileInfo>& paths)
    6261{
    6362    Vector<Ref<File>> fileObjects;
    6463    for (auto& info : paths) {
    65         if (shouldResolveDirectories == FileListCreator::ShouldResolveDirectories::Yes && FileSystem::fileIsDirectory(info.path, FileSystem::ShouldFollowSymbolicLinks::No))
     64        if (FileSystem::fileIsDirectory(info.path, FileSystem::ShouldFollowSymbolicLinks::No))
    6665            appendDirectoryFiles(info.path, FileSystem::pathGetFileName(info.path), fileObjects);
    6766        else
     
    7170}
    7271
    73 RefPtr<FileListCreator> FileListCreator::create(const Vector<FileChooserFileInfo>& paths, ShouldResolveDirectories shouldResolveDirectories, CompletionHandler&& completionHandler)
     72DirectoryFileListCreator::DirectoryFileListCreator(CompletionHandler&& completionHandler)
     73    : m_workQueue(WorkQueue::create("DirectoryFileListCreator Work Queue"))
     74    , m_completionHandler(WTFMove(completionHandler))
    7475{
    75     if (shouldResolveDirectories == ShouldResolveDirectories::No) {
    76         completionHandler(createFileList<ShouldResolveDirectories::No>(paths));
    77         return nullptr;
    78     }
    79 
    80     return adoptRef(*new FileListCreator(paths, WTFMove(completionHandler)));
    8176}
    8277
    83 FileListCreator::FileListCreator(const Vector<FileChooserFileInfo>& paths, CompletionHandler&& completionHandler)
    84     : m_workQueue(WorkQueue::create("FileListCreator Work Queue"))
    85     , m_completionHandler(WTFMove(completionHandler))
     78void DirectoryFileListCreator::start(const Vector<FileChooserFileInfo>& paths)
    8679{
    8780    // Resolve directories on a background thread to avoid blocking the main thread.
    8881    m_workQueue->dispatch([this, protectedThis = makeRef(*this), paths = crossThreadCopy(paths)]() mutable {
    89         auto fileList = createFileList<ShouldResolveDirectories::Yes>(paths);
    90         callOnMainThread([this, protectedThis = WTFMove(protectedThis), fileList = WTFMove(fileList)]() mutable {
    91             if (auto completionHandler = WTFMove(m_completionHandler))
     82        callOnMainThread([this, protectedThis = WTFMove(protectedThis), fileList = createFileList(paths)]() mutable {
     83            if (auto completionHandler = std::exchange(m_completionHandler, nullptr))
    9284                completionHandler(WTFMove(fileList));
    9385        });
     
    9587}
    9688
    97 void FileListCreator::cancel()
     89void DirectoryFileListCreator::cancel()
    9890{
    9991    m_completionHandler = nullptr;
  • branches/safari-610.1.17-branch/Source/WebCore/html/DirectoryFileListCreator.h

    r263239 r263279  
    3737class FileList;
    3838
    39 class FileListCreator : public ThreadSafeRefCounted<FileListCreator> {
     39class DirectoryFileListCreator : public ThreadSafeRefCounted<DirectoryFileListCreator> {
    4040public:
    4141    using CompletionHandler = Function<void(Ref<FileList>&&)>;
    4242
    43     enum class ShouldResolveDirectories { No, Yes };
    44     static RefPtr<FileListCreator> create(const Vector<FileChooserFileInfo>&, ShouldResolveDirectories, CompletionHandler&&);
     43    static Ref<DirectoryFileListCreator> create(CompletionHandler&& completionHandler)
     44    {
     45        return adoptRef(*new DirectoryFileListCreator(WTFMove(completionHandler)));
     46    }
    4547
    46     ~FileListCreator();
     48    ~DirectoryFileListCreator();
    4749
     50    void start(const Vector<FileChooserFileInfo>&);
    4851    void cancel();
    4952
    5053private:
    51     FileListCreator(const Vector<FileChooserFileInfo>&, CompletionHandler&&);
     54    explicit DirectoryFileListCreator(CompletionHandler&&);
    5255
    5356    RefPtr<WorkQueue> m_workQueue;
  • branches/safari-610.1.17-branch/Source/WebCore/html/FileInputType.cpp

    r263238 r263279  
    2525#include "Chrome.h"
    2626#include "DOMFormData.h"
     27#include "DirectoryFileListCreator.h"
    2728#include "DragData.h"
    2829#include "ElementChildIterator.h"
     
    3031#include "File.h"
    3132#include "FileList.h"
    32 #include "FileListCreator.h"
    3333#include "FormController.h"
    3434#include "Frame.h"
     
    410410        m_displayString = displayString;
    411411
    412     if (m_fileListCreator)
    413         m_fileListCreator->cancel();
    414 
    415     auto shouldResolveDirectories = allowsDirectories() ? FileListCreator::ShouldResolveDirectories::Yes : FileListCreator::ShouldResolveDirectories::No;
    416     m_fileListCreator = FileListCreator::create(paths, shouldResolveDirectories, [this, weakThis = makeWeakPtr(*this), icon = makeRefPtr(icon)](Ref<FileList>&& fileList) mutable {
    417         auto protectedThis = makeRefPtr(weakThis.get());
    418         if (!protectedThis)
     412    if (m_directoryFileListCreator)
     413        m_directoryFileListCreator->cancel();
     414
     415    if (!allowsDirectories()) {
     416        auto files = paths.map([](auto& fileInfo) {
     417            return File::create(fileInfo.path, fileInfo.displayName);
     418        });
     419        didCreateFileList(FileList::create(WTFMove(files)), icon);
     420        return;
     421    }
     422
     423    m_directoryFileListCreator = DirectoryFileListCreator::create([this, weakThis = makeWeakPtr(*this), icon = makeRefPtr(icon)](Ref<FileList>&& fileList) mutable {
     424        ASSERT(isMainThread());
     425        if (!weakThis)
    419426            return;
    420         setFiles(WTFMove(fileList), icon ? RequestIcon::Yes : RequestIcon::No);
    421         if (icon && !m_fileList->isEmpty() && element())
    422             iconLoaded(WTFMove(icon));
    423         m_fileListCreator = nullptr;
     427        didCreateFileList(WTFMove(fileList), WTFMove(icon));
    424428    });
     429    m_directoryFileListCreator->start(paths);
     430}
     431
     432void FileInputType::didCreateFileList(Ref<FileList>&& fileList, RefPtr<Icon>&& icon)
     433{
     434    auto protectedThis = makeRef(*this);
     435
     436    ASSERT(!allowsDirectories() || m_directoryFileListCreator);
     437    m_directoryFileListCreator = nullptr;
     438
     439    setFiles(WTFMove(fileList), icon ? RequestIcon::Yes : RequestIcon::No);
     440    if (icon && !m_fileList->isEmpty() && element())
     441        iconLoaded(WTFMove(icon));
    425442}
    426443
  • branches/safari-610.1.17-branch/Source/WebCore/html/FileInputType.h

    r263238 r263279  
    4040namespace WebCore {
    4141
     42class DirectoryFileListCreator;
    4243class DragData;
    4344class FileList;
    44 class FileListCreator;
    4545class Icon;
    4646
     
    8787    void iconLoaded(RefPtr<Icon>&&) final;
    8888
     89    void applyFileChooserSettings(const FileChooserSettings&);
     90    void didCreateFileList(Ref<FileList>&&, RefPtr<Icon>&&);
    8991    void requestIcon(const Vector<String>&);
    90 
    91     void applyFileChooserSettings(const FileChooserSettings&);
    9292
    9393    bool allowsDirectories() const;
     
    9797
    9898    Ref<FileList> m_fileList;
    99     RefPtr<FileListCreator> m_fileListCreator;
     99    RefPtr<DirectoryFileListCreator> m_directoryFileListCreator;
    100100    RefPtr<Icon> m_icon;
    101101    String m_displayString;
  • branches/safari-610.1.17-branch/Source/WebCore/html/HTMLCanvasElement.cpp

    r263238 r263279  
    147147    // downcasts the CanvasBase object to HTMLCanvasElement. That invokes virtual methods, which should be
    148148    // avoided in destructors, but works as long as it's done before HTMLCanvasElement destructs completely.
    149     // This will also cause the document to remove itself as an observer.
    150149    notifyObserversCanvasDestroyed();
     150    document().clearCanvasPreparation(this);
    151151
    152152    m_context = nullptr; // Ensure this goes away before the ImageBuffer.
     
    10021002void HTMLCanvasElement::didMoveToNewDocument(Document& oldDocument, Document& newDocument)
    10031003{
     1004    oldDocument.clearCanvasPreparation(this);
    10041005    removeObserver(oldDocument);
    10051006    addObserver(newDocument);
     
    10101011void HTMLCanvasElement::removedFromAncestor(RemovalType removalType, ContainerNode& oldParentOfRemovedTree)
    10111012{
    1012     if (removalType.disconnectedFromDocument)
     1013    if (removalType.disconnectedFromDocument) {
     1014        oldParentOfRemovedTree.document().clearCanvasPreparation(this);
    10131015        removeObserver(oldParentOfRemovedTree.document());
     1016    }
    10141017
    10151018    HTMLElement::removedFromAncestor(removalType, oldParentOfRemovedTree);
  • branches/safari-610.1.17-branch/Source/WebCore/inspector/InspectorInstrumentation.cpp

    r263238 r263279  
    833833}
    834834
    835 void InspectorInstrumentation::interceptRequestImpl(InstrumentingAgents& instrumentingAgents, ResourceLoader& loader, CompletionHandler<void(const ResourceRequest&)>&& handler)
     835void InspectorInstrumentation::interceptRequestImpl(InstrumentingAgents& instrumentingAgents, ResourceLoader& loader, Function<void(const ResourceRequest&)>&& handler)
    836836{
    837837    if (auto* networkAgent = instrumentingAgents.enabledNetworkAgent())
  • branches/safari-610.1.17-branch/Source/WebCore/inspector/InspectorInstrumentation.h

    r263238 r263279  
    5353#include <initializer_list>
    5454#include <wtf/CompletionHandler.h>
     55#include <wtf/Function.h>
    5556#include <wtf/MemoryPressureHandler.h>
    5657#include <wtf/RefPtr.h>
     
    239240    static bool shouldInterceptRequest(const Frame&, const ResourceRequest&);
    240241    static bool shouldInterceptResponse(const Frame&, const ResourceResponse&);
    241     static void interceptRequest(ResourceLoader&, CompletionHandler<void(const ResourceRequest&)>&&);
     242    static void interceptRequest(ResourceLoader&, Function<void(const ResourceRequest&)>&&);
    242243    static void interceptResponse(const Frame&, const ResourceResponse&, unsigned long identifier, CompletionHandler<void(const ResourceResponse&, RefPtr<SharedBuffer>)>&&);
    243244
     
    449450    static bool shouldInterceptRequestImpl(InstrumentingAgents&, const ResourceRequest&);
    450451    static bool shouldInterceptResponseImpl(InstrumentingAgents&, const ResourceResponse&);
    451     static void interceptRequestImpl(InstrumentingAgents&, ResourceLoader&, CompletionHandler<void(const ResourceRequest&)>&&);
     452    static void interceptRequestImpl(InstrumentingAgents&, ResourceLoader&, Function<void(const ResourceRequest&)>&&);
    452453    static void interceptResponseImpl(InstrumentingAgents&, const ResourceResponse&, unsigned long identifier, CompletionHandler<void(const ResourceResponse&, RefPtr<SharedBuffer>)>&&);
    453454
     
    12871288}
    12881289
    1289 inline void InspectorInstrumentation::interceptRequest(ResourceLoader& loader, CompletionHandler<void(const ResourceRequest&)>&& handler)
     1290inline void InspectorInstrumentation::interceptRequest(ResourceLoader& loader, Function<void(const ResourceRequest&)>&& handler)
    12901291{
    12911292    ASSERT(InspectorInstrumentation::shouldInterceptRequest(*loader.frame(), loader.request()));
  • branches/safari-610.1.17-branch/Source/WebCore/inspector/InspectorInstrumentationWebKit.cpp

    r263238 r263279  
    4141}
    4242
    43 void InspectorInstrumentationWebKit::interceptRequestInternal(ResourceLoader& loader, CompletionHandler<void(const ResourceRequest&)>&& handler)
     43void InspectorInstrumentationWebKit::interceptRequestInternal(ResourceLoader& loader, Function<void(const ResourceRequest&)>&& handler)
    4444{
    4545    InspectorInstrumentation::interceptRequest(loader, WTFMove(handler));
  • branches/safari-610.1.17-branch/Source/WebCore/inspector/InspectorInstrumentationWebKit.h

    r263238 r263279  
    2828#include "InspectorInstrumentationPublic.h"
    2929#include <wtf/CompletionHandler.h>
     30#include <wtf/Function.h>
    3031
    3132namespace WebCore {
     
    3940    static bool shouldInterceptRequest(const Frame*, const ResourceRequest&);
    4041    static bool shouldInterceptResponse(const Frame*, const ResourceResponse&);
    41     static void interceptRequest(ResourceLoader&, CompletionHandler<void(const ResourceRequest&)>&&);
     42    static void interceptRequest(ResourceLoader&, Function<void(const ResourceRequest&)>&&);
    4243    static void interceptResponse(const Frame*, const ResourceResponse&, unsigned long identifier, CompletionHandler<void(const ResourceResponse&, RefPtr<SharedBuffer>)>&&);
    4344
     
    4546    static bool shouldInterceptRequestInternal(const Frame&, const ResourceRequest&);
    4647    static bool shouldInterceptResponseInternal(const Frame&, const ResourceResponse&);
    47     static void interceptRequestInternal(ResourceLoader&, CompletionHandler<void(const ResourceRequest&)>&&);
     48    static void interceptRequestInternal(ResourceLoader&, Function<void(const ResourceRequest&)>&&);
    4849    static void interceptResponseInternal(const Frame&, const ResourceResponse&, unsigned long identifier, CompletionHandler<void(const ResourceResponse&, RefPtr<SharedBuffer>)>&&);
    4950};
     
    6768}
    6869
    69 inline void InspectorInstrumentationWebKit::interceptRequest(ResourceLoader& loader, CompletionHandler<void(const ResourceRequest&)>&& handler)
     70inline void InspectorInstrumentationWebKit::interceptRequest(ResourceLoader& loader, Function<void(const ResourceRequest&)>&& handler)
    7071{
    7172    ASSERT(InspectorInstrumentationWebKit::shouldInterceptRequest(loader.frame(), loader.request()));
  • branches/safari-610.1.17-branch/Source/WebCore/inspector/agents/InspectorNetworkAgent.cpp

    r263238 r263279  
    11151115}
    11161116
    1117 void InspectorNetworkAgent::interceptRequest(ResourceLoader& loader, CompletionHandler<void(const ResourceRequest&)>&& handler)
     1117void InspectorNetworkAgent::interceptRequest(ResourceLoader& loader, Function<void(const ResourceRequest&)>&& handler)
    11181118{
    11191119    ASSERT(m_enabled);
  • branches/safari-610.1.17-branch/Source/WebCore/inspector/agents/InspectorNetworkAgent.h

    r263238 r263279  
    126126    bool shouldInterceptResponse(const ResourceResponse&);
    127127    void interceptResponse(const ResourceResponse&, unsigned long identifier, CompletionHandler<void(const ResourceResponse&, RefPtr<SharedBuffer>)>&&);
    128     void interceptRequest(ResourceLoader&, CompletionHandler<void(const ResourceRequest&)>&&);
     128    void interceptRequest(ResourceLoader&, Function<void(const ResourceRequest&)>&&);
    129129
    130130    void searchOtherRequests(const JSC::Yarr::RegularExpression&, RefPtr<JSON::ArrayOf<Inspector::Protocol::Page::SearchResult>>&);
     
    165165        WTF_MAKE_FAST_ALLOCATED;
    166166    public:
    167         PendingInterceptRequest(RefPtr<ResourceLoader> loader, CompletionHandler<void(const ResourceRequest&)>&& completionHandler)
     167        PendingInterceptRequest(RefPtr<ResourceLoader> loader, Function<void(const ResourceRequest&)>&& callback)
    168168            : m_loader(loader)
    169             , m_completionHandler(WTFMove(completionHandler))
     169            , m_completionCallback(WTFMove(callback))
    170170        { }
    171171
     
    173173        {
    174174            if (!m_loader->reachedTerminalState())
    175                 m_completionHandler(m_loader->request());
     175                m_completionCallback(m_loader->request());
    176176        }
    177177
    178178        void continueWithRequest(const ResourceRequest& request)
    179179        {
    180             m_completionHandler(request);
     180            m_completionCallback(request);
    181181        }
    182182
    183183        PendingInterceptRequest() = default;
    184184        RefPtr<ResourceLoader> m_loader;
    185         CompletionHandler<void(const ResourceRequest&)> m_completionHandler;
     185        Function<void(const ResourceRequest&)> m_completionCallback;
    186186    };
    187187
Note: See TracChangeset for help on using the changeset viewer.