| Differences between
and this patch
- Source/WebCore/ChangeLog +28 lines
Lines 1-3 Source/WebCore/ChangeLog_sec1
1
2020-07-03  Said Abou-Hallawa  <sabouhallawa@apple.com>
2
3
        [macOS]: Allow selecting HEIF images if the 'accept' attribute includes a supported for encoding mime type
4
        https://bugs.webkit.org/show_bug.cgi?id=212489
5
6
        Reviewed by NOBODY (OOPS!).
7
8
        Move the structure FileChooserSettings to a separate source and header.
9
10
        * Headers.cmake:
11
        * Sources.txt:
12
        * WebCore.xcodeproj/project.pbxproj:
13
        * platform/FileChooser.h:
14
        * platform/FileChooserSettings.cpp: Added.
15
        (WebCore::trimmedExtension):
16
        (WebCore::shouldAppendNotAcceptedExtensions):
17
        (WebCore::FileChooserSettings::allowedMIMETypes const):
18
        It returns the set of mime types which is stated in the accept attribute
19
        of the <input> element.
20
21
        (WebCore::FileChooserSettings::allowedFileExtensions const):
22
        It returns the set of extensions which is stated in the accept attribute
23
        of the <input> element. The extensions of the HEIF/HEIC will be included
24
        as well if 'accept' attribute include a mime type which is supported for
25
        encoding.
26
27
        * platform/FileChooserSettings.h: Added.
28
1
2020-07-03  Said Abou-Hallawa  <sabouhallawa@apple.com>
29
2020-07-03  Said Abou-Hallawa  <sabouhallawa@apple.com>
2
30
3
        Change the names of MIMETypeRegistry methods to comply with webkit naming style
31
        Change the names of MIMETypeRegistry methods to comply with webkit naming style
- Source/WebCore/Headers.cmake +1 lines
Lines 945-950 set(WebCore_PRIVATE_FRAMEWORK_HEADERS Source/WebCore/Headers.cmake_sec1
945
    platform/DragItem.h
945
    platform/DragItem.h
946
    platform/EventTrackingRegions.h
946
    platform/EventTrackingRegions.h
947
    platform/FileChooser.h
947
    platform/FileChooser.h
948
    platform/FileChooserSettings.h
948
    platform/FileHandle.h
949
    platform/FileHandle.h
949
    platform/FileMonitor.h
950
    platform/FileMonitor.h
950
    platform/FileStreamClient.h
951
    platform/FileStreamClient.h
- Source/WebCore/Sources.txt +1 lines
Lines 1797-1802 platform/DragData.cpp Source/WebCore/Sources.txt_sec1
1797
platform/DragImage.cpp
1797
platform/DragImage.cpp
1798
platform/EventTrackingRegions.cpp
1798
platform/EventTrackingRegions.cpp
1799
platform/FileChooser.cpp
1799
platform/FileChooser.cpp
1800
platform/FileChooserSettings.cpp
1800
platform/FileHandle.cpp
1801
platform/FileHandle.cpp
1801
platform/FileMonitor.cpp
1802
platform/FileMonitor.cpp
1802
platform/FileStream.cpp
1803
platform/FileStream.cpp
- Source/WebCore/WebCore.xcodeproj/project.pbxproj -1 / +7 lines
Lines 1745-1750 Source/WebCore/WebCore.xcodeproj/project.pbxproj_sec1
1745
		556C7C4B22123997009B06CA /* RenderingUpdateScheduler.h in Headers */ = {isa = PBXBuildFile; fileRef = 556C7C4722123942009B06CA /* RenderingUpdateScheduler.h */; settings = {ATTRIBUTES = (Private, ); }; };
1745
		556C7C4B22123997009B06CA /* RenderingUpdateScheduler.h in Headers */ = {isa = PBXBuildFile; fileRef = 556C7C4722123942009B06CA /* RenderingUpdateScheduler.h */; settings = {ATTRIBUTES = (Private, ); }; };
1746
		5576A5651D88A70800CCC04C /* ImageFrame.h in Headers */ = {isa = PBXBuildFile; fileRef = 5576A5631D88A70800CCC04C /* ImageFrame.h */; settings = {ATTRIBUTES = (Private, ); }; };
1746
		5576A5651D88A70800CCC04C /* ImageFrame.h in Headers */ = {isa = PBXBuildFile; fileRef = 5576A5631D88A70800CCC04C /* ImageFrame.h */; settings = {ATTRIBUTES = (Private, ); }; };
1747
		5584765A2453F334009F550C /* ReducedResolutionSeconds.h in Headers */ = {isa = PBXBuildFile; fileRef = 558476582453ABC2009F550C /* ReducedResolutionSeconds.h */; settings = {ATTRIBUTES = (Private, ); }; };
1747
		5584765A2453F334009F550C /* ReducedResolutionSeconds.h in Headers */ = {isa = PBXBuildFile; fileRef = 558476582453ABC2009F550C /* ReducedResolutionSeconds.h */; settings = {ATTRIBUTES = (Private, ); }; };
1748
		559B76D724AD903800F92423 /* FileChooserSettings.h in Headers */ = {isa = PBXBuildFile; fileRef = 559B76D324AD88B700F92423 /* FileChooserSettings.h */; settings = {ATTRIBUTES = (Private, ); }; };
1748
		55A336F91D821E3C0022C4C7 /* ImageBackingStore.h in Headers */ = {isa = PBXBuildFile; fileRef = 55A336F81D821E3C0022C4C7 /* ImageBackingStore.h */; settings = {ATTRIBUTES = (Private, ); }; };
1749
		55A336F91D821E3C0022C4C7 /* ImageBackingStore.h in Headers */ = {isa = PBXBuildFile; fileRef = 55A336F81D821E3C0022C4C7 /* ImageBackingStore.h */; settings = {ATTRIBUTES = (Private, ); }; };
1749
		55AD093E2408963500DE4D2F /* DisplayListImageBuffer.h in Headers */ = {isa = PBXBuildFile; fileRef = 72EA09F723FCCB3D008504A5 /* DisplayListImageBuffer.h */; settings = {ATTRIBUTES = (Private, ); }; };
1750
		55AD093E2408963500DE4D2F /* DisplayListImageBuffer.h in Headers */ = {isa = PBXBuildFile; fileRef = 72EA09F723FCCB3D008504A5 /* DisplayListImageBuffer.h */; settings = {ATTRIBUTES = (Private, ); }; };
1750
		55AD09402408964000DE4D2F /* DisplayListDrawingContext.h in Headers */ = {isa = PBXBuildFile; fileRef = 72EA09F923FCCC6A008504A5 /* DisplayListDrawingContext.h */; settings = {ATTRIBUTES = (Private, ); }; };
1751
		55AD09402408964000DE4D2F /* DisplayListDrawingContext.h in Headers */ = {isa = PBXBuildFile; fileRef = 72EA09F923FCCC6A008504A5 /* DisplayListDrawingContext.h */; settings = {ATTRIBUTES = (Private, ); }; };
Lines 8763-8768 Source/WebCore/WebCore.xcodeproj/project.pbxproj_sec2
8763
		5576A5631D88A70800CCC04C /* ImageFrame.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ImageFrame.h; sourceTree = "<group>"; };
8764
		5576A5631D88A70800CCC04C /* ImageFrame.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ImageFrame.h; sourceTree = "<group>"; };
8764
		558476582453ABC2009F550C /* ReducedResolutionSeconds.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ReducedResolutionSeconds.h; sourceTree = "<group>"; };
8765
		558476582453ABC2009F550C /* ReducedResolutionSeconds.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ReducedResolutionSeconds.h; sourceTree = "<group>"; };
8765
		5597FCCB2076C06800D35BB0 /* GlyphDisplayListCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GlyphDisplayListCache.h; sourceTree = "<group>"; };
8766
		5597FCCB2076C06800D35BB0 /* GlyphDisplayListCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GlyphDisplayListCache.h; sourceTree = "<group>"; };
8767
		559B76D224AD88B700F92423 /* FileChooserSettings.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = FileChooserSettings.cpp; sourceTree = "<group>"; };
8768
		559B76D324AD88B700F92423 /* FileChooserSettings.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FileChooserSettings.h; sourceTree = "<group>"; };
8766
		55A336F61D8209F40022C4C7 /* NativeImage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NativeImage.h; sourceTree = "<group>"; };
8769
		55A336F61D8209F40022C4C7 /* NativeImage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NativeImage.h; sourceTree = "<group>"; };
8767
		55A336F81D821E3C0022C4C7 /* ImageBackingStore.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ImageBackingStore.h; sourceTree = "<group>"; };
8770
		55A336F81D821E3C0022C4C7 /* ImageBackingStore.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ImageBackingStore.h; sourceTree = "<group>"; };
8768
		55AF14E31EAAC59B0026EEAA /* UTIRegistry.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = UTIRegistry.cpp; sourceTree = "<group>"; };
8771
		55AF14E31EAAC59B0026EEAA /* UTIRegistry.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = UTIRegistry.cpp; sourceTree = "<group>"; };
Lines 26457-26462 Source/WebCore/WebCore.xcodeproj/project.pbxproj_sec3
26457
				262EC4191D078F3D00BA78FC /* EventTrackingRegions.h */,
26460
				262EC4191D078F3D00BA78FC /* EventTrackingRegions.h */,
26458
				934FE9E40B5CA539003E4A73 /* FileChooser.cpp */,
26461
				934FE9E40B5CA539003E4A73 /* FileChooser.cpp */,
26459
				066C772A0AB603B700238CC4 /* FileChooser.h */,
26462
				066C772A0AB603B700238CC4 /* FileChooser.h */,
26463
				559B76D224AD88B700F92423 /* FileChooserSettings.cpp */,
26464
				559B76D324AD88B700F92423 /* FileChooserSettings.h */,
26460
				5351D4AE1DF916AC008010CD /* FileHandle.cpp */,
26465
				5351D4AE1DF916AC008010CD /* FileHandle.cpp */,
26461
				5351D4AF1DF916AC008010CD /* FileHandle.h */,
26466
				5351D4AF1DF916AC008010CD /* FileHandle.h */,
26462
				7A09CEEB1F01CC9300E93BDB /* FileMonitor.cpp */,
26467
				7A09CEEB1F01CC9300E93BDB /* FileMonitor.cpp */,
Lines 30688-30693 Source/WebCore/WebCore.xcodeproj/project.pbxproj_sec4
30688
				976D6C81122B8A3D001FD1F7 /* File.h in Headers */,
30693
				976D6C81122B8A3D001FD1F7 /* File.h in Headers */,
30689
				838F86DA1F509E7400E8CFC5 /* FileCallback.h in Headers */,
30694
				838F86DA1F509E7400E8CFC5 /* FileCallback.h in Headers */,
30690
				066C772B0AB603B700238CC4 /* FileChooser.h in Headers */,
30695
				066C772B0AB603B700238CC4 /* FileChooser.h in Headers */,
30696
				559B76D724AD903800F92423 /* FileChooserSettings.h in Headers */,
30691
				5351D4B11DF916B4008010CD /* FileHandle.h in Headers */,
30697
				5351D4B11DF916B4008010CD /* FileHandle.h in Headers */,
30692
				1A88A90517553CD7000C74F9 /* FileIconLoader.h in Headers */,
30698
				1A88A90517553CD7000C74F9 /* FileIconLoader.h in Headers */,
30693
				F55B3DBE1251F12D003EF269 /* FileInputType.h in Headers */,
30699
				F55B3DBE1251F12D003EF269 /* FileInputType.h in Headers */,
Lines 34442-34447 Source/WebCore/WebCore.xcodeproj/project.pbxproj_sec5
34442
				515BE18F1D54F5FB00DD7C68 /* EmptyGamepadProvider.cpp in Sources */,
34448
				515BE18F1D54F5FB00DD7C68 /* EmptyGamepadProvider.cpp in Sources */,
34443
				6E72F54C229DCD0C00B3E151 /* ExtensionsGLANGLE.cpp in Sources */,
34449
				6E72F54C229DCD0C00B3E151 /* ExtensionsGLANGLE.cpp in Sources */,
34444
				7CE6CBFD187F394900D46BF5 /* FormatConverter.cpp in Sources */,
34450
				7CE6CBFD187F394900D46BF5 /* FormatConverter.cpp in Sources */,
34451
				5130F2F624AEA60A00E1D0A0 /* GameControllerSoftLink.mm in Sources */,
34445
				51A4BB0A1954D61600FA5C2E /* Gamepad.cpp in Sources */,
34452
				51A4BB0A1954D61600FA5C2E /* Gamepad.cpp in Sources */,
34446
				518F4FF6194CA4E60081BAAE /* GamepadButton.cpp in Sources */,
34453
				518F4FF6194CA4E60081BAAE /* GamepadButton.cpp in Sources */,
34447
				516C62201950D48700337E75 /* GamepadEvent.cpp in Sources */,
34454
				516C62201950D48700337E75 /* GamepadEvent.cpp in Sources */,
Lines 34922-34928 Source/WebCore/WebCore.xcodeproj/project.pbxproj_sec6
34922
				DE5F84321FA186E9006DB63A /* UnifiedSource329.cpp in Sources */,
34929
				DE5F84321FA186E9006DB63A /* UnifiedSource329.cpp in Sources */,
34923
				DE5F84331FA186E9006DB63A /* UnifiedSource330.cpp in Sources */,
34930
				DE5F84331FA186E9006DB63A /* UnifiedSource330.cpp in Sources */,
34924
				DE5F84341FA186E9006DB63A /* UnifiedSource331.cpp in Sources */,
34931
				DE5F84341FA186E9006DB63A /* UnifiedSource331.cpp in Sources */,
34925
				5130F2F624AEA60A00E1D0A0 /* GameControllerSoftLink.mm in Sources */,
34926
				DE5F84351FA186E9006DB63A /* UnifiedSource332.cpp in Sources */,
34932
				DE5F84351FA186E9006DB63A /* UnifiedSource332.cpp in Sources */,
34927
				DE5F84361FA186E9006DB63A /* UnifiedSource333.cpp in Sources */,
34933
				DE5F84361FA186E9006DB63A /* UnifiedSource333.cpp in Sources */,
34928
				DE5F84371FA186E9006DB63A /* UnifiedSource334.cpp in Sources */,
34934
				DE5F84371FA186E9006DB63A /* UnifiedSource334.cpp in Sources */,
- Source/WebCore/platform/FileChooser.h -33 / +2 lines
Lines 29-47 Source/WebCore/platform/FileChooser.h_sec1
29
29
30
#pragma once
30
#pragma once
31
31
32
#include <wtf/EnumTraits.h>
32
#include "FileChooserSettings.h"
33
#include <wtf/HashSet.h>
33
#include <wtf/RefCounted.h>
34
#include <wtf/RefCounted.h>
34
#include <wtf/Vector.h>
35
#include <wtf/text/WTFString.h>
36
35
37
namespace WebCore {
36
namespace WebCore {
38
37
39
enum MediaCaptureType {
40
    MediaCaptureTypeNone,
41
    MediaCaptureTypeUser,
42
    MediaCaptureTypeEnvironment
43
};
44
45
class FileChooser;
38
class FileChooser;
46
class Icon;
39
class Icon;
47
40
Lines 56-72 struct FileChooserFileInfo { Source/WebCore/platform/FileChooser.h_sec2
56
    const String displayName;
49
    const String displayName;
57
};
50
};
58
51
59
struct FileChooserSettings {
60
    bool allowsDirectories { false };
61
    bool allowsMultipleFiles { false };
62
    Vector<String> acceptMIMETypes;
63
    Vector<String> acceptFileExtensions;
64
    Vector<String> selectedFiles;
65
#if ENABLE(MEDIA_CAPTURE)
66
    MediaCaptureType mediaCaptureType { MediaCaptureTypeNone };
67
#endif
68
};
69
70
class FileChooserClient {
52
class FileChooserClient {
71
public:
53
public:
72
    virtual ~FileChooserClient() = default;
54
    virtual ~FileChooserClient() = default;
Lines 102-117 private: Source/WebCore/platform/FileChooser.h_sec3
102
};
84
};
103
85
104
} // namespace WebCore
86
} // namespace WebCore
105
106
namespace WTF {
107
108
template<> struct EnumTraits<WebCore::MediaCaptureType> {
109
    using values = EnumValues<
110
        WebCore::MediaCaptureType,
111
        WebCore::MediaCaptureType::MediaCaptureTypeNone,
112
        WebCore::MediaCaptureType::MediaCaptureTypeUser,
113
        WebCore::MediaCaptureType::MediaCaptureTypeEnvironment
114
    >;
115
};
116
117
} // namespace WTF
- Source/WebCore/platform/FileChooserSettings.cpp +84 lines
Line 0 Source/WebCore/platform/FileChooserSettings.cpp_sec1
1
/*
2
 * Copyright (C) 2020 Apple Inc. All rights reserved.
3
 *
4
 * Redistribution and use in source and binary forms, with or without
5
 * modification, are permitted provided that the following conditions
6
 * are met:
7
 *
8
 * 1.  Redistributions of source code must retain the above copyright
9
 *     notice, this list of conditions and the following disclaimer.
10
 * 2.  Redistributions in binary form must reproduce the above copyright
11
 *     notice, this list of conditions and the following disclaimer in the
12
 *     documentation and/or other materials provided with the distribution.
13
 * 3.  Neither the name of Apple Inc. ("Apple") nor the names of
14
 *     its contributors may be used to endorse or promote products derived
15
 *     from this software without specific prior written permission.
16
 *
17
 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
18
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20
 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
21
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
 */
28
29
#include "config.h"
30
#include "FileChooserSettings.h"
31
32
#include "MIMETypeRegistry.h"
33
34
namespace WebCore {
35
36
static inline String trimmedExtension(const String& extension)
37
{
38
    return extension.startsWith('.') ? extension.right(extension.length() - 1) : extension;
39
}
40
41
static inline bool shouldAppendNotAcceptedExtensions(const Vector<String>& allowedMIMETypes)
42
{
43
    return allowedMIMETypes.findMatching([](const auto& mimeType) {
44
        return MIMETypeRegistry::isSupportedImageMIMETypeForEncoding(mimeType);
45
    }) != notFound;
46
}
47
48
Vector<String> FileChooserSettings::allowedMIMETypes() const
49
{
50
    Vector<String> allowedMIMETypes;
51
52
    for (auto& mimeType : this->acceptMIMETypes)
53
        allowedMIMETypes.appendIfNotContains(mimeType);
54
55
    for (auto& extension : this->acceptFileExtensions) {
56
        auto mimeType = MIMETypeRegistry::mimeTypeForExtension(trimmedExtension(extension));
57
        if (mimeType.isEmpty())
58
            continue;
59
        allowedMIMETypes.appendIfNotContains(mimeType);
60
    }
61
62
    return allowedMIMETypes;
63
}
64
65
Vector<String> FileChooserSettings::allowedFileExtensions() const
66
{
67
    Vector<String> acceptMIMETypes = this->acceptMIMETypes;
68
    Vector<String> allowedFileExtensions;
69
70
    if (shouldAppendNotAcceptedExtensions(allowedMIMETypes()))
71
        acceptMIMETypes.appendVector(Vector<String>({ "image/heif", "image/heic" }));
72
73
    for (auto& mimeType : acceptMIMETypes) {
74
        for (auto& extension : MIMETypeRegistry::extensionsForMIMEType(mimeType))
75
            allowedFileExtensions.appendIfNotContains(extension);
76
    }
77
    
78
    for (auto& extension : this->acceptFileExtensions)
79
        allowedFileExtensions.appendIfNotContains(trimmedExtension(extension));
80
81
    return allowedFileExtensions;
82
}
83
84
}
- Source/WebCore/platform/FileChooserSettings.h +70 lines
Line 0 Source/WebCore/platform/FileChooserSettings.h_sec1
1
/*
2
 * Copyright (C) 2020 Apple Inc. All rights reserved.
3
 *
4
 * Redistribution and use in source and binary forms, with or without
5
 * modification, are permitted provided that the following conditions
6
 * are met:
7
 *
8
 * 1.  Redistributions of source code must retain the above copyright
9
 *     notice, this list of conditions and the following disclaimer.
10
 * 2.  Redistributions in binary form must reproduce the above copyright
11
 *     notice, this list of conditions and the following disclaimer in the
12
 *     documentation and/or other materials provided with the distribution.
13
 * 3.  Neither the name of Apple Inc. ("Apple") nor the names of
14
 *     its contributors may be used to endorse or promote products derived
15
 *     from this software without specific prior written permission.
16
 *
17
 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
18
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20
 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
21
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
 *
28
 */
29
30
#pragma once
31
32
#include <wtf/EnumTraits.h>
33
#include <wtf/Vector.h>
34
#include <wtf/text/WTFString.h>
35
36
namespace WebCore {
37
38
enum MediaCaptureType {
39
    MediaCaptureTypeNone,
40
    MediaCaptureTypeUser,
41
    MediaCaptureTypeEnvironment
42
};
43
44
struct FileChooserSettings {
45
    bool allowsDirectories { false };
46
    bool allowsMultipleFiles { false };
47
    Vector<String> acceptMIMETypes;
48
    Vector<String> acceptFileExtensions;
49
    WEBCORE_EXPORT Vector<String> allowedMIMETypes() const;
50
    WEBCORE_EXPORT Vector<String> allowedFileExtensions() const;
51
    Vector<String> selectedFiles;
52
#if ENABLE(MEDIA_CAPTURE)
53
    MediaCaptureType mediaCaptureType { MediaCaptureTypeNone };
54
#endif
55
};
56
57
} // namespace WebCore
58
59
namespace WTF {
60
61
template<> struct EnumTraits<WebCore::MediaCaptureType> {
62
    using values = EnumValues<
63
        WebCore::MediaCaptureType,
64
        WebCore::MediaCaptureType::MediaCaptureTypeNone,
65
        WebCore::MediaCaptureType::MediaCaptureTypeUser,
66
        WebCore::MediaCaptureType::MediaCaptureTypeEnvironment
67
    >;
68
};
69
70
} // namespace WTF
- Source/WebKit/ChangeLog +35 lines
Lines 1-3 Source/WebKit/ChangeLog_sec1
1
2020-07-03  Said Abou-Hallawa  <sabouhallawa@apple.com>
2
3
        [macOS]: Allow selecting HEIF images if the 'accept' attribute includes a supported for encoding mime type
4
        https://bugs.webkit.org/show_bug.cgi?id=212489
5
6
        Reviewed by NOBODY (OOPS!).
7
8
        Make WKOpenPanelParameters call allowedFileExtensions() and allowedMIMETypes()
9
        of FileChooserSettings via OpenPanelParameters.
10
11
        UIDelegate will get allowedMIMETypes() and pass it to WebOpenPanelResultListenerProxy
12
        which will pass it to WebPageProxy. In a following patch, WebPageProxy
13
        will use allowedMIMETypes to transcode the selected images before sending
14
        them to WebPage.
15
16
        * UIProcess/API/APIOpenPanelParameters.cpp:
17
        (API::OpenPanelParameters::allowedMIMETypes const):
18
        (API::OpenPanelParameters::allowedFileExtensions const):
19
        (API::OpenPanelParameters::mediaCaptureType const): Deleted.
20
        * UIProcess/API/APIOpenPanelParameters.h:
21
        (API::OpenPanelParameters::mediaCaptureType const):
22
        * UIProcess/API/Cocoa/WKOpenPanelParameters.mm:
23
        (-[WKOpenPanelParameters _allowedFileExtensions]):
24
        (-[WKOpenPanelParameters _allowedFileExtensionsTitles]): Deleted.
25
        * UIProcess/API/Cocoa/WKOpenPanelParametersPrivate.h:
26
        * UIProcess/Cocoa/UIDelegate.mm:
27
        (WebKit::UIDelegate::UIClient::runOpenPanel):
28
        * UIProcess/WebOpenPanelResultListenerProxy.cpp:
29
        (WebKit::WebOpenPanelResultListenerProxy::chooseFiles):
30
        * UIProcess/WebOpenPanelResultListenerProxy.h:
31
        (WebKit::WebOpenPanelResultListenerProxy::chooseFiles):
32
        * UIProcess/WebPageProxy.cpp:
33
        (WebKit::WebPageProxy::didChooseFilesForOpenPanel):
34
        * UIProcess/WebPageProxy.h:
35
1
2020-07-03  Said Abou-Hallawa  <sabouhallawa@apple.com>
36
2020-07-03  Said Abou-Hallawa  <sabouhallawa@apple.com>
2
37
3
        Change the names of MIMETypeRegistry methods to comply with webkit naming style
38
        Change the names of MIMETypeRegistry methods to comply with webkit naming style
- Source/WebKit/UIProcess/WebOpenPanelResultListenerProxy.cpp -2 / +2 lines
Lines 54-65 void WebOpenPanelResultListenerProxy::ch Source/WebKit/UIProcess/WebOpenPanelResultListenerProxy.cpp_sec1
54
}
54
}
55
#endif
55
#endif
56
56
57
void WebOpenPanelResultListenerProxy::chooseFiles(const Vector<String>& filenames)
57
void WebOpenPanelResultListenerProxy::chooseFiles(const Vector<String>& filenames, const Vector<String>& allowedMIMETypes)
58
{
58
{
59
    if (!m_page)
59
    if (!m_page)
60
        return;
60
        return;
61
61
62
    m_page->didChooseFilesForOpenPanel(filenames);
62
    m_page->didChooseFilesForOpenPanel(filenames, allowedMIMETypes);
63
}
63
}
64
64
65
void WebOpenPanelResultListenerProxy::cancel()
65
void WebOpenPanelResultListenerProxy::cancel()
- Source/WebKit/UIProcess/WebOpenPanelResultListenerProxy.h -1 / +1 lines
Lines 50-56 public: Source/WebKit/UIProcess/WebOpenPanelResultListenerProxy.h_sec1
50
#if PLATFORM(IOS_FAMILY)
50
#if PLATFORM(IOS_FAMILY)
51
    void chooseFiles(const Vector<String>& filenames, const String& displayString, const API::Data* iconImageData);
51
    void chooseFiles(const Vector<String>& filenames, const String& displayString, const API::Data* iconImageData);
52
#endif
52
#endif
53
    void chooseFiles(const Vector<String>& filenames);
53
    void chooseFiles(const Vector<String>& filenames, const Vector<String>& allowedMIMETypes = { });
54
    void cancel();
54
    void cancel();
55
55
56
    void invalidate();
56
    void invalidate();
- Source/WebKit/UIProcess/WebPageProxy.cpp -1 / +1 lines
Lines 6690-6696 void WebPageProxy::didChooseFilesForOpen Source/WebKit/UIProcess/WebPageProxy.cpp_sec1
6690
}
6690
}
6691
#endif
6691
#endif
6692
6692
6693
void WebPageProxy::didChooseFilesForOpenPanel(const Vector<String>& fileURLs)
6693
void WebPageProxy::didChooseFilesForOpenPanel(const Vector<String>& fileURLs, const Vector<String>&)
6694
{
6694
{
6695
    if (!hasRunningProcess())
6695
    if (!hasRunningProcess())
6696
        return;
6696
        return;
- Source/WebKit/UIProcess/WebPageProxy.h -1 / +1 lines
Lines 1257-1263 public: Source/WebKit/UIProcess/WebPageProxy.h_sec1
1257
#if PLATFORM(IOS_FAMILY)
1257
#if PLATFORM(IOS_FAMILY)
1258
    void didChooseFilesForOpenPanelWithDisplayStringAndIcon(const Vector<String>&, const String& displayString, const API::Data* iconData);
1258
    void didChooseFilesForOpenPanelWithDisplayStringAndIcon(const Vector<String>&, const String& displayString, const API::Data* iconData);
1259
#endif
1259
#endif
1260
    void didChooseFilesForOpenPanel(const Vector<String>&);
1260
    void didChooseFilesForOpenPanel(const Vector<String>& fileURLs, const Vector<String>& allowedMIMETypes);
1261
    void didCancelForOpenPanel();
1261
    void didCancelForOpenPanel();
1262
1262
1263
    WebPageCreationParameters creationParameters(WebProcessProxy&, DrawingAreaProxy&, RefPtr<API::WebsitePolicies>&& = nullptr);
1263
    WebPageCreationParameters creationParameters(WebProcessProxy&, DrawingAreaProxy&, RefPtr<API::WebsitePolicies>&& = nullptr);
- Source/WebKit/UIProcess/API/APIOpenPanelParameters.cpp -4 / +7 lines
Lines 58-69 Ref<API::Array> OpenPanelParameters::acc Source/WebKit/UIProcess/API/APIOpenPanelParameters.cpp_sec1
58
    return API::Array::createStringArray(m_settings.acceptFileExtensions);
58
    return API::Array::createStringArray(m_settings.acceptFileExtensions);
59
}
59
}
60
60
61
#if ENABLE(MEDIA_CAPTURE)
61
Ref<API::Array> OpenPanelParameters::allowedMIMETypes() const
62
WebCore::MediaCaptureType OpenPanelParameters::mediaCaptureType() const
63
{
62
{
64
    return m_settings.mediaCaptureType;
63
    return API::Array::createStringArray(m_settings.allowedMIMETypes());
64
}
65
66
Ref<API::Array> OpenPanelParameters::allowedFileExtensions() const
67
{
68
    return API::Array::createStringArray(m_settings.allowedFileExtensions());
65
}
69
}
66
#endif
67
70
68
Ref<API::Array> OpenPanelParameters::selectedFileNames() const
71
Ref<API::Array> OpenPanelParameters::selectedFileNames() const
69
{
72
{
- Source/WebKit/UIProcess/API/APIOpenPanelParameters.h -1 / +3 lines
Lines 42-50 public: Source/WebKit/UIProcess/API/APIOpenPanelParameters.h_sec1
42
    bool allowMultipleFiles() const { return m_settings.allowsMultipleFiles; }
42
    bool allowMultipleFiles() const { return m_settings.allowsMultipleFiles; }
43
    Ref<API::Array> acceptMIMETypes() const;
43
    Ref<API::Array> acceptMIMETypes() const;
44
    Ref<API::Array> acceptFileExtensions() const;
44
    Ref<API::Array> acceptFileExtensions() const;
45
    Ref<API::Array> allowedMIMETypes() const;
46
    Ref<API::Array> allowedFileExtensions() const;
45
    Ref<API::Array> selectedFileNames() const;
47
    Ref<API::Array> selectedFileNames() const;
46
#if ENABLE(MEDIA_CAPTURE)
48
#if ENABLE(MEDIA_CAPTURE)
47
    WebCore::MediaCaptureType mediaCaptureType() const;
49
    WebCore::MediaCaptureType mediaCaptureType() const { return m_settings.mediaCaptureType; }
48
#endif
50
#endif
49
51
50
private:
52
private:
- Source/WebKit/UIProcess/API/Cocoa/WKOpenPanelParameters.mm -53 / +1 lines
Lines 66-124 - (NSArray<NSString *> *)_acceptedFileEx Source/WebKit/UIProcess/API/Cocoa/WKOpenPanelParameters.mm_sec1
66
66
67
- (NSArray<NSString *> *)_allowedFileExtensions
67
- (NSArray<NSString *> *)_allowedFileExtensions
68
{
68
{
69
    // Aggregate extensions based on specified MIME types.
69
    return wrapper(_openPanelParameters->allowedFileExtensions());
70
    auto acceptedMIMETypes = [self _acceptedMIMETypes];
71
    auto acceptedFileExtensions = [self _acceptedFileExtensions];
72
73
    auto allowedFileExtensions = adoptNS([[NSMutableSet alloc] init]);
74
75
    [acceptedMIMETypes enumerateObjectsUsingBlock:^(NSString *mimeType, NSUInteger index, BOOL* stop) {
76
        ASSERT([mimeType containsString:@"/"]);
77
        auto extensions = API::Array::createStringArray(WebCore::MIMETypeRegistry::extensionsForMIMEType(mimeType));
78
        [allowedFileExtensions addObjectsFromArray:wrapper(extensions)];
79
    }];
80
81
    auto additionalAllowedFileExtensions = adoptNS([[NSMutableArray alloc] init]);
82
83
    [acceptedFileExtensions enumerateObjectsUsingBlock:^(NSString *extension, NSUInteger index, BOOL *stop) {
84
        ASSERT([extension characterAtIndex:0] == '.');
85
        [additionalAllowedFileExtensions addObject:[extension substringFromIndex:1]];
86
    }];
87
    
88
    [allowedFileExtensions addObjectsFromArray:additionalAllowedFileExtensions.get()];
89
    return [allowedFileExtensions allObjects];
90
}
91
92
- (NSArray<NSString *> *)_allowedFileExtensionsTitles
93
{
94
    auto acceptedMIMETypes = [self _acceptedMIMETypes];
95
    auto acceptedFileExtensions = [self _acceptedFileExtensions];
96
97
    constexpr auto AllFilesTitle = @"All Files";
98
    constexpr auto CustomFilesTitle = @"Custom Files";
99
    
100
    if (![acceptedMIMETypes count] && ![acceptedFileExtensions count])
101
        return @[AllFilesTitle];
102
103
    if (!([acceptedMIMETypes count] == 1 && ![acceptedFileExtensions count]))
104
        return @[CustomFilesTitle, AllFilesTitle];
105
106
    auto mimeType = [acceptedMIMETypes firstObject];
107
    auto range = [mimeType rangeOfString:@"/"];
108
    
109
    if (!range.length)
110
        return @[CustomFilesTitle, AllFilesTitle];
111
    
112
    auto mimeTypePrefix = [mimeType substringToIndex:range.location];
113
    auto mimeTypeSuffix = [mimeType substringFromIndex:range.location + 1];
114
    
115
    if ([mimeTypeSuffix isEqualToString:@"*"])
116
        return @[[NSString stringWithFormat:@"%@%@ Files", [[mimeTypePrefix substringToIndex:1] uppercaseString], [mimeTypePrefix substringFromIndex:1]], AllFilesTitle];
117
118
    if ([mimeTypeSuffix length] <= 4)
119
        return @[[NSString stringWithFormat:@"%@ %@", [mimeTypeSuffix uppercaseString], mimeTypePrefix], AllFilesTitle];
120
121
    return @[[NSString stringWithFormat:@"%@ %@", mimeTypeSuffix, mimeTypePrefix], AllFilesTitle];
122
}
70
}
123
71
124
@end
72
@end
- Source/WebKit/UIProcess/API/Cocoa/WKOpenPanelParametersPrivate.h -2 / +1 lines
Lines 31-38 Source/WebKit/UIProcess/API/Cocoa/WKOpenPanelParametersPrivate.h_sec1
31
31
32
@property (nonatomic, readonly, copy) NSArray<NSString *> *_acceptedMIMETypes WK_API_AVAILABLE(macos(10.13.4));
32
@property (nonatomic, readonly, copy) NSArray<NSString *> *_acceptedMIMETypes WK_API_AVAILABLE(macos(10.13.4));
33
@property (nonatomic, readonly, copy) NSArray<NSString *> *_acceptedFileExtensions WK_API_AVAILABLE(macos(10.13.4));
33
@property (nonatomic, readonly, copy) NSArray<NSString *> *_acceptedFileExtensions WK_API_AVAILABLE(macos(10.13.4));
34
@property (nonatomic, readonly, copy) NSArray<NSString *> *_allowedFileExtensions WK_API_AVAILABLE(macos(10.13.4));
34
@property (nonatomic, readonly, copy) NSArray<NSString *> *_allowedFileExtensions WK_API_AVAILABLE(macos(WK_MAC_TBA));
35
@property (nonatomic, readonly, copy) NSArray<NSString *> *_allowedFileExtensionsTitles WK_API_AVAILABLE(macos(10.13.4));
36
35
37
@end
36
@end
38
37
- Source/WebKit/UIProcess/Cocoa/UIDelegate.mm -2 / +3 lines
Lines 26-31 Source/WebKit/UIProcess/Cocoa/UIDelegate.mm_sec1
26
#import "config.h"
26
#import "config.h"
27
#import "UIDelegate.h"
27
#import "UIDelegate.h"
28
28
29
#import "APIArray.h"
29
#import "APIFrameInfo.h"
30
#import "APIFrameInfo.h"
30
#import "APIHitTestResult.h"
31
#import "APIHitTestResult.h"
31
#import "CompletionHandlerCallChecker.h"
32
#import "CompletionHandlerCallChecker.h"
Lines 826-832 bool UIDelegate::UIClient::runOpenPanel( Source/WebKit/UIProcess/Cocoa/UIDelegate.mm_sec2
826
827
827
    auto checker = CompletionHandlerCallChecker::create(delegate.get(), @selector(webView:runOpenPanelWithParameters:initiatedByFrame:completionHandler:));
828
    auto checker = CompletionHandlerCallChecker::create(delegate.get(), @selector(webView:runOpenPanelWithParameters:initiatedByFrame:completionHandler:));
828
829
829
    [delegate webView:m_uiDelegate.m_webView runOpenPanelWithParameters:wrapper(*openPanelParameters) initiatedByFrame:wrapper(frame) completionHandler:makeBlockPtr([checker = WTFMove(checker), listener = WTFMove(listener)] (NSArray *URLs) mutable {
830
    [delegate webView:m_uiDelegate.m_webView runOpenPanelWithParameters:wrapper(*openPanelParameters) initiatedByFrame:wrapper(frame) completionHandler:makeBlockPtr([checker = WTFMove(checker), openPanelParameters = makeRef(*openPanelParameters), listener = WTFMove(listener)] (NSArray *URLs) mutable {
830
        if (checker->completionHandlerHasBeenCalled())
831
        if (checker->completionHandlerHasBeenCalled())
831
            return;
832
            return;
832
        checker->didCallCompletionHandler();
833
        checker->didCallCompletionHandler();
Lines 840-846 bool UIDelegate::UIClient::runOpenPanel( Source/WebKit/UIProcess/Cocoa/UIDelegate.mm_sec3
840
        for (NSURL *url in URLs)
841
        for (NSURL *url in URLs)
841
            filenames.append(url.path);
842
            filenames.append(url.path);
842
843
843
        listener->chooseFiles(filenames);
844
        listener->chooseFiles(filenames, openPanelParameters->allowedMIMETypes()->toStringVector());
844
    }).get()];
845
    }).get()];
845
846
846
    return true;
847
    return true;
- Tools/ChangeLog +19 lines
Lines 1-3 Tools/ChangeLog_sec1
1
2020-07-03  Said Abou-Hallawa  <sabouhallawa@apple.com>
2
3
        [macOS]: Allow selecting HEIF images if the 'accept' attribute includes a supported for encoding mime type
4
        https://bugs.webkit.org/show_bug.cgi?id=212489
5
6
        Reviewed by NOBODY (OOPS!).
7
8
        Then scope of the change will be limited. No UI change will be done.
9
        Only allow HEIF/HEIC images to be selected the 'accept' attribute include
10
        a mime type which is supported for encoding.
11
12
        * MiniBrowser/mac/WK2BrowserWindowController.m:
13
        (-[WK2BrowserWindowController dealloc]):
14
        (-[WK2BrowserWindowController webView:runOpenPanelWithParameters:initiatedByFrame:completionHandler:webView:runOpenPanelWithParameters:initiatedByFrame:completionHandler:]):
15
        (-[FileExtensionsPopupTarget initWithOpenPanel:allowedFileExtensions:]): Deleted.
16
        (-[FileExtensionsPopupTarget popupAction:]): Deleted.
17
        (-[FileExtensionsPopupTarget dealloc]): Deleted.
18
        (-[WK2BrowserWindowController createFilterView:popupTarget:]): Deleted.
19
1
2020-07-03  Sam Weinig  <weinig@apple.com>
20
2020-07-03  Sam Weinig  <weinig@apple.com>
2
21
3
        Remove support for ENABLE_INPUT_TYPE_DATETIME_INCOMPLETE
22
        Remove support for ENABLE_INPUT_TYPE_DATETIME_INCOMPLETE
- Tools/MiniBrowser/mac/WK2BrowserWindowController.m -97 / +1 lines
Lines 72-116 - (void)performAction:(NSTextFinderActio Tools/MiniBrowser/mac/WK2BrowserWindowController.m_sec1
72
72
73
@end
73
@end
74
74
75
// Target for the FileExtensions NSPopupButton in the OpenPanel's AccessoryView.
76
@interface FileExtensionsPopupTarget : NSObject {
77
@private
78
    NSOpenPanel *_openPanel;
79
    NSArray<NSString *> *_allowedFileExtensions;
80
}
81
@end
82
83
@implementation FileExtensionsPopupTarget
84
85
- (id)initWithOpenPanel:(NSOpenPanel*)openPanel allowedFileExtensions:(NSArray<NSString *> *)allowedFileExtensions {
86
    if ((self = [super init])) {
87
        _openPanel = openPanel;
88
        _allowedFileExtensions = [allowedFileExtensions copy];
89
    }
90
    return self;
91
}
92
93
- (void)popupAction:(id)sender {
94
    // Last item.
95
    if ([sender indexOfSelectedItem] == [sender numberOfItems] - 1)
96
        [_openPanel setAllowedFileTypes:nil];
97
    else if (![sender indexOfSelectedItem]) {
98
        // First item.
99
        if (![_allowedFileExtensions count])
100
            [_openPanel setAllowedFileTypes:@[@""]];
101
        else
102
            [_openPanel setAllowedFileTypes:_allowedFileExtensions];
103
    }
104
}
105
106
- (void)dealloc
107
{
108
    [_allowedFileExtensions release];
109
    [super dealloc];
110
}
111
112
@end
113
114
@interface WK2BrowserWindowController () <NSTextFinderBarContainer, WKNavigationDelegate, WKUIDelegate, _WKIconLoadingDelegate>
75
@interface WK2BrowserWindowController () <NSTextFinderBarContainer, WKNavigationDelegate, WKUIDelegate, _WKIconLoadingDelegate>
115
@end
76
@end
116
77
Lines 125-131 @interface WK2BrowserWindowController () Tools/MiniBrowser/mac/WK2BrowserWindowController.m_sec2
125
    MiniBrowserNSTextFinder *_textFinder;
86
    MiniBrowserNSTextFinder *_textFinder;
126
    NSView *_textFindBarView;
87
    NSView *_textFindBarView;
127
    BOOL _findBarVisible;
88
    BOOL _findBarVisible;
128
    FileExtensionsPopupTarget *_fileExtensionsPopupTarget;
129
}
89
}
130
90
131
- (void)awakeFromNib
91
- (void)awakeFromNib
Lines 211-217 - (void)dealloc Tools/MiniBrowser/mac/WK2BrowserWindowController.m_sec3
211
171
212
    [_webView release];
172
    [_webView release];
213
    [_configuration release];
173
    [_configuration release];
214
    [_fileExtensionsPopupTarget release];
215
174
216
    [super dealloc];
175
    [super dealloc];
217
}
176
}
Lines 629-682 - (void)webView:(WKWebView *)webView run Tools/MiniBrowser/mac/WK2BrowserWindowController.m_sec4
629
    }];
588
    }];
630
}
589
}
631
590
632
- (nullable NSView *)createFilterView:(NSArray *)titles popupTarget:(FileExtensionsPopupTarget*)popupTarget
633
{
634
    NSTextField* label = [[[NSTextField alloc] initWithFrame:NSZeroRect] autorelease];
635
    [label setStringValue:@"Format:"];
636
    [label setEditable:NO];
637
    [label setSelectable:NO];
638
    [label setBordered:NO];
639
    [label setBackgroundColor:[NSColor clearColor]];
640
    [label sizeToFit];
641
642
    NSPopUpButton *button = [[[NSPopUpButton alloc] initWithFrame:NSZeroRect pullsDown:NO] autorelease];
643
    [button addItemsWithTitles:titles];
644
    [button setTarget:popupTarget];
645
    [button setAction:@selector(popupAction:)];
646
    [button sizeToFit];
647
    [button selectItemAtIndex:0];
648
    [popupTarget popupAction:button];
649
    
650
    NSView* filterView = [[[NSView alloc] initWithFrame:NSZeroRect] autorelease];
651
    [filterView addSubview:label];
652
    [filterView addSubview:button];
653
654
    const CGFloat margin = 20;
655
    const CGFloat spacing = 2;
656
    const CGFloat minButtonWidth = 230;
657
658
    NSRect labelFrame = [label frame];
659
    NSRect buttonFrame = [button frame];
660
    NSRect filterViewFrame = [filterView frame];
661
662
    // Set a minimum width for 'button'.
663
    buttonFrame.size = NSMakeSize(MAX(NSWidth(buttonFrame), minButtonWidth), NSHeight(buttonFrame));
664
    
665
    // FilterView will lay out 'label' and 'button' horizontally and have a vertical margins.
666
    filterViewFrame.size = NSMakeSize(NSWidth(labelFrame) + NSWidth(buttonFrame) + spacing, MAX(NSHeight(labelFrame), NSHeight(buttonFrame)) + margin * 2);
667
    [filterView setFrame:filterViewFrame];
668
669
    // 'label' will be laid out center vertically.
670
    labelFrame.origin = NSMakePoint(NSMinX(labelFrame), (NSHeight(filterViewFrame) - NSHeight(labelFrame)) / 2);
671
    [label setFrame:labelFrame];
672
    
673
    // 'button' will be laid out center vertically and it will come after 'label' horizontally.
674
    buttonFrame.origin = NSMakePoint(NSMaxX(labelFrame) + spacing, (NSHeight(filterViewFrame) - NSHeight(buttonFrame)) / 2);
675
    [button setFrame:buttonFrame];
676
677
    return filterView;
678
}
679
680
#if __has_feature(objc_generics)
591
#if __has_feature(objc_generics)
681
- (void)webView:(WKWebView *)webView runOpenPanelWithParameters:(WKOpenPanelParameters *)parameters initiatedByFrame:(WKFrameInfo *)frame completionHandler:(void (^)(NSArray<NSURL *> * URLs))completionHandler
592
- (void)webView:(WKWebView *)webView runOpenPanelWithParameters:(WKOpenPanelParameters *)parameters initiatedByFrame:(WKFrameInfo *)frame completionHandler:(void (^)(NSArray<NSURL *> * URLs))completionHandler
682
#else
593
#else
Lines 686-699 - (void)webView:(WKWebView *)webView run Tools/MiniBrowser/mac/WK2BrowserWindowController.m_sec5
686
    NSOpenPanel *openPanel = [NSOpenPanel openPanel];
597
    NSOpenPanel *openPanel = [NSOpenPanel openPanel];
687
598
688
    openPanel.allowsMultipleSelection = parameters.allowsMultipleSelection;
599
    openPanel.allowsMultipleSelection = parameters.allowsMultipleSelection;
689
600
    [openPanel setAllowedFileTypes:parameters._allowedFileExtensions];
690
    [_fileExtensionsPopupTarget release];
691
    _fileExtensionsPopupTarget = [[FileExtensionsPopupTarget alloc] initWithOpenPanel: openPanel allowedFileExtensions: parameters._allowedFileExtensions];
692
693
    NSArray *allowedFileExtensionsTitles = parameters._allowedFileExtensionsTitles;
694
    NSView *filterView = [self createFilterView:allowedFileExtensionsTitles popupTarget:_fileExtensionsPopupTarget];
695
    if (filterView)
696
        [openPanel setAccessoryView:filterView];
697
601
698
    [openPanel beginSheetModalForWindow:webView.window completionHandler:^(NSInteger result) {
602
    [openPanel beginSheetModalForWindow:webView.window completionHandler:^(NSInteger result) {
699
        if (result == NSModalResponseOK)
603
        if (result == NSModalResponseOK)

Return to Bug 212489