Title: [289302] branches/safari-613-branch
Revision
289302
Author
[email protected]
Date
2022-02-07 18:55:08 -0800 (Mon, 07 Feb 2022)

Log Message

Cherry-pick r288543. rdar://problem/84958961

    REGRESSION(r282320): [Cocoa] User-installed fonts don't work in the GPU Process (in WKWebView)
    https://bugs.webkit.org/show_bug.cgi?id=235449
    <rdar://problem/84958961>

    Reviewed by Darin Adler.

    Source/WebCore/PAL:

    * pal/spi/cf/CoreTextSPI.h:

    Source/WebKit:

    The reason for this bug was I was misusing kCTFontOptionsSystemUIFont. I thought this flag just
    meant "allow the creation of system fonts" but it turns out it means something more subtle than
    that. Instead of unconditionally specifying this flag, we should just pull out the options field
    from the source font (which will include that flag if the font was a system font) and use that
    instead.

    Test: fast/text/user-installed-canvas.html

    * Shared/Cocoa/WebCoreArgumentCodersCocoa.mm:
    (IPC::ArgumentCoder<Ref<WebCore::Font>>::encodePlatformData):
    (IPC::createCTFont):
    (IPC::ArgumentCoder<Ref<WebCore::Font>>::decodePlatformData):

    LayoutTests:

    * fast/text/user-installed-canvas-expected.html: Added.
    * fast/text/user-installed-canvas.html: Added.

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

Modified Paths

Added Paths

Diff

Modified: branches/safari-613-branch/LayoutTests/ChangeLog (289301 => 289302)


--- branches/safari-613-branch/LayoutTests/ChangeLog	2022-02-08 02:55:04 UTC (rev 289301)
+++ branches/safari-613-branch/LayoutTests/ChangeLog	2022-02-08 02:55:08 UTC (rev 289302)
@@ -1,5 +1,52 @@
 2022-02-07  Russell Epstein  <[email protected]>
 
+        Cherry-pick r288543. rdar://problem/84958961
+
+    REGRESSION(r282320): [Cocoa] User-installed fonts don't work in the GPU Process (in WKWebView)
+    https://bugs.webkit.org/show_bug.cgi?id=235449
+    <rdar://problem/84958961>
+    
+    Reviewed by Darin Adler.
+    
+    Source/WebCore/PAL:
+    
+    * pal/spi/cf/CoreTextSPI.h:
+    
+    Source/WebKit:
+    
+    The reason for this bug was I was misusing kCTFontOptionsSystemUIFont. I thought this flag just
+    meant "allow the creation of system fonts" but it turns out it means something more subtle than
+    that. Instead of unconditionally specifying this flag, we should just pull out the options field
+    from the source font (which will include that flag if the font was a system font) and use that
+    instead.
+    
+    Test: fast/text/user-installed-canvas.html
+    
+    * Shared/Cocoa/WebCoreArgumentCodersCocoa.mm:
+    (IPC::ArgumentCoder<Ref<WebCore::Font>>::encodePlatformData):
+    (IPC::createCTFont):
+    (IPC::ArgumentCoder<Ref<WebCore::Font>>::decodePlatformData):
+    
+    LayoutTests:
+    
+    * fast/text/user-installed-canvas-expected.html: Added.
+    * fast/text/user-installed-canvas.html: Added.
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@288543 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2022-01-24  Myles C. Maxfield  <[email protected]>
+
+            REGRESSION(r282320): [Cocoa] User-installed fonts don't work in the GPU Process (in WKWebView)
+            https://bugs.webkit.org/show_bug.cgi?id=235449
+            <rdar://problem/84958961>
+
+            Reviewed by Darin Adler.
+
+            * fast/text/user-installed-canvas-expected.html: Added.
+            * fast/text/user-installed-canvas.html: Added.
+
+2022-02-07  Russell Epstein  <[email protected]>
+
         Cherry-pick r288466. rdar://problem/82554226
 
     REGRESSION (iOS 15): HTMLAudioElement fails to load new audio when device is locked or safari is in background

Added: branches/safari-613-branch/LayoutTests/fast/text/user-installed-canvas-expected.html (0 => 289302)


--- branches/safari-613-branch/LayoutTests/fast/text/user-installed-canvas-expected.html	                        (rev 0)
+++ branches/safari-613-branch/LayoutTests/fast/text/user-installed-canvas-expected.html	2022-02-08 02:55:08 UTC (rev 289302)
@@ -0,0 +1,14 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+</head>
+<body>
+<p>This test makes sure that user-installed fonts work correctly when drawn into canvas. The test passes if you see a big solid black square below (and not an @ sign).</p>
+<canvas id="canvas" width="300" height="300"></canvas>
+<script>
+let context = canvas.getContext("2d");
+context.fillRect(0, 0, 300, 300);
+</script>
+</body>
+</html>

Added: branches/safari-613-branch/LayoutTests/fast/text/user-installed-canvas.html (0 => 289302)


--- branches/safari-613-branch/LayoutTests/fast/text/user-installed-canvas.html	                        (rev 0)
+++ branches/safari-613-branch/LayoutTests/fast/text/user-installed-canvas.html	2022-02-08 02:55:08 UTC (rev 289302)
@@ -0,0 +1,15 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+</head>
+<body>
+<p>This test makes sure that user-installed fonts work correctly when drawn into canvas. The test passes if you see a big solid black square below (and not an @ sign).</p>
+<canvas id="canvas" width="300" height="300"></canvas>
+<script>
+let context = canvas.getContext("2d");
+context.font = "400px 'Ahem'";
+context.fillText("A", -50, 270);
+</script>
+</body>
+</html>

Modified: branches/safari-613-branch/Source/WebCore/PAL/ChangeLog (289301 => 289302)


--- branches/safari-613-branch/Source/WebCore/PAL/ChangeLog	2022-02-08 02:55:04 UTC (rev 289301)
+++ branches/safari-613-branch/Source/WebCore/PAL/ChangeLog	2022-02-08 02:55:08 UTC (rev 289302)
@@ -1,5 +1,51 @@
 2022-02-07  Russell Epstein  <[email protected]>
 
+        Cherry-pick r288543. rdar://problem/84958961
+
+    REGRESSION(r282320): [Cocoa] User-installed fonts don't work in the GPU Process (in WKWebView)
+    https://bugs.webkit.org/show_bug.cgi?id=235449
+    <rdar://problem/84958961>
+    
+    Reviewed by Darin Adler.
+    
+    Source/WebCore/PAL:
+    
+    * pal/spi/cf/CoreTextSPI.h:
+    
+    Source/WebKit:
+    
+    The reason for this bug was I was misusing kCTFontOptionsSystemUIFont. I thought this flag just
+    meant "allow the creation of system fonts" but it turns out it means something more subtle than
+    that. Instead of unconditionally specifying this flag, we should just pull out the options field
+    from the source font (which will include that flag if the font was a system font) and use that
+    instead.
+    
+    Test: fast/text/user-installed-canvas.html
+    
+    * Shared/Cocoa/WebCoreArgumentCodersCocoa.mm:
+    (IPC::ArgumentCoder<Ref<WebCore::Font>>::encodePlatformData):
+    (IPC::createCTFont):
+    (IPC::ArgumentCoder<Ref<WebCore::Font>>::decodePlatformData):
+    
+    LayoutTests:
+    
+    * fast/text/user-installed-canvas-expected.html: Added.
+    * fast/text/user-installed-canvas.html: Added.
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@288543 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2022-01-24  Myles C. Maxfield  <[email protected]>
+
+            REGRESSION(r282320): [Cocoa] User-installed fonts don't work in the GPU Process (in WKWebView)
+            https://bugs.webkit.org/show_bug.cgi?id=235449
+            <rdar://problem/84958961>
+
+            Reviewed by Darin Adler.
+
+            * pal/spi/cf/CoreTextSPI.h:
+
+2022-02-07  Russell Epstein  <[email protected]>
+
         Cherry-pick r288031. rdar://problem/82997136
 
     [Cocoa] rVFC() isn't called for initial video load

Modified: branches/safari-613-branch/Source/WebCore/PAL/pal/spi/cf/CoreTextSPI.h (289301 => 289302)


--- branches/safari-613-branch/Source/WebCore/PAL/pal/spi/cf/CoreTextSPI.h	2022-02-08 02:55:04 UTC (rev 289301)
+++ branches/safari-613-branch/Source/WebCore/PAL/pal/spi/cf/CoreTextSPI.h	2022-02-08 02:55:08 UTC (rev 289302)
@@ -95,6 +95,10 @@
 
 typedef const struct __OTSVGTable * OTSVGTableRef;
 
+typedef CF_OPTIONS(uint32_t, CTFontDescriptorOptions) {
+    kCTFontDescriptorOptionThisIsNotARealOption = 0xFFFFFFFF
+};
+
 #endif
 
 WTF_EXTERN_C_BEGIN
@@ -222,4 +226,6 @@
 CTFontRef CTFontCreateForCharacters(CTFontRef currentFont, const UTF16Char *characters, CFIndex length, CFIndex *coveredLength);
 CGFloat CTFontGetSbixImageSizeForGlyphAndContentsScale(CTFontRef, const CGGlyph, CGFloat contentsScale);
 
+CTFontDescriptorOptions CTFontDescriptorGetOptions(CTFontDescriptorRef);
+
 WTF_EXTERN_C_END

Modified: branches/safari-613-branch/Source/WebKit/ChangeLog (289301 => 289302)


--- branches/safari-613-branch/Source/WebKit/ChangeLog	2022-02-08 02:55:04 UTC (rev 289301)
+++ branches/safari-613-branch/Source/WebKit/ChangeLog	2022-02-08 02:55:08 UTC (rev 289302)
@@ -1,5 +1,62 @@
 2022-02-07  Russell Epstein  <[email protected]>
 
+        Cherry-pick r288543. rdar://problem/84958961
+
+    REGRESSION(r282320): [Cocoa] User-installed fonts don't work in the GPU Process (in WKWebView)
+    https://bugs.webkit.org/show_bug.cgi?id=235449
+    <rdar://problem/84958961>
+    
+    Reviewed by Darin Adler.
+    
+    Source/WebCore/PAL:
+    
+    * pal/spi/cf/CoreTextSPI.h:
+    
+    Source/WebKit:
+    
+    The reason for this bug was I was misusing kCTFontOptionsSystemUIFont. I thought this flag just
+    meant "allow the creation of system fonts" but it turns out it means something more subtle than
+    that. Instead of unconditionally specifying this flag, we should just pull out the options field
+    from the source font (which will include that flag if the font was a system font) and use that
+    instead.
+    
+    Test: fast/text/user-installed-canvas.html
+    
+    * Shared/Cocoa/WebCoreArgumentCodersCocoa.mm:
+    (IPC::ArgumentCoder<Ref<WebCore::Font>>::encodePlatformData):
+    (IPC::createCTFont):
+    (IPC::ArgumentCoder<Ref<WebCore::Font>>::decodePlatformData):
+    
+    LayoutTests:
+    
+    * fast/text/user-installed-canvas-expected.html: Added.
+    * fast/text/user-installed-canvas.html: Added.
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@288543 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2022-01-24  Myles C. Maxfield  <[email protected]>
+
+            REGRESSION(r282320): [Cocoa] User-installed fonts don't work in the GPU Process (in WKWebView)
+            https://bugs.webkit.org/show_bug.cgi?id=235449
+            <rdar://problem/84958961>
+
+            Reviewed by Darin Adler.
+
+            The reason for this bug was I was misusing kCTFontOptionsSystemUIFont. I thought this flag just
+            meant "allow the creation of system fonts" but it turns out it means something more subtle than
+            that. Instead of unconditionally specifying this flag, we should just pull out the options field
+            from the source font (which will include that flag if the font was a system font) and use that
+            instead.
+
+            Test: fast/text/user-installed-canvas.html
+
+            * Shared/Cocoa/WebCoreArgumentCodersCocoa.mm:
+            (IPC::ArgumentCoder<Ref<WebCore::Font>>::encodePlatformData):
+            (IPC::createCTFont):
+            (IPC::ArgumentCoder<Ref<WebCore::Font>>::decodePlatformData):
+
+2022-02-07  Russell Epstein  <[email protected]>
+
         Cherry-pick r288478. rdar://problem/72567903
 
     Regression (r286936): SessionStorage data is not cleared when deleting website data by modification time

Modified: branches/safari-613-branch/Source/WebKit/Shared/Cocoa/WebCoreArgumentCodersCocoa.mm (289301 => 289302)


--- branches/safari-613-branch/Source/WebKit/Shared/Cocoa/WebCoreArgumentCodersCocoa.mm	2022-02-08 02:55:04 UTC (rev 289301)
+++ branches/safari-613-branch/Source/WebKit/Shared/Cocoa/WebCoreArgumentCodersCocoa.mm	2022-02-08 02:55:08 UTC (rev 289302)
@@ -461,16 +461,18 @@
         encoder << creationData->fontFaceData;
         encoder << creationData->itemInCollection;
     } else {
+        auto options = CTFontDescriptorGetOptions(fontDescriptor.get());
+        encoder << options;
         auto referenceURL = adoptCF(static_cast<CFURLRef>(CTFontCopyAttribute(ctFont, kCTFontReferenceURLAttribute)));
         auto string = CFURLGetString(referenceURL.get());
-        encoder << String(string);
-        encoder << String(adoptCF(CTFontCopyPostScriptName(ctFont)).get());
+        encoder << string;
+        encoder << adoptCF(CTFontCopyPostScriptName(ctFont)).get();
     }
 }
 
-static RetainPtr<CTFontDescriptorRef> findFontDescriptor(const String& referenceURL, const String& postScriptName)
+static RetainPtr<CTFontDescriptorRef> findFontDescriptor(CFStringRef referenceURL, CFStringRef postScriptName)
 {
-    auto url = "" referenceURL.createCFString().get(), nullptr));
+    auto url = "" referenceURL, nullptr));
     if (!url)
         return nullptr;
     auto fontDescriptors = adoptCF(CTFontManagerCreateFontDescriptorsFromURL(url.get()));
@@ -481,20 +483,20 @@
 
     for (CFIndex i = 0; i < CFArrayGetCount(fontDescriptors.get()); ++i) {
         auto fontDescriptor = static_cast<CTFontDescriptorRef>(CFArrayGetValueAtIndex(fontDescriptors.get(), i));
-        auto currentPostScriptName = adoptCF(static_cast<CFStringRef>(CTFontDescriptorCopyAttribute(fontDescriptor, kCTFontNameAttribute)));
-        if (String(currentPostScriptName.get()) == postScriptName)
+        auto currentPostScriptName = adoptCF(CTFontDescriptorCopyAttribute(fontDescriptor, kCTFontNameAttribute));
+        if (CFEqual(currentPostScriptName.get(), postScriptName))
             return fontDescriptor;
     }
     return nullptr;
 }
 
-static RetainPtr<CTFontRef> createCTFont(CFDictionaryRef attributes, float size, const String& referenceURL, const String& desiredPostScriptName)
+static RetainPtr<CTFontRef> createCTFont(CFDictionaryRef attributes, float size, CTFontDescriptorOptions options, CFStringRef referenceURL, CFStringRef desiredPostScriptName)
 {
     auto fontDescriptor = adoptCF(CTFontDescriptorCreateWithAttributes(attributes));
     if (fontDescriptor) {
-        auto font = adoptCF(CTFontCreateWithFontDescriptorAndOptions(fontDescriptor.get(), size, nullptr, kCTFontOptionsSystemUIFont));
-        String actualPostScriptName(adoptCF(CTFontCopyPostScriptName(font.get())).get());
-        if (actualPostScriptName == desiredPostScriptName)
+        auto font = adoptCF(CTFontCreateWithFontDescriptorAndOptions(fontDescriptor.get(), size, nullptr, options));
+        auto actualPostScriptName = adoptCF(CTFontCopyPostScriptName(font.get()));
+        if (CFEqual(actualPostScriptName.get(), desiredPostScriptName))
             return font;
     }
 
@@ -506,7 +508,7 @@
         fontDescriptor = adoptCF(CTFontDescriptorCreateLastResort());
     }
     ASSERT(fontDescriptor);
-    return adoptCF(CTFontCreateWithFontDescriptorAndOptions(fontDescriptor.get(), size, nullptr, kCTFontOptionsSystemUIFont));
+    return adoptCF(CTFontCreateWithFontDescriptorAndOptions(fontDescriptor.get(), size, nullptr, options));
 }
 
 std::optional<WebCore::FontPlatformData> ArgumentCoder<Ref<WebCore::Font>>::decodePlatformData(Decoder& decoder)
@@ -577,17 +579,22 @@
         return WebCore::FontPlatformData(ctFont.get(), *size, *syntheticBold, *syntheticOblique, *orientation, *widthVariant, *textRenderingMode, &creationData);
     }
 
-    std::optional<String> referenceURL;
+    std::optional<CTFontDescriptorOptions> options;
+    decoder >> options;
+    if (!options)
+        return std::nullopt;
+
+    std::optional<RetainPtr<CFStringRef>> referenceURL;
     decoder >> referenceURL;
-    if (!referenceURL)
+    if (!referenceURL || !*referenceURL)
         return std::nullopt;
 
-    std::optional<String> postScriptName;
+    std::optional<RetainPtr<CFStringRef>> postScriptName;
     decoder >> postScriptName;
-    if (!postScriptName)
+    if (!postScriptName || !*postScriptName)
         return std::nullopt;
 
-    auto ctFont = createCTFont(attributes->get(), *size, *referenceURL, *postScriptName);
+    auto ctFont = createCTFont(attributes->get(), *size, *options, referenceURL->get(), postScriptName->get());
     if (!ctFont)
         return std::nullopt;
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to