Title: [232799] trunk/Source/WebCore
Revision
232799
Author
wenson_hs...@apple.com
Date
2018-06-13 11:51:17 -0700 (Wed, 13 Jun 2018)

Log 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:]):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (232798 => 232799)


--- trunk/Source/WebCore/ChangeLog	2018-06-13 18:32:56 UTC (rev 232798)
+++ trunk/Source/WebCore/ChangeLog	2018-06-13 18:51:17 UTC (rev 232799)
@@ -1,3 +1,31 @@
+2018-06-13  Wenson Hsieh  <wenson_hs...@apple.com>
+
+        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:]):
+
 2018-06-13  Thibault Saunier  <tsaun...@igalia.com>
 
         [WPE] Build getUserMedia support

Modified: trunk/Source/WebCore/rendering/RenderThemeMac.mm (232798 => 232799)


--- trunk/Source/WebCore/rendering/RenderThemeMac.mm	2018-06-13 18:32:56 UTC (rev 232798)
+++ trunk/Source/WebCore/rendering/RenderThemeMac.mm	2018-06-13 18:51:17 UTC (rev 232799)
@@ -115,6 +115,7 @@
 // FIXME: This should go into an SPI.h file in the spi directory.
 @interface NSTextFieldCell ()
 - (CFDictionaryRef)_coreUIDrawOptionsWithFrame:(NSRect)cellFrame inView:(NSView *)controlView includeFocus:(BOOL)includeFocus;
+- (CFDictionaryRef)_coreUIDrawOptionsWithFrame:(NSRect)cellFrame inView:(NSView *)controlView includeFocus:(BOOL)includeFocus maskOnly:(BOOL)maskOnly;
 @end
 
 // FIXME: This should go into an SPI.h file in the spi directory.
@@ -153,15 +154,26 @@
 
 @implementation WebCoreTextFieldCell
 
-- (CFDictionaryRef)_coreUIDrawOptionsWithFrame:(NSRect)cellFrame inView:(NSView *)controlView includeFocus:(BOOL)includeFocus
+- (CFDictionaryRef)_adjustedCoreUIDrawOptionsForDrawingBordersOnly:(CFDictionaryRef)defaultOptions
 {
-    // FIXME: This is a workaround for <rdar://problem/11385461>. When that bug is resolved, we should remove this code.
-    CFMutableDictionaryRef coreUIDrawOptions = CFDictionaryCreateMutableCopy(NULL, 0, [super _coreUIDrawOptionsWithFrame:cellFrame inView:controlView includeFocus:includeFocus]);
+    // FIXME: This is a workaround for <rdar://problem/11385461>. When that bug is resolved, we should remove this code,
+    // as well as the internal method overrides below.
+    CFMutableDictionaryRef coreUIDrawOptions = CFDictionaryCreateMutableCopy(NULL, 0, defaultOptions);
     CFDictionarySetValue(coreUIDrawOptions, CFSTR("borders only"), kCFBooleanTrue);
     CFAutorelease(coreUIDrawOptions);
     return coreUIDrawOptions;
 }
 
+- (CFDictionaryRef)_coreUIDrawOptionsWithFrame:(NSRect)cellFrame inView:(NSView *)controlView includeFocus:(BOOL)includeFocus
+{
+    return [self _adjustedCoreUIDrawOptionsForDrawingBordersOnly:[super _coreUIDrawOptionsWithFrame:cellFrame inView:controlView includeFocus:includeFocus]];
+}
+
+- (CFDictionaryRef)_coreUIDrawOptionsWithFrame:(NSRect)cellFrame inView:(NSView *)controlView includeFocus:(BOOL)includeFocus maskOnly:(BOOL)maskOnly
+{
+    return [self _adjustedCoreUIDrawOptionsForDrawingBordersOnly:[super _coreUIDrawOptionsWithFrame:cellFrame inView:controlView includeFocus:includeFocus maskOnly:maskOnly]];
+}
+
 @end
 
 @interface WebCoreRenderThemeBundle : NSObject
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to