Title: [276428] trunk
Revision
276428
Author
mmaxfi...@apple.com
Date
2021-04-22 01:29:02 -0700 (Thu, 22 Apr 2021)

Log Message

[iOS] Web processes recreated after crashing are not created with the right contentSizeCategory
https://bugs.webkit.org/show_bug.cgi?id=224916

Reviewed by Tim Horton.

Source/WebCore:

The constructor of WKWebView sets the contentSizeCategory for the first page.
But if the web process crashes, the new one won't have it set.

This patch simply adds the contentSizeCategory to the WebProcessCreationParameters.

Tests: TextStyleFontSize.Startup
       TextStyleFontSize.AfterCrash

* rendering/RenderThemeCocoa.h:

Source/WebKit:

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

Tools:

* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/ios/TextStyleFontSize.mm: Added.
(-[TextStyleFontSizeWebView _contentSizeCategory]):
(TEST):

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (276427 => 276428)


--- trunk/Source/WebCore/ChangeLog	2021-04-22 08:27:42 UTC (rev 276427)
+++ trunk/Source/WebCore/ChangeLog	2021-04-22 08:29:02 UTC (rev 276428)
@@ -1,3 +1,20 @@
+2021-04-22  Myles C. Maxfield  <mmaxfi...@apple.com>
+
+        [iOS] Web processes recreated after crashing are not created with the right contentSizeCategory
+        https://bugs.webkit.org/show_bug.cgi?id=224916
+
+        Reviewed by Tim Horton.
+
+        The constructor of WKWebView sets the contentSizeCategory for the first page.
+        But if the web process crashes, the new one won't have it set.
+
+        This patch simply adds the contentSizeCategory to the WebProcessCreationParameters.
+
+        Tests: TextStyleFontSize.Startup
+               TextStyleFontSize.AfterCrash
+
+        * rendering/RenderThemeCocoa.h:
+
 2021-04-22  Alejandro G. Castro  <a...@igalia.com>
 
         REGRESSION(r275790) [GTK][WPE] Scrolling rendering fails after the second page

Modified: trunk/Source/WebCore/rendering/RenderThemeCocoa.h (276427 => 276428)


--- trunk/Source/WebCore/rendering/RenderThemeCocoa.h	2021-04-22 08:27:42 UTC (rev 276427)
+++ trunk/Source/WebCore/rendering/RenderThemeCocoa.h	2021-04-22 08:29:02 UTC (rev 276428)
@@ -34,7 +34,7 @@
 
 class RenderThemeCocoa : public RenderTheme {
 public:
-    static RenderThemeCocoa& singleton();
+    WEBCORE_EXPORT static RenderThemeCocoa& singleton();
 
     virtual CFStringRef contentSizeCategory() const = 0;
 

Modified: trunk/Source/WebKit/ChangeLog (276427 => 276428)


--- trunk/Source/WebKit/ChangeLog	2021-04-22 08:27:42 UTC (rev 276427)
+++ trunk/Source/WebKit/ChangeLog	2021-04-22 08:29:02 UTC (rev 276428)
@@ -1,3 +1,19 @@
+2021-04-22  Myles C. Maxfield  <mmaxfi...@apple.com>
+
+        [iOS] Web processes recreated after crashing are not created with the right contentSizeCategory
+        https://bugs.webkit.org/show_bug.cgi?id=224916
+
+        Reviewed by Tim Horton.
+
+        * Shared/WebProcessCreationParameters.cpp:
+        (WebKit::WebProcessCreationParameters::encode const):
+        (WebKit::WebProcessCreationParameters::decode):
+        * Shared/WebProcessCreationParameters.h:
+        * UIProcess/Cocoa/WebProcessPoolCocoa.mm:
+        (WebKit::WebProcessPool::platformInitializeWebProcess):
+        * WebProcess/cocoa/WebProcessCocoa.mm:
+        (WebKit::WebProcess::platformInitializeWebProcess):
+
 2021-04-21  Fujii Hironori  <hironori.fu...@sony.com>
 
         [Win] GetDoubleClickTime() returns 0 in the non-interactive window station on Windows 10 version 2004

Modified: trunk/Source/WebKit/Shared/WebProcessCreationParameters.cpp (276427 => 276428)


--- trunk/Source/WebKit/Shared/WebProcessCreationParameters.cpp	2021-04-22 08:27:42 UTC (rev 276427)
+++ trunk/Source/WebKit/Shared/WebProcessCreationParameters.cpp	2021-04-22 08:29:02 UTC (rev 276428)
@@ -180,6 +180,7 @@
     encoder << cssValueToSystemColorMap;
     encoder << focusRingColor;
     encoder << localizedDeviceModel;
+    encoder << contentSizeCategory;
 #endif
 
 #if PLATFORM(COCOA)
@@ -508,6 +509,9 @@
     
     if (!decoder.decode(parameters.localizedDeviceModel))
         return false;
+
+    if (!decoder.decode(parameters.contentSizeCategory))
+        return false;
 #endif
 
 #if PLATFORM(COCOA)

Modified: trunk/Source/WebKit/Shared/WebProcessCreationParameters.h (276427 => 276428)


--- trunk/Source/WebKit/Shared/WebProcessCreationParameters.h	2021-04-22 08:27:42 UTC (rev 276427)
+++ trunk/Source/WebKit/Shared/WebProcessCreationParameters.h	2021-04-22 08:29:02 UTC (rev 276428)
@@ -221,6 +221,7 @@
     WebCore::RenderThemeIOS::CSSValueToSystemColorMap cssValueToSystemColorMap;
     WebCore::Color focusRingColor;
     String localizedDeviceModel;
+    String contentSizeCategory;
 #endif
 
 #if PLATFORM(COCOA)

Modified: trunk/Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm (276427 => 276428)


--- trunk/Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm	2021-04-22 08:27:42 UTC (rev 276427)
+++ trunk/Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm	2021-04-22 08:29:02 UTC (rev 276428)
@@ -432,6 +432,7 @@
     parameters.cssValueToSystemColorMap = RenderThemeIOS::cssValueToSystemColorMap();
     parameters.focusRingColor = RenderThemeIOS::systemFocusRingColor();
     parameters.localizedDeviceModel = localizedDeviceModel();
+    parameters.contentSizeCategory = RenderThemeCocoa::singleton().contentSizeCategory();
 #endif
 
 #if ENABLE(CFPREFS_DIRECT_MODE) && PLATFORM(IOS_FAMILY)

Modified: trunk/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm (276427 => 276428)


--- trunk/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm	2021-04-22 08:27:42 UTC (rev 276427)
+++ trunk/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm	2021-04-22 08:29:02 UTC (rev 276428)
@@ -296,6 +296,7 @@
 #if PLATFORM(IOS_FAMILY)
     setCurrentUserInterfaceIdiomIsPadOrMac(parameters.currentUserInterfaceIdiomIsPad);
     setLocalizedDeviceModel(parameters.localizedDeviceModel);
+    RenderThemeIOS::setContentSizeCategory(parameters.contentSizeCategory);
 #if ENABLE(VIDEO_PRESENTATION_MODE)
     setSupportsPictureInPicture(parameters.supportsPictureInPicture);
 #endif

Modified: trunk/Tools/ChangeLog (276427 => 276428)


--- trunk/Tools/ChangeLog	2021-04-22 08:27:42 UTC (rev 276427)
+++ trunk/Tools/ChangeLog	2021-04-22 08:29:02 UTC (rev 276428)
@@ -1,3 +1,15 @@
+2021-04-22  Myles C. Maxfield  <mmaxfi...@apple.com>
+
+        [iOS] Web processes recreated after crashing are not created with the right contentSizeCategory
+        https://bugs.webkit.org/show_bug.cgi?id=224916
+
+        Reviewed by Tim Horton.
+
+        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+        * TestWebKitAPI/Tests/ios/TextStyleFontSize.mm: Added.
+        (-[TextStyleFontSizeWebView _contentSizeCategory]):
+        (TEST):
+
 2021-04-21  Commit Queue  <commit-qu...@webkit.org>
 
         Unreviewed, reverting r276380 and r276386.

Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (276427 => 276428)


--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj	2021-04-22 08:27:42 UTC (rev 276427)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj	2021-04-22 08:29:02 UTC (rev 276428)
@@ -105,6 +105,7 @@
 		1ADBEFE3130C6AA100D61D19 /* simple-accelerated-compositing.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 1ADBEFBC130C6A0100D61D19 /* simple-accelerated-compositing.html */; };
 		1AEDE22613E5E7E700E62FE8 /* InjectedBundleControllerMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1AEDE22413E5E7A000E62FE8 /* InjectedBundleControllerMac.mm */; };
 		1AF7B21F1D6CD14D008C126C /* EnumTraits.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AF7B21D1D6CD12E008C126C /* EnumTraits.cpp */; };
+		1C24DEED263001DE00450D07 /* TextStyleFontSize.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1C24DEEC263001DE00450D07 /* TextStyleFontSize.mm */; };
 		1C2B81801C891E7C00A5529F /* CancelFontSubresource.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1C2B817E1C891E4200A5529F /* CancelFontSubresource.mm */; };
 		1C2B81831C891F0900A5529F /* CancelFontSubresourcePlugIn.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1C2B81811C891EFA00A5529F /* CancelFontSubresourcePlugIn.mm */; };
 		1C2B81861C89259D00A5529F /* webfont.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 1C2B81841C8924A200A5529F /* webfont.html */; };
@@ -1837,6 +1838,7 @@
 		1AEF994817A09F5300998EF0 /* GetPIDAfterAbortedProcessLaunch.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GetPIDAfterAbortedProcessLaunch.cpp; sourceTree = "<group>"; };
 		1AF7B21D1D6CD12E008C126C /* EnumTraits.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = EnumTraits.cpp; sourceTree = "<group>"; };
 		1AFDE6541953B2C000C48FFA /* Optional.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Optional.cpp; sourceTree = "<group>"; };
+		1C24DEEC263001DE00450D07 /* TextStyleFontSize.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = TextStyleFontSize.mm; sourceTree = "<group>"; };
 		1C2B817E1C891E4200A5529F /* CancelFontSubresource.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = CancelFontSubresource.mm; sourceTree = "<group>"; };
 		1C2B81811C891EFA00A5529F /* CancelFontSubresourcePlugIn.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = CancelFontSubresourcePlugIn.mm; sourceTree = "<group>"; };
 		1C2B81841C8924A200A5529F /* webfont.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = webfont.html; sourceTree = "<group>"; };
@@ -3791,6 +3793,7 @@
 				F45E15742112CE6200307E82 /* TestInputDelegate.h */,
 				F45E15752112CE6200307E82 /* TestInputDelegate.mm */,
 				F45033F4206BEC95009351CE /* TextAutosizingBoost.mm */,
+				1C24DEEC263001DE00450D07 /* TextStyleFontSize.mm */,
 				F460F6742614DE2F0064F2B6 /* UIFocusTests.mm */,
 				F46849BD1EEF58E400B937FE /* UIPasteboardTests.mm */,
 				F402F56B23ECC2FB00865549 /* UIWKInteractionViewProtocol.mm */,
@@ -5702,6 +5705,7 @@
 				CE3524F91B1441C40028A7C5 /* TextFieldDidBeginAndEndEditing.cpp in Sources */,
 				9B02E0D6235FA47D004044B2 /* TextManipulation.mm in Sources */,
 				5C16F8FC230C94370074C4A8 /* TextSize.mm in Sources */,
+				1C24DEED263001DE00450D07 /* TextStyleFontSize.mm in Sources */,
 				C22FA32B228F8708009D7988 /* TextWidth.mm in Sources */,
 				7CCE7EDD1A411A9200447C4C /* TimeRanges.cpp in Sources */,
 				7C83E0BD1D0A650C00FEBCF3 /* TopContentInset.mm in Sources */,

Added: trunk/Tools/TestWebKitAPI/Tests/ios/TextStyleFontSize.mm (0 => 276428)


--- trunk/Tools/TestWebKitAPI/Tests/ios/TextStyleFontSize.mm	                        (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/ios/TextStyleFontSize.mm	2021-04-22 08:29:02 UTC (rev 276428)
@@ -0,0 +1,94 @@
+/*
+ * Copyright (C) 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
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "config.h"
+
+#import "InstanceMethodSwizzler.h"
+#import "TestWKWebView.h"
+#import "UIKitSPI.h"
+#import <WebKit/WKPreferencesPrivate.h>
+#import <WebKit/WKPreferencesRef.h>
+#import <WebKit/WKWebViewPrivate.h>
+
+#if PLATFORM(IOS_FAMILY)
+
+#include <WebCore/RenderThemeIOS.h>
+
+static auto contentSizeCategory = kCTFontContentSizeCategoryXXXL;
+
+@interface TextStyleFontSizeWebView : TestWKWebView
+
+@end
+
+@implementation TextStyleFontSizeWebView
+
+- (NSString *)_contentSizeCategory
+{
+    return static_cast<NSString *>(contentSizeCategory);
+}
+
+@end
+
+TEST(TextStyleFontSize, Startup)
+{
+    auto descriptor = adoptCF(CTFontDescriptorCreateWithTextStyle(kCTUIFontTextStyleBody, contentSizeCategory, nullptr));
+    auto sizeNumber = adoptCF(CTFontDescriptorCopyAttribute(descriptor.get(), kCTFontSizeAttribute));
+    auto expected = static_cast<NSNumber *>(sizeNumber.get()).integerValue;
+
+    static NSString *testMarkup = @"<html><head></head><body><div id='target' style='-webkit-text-size-adjust: none; font: -apple-system-body;'>Hello</div></body></html>";
+
+    auto webView = adoptNS([[TextStyleFontSizeWebView alloc] initWithFrame:CGRectMake(0, 0, 960, 360)]);
+    [webView synchronouslyLoadHTMLString:testMarkup];
+    auto actual = [webView stringByEvaluatingJavaScript:@"parseInt(window.getComputedStyle(document.getElementById('target')).getPropertyValue('font-size'))"].integerValue;
+    
+    ASSERT_EQ(actual, expected);
+}
+
+TEST(TextStyleFontSize, AfterCrash)
+{
+    auto *originalContentSizeCategory = static_cast<NSString *>(WebCore::RenderThemeCocoa::singleton().contentSizeCategory());
+    auto *preferredContentSizeCategory = [[UIApplication sharedApplication] preferredContentSizeCategory];
+    ASSERT_TRUE((!originalContentSizeCategory && !preferredContentSizeCategory) || [originalContentSizeCategory isEqualToString:preferredContentSizeCategory]);
+
+    WebCore::RenderThemeIOS::setContentSizeCategory(contentSizeCategory);
+
+    auto descriptor = adoptCF(CTFontDescriptorCreateWithTextStyle(kCTUIFontTextStyleBody, contentSizeCategory, nullptr));
+    auto sizeNumber = adoptCF(CTFontDescriptorCopyAttribute(descriptor.get(), kCTFontSizeAttribute));
+    auto expected = static_cast<NSNumber *>(sizeNumber.get()).integerValue;
+
+    static NSString *testMarkup = @"<html><head></head><body><div id='target' style='-webkit-text-size-adjust: none; font: -apple-system-body;'>Hello</div></body></html>";
+
+    auto webView = adoptNS([[TextStyleFontSizeWebView alloc] initWithFrame:CGRectMake(0, 0, 960, 360)]);
+    [webView synchronouslyLoadHTMLString:testMarkup];
+    [webView _killWebContentProcessAndResetState];
+    [webView synchronouslyLoadHTMLString:testMarkup];
+    auto actual = [webView stringByEvaluatingJavaScript:@"parseInt(window.getComputedStyle(document.getElementById('target')).getPropertyValue('font-size'))"].integerValue;
+    
+    ASSERT_EQ(actual, expected);
+
+    WebCore::RenderThemeIOS::setContentSizeCategory(String());
+}
+
+#endif // PLATFORM(IOS_FAMILY)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to