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

Changeset 238461 in webkit


Ignore:
Timestamp:
Nov 23, 2018, 10:18:01 AM (8 years ago)
Author:
Wenson Hsieh
Message:

Enable drag and drop support for iOSMac
https://bugs.webkit.org/show_bug.cgi?id=191818
<rdar://problem/43907454>

Reviewed by Dean Jackson.

Source/JavaScriptCore:

  • Configurations/FeatureDefines.xcconfig:

Source/WebCore:

Enables drag and drop by default on iOSMac by switching on ENABLE_DATA_INTERACTION and ENABLE_DRAG_SUPPORT. This
enables support for dragging links, text selections, and images, though many advanced features (e.g. custom
pasteboard data) will require additional support from the platform.

  • Configurations/FeatureDefines.xcconfig:
  • platform/ios/PlatformPasteboardIOS.mm:

(WebCore::PlatformPasteboard::informationForItemAtIndex):
(WebCore::registerItemToPasteboard):
(WebCore::PlatformPasteboard::typesSafeForDOMToReadAndWrite const):

  • platform/ios/WebItemProviderPasteboard.mm:

(-[WebItemProviderLoadResult canBeRepresentedAsFileUpload]):
(-[WebItemProviderPasteboard numberOfFiles]):

Disable codepaths which attempt to access or set teamData or preferredPresentationStyle on NSItemProvider
in iOSMac, since these are currently unimplemented.

Source/WebCore/PAL:

  • Configurations/FeatureDefines.xcconfig:

Source/WebKit:

  • Configurations/FeatureDefines.xcconfig:
  • Shared/WebPreferencesDefaultValues.cpp:

(defaultCustomPasteboardDataEnabled):

Enable custom pasteboard data by default on iOSMac. While writing and reading custom pasteboard data is
currently broken in iOSMac due to the lack of teamData and preferredPresentationStyle, opting into custom
pasteboard data at least allows us to avoid writing unsanitized data types to the pasteboard.

  • WebProcess/WebPage/ios/WebPageIOS.mm:

(WebKit::WebPage::platformEditorState const):

Fix a regression from <https://trac.webkit.org/r236619> wherein the web process crashes when attempting to edit
a text field. This happens because the call to -[UIKeyboard isInHardwareKeyboardMode] on the iOSMac platform
attempts to initialize a UHASWorkspace from the web process, which then attempts to connect to the UIKit host
application. Instead, we can skip this call altogether on iOSMac, where the platform never considers a hardware
keyboard to be "connected", even when typing.

Source/WebKitLegacy/mac:

  • Configurations/FeatureDefines.xcconfig:

Tools:

  • TestWebKitAPI/Configurations/FeatureDefines.xcconfig:
Location:
trunk
Files:
16 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r238453 r238461  
     12018-11-23  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        Enable drag and drop support for iOSMac
     4        https://bugs.webkit.org/show_bug.cgi?id=191818
     5        <rdar://problem/43907454>
     6
     7        Reviewed by Dean Jackson.
     8
     9        * Configurations/FeatureDefines.xcconfig:
     10
    1112018-11-22  Mark Lam  <mark.lam@apple.com>
    212
  • trunk/Source/JavaScriptCore/Configurations/FeatureDefines.xcconfig

    r237912 r238461  
    125125ENABLE_DATA_INTERACTION_iphoneos = ENABLE_DATA_INTERACTION;
    126126ENABLE_DATA_INTERACTION_iphonesimulator = ENABLE_DATA_INTERACTION;
     127ENABLE_DATA_INTERACTION_iosmac = ENABLE_DATA_INTERACTION;
    127128
    128129ENABLE_DEVICE_ORIENTATION = $(ENABLE_DEVICE_ORIENTATION_$(WK_PLATFORM_NAME));
     
    137138ENABLE_DRAG_SUPPORT_iphoneos = ENABLE_DRAG_SUPPORT;
    138139ENABLE_DRAG_SUPPORT_iphonesimulator = ENABLE_DRAG_SUPPORT;
     140ENABLE_DRAG_SUPPORT_iosmac = ENABLE_DRAG_SUPPORT;
    139141
    140142ENABLE_ENCRYPTED_MEDIA = $(ENABLE_ENCRYPTED_MEDIA_$(WK_PLATFORM_NAME));
  • trunk/Source/WebCore/ChangeLog

    r238460 r238461  
     12018-11-23  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        Enable drag and drop support for iOSMac
     4        https://bugs.webkit.org/show_bug.cgi?id=191818
     5        <rdar://problem/43907454>
     6
     7        Reviewed by Dean Jackson.
     8
     9        Enables drag and drop by default on iOSMac by switching on ENABLE_DATA_INTERACTION and ENABLE_DRAG_SUPPORT. This
     10        enables support for dragging links, text selections, and images, though many advanced features (e.g. custom
     11        pasteboard data) will require additional support from the platform.
     12
     13        * Configurations/FeatureDefines.xcconfig:
     14        * platform/ios/PlatformPasteboardIOS.mm:
     15        (WebCore::PlatformPasteboard::informationForItemAtIndex):
     16        (WebCore::registerItemToPasteboard):
     17        (WebCore::PlatformPasteboard::typesSafeForDOMToReadAndWrite const):
     18        * platform/ios/WebItemProviderPasteboard.mm:
     19        (-[WebItemProviderLoadResult canBeRepresentedAsFileUpload]):
     20        (-[WebItemProviderPasteboard numberOfFiles]):
     21
     22        Disable codepaths which attempt to access or set `teamData` or `preferredPresentationStyle` on `NSItemProvider`
     23        in iOSMac, since these are currently unimplemented.
     24
    1252018-11-23  Zalan Butjas  <zalan@apple.com>
    226
  • trunk/Source/WebCore/Configurations/FeatureDefines.xcconfig

    r237912 r238461  
    125125ENABLE_DATA_INTERACTION_iphoneos = ENABLE_DATA_INTERACTION;
    126126ENABLE_DATA_INTERACTION_iphonesimulator = ENABLE_DATA_INTERACTION;
     127ENABLE_DATA_INTERACTION_iosmac = ENABLE_DATA_INTERACTION;
    127128
    128129ENABLE_DEVICE_ORIENTATION = $(ENABLE_DEVICE_ORIENTATION_$(WK_PLATFORM_NAME));
     
    137138ENABLE_DRAG_SUPPORT_iphoneos = ENABLE_DRAG_SUPPORT;
    138139ENABLE_DRAG_SUPPORT_iphonesimulator = ENABLE_DRAG_SUPPORT;
     140ENABLE_DRAG_SUPPORT_iosmac = ENABLE_DRAG_SUPPORT;
    139141
    140142ENABLE_ENCRYPTED_MEDIA = $(ENABLE_ENCRYPTED_MEDIA_$(WK_PLATFORM_NAME));
  • trunk/Source/WebCore/PAL/ChangeLog

    r238438 r238461  
     12018-11-23  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        Enable drag and drop support for iOSMac
     4        https://bugs.webkit.org/show_bug.cgi?id=191818
     5        <rdar://problem/43907454>
     6
     7        Reviewed by Dean Jackson.
     8
     9        * Configurations/FeatureDefines.xcconfig:
     10
    1112018-11-21  Wenson Hsieh  <wenson_hsieh@apple.com>
    212
  • trunk/Source/WebCore/PAL/Configurations/FeatureDefines.xcconfig

    r237912 r238461  
    125125ENABLE_DATA_INTERACTION_iphoneos = ENABLE_DATA_INTERACTION;
    126126ENABLE_DATA_INTERACTION_iphonesimulator = ENABLE_DATA_INTERACTION;
     127ENABLE_DATA_INTERACTION_iosmac = ENABLE_DATA_INTERACTION;
    127128
    128129ENABLE_DEVICE_ORIENTATION = $(ENABLE_DEVICE_ORIENTATION_$(WK_PLATFORM_NAME));
     
    137138ENABLE_DRAG_SUPPORT_iphoneos = ENABLE_DRAG_SUPPORT;
    138139ENABLE_DRAG_SUPPORT_iphonesimulator = ENABLE_DRAG_SUPPORT;
     140ENABLE_DRAG_SUPPORT_iosmac = ENABLE_DRAG_SUPPORT;
    139141
    140142ENABLE_ENCRYPTED_MEDIA = $(ENABLE_ENCRYPTED_MEDIA_$(WK_PLATFORM_NAME));
  • trunk/Source/WebCore/platform/ios/PlatformPasteboardIOS.mm

    r238360 r238461  
    4848
    4949#define PASTEBOARD_SUPPORTS_ITEM_PROVIDERS (PLATFORM(IOS_FAMILY) && !(PLATFORM(WATCHOS) || PLATFORM(APPLETV)))
     50#define PASTEBOARD_SUPPORTS_PRESENTATION_STYLE_AND_TEAM_DATA (PASTEBOARD_SUPPORTS_ITEM_PROVIDERS && !PLATFORM(IOSMAC))
    5051#define NSURL_SUPPORTS_TITLE (!PLATFORM(IOSMAC))
    5152
     
    110111
    111112#if PASTEBOARD_SUPPORTS_ITEM_PROVIDERS
     113
     114#if PASTEBOARD_SUPPORTS_PRESENTATION_STYLE_AND_TEAM_DATA
    112115
    113116static PasteboardItemPresentationStyle pasteboardItemPresentationStyle(UIPreferredPresentationStyle style)
     
    126129}
    127130
     131#endif // PASTEBOARD_SUPPORTS_PRESENTATION_STYLE_AND_TEAM_DATA
     132
    128133Vector<PasteboardItemInfo> PlatformPasteboard::allPasteboardItemInfo()
    129134{
     
    147152
    148153    NSItemProvider *itemProvider = [[m_pasteboard itemProviders] objectAtIndex:index];
     154#if PASTEBOARD_SUPPORTS_PRESENTATION_STYLE_AND_TEAM_DATA
    149155    info.preferredPresentationStyle = pasteboardItemPresentationStyle(itemProvider.preferredPresentationStyle);
     156#endif
    150157    info.suggestedFileName = itemProvider.suggestedName;
    151158    for (NSString *typeIdentifier in itemProvider.registeredTypeIdentifiers) {
     
    286293{
    287294#if PLATFORM(IOSMAC)
    288     auto itemDictionary = adoptNS([[NSMutableDictionary alloc] init]);
    289     [representationsToRegister enumerateItems:[itemDictionary] (id <WebItemProviderRegistrar> item, NSUInteger) {
    290         if ([item respondsToSelector:@selector(typeIdentifierForClient)] && [item respondsToSelector:@selector(dataForClient)])
    291             [itemDictionary setObject:item.dataForClient forKey:item.typeIdentifierForClient];
    292     }];
    293     [pasteboard setItems:@[ itemDictionary.get() ]];
    294 #else
     295    // In iOSMac, -[UIPasteboard setItemProviders:] is not yet supported, so we fall back to setting an item dictionary when
     296    // populating the pasteboard upon copy.
     297    if ([pasteboard isKindOfClass:getUIPasteboardClass()]) {
     298        auto itemDictionary = adoptNS([[NSMutableDictionary alloc] init]);
     299        [representationsToRegister enumerateItems:[itemDictionary] (id <WebItemProviderRegistrar> item, NSUInteger) {
     300            if ([item respondsToSelector:@selector(typeIdentifierForClient)] && [item respondsToSelector:@selector(dataForClient)])
     301                [itemDictionary setObject:item.dataForClient forKey:item.typeIdentifierForClient];
     302        }];
     303        [pasteboard setItems:@[ itemDictionary.get() ]];
     304        return;
     305    }
     306#endif // PLATFORM(IOSMAC)
     307
    295308    if (NSItemProvider *itemProvider = representationsToRegister.itemProvider)
    296309        [pasteboard setItemProviders:@[ itemProvider ]];
     
    300313    if ([pasteboard respondsToSelector:@selector(stageRegistrationList:)])
    301314        [pasteboard stageRegistrationList:representationsToRegister];
    302 #endif
    303    
    304315}
    305316
     
    467478{
    468479    ListHashSet<String> domPasteboardTypes;
     480#if PASTEBOARD_SUPPORTS_PRESENTATION_STYLE_AND_TEAM_DATA
    469481    for (NSItemProvider *provider in [m_pasteboard itemProviders]) {
    470482        if (!provider.teamData.length)
     
    488500            domPasteboardTypes.add(type);
    489501    }
     502#endif // PASTEBOARD_SUPPORTS_PRESENTATION_STYLE_AND_TEAM_DATA
    490503
    491504    if (NSData *serializedCustomData = [m_pasteboard dataForPasteboardType:@(PasteboardCustomData::cocoaType())]) {
  • trunk/Source/WebCore/platform/ios/WebItemProviderPasteboard.mm

    r238360 r238461  
    2727#import "WebItemProviderPasteboard.h"
    2828
    29 #if ENABLE(DATA_INTERACTION) || PLATFORM(IOSMAC)
     29#if ENABLE(DATA_INTERACTION)
    3030
    3131#import <Foundation/NSItemProvider.h>
     
    343343- (BOOL)canBeRepresentedAsFileUpload
    344344{
     345#if PLATFORM(IOSMAC)
     346    return false;
     347#else
    345348    return [_itemProvider preferredPresentationStyle] != UIPreferredPresentationStyleInline;
     349#endif
    346350}
    347351
     
    644648    NSInteger numberOfFiles = 0;
    645649    for (NSItemProvider *itemProvider in _itemProviders.get()) {
     650#if !PLATFORM(IOSMAC)
    646651        if (itemProvider.preferredPresentationStyle == UIPreferredPresentationStyleInline)
    647652            continue;
     653#endif
    648654
    649655        for (NSString *identifier in itemProvider.registeredTypeIdentifiers) {
     
    830836@end
    831837
    832 #endif // ENABLE(DATA_INTERACTION) || PLATFORM(IOSMAC)
     838#endif // ENABLE(DATA_INTERACTION)
  • trunk/Source/WebKit/ChangeLog

    r238459 r238461  
     12018-11-23  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        Enable drag and drop support for iOSMac
     4        https://bugs.webkit.org/show_bug.cgi?id=191818
     5        <rdar://problem/43907454>
     6
     7        Reviewed by Dean Jackson.
     8
     9        * Configurations/FeatureDefines.xcconfig:
     10        * Shared/WebPreferencesDefaultValues.cpp:
     11        (defaultCustomPasteboardDataEnabled):
     12
     13        Enable custom pasteboard data by default on iOSMac. While writing and reading custom pasteboard data is
     14        currently broken in iOSMac due to the lack of `teamData` and `preferredPresentationStyle`, opting into custom
     15        pasteboard data at least allows us to avoid writing unsanitized data types to the pasteboard.
     16
     17        * WebProcess/WebPage/ios/WebPageIOS.mm:
     18        (WebKit::WebPage::platformEditorState const):
     19
     20        Fix a regression from <https://trac.webkit.org/r236619> wherein the web process crashes when attempting to edit
     21        a text field. This happens because the call to `-[UIKeyboard isInHardwareKeyboardMode]` on the iOSMac platform
     22        attempts to initialize a `UHASWorkspace` from the web process, which then attempts to connect to the UIKit host
     23        application. Instead, we can skip this call altogether on iOSMac, where the platform never considers a hardware
     24        keyboard to be "connected", even when typing.
     25
    1262018-11-23  Antti Koivisto  <antti@apple.com>
    227
  • trunk/Source/WebKit/Configurations/FeatureDefines.xcconfig

    r237912 r238461  
    125125ENABLE_DATA_INTERACTION_iphoneos = ENABLE_DATA_INTERACTION;
    126126ENABLE_DATA_INTERACTION_iphonesimulator = ENABLE_DATA_INTERACTION;
     127ENABLE_DATA_INTERACTION_iosmac = ENABLE_DATA_INTERACTION;
    127128
    128129ENABLE_DEVICE_ORIENTATION = $(ENABLE_DEVICE_ORIENTATION_$(WK_PLATFORM_NAME));
     
    137138ENABLE_DRAG_SUPPORT_iphoneos = ENABLE_DRAG_SUPPORT;
    138139ENABLE_DRAG_SUPPORT_iphonesimulator = ENABLE_DRAG_SUPPORT;
     140ENABLE_DRAG_SUPPORT_iosmac = ENABLE_DRAG_SUPPORT;
    139141
    140142ENABLE_ENCRYPTED_MEDIA = $(ENABLE_ENCRYPTED_MEDIA_$(WK_PLATFORM_NAME));
  • trunk/Source/WebKit/Shared/WebPreferencesDefaultValues.cpp

    r237607 r238461  
    4747bool defaultCustomPasteboardDataEnabled()
    4848{
    49 #if PLATFORM(IOS_FAMILY)
     49#if PLATFORM(IOSMAC)
     50    return true;
     51#elif PLATFORM(IOS_FAMILY)
    5052    return WebCore::IOSApplication::isMobileSafari() || dyld_get_program_sdk_version() >= DYLD_IOS_VERSION_11_3;
    5153#elif PLATFORM(MAC) && __MAC_OS_X_VERSION_MAX_ALLOWED >= 101300
  • trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm

    r238454 r238461  
    199199    // immediately so that the UIProcess can update UI, including the position of the caret.
    200200    bool needsLayout = !frame.view() || frame.view()->needsLayout();
    201     if (shouldIncludePostLayoutData == IncludePostLayoutDataHint::No && needsLayout && ![UIKeyboard isInHardwareKeyboardMode] && !frame.editor().hasComposition()) {
     201    bool requiresPostLayoutData = frame.editor().hasComposition();
     202#if !PLATFORM(IOSMAC)
     203    requiresPostLayoutData |= [UIKeyboard isInHardwareKeyboardMode];
     204#endif
     205    if (shouldIncludePostLayoutData == IncludePostLayoutDataHint::No && needsLayout && !requiresPostLayoutData) {
    202206        result.isMissingPostLayoutData = true;
    203207        return;
  • trunk/Source/WebKitLegacy/mac/ChangeLog

    r238454 r238461  
     12018-11-23  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        Enable drag and drop support for iOSMac
     4        https://bugs.webkit.org/show_bug.cgi?id=191818
     5        <rdar://problem/43907454>
     6
     7        Reviewed by Dean Jackson.
     8
     9        * Configurations/FeatureDefines.xcconfig:
     10
    1112018-11-22  Wenson Hsieh  <wenson_hsieh@apple.com>
    212
  • trunk/Source/WebKitLegacy/mac/Configurations/FeatureDefines.xcconfig

    r237912 r238461  
    125125ENABLE_DATA_INTERACTION_iphoneos = ENABLE_DATA_INTERACTION;
    126126ENABLE_DATA_INTERACTION_iphonesimulator = ENABLE_DATA_INTERACTION;
     127ENABLE_DATA_INTERACTION_iosmac = ENABLE_DATA_INTERACTION;
    127128
    128129ENABLE_DEVICE_ORIENTATION = $(ENABLE_DEVICE_ORIENTATION_$(WK_PLATFORM_NAME));
     
    137138ENABLE_DRAG_SUPPORT_iphoneos = ENABLE_DRAG_SUPPORT;
    138139ENABLE_DRAG_SUPPORT_iphonesimulator = ENABLE_DRAG_SUPPORT;
     140ENABLE_DRAG_SUPPORT_iosmac = ENABLE_DRAG_SUPPORT;
    139141
    140142ENABLE_ENCRYPTED_MEDIA = $(ENABLE_ENCRYPTED_MEDIA_$(WK_PLATFORM_NAME));
  • trunk/Tools/ChangeLog

    r238460 r238461  
     12018-11-23  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        Enable drag and drop support for iOSMac
     4        https://bugs.webkit.org/show_bug.cgi?id=191818
     5        <rdar://problem/43907454>
     6
     7        Reviewed by Dean Jackson.
     8
     9        * TestWebKitAPI/Configurations/FeatureDefines.xcconfig:
     10
    1112018-11-23  Zalan Bujtas  <zalan@apple.com>
    212
  • trunk/Tools/TestWebKitAPI/Configurations/FeatureDefines.xcconfig

    r237912 r238461  
    125125ENABLE_DATA_INTERACTION_iphoneos = ENABLE_DATA_INTERACTION;
    126126ENABLE_DATA_INTERACTION_iphonesimulator = ENABLE_DATA_INTERACTION;
     127ENABLE_DATA_INTERACTION_iosmac = ENABLE_DATA_INTERACTION;
    127128
    128129ENABLE_DEVICE_ORIENTATION = $(ENABLE_DEVICE_ORIENTATION_$(WK_PLATFORM_NAME));
     
    137138ENABLE_DRAG_SUPPORT_iphoneos = ENABLE_DRAG_SUPPORT;
    138139ENABLE_DRAG_SUPPORT_iphonesimulator = ENABLE_DRAG_SUPPORT;
     140ENABLE_DRAG_SUPPORT_iosmac = ENABLE_DRAG_SUPPORT;
    139141
    140142ENABLE_ENCRYPTED_MEDIA = $(ENABLE_ENCRYPTED_MEDIA_$(WK_PLATFORM_NAME));
Note: See TracChangeset for help on using the changeset viewer.