Skip to content
Permalink
Browse files
[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):


Canonical link: https://commits.webkit.org/236891@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@276428 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
litherum committed Apr 22, 2021
1 parent 70f7fa9 commit c5e2be795a518af9726ede66d03a3a68b9361919
Showing 10 changed files with 151 additions and 1 deletion.
@@ -1,3 +1,20 @@
2021-04-22 Myles C. Maxfield <mmaxfield@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 <alex@igalia.com>

REGRESSION(r275790) [GTK][WPE] Scrolling rendering fails after the second page
@@ -34,7 +34,7 @@ namespace WebCore {

class RenderThemeCocoa : public RenderTheme {
public:
static RenderThemeCocoa& singleton();
WEBCORE_EXPORT static RenderThemeCocoa& singleton();

virtual CFStringRef contentSizeCategory() const = 0;

@@ -1,3 +1,19 @@
2021-04-22 Myles C. Maxfield <mmaxfield@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.Fujii@sony.com>

[Win] GetDoubleClickTime() returns 0 in the non-interactive window station on Windows 10 version 2004
@@ -180,6 +180,7 @@ void WebProcessCreationParameters::encode(IPC::Encoder& encoder) const
encoder << cssValueToSystemColorMap;
encoder << focusRingColor;
encoder << localizedDeviceModel;
encoder << contentSizeCategory;
#endif

#if PLATFORM(COCOA)
@@ -508,6 +509,9 @@ bool WebProcessCreationParameters::decode(IPC::Decoder& decoder, WebProcessCreat

if (!decoder.decode(parameters.localizedDeviceModel))
return false;

if (!decoder.decode(parameters.contentSizeCategory))
return false;
#endif

#if PLATFORM(COCOA)
@@ -221,6 +221,7 @@ struct WebProcessCreationParameters {
WebCore::RenderThemeIOS::CSSValueToSystemColorMap cssValueToSystemColorMap;
WebCore::Color focusRingColor;
String localizedDeviceModel;
String contentSizeCategory;
#endif

#if PLATFORM(COCOA)
@@ -432,6 +432,7 @@ static bool requiresContainerManagerAccess()
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)
@@ -296,6 +296,7 @@ static Boolean isAXAuthenticatedCallback(audit_token_t auditToken)
#if PLATFORM(IOS_FAMILY)
setCurrentUserInterfaceIdiomIsPadOrMac(parameters.currentUserInterfaceIdiomIsPad);
setLocalizedDeviceModel(parameters.localizedDeviceModel);
RenderThemeIOS::setContentSizeCategory(parameters.contentSizeCategory);
#if ENABLE(VIDEO_PRESENTATION_MODE)
setSupportsPictureInPicture(parameters.supportsPictureInPicture);
#endif
@@ -1,3 +1,15 @@
2021-04-22 Myles C. Maxfield <mmaxfield@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-queue@webkit.org>

Unreviewed, reverting r276380 and r276386.
@@ -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 */,
@@ -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)

0 comments on commit c5e2be7

Please sign in to comment.