Closed
Bug 924136
Opened 12 years ago
Closed 12 years ago
css-color.js interprets "inherit" as black
Categories
(DevTools :: Inspector, defect)
Tracking
(firefox26 unaffected, firefox27+ verified)
VERIFIED
FIXED
Firefox 27
Tracking | Status | |
---|---|---|
firefox26 | --- | unaffected |
firefox27 | + | verified |
People
(Reporter: miker, Assigned: miker)
References
Details
Attachments
(1 file, 4 obsolete files)
9.70 KB,
patch
|
jwalker
:
review+
|
Details | Diff | Splinter Review |
let {devtools} = Cu.import("resource://gre/modules/devtools/Loader.jsm", {});
let {colorUtils} = devtools.require("devtools/css-color");
let color = new colorUtils.CssColor("inherit");
color will have been interpreted as rgb(0, 0, 0). We need to treat it specially and always return "inherit" when it is used (similar to transparent).
Assignee | ||
Updated•12 years ago
|
Summary: cssColor.js interprets "inherit" incorrectly → css-color.js interprets "inherit" as black
Assignee | ||
Comment 1•12 years ago
|
||
Another simple one:
- Moved check for invalid color, "transparent" and "inherit" into a function.
- Return these values if necessary from each color type.
- Added "inherit" to browser/devtools/shared/test/browser_css_color.js
Attachment #814380 -
Flags: review?(jwalker)
Comment 2•12 years ago
|
||
Do other keywords like "initial", "unset" (bug 921731) need special treatment too?
Assignee | ||
Comment 3•12 years ago
|
||
(In reply to Robert Longson from comment #2)
> Do other keywords like "initial", "unset" (bug 921731) need special
> treatment too?
I had checked the specs but only found "transparent" and "initial" but I agree that initial should receive this treatment.
I don't believe a color can be unset.
Assignee | ||
Comment 4•12 years ago
|
||
stand corrected, unset === initial when it comes to colors. I will add both.
Assignee | ||
Comment 5•12 years ago
|
||
Added initial and unset.
Attachment #814380 -
Attachment is obsolete: true
Attachment #814380 -
Flags: review?(jwalker)
Attachment #814425 -
Flags: review?(jwalker)
Assignee | ||
Comment 6•12 years ago
|
||
Simplified variable name as an afterthought.
Attachment #814425 -
Attachment is obsolete: true
Attachment #814425 -
Flags: review?(jwalker)
Attachment #814428 -
Flags: review?(jwalker)
Comment 7•12 years ago
|
||
There is one other keyword: currentColor http://www.w3.org/TR/css3-color/#currentcolor I think you should test that too.
Comment 8•12 years ago
|
||
I'm not sure if the bug is still there, but I've one seen transition:all 0.3s; replaced by transition:#000 0.3s;
Comment 9•12 years ago
|
||
I think black listing those keywords is not a powerful way to solve this bug. It'll be not convenient for future implementations. I suggest you whitelist the color names instead.
Assignee | ||
Comment 10•12 years ago
|
||
Comment on attachment 814428 [details] [diff] [review]
Simplified variable name
I agree, a color name list is a better fix.
Attachment #814428 -
Flags: review?(jwalker)
Assignee | ||
Comment 11•12 years ago
|
||
We now build the special color value list by doing the following:
1. Get all autocompletion values for color.
2. Remove all HTML, rgb, rgba, hsl, hsla and system colors from the list.
This way we are future proof.
Attachment #814428 -
Attachment is obsolete: true
Attachment #815357 -
Flags: review?(jwalker)
Comment 12•12 years ago
|
||
Comment on attachment 815357 [details] [diff] [review]
Made special color values list dynamic
Review of attachment 815357 [details] [diff] [review]:
-----------------------------------------------------------------
I find the definition of _getRGBATuple to be bizarre. It returns either a string or dictionary depending on something. Isn't there a way to specify 'transparent' in the tuple?
i.e. sometimes _getRGBATuple doesn't return a tuple. So it should be called _getRGBATupleOrStringDependingOnStuff() which should set alarm bells off.
What do you think?
::: toolkit/devtools/css-color.js
@@ +116,5 @@
> + return "transparent";
> + }
> + if (SPECIALVALUES.has(this.authored)) {
> + return this.authored;
> + }
Isn't "transparent" a special value?
@@ +428,5 @@
> loader.lazyGetter(this, "DOMUtils", function () {
> return Cc["@mozilla.org/inspector/dom-utils;1"].getService(Ci.inIDOMUtils);
> });
> +
> +loader.lazyGetter(this, "SPECIALVALUES", function () {
This needs some explanation as to what's going on.
I'm also concerned that new system colors will magically be marked 'special', so how is this code better than:
const SPECIALVALUES = new Set([ 'inherit', 'initial', 'transparent', 'unset' ]);
@@ +486,5 @@
> + let allColorValues = DOMUtils.getCSSValuesForProperty("color");
> +
> + // Remove all color names in the HTML color table, rgb, rgba, hsl and hsla.
> + let specialValues = allColorValues.filter(function(color) {
> + return !(HTMLCOLORS.has(color) || color.contains("rgb") || color.contains("hsl"));
What if there is a color called roughslate. Shouldn't we test against the strings exactly?
Attachment #815357 -
Flags: review?(jwalker)
Assignee | ||
Comment 13•12 years ago
|
||
(In reply to Joe Walker [:jwalker] from comment #12)
> Comment on attachment 815357 [details] [diff] [review]
> Made special color values list dynamic
>
> Review of attachment 815357 [details] [diff] [review]:
> -----------------------------------------------------------------
>
> I find the definition of _getRGBATuple to be bizarre. It returns either a
> string or dictionary depending on something. Isn't there a way to specify
> 'transparent' in the tuple?
> i.e. sometimes _getRGBATuple doesn't return a tuple. So it should be called
> _getRGBATupleOrStringDependingOnStuff() which should set alarm bells off.
> What do you think?
>
Ew, ugly hack, changed to return {r:0, g:0, b:0, a:0}
> ::: toolkit/devtools/css-color.js
> @@ +116,5 @@
> > + return "transparent";
> > + }
> > + if (SPECIALVALUES.has(this.authored)) {
> > + return this.authored;
> > + }
>
> Isn't "transparent" a special value?
>
Yes, we were also processing e.g. rgba(0, 0, 0, 0) as "transparent." We now only treat "transparent" as "transparent."
> @@ +428,5 @@
> > loader.lazyGetter(this, "DOMUtils", function () {
> > return Cc["@mozilla.org/inspector/dom-utils;1"].getService(Ci.inIDOMUtils);
> > });
> > +
> > +loader.lazyGetter(this, "SPECIALVALUES", function () {
>
> This needs some explanation as to what's going on.
>
Not any more, I have removed it.
> I'm also concerned that new system colors will magically be marked
> 'special', so how is this code better than:
>
> const SPECIALVALUES = new Set([ 'inherit', 'initial', 'transparent',
> 'unset' ]);
>
I weighed up whether a new special value or -moz prefixed special color is most likely to be added and decided to calculate from there. e.g. 'all' was a special value for a few days. At the same time currentcolor is missing from the autocomplete list (bug 927367 logged).
A short list is more easily maintained and that has to win out.
Changed to:
const SPECIALVALUES = new Set([
"currentcolor",
"initial",
"inherit",
"transparent",
"unset"
]);
> @@ +486,5 @@
> > + let allColorValues = DOMUtils.getCSSValuesForProperty("color");
> > +
> > + // Remove all color names in the HTML color table, rgb, rgba, hsl and hsla.
> > + let specialValues = allColorValues.filter(function(color) {
> > + return !(HTMLCOLORS.has(color) || color.contains("rgb") || color.contains("hsl"));
>
> What if there is a color called roughslate. Shouldn't we test against the
> strings exactly?
That was what HTMLCOLORS.has(color) did but as we no longer generate the list this is not important.
Attachment #815357 -
Attachment is obsolete: true
Attachment #817828 -
Flags: review?(jwalker)
Comment 14•12 years ago
|
||
Comment on attachment 817828 [details] [diff] [review]
Fixed special values
Review of attachment 817828 [details] [diff] [review]:
-----------------------------------------------------------------
Thanks.
Attachment #817828 -
Flags: review?(jwalker) → review+
Assignee | ||
Updated•12 years ago
|
Keywords: checkin-needed
Comment 15•12 years ago
|
||
Comment 16•12 years ago
|
||
Status: NEW → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
Whiteboard: [fixed-in-fx-team]
Target Milestone: --- → Firefox 27
Updated•12 years ago
|
Comment 17•12 years ago
|
||
Is there any help needed for manual testing here? If yes can you please provide some steps in order to reproduce and verify that this is fixed?
Flags: needinfo?(mratcliffe)
Assignee | ||
Comment 18•12 years ago
|
||
(In reply to Bogdan Maris, QA [:bogdan_maris] from comment #17)
> Is there any help needed for manual testing here? If yes can you please
> provide some steps in order to reproduce and verify that this is fixed?
Sure:
1. Open http://fiddle.jshell.net/5rNrx/show/
2. Right-click the page and choose inspect element
3. In the markup panel select the body tag
4. Ensure that in the rule view it displays background-color as inherit (not black).
Flags: needinfo?(mratcliffe)
Comment 19•12 years ago
|
||
Thanks Michael,
Backgrould-color is displayed as inherit so this is verified as fixed using the latest Aurora 27.0a2 (buildID: 20131203004003) on Windows 7 x64, Ubuntu 12.04 x64 and Mac OS X 10.8.5.
Updated•7 years ago
|
Product: Firefox → DevTools
You need to log in
before you can comment on or make changes to this bug.
Description
•