Closed Bug 760345 Opened 12 years ago Closed 5 years ago

change 'currentColor' keyword to be a computed value (except for 'color' property)

Categories

(Core :: CSS Parsing and Computation, defect, P3)

defect

Tracking

()

RESOLVED FIXED
mozilla68
Tracking Status
firefox68 --- fixed

People

(Reporter: dbaron, Assigned: emilio)

References

()

Details

(Keywords: dev-doc-complete, Whiteboard: [stylo])

Attachments

(2 files)

At the Hamburg Face-to-Face meeting earlier this month the CSS WG agreed to change currentColor so that it's a computed value (by changing the computed value lines of the properties that accept it).

We should change our implementation to match.

This is easy for:
 * border-color
 * outline-color
 * column-rule-color
 * text-decoration-color
since we already have an implementation of this concept under a different name.  It'll require a drop more work for things already stored in some sort of union or structure:
 * fill
 * stroke
 * gradient color stops
 * shadow colors
and a little more still for the things we just store as nscolor:
 * background-color 
 *-moz-border-*-colors
 * flood-color
 * lighting-color
 * stop-color

This is a pretty useful simplification for the first four properties, though a bit more work for the others.

Might want to wait until after bug 629882 lands.
No longer blocks: 1247777
Depends on: 1260543
A few notes:
 - we've already done this for text-emphasis-color, text-decoration-color, and -webkit-text-fill-color
 - we already have an implementation of this concept under another name (-moz-use-text-color) for border-color
 - it requires additional per-property code (like for the above properties) for all other CSS properties that take colors
Depends on: 1266621
I think we probably shouldn't make any more properties do this until we have the ability to interpolate between currentcolor and real colors.  Otherwise we risk making the web depend on them *not* being interpolable, when we actually want them to be interpolable.  See bug 1260543 and https://lists.w3.org/Archives/Public/www-style/2016Apr/0284.html .
No longer blocks: css-text-emphasis
Hmmmm... currentcolor is so hard...

I think we have three choices:
1. make stylo follow how gecko handle it currently (so access nsStyleColor when needed)
2. follow the WebKit way (which was implemented in bug 1260543 comment 15) and turn all currentcolor (except for 'color') to the real used-value time currentcolor
3. implement an internal version of blend() function (and push CSSWG to standardize it)

The thrid way needs lots of work, but might be the best thing to do in long term.

dbaron, what do you think?
Flags: needinfo?(dbaron)
(In reply to Xidorn Quan [:xidorn] (UTC+10) from comment #6)
> Hmmmm... currentcolor is so hard...
> 
> I think we have three choices:
> 1. make stylo follow how gecko handle it currently (so access nsStyleColor
> when needed)
> 2. follow the WebKit way (which was implemented in bug 1260543 comment 15)
> and turn all currentcolor (except for 'color') to the real used-value time
> currentcolor
> 3. implement an internal version of blend() function (and push CSSWG to
> standardize it)
> 
> The thrid way needs lots of work, but might be the best thing to do in long
> term.

So I believe current specs call for (2).

Is the reason you're suggesting (3) so that animation works better with 'currentcolor' values?  (That is a known risk for switching to what the spec wants.)

But for animation, what's wrong with the standardized version at https://drafts.csswg.org/css-color-4/#blend-adjuster other than complexity?
Flags: needinfo?(dbaron)
Per discussion with dbaron on IRC:

The current spec calls for making currentcolor not interpolatable with other color value, which isn't what we want.

We can follow the WebKit way to treat currentcolor as a static value of "color" property at a given moment, which should not cause bigger compatibility issue in the future than our current behavior. But before we start implementing that way, we should bring it up in www-style to let other vendors know that we are going this way.
Flags: needinfo?(bugs)
I'm going to work on this.
Assignee: nobody → xidorn+moz
Flags: needinfo?(bugs)
It looks like Blink implements the full interpolation of currentcolor. I'm going to go that way as well. I think we can implement that without fully implementing blend() function. (The only issue is getComputedStyle(). But I guess it's fine to make resolved value of color properties to be used value later.)
(In reply to David Baron :dbaron: ⌚️UTC-7 (review requests must explain patch) from comment #7)
> But for animation, what's wrong with the standardized version at
> https://drafts.csswg.org/css-color-4/#blend-adjuster other than complexity?

It seems the spec still doesn't say anything about how currentcolor should be interpolated with a numeric color value.

The current interpolation approach for color value defined in CSS Transitions doesn't use this blenda function. Instead, it just does a linear interpolation on premultipled color channels. That means if we use blenda for interpolation between currentcolor value and numeric color value, we would have inconsistent behavior.

In addition, it doesn't seem to me that the blenda function is something stable enough in the spec. There is still an issue calls for potential better formula [1] (as the current formula of blenda was determined empirically without any theory support), and I don't quite agree with some part of the current algorithm (the part how alpha channel is computed).

I'd probably go with linear interpolation on premultipled color channels, then.


[1] https://github.com/w3c/csswg-drafts/issues/305
Looks like Blink is using linear interpolation on premultipled color, FWIW.
Depends on: 1299741
Priority: -- → P3
Depends on: 1326209
Priority: P3 → P2
Summary: change 'currentColor' keyword to be a computed value (except for 'color' property) → stylo: implement currentColor
This is not a stylo bug.
Priority: P2 → P3
Summary: stylo: implement currentColor → change 'currentColor' keyword to be a computed value (except for 'color' property)
Blocks: 1345709
(In reply to Xidorn Quan [:xidorn] (UTC+10) from comment #13)
> This is not a stylo bug.

Oh I see, I didn't read the bug history carefully enough. Filed bug 1345709 for the stylo work item.
No longer blocks: stylo
Whiteboard: [stylo]
Depends on: 1457353
Depends on: 1467379
Depends on: 1467621
Depends on: 1467622
Assignee: xidorn+moz → nobody
Assignee: nobody → emilio

We don't have lossy currentcolor in the style system anymore, except for a
single property -moz-font-smoothing-background-color.

I could've converted it into a proper StyleColor and thread down all the
necessary information to the font metrics code.

But it doesn't really seem worth it given it's not exposed to the web, so I just
did the simplest thing, which is making currentcolor compute to transparent to
that specific property.

This patch also removes the stores_complex_colors_lossily code and related,
since now we always can cache computed colors.

The text-decoration-line is a drive-by thing, but I can put it in a separate
patch if you want. It was needed for Servo (to compute
-servo-text-decorations-in-effect), but I moved Servo away from that model a
while ago.

It's OK for now, but is the kind of thing that helps reviewers (well, me at least) determine which changes are not related to the others.

Pushed by ealvarez@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/1ea4b3582033
Remove the last usage of lossy currentcolor. r=heycam
Attachment #9055903 - Attachment description: Bug 760345 - Remove the last usage of lossy currentcolor. r=#style → Bug 760345 - Remove the last usage of lossy currentcolor. r=heycam
Flags: needinfo?(emilio)
Pushed by ealvarez@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/0550767ec778
Remove the last usage of lossy currentcolor. r=heycam
Pushed by ealvarez@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/08f256aa338a
Make color and text-decoration-line not early properties. r=heycam
Status: NEW → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla68

Added to the release notes for 68.

You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: