Title: [283721] trunk/Source
Revision
283721
Author
da...@apple.com
Date
2021-10-07 10:58:38 -0700 (Thu, 07 Oct 2021)

Log Message

Get rid of the deviceClass function, up-leveling to deviceClassIsSmallScreen
https://bugs.webkit.org/show_bug.cgi?id=231344

Reviewed by Tim Horton.

Source/WebCore:

* platform/ios/Device.cpp:
(WebCore::deviceClassIsSmallScreen): Replaced deviceClass with this.
* platform/ios/Device.h: Ditto.

Source/WebKit:

* Shared/UserInterfaceIdiom.h:
* Shared/UserInterfaceIdiom.mm:
(WebKit::currentUserInterfaceIdiomIsSmallScreen): Renamed to say "is small screen"
instead of "is phone or watch", the same concept. Also switched to TriState instead
of using a unique enumeration.
(WebKit::setCurrentUserInterfaceIdiomIsSmallScreen): Ditto.
(WebKit::updateCurrentUserInterfaceIdiom): Updated for name change.

* Shared/WebProcessCreationParameters.cpp:
(WebKit::WebProcessCreationParameters::encode const): Updated for name change.
(WebKit::WebProcessCreationParameters::decode): Ditto.
* Shared/WebProcessCreationParameters.h: Ditto.

* Shared/ios/WebPreferencesDefaultValuesIOS.mm:
(WebKit::defaultTextAutosizingUsesIdempotentMode): Updated for name change.
(WebKit::defaultMediaSourceEnabled): Use !deviceClassIsSmallScreen instead of
deviceClass != iPhone and != iPod, and also remove unneeded compile time conditionals.

* UIProcess/API/Cocoa/WKWebViewConfiguration.mm: Removed uneeded Device.h include.
(-[WKWebViewConfiguration init]): Updated for name change.
* UIProcess/Cocoa/WebProcessPoolCocoa.mm:
(WebKit::WebProcessPool::platformInitializeWebProcess): Ditto.
(WebKit::WebProcessPool::registerNotificationObservers): Ditto, also got rid of
local variable.

* UIProcess/ios/SmartMagnificationController.mm:
(WebKit::SmartMagnificationController::didCollectGeometryForSmartMagnificationGesture):
Updated for name change.
* UIProcess/ios/WKContentViewInteraction.mm:
(-[WKFormInputSession setAccessoryViewCustomButtonTitle:]): Ditto.
(-[WKContentView endEditingAndUpdateFocusAppearanceWithReason:]): Ditto.
(-[WKContentView _shouldShowAutomaticKeyboardUIIgnoringInputMode]): Ditto.
(-[WKContentView _zoomToRevealFocusedElement]): Ditto.
(-[WKContentView _elementTypeRequiresAccessoryView:]): Ditto.
(-[WKContentView _updateAccessory]): Ditto.
(-[WKContentView _shouldUseLegacySelectPopoverDismissalBehavior]): Ditto.
* UIProcess/ios/WebDataListSuggestionsDropdownIOS.mm:
(WebKit::WebDataListSuggestionsDropdownIOS::show): Ditto.
* UIProcess/ios/WebPageProxyIOS.mm:
(WebKit::desktopClassBrowsingSupported): Ditto.
* UIProcess/ios/forms/WKAirPlayRoutePicker.mm:
(-[WKAirPlayRoutePicker show:fromRect:]): Ditto.
* UIProcess/ios/forms/WKFileUploadPanel.mm:
(-[WKFileUploadPanel _showPhotoPickerWithSourceType:]): Ditto.
(-[WKFileUploadPanel _presentMenuOptionForCurrentInterfaceIdiom:]): Ditto.
* UIProcess/ios/forms/WKFormSelectControl.mm:
(-[WKFormSelectControl initWithView:]): Ditto.
* UIProcess/ios/forms/WKFormSelectPicker.mm:
(-[WKSelectMultiplePicker configurePresentation]): Ditto.
* WebProcess/cocoa/WebProcessCocoa.mm:
(WebKit::WebProcess::platformInitializeWebProcess): Ditto.
(WebKit::WebProcess::userInterfaceIdiomDidChange): Ditto.

Source/WebKitLegacy/mac:

* WebView/WebPreferences.mm: Removed uneeded Device.h include.

* WebView/WebPreferencesDefaultValues.mm:
(WebKit::defaultAllowsInlineMediaPlayback): Use !deviceClassIsSmallScreen
instead of deviceClass == iPad.
(WebKit::defaultAllowsInlineMediaPlaybackAfterFullscreen): Use
deviceClassIsSmallScreen instead of deviceClass != iPad.
(WebKit::defaultInlineMediaPlaybackRequiresPlaysInlineAttribute): Ditto.
(WebKit::defaultMediaSourceEnabled): Use !deviceClassIsSmallScreen instead of
deviceClass != iPhone and != iPod, and also remove unneeded compile time conditionals.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (283720 => 283721)


--- trunk/Source/WebCore/ChangeLog	2021-10-07 17:46:34 UTC (rev 283720)
+++ trunk/Source/WebCore/ChangeLog	2021-10-07 17:58:38 UTC (rev 283721)
@@ -1,3 +1,14 @@
+2021-10-07  Darin Adler  <da...@apple.com>
+
+        Get rid of the deviceClass function, up-leveling to deviceClassIsSmallScreen
+        https://bugs.webkit.org/show_bug.cgi?id=231344
+
+        Reviewed by Tim Horton.
+
+        * platform/ios/Device.cpp:
+        (WebCore::deviceClassIsSmallScreen): Replaced deviceClass with this.
+        * platform/ios/Device.h: Ditto.
+
 2021-10-07  Antti Koivisto  <an...@apple.com>
 
         Cascade layer styles should be lower priority than unlayered styles

Modified: trunk/Source/WebCore/platform/ios/Device.cpp (283720 => 283721)


--- trunk/Source/WebCore/platform/ios/Device.cpp	2021-10-07 17:46:34 UTC (rev 283720)
+++ trunk/Source/WebCore/platform/ios/Device.cpp	2021-10-07 17:58:38 UTC (rev 283721)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2015 Apple Inc. All rights reserved.
+ * Copyright (C) 2015-2021 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -29,6 +29,7 @@
 #if PLATFORM(IOS_FAMILY)
 
 #include <mutex>
+#include <pal/spi/ios/MobileGestaltSPI.h>
 #include <wtf/NeverDestroyed.h>
 #include <wtf/RetainPtr.h>
 #include <wtf/text/WTFString.h>
@@ -35,10 +36,10 @@
 
 namespace WebCore {
 
-MGDeviceClass deviceClass()
+bool deviceClassIsSmallScreen()
 {
-    static MGDeviceClass deviceClass = static_cast<MGDeviceClass>(MGGetSInt32Answer(kMGQDeviceClassNumber, MGDeviceClassInvalid));
-    return deviceClass;
+    static auto deviceClass = MGGetSInt32Answer(kMGQDeviceClassNumber, MGDeviceClassInvalid);
+    return deviceClass == MGDeviceClassiPhone || deviceClass == MGDeviceClassiPod || deviceClass == MGDeviceClassWatch;
 }
 
 String deviceName()

Modified: trunk/Source/WebCore/platform/ios/Device.h (283720 => 283721)


--- trunk/Source/WebCore/platform/ios/Device.h	2021-10-07 17:46:34 UTC (rev 283720)
+++ trunk/Source/WebCore/platform/ios/Device.h	2021-10-07 17:58:38 UTC (rev 283721)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2015-2018 Apple Inc. All rights reserved.
+ * Copyright (C) 2015-2021 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -23,24 +23,24 @@
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef Device_h
-#define Device_h
+#pragma once
 
 #if PLATFORM(IOS_FAMILY)
 
 #include <wtf/Forward.h>
-#include <pal/spi/ios/MobileGestaltSPI.h>
 
 namespace WebCore {
 
-WEBCORE_EXPORT MGDeviceClass deviceClass();
 String deviceName(); // Thread-safe.
 
-// FIXME: Isn't this the same as deviceClass() == MGDeviceClassiPad?
+// Returns true only for iPhone, iPod, Apple Watch.
+// Few callers should be making any decisions based on device class.
+// If a check like this is needed, often currentUserInterfaceIdiomIsSmallScreen is preferred.
+WEBCORE_EXPORT bool deviceClassIsSmallScreen();
+
+// FIXME: How does this differ from !deviceClassIsSmallScreen()?
 bool deviceHasIPadCapability();
 
 }
 
 #endif // PLATFORM(IOS_FAMILY)
-
-#endif // Device_h

Modified: trunk/Source/WebKit/ChangeLog (283720 => 283721)


--- trunk/Source/WebKit/ChangeLog	2021-10-07 17:46:34 UTC (rev 283720)
+++ trunk/Source/WebKit/ChangeLog	2021-10-07 17:58:38 UTC (rev 283721)
@@ -1,3 +1,63 @@
+2021-10-07  Darin Adler  <da...@apple.com>
+
+        Get rid of the deviceClass function, up-leveling to deviceClassIsSmallScreen
+        https://bugs.webkit.org/show_bug.cgi?id=231344
+
+        Reviewed by Tim Horton.
+
+        * Shared/UserInterfaceIdiom.h:
+        * Shared/UserInterfaceIdiom.mm:
+        (WebKit::currentUserInterfaceIdiomIsSmallScreen): Renamed to say "is small screen"
+        instead of "is phone or watch", the same concept. Also switched to TriState instead
+        of using a unique enumeration.
+        (WebKit::setCurrentUserInterfaceIdiomIsSmallScreen): Ditto.
+        (WebKit::updateCurrentUserInterfaceIdiom): Updated for name change.
+
+        * Shared/WebProcessCreationParameters.cpp:
+        (WebKit::WebProcessCreationParameters::encode const): Updated for name change.
+        (WebKit::WebProcessCreationParameters::decode): Ditto.
+        * Shared/WebProcessCreationParameters.h: Ditto.
+
+        * Shared/ios/WebPreferencesDefaultValuesIOS.mm:
+        (WebKit::defaultTextAutosizingUsesIdempotentMode): Updated for name change.
+        (WebKit::defaultMediaSourceEnabled): Use !deviceClassIsSmallScreen instead of
+        deviceClass != iPhone and != iPod, and also remove unneeded compile time conditionals.
+
+        * UIProcess/API/Cocoa/WKWebViewConfiguration.mm: Removed uneeded Device.h include.
+        (-[WKWebViewConfiguration init]): Updated for name change.
+        * UIProcess/Cocoa/WebProcessPoolCocoa.mm:
+        (WebKit::WebProcessPool::platformInitializeWebProcess): Ditto.
+        (WebKit::WebProcessPool::registerNotificationObservers): Ditto, also got rid of
+        local variable.
+
+        * UIProcess/ios/SmartMagnificationController.mm:
+        (WebKit::SmartMagnificationController::didCollectGeometryForSmartMagnificationGesture):
+        Updated for name change.
+        * UIProcess/ios/WKContentViewInteraction.mm:
+        (-[WKFormInputSession setAccessoryViewCustomButtonTitle:]): Ditto.
+        (-[WKContentView endEditingAndUpdateFocusAppearanceWithReason:]): Ditto.
+        (-[WKContentView _shouldShowAutomaticKeyboardUIIgnoringInputMode]): Ditto.
+        (-[WKContentView _zoomToRevealFocusedElement]): Ditto.
+        (-[WKContentView _elementTypeRequiresAccessoryView:]): Ditto.
+        (-[WKContentView _updateAccessory]): Ditto.
+        (-[WKContentView _shouldUseLegacySelectPopoverDismissalBehavior]): Ditto.
+        * UIProcess/ios/WebDataListSuggestionsDropdownIOS.mm:
+        (WebKit::WebDataListSuggestionsDropdownIOS::show): Ditto.
+        * UIProcess/ios/WebPageProxyIOS.mm:
+        (WebKit::desktopClassBrowsingSupported): Ditto.
+        * UIProcess/ios/forms/WKAirPlayRoutePicker.mm:
+        (-[WKAirPlayRoutePicker show:fromRect:]): Ditto.
+        * UIProcess/ios/forms/WKFileUploadPanel.mm:
+        (-[WKFileUploadPanel _showPhotoPickerWithSourceType:]): Ditto.
+        (-[WKFileUploadPanel _presentMenuOptionForCurrentInterfaceIdiom:]): Ditto.
+        * UIProcess/ios/forms/WKFormSelectControl.mm:
+        (-[WKFormSelectControl initWithView:]): Ditto.
+        * UIProcess/ios/forms/WKFormSelectPicker.mm:
+        (-[WKSelectMultiplePicker configurePresentation]): Ditto.
+        * WebProcess/cocoa/WebProcessCocoa.mm:
+        (WebKit::WebProcess::platformInitializeWebProcess): Ditto.
+        (WebKit::WebProcess::userInterfaceIdiomDidChange): Ditto.
+
 2021-10-07  Wenson Hsieh  <wenson_hs...@apple.com>
 
         Add the ability to dispatch messages to multiple receiver types in IPC::StreamServerConnection

Modified: trunk/Source/WebKit/Shared/UserInterfaceIdiom.h (283720 => 283721)


--- trunk/Source/WebKit/Shared/UserInterfaceIdiom.h	2021-10-07 17:46:34 UTC (rev 283720)
+++ trunk/Source/WebKit/Shared/UserInterfaceIdiom.h	2021-10-07 17:58:38 UTC (rev 283721)
@@ -1,5 +1,5 @@
 /*
-* Copyright (C) 2019 Apple Inc. All rights reserved.
+* Copyright (C) 2019-2021 Apple Inc. All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
@@ -29,8 +29,8 @@
 
 namespace WebKit {
 
-bool currentUserInterfaceIdiomIsPhoneOrWatch();
-void setCurrentUserInterfaceIdiomIsPhoneOrWatch(bool);
+bool currentUserInterfaceIdiomIsSmallScreen();
+void setCurrentUserInterfaceIdiomIsSmallScreen(bool);
 bool updateCurrentUserInterfaceIdiom();
 
 }

Modified: trunk/Source/WebKit/Shared/UserInterfaceIdiom.mm (283720 => 283721)


--- trunk/Source/WebKit/Shared/UserInterfaceIdiom.mm	2021-10-07 17:46:34 UTC (rev 283720)
+++ trunk/Source/WebKit/Shared/UserInterfaceIdiom.mm	2021-10-07 17:58:38 UTC (rev 283721)
@@ -1,5 +1,5 @@
 /*
-* Copyright (C) 2019 Apple Inc. All rights reserved.
+* Copyright (C) 2019-2021 Apple Inc. All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
@@ -30,52 +30,43 @@
 
 #import "UIKitSPI.h"
 #import <WebCore/Device.h>
+#import <wtf/TriState.h>
 
 namespace WebKit {
 
-enum class UserInterfaceIdiomState : uint8_t {
-    IsPhoneOrWatch,
-    IsNotPhoneOrWatch,
-    Unknown,
-};
+static TriState idiomIsSmallScreen = TriState::Indeterminate;
 
-static UserInterfaceIdiomState userInterfaceIdiomState = UserInterfaceIdiomState::Unknown;
-
-bool currentUserInterfaceIdiomIsPhoneOrWatch()
+bool currentUserInterfaceIdiomIsSmallScreen()
 {
-    // FIXME: We should get rid of this function and have callers make explicit decisions for all of iPhone/iPad/macOS.
-
-    if (userInterfaceIdiomState == UserInterfaceIdiomState::Unknown)
+    if (idiomIsSmallScreen == TriState::Indeterminate)
         updateCurrentUserInterfaceIdiom();
-
-    return userInterfaceIdiomState == UserInterfaceIdiomState::IsPhoneOrWatch;
+    return idiomIsSmallScreen == TriState::True;
 }
 
-void setCurrentUserInterfaceIdiomIsPhoneOrWatch(bool isPhoneOrWatch)
+void setCurrentUserInterfaceIdiomIsSmallScreen(bool isSmallScreen)
 {
-    userInterfaceIdiomState = isPhoneOrWatch ? UserInterfaceIdiomState::IsPhoneOrWatch : UserInterfaceIdiomState::IsNotPhoneOrWatch;
+    idiomIsSmallScreen = TriState(isSmallScreen);
 }
 
 bool updateCurrentUserInterfaceIdiom()
 {
-    bool wasPhoneOrWatch = userInterfaceIdiomState == UserInterfaceIdiomState::IsPhoneOrWatch;
-    bool isPhoneOrWatch = false;
+    bool wasSmallScreen = idiomIsSmallScreen == TriState::True;
 
     // If we are in a daemon, we cannot use UIDevice. Fall back to checking the hardware itself.
     // Since daemons don't ever run in an iPhone-app-on-iPad jail, this will be accurate in the daemon case,
     // but is not sufficient in the application case.
-    if (![UIApplication sharedApplication]) {
-        auto deviceClass = WebCore::deviceClass();
-        isPhoneOrWatch = deviceClass == MGDeviceClassiPhone || deviceClass == MGDeviceClassiPod || deviceClass == MGDeviceClassWatch;
-    } else {
+    bool isSmallScreen;
+    if (![UIApplication sharedApplication])
+        isSmallScreen = WebCore::deviceClassIsSmallScreen();
+    else {
         auto idiom = [[UIDevice currentDevice] userInterfaceIdiom];
-        isPhoneOrWatch = idiom == UIUserInterfaceIdiomPhone || idiom == UIUserInterfaceIdiomWatch;
+        isSmallScreen = idiom == UIUserInterfaceIdiomPhone || idiom == UIUserInterfaceIdiomWatch;
     }
 
-    if (wasPhoneOrWatch == isPhoneOrWatch)
+    if (wasSmallScreen == isSmallScreen)
         return false;
 
-    setCurrentUserInterfaceIdiomIsPhoneOrWatch(isPhoneOrWatch);
+    setCurrentUserInterfaceIdiomIsSmallScreen(isSmallScreen);
     return true;
 }
 

Modified: trunk/Source/WebKit/Shared/WebProcessCreationParameters.cpp (283720 => 283721)


--- trunk/Source/WebKit/Shared/WebProcessCreationParameters.cpp	2021-10-07 17:46:34 UTC (rev 283720)
+++ trunk/Source/WebKit/Shared/WebProcessCreationParameters.cpp	2021-10-07 17:58:38 UTC (rev 283721)
@@ -183,7 +183,7 @@
 #endif
 
 #if PLATFORM(IOS_FAMILY)
-    encoder << currentUserInterfaceIdiomIsPhoneOrWatch;
+    encoder << currentUserInterfaceIdiomIsSmallScreen;
     encoder << supportsPictureInPicture;
     encoder << cssValueToSystemColorMap;
     encoder << focusRingColor;
@@ -526,7 +526,7 @@
 #endif
 
 #if PLATFORM(IOS_FAMILY)
-    if (!decoder.decode(parameters.currentUserInterfaceIdiomIsPhoneOrWatch))
+    if (!decoder.decode(parameters.currentUserInterfaceIdiomIsSmallScreen))
         return false;
 
     if (!decoder.decode(parameters.supportsPictureInPicture))

Modified: trunk/Source/WebKit/Shared/WebProcessCreationParameters.h (283720 => 283721)


--- trunk/Source/WebKit/Shared/WebProcessCreationParameters.h	2021-10-07 17:46:34 UTC (rev 283720)
+++ trunk/Source/WebKit/Shared/WebProcessCreationParameters.h	2021-10-07 17:58:38 UTC (rev 283721)
@@ -229,7 +229,7 @@
 #endif
 
 #if PLATFORM(IOS_FAMILY)
-    bool currentUserInterfaceIdiomIsPhoneOrWatch { false };
+    bool currentUserInterfaceIdiomIsSmallScreen { false };
     bool supportsPictureInPicture { false };
     WebCore::RenderThemeIOS::CSSValueToSystemColorMap cssValueToSystemColorMap;
     WebCore::Color focusRingColor;

Modified: trunk/Source/WebKit/Shared/ios/WebPreferencesDefaultValuesIOS.mm (283720 => 283721)


--- trunk/Source/WebKit/Shared/ios/WebPreferencesDefaultValuesIOS.mm	2021-10-07 17:46:34 UTC (rev 283720)
+++ trunk/Source/WebKit/Shared/ios/WebPreferencesDefaultValuesIOS.mm	2021-10-07 17:58:38 UTC (rev 283721)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2019 Apple Inc. All rights reserved.
+ * Copyright (C) 2019-2021 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -39,7 +39,7 @@
 
 bool defaultTextAutosizingUsesIdempotentMode()
 {
-    return !currentUserInterfaceIdiomIsPhoneOrWatch();
+    return !currentUserInterfaceIdiomIsSmallScreen();
 }
 
 #endif
@@ -65,17 +65,12 @@
 #endif
 
 #if ENABLE(MEDIA_SOURCE)
+
 bool defaultMediaSourceEnabled()
 {
-#if PLATFORM(MACCATALYST)
-    return true;
-#elif PLATFORM(IOS)
-    return WebCore::deviceClass() != MGDeviceClassiPhone
-        && WebCore::deviceClass() != MGDeviceClassiPod;
-#else
-    return false;
-#endif
+    return !WebCore::deviceClassIsSmallScreen();
 }
+
 #endif
 
 } // namespace WebKit

Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewConfiguration.mm (283720 => 283721)


--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewConfiguration.mm	2021-10-07 17:46:34 UTC (rev 283720)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewConfiguration.mm	2021-10-07 17:58:38 UTC (rev 283721)
@@ -52,7 +52,6 @@
 
 #if PLATFORM(IOS_FAMILY)
 #import "UIKitSPI.h"
-#import <WebCore/Device.h>
 #endif
 
 template<typename T> class LazyInitialized {
@@ -197,7 +196,7 @@
     _allowsPictureInPictureMediaPlayback = YES;
 #endif
 
-    _allowsInlineMediaPlayback = !WebKit::currentUserInterfaceIdiomIsPhoneOrWatch();
+    _allowsInlineMediaPlayback = !WebKit::currentUserInterfaceIdiomIsSmallScreen();
     _inlineMediaPlaybackRequiresPlaysInlineAttribute = !_allowsInlineMediaPlayback;
     _allowsInlineMediaPlaybackAfterFullscreen = !_allowsInlineMediaPlayback;
     _mediaDataLoadsAutomatically = _allowsInlineMediaPlayback;

Modified: trunk/Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm (283720 => 283721)


--- trunk/Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm	2021-10-07 17:46:34 UTC (rev 283720)
+++ trunk/Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm	2021-10-07 17:58:38 UTC (rev 283721)
@@ -477,7 +477,7 @@
     }
 
 #if PLATFORM(IOS_FAMILY)
-    parameters.currentUserInterfaceIdiomIsPhoneOrWatch = currentUserInterfaceIdiomIsPhoneOrWatch();
+    parameters.currentUserInterfaceIdiomIsSmallScreen = currentUserInterfaceIdiomIsSmallScreen();
     parameters.supportsPictureInPicture = supportsPictureInPicture();
     parameters.cssValueToSystemColorMap = RenderThemeIOS::cssValueToSystemColorMap();
     parameters.focusRingColor = RenderThemeIOS::systemFocusRingColor();
@@ -803,10 +803,8 @@
 #endif
     if (![UIApplication sharedApplication]) {
         m_applicationLaunchObserver = [[NSNotificationCenter defaultCenter] addObserverForName:UIApplicationDidFinishLaunchingNotification object:nil queue:[NSOperationQueue currentQueue] usingBlock:^(NSNotification *notification) {
-            if (WebKit::updateCurrentUserInterfaceIdiom()) {
-                auto isPhoneOrWatch = WebKit::currentUserInterfaceIdiomIsPhoneOrWatch();
-                sendToAllProcesses(Messages::WebProcess::UserInterfaceIdiomDidChange(isPhoneOrWatch));
-            }
+            if (WebKit::updateCurrentUserInterfaceIdiom())
+                sendToAllProcesses(Messages::WebProcess::UserInterfaceIdiomDidChange(WebKit::currentUserInterfaceIdiomIsSmallScreen()));
         }];
     }
 #endif

Modified: trunk/Source/WebKit/UIProcess/ios/SmartMagnificationController.mm (283720 => 283721)


--- trunk/Source/WebKit/UIProcess/ios/SmartMagnificationController.mm	2021-10-07 17:46:34 UTC (rev 283720)
+++ trunk/Source/WebKit/UIProcess/ios/SmartMagnificationController.mm	2021-10-07 17:58:38 UTC (rev 283721)
@@ -119,7 +119,7 @@
     float minimumScrollDistance;
     if ([m_contentView bounds].size.width <= m_webPageProxy.unobscuredContentRect().width())
         minimumScrollDistance = smartMagnificationPanScrollThresholdZoomedOut;
-    else if (currentUserInterfaceIdiomIsPhoneOrWatch())
+    else if (currentUserInterfaceIdiomIsSmallScreen())
         minimumScrollDistance = smartMagnificationPanScrollThresholdIPhone;
     else
         minimumScrollDistance = smartMagnificationPanScrollThresholdIPad;

Modified: trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm (283720 => 283721)


--- trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm	2021-10-07 17:46:34 UTC (rev 283720)
+++ trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm	2021-10-07 17:58:38 UTC (rev 283721)
@@ -476,7 +476,7 @@
         [[_contentView formAccessoryView] showAutoFillButtonWithTitle:title];
     else
         [[_contentView formAccessoryView] hideAutoFillButton];
-    if (!WebKit::currentUserInterfaceIdiomIsPhoneOrWatch())
+    if (!WebKit::currentUserInterfaceIdiomIsSmallScreen())
         [_contentView reloadInputViews];
 }
 
@@ -1582,7 +1582,7 @@
                 if (_focusRequiresStrongPasswordAssistance)
                     return true;
 
-                if (WebKit::currentUserInterfaceIdiomIsPhoneOrWatch())
+                if (WebKit::currentUserInterfaceIdiomIsSmallScreen())
                     return true;
             }
 
@@ -2257,7 +2257,7 @@
         if (self._shouldUseContextMenusForFormControls)
             return NO;
 #endif
-        return WebKit::currentUserInterfaceIdiomIsPhoneOrWatch();
+        return WebKit::currentUserInterfaceIdiomIsSmallScreen();
     }
     default:
         return YES;
@@ -2312,7 +2312,7 @@
         fontSize:_focusedElementInformation.nodeFontSize
         minimumScale:_focusedElementInformation.minimumScaleFactor
         maximumScale:_focusedElementInformation.maximumScaleFactorIgnoringAlwaysScalable
-        allowScaling:_focusedElementInformation.allowsUserScalingIgnoringAlwaysScalable && WebKit::currentUserInterfaceIdiomIsPhoneOrWatch()
+        allowScaling:_focusedElementInformation.allowsUserScalingIgnoringAlwaysScalable && WebKit::currentUserInterfaceIdiomIsSmallScreen()
         forceScroll:[self requiresAccessoryView]];
 }
 
@@ -3336,7 +3336,7 @@
         if (self._shouldUseContextMenusForFormControls)
             return NO;
 #endif
-        return WebKit::currentUserInterfaceIdiomIsPhoneOrWatch();
+        return WebKit::currentUserInterfaceIdiomIsSmallScreen();
     }
     case WebKit::InputType::Text:
     case WebKit::InputType::Password:
@@ -3349,7 +3349,7 @@
     case WebKit::InputType::ContentEditable:
     case WebKit::InputType::TextArea:
     case WebKit::InputType::Week:
-        return WebKit::currentUserInterfaceIdiomIsPhoneOrWatch();
+        return WebKit::currentUserInterfaceIdiomIsSmallScreen();
     }
 }
 
@@ -4886,7 +4886,7 @@
     [accessoryView setNextEnabled:_focusedElementInformation.hasNextNode];
     [accessoryView setPreviousEnabled:_focusedElementInformation.hasPreviousNode];
 
-    if (!WebKit::currentUserInterfaceIdiomIsPhoneOrWatch()) {
+    if (!WebKit::currentUserInterfaceIdiomIsSmallScreen()) {
         [accessoryView setClearVisible:NO];
         return;
     }
@@ -7718,7 +7718,7 @@
 
 - (BOOL)_shouldUseLegacySelectPopoverDismissalBehavior
 {
-    if (WebKit::currentUserInterfaceIdiomIsPhoneOrWatch())
+    if (WebKit::currentUserInterfaceIdiomIsSmallScreen())
         return NO;
 
     if (_focusedElementInformation.elementType != WebKit::InputType::Select)

Modified: trunk/Source/WebKit/UIProcess/ios/WebDataListSuggestionsDropdownIOS.mm (283720 => 283721)


--- trunk/Source/WebKit/UIProcess/ios/WebDataListSuggestionsDropdownIOS.mm	2021-10-07 17:46:34 UTC (rev 283720)
+++ trunk/Source/WebKit/UIProcess/ios/WebDataListSuggestionsDropdownIOS.mm	2021-10-07 17:58:38 UTC (rev 283721)
@@ -116,7 +116,7 @@
     }
 #endif
 
-    if (currentUserInterfaceIdiomIsPhoneOrWatch())
+    if (currentUserInterfaceIdiomIsSmallScreen())
         m_suggestionsControl = adoptNS([[WKDataListSuggestionsPicker alloc] initWithInformation:WTFMove(information) inView:m_contentView]);
     else
         m_suggestionsControl = adoptNS([[WKDataListSuggestionsPopover alloc] initWithInformation:WTFMove(information) inView:m_contentView]);

Modified: trunk/Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm (283720 => 283721)


--- trunk/Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm	2021-10-07 17:46:34 UTC (rev 283720)
+++ trunk/Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm	2021-10-07 17:58:38 UTC (rev 283721)
@@ -1258,7 +1258,7 @@
     static bool supportsDesktopClassBrowsing = false;
     static dispatch_once_t onceToken;
     dispatch_once(&onceToken, ^{
-        supportsDesktopClassBrowsing = !currentUserInterfaceIdiomIsPhoneOrWatch();
+        supportsDesktopClassBrowsing = !currentUserInterfaceIdiomIsSmallScreen();
     });
     return supportsDesktopClassBrowsing;
 }

Modified: trunk/Source/WebKit/UIProcess/ios/forms/WKAirPlayRoutePicker.mm (283720 => 283721)


--- trunk/Source/WebKit/UIProcess/ios/forms/WKAirPlayRoutePicker.mm	2021-10-07 17:46:34 UTC (rev 283720)
+++ trunk/Source/WebKit/UIProcess/ios/forms/WKAirPlayRoutePicker.mm	2021-10-07 17:58:38 UTC (rev 283721)
@@ -152,7 +152,7 @@
     [_routingController setDiscoveryMode:MPRouteDiscoveryModeDetailed];
 
     MPAVItemType itemType = hasVideo ? MPAVItemTypeVideo : MPAVItemTypeAudio;
-    if (WebKit::currentUserInterfaceIdiomIsPhoneOrWatch())
+    if (WebKit::currentUserInterfaceIdiomIsSmallScreen())
         [self showAirPlayPickerIPhone:itemType];
     else
         [self showAirPlayPickerIPad:itemType fromRect:elementRect];

Modified: trunk/Source/WebKit/UIProcess/ios/forms/WKFileUploadPanel.mm (283720 => 283721)


--- trunk/Source/WebKit/UIProcess/ios/forms/WKFileUploadPanel.mm	2021-10-07 17:46:34 UTC (rev 283720)
+++ trunk/Source/WebKit/UIProcess/ios/forms/WKFileUploadPanel.mm	2021-10-07 17:58:38 UTC (rev 283721)
@@ -785,7 +785,7 @@
 
     // Use a popover on the iPad if the source type is not the camera.
     // The camera will use a fullscreen, modal view controller.
-    BOOL usePopover = !currentUserInterfaceIdiomIsPhoneOrWatch() && sourceType != UIImagePickerControllerSourceTypeCamera;
+    BOOL usePopover = !currentUserInterfaceIdiomIsSmallScreen() && sourceType != UIImagePickerControllerSourceTypeCamera;
     if (usePopover)
         [self _presentPopoverWithContentViewController:_imagePicker.get() animated:YES];
     else
@@ -796,7 +796,7 @@
 
 - (void)_presentMenuOptionForCurrentInterfaceIdiom:(UIViewController *)viewController
 {
-    if (currentUserInterfaceIdiomIsPhoneOrWatch())
+    if (currentUserInterfaceIdiomIsSmallScreen())
         [self _presentFullscreenViewController:viewController animated:YES];
     else
         [self _presentPopoverWithContentViewController:viewController animated:YES];

Modified: trunk/Source/WebKit/UIProcess/ios/forms/WKFormSelectControl.mm (283720 => 283721)


--- trunk/Source/WebKit/UIProcess/ios/forms/WKFormSelectControl.mm	2021-10-07 17:46:34 UTC (rev 283720)
+++ trunk/Source/WebKit/UIProcess/ios/forms/WKFormSelectControl.mm	2021-10-07 17:58:38 UTC (rev 283721)
@@ -85,7 +85,7 @@
     }
 #endif
 
-    if (!currentUserInterfaceIdiomIsPhoneOrWatch())
+    if (!currentUserInterfaceIdiomIsSmallScreen())
         control = adoptNS([[WKSelectPopover alloc] initWithView:view hasGroups:hasGroups]);
     else if (view.focusedElementInformation.isMultiSelect || hasGroups)
         control = adoptNS([[WKMultipleSelectPicker alloc] initWithView:view]);

Modified: trunk/Source/WebKit/UIProcess/ios/forms/WKFormSelectPicker.mm (283720 => 283721)


--- trunk/Source/WebKit/UIProcess/ios/forms/WKFormSelectPicker.mm	2021-10-07 17:46:34 UTC (rev 283720)
+++ trunk/Source/WebKit/UIProcess/ios/forms/WKFormSelectPicker.mm	2021-10-07 17:58:38 UTC (rev 283721)
@@ -1176,7 +1176,7 @@
 
 - (void)configurePresentation
 {
-    if (WebKit::currentUserInterfaceIdiomIsPhoneOrWatch()) {
+    if (WebKit::currentUserInterfaceIdiomIsSmallScreen()) {
         [[_navigationController navigationBar] setBarTintColor:UIColor.systemGroupedBackgroundColor];
 
         UIPresentationController *presentationController = [_navigationController presentationController];

Modified: trunk/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm (283720 => 283721)


--- trunk/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm	2021-10-07 17:46:34 UTC (rev 283720)
+++ trunk/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm	2021-10-07 17:58:38 UTC (rev 283721)
@@ -313,7 +313,7 @@
     setEnhancedAccessibility(parameters.accessibilityEnhancedUserInterfaceEnabled);
 
 #if PLATFORM(IOS_FAMILY)
-    setCurrentUserInterfaceIdiomIsPhoneOrWatch(parameters.currentUserInterfaceIdiomIsPhoneOrWatch);
+    setCurrentUserInterfaceIdiomIsSmallScreen(parameters.currentUserInterfaceIdiomIsSmallScreen);
     setLocalizedDeviceModel(parameters.localizedDeviceModel);
     RenderThemeIOS::setContentSizeCategory(parameters.contentSizeCategory);
 #if ENABLE(VIDEO_PRESENTATION_MODE)
@@ -930,9 +930,10 @@
 }
 
 #if PLATFORM(IOS_FAMILY)
-void WebProcess::userInterfaceIdiomDidChange(bool isPhoneOrWatch)
+
+void WebProcess::userInterfaceIdiomDidChange(bool isSmallScreen)
 {
-    WebKit::setCurrentUserInterfaceIdiomIsPhoneOrWatch(isPhoneOrWatch);
+    WebKit::setCurrentUserInterfaceIdiomIsSmallScreen(isSmallScreen);
 }
 
 bool WebProcess::shouldFreezeOnSuspension() const
@@ -965,6 +966,7 @@
     else
         WEBPROCESS_RELEASE_LOG(ProcessSuspension, "updateFreezerStatus: isFreezable=%d, success", isFreezable);
 }
+
 #endif
 
 #if PLATFORM(MAC)

Modified: trunk/Source/WebKitLegacy/mac/ChangeLog (283720 => 283721)


--- trunk/Source/WebKitLegacy/mac/ChangeLog	2021-10-07 17:46:34 UTC (rev 283720)
+++ trunk/Source/WebKitLegacy/mac/ChangeLog	2021-10-07 17:58:38 UTC (rev 283721)
@@ -1,3 +1,21 @@
+2021-10-07  Darin Adler  <da...@apple.com>
+
+        Get rid of the deviceClass function, up-leveling to deviceClassIsSmallScreen
+        https://bugs.webkit.org/show_bug.cgi?id=231344
+
+        Reviewed by Tim Horton.
+
+        * WebView/WebPreferences.mm: Removed uneeded Device.h include.
+
+        * WebView/WebPreferencesDefaultValues.mm:
+        (WebKit::defaultAllowsInlineMediaPlayback): Use !deviceClassIsSmallScreen
+        instead of deviceClass == iPad.
+        (WebKit::defaultAllowsInlineMediaPlaybackAfterFullscreen): Use
+        deviceClassIsSmallScreen instead of deviceClass != iPad.
+        (WebKit::defaultInlineMediaPlaybackRequiresPlaysInlineAttribute): Ditto.
+        (WebKit::defaultMediaSourceEnabled): Use !deviceClassIsSmallScreen instead of
+        deviceClass != iPhone and != iPod, and also remove unneeded compile time conditionals.
+
 2021-10-05  Tim Horton  <timothy_hor...@apple.com>
 
         <model> should be draggable, similar to <img>

Modified: trunk/Source/WebKitLegacy/mac/WebView/WebPreferences.mm (283720 => 283721)


--- trunk/Source/WebKitLegacy/mac/WebView/WebPreferences.mm	2021-10-07 17:46:34 UTC (rev 283720)
+++ trunk/Source/WebKitLegacy/mac/WebView/WebPreferences.mm	2021-10-07 17:58:38 UTC (rev 283721)
@@ -62,7 +62,6 @@
 using namespace WebCore;
 
 #if PLATFORM(IOS_FAMILY)
-#import <WebCore/Device.h>
 #import <WebCore/GraphicsContext.h>
 #import <WebCore/WebCoreThreadMessage.h>
 #endif

Modified: trunk/Source/WebKitLegacy/mac/WebView/WebPreferencesDefaultValues.mm (283720 => 283721)


--- trunk/Source/WebKitLegacy/mac/WebView/WebPreferencesDefaultValues.mm	2021-10-07 17:46:34 UTC (rev 283720)
+++ trunk/Source/WebKitLegacy/mac/WebView/WebPreferencesDefaultValues.mm	2021-10-07 17:58:38 UTC (rev 283721)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2020 Apple Inc. All rights reserved.
+ * Copyright (C) 2020-2021 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -93,12 +93,12 @@
 
 bool defaultAllowsInlineMediaPlayback()
 {
-    return WebCore::deviceClass() == MGDeviceClassiPad;
+    return !WebCore::deviceClassIsSmallScreen();
 }
 
 bool defaultAllowsInlineMediaPlaybackAfterFullscreen()
 {
-    return WebCore::deviceClass() != MGDeviceClassiPad;
+    return WebCore::deviceClassIsSmallScreen();
 }
 
 bool defaultAllowsPictureInPictureMediaPlayback()
@@ -115,7 +115,7 @@
 
 bool defaultInlineMediaPlaybackRequiresPlaysInlineAttribute()
 {
-    return WebCore::deviceClass() != MGDeviceClassiPad;
+    return WebCore::deviceClassIsSmallScreen();
 }
 
 bool defaultPassiveTouchListenersAsDefaultOnDocument()
@@ -272,26 +272,23 @@
 #endif
 
 #if ENABLE(MEDIA_SOURCE) && PLATFORM(IOS_FAMILY)
+
 bool defaultMediaSourceEnabled()
 {
-#if PLATFORM(MACCATALYST)
-    return true;
-#elif PLATFORM(IOS)
-    return WebCore::deviceClass() != MGDeviceClassiPhone
-        && WebCore::deviceClass() != MGDeviceClassiPod;
-#else
-    return false;
-#endif
+    return !WebCore::deviceClassIsSmallScreen();
 }
+
 #endif
 
 #if ENABLE(MEDIA_SOURCE)
+
 bool defaultWebMParserEnabled()
 {
     return isFeatureFlagEnabled("webm_parser", true);
 }
-#endif // ENABLE(MEDIA_SOURCE)
 
+#endif
+
 #if ENABLE(VP9)
 
 bool defaultVP8DecoderEnabled()
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to