Title: [262428] trunk/Source/WebCore
Revision
262428
Author
timothy_hor...@apple.com
Date
2020-06-02 10:11:43 -0700 (Tue, 02 Jun 2020)

Log Message

UIColor and NSColor WebCore::Color factories should return invalid colors for nil input colors
https://bugs.webkit.org/show_bug.cgi?id=212631

Reviewed by Anders Carlsson.

* platform/graphics/mac/ColorMac.mm:
(WebCore::colorFromNSColor):
(WebCore::semanticColorFromNSColor):
* platform/ios/ColorIOS.mm:
(WebCore::colorFromUIColor):
This doesn't affect any code currently in WebKit, but it is very, very surprising
that these functions happily accept a null color, assert in debug, but in release
do crazy things like try to paint the null color into a small bitmap to figure out
what it really is.

Also, this matches the behavior of the Color constructors that take CGColorRef.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (262427 => 262428)


--- trunk/Source/WebCore/ChangeLog	2020-06-02 17:09:18 UTC (rev 262427)
+++ trunk/Source/WebCore/ChangeLog	2020-06-02 17:11:43 UTC (rev 262428)
@@ -1,3 +1,22 @@
+2020-06-02  Tim Horton  <timothy_hor...@apple.com>
+
+        UIColor and NSColor WebCore::Color factories should return invalid colors for nil input colors
+        https://bugs.webkit.org/show_bug.cgi?id=212631
+
+        Reviewed by Anders Carlsson.
+
+        * platform/graphics/mac/ColorMac.mm:
+        (WebCore::colorFromNSColor):
+        (WebCore::semanticColorFromNSColor):
+        * platform/ios/ColorIOS.mm:
+        (WebCore::colorFromUIColor):
+        This doesn't affect any code currently in WebKit, but it is very, very surprising
+        that these functions happily accept a null color, assert in debug, but in release
+        do crazy things like try to paint the null color into a small bitmap to figure out
+        what it really is.
+
+        Also, this matches the behavior of the Color constructors that take CGColorRef.
+
 2020-06-02  Rob Buis  <rb...@igalia.com>
 
         Make generated C++ code use modern C++

Modified: trunk/Source/WebCore/platform/graphics/mac/ColorMac.mm (262427 => 262428)


--- trunk/Source/WebCore/platform/graphics/mac/ColorMac.mm	2020-06-02 17:09:18 UTC (rev 262427)
+++ trunk/Source/WebCore/platform/graphics/mac/ColorMac.mm	2020-06-02 17:11:43 UTC (rev 262428)
@@ -94,6 +94,9 @@
 
 Color colorFromNSColor(NSColor *color)
 {
+    if (!color)
+        return { };
+
     // FIXME: ExtendedColor - needs to handle color spaces.
 
     return makeSimpleColorFromNSColor(color);
@@ -101,6 +104,9 @@
 
 Color semanticColorFromNSColor(NSColor *color)
 {
+    if (!color)
+        return { };
+
     // FIXME: ExtendedColor - needs to handle color spaces.
 
     return Color(makeSimpleColorFromNSColor(color), Color::Semantic);

Modified: trunk/Source/WebCore/platform/ios/ColorIOS.mm (262427 => 262428)


--- trunk/Source/WebCore/platform/ios/ColorIOS.mm	2020-06-02 17:09:18 UTC (rev 262427)
+++ trunk/Source/WebCore/platform/ios/ColorIOS.mm	2020-06-02 17:11:43 UTC (rev 262428)
@@ -34,6 +34,9 @@
 
 Color colorFromUIColor(UIColor *color)
 {
+    if (!color)
+        return { };
+
     // FIXME: ExtendedColor - needs to handle color spaces.
 
     // FIXME: Make this work for a UIColor that was created from a pattern or a DispayP3 color.
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to