Changeset 232799 in webkit


Ignore:
Timestamp:
Jun 13, 2018 11:51:17 AM (6 years ago)
Author:
Wenson Hsieh
Message:

CSS "background-color" style no longer affects natively rendered text fields
https://bugs.webkit.org/show_bug.cgi?id=186597
<rdar://problem/41050528>

Reviewed by Tim Horton.

AppKit currently does not support rendering background color to the edges of a text field cell. This means that
in WebCore, when natively rendering text inputs with background color, we need to only draw the bezels of a text
field, such that the background color we paint behind the text field will be shown. Currently, the way we
accomplish this is by intercepting an internal NSTextField method that computes drawing options for CoreUI, and
inserting a "borders only" => true entry.

However, in a recent build of macOS Mojave, AppKit tweaked -_coreUIDrawOptionsWithFrame:inView:includeFocus: to
add an extra argument (such that it's now -_coreUIDrawOptionsWithFrame:inView:includeFocus:maskOnly:), which
negates the above workaround. To fix this in the short term, augment the workaround to apply to the latest macOS
Mojave as well. A longer-term fix is already tracked in <rdar://problem/11385461>, which would allow WebKit to
simply specify a background color on the text field cell, and have AppKit render it properly to the edges of the
bezels.

Covered by a test that is currently failing on Mojave: fast/forms/hidpi-textfield-background-bleeding.html

  • rendering/RenderThemeMac.mm:

(-[WebCoreTextFieldCell _adjustedCoreUIDrawOptionsForDrawingBordersOnly:]):
(-[WebCoreTextFieldCell _coreUIDrawOptionsWithFrame:inView:includeFocus:]):
(-[WebCoreTextFieldCell _coreUIDrawOptionsWithFrame:inView:includeFocus:maskOnly:]):

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r232796 r232799  
     12018-06-13  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        CSS "background-color" style no longer affects natively rendered text fields
     4        https://bugs.webkit.org/show_bug.cgi?id=186597
     5        <rdar://problem/41050528>
     6
     7        Reviewed by Tim Horton.
     8
     9        AppKit currently does not support rendering background color to the edges of a text field cell. This means that
     10        in WebCore, when natively rendering text inputs with background color, we need to only draw the bezels of a text
     11        field, such that the background color we paint behind the text field will be shown. Currently, the way we
     12        accomplish this is by intercepting an internal NSTextField method that computes drawing options for CoreUI, and
     13        inserting a `"borders only" => true` entry.
     14
     15        However, in a recent build of macOS Mojave, AppKit tweaked -_coreUIDrawOptionsWithFrame:inView:includeFocus: to
     16        add an extra argument (such that it's now -_coreUIDrawOptionsWithFrame:inView:includeFocus:maskOnly:), which
     17        negates the above workaround. To fix this in the short term, augment the workaround to apply to the latest macOS
     18        Mojave as well. A longer-term fix is already tracked in <rdar://problem/11385461>, which would allow WebKit to
     19        simply specify a background color on the text field cell, and have AppKit render it properly to the edges of the
     20        bezels.
     21
     22        Covered by a test that is currently failing on Mojave: fast/forms/hidpi-textfield-background-bleeding.html
     23
     24        * rendering/RenderThemeMac.mm:
     25        (-[WebCoreTextFieldCell _adjustedCoreUIDrawOptionsForDrawingBordersOnly:]):
     26        (-[WebCoreTextFieldCell _coreUIDrawOptionsWithFrame:inView:includeFocus:]):
     27        (-[WebCoreTextFieldCell _coreUIDrawOptionsWithFrame:inView:includeFocus:maskOnly:]):
     28
    1292018-06-13  Thibault Saunier  <tsaunier@igalia.com>
    230
  • trunk/Source/WebCore/rendering/RenderThemeMac.mm

    r232501 r232799  
    116116@interface NSTextFieldCell ()
    117117- (CFDictionaryRef)_coreUIDrawOptionsWithFrame:(NSRect)cellFrame inView:(NSView *)controlView includeFocus:(BOOL)includeFocus;
     118- (CFDictionaryRef)_coreUIDrawOptionsWithFrame:(NSRect)cellFrame inView:(NSView *)controlView includeFocus:(BOOL)includeFocus maskOnly:(BOOL)maskOnly;
    118119@end
    119120
     
    154155@implementation WebCoreTextFieldCell
    155156
    156 - (CFDictionaryRef)_coreUIDrawOptionsWithFrame:(NSRect)cellFrame inView:(NSView *)controlView includeFocus:(BOOL)includeFocus
    157 {
    158     // FIXME: This is a workaround for <rdar://problem/11385461>. When that bug is resolved, we should remove this code.
    159     CFMutableDictionaryRef coreUIDrawOptions = CFDictionaryCreateMutableCopy(NULL, 0, [super _coreUIDrawOptionsWithFrame:cellFrame inView:controlView includeFocus:includeFocus]);
     157- (CFDictionaryRef)_adjustedCoreUIDrawOptionsForDrawingBordersOnly:(CFDictionaryRef)defaultOptions
     158{
     159    // FIXME: This is a workaround for <rdar://problem/11385461>. When that bug is resolved, we should remove this code,
     160    // as well as the internal method overrides below.
     161    CFMutableDictionaryRef coreUIDrawOptions = CFDictionaryCreateMutableCopy(NULL, 0, defaultOptions);
    160162    CFDictionarySetValue(coreUIDrawOptions, CFSTR("borders only"), kCFBooleanTrue);
    161163    CFAutorelease(coreUIDrawOptions);
    162164    return coreUIDrawOptions;
     165}
     166
     167- (CFDictionaryRef)_coreUIDrawOptionsWithFrame:(NSRect)cellFrame inView:(NSView *)controlView includeFocus:(BOOL)includeFocus
     168{
     169    return [self _adjustedCoreUIDrawOptionsForDrawingBordersOnly:[super _coreUIDrawOptionsWithFrame:cellFrame inView:controlView includeFocus:includeFocus]];
     170}
     171
     172- (CFDictionaryRef)_coreUIDrawOptionsWithFrame:(NSRect)cellFrame inView:(NSView *)controlView includeFocus:(BOOL)includeFocus maskOnly:(BOOL)maskOnly
     173{
     174    return [self _adjustedCoreUIDrawOptionsForDrawingBordersOnly:[super _coreUIDrawOptionsWithFrame:cellFrame inView:controlView includeFocus:includeFocus maskOnly:maskOnly]];
    163175}
    164176
Note: See TracChangeset for help on using the changeset viewer.