RESOLVED FIXED 214514
Additional Color related cleanups
https://bugs.webkit.org/show_bug.cgi?id=214514
Summary Additional Color related cleanups
Sam Weinig
Reported 2020-07-17 20:53:16 PDT
Additional Color related cleanups
Attachments
Patch (9.01 KB, patch)
2020-07-17 20:58 PDT, Sam Weinig
no flags
Patch (8.96 KB, patch)
2020-07-19 10:14 PDT, Sam Weinig
no flags
Sam Weinig
Comment 1 2020-07-17 20:58:22 PDT
Darin Adler
Comment 2 2020-07-19 08:38:53 PDT
Comment on attachment 404634 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=404634&action=review > Source/WebCore/platform/graphics/ColorUtilities.h:97 > + return std::clamp(component, static_cast<ComponentType>(0), static_cast<ComponentType>(255)); Could this be written this way instead? return std::clamp<ComponentType>(component, 0, 255); Are there disadvantages to writing it this way? > Source/WebCore/platform/graphics/ColorUtilities.h:102 > + return std::clamp(component, static_cast<ComponentType>(0.0), static_cast<ComponentType>(1.0)); Could this be written this way instead? return std::clamp<ComponentType>(component, 0, 1); Are there disadvantages to writing it this way? > Source/WebCore/platform/graphics/ColorUtilities.h:153 > + copy.red = std::invoke(functor, color.red); > + copy.green = std::invoke(functor, color.green); > + copy.blue = std::invoke(functor, color.blue); No forwarding, not even on the third call? I wish I understood universal references better.
Sam Weinig
Comment 3 2020-07-19 10:12:49 PDT
(In reply to Darin Adler from comment #2) > Comment on attachment 404634 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=404634&action=review > > > Source/WebCore/platform/graphics/ColorUtilities.h:97 > > + return std::clamp(component, static_cast<ComponentType>(0), static_cast<ComponentType>(255)); > > Could this be written this way instead? > > return std::clamp<ComponentType>(component, 0, 255); > > Are there disadvantages to writing it this way? > > > Source/WebCore/platform/graphics/ColorUtilities.h:102 > > + return std::clamp(component, static_cast<ComponentType>(0.0), static_cast<ComponentType>(1.0)); > > Could this be written this way instead? > > return std::clamp<ComponentType>(component, 0, 1); > > Are there disadvantages to writing it this way? You know, I am not sure. It just didn't occur to me. Seems like your proposal is better, and the literals should convert cleanly. > > > Source/WebCore/platform/graphics/ColorUtilities.h:153 > > + copy.red = std::invoke(functor, color.red); > > + copy.green = std::invoke(functor, color.green); > > + copy.blue = std::invoke(functor, color.blue); > > No forwarding, not even on the third call? I wish I understood universal > references better. Seems like I could forward it to the last one. Will change. Thanks for all the reviews.
Sam Weinig
Comment 4 2020-07-19 10:14:53 PDT
EWS
Comment 5 2020-07-19 10:59:09 PDT
Committed r264577: <https://trac.webkit.org/changeset/264577> All reviewed patches have been landed. Closing bug and clearing flags on attachment 404674 [details].
Radar WebKit Bug Importer
Comment 6 2020-07-19 11:00:23 PDT
Note You need to log in before you can comment on or make changes to this bug.