Title: [271826] branches/safari-611-branch/Source
Revision
271826
Author
alanc...@apple.com
Date
2021-01-25 14:11:21 -0800 (Mon, 25 Jan 2021)

Log Message

Cherry-pick r271497. rdar://problem/73469623

    Exceptions thrown when invoking a <select> on an iPhone-idiom app running on macOS
    https://bugs.webkit.org/show_bug.cgi?id=220628
    <rdar://problem/70546547>

    Reviewed by Wenson Hsieh.
    Source/WebCore/PAL:

    * pal/spi/ios/MobileGestaltSPI.h:

    Source/WebKit:

    iPhone-idiom apps running on macOS need to behave exactly like iPhone apps,
    even in ways that might not totally make sense on the platform (e.g.
    using input accessory views for <select> instead of popover) for two reasons:

    - we want to maximize compatibility, so they should behave exactly as they do
    on the only platform they're tested on

    - other frameworks (mostly UIKit) enforce the use of iPhone UI in iPhone-idiom
    apps, even on macOS

    * Shared/UserInterfaceIdiom.mm:
    (WebKit::currentUserInterfaceIdiomIsPadOrMac):
    (WebKit::setCurrentUserInterfaceIdiomIsPadOrMac):
    (WebKit::updateCurrentUserInterfaceIdiom):
    (WebKit::userInterfaceIdiomIsPad): Deleted.
    Simplify our UIUserInterfaceIdiom-caching code.

    currentUserInterfaceIdiomIsPadOrMac now does what it says on the tin, globally;
    previously on macOS it said YES for iPhone-idiom apps, but now it says NO,
    like you would expect.

    Use UIDevice everywhere instead of the soft-deprecated UICurrentUserInterfaceIdiomIsPad,
    both because it is soft-deprecated, and because it lets us elide the static helper.

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

Modified Paths

Diff

Modified: branches/safari-611-branch/Source/WebCore/PAL/ChangeLog (271825 => 271826)


--- branches/safari-611-branch/Source/WebCore/PAL/ChangeLog	2021-01-25 22:11:17 UTC (rev 271825)
+++ branches/safari-611-branch/Source/WebCore/PAL/ChangeLog	2021-01-25 22:11:21 UTC (rev 271826)
@@ -1,5 +1,57 @@
 2021-01-25  Alan Coon  <alanc...@apple.com>
 
+        Cherry-pick r271497. rdar://problem/73469623
+
+    Exceptions thrown when invoking a <select> on an iPhone-idiom app running on macOS
+    https://bugs.webkit.org/show_bug.cgi?id=220628
+    <rdar://problem/70546547>
+    
+    Reviewed by Wenson Hsieh.
+    Source/WebCore/PAL:
+    
+    * pal/spi/ios/MobileGestaltSPI.h:
+    
+    Source/WebKit:
+    
+    iPhone-idiom apps running on macOS need to behave exactly like iPhone apps,
+    even in ways that might not totally make sense on the platform (e.g.
+    using input accessory views for <select> instead of popover) for two reasons:
+    
+    - we want to maximize compatibility, so they should behave exactly as they do
+    on the only platform they're tested on
+    
+    - other frameworks (mostly UIKit) enforce the use of iPhone UI in iPhone-idiom
+    apps, even on macOS
+    
+    * Shared/UserInterfaceIdiom.mm:
+    (WebKit::currentUserInterfaceIdiomIsPadOrMac):
+    (WebKit::setCurrentUserInterfaceIdiomIsPadOrMac):
+    (WebKit::updateCurrentUserInterfaceIdiom):
+    (WebKit::userInterfaceIdiomIsPad): Deleted.
+    Simplify our UIUserInterfaceIdiom-caching code.
+    
+    currentUserInterfaceIdiomIsPadOrMac now does what it says on the tin, globally;
+    previously on macOS it said YES for iPhone-idiom apps, but now it says NO,
+    like you would expect.
+    
+    Use UIDevice everywhere instead of the soft-deprecated UICurrentUserInterfaceIdiomIsPad,
+    both because it is soft-deprecated, and because it lets us elide the static helper.
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@271497 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2021-01-14  Tim Horton  <timothy_hor...@apple.com>
+
+            Exceptions thrown when invoking a <select> on an iPhone-idiom app running on macOS
+            https://bugs.webkit.org/show_bug.cgi?id=220628
+            <rdar://problem/70546547>
+
+            Reviewed by Wenson Hsieh.
+
+            * pal/spi/ios/MobileGestaltSPI.h:
+
+2021-01-25  Alan Coon  <alanc...@apple.com>
+
         Cherry-pick r271405. rdar://problem/73466993
 
     [Cocoa] Support key rotation with HLS-backed encrypted media streams

Modified: branches/safari-611-branch/Source/WebCore/PAL/pal/spi/ios/MobileGestaltSPI.h (271825 => 271826)


--- branches/safari-611-branch/Source/WebCore/PAL/pal/spi/ios/MobileGestaltSPI.h	2021-01-25 22:11:17 UTC (rev 271825)
+++ branches/safari-611-branch/Source/WebCore/PAL/pal/spi/ios/MobileGestaltSPI.h	2021-01-25 22:11:21 UTC (rev 271826)
@@ -57,13 +57,12 @@
 
 typedef enum {
     MGDeviceClassInvalid = -1,
-    /* 0 is intentionally not in this enum */
     MGDeviceClassiPhone  = 1,
     MGDeviceClassiPod    = 2,
     MGDeviceClassiPad    = 3,
     MGDeviceClassAppleTV = 4,
-    /* 5 is intentionally not in this enum */
     MGDeviceClassWatch   = 6,
+    MGDeviceClassMac     = 9,
 } MGDeviceClass;
 
 typedef enum {

Modified: branches/safari-611-branch/Source/WebKit/ChangeLog (271825 => 271826)


--- branches/safari-611-branch/Source/WebKit/ChangeLog	2021-01-25 22:11:17 UTC (rev 271825)
+++ branches/safari-611-branch/Source/WebKit/ChangeLog	2021-01-25 22:11:21 UTC (rev 271826)
@@ -1,5 +1,79 @@
 2021-01-25  Alan Coon  <alanc...@apple.com>
 
+        Cherry-pick r271497. rdar://problem/73469623
+
+    Exceptions thrown when invoking a <select> on an iPhone-idiom app running on macOS
+    https://bugs.webkit.org/show_bug.cgi?id=220628
+    <rdar://problem/70546547>
+    
+    Reviewed by Wenson Hsieh.
+    Source/WebCore/PAL:
+    
+    * pal/spi/ios/MobileGestaltSPI.h:
+    
+    Source/WebKit:
+    
+    iPhone-idiom apps running on macOS need to behave exactly like iPhone apps,
+    even in ways that might not totally make sense on the platform (e.g.
+    using input accessory views for <select> instead of popover) for two reasons:
+    
+    - we want to maximize compatibility, so they should behave exactly as they do
+    on the only platform they're tested on
+    
+    - other frameworks (mostly UIKit) enforce the use of iPhone UI in iPhone-idiom
+    apps, even on macOS
+    
+    * Shared/UserInterfaceIdiom.mm:
+    (WebKit::currentUserInterfaceIdiomIsPadOrMac):
+    (WebKit::setCurrentUserInterfaceIdiomIsPadOrMac):
+    (WebKit::updateCurrentUserInterfaceIdiom):
+    (WebKit::userInterfaceIdiomIsPad): Deleted.
+    Simplify our UIUserInterfaceIdiom-caching code.
+    
+    currentUserInterfaceIdiomIsPadOrMac now does what it says on the tin, globally;
+    previously on macOS it said YES for iPhone-idiom apps, but now it says NO,
+    like you would expect.
+    
+    Use UIDevice everywhere instead of the soft-deprecated UICurrentUserInterfaceIdiomIsPad,
+    both because it is soft-deprecated, and because it lets us elide the static helper.
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@271497 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2021-01-14  Tim Horton  <timothy_hor...@apple.com>
+
+            Exceptions thrown when invoking a <select> on an iPhone-idiom app running on macOS
+            https://bugs.webkit.org/show_bug.cgi?id=220628
+            <rdar://problem/70546547>
+
+            Reviewed by Wenson Hsieh.
+
+            iPhone-idiom apps running on macOS need to behave exactly like iPhone apps,
+            even in ways that might not totally make sense on the platform (e.g.
+            using input accessory views for <select> instead of popover) for two reasons:
+
+            - we want to maximize compatibility, so they should behave exactly as they do
+            on the only platform they're tested on
+
+            - other frameworks (mostly UIKit) enforce the use of iPhone UI in iPhone-idiom
+            apps, even on macOS
+
+            * Shared/UserInterfaceIdiom.mm:
+            (WebKit::currentUserInterfaceIdiomIsPadOrMac):
+            (WebKit::setCurrentUserInterfaceIdiomIsPadOrMac):
+            (WebKit::updateCurrentUserInterfaceIdiom):
+            (WebKit::userInterfaceIdiomIsPad): Deleted.
+            Simplify our UIUserInterfaceIdiom-caching code.
+
+            currentUserInterfaceIdiomIsPadOrMac now does what it says on the tin, globally;
+            previously on macOS it said YES for iPhone-idiom apps, but now it says NO,
+            like you would expect.
+
+            Use UIDevice everywhere instead of the soft-deprecated UICurrentUserInterfaceIdiomIsPad,
+            both because it is soft-deprecated, and because it lets us elide the static helper.
+
+2021-01-25  Alan Coon  <alanc...@apple.com>
+
         Cherry-pick r271479. rdar://problem/73469631
 
     REGRESSION (r266634): Messages crashes sometimes while scrolling around and playing YouTube videos

Modified: branches/safari-611-branch/Source/WebKit/Shared/UserInterfaceIdiom.mm (271825 => 271826)


--- branches/safari-611-branch/Source/WebKit/Shared/UserInterfaceIdiom.mm	2021-01-25 22:11:17 UTC (rev 271825)
+++ branches/safari-611-branch/Source/WebKit/Shared/UserInterfaceIdiom.mm	2021-01-25 22:11:21 UTC (rev 271826)
@@ -34,58 +34,48 @@
 namespace WebKit {
 
 enum class UserInterfaceIdiomState : uint8_t {
-    IsPad,
-    IsNotPad,
+    IsPadOrMac,
+    IsNotPadOrMac,
     Unknown,
 };
 
 static UserInterfaceIdiomState userInterfaceIdiomIsPadState = UserInterfaceIdiomState::Unknown;
 
-static inline bool userInterfaceIdiomIsPad()
+bool currentUserInterfaceIdiomIsPadOrMac()
 {
-#if PLATFORM(MACCATALYST)
-    // UIKit varies the UIUserInterfaceIdiom between iPad and macOS in macCatalyst, depending on various settings,
-    // but for the purposes of WebKit we always want to use iPad behavior (vs. iPhone) in macCatalyst.
     // FIXME: We should get rid of this function and have callers make explicit decisions for all of iPhone/iPad/macOS.
-    return true;
-#else
-    // 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])
-        return WebCore::deviceClass() == MGDeviceClassiPad;
 
-    // This inline function exists to thwart unreachable code
-    // detection on platforms where UICurrentUserInterfaceIdiomIsPad
-    // is defined directly to false.
-#if USE(APPLE_INTERNAL_SDK)
-    return UICurrentUserInterfaceIdiomIsPad();
-#else
-    return [[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad;
-#endif
-#endif
-}
-
-bool currentUserInterfaceIdiomIsPadOrMac()
-{
     if (userInterfaceIdiomIsPadState == UserInterfaceIdiomState::Unknown)
-        setCurrentUserInterfaceIdiomIsPadOrMac(userInterfaceIdiomIsPad());
+        updateCurrentUserInterfaceIdiom();
 
-    return userInterfaceIdiomIsPadState == UserInterfaceIdiomState::IsPad;
+    return userInterfaceIdiomIsPadState == UserInterfaceIdiomState::IsPadOrMac;
 }
 
-void setCurrentUserInterfaceIdiomIsPadOrMac(bool isPad)
+void setCurrentUserInterfaceIdiomIsPadOrMac(bool isPadOrMac)
 {
-    userInterfaceIdiomIsPadState = isPad ? UserInterfaceIdiomState::IsPad : UserInterfaceIdiomState::IsNotPad;
+    userInterfaceIdiomIsPadState = isPadOrMac ? UserInterfaceIdiomState::IsPadOrMac : UserInterfaceIdiomState::IsNotPadOrMac;
 }
 
 bool updateCurrentUserInterfaceIdiom()
 {
-    bool isPad = userInterfaceIdiomIsPad();
-    if (currentUserInterfaceIdiomIsPadOrMac() == isPad)
+    bool wasPadOrMac = userInterfaceIdiomIsPadState == UserInterfaceIdiomState::IsPadOrMac;
+    bool isPadOrMac = false;
+
+    // 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();
+        isPadOrMac = deviceClass == MGDeviceClassiPad || deviceClass == MGDeviceClassMac;
+    } else {
+        auto idiom = [[UIDevice currentDevice] userInterfaceIdiom];
+        isPadOrMac = idiom == UIUserInterfaceIdiomPad || idiom == UIUserInterfaceIdiomMac;
+    }
+
+    if (wasPadOrMac == isPadOrMac)
         return false;
 
-    setCurrentUserInterfaceIdiomIsPadOrMac(isPad);
+    setCurrentUserInterfaceIdiomIsPadOrMac(isPadOrMac);
     return true;
 }
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to