Title: [250640] trunk
Revision
250640
Author
mmaxfi...@apple.com
Date
2019-10-02 17:53:31 -0700 (Wed, 02 Oct 2019)

Log Message

REGRESSION (r245672): <select> dropdown with text-rendering: optimizeLegibility freezes Safari
https://bugs.webkit.org/show_bug.cgi?id=202198

Reviewed by Tim Horton.

Source/WebKit:

NSFont has a bug where passing "auto" to kCTFontOpticalSizeAttribute
causes an exception to be thrown. We don't catch the exception, so we
pop up back to the runloop, which confuses the UI process.

The solution is twofold: 1) Workaround the bug by passing the font size
to kCTFontOpticalSizeAttribute instead, and 2) catch any exceptions that
this part of the code might throw.

* UIProcess/mac/WebPopupMenuProxyMac.mm:
(WebKit::WebPopupMenuProxyMac::showPopupMenu):

Source/WTF:

* wtf/Platform.h:

LayoutTests:

* fast/forms/select-font-optical-size-expected.txt: Added.
* fast/forms/select-font-optical-size.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (250639 => 250640)


--- trunk/LayoutTests/ChangeLog	2019-10-03 00:19:10 UTC (rev 250639)
+++ trunk/LayoutTests/ChangeLog	2019-10-03 00:53:31 UTC (rev 250640)
@@ -1,3 +1,13 @@
+2019-10-02  Myles C. Maxfield  <mmaxfi...@apple.com>
+
+        REGRESSION (r245672): <select> dropdown with text-rendering: optimizeLegibility freezes Safari
+        https://bugs.webkit.org/show_bug.cgi?id=202198
+
+        Reviewed by Tim Horton.
+
+        * fast/forms/select-font-optical-size-expected.txt: Added.
+        * fast/forms/select-font-optical-size.html: Added.
+
 2019-10-02  Kate Cheney  <katherine_che...@apple.com>
 
         Updated resource load statistics are never merged into the SQLite Database backend (202372).

Added: trunk/LayoutTests/fast/forms/select-font-optical-size-expected.txt (0 => 250640)


--- trunk/LayoutTests/fast/forms/select-font-optical-size-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/forms/select-font-optical-size-expected.txt	2019-10-03 00:53:31 UTC (rev 250640)
@@ -0,0 +1,9 @@
+This test makes sure that text-rendering: optimizeLegibility on a drop-down select element doesn't cause a hang.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/fast/forms/select-font-optical-size.html (0 => 250640)


--- trunk/LayoutTests/fast/forms/select-font-optical-size.html	                        (rev 0)
+++ trunk/LayoutTests/fast/forms/select-font-optical-size.html	2019-10-03 00:53:31 UTC (rev 250640)
@@ -0,0 +1,33 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+<style>
+body {
+    text-rendering: optimizeLegibility;
+}
+select {
+    -webkit-appearance: none;
+}
+</style>
+</head>
+<body>
+<select id="target">
+    <option>Click</option>
+    <option>Click</option>
+</select>
+<script>
+description("This test makes sure that text-rendering: optimizeLegibility on a drop-down select element doesn't cause a hang.");
+window.jsTestIsAsync = true;
+const target = document.getElementById("target");
+if (window.internals) {
+    internals.withUserGesture(function() {
+        target.click();
+        window.setTimeout(finishJSTest, 50);
+    });
+} else
+    finishJSTest();
+</script>
+<script src=""
+</body>
+</html>

Modified: trunk/Source/WTF/ChangeLog (250639 => 250640)


--- trunk/Source/WTF/ChangeLog	2019-10-03 00:19:10 UTC (rev 250639)
+++ trunk/Source/WTF/ChangeLog	2019-10-03 00:53:31 UTC (rev 250640)
@@ -1,3 +1,12 @@
+2019-10-02  Myles C. Maxfield  <mmaxfi...@apple.com>
+
+        REGRESSION (r245672): <select> dropdown with text-rendering: optimizeLegibility freezes Safari
+        https://bugs.webkit.org/show_bug.cgi?id=202198
+
+        Reviewed by Tim Horton.
+
+        * wtf/Platform.h:
+
 2019-10-02  Mark Lam  <mark....@apple.com>
 
         DoubleToStringConverter::ToExponential() should null terminate its string.

Modified: trunk/Source/WTF/wtf/Platform.h (250639 => 250640)


--- trunk/Source/WTF/wtf/Platform.h	2019-10-03 00:19:10 UTC (rev 250639)
+++ trunk/Source/WTF/wtf/Platform.h	2019-10-03 00:53:31 UTC (rev 250640)
@@ -1598,6 +1598,10 @@
 #define HAVE_CORETEXT_AUTO_OPTICAL_SIZING 1
 #endif
 
+#if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED < 101500) || (PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED < 130000)
+#define HAVE_NSFONT_WITH_OPTICAL_SIZING_BUG 1
+#endif
+
 #if (PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 130000 || PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101500)
 #define HAVE_APP_SSO 1
 #endif

Modified: trunk/Source/WebKit/ChangeLog (250639 => 250640)


--- trunk/Source/WebKit/ChangeLog	2019-10-03 00:19:10 UTC (rev 250639)
+++ trunk/Source/WebKit/ChangeLog	2019-10-03 00:53:31 UTC (rev 250640)
@@ -1,3 +1,21 @@
+2019-10-02  Myles C. Maxfield  <mmaxfi...@apple.com>
+
+        REGRESSION (r245672): <select> dropdown with text-rendering: optimizeLegibility freezes Safari
+        https://bugs.webkit.org/show_bug.cgi?id=202198
+
+        Reviewed by Tim Horton.
+
+        NSFont has a bug where passing "auto" to kCTFontOpticalSizeAttribute
+        causes an exception to be thrown. We don't catch the exception, so we
+        pop up back to the runloop, which confuses the UI process.
+
+        The solution is twofold: 1) Workaround the bug by passing the font size
+        to kCTFontOpticalSizeAttribute instead, and 2) catch any exceptions that
+        this part of the code might throw.
+
+        * UIProcess/mac/WebPopupMenuProxyMac.mm:
+        (WebKit::WebPopupMenuProxyMac::showPopupMenu):
+
 2019-10-02  Alex Christensen  <achristen...@webkit.org>
 
         [CMake] Don't link WebKit.framework with SecItemShim

Modified: trunk/Source/WebKit/UIProcess/mac/WebPopupMenuProxyMac.mm (250639 => 250640)


--- trunk/Source/WebKit/UIProcess/mac/WebPopupMenuProxyMac.mm	2019-10-03 00:19:10 UTC (rev 250639)
+++ trunk/Source/WebKit/UIProcess/mac/WebPopupMenuProxyMac.mm	2019-10-03 00:53:31 UTC (rev 250640)
@@ -33,7 +33,9 @@
 #import "PlatformPopupMenuData.h"
 #import "StringUtilities.h"
 #import "WebPopupItem.h"
+#import <pal/spi/cocoa/CoreTextSPI.h>
 #import <pal/system/mac/PopupMenu.h>
+#import <wtf/BlockObjCExceptions.h>
 #import <wtf/ProcessPrivilege.h>
 
 namespace WebKit {
@@ -100,11 +102,26 @@
 {
     ASSERT(hasProcessPrivilege(ProcessPrivilege::CanCommunicateWithWindowServer));
     NSFont *font;
+
+    BEGIN_BLOCK_OBJC_EXCEPTIONS;
+
     if (data.fontInfo.fontAttributeDictionary) {
-        NSFontDescriptor *fontDescriptor = [NSFontDescriptor fontDescriptorWithFontAttributes:(__bridge NSDictionary *)data.fontInfo.fontAttributeDictionary.get()];
+        RetainPtr<NSMutableDictionary> mutableDictionary = adoptNS([(__bridge NSDictionary *)data.fontInfo.fontAttributeDictionary.get() mutableCopy]);
+#if HAVE(NSFONT_WITH_OPTICAL_SIZING_BUG)
+        if (id opticalSizeAttribute = [mutableDictionary objectForKey:(__bridge NSString *)kCTFontOpticalSizeAttribute]) {
+            if ([opticalSizeAttribute isKindOfClass:[NSString class]]) {
+                [mutableDictionary removeObjectForKey:(__bridge NSString *)kCTFontOpticalSizeAttribute];
+                if (NSNumber *size = [mutableDictionary objectForKey:(__bridge NSString *)kCTFontSizeAttribute])
+                    [mutableDictionary setObject:size forKey:(__bridge NSString *)kCTFontOpticalSizeAttribute];
+            }
+        }
+#endif
+        NSFontDescriptor *fontDescriptor = [NSFontDescriptor fontDescriptorWithFontAttributes:mutableDictionary.get()];
         font = [NSFont fontWithDescriptor:fontDescriptor size:((pageScaleFactor != 1) ? [fontDescriptor pointSize] * pageScaleFactor : 0)];
     } else
         font = [NSFont menuFontOfSize:0];
+    
+    END_BLOCK_OBJC_EXCEPTIONS
 
     populate(items, font, textDirection);
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to