Title: [267273] branches/safari-610-branch/Source
Revision
267273
Author
[email protected]
Date
2020-09-18 12:36:31 -0700 (Fri, 18 Sep 2020)

Log Message

Cherry-pick r266802. rdar://problem/69101097

    Text copied and pasted from Mac Catalyst apps appears larger than expected
    https://bugs.webkit.org/show_bug.cgi?id=215971
    <rdar://problem/65768907>

    Reviewed by Tim Horton.

    Source/WebKit:

    Various pieces of platform logic in Mac Catalyst depend on the user interface idiom (i.e. Mac or iPad) of the
    app, as well as the application-wide "scale factor". In the context of this bug, NSAttributedString to RTF data
    conversion methods in `UIFoundation` consult the scale factor of `UIiOSMacIdiomManager` to determine whether to
    emit 0 (standard) or 1 (iOS) for the `\cocoatextscaling` attribute. The fact that the web process' scale factor
    may be out of sync with the UI process' scale factor leads to copied RTF data in the web process appearing
    either larger or smaller than expected, due to an incorrect `NSTextScalingType` value.

    To mitigate this (as well as any other issues), we add a mechanism for the UI process to forward the global
    scale factor and user interface idiom to the web process inside of the web process creation parameters, and then
    use new UIKit SPI to override the scale factor and idiom within the web process.

    * Scripts/process-entitlements.sh:

    Add a new entitlement needed to use `_UIApplicationCatalystRequestViewServiceIdiomAndScaleFactor`.

    * Shared/WebProcessCreationParameters.cpp:
    (WebKit::WebProcessCreationParameters::encode const):
    (WebKit::WebProcessCreationParameters::decode):
    * Shared/WebProcessCreationParameters.h:
    * UIProcess/Cocoa/WebProcessPoolCocoa.mm:
    (WebKit::WebProcessPool::platformInitializeWebProcess):

    Use `_UIApplicationCatalystUserInterfaceIdiom` and `_UIApplicationCatalystScaleFactor` to grab the global user
    interface idiom and scale factor, respectively.

    * WebProcess/cocoa/WebProcessCocoa.mm:
    (WebKit::WebProcess::platformInitializeWebProcess):

    Override the idiom and scale factor in the web process with the idiom and scale factor from the UI process,
    using the new SPI `_UIApplicationCatalystRequestViewServiceIdiomAndScaleFactor`. As this function hasn't landed
    yet, we soft link the function for now to avoid causing the web process to instantly crash on any builds without
    the fix for <rdar://problem/68524148>.

    Source/WTF:

    Add a new flag to guard the presence of `_UIApplicationCatalystUserInterfaceIdiom`,
    `_UIApplicationCatalystScaleFactor`, and `_UIApplicationCatalystRequestViewServiceIdiomAndScaleFactor`.

    * wtf/PlatformHave.h:

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

Modified Paths

Diff

Modified: branches/safari-610-branch/Source/WTF/ChangeLog (267272 => 267273)


--- branches/safari-610-branch/Source/WTF/ChangeLog	2020-09-18 19:36:28 UTC (rev 267272)
+++ branches/safari-610-branch/Source/WTF/ChangeLog	2020-09-18 19:36:31 UTC (rev 267273)
@@ -1,5 +1,73 @@
 2020-09-17  Alan Coon  <[email protected]>
 
+        Cherry-pick r266802. rdar://problem/69101097
+
+    Text copied and pasted from Mac Catalyst apps appears larger than expected
+    https://bugs.webkit.org/show_bug.cgi?id=215971
+    <rdar://problem/65768907>
+    
+    Reviewed by Tim Horton.
+    
+    Source/WebKit:
+    
+    Various pieces of platform logic in Mac Catalyst depend on the user interface idiom (i.e. Mac or iPad) of the
+    app, as well as the application-wide "scale factor". In the context of this bug, NSAttributedString to RTF data
+    conversion methods in `UIFoundation` consult the scale factor of `UIiOSMacIdiomManager` to determine whether to
+    emit 0 (standard) or 1 (iOS) for the `\cocoatextscaling` attribute. The fact that the web process' scale factor
+    may be out of sync with the UI process' scale factor leads to copied RTF data in the web process appearing
+    either larger or smaller than expected, due to an incorrect `NSTextScalingType` value.
+    
+    To mitigate this (as well as any other issues), we add a mechanism for the UI process to forward the global
+    scale factor and user interface idiom to the web process inside of the web process creation parameters, and then
+    use new UIKit SPI to override the scale factor and idiom within the web process.
+    
+    * Scripts/process-entitlements.sh:
+    
+    Add a new entitlement needed to use `_UIApplicationCatalystRequestViewServiceIdiomAndScaleFactor`.
+    
+    * Shared/WebProcessCreationParameters.cpp:
+    (WebKit::WebProcessCreationParameters::encode const):
+    (WebKit::WebProcessCreationParameters::decode):
+    * Shared/WebProcessCreationParameters.h:
+    * UIProcess/Cocoa/WebProcessPoolCocoa.mm:
+    (WebKit::WebProcessPool::platformInitializeWebProcess):
+    
+    Use `_UIApplicationCatalystUserInterfaceIdiom` and `_UIApplicationCatalystScaleFactor` to grab the global user
+    interface idiom and scale factor, respectively.
+    
+    * WebProcess/cocoa/WebProcessCocoa.mm:
+    (WebKit::WebProcess::platformInitializeWebProcess):
+    
+    Override the idiom and scale factor in the web process with the idiom and scale factor from the UI process,
+    using the new SPI `_UIApplicationCatalystRequestViewServiceIdiomAndScaleFactor`. As this function hasn't landed
+    yet, we soft link the function for now to avoid causing the web process to instantly crash on any builds without
+    the fix for <rdar://problem/68524148>.
+    
+    Source/WTF:
+    
+    Add a new flag to guard the presence of `_UIApplicationCatalystUserInterfaceIdiom`,
+    `_UIApplicationCatalystScaleFactor`, and `_UIApplicationCatalystRequestViewServiceIdiomAndScaleFactor`.
+    
+    * wtf/PlatformHave.h:
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266802 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2020-09-09  Wenson Hsieh  <[email protected]>
+
+            Text copied and pasted from Mac Catalyst apps appears larger than expected
+            https://bugs.webkit.org/show_bug.cgi?id=215971
+            <rdar://problem/65768907>
+
+            Reviewed by Tim Horton.
+
+            Add a new flag to guard the presence of `_UIApplicationCatalystUserInterfaceIdiom`,
+            `_UIApplicationCatalystScaleFactor`, and `_UIApplicationCatalystRequestViewServiceIdiomAndScaleFactor`.
+
+            * wtf/PlatformHave.h:
+
+2020-09-17  Alan Coon  <[email protected]>
+
         Cherry-pick r266827. rdar://problem/69101047
 
     [CG] REGRESSION (Big Sur): A GIF image with a finite loopCount loops an extra cycle

Modified: branches/safari-610-branch/Source/WTF/wtf/PlatformHave.h (267272 => 267273)


--- branches/safari-610-branch/Source/WTF/wtf/PlatformHave.h	2020-09-18 19:36:28 UTC (rev 267272)
+++ branches/safari-610-branch/Source/WTF/wtf/PlatformHave.h	2020-09-18 19:36:31 UTC (rev 267273)
@@ -697,3 +697,7 @@
 #define HAVE_PTHREAD_JIT_PERMISSIONS_API 1
 #define HAVE_WEBP 1
 #endif
+
+#if PLATFORM(MACCATALYST) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 140000
+#define HAVE_CATALYST_USER_INTERFACE_IDIOM_AND_SCALE_FACTOR 1
+#endif

Modified: branches/safari-610-branch/Source/WebKit/ChangeLog (267272 => 267273)


--- branches/safari-610-branch/Source/WebKit/ChangeLog	2020-09-18 19:36:28 UTC (rev 267272)
+++ branches/safari-610-branch/Source/WebKit/ChangeLog	2020-09-18 19:36:31 UTC (rev 267273)
@@ -1,5 +1,101 @@
 2020-09-17  Alan Coon  <[email protected]>
 
+        Cherry-pick r266802. rdar://problem/69101097
+
+    Text copied and pasted from Mac Catalyst apps appears larger than expected
+    https://bugs.webkit.org/show_bug.cgi?id=215971
+    <rdar://problem/65768907>
+    
+    Reviewed by Tim Horton.
+    
+    Source/WebKit:
+    
+    Various pieces of platform logic in Mac Catalyst depend on the user interface idiom (i.e. Mac or iPad) of the
+    app, as well as the application-wide "scale factor". In the context of this bug, NSAttributedString to RTF data
+    conversion methods in `UIFoundation` consult the scale factor of `UIiOSMacIdiomManager` to determine whether to
+    emit 0 (standard) or 1 (iOS) for the `\cocoatextscaling` attribute. The fact that the web process' scale factor
+    may be out of sync with the UI process' scale factor leads to copied RTF data in the web process appearing
+    either larger or smaller than expected, due to an incorrect `NSTextScalingType` value.
+    
+    To mitigate this (as well as any other issues), we add a mechanism for the UI process to forward the global
+    scale factor and user interface idiom to the web process inside of the web process creation parameters, and then
+    use new UIKit SPI to override the scale factor and idiom within the web process.
+    
+    * Scripts/process-entitlements.sh:
+    
+    Add a new entitlement needed to use `_UIApplicationCatalystRequestViewServiceIdiomAndScaleFactor`.
+    
+    * Shared/WebProcessCreationParameters.cpp:
+    (WebKit::WebProcessCreationParameters::encode const):
+    (WebKit::WebProcessCreationParameters::decode):
+    * Shared/WebProcessCreationParameters.h:
+    * UIProcess/Cocoa/WebProcessPoolCocoa.mm:
+    (WebKit::WebProcessPool::platformInitializeWebProcess):
+    
+    Use `_UIApplicationCatalystUserInterfaceIdiom` and `_UIApplicationCatalystScaleFactor` to grab the global user
+    interface idiom and scale factor, respectively.
+    
+    * WebProcess/cocoa/WebProcessCocoa.mm:
+    (WebKit::WebProcess::platformInitializeWebProcess):
+    
+    Override the idiom and scale factor in the web process with the idiom and scale factor from the UI process,
+    using the new SPI `_UIApplicationCatalystRequestViewServiceIdiomAndScaleFactor`. As this function hasn't landed
+    yet, we soft link the function for now to avoid causing the web process to instantly crash on any builds without
+    the fix for <rdar://problem/68524148>.
+    
+    Source/WTF:
+    
+    Add a new flag to guard the presence of `_UIApplicationCatalystUserInterfaceIdiom`,
+    `_UIApplicationCatalystScaleFactor`, and `_UIApplicationCatalystRequestViewServiceIdiomAndScaleFactor`.
+    
+    * wtf/PlatformHave.h:
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266802 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2020-09-09  Wenson Hsieh  <[email protected]>
+
+            Text copied and pasted from Mac Catalyst apps appears larger than expected
+            https://bugs.webkit.org/show_bug.cgi?id=215971
+            <rdar://problem/65768907>
+
+            Reviewed by Tim Horton.
+
+            Various pieces of platform logic in Mac Catalyst depend on the user interface idiom (i.e. Mac or iPad) of the
+            app, as well as the application-wide "scale factor". In the context of this bug, NSAttributedString to RTF data
+            conversion methods in `UIFoundation` consult the scale factor of `UIiOSMacIdiomManager` to determine whether to
+            emit 0 (standard) or 1 (iOS) for the `\cocoatextscaling` attribute. The fact that the web process' scale factor
+            may be out of sync with the UI process' scale factor leads to copied RTF data in the web process appearing
+            either larger or smaller than expected, due to an incorrect `NSTextScalingType` value.
+
+            To mitigate this (as well as any other issues), we add a mechanism for the UI process to forward the global
+            scale factor and user interface idiom to the web process inside of the web process creation parameters, and then
+            use new UIKit SPI to override the scale factor and idiom within the web process.
+
+            * Scripts/process-entitlements.sh:
+
+            Add a new entitlement needed to use `_UIApplicationCatalystRequestViewServiceIdiomAndScaleFactor`.
+
+            * Shared/WebProcessCreationParameters.cpp:
+            (WebKit::WebProcessCreationParameters::encode const):
+            (WebKit::WebProcessCreationParameters::decode):
+            * Shared/WebProcessCreationParameters.h:
+            * UIProcess/Cocoa/WebProcessPoolCocoa.mm:
+            (WebKit::WebProcessPool::platformInitializeWebProcess):
+
+            Use `_UIApplicationCatalystUserInterfaceIdiom` and `_UIApplicationCatalystScaleFactor` to grab the global user
+            interface idiom and scale factor, respectively.
+
+            * WebProcess/cocoa/WebProcessCocoa.mm:
+            (WebKit::WebProcess::platformInitializeWebProcess):
+
+            Override the idiom and scale factor in the web process with the idiom and scale factor from the UI process,
+            using the new SPI `_UIApplicationCatalystRequestViewServiceIdiomAndScaleFactor`. As this function hasn't landed
+            yet, we soft link the function for now to avoid causing the web process to instantly crash on any builds without
+            the fix for <rdar://problem/68524148>.
+
+2020-09-17  Alan Coon  <[email protected]>
+
         Cherry-pick r266677. rdar://problem/68740521
 
     [MotionMark] RenderLayer::paintLayerContents spends ~5% of the time in MonotonicTime::now() in Multiply

Modified: branches/safari-610-branch/Source/WebKit/Scripts/process-entitlements.sh (267272 => 267273)


--- branches/safari-610-branch/Source/WebKit/Scripts/process-entitlements.sh	2020-09-18 19:36:28 UTC (rev 267272)
+++ branches/safari-610-branch/Source/WebKit/Scripts/process-entitlements.sh	2020-09-18 19:36:31 UTC (rev 267273)
@@ -110,6 +110,7 @@
     then
         plistbuddy Add :com.apple.pac.shared_region_id string WebContent
         plistbuddy Add :com.apple.private.pac.exception bool YES
+        plistbuddy Add :com.apple.UIKit.view-service-wants-custom-idiom-and-scale bool YES
     fi
 }
 

Modified: branches/safari-610-branch/Source/WebKit/Shared/WebProcessCreationParameters.cpp (267272 => 267273)


--- branches/safari-610-branch/Source/WebKit/Shared/WebProcessCreationParameters.cpp	2020-09-18 19:36:28 UTC (rev 267272)
+++ branches/safari-610-branch/Source/WebKit/Shared/WebProcessCreationParameters.cpp	2020-09-18 19:36:31 UTC (rev 267273)
@@ -192,6 +192,10 @@
 #if PLATFORM(GTK)
     encoder << useSystemAppearanceForScrollbars;
 #endif
+
+#if HAVE(CATALYST_USER_INTERFACE_IDIOM_AND_SCALE_FACTOR)
+    encoder << overrideUserInterfaceIdiomAndScale;
+#endif
 }
 
 bool WebProcessCreationParameters::decode(IPC::Decoder& decoder, WebProcessCreationParameters& parameters)
@@ -517,6 +521,14 @@
     parameters.useSystemAppearanceForScrollbars = WTFMove(*useSystemAppearanceForScrollbars);
 #endif
 
+#if HAVE(CATALYST_USER_INTERFACE_IDIOM_AND_SCALE_FACTOR)
+    Optional<std::pair<int64_t, double>> overrideUserInterfaceIdiomAndScale;
+    decoder >> overrideUserInterfaceIdiomAndScale;
+    if (!overrideUserInterfaceIdiomAndScale)
+        return false;
+    parameters.overrideUserInterfaceIdiomAndScale = WTFMove(*overrideUserInterfaceIdiomAndScale);
+#endif
+
     return true;
 }
 

Modified: branches/safari-610-branch/Source/WebKit/Shared/WebProcessCreationParameters.h (267272 => 267273)


--- branches/safari-610-branch/Source/WebKit/Shared/WebProcessCreationParameters.h	2020-09-18 19:36:28 UTC (rev 267272)
+++ branches/safari-610-branch/Source/WebKit/Shared/WebProcessCreationParameters.h	2020-09-18 19:36:31 UTC (rev 267273)
@@ -235,6 +235,10 @@
 #if PLATFORM(GTK)
     bool useSystemAppearanceForScrollbars { false };
 #endif
+
+#if HAVE(CATALYST_USER_INTERFACE_IDIOM_AND_SCALE_FACTOR)
+    std::pair<int64_t, double> overrideUserInterfaceIdiomAndScale;
+#endif
 };
 
 } // namespace WebKit

Modified: branches/safari-610-branch/Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm (267272 => 267273)


--- branches/safari-610-branch/Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm	2020-09-18 19:36:28 UTC (rev 267272)
+++ branches/safari-610-branch/Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm	2020-09-18 19:36:31 UTC (rev 267273)
@@ -480,6 +480,10 @@
             startObservingPreferenceChanges();
     }
 #endif
+
+#if HAVE(CATALYST_USER_INTERFACE_IDIOM_AND_SCALE_FACTOR)
+    parameters.overrideUserInterfaceIdiomAndScale = { _UIApplicationCatalystUserInterfaceIdiom(), _UIApplicationCatalystScaleFactor() };
+#endif
 }
 
 void WebProcessPool::platformInitializeNetworkProcess(NetworkProcessCreationParameters& parameters)

Modified: branches/safari-610-branch/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm (267272 => 267273)


--- branches/safari-610-branch/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm	2020-09-18 19:36:28 UTC (rev 267272)
+++ branches/safari-610-branch/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm	2020-09-18 19:36:31 UTC (rev 267273)
@@ -135,6 +135,12 @@
 
 #import <pal/cocoa/AVFoundationSoftLink.h>
 
+#if HAVE(CATALYST_USER_INTERFACE_IDIOM_AND_SCALE_FACTOR)
+// FIXME: This is only for binary compatibility with versions of UIKit in macOS 11 that are missing the change in <rdar://problem/68524148>.
+SOFT_LINK_FRAMEWORK(UIKit)
+SOFT_LINK_FUNCTION_MAY_FAIL_FOR_SOURCE(WebKit, UIKit, _UIApplicationCatalystRequestViewServiceIdiomAndScaleFactor, void, (UIUserInterfaceIdiom idiom, CGFloat scaleFactor), (idiom, scaleFactor))
+#endif
+
 SOFT_LINK_FRAMEWORK(CoreServices)
 SOFT_LINK_CLASS(CoreServices, _LSDService)
 SOFT_LINK_CLASS(CoreServices, _LSDOpenService)
@@ -168,6 +174,13 @@
 
 void WebProcess::platformInitializeWebProcess(WebProcessCreationParameters& parameters)
 {
+#if HAVE(CATALYST_USER_INTERFACE_IDIOM_AND_SCALE_FACTOR)
+    if (canLoad_UIKit__UIApplicationCatalystRequestViewServiceIdiomAndScaleFactor()) {
+        auto [overrideUserInterfaceIdiom, overrideScaleFactor] = parameters.overrideUserInterfaceIdiomAndScale;
+        softLink_UIKit__UIApplicationCatalystRequestViewServiceIdiomAndScaleFactor(static_cast<UIUserInterfaceIdiom>(overrideUserInterfaceIdiom), overrideScaleFactor);
+    }
+#endif
+
     if (parameters.mobileGestaltExtensionHandle) {
         if (auto extension = SandboxExtension::create(WTFMove(*parameters.mobileGestaltExtensionHandle))) {
             bool ok = extension->consume();
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to