RESOLVED FIXED 214226
Tidy up color usage in accessibility code
https://bugs.webkit.org/show_bug.cgi?id=214226
Summary Tidy up color usage in accessibility code
Sam Weinig
Reported 2020-07-11 20:20:54 PDT
Tidy up color usage in accessibility code
Attachments
Patch (8.64 KB, patch)
2020-07-11 20:22 PDT, Sam Weinig
no flags
Patch (9.44 KB, patch)
2020-07-12 09:43 PDT, Sam Weinig
no flags
Patch (9.46 KB, patch)
2020-07-12 10:56 PDT, Sam Weinig
no flags
Patch (9.37 KB, patch)
2020-07-12 11:00 PDT, Sam Weinig
no flags
Patch (9.37 KB, patch)
2020-07-12 11:03 PDT, Sam Weinig
no flags
Sam Weinig
Comment 1 2020-07-11 20:22:35 PDT Comment hidden (obsolete)
Darin Adler
Comment 2 2020-07-12 08:57:13 PDT
Comment on attachment 404085 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=404085&action=review > Source/WebCore/accessibility/AccessibilityNodeObject.cpp:1997 > + SRGBA<uint8_t> result { 0, 0, 0, 0 }; I don’t see why this function benefits from a local variable. But if we did keep it, is there no "tidier" way to write this? Related: Is there a significant downside to having a structure like SRGBA be initialized by default? I would prefer one of these: SRGBA<uint8_t> result = Color::transparentBlack; auto result = Color::transparentBlack; SRGBA<uint8_t> result = { }; SRGBA<uint8_t> result { }; SRGBA<uint8_t> result; // <initialized to transparent black because we change SRGBA to just do that> > Source/WebCore/accessibility/AccessibilityNodeObject.cpp:2001 > + return result; I propose one of these: return Color::transparentBlack; return { }; > Source/WebCore/accessibility/AccessibilityNodeObject.cpp:2004 > + return result; Ditto. > Source/WebCore/accessibility/AccessibilityNodeObject.cpp:2006 > + result = downcast<HTMLInputElement>(*node()).valueAsColor().toSRGBALossy<uint8_t>(); I propose: return downcast ... > Source/WebCore/accessibility/AccessibilityNodeObject.cpp:2009 > + return result; I propose one of these: return Color::transparentBlack; return { }; But also changing structure a bit perhaps.
Sam Weinig
Comment 3 2020-07-12 09:43:56 PDT Comment hidden (obsolete)
Darin Adler
Comment 4 2020-07-12 09:58:39 PDT
Comment on attachment 404102 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=404102&action=review My comments on the previous patch still apply to this one. > Source/WebCore/accessibility/ios/WebAccessibilityObjectWrapperIOS.mm:1425 > + auto color = self.axBackingObject->colorValue(); Build failures seems to be because this is missing the call to convertToComponentFloats.
Sam Weinig
Comment 5 2020-07-12 10:56:34 PDT Comment hidden (obsolete)
Sam Weinig
Comment 6 2020-07-12 11:00:44 PDT
Sam Weinig
Comment 7 2020-07-12 11:01:25 PDT
(In reply to Darin Adler from comment #2) > Comment on attachment 404085 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=404085&action=review > > > Source/WebCore/accessibility/AccessibilityNodeObject.cpp:1997 > > + SRGBA<uint8_t> result { 0, 0, 0, 0 }; > > I don’t see why this function benefits from a local variable. > > But if we did keep it, is there no "tidier" way to write this? Related: Is > there a significant downside to having a structure like SRGBA be initialized > by default? I would prefer one of these: > > SRGBA<uint8_t> result = Color::transparentBlack; > auto result = Color::transparentBlack; > SRGBA<uint8_t> result = { }; > SRGBA<uint8_t> result { }; > SRGBA<uint8_t> result; // <initialized to transparent black because we > change SRGBA to just do that> > > > Source/WebCore/accessibility/AccessibilityNodeObject.cpp:2001 > > + return result; > > I propose one of these: > > return Color::transparentBlack; > return { }; > > > Source/WebCore/accessibility/AccessibilityNodeObject.cpp:2004 > > + return result; > > Ditto. > > > Source/WebCore/accessibility/AccessibilityNodeObject.cpp:2006 > > + result = downcast<HTMLInputElement>(*node()).valueAsColor().toSRGBALossy<uint8_t>(); > > I propose: > > return downcast ... > > > Source/WebCore/accessibility/AccessibilityNodeObject.cpp:2009 > > + return result; > > I propose one of these: > > return Color::transparentBlack; > return { }; > > But also changing structure a bit perhaps. Reworked it to remove the local variable and use early returns of Color::transparent;
Sam Weinig
Comment 8 2020-07-12 11:03:01 PDT
EWS
Comment 9 2020-07-12 12:46:04 PDT
Committed r264284: <https://trac.webkit.org/changeset/264284> All reviewed patches have been landed. Closing bug and clearing flags on attachment 404109 [details].
Radar WebKit Bug Importer
Comment 10 2020-07-12 12:47:15 PDT
Note You need to log in before you can comment on or make changes to this bug.