RESOLVED FIXED 213706
Remove remaining makeSimpleColorFrom* variants
https://bugs.webkit.org/show_bug.cgi?id=213706
Summary Remove remaining makeSimpleColorFrom* variants
Sam Weinig
Reported 2020-06-28 16:44:18 PDT
Remove remaining makeSimpleColorFrom* variants
Attachments
Patch (44.52 KB, patch)
2020-06-28 17:10 PDT, Sam Weinig
no flags
Patch (44.53 KB, patch)
2020-06-28 18:04 PDT, Sam Weinig
no flags
Patch (44.88 KB, patch)
2020-06-29 11:07 PDT, Sam Weinig
no flags
Sam Weinig
Comment 1 2020-06-28 17:10:53 PDT Comment hidden (obsolete)
Sam Weinig
Comment 2 2020-06-28 18:04:24 PDT
Darin Adler
Comment 3 2020-06-29 09:35:28 PDT
Comment on attachment 403020 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=403020&action=review > Source/WebCore/html/canvas/CanvasRenderingContext2DBase.cpp:918 > + if (state().strokeStyle.isValid() && state().strokeStyle.isEquivalent(color)) Seems awkward that we need to explicitly check isValid. Why does isEquivalent ever return true when isValid is false? Wish invalid color was a little more like Optional's nullopt. > Source/WebCore/html/canvas/CanvasStyle.h:74 > CMYKAColor(const CMYKAColor&) = default; Why is this needed? > Source/WebCore/platform/graphics/ColorUtilities.h:38 > +template<typename> struct CMYKA; Alphabetical order, please > Source/WebCore/platform/graphics/ColorUtilities.h:67 > - return std::clamp(static_cast<int>(std::lroundf(f)), 0, 255); > + return std::clamp(static_cast<int>(std::round(f)), 0, 255); I think maybe std::lround would be better than std::round. Since the library can round and convert to int in a single operation, why not do it? Or if we are trying to make this work for values larger or smaller than an int, then we should not cast to int, and need a clamp that takes a floating point value as an argument. > Source/WebCore/platform/graphics/ColorUtilities.h:72 > - return std::clamp(static_cast<int>(std::lroundf(f * 255.0f)), 0, 255); > + return std::clamp(static_cast<int>(std::round(f * 255.0f)), 0, 255); Ditto.
Sam Weinig
Comment 4 2020-06-29 10:29:53 PDT
(In reply to Darin Adler from comment #3) > Comment on attachment 403020 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=403020&action=review > > > Source/WebCore/html/canvas/CanvasRenderingContext2DBase.cpp:918 > > + if (state().strokeStyle.isValid() && state().strokeStyle.isEquivalent(color)) > > Seems awkward that we need to explicitly check isValid. Why does > isEquivalent ever return true when isValid is false? Wish invalid color was > a little more like Optional's nullopt. Looks like this isValid() is totally not needed. isEquivalent() will return false already is the CanvasStyle is in the invalid state. Removed a bunch of these. > > > Source/WebCore/html/canvas/CanvasStyle.h:74 > > CMYKAColor(const CMYKAColor&) = default; > > Why is this needed? I am not sure. Will try removing it. > > > Source/WebCore/platform/graphics/ColorUtilities.h:38 > > +template<typename> struct CMYKA; > > Alphabetical order, please Fixed. > > > Source/WebCore/platform/graphics/ColorUtilities.h:67 > > - return std::clamp(static_cast<int>(std::lroundf(f)), 0, 255); > > + return std::clamp(static_cast<int>(std::round(f)), 0, 255); > > I think maybe std::lround would be better than std::round. Since the library > can round and convert to int in a single operation, why not do it? > > Or if we are trying to make this work for values larger or smaller than an > int, then we should not cast to int, and need a clamp that takes a floating > point value as an argument. > > > Source/WebCore/platform/graphics/ColorUtilities.h:72 > > - return std::clamp(static_cast<int>(std::lroundf(f * 255.0f)), 0, 255); > > + return std::clamp(static_cast<int>(std::round(f * 255.0f)), 0, 255); > > Ditto. Fixed.
Sam Weinig
Comment 5 2020-06-29 11:07:04 PDT
EWS
Comment 6 2020-06-29 13:31:50 PDT
Committed r263688: <https://trac.webkit.org/changeset/263688> All reviewed patches have been landed. Closing bug and clearing flags on attachment 403088 [details].
Radar WebKit Bug Importer
Comment 7 2020-06-29 13:57:07 PDT
Note You need to log in before you can comment on or make changes to this bug.