Title: [295351] trunk
Revision
295351
Author
[email protected]
Date
2022-06-07 09:33:17 -0700 (Tue, 07 Jun 2022)

Log Message

[Cocoa] Move contentSizeCategory to platform/
https://bugs.webkit.org/show_bug.cgi?id=241360

Reviewed by Cameron McCormack.

There are 2 reasons for moving it:
1. There are already layering violations where existing code in platform/ is calling into RenderTheme
       to get the contentSizeCategory.
2. For https://bugs.webkit.org/show_bug.cgi?id=237817, I'm going to be adding a new system font cache,
       and the most natural place to put it is in SystemFontDatabase in platform/. This new cache needs
       access to the contentSizeCategory, so contentSizeCategory needs to be in platform/.

This patch adds FontCacheCocoa.mm because the contentSizeCategory stuff is exposed via Objective-C, and
FontCacheCoreText.cpp is a C++ source.

* Source/WebCore/SourcesCocoa.txt:
* Source/WebCore/WebCore.xcodeproj/project.pbxproj:
* Source/WebCore/platform/graphics/cocoa/FontCacheCocoa.mm: Copied from Source/WebCore/rendering/RenderThemeCocoa.h.
(WebCore::getUIContentSizeCategoryDidChangeNotificationName):
(WebCore::_contentSizeCategory):
(WebCore::contentSizeCategory):
(WebCore::setContentSizeCategory):
* Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp:
(WebCore::FontCache::platformInit):
(WebCore::fontWithFamilySpecialCase):
* Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.h:
* Source/WebCore/platform/graphics/cocoa/SystemFontDatabaseCoreText.cpp:
(WebCore::SystemFontDatabaseCoreText::createTextStyleFont):
* Source/WebCore/rendering/RenderThemeCocoa.h:
* Source/WebCore/rendering/RenderThemeIOS.h:
* Source/WebCore/rendering/RenderThemeIOS.mm:
(WebCore::attachmentActionFont):
(WebCore::attachmentTitleFont):
(WebCore::attachmentDynamicTypeScaleFactor):
(WebCore::contentSizeCategoryDidChange): Deleted.
(WebCore::RenderThemeIOS::RenderThemeIOS): Deleted.
(WebCore::_contentSizeCategory): Deleted.
(WebCore::RenderThemeIOS::contentSizeCategory const): Deleted.
(WebCore::RenderThemeIOS::setContentSizeCategory): Deleted.
* Source/WebCore/rendering/RenderThemeMac.h:
* Source/WebCore/rendering/RenderThemeMac.mm:
(WebCore::RenderThemeMac::contentSizeCategory const): Deleted.
* Source/WebCore/testing/Internals.cpp:
(WebCore::Internals::resetToConsistentState):
(WebCore::Internals::setContentSizeCategory):
* Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm:
(WebKit::WebProcessPool::platformInitializeWebProcess):
* Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::WebPage::contentSizeCategoryDidChange):
* Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm:
(WebKit::WebProcess::platformInitializeWebProcess):
* Tools/TestWebKitAPI/Tests/ios/TextStyleFontSize.mm:
(TEST):

Canonical link: https://commits.webkit.org/251365@main

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebCore/SourcesCocoa.txt (295350 => 295351)


--- trunk/Source/WebCore/SourcesCocoa.txt	2022-06-07 16:29:26 UTC (rev 295350)
+++ trunk/Source/WebCore/SourcesCocoa.txt	2022-06-07 16:33:17 UTC (rev 295351)
@@ -1,4 +1,4 @@
-// Copyright (C) 2017-2020 Apple Inc. All rights reserved.
+// Copyright (C) 2017-2022 Apple Inc. All rights reserved.
 //
 // Redistribution and use in source and binary forms, with or without
 // modification, are permitted provided that the following conditions
@@ -390,6 +390,7 @@
 platform/graphics/cocoa/CMUtilities.mm @no-unify
 platform/graphics/cocoa/ColorCocoa.mm
 platform/graphics/cocoa/FloatRectCocoa.mm
+platform/graphics/cocoa/FontCacheCocoa.mm
 platform/graphics/cocoa/FontCacheCoreText.cpp
 platform/graphics/cocoa/FontCascadeCocoa.cpp
 platform/graphics/cocoa/FontCocoa.cpp

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (295350 => 295351)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2022-06-07 16:29:26 UTC (rev 295350)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2022-06-07 16:33:17 UTC (rev 295351)
@@ -7162,6 +7162,7 @@
 		1C12AC281EE778AE0079E0A0 /* FontFamilySpecificationCoreText.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = FontFamilySpecificationCoreText.cpp; sourceTree = "<group>"; };
 		1C12AC291EE778AE0079E0A0 /* FontFamilySpecificationCoreText.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FontFamilySpecificationCoreText.h; sourceTree = "<group>"; };
 		1C12AC2C1EE779950079E0A0 /* FontDescriptionCocoa.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = FontDescriptionCocoa.cpp; sourceTree = "<group>"; };
+		1C16B86C284D73EF00318FEC /* FontCacheCocoa.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = FontCacheCocoa.mm; sourceTree = "<group>"; };
 		1C18DA56181AF6A500C4EF22 /* TextPainter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TextPainter.cpp; sourceTree = "<group>"; };
 		1C18DA57181AF6A500C4EF22 /* TextPainter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextPainter.h; sourceTree = "<group>"; };
 		1C21E57A183ED1FF001C289D /* IOSurfacePool.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = IOSurfacePool.cpp; sourceTree = "<group>"; };
@@ -29570,6 +29571,7 @@
 				07F5CFF42582A4F800662EF5 /* WebMAudioUtilitiesCocoa.h */,
 				07F5CFF22582A4F800662EF5 /* WebMAudioUtilitiesCocoa.mm */,
 				7B1619102719880E00C40EAC /* WebProcessGraphicsContextGLCocoa.mm */,
+				1C16B86C284D73EF00318FEC /* FontCacheCocoa.mm */,
 			);
 			path = cocoa;
 			sourceTree = "<group>";

Added: trunk/Source/WebCore/platform/graphics/cocoa/FontCacheCocoa.mm (0 => 295351)


--- trunk/Source/WebCore/platform/graphics/cocoa/FontCacheCocoa.mm	                        (rev 0)
+++ trunk/Source/WebCore/platform/graphics/cocoa/FontCacheCocoa.mm	2022-06-07 16:33:17 UTC (rev 295351)
@@ -0,0 +1,68 @@
+/*
+ * Copyright (C) 2022 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 "FontCache.h"
+
+#import "FontCacheCoreText.h"
+#import <wtf/cocoa/TypeCastsCocoa.h>
+
+#import <pal/ios/UIKitSoftLink.h>
+
+namespace WebCore {
+
+#if PLATFORM(IOS_FAMILY)
+CFStringRef getUIContentSizeCategoryDidChangeNotificationName()
+{
+    return static_cast<CFStringRef>(PAL::get_UIKit_UIContentSizeCategoryDidChangeNotification());
+}
+#endif
+
+static String& contentSizeCategoryStorage()
+{
+    static NeverDestroyed<String> contentSizeCategory;
+    return contentSizeCategory.get();
+}
+
+CFStringRef contentSizeCategory()
+{
+    if (!contentSizeCategoryStorage().isNull()) {
+        // The contract of this function is that it returns a +0 autoreleased object (just like [[UIApplication sharedApplication] preferredContentSizeCategory] does).
+        // String's operator NSString returns a +0 autoreleased object, so we do that here, and then cast it to CFStringRef to return it.
+        return bridge_cast(static_cast<NSString*>(contentSizeCategoryStorage()));
+    }
+#if PLATFORM(IOS_FAMILY)
+    return static_cast<CFStringRef>([[PAL::getUIApplicationClass() sharedApplication] preferredContentSizeCategory]);
+#else
+    return kCTFontContentSizeCategoryL;
+#endif
+}
+
+void setContentSizeCategory(const String& contentSizeCategory)
+{
+    contentSizeCategoryStorage() = contentSizeCategory;
+}
+
+} // namespace WebCore

Modified: trunk/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp (295350 => 295351)


--- trunk/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp	2022-06-07 16:29:26 UTC (rev 295350)
+++ trunk/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp	2022-06-07 16:33:17 UTC (rev 295351)
@@ -32,7 +32,6 @@
 #include "FontCreationContext.h"
 #include "FontFamilySpecificationCoreText.h"
 #include "FontPaletteValues.h"
-#include "RenderThemeCocoa.h"
 #include "SystemFontDatabaseCoreText.h"
 #include <CoreText/SFNTLayoutTypes.h>
 #include <pal/spi/cf/CoreTextSPI.h>
@@ -764,6 +763,10 @@
 {
     CFNotificationCenterAddObserver(CFNotificationCenterGetLocalCenter(), this, &fontCacheRegisteredFontsChangedNotificationCallback, kCTFontManagerRegisteredFontsChangedNotification, nullptr, CFNotificationSuspensionBehaviorDeliverImmediately);
 
+#if PLATFORM(IOS_FAMILY)
+    CFNotificationCenterAddObserver(CFNotificationCenterGetLocalCenter(), this, &fontCacheRegisteredFontsChangedNotificationCallback, getUIContentSizeCategoryDidChangeNotificationName(), 0, CFNotificationSuspensionBehaviorDeliverImmediately);
+#endif
+
 #if PLATFORM(MAC)
     CFNotificationCenterRef center = CFNotificationCenterGetLocalCenter();
     const CFStringRef notificationName = kCFLocaleCurrentLocaleDidChangeNotification;
@@ -1283,7 +1286,7 @@
     if (family.startsWith("UICTFontTextStyle"_s)) {
         const auto& request = fontDescription.fontSelectionRequest();
         CTFontSymbolicTraits traits = (isFontWeightBold(request.weight) || FontCache::forCurrentThread().shouldMockBoldSystemFontForAccessibility() ? kCTFontTraitBold : 0) | (isItalic(request.slope) ? kCTFontTraitItalic : 0);
-        auto descriptor = adoptCF(CTFontDescriptorCreateWithTextStyle(family.string().createCFString().get(), RenderThemeCocoa::singleton().contentSizeCategory(), fontDescription.computedLocale().string().createCFString().get()));
+        auto descriptor = adoptCF(CTFontDescriptorCreateWithTextStyle(family.string().createCFString().get(), contentSizeCategory(), fontDescription.computedLocale().string().createCFString().get()));
         if (traits)
             descriptor = adoptCF(CTFontDescriptorCreateCopyWithSymbolicTraits(descriptor.get(), traits, traits));
         return createFontForInstalledFonts(descriptor.get(), size, allowUserInstalledFonts);

Modified: trunk/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.h (295350 => 295351)


--- trunk/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.h	2022-06-07 16:29:26 UTC (rev 295350)
+++ trunk/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.h	2022-06-07 16:33:17 UTC (rev 295351)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2017-2021 Apple Inc.  All rights reserved.
+ * Copyright (C) 2017-2022 Apple Inc.  All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -72,6 +72,11 @@
 RetainPtr<CTFontRef> createFontForInstalledFonts(CTFontRef, AllowUserInstalledFonts);
 void addAttributesForWebFonts(CFMutableDictionaryRef attributes, AllowUserInstalledFonts);
 RetainPtr<CFSetRef> installedFontMandatoryAttributes(AllowUserInstalledFonts);
+CFStringRef getUIContentSizeCategoryDidChangeNotificationName();
 
+WEBCORE_EXPORT void setContentSizeCategory(const String&);
+WEBCORE_EXPORT CFStringRef contentSizeCategory();
+
 VariationDefaultsMap defaultVariationValues(CTFontRef, ShouldLocalizeAxisNames);
-}
+
+} // namespace WebCore

Modified: trunk/Source/WebCore/platform/graphics/cocoa/SystemFontDatabaseCoreText.cpp (295350 => 295351)


--- trunk/Source/WebCore/platform/graphics/cocoa/SystemFontDatabaseCoreText.cpp	2022-06-07 16:29:26 UTC (rev 295350)
+++ trunk/Source/WebCore/platform/graphics/cocoa/SystemFontDatabaseCoreText.cpp	2022-06-07 16:33:17 UTC (rev 295351)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2018 Apple Inc. All rights reserved.
+ * Copyright (C) 2018-2022 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -27,8 +27,8 @@
 #include "SystemFontDatabaseCoreText.h"
 
 #include "FontCache.h"
+#include "FontCacheCoreText.h"
 #include "FontCascadeDescription.h"
-#include "RenderThemeCocoa.h"
 
 #include <wtf/cf/TypeCastsCF.h>
 
@@ -81,7 +81,7 @@
 RetainPtr<CTFontRef> SystemFontDatabaseCoreText::createTextStyleFont(const CascadeListParameters& parameters)
 {
     RetainPtr<CFStringRef> localeString = parameters.locale.isEmpty() ? nullptr : parameters.locale.string().createCFString();
-    auto descriptor = adoptCF(CTFontDescriptorCreateWithTextStyle(parameters.fontName.string().createCFString().get(), RenderThemeCocoa::singleton().contentSizeCategory(), localeString.get()));
+    auto descriptor = adoptCF(CTFontDescriptorCreateWithTextStyle(parameters.fontName.string().createCFString().get(), contentSizeCategory(), localeString.get()));
     // FIXME: Use createFontByApplyingWeightWidthItalicsAndFallbackBehavior().
     CTFontSymbolicTraits traits = (parameters.weight >= kCTFontWeightSemibold ? kCTFontTraitBold : 0)
 #if HAVE(LEVEL_2_SYSTEM_FONT_WIDTH_VALUES) || HAVE(LEVEL_3_SYSTEM_FONT_WIDTH_VALUES)

Modified: trunk/Source/WebCore/rendering/RenderThemeCocoa.h (295350 => 295351)


--- trunk/Source/WebCore/rendering/RenderThemeCocoa.h	2022-06-07 16:29:26 UTC (rev 295350)
+++ trunk/Source/WebCore/rendering/RenderThemeCocoa.h	2022-06-07 16:33:17 UTC (rev 295351)
@@ -36,8 +36,6 @@
 public:
     WEBCORE_EXPORT static RenderThemeCocoa& singleton();
 
-    virtual CFStringRef contentSizeCategory() const = 0;
-
 private:
     void purgeCaches() override;
 

Modified: trunk/Source/WebCore/rendering/RenderThemeCocoa.mm (295350 => 295351)


--- trunk/Source/WebCore/rendering/RenderThemeCocoa.mm	2022-06-07 16:29:26 UTC (rev 295350)
+++ trunk/Source/WebCore/rendering/RenderThemeCocoa.mm	2022-06-07 16:33:17 UTC (rev 295351)
@@ -27,6 +27,7 @@
 #import "RenderThemeCocoa.h"
 
 #import "ApplePayLogoSystemImage.h"
+#import "FontCacheCoreText.h"
 #import "GraphicsContextCG.h"
 #import "HTMLInputElement.h"
 #import "ImageBuffer.h"

Modified: trunk/Source/WebCore/rendering/RenderThemeIOS.h (295350 => 295351)


--- trunk/Source/WebCore/rendering/RenderThemeIOS.h	2022-06-07 16:29:26 UTC (rev 295350)
+++ trunk/Source/WebCore/rendering/RenderThemeIOS.h	2022-06-07 16:33:17 UTC (rev 295351)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2005-2022 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -45,10 +45,6 @@
 
     static void adjustRoundBorderRadius(RenderStyle&, RenderBox&);
 
-    CFStringRef contentSizeCategory() const final;
-
-    WEBCORE_EXPORT static void setContentSizeCategory(const String&);
-
 #if USE(SYSTEM_PREVIEW)
     void paintSystemPreviewBadge(Image&, const PaintInfo&, const FloatRect&) override;
 #endif

Modified: trunk/Source/WebCore/rendering/RenderThemeIOS.mm (295350 => 295351)


--- trunk/Source/WebCore/rendering/RenderThemeIOS.mm	2022-06-07 16:29:26 UTC (rev 295350)
+++ trunk/Source/WebCore/rendering/RenderThemeIOS.mm	2022-06-07 16:33:17 UTC (rev 295351)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2005-2017 Apple Inc. All rights reserved.
+ * Copyright (C) 2005-2022 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -43,6 +43,7 @@
 #import "File.h"
 #import "FloatRoundedRect.h"
 #import "FontCache.h"
+#import "FontCacheCoreText.h"
 #import "FontCascade.h"
 #import "Frame.h"
 #import "FrameSelection.h"
@@ -280,19 +281,8 @@
     return nullptr;
 }
 
-static void contentSizeCategoryDidChange(CFNotificationCenterRef, void*, CFStringRef name, const void*, CFDictionaryRef)
-{
-    ASSERT_UNUSED(name, CFEqual(name, PAL::get_UIKit_UIContentSizeCategoryDidChangeNotification()));
-    WebThreadRun(^{
-        Page::updateStyleForAllPagesAfterGlobalChangeInEnvironment();
-    });
-}
+RenderThemeIOS::RenderThemeIOS() = default;
 
-RenderThemeIOS::RenderThemeIOS()
-{
-    CFNotificationCenterAddObserver(CFNotificationCenterGetLocalCenter(), this, contentSizeCategoryDidChange, (__bridge CFStringRef)PAL::get_UIKit_UIContentSizeCategoryDidChangeNotification(), 0, CFNotificationSuspensionBehaviorDeliverImmediately);
-}
-
 RenderTheme& RenderTheme::singleton()
 {
     static NeverDestroyed<RenderThemeIOS> theme;
@@ -299,24 +289,6 @@
     return theme;
 }
 
-static String& _contentSizeCategory()
-{
-    static NeverDestroyed<String> _contentSizeCategory;
-    return _contentSizeCategory.get();
-}
-
-CFStringRef RenderThemeIOS::contentSizeCategory() const
-{
-    if (!_contentSizeCategory().isNull())
-        return (__bridge CFStringRef)static_cast<NSString*>(_contentSizeCategory());
-    return (CFStringRef)[[PAL::getUIApplicationClass() sharedApplication] preferredContentSizeCategory];
-}
-
-void RenderThemeIOS::setContentSizeCategory(const String& contentSizeCategory)
-{
-    _contentSizeCategory() = contentSizeCategory;
-}
-
 FloatRect RenderThemeIOS::addRoundedBorderClip(const RenderObject& box, GraphicsContext& context, const IntRect& rect)
 {
     // To fix inner border bleeding issues <rdar://problem/9812507>, we clip to the outer border and assert that
@@ -1626,7 +1598,7 @@
 static RetainPtr<CTFontRef> attachmentActionFont()
 {
     auto style = kCTUIFontTextStyleFootnote;
-    auto size = RenderThemeIOS::singleton().contentSizeCategory();
+    auto size = contentSizeCategory();
     auto attributes = static_cast<CFDictionaryRef>(@{ (id)kCTFontTraitsAttribute: @{ (id)kCTFontSymbolicTrait: @(kCTFontTraitTightLeading | kCTFontTraitEmphasized) } });
 #if HAVE(CTFONTDESCRIPTOR_CREATE_WITH_TEXT_STYLE_AND_ATTRIBUTES)
     auto emphasizedFontDescriptor = adoptCF(CTFontDescriptorCreateWithTextStyleAndAttributes(style, size, attributes));
@@ -1645,7 +1617,7 @@
 
 static RetainPtr<CTFontRef> attachmentTitleFont()
 {
-    auto fontDescriptor = adoptCF(CTFontDescriptorCreateWithTextStyle(kCTUIFontTextStyleShortCaption1, RenderThemeIOS::singleton().contentSizeCategory(), 0));
+    auto fontDescriptor = adoptCF(CTFontDescriptorCreateWithTextStyle(kCTUIFontTextStyleShortCaption1, contentSizeCategory(), 0));
     return adoptCF(CTFontCreateWithFontDescriptor(fontDescriptor.get(), 0, nullptr));
 }
 
@@ -1659,7 +1631,7 @@
 static CGFloat attachmentDynamicTypeScaleFactor()
 {
     CGFloat fixedPointSize = shortCaptionPointSizeWithContentSizeCategory(kCTFontContentSizeCategoryL);
-    CGFloat dynamicPointSize = shortCaptionPointSizeWithContentSizeCategory(RenderThemeIOS::singleton().contentSizeCategory());
+    CGFloat dynamicPointSize = shortCaptionPointSizeWithContentSizeCategory(contentSizeCategory());
     if (!dynamicPointSize || !fixedPointSize)
         return 1;
     return std::max<CGFloat>(1, dynamicPointSize / fixedPointSize);

Modified: trunk/Source/WebCore/rendering/RenderThemeMac.h (295350 => 295351)


--- trunk/Source/WebCore/rendering/RenderThemeMac.h	2022-06-07 16:29:26 UTC (rev 295350)
+++ trunk/Source/WebCore/rendering/RenderThemeMac.h	2022-06-07 16:33:17 UTC (rev 295351)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2005-2021 Apple Inc. All rights reserved.
+ * Copyright (C) 2005-2022 Apple Inc. All rights reserved.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -41,8 +41,6 @@
 public:
     friend NeverDestroyed<RenderThemeMac>;
 
-    CFStringRef contentSizeCategory() const final;
-
     // A method asking if the control changes its tint when the window has focus or not.
     bool controlSupportsTints(const RenderObject&) const final;
 

Modified: trunk/Source/WebCore/rendering/RenderThemeMac.mm (295350 => 295351)


--- trunk/Source/WebCore/rendering/RenderThemeMac.mm	2022-06-07 16:29:26 UTC (rev 295350)
+++ trunk/Source/WebCore/rendering/RenderThemeMac.mm	2022-06-07 16:33:17 UTC (rev 295351)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2005-2021 Apple Inc. All rights reserved.
+ * Copyright (C) 2005-2022 Apple Inc. All rights reserved.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -261,11 +261,6 @@
     return paintInfo.context().hasPlatformContext();
 }
 
-CFStringRef RenderThemeMac::contentSizeCategory() const
-{
-    return kCTFontContentSizeCategoryL;
-}
-
 RenderThemeMac::RenderThemeMac()
     : m_notificationObserver(adoptNS([[WebCoreRenderThemeNotificationObserver alloc] init]))
 {

Modified: trunk/Source/WebCore/testing/Internals.cpp (295350 => 295351)


--- trunk/Source/WebCore/testing/Internals.cpp	2022-06-07 16:29:26 UTC (rev 295350)
+++ trunk/Source/WebCore/testing/Internals.cpp	2022-06-07 16:33:17 UTC (rev 295351)
@@ -348,6 +348,7 @@
 #endif
 
 #if PLATFORM(IOS_FAMILY)
+#include "FontCacheCoreText.h"
 #include "MediaSessionHelperIOS.h"
 #endif
 
@@ -641,7 +642,7 @@
     DOMWindow::overrideTransientActivationDurationForTesting(std::nullopt);
 
 #if PLATFORM(IOS)
-    RenderThemeIOS::setContentSizeCategory(kCTFontContentSizeCategoryL);
+    WebCore::setContentSizeCategory(kCTFontContentSizeCategoryL);
 #endif
 
 #if ENABLE(MEDIA_SESSION) && USE(GLIB)
@@ -6519,7 +6520,7 @@
         ctCategory = kCTFontContentSizeCategoryXXXL;
         break;
     }
-    RenderThemeIOS::setContentSizeCategory(ctCategory);
+    WebCore::setContentSizeCategory(ctCategory);
     Page::updateStyleForAllPagesAfterGlobalChangeInEnvironment();
 #else
     UNUSED_PARAM(category);

Modified: trunk/Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm (295350 => 295351)


--- trunk/Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm	2022-06-07 16:29:26 UTC (rev 295350)
+++ trunk/Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm	2022-06-07 16:33:17 UTC (rev 295351)
@@ -54,6 +54,7 @@
 #import "_WKSystemPreferencesInternal.h"
 #import <WebCore/AGXCompilerService.h>
 #import <WebCore/Color.h>
+#import <WebCore/FontCacheCoreText.h>
 #import <WebCore/LocalizedDeviceModel.h>
 #import <WebCore/NetworkStorageSession.h>
 #import <WebCore/NotImplemented.h>
@@ -381,7 +382,7 @@
     parameters.cssValueToSystemColorMap = RenderThemeIOS::cssValueToSystemColorMap();
     parameters.focusRingColor = RenderThemeIOS::systemFocusRingColor();
     parameters.localizedDeviceModel = localizedDeviceModel();
-    parameters.contentSizeCategory = RenderThemeCocoa::singleton().contentSizeCategory();
+    parameters.contentSizeCategory = contentSizeCategory();
 #endif
 
     parameters.mobileGestaltExtensionHandle = process.createMobileGestaltSandboxExtensionIfNeeded();

Modified: trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm (295350 => 295351)


--- trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm	2022-06-07 16:29:26 UTC (rev 295350)
+++ trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm	2022-06-07 16:33:17 UTC (rev 295351)
@@ -87,6 +87,7 @@
 #import <WebCore/File.h>
 #import <WebCore/FloatQuad.h>
 #import <WebCore/FocusController.h>
+#import <WebCore/FontCacheCoreText.h>
 #import <WebCore/Frame.h>
 #import <WebCore/FrameLoaderClient.h>
 #import <WebCore/FrameView.h>
@@ -4385,7 +4386,7 @@
 
 void WebPage::contentSizeCategoryDidChange(const String& contentSizeCategory)
 {
-    RenderThemeIOS::setContentSizeCategory(contentSizeCategory);
+    setContentSizeCategory(contentSizeCategory);
     Page::updateStyleForAllPagesAfterGlobalChangeInEnvironment();
 }
 

Modified: trunk/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm (295350 => 295351)


--- trunk/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm	2022-06-07 16:29:26 UTC (rev 295350)
+++ trunk/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm	2022-06-07 16:33:17 UTC (rev 295351)
@@ -61,6 +61,7 @@
 #import <WebCore/CPUMonitor.h>
 #import <WebCore/DisplayRefreshMonitorManager.h>
 #import <WebCore/FontCache.h>
+#import <WebCore/FontCacheCoreText.h>
 #import <WebCore/FontCascade.h>
 #import <WebCore/FrameView.h>
 #import <WebCore/HistoryController.h>
@@ -295,7 +296,7 @@
 #if PLATFORM(IOS_FAMILY)
     setCurrentUserInterfaceIdiomIsSmallScreen(parameters.currentUserInterfaceIdiomIsSmallScreen);
     setLocalizedDeviceModel(parameters.localizedDeviceModel);
-    RenderThemeIOS::setContentSizeCategory(parameters.contentSizeCategory);
+    setContentSizeCategory(parameters.contentSizeCategory);
 #if ENABLE(VIDEO_PRESENTATION_MODE)
     setSupportsPictureInPicture(parameters.supportsPictureInPicture);
 #endif

Modified: trunk/Tools/TestWebKitAPI/Tests/ios/TextStyleFontSize.mm (295350 => 295351)


--- trunk/Tools/TestWebKitAPI/Tests/ios/TextStyleFontSize.mm	2022-06-07 16:29:26 UTC (rev 295350)
+++ trunk/Tools/TestWebKitAPI/Tests/ios/TextStyleFontSize.mm	2022-06-07 16:33:17 UTC (rev 295351)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2021 Apple Inc. All rights reserved.
+ * Copyright (C) 2021-2022 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -28,6 +28,7 @@
 #import "InstanceMethodSwizzler.h"
 #import "TestWKWebView.h"
 #import "UIKitSPI.h"
+#import <WebCore/FontCacheCoreText.h>
 #import <WebKit/WKPreferencesPrivate.h>
 #import <WebKit/WKPreferencesRef.h>
 #import <WebKit/WKWebViewPrivate.h>
@@ -68,11 +69,11 @@
 
 TEST(TextStyleFontSize, AfterCrash)
 {
-    auto *originalContentSizeCategory = static_cast<NSString *>(WebCore::RenderThemeCocoa::singleton().contentSizeCategory());
+    auto *originalContentSizeCategory = static_cast<NSString *>(WebCore::contentSizeCategory());
     auto *preferredContentSizeCategory = [[UIApplication sharedApplication] preferredContentSizeCategory];
     ASSERT_TRUE((!originalContentSizeCategory && !preferredContentSizeCategory) || [originalContentSizeCategory isEqualToString:preferredContentSizeCategory]);
 
-    WebCore::RenderThemeIOS::setContentSizeCategory(contentSizeCategory);
+    WebCore::setContentSizeCategory(contentSizeCategory);
 
     auto descriptor = adoptCF(CTFontDescriptorCreateWithTextStyle(kCTUIFontTextStyleBody, contentSizeCategory, nullptr));
     auto sizeNumber = adoptCF(CTFontDescriptorCopyAttribute(descriptor.get(), kCTFontSizeAttribute));
@@ -88,7 +89,7 @@
     
     ASSERT_EQ(actual, expected);
 
-    WebCore::RenderThemeIOS::setContentSizeCategory(String());
+    WebCore::setContentSizeCategory(String());
 }
 
 #endif // PLATFORM(IOS_FAMILY)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to