[webkit-changes] [WebKit/WebKit] d4bad9: `WebCore::colorFromCocoaColor` can sometimes fail ...

Richard Robinson noreply at github.com
Fri May 26 20:56:26 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: d4bad90961616ac6562ff5dd66f5c1f4906159d5
      https://github.com/WebKit/WebKit/commit/d4bad90961616ac6562ff5dd66f5c1f4906159d5
  Author: Richard Robinson <richard_robinson2 at apple.com>
  Date:   2023-05-26 (Fri, 26 May 2023)

  Changed paths:
    M Source/WebCore/platform/ios/ColorIOS.mm

  Log Message:
  -----------
  `WebCore::colorFromCocoaColor` can sometimes fail to convert a color
https://bugs.webkit.org/show_bug.cgi?id=257405
rdar://108643609

Reviewed by Aditya Keerthi.

The method `[UIColor getRed:green:blue:alpha:]` can fail if the given color is of an incompatible
color space, such as `NSColor Generic Gray Gamma 2.2 Profile colorspace 0.5 1`. Previously in the
ColorIOS implementation of `WebCore::colorFromCocoaColor`, we would just silently fail and return
an empty color.

This PR fixes this by checking if `[UIColor getRed:green:blue:alpha:]` is successful. If it is not,
we instead create a single colored pixel, and then extract the converted color from it to return.

* Source/WebCore/platform/ios/ColorIOS.mm:
(WebCore::colorFromCocoaColor):

Canonical link: https://commits.webkit.org/264619@main




More information about the webkit-changes mailing list