Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WebCore::colorFromCocoaColor can sometimes fail to convert a color #14414

Merged
merged 1 commit into from May 27, 2023

Conversation

rr-codes
Copy link
Contributor

@rr-codes rr-codes commented May 27, 2023

d4bad90

`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

29bcfd6

Misc iOS, tvOS & watchOS macOS Linux Windows
βœ… πŸ§ͺ style βœ… πŸ›  ios βœ… πŸ›  mac βœ… πŸ›  wpe βœ… πŸ›  wincairo
βœ… πŸ§ͺ bindings βœ… πŸ›  ios-sim βœ… πŸ›  mac-AS-debug βœ… πŸ§ͺ wpe-wk2
βœ… πŸ§ͺ webkitperl βœ… πŸ§ͺ ios-wk2 ⏳ πŸ§ͺ api-mac βœ… πŸ›  gtk
βœ… πŸ§ͺ ios-wk2-wpt βœ… πŸ§ͺ mac-wk1 ❌ πŸ§ͺ gtk-wk2
βœ… πŸ§ͺ api-ios βœ… πŸ§ͺ mac-wk2 βœ… πŸ§ͺ api-gtk
βœ… πŸ›  tv βœ… πŸ§ͺ mac-AS-debug-wk2
βœ… πŸ›  tv-sim
βœ… πŸ›  πŸ§ͺ merge βœ… πŸ›  watch
βœ… πŸ›  watch-sim

@rr-codes rr-codes self-assigned this May 27, 2023
@rr-codes rr-codes added the Platform Portability improvements and other general platform improvements not driven directly by site bugs. label May 27, 2023
Copy link
Member

@pxlcoder pxlcoder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In Catalyst,

Remember that this is not just about Catalyst, the method can also return NO on iOS.

Source/WebCore/platform/ios/ColorIOS.mm Outdated Show resolved Hide resolved
Source/WebCore/platform/ios/ColorIOS.mm Outdated Show resolved Hide resolved
Source/WebCore/platform/ios/ColorIOS.mm Outdated Show resolved Hide resolved
@rr-codes rr-codes added the merge-queue Applied to send a pull request to merge-queue label May 27, 2023
@webkit-ews-buildbot webkit-ews-buildbot added merging-blocked Applied to prevent a change from being merged and removed merge-queue Applied to send a pull request to merge-queue labels May 27, 2023
@rr-codes rr-codes added merge-queue Applied to send a pull request to merge-queue and removed merging-blocked Applied to prevent a change from being merged labels May 27, 2023
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
@webkit-commit-queue
Copy link
Collaborator

Committed 264619@main (d4bad90): https://commits.webkit.org/264619@main

Reviewed commits have been landed. Closing PR #14414 and removing active labels.

@webkit-commit-queue webkit-commit-queue removed the merge-queue Applied to send a pull request to merge-queue label May 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Platform Portability improvements and other general platform improvements not driven directly by site bugs.
Projects
None yet
5 participants