DrawGlyphsRecorder::recordDrawGlyphs() has code that converts CGColors to Colors, via Color::createAndPreserveColorSpace(). However, if the CSS color is, say #FF0000, which is inline, this CG-related code will make an out-of-line sRGB color, which will then compare as different to the inline color.
<rdar://problem/88345680>
I think heycam did this deliberately for https://trac.webkit.org/changeset/281470/webkit (https://bugs.webkit.org/show_bug.cgi?id=229024). I believe the issue is that the colors lose state when when they go into the CGContextDelegateRef so we don't know what they originally were and so we err on the side of more bits.
Perhaps the thing to fix here is whatever code is doing the comparison you mention. Where is that?
That's just Color's operator==
Simon, where is the display list code doing the comparison of colors, and what does it use it for? If it's important for Color::operator== to distinguish equivalent colors specified using different syntaxes, we could add a different comparison function.
I found this while investigating rdar://84602660. It affects the behavior of updateGraphicsContext(GraphicsContext& context, const TextPaintStyle& paintStyle, FillColorType fillColorType).
Specifically the fill colors compare as different here: if (mode.contains(TextDrawingMode::Fill) && (fillColor != context.fillColor())) context.setFillColor(fillColor);
When Cameron wrote that code, we were using bounded SRGB for both color(srgb ...) and legacy rgb. Now, we use extended sRGB for color(srgb ) but still use bounded sRGB for legacy. So, we could consider smuggling / encoding whether to use 8-bit / inline based on whether the CGColorRef is using bounded sRGB or extended sRGB for the color space.
*** Bug 239953 has been marked as a duplicate of this bug. ***
Created attachment 458775 [details] Patch
Created attachment 458827 [details] Patch
Committed r293867 (250329@main): <https://commits.webkit.org/250329@main> All reviewed patches have been landed. Closing bug and clearing flags on attachment 458827 [details].