Page MenuHomePhabricator

Bug 1814620 - [devtools] Remove color.js rgbToColorName. r=ochameau.
ClosedPublic

Authored by nchevobbe on Feb 6 2023, 5:48 PM.
Referenced Files
Unknown Object (File)
Thu, May 1, 7:02 AM
Unknown Object (File)
Tue, Apr 29, 3:29 AM
Unknown Object (File)
Thu, Apr 17, 9:52 AM
Unknown Object (File)
Wed, Apr 16, 10:50 PM
Unknown Object (File)
Apr 9 2025, 10:23 PM
Unknown Object (File)
Apr 4 2025, 8:56 AM
Unknown Object (File)
Apr 4 2025, 1:35 AM
Unknown Object (File)
Apr 2 2025, 6:37 AM
Subscribers

Details

Summary

Make the callsites call InspectorUtils.rgbToColorName instead.
Since it was throwing when passed a non-valid named color,
which wasn't the expected outcome in DevTools, modify the
c++ method so it return an empty string instead.
Add a dedicated test since there wasn't one.

Diff Detail

Repository
rMOZILLACENTRAL mozilla-central
Lint
Lint Not Applicable
Unit
Tests Not Applicable
Build Status
Buildable 505035
Build 601388: arc lint + arc unit

Event Timeline

phab-bot published this revision for review.Feb 6 2023, 5:50 PM
phab-bot changed the visibility from "Custom Policy" to "Public (No Login Required)".
phab-bot changed the edit policy from "Custom Policy" to "Restricted Project (Project)".
phab-bot removed a project: secure-revision.

praise: Great work, thanks for tweaking the c++ to avoid the intermediate workaround!

devtools/client/shared/test/xpcshell/test_cssColorDatabase.js
20

nitpick: This test is only assertion cases where isValidCssColor return true, should it also cover one or some case(s) where it returns false? May be it is already covered by layout mochitests?

This revision is now accepted and ready to land.Feb 7 2023, 8:07 AM
nchevobbe added inline comments.
devtools/client/shared/test/xpcshell/test_cssColorDatabase.js
20

yes, the layout test checking those https://searchfox.org/mozilla-central/search?q=is+not+a+valid+color&path=layout&case=false&regexp=false
It makes me think I should probably move this check on transparent there and only check the colors from the database here

nchevobbe edited the summary of this revision. (Show Details)
nchevobbe marked an inline comment as done.

address review comment

evilpie added inline comments.
layout/inspector/InspectorUtils.cpp
513–514

Truncate is better.

layout/inspector/InspectorUtils.cpp
513–514

oh shoot, I'll fix that in a follow up
Why is it better?

layout/inspector/InspectorUtils.cpp
513–514

It's a lot simpler and probably more efficient. And just what we usually do to make something an empty string.

This revision is now accepted and ready to land.Feb 7 2023, 10:29 AM

use Truncate instead of AssignASCII