Title: [219177] trunk/Source/WebCore
Revision
219177
Author
cdu...@apple.com
Date
2017-07-05 19:01:30 -0700 (Wed, 05 Jul 2017)

Log Message

[iOS] User agent string incorrectly says "iPhone" instead of "iPad" on newer iPads
https://bugs.webkit.org/show_bug.cgi?id=174182
<rdar://problem/32868369>

Reviewed by Tim Horton.

In deviceNameForUserAgent() on iOS, we were forcefully returning "iPhone" if
[UIApplication _isClassic] returns true. Update check to return "iPad" if
[UIApplication _isClassic] returns true but [UIApplication _classMode] returns
UIApplicationSceneClassicModeOriginalPad.

* page/ios/UserAgentIOS.mm:
(WebCore::isClassicPad):
(WebCore::isClassicPhone):
(WebCore::osNameForUserAgent):
(WebCore::deviceNameForUserAgent):
* platform/spi/ios/UIKitSPI.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (219176 => 219177)


--- trunk/Source/WebCore/ChangeLog	2017-07-06 01:57:43 UTC (rev 219176)
+++ trunk/Source/WebCore/ChangeLog	2017-07-06 02:01:30 UTC (rev 219177)
@@ -1,3 +1,23 @@
+2017-07-05  Chris Dumez  <cdu...@apple.com>
+
+        [iOS] User agent string incorrectly says "iPhone" instead of "iPad" on newer iPads
+        https://bugs.webkit.org/show_bug.cgi?id=174182
+        <rdar://problem/32868369>
+
+        Reviewed by Tim Horton.
+
+        In deviceNameForUserAgent() on iOS, we were forcefully returning "iPhone" if
+        [UIApplication _isClassic] returns true. Update check to return "iPad" if
+        [UIApplication _isClassic] returns true but [UIApplication _classMode] returns
+        UIApplicationSceneClassicModeOriginalPad.
+
+        * page/ios/UserAgentIOS.mm:
+        (WebCore::isClassicPad):
+        (WebCore::isClassicPhone):
+        (WebCore::osNameForUserAgent):
+        (WebCore::deviceNameForUserAgent):
+        * platform/spi/ios/UIKitSPI.h:
+
 2017-07-05  Yusuke Suzuki  <utatane....@gmail.com>
 
         WTF::Thread should have the threads stack bounds.

Modified: trunk/Source/WebCore/page/ios/UserAgentIOS.mm (219176 => 219177)


--- trunk/Source/WebCore/page/ios/UserAgentIOS.mm	2017-07-06 01:57:43 UTC (rev 219176)
+++ trunk/Source/WebCore/page/ios/UserAgentIOS.mm	2017-07-06 02:01:30 UTC (rev 219177)
@@ -44,9 +44,19 @@
     return [[getUIApplicationClass() sharedApplication] _isClassic];
 }
 
+static inline bool isClassicPad()
+{
+    return [getUIApplicationClass() _classicMode] == UIApplicationSceneClassicModeOriginalPad;
+}
+
+static inline bool isClassicPhone()
+{
+    return isClassic() && [getUIApplicationClass() _classicMode] != UIApplicationSceneClassicModeOriginalPad;
+}
+
 static inline NSString *osNameForUserAgent()
 {
-    if (deviceHasIPadCapability() && !isClassic())
+    if (deviceHasIPadCapability() && !isClassicPhone())
         return @"OS";
     return @"iPhone OS";
 }
@@ -53,9 +63,12 @@
 
 static inline NSString *deviceNameForUserAgent()
 {
-    if (isClassic())
+    if (isClassic()) {
+        if (isClassicPad())
+            return @"iPad";
         return @"iPhone";
-    
+    }
+
     auto name = retainPtr((NSString *)deviceName());
 #if PLATFORM(IOS_SIMULATOR)
     NSUInteger location = [name rangeOfString:@" Simulator" options:NSBackwardsSearch].location;

Modified: trunk/Source/WebCore/platform/spi/ios/UIKitSPI.h (219176 => 219177)


--- trunk/Source/WebCore/platform/spi/ios/UIKitSPI.h	2017-07-06 01:57:43 UTC (rev 219176)
+++ trunk/Source/WebCore/platform/spi/ios/UIKitSPI.h	2017-07-06 02:01:30 UTC (rev 219177)
@@ -38,9 +38,14 @@
 
 #import <UIKit/UIKit.h>
 
+typedef NS_ENUM(NSInteger, UIApplicationSceneClassicMode) {
+    UIApplicationSceneClassicModeOriginalPad = 4,
+};
+
 @interface UIApplication ()
 
 - (BOOL)_isClassic;
++ (UIApplicationSceneClassicMode)_classicMode;
 
 @end
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to