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

Changeset 267628 in webkit


Ignore:
Timestamp:
Sep 26, 2020, 2:08:24 PM (6 years ago)
Author:
Alan Coon
Message:

Cherry-pick r266804. rdar://problem/69583164

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.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266804 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Location:
branches/safari-610-branch/Source/WebKit
Files:
16 edited

Legend:

Unmodified
Added
Removed
  • branches/safari-610-branch/Source/WebKit/ChangeLog

    r267627 r267628  
     12020-09-25  Alan Coon  <alancoon@apple.com>
     2
     3        Cherry-pick r266804. rdar://problem/69583164
     4
     5    macCatalyst: Form controls behave strangely (like iPhone) in macOS-idiom apps
     6    https://bugs.webkit.org/show_bug.cgi?id=216326
     7   
     8    Reviewed by Wenson Hsieh.
     9   
     10    * Shared/UserInterfaceIdiom.h:
     11    * Shared/UserInterfaceIdiom.mm:
     12    (WebKit::userInterfaceIdiomIsPad):
     13    (WebKit::currentUserInterfaceIdiomIsPadOrMac):
     14    (WebKit::setCurrentUserInterfaceIdiomIsPadOrMac):
     15    (WebKit::currentUserInterfaceIdiomIsPad): Deleted.
     16    (WebKit::setCurrentUserInterfaceIdiomIsPad): Deleted.
     17    * Shared/ios/WebPreferencesDefaultValuesIOS.mm:
     18    (WebKit::defaultTextAutosizingUsesIdempotentMode):
     19    * UIProcess/API/Cocoa/WKWebViewConfiguration.mm:
     20    (-[WKWebViewConfiguration init]):
     21    * UIProcess/Cocoa/WebProcessPoolCocoa.mm:
     22    (WebKit::WebProcessPool::platformInitializeWebProcess):
     23    * UIProcess/ios/SmartMagnificationController.mm:
     24    (WebKit::SmartMagnificationController::didCollectGeometryForSmartMagnificationGesture):
     25    * UIProcess/ios/WKContentViewInteraction.mm:
     26    (-[WKFormInputSession setAccessoryViewCustomButtonTitle:]):
     27    (-[WKContentView endEditingAndUpdateFocusAppearanceWithReason:]):
     28    (-[WKContentView _shouldShowAutomaticKeyboardUIIgnoringInputMode]):
     29    (-[WKContentView _zoomToRevealFocusedElement]):
     30    (-[WKContentView requiresAccessoryView]):
     31    (-[WKContentView _updateAccessory]):
     32    (shouldShowKeyboardForElement):
     33    (-[WKContentView _shouldUseLegacySelectPopoverDismissalBehavior]):
     34    * UIProcess/ios/WebDataListSuggestionsDropdownIOS.mm:
     35    (WebKit::WebDataListSuggestionsDropdownIOS::show):
     36    * UIProcess/ios/WebPageProxyIOS.mm:
     37    (WebKit::desktopClassBrowsingSupported):
     38    * UIProcess/ios/forms/WKAirPlayRoutePicker.mm:
     39    (-[WKAirPlayRoutePicker show:fromRect:]):
     40    * UIProcess/ios/forms/WKFileUploadPanel.mm:
     41    (-[WKFileUploadPanel _showPhotoPickerWithSourceType:]):
     42    (-[WKFileUploadPanel _presentMenuOptionForCurrentInterfaceIdiom:]):
     43    * UIProcess/ios/forms/WKFormColorControl.mm:
     44    (-[WKFormColorControl initWithView:]):
     45    * UIProcess/ios/forms/WKFormColorPicker.mm:
     46    (-[WKColorPicker initWithView:inPopover:]):
     47    (-[WKColorPicker drawSelectionIndicatorForColorButton:]):
     48    * UIProcess/ios/forms/WKFormSelectControl.mm:
     49    (-[WKFormSelectControl initWithView:]):
     50    * WebProcess/cocoa/WebProcessCocoa.mm:
     51    (WebKit::WebProcess::platformInitializeWebProcess):
     52    Rename currentUserInterfaceIdiomIsPad to currentUserInterfaceIdiomIsPadOrMac,
     53    and force it to YES on macCatalyst since internally we use it to distinguish
     54    between iPhone and iPad behavior, and (for our behaviors, at least) macCatalyst
     55    should always follow iPad.
     56   
     57    We should clean this up, and make all callers make their
     58    iPhone vs. iPad vs. macOS decisions more explicit.
     59   
     60   
     61    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266804 268f45cc-cd09-0410-ab3c-d52691b4dbfc
     62
     63    2020-09-09  Tim Horton  <timothy_horton@apple.com>
     64
     65            macCatalyst: Form controls behave strangely (like iPhone) in macOS-idiom apps
     66            https://bugs.webkit.org/show_bug.cgi?id=216326
     67
     68            Reviewed by Wenson Hsieh.
     69
     70            * Shared/UserInterfaceIdiom.h:
     71            * Shared/UserInterfaceIdiom.mm:
     72            (WebKit::userInterfaceIdiomIsPad):
     73            (WebKit::currentUserInterfaceIdiomIsPadOrMac):
     74            (WebKit::setCurrentUserInterfaceIdiomIsPadOrMac):
     75            (WebKit::currentUserInterfaceIdiomIsPad): Deleted.
     76            (WebKit::setCurrentUserInterfaceIdiomIsPad): Deleted.
     77            * Shared/ios/WebPreferencesDefaultValuesIOS.mm:
     78            (WebKit::defaultTextAutosizingUsesIdempotentMode):
     79            * UIProcess/API/Cocoa/WKWebViewConfiguration.mm:
     80            (-[WKWebViewConfiguration init]):
     81            * UIProcess/Cocoa/WebProcessPoolCocoa.mm:
     82            (WebKit::WebProcessPool::platformInitializeWebProcess):
     83            * UIProcess/ios/SmartMagnificationController.mm:
     84            (WebKit::SmartMagnificationController::didCollectGeometryForSmartMagnificationGesture):
     85            * UIProcess/ios/WKContentViewInteraction.mm:
     86            (-[WKFormInputSession setAccessoryViewCustomButtonTitle:]):
     87            (-[WKContentView endEditingAndUpdateFocusAppearanceWithReason:]):
     88            (-[WKContentView _shouldShowAutomaticKeyboardUIIgnoringInputMode]):
     89            (-[WKContentView _zoomToRevealFocusedElement]):
     90            (-[WKContentView requiresAccessoryView]):
     91            (-[WKContentView _updateAccessory]):
     92            (shouldShowKeyboardForElement):
     93            (-[WKContentView _shouldUseLegacySelectPopoverDismissalBehavior]):
     94            * UIProcess/ios/WebDataListSuggestionsDropdownIOS.mm:
     95            (WebKit::WebDataListSuggestionsDropdownIOS::show):
     96            * UIProcess/ios/WebPageProxyIOS.mm:
     97            (WebKit::desktopClassBrowsingSupported):
     98            * UIProcess/ios/forms/WKAirPlayRoutePicker.mm:
     99            (-[WKAirPlayRoutePicker show:fromRect:]):
     100            * UIProcess/ios/forms/WKFileUploadPanel.mm:
     101            (-[WKFileUploadPanel _showPhotoPickerWithSourceType:]):
     102            (-[WKFileUploadPanel _presentMenuOptionForCurrentInterfaceIdiom:]):
     103            * UIProcess/ios/forms/WKFormColorControl.mm:
     104            (-[WKFormColorControl initWithView:]):
     105            * UIProcess/ios/forms/WKFormColorPicker.mm:
     106            (-[WKColorPicker initWithView:inPopover:]):
     107            (-[WKColorPicker drawSelectionIndicatorForColorButton:]):
     108            * UIProcess/ios/forms/WKFormSelectControl.mm:
     109            (-[WKFormSelectControl initWithView:]):
     110            * WebProcess/cocoa/WebProcessCocoa.mm:
     111            (WebKit::WebProcess::platformInitializeWebProcess):
     112            Rename currentUserInterfaceIdiomIsPad to currentUserInterfaceIdiomIsPadOrMac,
     113            and force it to YES on macCatalyst since internally we use it to distinguish
     114            between iPhone and iPad behavior, and (for our behaviors, at least) macCatalyst
     115            should always follow iPad.
     116
     117            We should clean this up, and make all callers make their
     118            iPhone vs. iPad vs. macOS decisions more explicit.
     119
    11202020-09-25  Alan Coon  <alancoon@apple.com>
    2121
  • branches/safari-610-branch/Source/WebKit/Shared/UserInterfaceIdiom.h

    r253663 r267628  
    3030namespace WebKit {
    3131
    32 bool currentUserInterfaceIdiomIsPad();
    33 void setCurrentUserInterfaceIdiomIsPad(bool);
     32bool currentUserInterfaceIdiomIsPadOrMac();
     33void setCurrentUserInterfaceIdiomIsPadOrMac(bool);
    3434
    3535}
  • branches/safari-610-branch/Source/WebKit/Shared/UserInterfaceIdiom.mm

    r261157 r267628  
    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;
  • branches/safari-610-branch/Source/WebKit/Shared/ios/WebPreferencesDefaultValuesIOS.mm

    r255376 r267628  
    3939bool defaultTextAutosizingUsesIdempotentMode()
    4040{
    41     return currentUserInterfaceIdiomIsPad();
     41    return currentUserInterfaceIdiomIsPadOrMac();
    4242}
    4343
  • branches/safari-610-branch/Source/WebKit/UIProcess/API/Cocoa/WKWebViewConfiguration.mm

    r266002 r267628  
    195195#endif
    196196
    197 #if PLATFORM(MACCATALYST)
    198     _allowsInlineMediaPlayback = YES;
    199 #else
    200     _allowsInlineMediaPlayback = WebKit::currentUserInterfaceIdiomIsPad();
    201 #endif
     197    _allowsInlineMediaPlayback = WebKit::currentUserInterfaceIdiomIsPadOrMac();
    202198    _inlineMediaPlaybackRequiresPlaysInlineAttribute = !_allowsInlineMediaPlayback;
    203199    _allowsInlineMediaPlaybackAfterFullscreen = !_allowsInlineMediaPlayback;
  • branches/safari-610-branch/Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm

    r267273 r267628  
    442442
    443443#if PLATFORM(IOS_FAMILY)
    444     parameters.currentUserInterfaceIdiomIsPad = currentUserInterfaceIdiomIsPad();
     444    parameters.currentUserInterfaceIdiomIsPad = currentUserInterfaceIdiomIsPadOrMac();
    445445    parameters.supportsPictureInPicture = supportsPictureInPicture();
    446446    parameters.cssValueToSystemColorMap = RenderThemeIOS::cssValueToSystemColorMap();
  • branches/safari-610-branch/Source/WebKit/UIProcess/ios/SmartMagnificationController.mm

    r261299 r267628  
    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
  • branches/safari-610-branch/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm

    r266864 r267628  
    394394    else
    395395        [[_contentView formAccessoryView] hideAutoFillButton];
    396     if (WebKit::currentUserInterfaceIdiomIsPad())
     396    if (WebKit::currentUserInterfaceIdiomIsPadOrMac())
    397397        [_contentView reloadInputViews];
    398398}
     
    14011401                    return true;
    14021402
    1403                 if (!WebKit::currentUserInterfaceIdiomIsPad())
     1403                if (!WebKit::currentUserInterfaceIdiomIsPadOrMac())
    14041404                    return true;
    14051405            }
     
    19721972    case WebKit::InputType::Color:
    19731973#endif
    1974         return !WebKit::currentUserInterfaceIdiomIsPad();
     1974        return !WebKit::currentUserInterfaceIdiomIsPadOrMac();
    19751975    default:
    19761976        return YES;
     
    20162016        minimumScale:_focusedElementInformation.minimumScaleFactor
    20172017        maximumScale:_focusedElementInformation.maximumScaleFactorIgnoringAlwaysScalable
    2018         allowScaling:_focusedElementInformation.allowsUserScalingIgnoringAlwaysScalable && !WebKit::currentUserInterfaceIdiomIsPad()
     2018        allowScaling:_focusedElementInformation.allowsUserScalingIgnoringAlwaysScalable && !WebKit::currentUserInterfaceIdiomIsPadOrMac()
    20192019        forceScroll:[self requiresAccessoryView]];
    20202020}
     
    30033003    case WebKit::InputType::Color:
    30043004#endif
    3005         return !WebKit::currentUserInterfaceIdiomIsPad();
     3005        return !WebKit::currentUserInterfaceIdiomIsPadOrMac();
    30063006    }
    30073007}
     
    44864486    [accessoryView setPreviousEnabled:_focusedElementInformation.hasPreviousNode];
    44874487
    4488     if (WebKit::currentUserInterfaceIdiomIsPad()) {
     4488    if (WebKit::currentUserInterfaceIdiomIsPadOrMac()) {
    44894489        [accessoryView setClearVisible:NO];
    44904490        return;
     
    58585858        return true;
    58595859
    5860     return !WebKit::currentUserInterfaceIdiomIsPad();
     5860    return !WebKit::currentUserInterfaceIdiomIsPadOrMac();
    58615861}
    58625862
     
    71697169- (BOOL)_shouldUseLegacySelectPopoverDismissalBehavior
    71707170{
    7171     if (!WebKit::currentUserInterfaceIdiomIsPad())
     7171    if (!WebKit::currentUserInterfaceIdiomIsPadOrMac())
    71727172        return NO;
    71737173
  • branches/safari-610-branch/Source/WebKit/UIProcess/ios/WebDataListSuggestionsDropdownIOS.mm

    r260366 r267628  
    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
  • branches/safari-610-branch/Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm

    r265882 r267628  
    13501350    static dispatch_once_t onceToken;
    13511351    dispatch_once(&onceToken, ^{
    1352 #if PLATFORM(MACCATALYST)
    1353         supportsDesktopClassBrowsing = true;
    1354 #else
    1355         supportsDesktopClassBrowsing = currentUserInterfaceIdiomIsPad();
    1356 #endif
     1352        supportsDesktopClassBrowsing = currentUserInterfaceIdiomIsPadOrMac();
    13571353    });
    13581354    return supportsDesktopClassBrowsing;
  • branches/safari-610-branch/Source/WebKit/UIProcess/ios/forms/WKAirPlayRoutePicker.mm

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

    r264785 r267628  
    561561    // Use a popover on the iPad if the source type is not the camera.
    562562    // The camera will use a fullscreen, modal view controller.
    563     BOOL usePopover = currentUserInterfaceIdiomIsPad() && sourceType != UIImagePickerControllerSourceTypeCamera;
     563    BOOL usePopover = currentUserInterfaceIdiomIsPadOrMac() && sourceType != UIImagePickerControllerSourceTypeCamera;
    564564    if (usePopover)
    565565        [self _presentPopoverWithContentViewController:_imagePicker.get() animated:YES];
     
    583583- (void)_presentMenuOptionForCurrentInterfaceIdiom:(UIViewController *)viewController
    584584{
    585     if (currentUserInterfaceIdiomIsPad())
     585    if (currentUserInterfaceIdiomIsPadOrMac())
    586586        [self _presentPopoverWithContentViewController:viewController animated:YES];
    587587    else
  • branches/safari-610-branch/Source/WebKit/UIProcess/ios/forms/WKFormColorControl.mm

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

    r263788 r267628  
    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
  • branches/safari-610-branch/Source/WebKit/UIProcess/ios/forms/WKFormSelectControl.mm

    r261815 r267628  
    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)
  • branches/safari-610-branch/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm

    r267273 r267628  
    254254
    255255#if PLATFORM(IOS_FAMILY)
    256     setCurrentUserInterfaceIdiomIsPad(parameters.currentUserInterfaceIdiomIsPad);
     256    setCurrentUserInterfaceIdiomIsPadOrMac(parameters.currentUserInterfaceIdiomIsPad);
    257257    setLocalizedDeviceModel(parameters.localizedDeviceModel);
    258258#if ENABLE(VIDEO_PRESENTATION_MODE)
Note: See TracChangeset for help on using the changeset viewer.