Title: [271497] trunk/Source
- Revision
- 271497
- Author
- [email protected]
- Date
- 2021-01-14 12:56:00 -0800 (Thu, 14 Jan 2021)
Log Message
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.
Modified Paths
Diff
Modified: trunk/Source/WebCore/PAL/ChangeLog (271496 => 271497)
--- trunk/Source/WebCore/PAL/ChangeLog 2021-01-14 20:54:26 UTC (rev 271496)
+++ trunk/Source/WebCore/PAL/ChangeLog 2021-01-14 20:56:00 UTC (rev 271497)
@@ -1,3 +1,13 @@
+2021-01-14 Tim Horton <[email protected]>
+
+ 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-12 Per Arne Vollan <[email protected]>
[macOS] Reset user directory suffix before getting sandbox directory
Modified: trunk/Source/WebCore/PAL/pal/spi/ios/MobileGestaltSPI.h (271496 => 271497)
--- trunk/Source/WebCore/PAL/pal/spi/ios/MobileGestaltSPI.h 2021-01-14 20:54:26 UTC (rev 271496)
+++ trunk/Source/WebCore/PAL/pal/spi/ios/MobileGestaltSPI.h 2021-01-14 20:56:00 UTC (rev 271497)
@@ -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: trunk/Source/WebKit/ChangeLog (271496 => 271497)
--- trunk/Source/WebKit/ChangeLog 2021-01-14 20:54:26 UTC (rev 271496)
+++ trunk/Source/WebKit/ChangeLog 2021-01-14 20:56:00 UTC (rev 271497)
@@ -1,3 +1,35 @@
+2021-01-14 Tim Horton <[email protected]>
+
+ 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-14 Chris Dumez <[email protected]>
[Hardening] Protect against overflows in calculateBytesPerRow()
Modified: trunk/Source/WebKit/Shared/UserInterfaceIdiom.mm (271496 => 271497)
--- trunk/Source/WebKit/Shared/UserInterfaceIdiom.mm 2021-01-14 20:54:26 UTC (rev 271496)
+++ trunk/Source/WebKit/Shared/UserInterfaceIdiom.mm 2021-01-14 20:56:00 UTC (rev 271497)
@@ -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
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes