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

Changeset 266804 in webkit


Ignore:
Timestamp:
Sep 9, 2020, 3:54:40 PM (6 years ago)
Author:
timothy_horton@apple.com
Message:

macCatalyst: Form controls behave strangely (like iPhone) in macOS-idiom apps
https://bugs.webkit.org/show_bug.cgi?id=216326

Reviewed by Wenson Hsieh.

  • Shared/UserInterfaceIdiom.h:
  • Shared/UserInterfaceIdiom.mm:

(WebKit::userInterfaceIdiomIsPad):
(WebKit::currentUserInterfaceIdiomIsPadOrMac):
(WebKit::setCurrentUserInterfaceIdiomIsPadOrMac):
(WebKit::currentUserInterfaceIdiomIsPad): Deleted.
(WebKit::setCurrentUserInterfaceIdiomIsPad): Deleted.

  • Shared/ios/WebPreferencesDefaultValuesIOS.mm:

(WebKit::defaultTextAutosizingUsesIdempotentMode):

  • UIProcess/API/Cocoa/WKWebViewConfiguration.mm:

(-[WKWebViewConfiguration init]):

  • UIProcess/Cocoa/WebProcessPoolCocoa.mm:

(WebKit::WebProcessPool::platformInitializeWebProcess):

  • UIProcess/ios/SmartMagnificationController.mm:

(WebKit::SmartMagnificationController::didCollectGeometryForSmartMagnificationGesture):

  • UIProcess/ios/WKContentViewInteraction.mm:

(-[WKFormInputSession setAccessoryViewCustomButtonTitle:]):
(-[WKContentView endEditingAndUpdateFocusAppearanceWithReason:]):
(-[WKContentView _shouldShowAutomaticKeyboardUIIgnoringInputMode]):
(-[WKContentView _zoomToRevealFocusedElement]):
(-[WKContentView requiresAccessoryView]):
(-[WKContentView _updateAccessory]):
(shouldShowKeyboardForElement):
(-[WKContentView _shouldUseLegacySelectPopoverDismissalBehavior]):

  • UIProcess/ios/WebDataListSuggestionsDropdownIOS.mm:

(WebKit::WebDataListSuggestionsDropdownIOS::show):

  • UIProcess/ios/WebPageProxyIOS.mm:

(WebKit::desktopClassBrowsingSupported):

  • UIProcess/ios/forms/WKAirPlayRoutePicker.mm:

(-[WKAirPlayRoutePicker show:fromRect:]):

  • UIProcess/ios/forms/WKFileUploadPanel.mm:

(-[WKFileUploadPanel _showPhotoPickerWithSourceType:]):
(-[WKFileUploadPanel _presentMenuOptionForCurrentInterfaceIdiom:]):

  • UIProcess/ios/forms/WKFormColorControl.mm:

(-[WKFormColorControl initWithView:]):

  • UIProcess/ios/forms/WKFormColorPicker.mm:

(-[WKColorPicker initWithView:inPopover:]):
(-[WKColorPicker drawSelectionIndicatorForColorButton:]):

  • UIProcess/ios/forms/WKFormSelectControl.mm:

(-[WKFormSelectControl initWithView:]):

  • WebProcess/cocoa/WebProcessCocoa.mm:

(WebKit::WebProcess::platformInitializeWebProcess):
Rename currentUserInterfaceIdiomIsPad to currentUserInterfaceIdiomIsPadOrMac,
and force it to YES on macCatalyst since internally we use it to distinguish
between iPhone and iPad behavior, and (for our behaviors, at least) macCatalyst
should always follow iPad.

We should clean this up, and make all callers make their
iPhone vs. iPad vs. macOS decisions more explicit.

Location:
trunk/Source/WebKit
Files:
16 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r266802 r266804  
     12020-09-09  Tim Horton  <timothy_horton@apple.com>
     2
     3        macCatalyst: Form controls behave strangely (like iPhone) in macOS-idiom apps
     4        https://bugs.webkit.org/show_bug.cgi?id=216326
     5
     6        Reviewed by Wenson Hsieh.
     7
     8        * Shared/UserInterfaceIdiom.h:
     9        * Shared/UserInterfaceIdiom.mm:
     10        (WebKit::userInterfaceIdiomIsPad):
     11        (WebKit::currentUserInterfaceIdiomIsPadOrMac):
     12        (WebKit::setCurrentUserInterfaceIdiomIsPadOrMac):
     13        (WebKit::currentUserInterfaceIdiomIsPad): Deleted.
     14        (WebKit::setCurrentUserInterfaceIdiomIsPad): Deleted.
     15        * Shared/ios/WebPreferencesDefaultValuesIOS.mm:
     16        (WebKit::defaultTextAutosizingUsesIdempotentMode):
     17        * UIProcess/API/Cocoa/WKWebViewConfiguration.mm:
     18        (-[WKWebViewConfiguration init]):
     19        * UIProcess/Cocoa/WebProcessPoolCocoa.mm:
     20        (WebKit::WebProcessPool::platformInitializeWebProcess):
     21        * UIProcess/ios/SmartMagnificationController.mm:
     22        (WebKit::SmartMagnificationController::didCollectGeometryForSmartMagnificationGesture):
     23        * UIProcess/ios/WKContentViewInteraction.mm:
     24        (-[WKFormInputSession setAccessoryViewCustomButtonTitle:]):
     25        (-[WKContentView endEditingAndUpdateFocusAppearanceWithReason:]):
     26        (-[WKContentView _shouldShowAutomaticKeyboardUIIgnoringInputMode]):
     27        (-[WKContentView _zoomToRevealFocusedElement]):
     28        (-[WKContentView requiresAccessoryView]):
     29        (-[WKContentView _updateAccessory]):
     30        (shouldShowKeyboardForElement):
     31        (-[WKContentView _shouldUseLegacySelectPopoverDismissalBehavior]):
     32        * UIProcess/ios/WebDataListSuggestionsDropdownIOS.mm:
     33        (WebKit::WebDataListSuggestionsDropdownIOS::show):
     34        * UIProcess/ios/WebPageProxyIOS.mm:
     35        (WebKit::desktopClassBrowsingSupported):
     36        * UIProcess/ios/forms/WKAirPlayRoutePicker.mm:
     37        (-[WKAirPlayRoutePicker show:fromRect:]):
     38        * UIProcess/ios/forms/WKFileUploadPanel.mm:
     39        (-[WKFileUploadPanel _showPhotoPickerWithSourceType:]):
     40        (-[WKFileUploadPanel _presentMenuOptionForCurrentInterfaceIdiom:]):
     41        * UIProcess/ios/forms/WKFormColorControl.mm:
     42        (-[WKFormColorControl initWithView:]):
     43        * UIProcess/ios/forms/WKFormColorPicker.mm:
     44        (-[WKColorPicker initWithView:inPopover:]):
     45        (-[WKColorPicker drawSelectionIndicatorForColorButton:]):
     46        * UIProcess/ios/forms/WKFormSelectControl.mm:
     47        (-[WKFormSelectControl initWithView:]):
     48        * WebProcess/cocoa/WebProcessCocoa.mm:
     49        (WebKit::WebProcess::platformInitializeWebProcess):
     50        Rename currentUserInterfaceIdiomIsPad to currentUserInterfaceIdiomIsPadOrMac,
     51        and force it to YES on macCatalyst since internally we use it to distinguish
     52        between iPhone and iPad behavior, and (for our behaviors, at least) macCatalyst
     53        should always follow iPad.
     54
     55        We should clean this up, and make all callers make their
     56        iPhone vs. iPad vs. macOS decisions more explicit.
     57
    1582020-09-09  Wenson Hsieh  <wenson_hsieh@apple.com>
    259
  • trunk/Source/WebKit/Shared/UserInterfaceIdiom.h

    r253663 r266804  
    3030namespace WebKit {
    3131
    32 bool currentUserInterfaceIdiomIsPad();
    33 void setCurrentUserInterfaceIdiomIsPad(bool);
     32bool currentUserInterfaceIdiomIsPadOrMac();
     33void setCurrentUserInterfaceIdiomIsPadOrMac(bool);
    3434
    3535}
  • trunk/Source/WebKit/Shared/UserInterfaceIdiom.mm

    r261157 r266804  
    4444static inline bool userInterfaceIdiomIsPad()
    4545{
     46#if PLATFORM(MACCATALYST)
     47    // UIKit varies the UIUserInterfaceIdiom between iPad and macOS in macCatalyst, depending on various settings,
     48    // but for the purposes of WebKit we always want to use iPad behavior (vs. iPhone) in macCatalyst.
     49    // FIXME: We should get rid of this function and have callers make explicit decisions for all of iPhone/iPad/macOS.
     50    return true;
     51#else
    4652    // If we are in a daemon, we cannot use UIDevice. Fall back to checking the hardware itself.
    4753    // Since daemons don't ever run in an iPhone-app-on-iPad jail, this will be accurate in the daemon case,
     
    5359    // detection on platforms where UICurrentUserInterfaceIdiomIsPad
    5460    // is defined directly to false.
    55 #if USE(APPLE_INTERNAL_SDK) && !PLATFORM(MACCATALYST)
     61#if USE(APPLE_INTERNAL_SDK)
    5662    return UICurrentUserInterfaceIdiomIsPad();
    5763#else
    5864    return [[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad;
    5965#endif
     66#endif
    6067}
    6168
    62 bool currentUserInterfaceIdiomIsPad()
     69bool currentUserInterfaceIdiomIsPadOrMac()
    6370{
    6471    if (userInterfaceIdiomIsPadState == UserInterfaceIdiomState::Unknown)
    65         setCurrentUserInterfaceIdiomIsPad(userInterfaceIdiomIsPad());
     72        setCurrentUserInterfaceIdiomIsPadOrMac(userInterfaceIdiomIsPad());
    6673
    6774    return userInterfaceIdiomIsPadState == UserInterfaceIdiomState::IsPad;
    6875}
    6976
    70 void setCurrentUserInterfaceIdiomIsPad(bool isPad)
     77void setCurrentUserInterfaceIdiomIsPadOrMac(bool isPad)
    7178{
    7279    userInterfaceIdiomIsPadState = isPad ? UserInterfaceIdiomState::IsPad : UserInterfaceIdiomState::IsNotPad;
  • trunk/Source/WebKit/Shared/ios/WebPreferencesDefaultValuesIOS.mm

    r255376 r266804  
    3939bool defaultTextAutosizingUsesIdempotentMode()
    4040{
    41     return currentUserInterfaceIdiomIsPad();
     41    return currentUserInterfaceIdiomIsPadOrMac();
    4242}
    4343
  • trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewConfiguration.mm

    r266342 r266804  
    194194#endif
    195195
    196 #if PLATFORM(MACCATALYST)
    197     _allowsInlineMediaPlayback = YES;
    198 #else
    199     _allowsInlineMediaPlayback = WebKit::currentUserInterfaceIdiomIsPad();
    200 #endif
     196    _allowsInlineMediaPlayback = WebKit::currentUserInterfaceIdiomIsPadOrMac();
    201197    _inlineMediaPlaybackRequiresPlaysInlineAttribute = !_allowsInlineMediaPlayback;
    202198    _allowsInlineMediaPlaybackAfterFullscreen = !_allowsInlineMediaPlayback;
  • trunk/Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm

    r266802 r266804  
    442442
    443443#if PLATFORM(IOS_FAMILY)
    444     parameters.currentUserInterfaceIdiomIsPad = currentUserInterfaceIdiomIsPad();
     444    parameters.currentUserInterfaceIdiomIsPad = currentUserInterfaceIdiomIsPadOrMac();
    445445    parameters.supportsPictureInPicture = supportsPictureInPicture();
    446446    parameters.cssValueToSystemColorMap = RenderThemeIOS::cssValueToSystemColorMap();
  • trunk/Source/WebKit/UIProcess/ios/SmartMagnificationController.mm

    r261299 r266804  
    120120    if ([m_contentView bounds].size.width <= m_webPageProxy.unobscuredContentRect().width())
    121121        minimumScrollDistance = smartMagnificationPanScrollThresholdZoomedOut;
    122     else if (currentUserInterfaceIdiomIsPad())
     122    else if (currentUserInterfaceIdiomIsPadOrMac())
    123123        minimumScrollDistance = smartMagnificationPanScrollThresholdIPad;
    124124    else
  • trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm

    r266766 r266804  
    389389    else
    390390        [[_contentView formAccessoryView] hideAutoFillButton];
    391     if (WebKit::currentUserInterfaceIdiomIsPad())
     391    if (WebKit::currentUserInterfaceIdiomIsPadOrMac())
    392392        [_contentView reloadInputViews];
    393393}
     
    13811381                    return true;
    13821382
    1383                 if (!WebKit::currentUserInterfaceIdiomIsPad())
     1383                if (!WebKit::currentUserInterfaceIdiomIsPadOrMac())
    13841384                    return true;
    13851385            }
     
    19521952    case WebKit::InputType::Color:
    19531953#endif
    1954         return !WebKit::currentUserInterfaceIdiomIsPad();
     1954        return !WebKit::currentUserInterfaceIdiomIsPadOrMac();
    19551955    default:
    19561956        return YES;
     
    19961996        minimumScale:_focusedElementInformation.minimumScaleFactor
    19971997        maximumScale:_focusedElementInformation.maximumScaleFactorIgnoringAlwaysScalable
    1998         allowScaling:_focusedElementInformation.allowsUserScalingIgnoringAlwaysScalable && !WebKit::currentUserInterfaceIdiomIsPad()
     1998        allowScaling:_focusedElementInformation.allowsUserScalingIgnoringAlwaysScalable && !WebKit::currentUserInterfaceIdiomIsPadOrMac()
    19991999        forceScroll:[self requiresAccessoryView]];
    20002000}
     
    29662966    case WebKit::InputType::Color:
    29672967#endif
    2968         return !WebKit::currentUserInterfaceIdiomIsPad();
     2968        return !WebKit::currentUserInterfaceIdiomIsPadOrMac();
    29692969    }
    29702970}
     
    44494449    [accessoryView setPreviousEnabled:_focusedElementInformation.hasPreviousNode];
    44504450
    4451     if (WebKit::currentUserInterfaceIdiomIsPad()) {
     4451    if (WebKit::currentUserInterfaceIdiomIsPadOrMac()) {
    44524452        [accessoryView setClearVisible:NO];
    44534453        return;
     
    58215821        return true;
    58225822
    5823     return !WebKit::currentUserInterfaceIdiomIsPad();
     5823    return !WebKit::currentUserInterfaceIdiomIsPadOrMac();
    58245824}
    58255825
     
    71167116- (BOOL)_shouldUseLegacySelectPopoverDismissalBehavior
    71177117{
    7118     if (!WebKit::currentUserInterfaceIdiomIsPad())
     7118    if (!WebKit::currentUserInterfaceIdiomIsPadOrMac())
    71197119        return NO;
    71207120
  • trunk/Source/WebKit/UIProcess/ios/WebDataListSuggestionsDropdownIOS.mm

    r260366 r266804  
    103103    WebCore::DataListSuggestionActivationType type = information.activationType;
    104104
    105     if (currentUserInterfaceIdiomIsPad())
     105    if (currentUserInterfaceIdiomIsPadOrMac())
    106106        m_suggestionsControl = adoptNS([[WKDataListSuggestionsPopover alloc] initWithInformation:WTFMove(information) inView:m_contentView]);
    107107    else
  • trunk/Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm

    r266654 r266804  
    13401340    static dispatch_once_t onceToken;
    13411341    dispatch_once(&onceToken, ^{
    1342 #if PLATFORM(MACCATALYST)
    1343         supportsDesktopClassBrowsing = true;
    1344 #else
    1345         supportsDesktopClassBrowsing = currentUserInterfaceIdiomIsPad();
    1346 #endif
     1342        supportsDesktopClassBrowsing = currentUserInterfaceIdiomIsPadOrMac();
    13471343    });
    13481344    return supportsDesktopClassBrowsing;
  • trunk/Source/WebKit/UIProcess/ios/forms/WKAirPlayRoutePicker.mm

    r253889 r266804  
    155155
    156156    MPAVItemType itemType = hasVideo ? MPAVItemTypeVideo : MPAVItemTypeAudio;
    157     if (currentUserInterfaceIdiomIsPad())
     157    if (currentUserInterfaceIdiomIsPadOrMac())
    158158        [self showAirPlayPickerIPad:itemType fromRect:elementRect];
    159159    else
  • trunk/Source/WebKit/UIProcess/ios/forms/WKFileUploadPanel.mm

    r266361 r266804  
    569569    // Use a popover on the iPad if the source type is not the camera.
    570570    // The camera will use a fullscreen, modal view controller.
    571     BOOL usePopover = currentUserInterfaceIdiomIsPad() && sourceType != UIImagePickerControllerSourceTypeCamera;
     571    BOOL usePopover = currentUserInterfaceIdiomIsPadOrMac() && sourceType != UIImagePickerControllerSourceTypeCamera;
    572572    if (usePopover)
    573573        [self _presentPopoverWithContentViewController:_imagePicker.get() animated:YES];
     
    580580- (void)_presentMenuOptionForCurrentInterfaceIdiom:(UIViewController *)viewController
    581581{
    582     if (currentUserInterfaceIdiomIsPad())
     582    if (currentUserInterfaceIdiomIsPadOrMac())
    583583        [self _presentPopoverWithContentViewController:viewController animated:YES];
    584584    else
  • trunk/Source/WebKit/UIProcess/ios/forms/WKFormColorControl.mm

    r259336 r266804  
    100100{
    101101    RetainPtr<NSObject <WKFormControl>> control;
    102     if (WebKit::currentUserInterfaceIdiomIsPad())
     102    if (WebKit::currentUserInterfaceIdiomIsPadOrMac())
    103103        control = adoptNS([[WKColorPopover alloc] initWithView:view]);
    104104    else
  • trunk/Source/WebKit/UIProcess/ios/forms/WKFormColorPicker.mm

    r263788 r266804  
    193193
    194194    CGSize colorPickerSize;
    195     if (currentUserInterfaceIdiomIsPad())
     195    if (currentUserInterfaceIdiomIsPadOrMac())
    196196        colorPickerSize = CGSizeMake(pickerWidthForPopover, pickerWidthForPopover);
    197197    else {
     
    253253
    254254    UIRectCorner roundCorner = 0;
    255     if (currentUserInterfaceIdiomIsPad()) {
     255    if (currentUserInterfaceIdiomIsPadOrMac()) {
    256256        CGRect colorPickerBounds = [_colorPicker bounds];
    257257
  • trunk/Source/WebKit/UIProcess/ios/forms/WKFormSelectControl.mm

    r261815 r266804  
    7575
    7676    RetainPtr<NSObject <WKFormControl>> control;
    77     if (currentUserInterfaceIdiomIsPad())
     77    if (currentUserInterfaceIdiomIsPadOrMac())
    7878        control = adoptNS([[WKSelectPopover alloc] initWithView:view hasGroups:hasGroups]);
    7979    else if (view.focusedElementInformation.isMultiSelect || hasGroups)
  • trunk/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm

    r266802 r266804  
    253253
    254254#if PLATFORM(IOS_FAMILY)
    255     setCurrentUserInterfaceIdiomIsPad(parameters.currentUserInterfaceIdiomIsPad);
     255    setCurrentUserInterfaceIdiomIsPadOrMac(parameters.currentUserInterfaceIdiomIsPad);
    256256    setLocalizedDeviceModel(parameters.localizedDeviceModel);
    257257#if ENABLE(VIDEO_PRESENTATION_MODE)
Note: See TracChangeset for help on using the changeset viewer.