Changeset 250640 in webkit


Ignore:
Timestamp:
Oct 2, 2019 5:53:31 PM (5 years ago)
Author:
mmaxfield@apple.com
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.
Location:
trunk
Files:
2 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r250621 r250640  
     12019-10-02  Myles C. Maxfield  <mmaxfield@apple.com>
     2
     3        REGRESSION (r245672): <select> dropdown with text-rendering: optimizeLegibility freezes Safari
     4        https://bugs.webkit.org/show_bug.cgi?id=202198
     5
     6        Reviewed by Tim Horton.
     7
     8        * fast/forms/select-font-optical-size-expected.txt: Added.
     9        * fast/forms/select-font-optical-size.html: Added.
     10
    1112019-10-02  Kate Cheney  <katherine_cheney@apple.com>
    212
  • trunk/Source/WTF/ChangeLog

    r250636 r250640  
     12019-10-02  Myles C. Maxfield  <mmaxfield@apple.com>
     2
     3        REGRESSION (r245672): <select> dropdown with text-rendering: optimizeLegibility freezes Safari
     4        https://bugs.webkit.org/show_bug.cgi?id=202198
     5
     6        Reviewed by Tim Horton.
     7
     8        * wtf/Platform.h:
     9
    1102019-10-02  Mark Lam  <mark.lam@apple.com>
    211
  • trunk/Source/WTF/wtf/Platform.h

    r250596 r250640  
    15991599#endif
    16001600
     1601#if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED < 101500) || (PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED < 130000)
     1602#define HAVE_NSFONT_WITH_OPTICAL_SIZING_BUG 1
     1603#endif
     1604
    16011605#if (PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 130000 || PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101500)
    16021606#define HAVE_APP_SSO 1
  • trunk/Source/WebKit/ChangeLog

    r250638 r250640  
     12019-10-02  Myles C. Maxfield  <mmaxfield@apple.com>
     2
     3        REGRESSION (r245672): <select> dropdown with text-rendering: optimizeLegibility freezes Safari
     4        https://bugs.webkit.org/show_bug.cgi?id=202198
     5
     6        Reviewed by Tim Horton.
     7
     8        NSFont has a bug where passing "auto" to kCTFontOpticalSizeAttribute
     9        causes an exception to be thrown. We don't catch the exception, so we
     10        pop up back to the runloop, which confuses the UI process.
     11
     12        The solution is twofold: 1) Workaround the bug by passing the font size
     13        to kCTFontOpticalSizeAttribute instead, and 2) catch any exceptions that
     14        this part of the code might throw.
     15
     16        * UIProcess/mac/WebPopupMenuProxyMac.mm:
     17        (WebKit::WebPopupMenuProxyMac::showPopupMenu):
     18
    1192019-10-02  Alex Christensen  <achristensen@webkit.org>
    220
  • trunk/Source/WebKit/UIProcess/mac/WebPopupMenuProxyMac.mm

    r243601 r250640  
    3434#import "StringUtilities.h"
    3535#import "WebPopupItem.h"
     36#import <pal/spi/cocoa/CoreTextSPI.h>
    3637#import <pal/system/mac/PopupMenu.h>
     38#import <wtf/BlockObjCExceptions.h>
    3739#import <wtf/ProcessPrivilege.h>
    3840
     
    101103    ASSERT(hasProcessPrivilege(ProcessPrivilege::CanCommunicateWithWindowServer));
    102104    NSFont *font;
     105
     106    BEGIN_BLOCK_OBJC_EXCEPTIONS;
     107
    103108    if (data.fontInfo.fontAttributeDictionary) {
    104         NSFontDescriptor *fontDescriptor = [NSFontDescriptor fontDescriptorWithFontAttributes:(__bridge NSDictionary *)data.fontInfo.fontAttributeDictionary.get()];
     109        RetainPtr<NSMutableDictionary> mutableDictionary = adoptNS([(__bridge NSDictionary *)data.fontInfo.fontAttributeDictionary.get() mutableCopy]);
     110#if HAVE(NSFONT_WITH_OPTICAL_SIZING_BUG)
     111        if (id opticalSizeAttribute = [mutableDictionary objectForKey:(__bridge NSString *)kCTFontOpticalSizeAttribute]) {
     112            if ([opticalSizeAttribute isKindOfClass:[NSString class]]) {
     113                [mutableDictionary removeObjectForKey:(__bridge NSString *)kCTFontOpticalSizeAttribute];
     114                if (NSNumber *size = [mutableDictionary objectForKey:(__bridge NSString *)kCTFontSizeAttribute])
     115                    [mutableDictionary setObject:size forKey:(__bridge NSString *)kCTFontOpticalSizeAttribute];
     116            }
     117        }
     118#endif
     119        NSFontDescriptor *fontDescriptor = [NSFontDescriptor fontDescriptorWithFontAttributes:mutableDictionary.get()];
    105120        font = [NSFont fontWithDescriptor:fontDescriptor size:((pageScaleFactor != 1) ? [fontDescriptor pointSize] * pageScaleFactor : 0)];
    106121    } else
    107122        font = [NSFont menuFontOfSize:0];
     123   
     124    END_BLOCK_OBJC_EXCEPTIONS
    108125
    109126    populate(items, font, textDirection);
Note: See TracChangeset for help on using the changeset viewer.